Compare commits
951 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45dbd5aa44 | ||
|
|
ee65251bf5 | ||
|
|
4d838d290d | ||
|
|
048efdf59f | ||
|
|
af2adeba13 | ||
|
|
93c6bec452 | ||
|
|
c944044465 | ||
|
|
8a63ca2310 | ||
|
|
12e5e3b35e | ||
|
|
553a85ef86 | ||
|
|
de7012cabf | ||
|
|
46f0d3ef74 | ||
|
|
c27c785ac2 | ||
|
|
4186c36f30 | ||
|
|
757e33dfb4 | ||
|
|
ab9bdf9f07 | ||
|
|
2e561697ac | ||
|
|
d242acd502 | ||
|
|
d37b44d3f6 | ||
|
|
e4c4d2bbf0 | ||
|
|
040d3e4433 | ||
|
|
b4f93fc0a5 | ||
|
|
c4e7807d18 | ||
|
|
8e55a4d824 | ||
|
|
c1e9fde6e8 | ||
|
|
32e80c7e95 | ||
|
|
c07a3b9d0d | ||
|
|
893d1a881d | ||
|
|
43ef130052 | ||
|
|
d5bea0ca53 | ||
|
|
9c740c5cc1 | ||
|
|
cf7535e2ba | ||
|
|
87afad29ce | ||
|
|
436233e735 | ||
|
|
6e367ddd74 | ||
|
|
fcdfaf5564 | ||
|
|
dff17fd11f | ||
|
|
85af73df99 | ||
|
|
c7a97711c0 | ||
|
|
ffbe05b2ae | ||
|
|
14f5d5daa4 | ||
|
|
f342cd6b56 | ||
|
|
8faacab53a | ||
|
|
659c327a6d | ||
|
|
bcc2f531c3 | ||
|
|
020df5c1f7 | ||
|
|
d6781e1d14 | ||
|
|
d42cd59880 | ||
|
|
be19c32fea | ||
|
|
8da0e98d23 | ||
|
|
73a2f05509 | ||
|
|
bb23f998e0 | ||
|
|
75915ff366 | ||
|
|
517e801580 | ||
|
|
12474e23f9 | ||
|
|
00bdd859a7 | ||
|
|
3a3af9ea00 | ||
|
|
1803b1a2ee | ||
|
|
4175c84363 | ||
|
|
1840d7b50e | ||
|
|
37b69833b3 | ||
|
|
093f766d1d | ||
|
|
69d8459b1c | ||
|
|
fa8a526642 | ||
|
|
1d35d951e6 | ||
|
|
3c0420f42f | ||
|
|
d000a825d3 | ||
|
|
23b28672d4 | ||
|
|
a076c9f420 | ||
|
|
bdc7a8f5ed | ||
|
|
bdcc3bb1f5 | ||
|
|
18d45aa1a3 | ||
|
|
b5bb8efe0a | ||
|
|
f18c18230b | ||
|
|
2fd1e998f4 | ||
|
|
c5a1980e0d | ||
|
|
d470ca4b47 | ||
|
|
35f450e444 | ||
|
|
206fb4e584 | ||
|
|
62088b36a4 | ||
|
|
aa5fd530d3 | ||
|
|
f0ee64bafa | ||
|
|
dfa413da6f | ||
|
|
9eb5e699e1 | ||
|
|
2d4c1b751e | ||
|
|
91b17ef4a2 | ||
|
|
9b748f7334 | ||
|
|
2deaed2067 | ||
|
|
fb608ed30a | ||
|
|
8e43afe408 | ||
|
|
73df680214 | ||
|
|
fa4aa154a3 | ||
|
|
cf7cdbc41b | ||
|
|
c2561a1de0 | ||
|
|
a36abe0272 | ||
|
|
5b10d697f6 | ||
|
|
e0f07ccc3b | ||
|
|
938ea8fb73 | ||
|
|
ea6a338128 | ||
|
|
ce3a668103 | ||
|
|
557c2b018a | ||
|
|
3add01d57e | ||
|
|
2ad1ea98f1 | ||
|
|
3121532217 | ||
|
|
20ac12ca0d | ||
|
|
f0b222140e | ||
|
|
2a35ca6094 | ||
|
|
93f9636916 | ||
|
|
2c24aba558 | ||
|
|
a35d7dc5ae | ||
|
|
1e9e7e4cd7 | ||
|
|
cfd97ebd3d | ||
|
|
3ac8dc5558 | ||
|
|
6f93440b11 | ||
|
|
9283f419ba | ||
|
|
be67b36b6a | ||
|
|
6934daecff | ||
|
|
3d74d027c1 | ||
|
|
e048235dad | ||
|
|
d21dff08b8 | ||
|
|
5f06c4c3c0 | ||
|
|
b693b34fe7 | ||
|
|
b7f469957c | ||
|
|
4a7b415635 | ||
|
|
d9985d03ab | ||
|
|
6e324fd5ab | ||
|
|
167498dd2c | ||
|
|
688eaf6aab | ||
|
|
d7df105e04 | ||
|
|
ea5c4cd027 | ||
|
|
9589706df9 | ||
|
|
e6e37aec47 | ||
|
|
fc2d5fe00e | ||
|
|
a73d3d375a | ||
|
|
ce97c8f7d9 | ||
|
|
a48abc56dd | ||
|
|
1044d7a8d1 | ||
|
|
fb0a075c50 | ||
|
|
8a8c785a31 | ||
|
|
4e976fc4ec | ||
|
|
cdf06578c1 | ||
|
|
4a131d6215 | ||
|
|
45f71cdcc1 | ||
|
|
5192175ddc | ||
|
|
274a672637 | ||
|
|
c281ab5a39 | ||
|
|
0106afc93c | ||
|
|
d69b091858 | ||
|
|
f71274d90d | ||
|
|
a37b9a1036 | ||
|
|
a9b8174b10 | ||
|
|
20a0eda5db | ||
|
|
e231dba0b0 | ||
|
|
d9459dc8fa | ||
|
|
a55ff5ce5a | ||
|
|
f2ea1cde46 | ||
|
|
04dd8003f7 | ||
|
|
b82b46f7d7 | ||
|
|
33bccd10fe | ||
|
|
9956f1ae4f | ||
|
|
09a3c5da23 | ||
|
|
b1d51bbefb | ||
|
|
9e7aaa6c91 | ||
|
|
9686c97731 | ||
|
|
663718ece4 | ||
|
|
e3048d1eb2 | ||
|
|
c6785bfda0 | ||
|
|
781438d83a | ||
|
|
f5625cc6b9 | ||
|
|
132d375d81 | ||
|
|
54007ecd28 | ||
|
|
03c2b55776 | ||
|
|
c6e46384f8 | ||
|
|
ce1c607f05 | ||
|
|
19bbe51f01 | ||
|
|
ff4a4eaf78 | ||
|
|
2cf08f74db | ||
|
|
cc6bbc9869 | ||
|
|
8d962516f4 | ||
|
|
ced4ca01cb | ||
|
|
1195323acd | ||
|
|
87b62aef70 | ||
|
|
ec89ba0155 | ||
|
|
0695103589 | ||
|
|
8d47b09e80 | ||
|
|
3cd156ae42 | ||
|
|
4a22f62ec5 | ||
|
|
9ad37b4412 | ||
|
|
9fcabcb05e | ||
|
|
db1ae6020d | ||
|
|
7e039c9055 | ||
|
|
db7482ff12 | ||
|
|
d63ae7cadd | ||
|
|
c4fa0d405e | ||
|
|
63fef3ab7c | ||
|
|
7019c07a6d | ||
|
|
006ea9844a | ||
|
|
d2bbfe01f1 | ||
|
|
86d8ff3c68 | ||
|
|
00dacc32df | ||
|
|
1c1bd9265e | ||
|
|
0bb090eee6 | ||
|
|
d2f3bfb2e3 | ||
|
|
634ce0dddf | ||
|
|
c82bacb037 | ||
|
|
3edfd0892a | ||
|
|
30c0fd600f | ||
|
|
ccb31de1ba | ||
|
|
a74b623c10 | ||
|
|
5808e8f321 | ||
|
|
4f3fef3bfe | ||
|
|
0c07e649bf | ||
|
|
fc2820ec11 | ||
|
|
312fb033e0 | ||
|
|
18bc4dc739 | ||
|
|
2b61b27271 | ||
|
|
58c9f75b91 | ||
|
|
790f1fb8a3 | ||
|
|
5c4f3f7fe4 | ||
|
|
86ead09080 | ||
|
|
0932507346 | ||
|
|
21f7b7120a | ||
|
|
473135bfc5 | ||
|
|
ce7960e5e9 | ||
|
|
3be96cf035 | ||
|
|
17c440ee43 | ||
|
|
5d881ca154 | ||
|
|
e4b29b3ff9 | ||
|
|
046aaa0649 | ||
|
|
f653c74ce8 | ||
|
|
0c73c55b9d | ||
|
|
8dec54e96f | ||
|
|
859ae966c8 | ||
|
|
5abf5d3367 | ||
|
|
0dc4e63b7a | ||
|
|
95d7ca5264 | ||
|
|
317252e1dd | ||
|
|
d9044b2d03 | ||
|
|
b6ae4e2b41 | ||
|
|
fce31df121 | ||
|
|
d5c1d86313 | ||
|
|
46df41504c | ||
|
|
48e232e04e | ||
|
|
58ff7c9235 | ||
|
|
730d664b91 | ||
|
|
36634ecca1 | ||
|
|
10c03ff01a | ||
|
|
e85b9db118 | ||
|
|
f6b0a7c780 | ||
|
|
3e785a2555 | ||
|
|
1cbb825892 | ||
|
|
82efa8298d | ||
|
|
c2ba716916 | ||
|
|
161bc5f69d | ||
|
|
b17237eb6b | ||
|
|
f61497ffd9 | ||
|
|
7f3c46942d | ||
|
|
4771882f50 | ||
|
|
345a1379ae | ||
|
|
33ab7f4d95 | ||
|
|
2a97cb34d7 | ||
|
|
03cbd8410f | ||
|
|
3c54bdd003 | ||
|
|
ba0a94e525 | ||
|
|
b439e0c2c2 | ||
|
|
f9281850ad | ||
|
|
4d5d25834e | ||
|
|
9e706ea096 | ||
|
|
46fe2bb8ac | ||
|
|
6405523232 | ||
|
|
930819ffa2 | ||
|
|
fa150e45ff | ||
|
|
400a2b14f7 | ||
|
|
a40322b2e7 | ||
|
|
de9c1017b3 | ||
|
|
2709d40fc0 | ||
|
|
45b42ad5bd | ||
|
|
878df24a64 | ||
|
|
b759f8d0a0 | ||
|
|
23e7aa2aaa | ||
|
|
fdd4f5abca | ||
|
|
c695468aec | ||
|
|
9166716f2a | ||
|
|
3407e74e99 | ||
|
|
6969f40fa0 | ||
|
|
11fc8b6642 | ||
|
|
4e4024c182 | ||
|
|
1d1931f721 | ||
|
|
ffad6a4ae6 | ||
|
|
4c5314fe59 | ||
|
|
96be49aa83 | ||
|
|
28b556121b | ||
|
|
558c19e526 | ||
|
|
59c2d20311 | ||
|
|
fa1f2cbf51 | ||
|
|
de8739f143 | ||
|
|
9aa28f6fd2 | ||
|
|
a2b1699047 | ||
|
|
2dce65a448 | ||
|
|
3d68d7c818 | ||
|
|
4987d43042 | ||
|
|
684b494edb | ||
|
|
714b708fa9 | ||
|
|
c462c19a8b | ||
|
|
e34acf010e | ||
|
|
0fb29174c5 | ||
|
|
ca45774cdb | ||
|
|
cccc2c4fe4 | ||
|
|
c73af2d45f | ||
|
|
acf7102d07 | ||
|
|
75fcd31758 | ||
|
|
7bffb5f22d | ||
|
|
c220bd5517 | ||
|
|
7c827b45d5 | ||
|
|
e91d9ee38e | ||
|
|
b6a86a6538 | ||
|
|
16b6b6c071 | ||
|
|
695feef4a6 | ||
|
|
6bf4e0cf89 | ||
|
|
44d8d0f246 | ||
|
|
e617e8d6d3 | ||
|
|
1f411b7530 | ||
|
|
d64bd9d9d3 | ||
|
|
f33dc8f797 | ||
|
|
e63ae12c8c | ||
|
|
cbd3d439cd | ||
|
|
83eb0d9f23 | ||
|
|
3c739eed8e | ||
|
|
d77646adf1 | ||
|
|
5b5e6cba57 | ||
|
|
8fc9b27840 | ||
|
|
fa536220eb | ||
|
|
98f16774c4 | ||
|
|
ce8f57c3ca | ||
|
|
be66106336 | ||
|
|
16c8641a07 | ||
|
|
d3e9ce874a | ||
|
|
aaf9c6a0bf | ||
|
|
c2276eb2cb | ||
|
|
5fbae1256b | ||
|
|
d61ba80bf6 | ||
|
|
74c9fa9488 | ||
|
|
ce732ccca0 | ||
|
|
6b99e360e0 | ||
|
|
1c73d54a94 | ||
|
|
36e21caf96 | ||
|
|
f7f9c53466 | ||
|
|
3f2ee2a925 | ||
|
|
b1c069f62f | ||
|
|
22d48fce8f | ||
|
|
6b2666c701 | ||
|
|
414f438762 | ||
|
|
54f60040b5 | ||
|
|
b0515033da | ||
|
|
d37eb07301 | ||
|
|
c2fa27712c | ||
|
|
10a2589c10 | ||
|
|
05eb96e7c0 | ||
|
|
15a08ad6ae | ||
|
|
3e437c2ecb | ||
|
|
fea667b87c | ||
|
|
93eaaac084 | ||
|
|
a60df582a2 | ||
|
|
aec1d4e0d6 | ||
|
|
507f2e883c | ||
|
|
5e82c75893 | ||
|
|
9c9a389aa5 | ||
|
|
1b3af70690 | ||
|
|
2e17efe82b | ||
|
|
9d1c4bd660 | ||
|
|
3b357eb509 | ||
|
|
5bed854b9c | ||
|
|
7262b403f0 | ||
|
|
a6fcbefc7b | ||
|
|
7f9ea0efa0 | ||
|
|
934861322e | ||
|
|
e008fbab9b | ||
|
|
2cd9ea19fd | ||
|
|
699a249620 | ||
|
|
6c87d5b0bc | ||
|
|
c92bdae842 | ||
|
|
6ca9608a80 | ||
|
|
8f9c0cbff1 | ||
|
|
cc6b114e4d | ||
|
|
3d5c2123d4 | ||
|
|
36b4e16b7c | ||
|
|
3ebd074e93 | ||
|
|
e9b2b545a4 | ||
|
|
cca6d5fa04 | ||
|
|
36a7a3ebbc | ||
|
|
48ec9a1ea9 | ||
|
|
76a9a0d1ab | ||
|
|
f2175b40c0 | ||
|
|
85b992ca32 | ||
|
|
41fb351fe0 | ||
|
|
b916d4016e | ||
|
|
abfd7f281d | ||
|
|
515d6ab2c9 | ||
|
|
8ee0dd9930 | ||
|
|
6b9fad493c | ||
|
|
a21297d209 | ||
|
|
db3183c6e2 | ||
|
|
9eaaf96abe | ||
|
|
365b6a410a | ||
|
|
a6a601c365 | ||
|
|
6ae52df8f8 | ||
|
|
993c139715 | ||
|
|
78ca36af11 | ||
|
|
078d0c9cf9 | ||
|
|
40602272da | ||
|
|
570d488bb3 | ||
|
|
de46cfe7ee | ||
|
|
8b5a985842 | ||
|
|
b57e4c520b | ||
|
|
ec6b8224ae | ||
|
|
c48cf83343 | ||
|
|
0c1ec2b0fc | ||
|
|
5d2c046d53 | ||
|
|
b0f221e5a7 | ||
|
|
85b8bc5d07 | ||
|
|
ae0aa370b2 | ||
|
|
d3e9dc2ea4 | ||
|
|
d5c7d8997f | ||
|
|
da797741f9 | ||
|
|
626d84eea3 | ||
|
|
4d2f32a082 | ||
|
|
c7cbe18afd | ||
|
|
d1eb76d960 | ||
|
|
4b49f7d7c1 | ||
|
|
fce73f6457 | ||
|
|
8d958329b9 | ||
|
|
70006b3cf4 | ||
|
|
fbdac9a7c0 | ||
|
|
8a08d58ed7 | ||
|
|
6dc8ee5cf0 | ||
|
|
b646cc00a3 | ||
|
|
7d2e70da7e | ||
|
|
83cc3d60c8 | ||
|
|
15ee102db4 | ||
|
|
ff25162834 | ||
|
|
4913332444 | ||
|
|
996f8f0f2e | ||
|
|
4851139ba5 | ||
|
|
f0380d7eff | ||
|
|
11356484b2 | ||
|
|
e6cd6617ba | ||
|
|
de176ec040 | ||
|
|
8a365250d9 | ||
|
|
9bd47e0410 | ||
|
|
02c15f896b | ||
|
|
150699f64d | ||
|
|
05ffc145be | ||
|
|
25d52c5a61 | ||
|
|
abc2fb0e40 | ||
|
|
54dfc32455 | ||
|
|
3802bc146f | ||
|
|
8b295f6a93 | ||
|
|
c115bcc163 | ||
|
|
88a3589f1d | ||
|
|
52dbd70c2f | ||
|
|
0b07e83e3c | ||
|
|
445ff89392 | ||
|
|
786914b1a6 | ||
|
|
a8a65e953f | ||
|
|
755f1e5747 | ||
|
|
d5d19c37d8 | ||
|
|
6f85afb841 | ||
|
|
3aed24fb49 | ||
|
|
2947cd3038 | ||
|
|
2849ac58cb | ||
|
|
a3ef1766a1 | ||
|
|
852bcbbb24 | ||
|
|
7438b6ce05 | ||
|
|
fcb301260c | ||
|
|
fc4dccb4e9 | ||
|
|
1f1fcf281d | ||
|
|
a0c5b75bba | ||
|
|
ccf4e4d285 | ||
|
|
15c570979b | ||
|
|
57f3715128 | ||
|
|
148986b454 | ||
|
|
179b08b96a | ||
|
|
d7f60fa95a | ||
|
|
564f052a2f | ||
|
|
8ff4eb2602 | ||
|
|
6e5197a3f5 | ||
|
|
2b8c713169 | ||
|
|
6a40a388b3 | ||
|
|
f52794e93c | ||
|
|
26e32ab584 | ||
|
|
5c3baa8575 | ||
|
|
ff4fe14f89 | ||
|
|
afc9682d53 | ||
|
|
9686ad6f00 | ||
|
|
ff21d1c4ec | ||
|
|
e1285fe738 | ||
|
|
889eea9c89 | ||
|
|
4a88ecc549 | ||
|
|
6eca4028ec | ||
|
|
5158f4bd89 | ||
|
|
eb7e255430 | ||
|
|
f6a70dc7ac | ||
|
|
4d447f9f01 | ||
|
|
6fa8406636 | ||
|
|
6d409168e3 | ||
|
|
5c10dae028 | ||
|
|
6a965ddb28 | ||
|
|
9b86052624 | ||
|
|
3c64d6675e | ||
|
|
9588ac8cbd | ||
|
|
5c05aaeacf | ||
|
|
238bc89be9 | ||
|
|
28a4d4164e | ||
|
|
19fe2e0eb5 | ||
|
|
862fb3c2e6 | ||
|
|
df34e921f3 | ||
|
|
44c1b5ebb4 | ||
|
|
a9454a1455 | ||
|
|
e9e419399c | ||
|
|
09db484d5e | ||
|
|
192737bab9 | ||
|
|
bb68f7b442 | ||
|
|
f46a9c5f3a | ||
|
|
27658eea20 | ||
|
|
eec21fc5c1 | ||
|
|
5d26743c8f | ||
|
|
3afa782e91 | ||
|
|
cfdc3a15c5 | ||
|
|
a2a7c26a42 | ||
|
|
7fb67be1b6 | ||
|
|
e8a225f97a | ||
|
|
54a914097d | ||
|
|
245e32237e | ||
|
|
29df122369 | ||
|
|
894900e955 | ||
|
|
632715e6c9 | ||
|
|
97c0fcf022 | ||
|
|
b3781abdeb | ||
|
|
1f7252fd12 | ||
|
|
3c0c4ce9c0 | ||
|
|
ed4c470bdc | ||
|
|
70db9ba94a | ||
|
|
3235141b2e | ||
|
|
2f9364561d | ||
|
|
8444188616 | ||
|
|
2d38733822 | ||
|
|
e6b574d13f | ||
|
|
2e26204a4e | ||
|
|
a932fd2cd9 | ||
|
|
a2d3b88c08 | ||
|
|
62a177fcb3 | ||
|
|
19c751d349 | ||
|
|
def2d5f494 | ||
|
|
94e9fa35e2 | ||
|
|
14be8d4936 | ||
|
|
38b550ecbb | ||
|
|
b8ecfb5455 | ||
|
|
f4c9d67178 | ||
|
|
ad4c65369d | ||
|
|
db6a53de84 | ||
|
|
fd25bd5934 | ||
|
|
33b2ec7ab1 | ||
|
|
cfb4c8d66a | ||
|
|
0797f1809a | ||
|
|
e8e1ab6637 | ||
|
|
1cb5e8134e | ||
|
|
246e3ee7d6 | ||
|
|
35e782884d | ||
|
|
e5e45fa40f | ||
|
|
f24aa5af06 | ||
|
|
25ebde1f0a | ||
|
|
120f45a6c5 | ||
|
|
fa8ae112ad | ||
|
|
c53d7f953d | ||
|
|
9881f9031f | ||
|
|
bd11827d8b | ||
|
|
40f2713234 | ||
|
|
b8e564a8d0 | ||
|
|
9cbca0329a | ||
|
|
c376662939 | ||
|
|
6f79bf198d | ||
|
|
542deac705 | ||
|
|
a905806232 | ||
|
|
7aeb691427 | ||
|
|
b7922d9096 | ||
|
|
be2d335a5b | ||
|
|
8de5c1fc3d | ||
|
|
aac4d1218d | ||
|
|
ba6474c7bb | ||
|
|
236c0edaaf | ||
|
|
02dc6965d1 | ||
|
|
735bf66593 | ||
|
|
dcc180eea5 | ||
|
|
694dc7a807 | ||
|
|
b2b8a62a57 | ||
|
|
f964dd8267 | ||
|
|
5260295079 | ||
|
|
6d6f881367 | ||
|
|
eae0709c09 | ||
|
|
0c83329e59 | ||
|
|
9de5024930 | ||
|
|
c813677041 | ||
|
|
d7541a115e | ||
|
|
4c911e666e | ||
|
|
4e059c4ee3 | ||
|
|
15d0addb7b | ||
|
|
1713efb51f | ||
|
|
9089555320 | ||
|
|
2f3b1f397c | ||
|
|
7ebb98ce06 | ||
|
|
805044fcf1 | ||
|
|
51d6a073e0 | ||
|
|
02980ea1e6 | ||
|
|
920ea6959c | ||
|
|
c7aaa22eab | ||
|
|
c218ae0baa | ||
|
|
5820b2f511 | ||
|
|
79c2bf17fd | ||
|
|
78aa4d76db | ||
|
|
e2f3ba19b8 | ||
|
|
41045686fc | ||
|
|
8b0b375dfe | ||
|
|
c7c23b9768 | ||
|
|
33190ae3ea | ||
|
|
03590f4b82 | ||
|
|
cbcf98e1d4 | ||
|
|
4098f06995 | ||
|
|
98f723200b | ||
|
|
07634d01f3 | ||
|
|
3bd67e2098 | ||
|
|
427ce5fd07 | ||
|
|
6bf927bb2c | ||
|
|
da17c3495a | ||
|
|
e739e3f9e0 | ||
|
|
10ec72047c | ||
|
|
4be514b754 | ||
|
|
add72c0be3 | ||
|
|
5758eed77b | ||
|
|
c7dc05be5a | ||
|
|
355933c742 | ||
|
|
f2bbf5855b | ||
|
|
970200aa40 | ||
|
|
67306734fa | ||
|
|
b14d629a45 | ||
|
|
1fb9eb3e3b | ||
|
|
1404a83c10 | ||
|
|
e18f911b1b | ||
|
|
c3f0644b46 | ||
|
|
733889f238 | ||
|
|
e280aa4963 | ||
|
|
254b0ab488 | ||
|
|
1253ca07cc | ||
|
|
e8bb4bac66 | ||
|
|
2ac6b84f87 | ||
|
|
e3a80b5a6d | ||
|
|
66dc5a9597 | ||
|
|
cb6bf91dd3 | ||
|
|
fb815abad0 | ||
|
|
8ef7580097 | ||
|
|
5f5a98e351 | ||
|
|
2535739c2b | ||
|
|
b6e13de73f | ||
|
|
fc3efbabbd | ||
|
|
2a7761dbc3 | ||
|
|
852f31574f | ||
|
|
ee79c23fdf | ||
|
|
097e040dd6 | ||
|
|
722b6d1e59 | ||
|
|
eed8ef7010 | ||
|
|
ba30690d26 | ||
|
|
4da6a4d450 | ||
|
|
197393fbd1 | ||
|
|
51ef6e3c78 | ||
|
|
663277fe6f | ||
|
|
332a38d674 | ||
|
|
e9410a2f54 | ||
|
|
b5fa2bd660 | ||
|
|
e56c61d834 | ||
|
|
7cb51f552a | ||
|
|
677f71dd84 | ||
|
|
3f90f88600 | ||
|
|
c7348f7438 | ||
|
|
22ac13c140 | ||
|
|
229a7c70d9 | ||
|
|
a2dbec98f9 | ||
|
|
3a02f8090e | ||
|
|
17519db44e | ||
|
|
99186bf269 | ||
|
|
9a65e40be1 | ||
|
|
f0add59f99 | ||
|
|
f18c182a6a | ||
|
|
68e9588f24 | ||
|
|
eea427216d | ||
|
|
8e9b89f6f0 | ||
|
|
4f3281be99 | ||
|
|
eb56a82702 | ||
|
|
089ccc9d15 | ||
|
|
12c1365513 | ||
|
|
7ecf9316e3 | ||
|
|
12e98ec36a | ||
|
|
22977fc7bc | ||
|
|
b387a49a4e | ||
|
|
dbbb0d0f64 | ||
|
|
0bbf2b752f | ||
|
|
14c1eacffa | ||
|
|
c2a0525bb8 | ||
|
|
4f502e580c | ||
|
|
7cb303966a | ||
|
|
3f0431f88b | ||
|
|
aad5601df1 | ||
|
|
8f2cf8141a | ||
|
|
eefd1129f7 | ||
|
|
5ed0f8b5a6 | ||
|
|
9b4aa4fd64 | ||
|
|
bbb226791b | ||
|
|
30ac4435d4 | ||
|
|
1b9dfe1901 | ||
|
|
808a6efd8f | ||
|
|
66ed19ed5a | ||
|
|
527a3cbd09 | ||
|
|
f22963b315 | ||
|
|
2ce5cb524f | ||
|
|
4cbc6392fb | ||
|
|
049f9fa625 | ||
|
|
c853fae820 | ||
|
|
dd1d84a4fe | ||
|
|
1569aa5dd5 | ||
|
|
51cd88eded | ||
|
|
bf386deef0 | ||
|
|
5c80cdee81 | ||
|
|
b29fbb37cd | ||
|
|
589831beef | ||
|
|
0f5d153543 | ||
|
|
ab1c99d132 | ||
|
|
af4870c39c | ||
|
|
9581b3da65 | ||
|
|
358a907b74 | ||
|
|
cdb1d8fe12 | ||
|
|
5513382aea | ||
|
|
a7a5c8978d | ||
|
|
b139d5fca5 | ||
|
|
977da5b1b4 | ||
|
|
78f2a13761 | ||
|
|
7ded7fd12a | ||
|
|
e50f79a25e | ||
|
|
904fc572d0 | ||
|
|
c280af9a5b | ||
|
|
af6df6dfa2 | ||
|
|
2380d69b11 | ||
|
|
ad76d6d414 | ||
|
|
d911ee12f2 | ||
|
|
e6ce03b516 | ||
|
|
17d7deef2d | ||
|
|
c2222344a2 | ||
|
|
0a8d677fe8 | ||
|
|
a4e1381238 | ||
|
|
1b6837d406 | ||
|
|
2adf8a139c | ||
|
|
efe96a6e05 | ||
|
|
0360df999f | ||
|
|
5cb4758b38 | ||
|
|
fce9f543e1 | ||
|
|
9e6cb1837e | ||
|
|
f9e40e17c4 | ||
|
|
a09d71cb13 | ||
|
|
de53445ac5 | ||
|
|
19fdd54dbd | ||
|
|
1c644188cd | ||
|
|
a50943ed01 | ||
|
|
1888aba335 | ||
|
|
b390fd49ca | ||
|
|
33f0eb9f38 | ||
|
|
db91458abc | ||
|
|
ee2ed0159d | ||
|
|
0bdc3e024e | ||
|
|
4aab4e636d | ||
|
|
af114d74df | ||
|
|
c5921f8a62 | ||
|
|
be0c8f2c96 | ||
|
|
bb685751cd | ||
|
|
22eebe89e7 | ||
|
|
fd9737aa9c | ||
|
|
1dcb479d62 | ||
|
|
7618a05162 | ||
|
|
174c6649e0 | ||
|
|
203608e9fd | ||
|
|
07e0ae884c | ||
|
|
cd8e256364 | ||
|
|
93998e460c | ||
|
|
71f205ca8b | ||
|
|
f9cee7a8f5 | ||
|
|
675e95da2b | ||
|
|
c1b6cef362 | ||
|
|
4977464e69 | ||
|
|
593624fdb9 | ||
|
|
c4585c81e1 | ||
|
|
27293f1bf8 | ||
|
|
d1fd31701d | ||
|
|
d30c7e6e9c | ||
|
|
0355b61e69 | ||
|
|
5d5ec719b7 | ||
|
|
6596dca291 | ||
|
|
a296c98602 | ||
|
|
be0718acf4 | ||
|
|
c42d913d4c | ||
|
|
446649b2bb | ||
|
|
9f145557ea | ||
|
|
ae856fca74 | ||
|
|
6dc8a4ffb5 | ||
|
|
73498964a8 | ||
|
|
256f88cc60 | ||
|
|
16cc6fb117 | ||
|
|
7bb809f227 | ||
|
|
57111f628d | ||
|
|
0129e9e092 | ||
|
|
d6c6132a04 | ||
|
|
eb5976a796 | ||
|
|
253f4abba1 | ||
|
|
3a442817ce | ||
|
|
594c359f1c | ||
|
|
cc28d4fe54 | ||
|
|
95708367a1 | ||
|
|
89b915b206 | ||
|
|
e4da0a126c | ||
|
|
56f9cc2c88 | ||
|
|
6037c66a2d | ||
|
|
d25837b40b | ||
|
|
fbd0f25b8f | ||
|
|
9c55fd166e | ||
|
|
2ac1828a0c | ||
|
|
45e1502c9b | ||
|
|
e2608cf85a | ||
|
|
05bbfe77b2 | ||
|
|
34ad0a7c68 | ||
|
|
c67ce38350 | ||
|
|
ad79ff2739 | ||
|
|
2e5afc73e7 | ||
|
|
73efe6fd83 | ||
|
|
c59e3165b6 | ||
|
|
ec8c5e0fd4 | ||
|
|
149ac9280c | ||
|
|
af20f65468 | ||
|
|
6f7efa9e26 | ||
|
|
7f5ef227eb | ||
|
|
e8e95a485b | ||
|
|
77186d271d | ||
|
|
ebeaf9703f | ||
|
|
625b2769c6 | ||
|
|
52e136ddef | ||
|
|
78fe18735b | ||
|
|
2f89c0bb92 | ||
|
|
fbac8881ce | ||
|
|
b51b3460c0 | ||
|
|
aaea4147a4 | ||
|
|
d2609c0560 | ||
|
|
6a3421df8a | ||
|
|
86be393335 | ||
|
|
96d6f9d80d | ||
|
|
384d0345f5 | ||
|
|
eb780a1449 | ||
|
|
15d094a175 | ||
|
|
eba5e484d6 | ||
|
|
7402e8569a | ||
|
|
8ae7863185 | ||
|
|
75b9fd1b7a | ||
|
|
dc46657fa6 | ||
|
|
d77177bbfd | ||
|
|
7c6a97e264 | ||
|
|
23f84c2416 | ||
|
|
550dfa9c9e | ||
|
|
e6b6a6bb37 | ||
|
|
92f9438992 | ||
|
|
d41a813e41 | ||
|
|
fae958f6ef | ||
|
|
d8db89326f | ||
|
|
3804896788 | ||
|
|
4aedea7e15 | ||
|
|
ed89d76488 | ||
|
|
bbd43b51e3 | ||
|
|
e5448fa8ab | ||
|
|
a6a392c7bf | ||
|
|
08f92f9614 | ||
|
|
c9cf09f4dd | ||
|
|
ab1624c918 | ||
|
|
62396111e3 | ||
|
|
e37f6f31da | ||
|
|
873b41e4f9 | ||
|
|
f0d4deffd7 | ||
|
|
b6c50d59ed | ||
|
|
9fcc19ef7e | ||
|
|
b90ebdabf9 | ||
|
|
e08a4cf1b2 | ||
|
|
bd4efcf110 | ||
|
|
0b9013e8b2 | ||
|
|
445128f462 | ||
|
|
f50a8b3112 | ||
|
|
ed65145f83 | ||
|
|
49e08eaf2f | ||
|
|
83a9570961 | ||
|
|
973a4073f0 | ||
|
|
867812b8e3 | ||
|
|
cf7341b065 | ||
|
|
de3c4545e6 | ||
|
|
a483d21120 | ||
|
|
665d46b7c4 | ||
|
|
3d5a1e9b30 | ||
|
|
e7e9c5fe9f | ||
|
|
c71460fcd8 | ||
|
|
8c2bc078e5 | ||
|
|
75b1068d46 | ||
|
|
4ac406aa2d | ||
|
|
f4f367850e | ||
|
|
b293e9f370 | ||
|
|
4e2350e5fc | ||
|
|
09412719b7 | ||
|
|
cd7d6d7674 | ||
|
|
bc0c5ac71a | ||
|
|
91619cc259 | ||
|
|
f0c9c61b49 | ||
|
|
d65158b7b9 | ||
|
|
4e5de1e33e | ||
|
|
b009a6423d | ||
|
|
467d0c8e18 | ||
|
|
4d535cef41 | ||
|
|
98147d0a81 | ||
|
|
323c1defaa | ||
|
|
60c5408ae8 | ||
|
|
51dc2ac046 | ||
|
|
24d9a49420 | ||
|
|
46891aa958 | ||
|
|
d1921193f0 | ||
|
|
a8c4c4045c | ||
|
|
0559c13dc6 | ||
|
|
3fbec046ba | ||
|
|
f0e56c4b6a | ||
|
|
4c8fa91af4 | ||
|
|
1568c09fa2 | ||
|
|
0e74d6e017 | ||
|
|
7690a29efb | ||
|
|
b1d6f5debd | ||
|
|
fbb92005a1 | ||
|
|
5b9922d509 | ||
|
|
49eebdf554 | ||
|
|
2da941d550 | ||
|
|
5a8d7531bf | ||
|
|
4d1f5e22d3 | ||
|
|
012416c881 | ||
|
|
0f48ad07a3 | ||
|
|
64752da948 | ||
|
|
d9d0656ef4 | ||
|
|
b17d8efa5c |
20
.editorconfig
Normal file
20
.editorconfig
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_size = 4
|
||||||
|
indent_style = tab
|
||||||
|
insert_final_newline = false
|
||||||
|
max_line_length = 120
|
||||||
|
tab_width = 4
|
||||||
|
# noinspection EditorConfigKeyCorrectness
|
||||||
|
disabled_rules=no-wildcard-imports,no-unused-imports
|
||||||
|
|
||||||
|
[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.rng,*.tld,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul}]
|
||||||
|
ij_continuation_indent_size = 4
|
||||||
|
|
||||||
|
[{*.kt,*.kts}]
|
||||||
|
ij_kotlin_allow_trailing_comma_on_call_site = true
|
||||||
|
ij_kotlin_allow_trailing_comma = true
|
||||||
|
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
|
||||||
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -1 +1 @@
|
|||||||
custom: ["https://money.yandex.ru/to/410012543938752"]
|
custom: ["https://yoomoney.ru/to/410012543938752"]
|
||||||
|
|||||||
29
.github/ISSUE_TEMPLATE.md
vendored
Normal file
29
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
**PLEASE READ THIS**
|
||||||
|
|
||||||
|
I acknowledge that:
|
||||||
|
|
||||||
|
- I have updated to the latest version of the app (https://github.com/KotatsuApp/Kotatsu/releases/latest)
|
||||||
|
- If this is an issue with a parser, that I should be opening an issue in https://github.com/KotatsuApp/kotatsu-parsers
|
||||||
|
- I have searched the existing issues and this is new ticket **NOT** a duplicate or related to another open or closed issue
|
||||||
|
- I will fill out the title and the information in this template
|
||||||
|
|
||||||
|
Note that the issue will be automatically closed if you do not fill out the title or requested information.
|
||||||
|
|
||||||
|
**DELETE THIS SECTION IF YOU HAVE READ AND ACKNOWLEDGED IT**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Device information
|
||||||
|
* Kotatsu version: ?
|
||||||
|
* Android version: ?
|
||||||
|
* Device: ?
|
||||||
|
|
||||||
|
## Steps to reproduce
|
||||||
|
1. First step
|
||||||
|
2. Second step
|
||||||
|
|
||||||
|
## Issue/Request
|
||||||
|
?
|
||||||
|
|
||||||
|
## Other details
|
||||||
|
Additional details and attachments.
|
||||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: ⚠️ Source issue
|
||||||
|
url: https://github.com/KotatsuApp/kotatsu-parsers/issues/new
|
||||||
|
about: If you have troubles with a manga parser or want to propose new manga source, please open an issue in the kotatsu-parsers repository instead
|
||||||
64
.github/ISSUE_TEMPLATE/report_bug.yml
vendored
Normal file
64
.github/ISSUE_TEMPLATE/report_bug.yml
vendored
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
name: 🐞 Bug report
|
||||||
|
description: Report a bug in Kotatsu
|
||||||
|
labels: [bug]
|
||||||
|
body:
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: summary
|
||||||
|
attributes:
|
||||||
|
label: Brief summary
|
||||||
|
description: Please describe, what went wrong
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: reproduce-steps
|
||||||
|
attributes:
|
||||||
|
label: Steps to reproduce
|
||||||
|
description: Please provide a way to reproduce this issue. Screenshots or videos can be very helpful
|
||||||
|
placeholder: |
|
||||||
|
Example:
|
||||||
|
1. First step
|
||||||
|
2. Second step
|
||||||
|
3. Issue here
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: kotatsu-version
|
||||||
|
attributes:
|
||||||
|
label: Kotatsu version
|
||||||
|
description: You can find your Kotatsu version in **Settings → About**.
|
||||||
|
placeholder: |
|
||||||
|
Example: "3.3"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: android-version
|
||||||
|
attributes:
|
||||||
|
label: Android version
|
||||||
|
description: You can find this somewhere in your Android settings.
|
||||||
|
placeholder: |
|
||||||
|
Example: "12.0"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: device
|
||||||
|
attributes:
|
||||||
|
label: Device
|
||||||
|
description: List your device and model.
|
||||||
|
placeholder: |
|
||||||
|
Example: "LG Nexus 5X"
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
|
||||||
|
- type: checkboxes
|
||||||
|
id: acknowledgements
|
||||||
|
attributes:
|
||||||
|
label: Acknowledgements
|
||||||
|
options:
|
||||||
|
- label: I have searched the existing issues and this is a new ticket, **NOT** a duplicate or related to another open issue.
|
||||||
|
required: true
|
||||||
24
.github/ISSUE_TEMPLATE/request_feature.yml
vendored
Normal file
24
.github/ISSUE_TEMPLATE/request_feature.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
name: ⭐ Feature request
|
||||||
|
description: Suggest a new idea how to improve Kotatsu
|
||||||
|
labels: [feature request]
|
||||||
|
body:
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: feature-description
|
||||||
|
attributes:
|
||||||
|
label: Describe your suggested feature
|
||||||
|
description: How can Kotatsu be improved?
|
||||||
|
placeholder: |
|
||||||
|
Example:
|
||||||
|
"It should work like this..."
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: checkboxes
|
||||||
|
id: acknowledgements
|
||||||
|
attributes:
|
||||||
|
label: Acknowledgements
|
||||||
|
description: Read this carefully, we will close and ignore your issue if you skimmed through this.
|
||||||
|
options:
|
||||||
|
- label: I have searched the existing issues and this is a new ticket, **NOT** a duplicate or related to another open issue.
|
||||||
|
required: true
|
||||||
29
.github/workflows/issue_moderator.yml
vendored
Normal file
29
.github/workflows/issue_moderator.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
name: Issue moderator
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened, edited, reopened]
|
||||||
|
issue_comment:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
moderate:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Moderate issues
|
||||||
|
uses: tachiyomiorg/issue-moderator-action@v1
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
auto-close-rules: |
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "body",
|
||||||
|
"regex": ".*DELETE THIS SECTION IF YOU HAVE READ AND ACKNOWLEDGED IT.*",
|
||||||
|
"message": "The acknowledgment section was not removed."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "body",
|
||||||
|
"regex": ".*\\* (Kotatsu version|Android version|Device): \\?.*",
|
||||||
|
"message": "Requested information in the template was not filled out."
|
||||||
|
}
|
||||||
|
]
|
||||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -3,11 +3,18 @@
|
|||||||
/local.properties
|
/local.properties
|
||||||
/.idea/caches
|
/.idea/caches
|
||||||
/.idea/libraries
|
/.idea/libraries
|
||||||
|
/.idea/dictionaries
|
||||||
/.idea/modules.xml
|
/.idea/modules.xml
|
||||||
/.idea/misc.xml
|
/.idea/misc.xml
|
||||||
|
/.idea/discord.xml
|
||||||
/.idea/workspace.xml
|
/.idea/workspace.xml
|
||||||
/.idea/navEditor.xml
|
/.idea/navEditor.xml
|
||||||
/.idea/assetWizardSettings.xml
|
/.idea/assetWizardSettings.xml
|
||||||
|
/.idea/kotlinScripting.xml
|
||||||
|
/.idea/kotlinc.xml
|
||||||
|
/.idea/deploymentTargetDropDown.xml
|
||||||
|
/.idea/androidTestResultsUserPreferences.xml
|
||||||
|
/.idea/render.experimental.xml
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/build
|
/build
|
||||||
/captures
|
/captures
|
||||||
|
|||||||
1
.idea/codeStyles/Project.xml
generated
1
.idea/codeStyles/Project.xml
generated
@@ -23,6 +23,7 @@
|
|||||||
</option>
|
</option>
|
||||||
</AndroidXmlCodeStyleSettings>
|
</AndroidXmlCodeStyleSettings>
|
||||||
<JetCodeStyleSettings>
|
<JetCodeStyleSettings>
|
||||||
|
<option name="ALLOW_TRAILING_COMMA" value="true" />
|
||||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
</JetCodeStyleSettings>
|
</JetCodeStyleSettings>
|
||||||
<codeStyleSettings language="CMake">
|
<codeStyleSettings language="CMake">
|
||||||
|
|||||||
2
.idea/compiler.xml
generated
2
.idea/compiler.xml
generated
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
<bytecodeTargetLevel target="11" />
|
<bytecodeTargetLevel target="17" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
17
.idea/deploymentTargetDropDown.xml
generated
17
.idea/deploymentTargetDropDown.xml
generated
@@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="deploymentTargetDropDown">
|
|
||||||
<targetSelectedWithDropDown>
|
|
||||||
<Target>
|
|
||||||
<type value="QUICK_BOOT_TARGET" />
|
|
||||||
<deviceKey>
|
|
||||||
<Key>
|
|
||||||
<type value="VIRTUAL_DEVICE_PATH" />
|
|
||||||
<value value="$USER_HOME$/.android/avd/Pixel_API_S.avd" />
|
|
||||||
</Key>
|
|
||||||
</deviceKey>
|
|
||||||
</Target>
|
|
||||||
</targetSelectedWithDropDown>
|
|
||||||
<timeTargetWasSelectedWithDropDown value="2021-02-19T19:02:37.198775Z" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
16
.idea/dictionaries/admin.xml
generated
16
.idea/dictionaries/admin.xml
generated
@@ -1,16 +0,0 @@
|
|||||||
<component name="ProjectDictionaryState">
|
|
||||||
<dictionary name="admin">
|
|
||||||
<words>
|
|
||||||
<w>amoled</w>
|
|
||||||
<w>chucker</w>
|
|
||||||
<w>desu</w>
|
|
||||||
<w>failsafe</w>
|
|
||||||
<w>koin</w>
|
|
||||||
<w>kotatsu</w>
|
|
||||||
<w>manga</w>
|
|
||||||
<w>snackbar</w>
|
|
||||||
<w>upsert</w>
|
|
||||||
<w>webtoon</w>
|
|
||||||
</words>
|
|
||||||
</dictionary>
|
|
||||||
</component>
|
|
||||||
2
.idea/gradle.xml
generated
2
.idea/gradle.xml
generated
@@ -7,13 +7,13 @@
|
|||||||
<option name="testRunner" value="GRADLE" />
|
<option name="testRunner" value="GRADLE" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleJvm" value="Embedded JDK" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
<option value="$PROJECT_DIR$/app" />
|
<option value="$PROJECT_DIR$/app" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
<option name="resolveModulePerSourceSet" value="false" />
|
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
287
.idea/icon.svg
generated
Normal file
287
.idea/icon.svg
generated
Normal file
@@ -0,0 +1,287 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
inkscape:export-ydpi="39.689999"
|
||||||
|
inkscape:export-xdpi="39.689999"
|
||||||
|
inkscape:export-filename="/home/admin/Documents/projects/graphics/k/icon4.png"
|
||||||
|
width="512mm"
|
||||||
|
height="512mm"
|
||||||
|
viewBox="0 0 512 512.00002"
|
||||||
|
version="1.1"
|
||||||
|
id="svg8"
|
||||||
|
inkscape:version="1.0 (4035a4fb49, 2020-05-01)"
|
||||||
|
sodipodi:docname="icon4.svg">
|
||||||
|
<defs
|
||||||
|
id="defs2">
|
||||||
|
<filter
|
||||||
|
style="color-interpolation-filters:sRGB;"
|
||||||
|
inkscape:label="Drop Shadow"
|
||||||
|
id="filter1266">
|
||||||
|
<feFlood
|
||||||
|
flood-opacity="0.498039"
|
||||||
|
flood-color="rgb(0,0,0)"
|
||||||
|
result="flood"
|
||||||
|
id="feFlood1256" />
|
||||||
|
<feComposite
|
||||||
|
in="flood"
|
||||||
|
in2="SourceGraphic"
|
||||||
|
operator="in"
|
||||||
|
result="composite1"
|
||||||
|
id="feComposite1258" />
|
||||||
|
<feGaussianBlur
|
||||||
|
in="composite1"
|
||||||
|
stdDeviation="3"
|
||||||
|
result="blur"
|
||||||
|
id="feGaussianBlur1260" />
|
||||||
|
<feOffset
|
||||||
|
dx="6"
|
||||||
|
dy="6"
|
||||||
|
result="offset"
|
||||||
|
id="feOffset1262" />
|
||||||
|
<feComposite
|
||||||
|
in="SourceGraphic"
|
||||||
|
in2="offset"
|
||||||
|
operator="over"
|
||||||
|
result="composite2"
|
||||||
|
id="feComposite1264" />
|
||||||
|
</filter>
|
||||||
|
<filter
|
||||||
|
style="color-interpolation-filters:sRGB;"
|
||||||
|
inkscape:label="Drop Shadow"
|
||||||
|
id="filter1059">
|
||||||
|
<feFlood
|
||||||
|
flood-opacity="0.498039"
|
||||||
|
flood-color="rgb(0,0,0)"
|
||||||
|
result="flood"
|
||||||
|
id="feFlood1049" />
|
||||||
|
<feComposite
|
||||||
|
in="flood"
|
||||||
|
in2="SourceGraphic"
|
||||||
|
operator="in"
|
||||||
|
result="composite1"
|
||||||
|
id="feComposite1051" />
|
||||||
|
<feGaussianBlur
|
||||||
|
in="composite1"
|
||||||
|
stdDeviation="3"
|
||||||
|
result="blur"
|
||||||
|
id="feGaussianBlur1053" />
|
||||||
|
<feOffset
|
||||||
|
dx="6"
|
||||||
|
dy="6"
|
||||||
|
result="offset"
|
||||||
|
id="feOffset1055" />
|
||||||
|
<feComposite
|
||||||
|
in="SourceGraphic"
|
||||||
|
in2="offset"
|
||||||
|
operator="over"
|
||||||
|
result="composite2"
|
||||||
|
id="feComposite1057" />
|
||||||
|
</filter>
|
||||||
|
<filter
|
||||||
|
style="color-interpolation-filters:sRGB;"
|
||||||
|
inkscape:label="Drop Shadow"
|
||||||
|
id="filter1071">
|
||||||
|
<feFlood
|
||||||
|
flood-opacity="0.498039"
|
||||||
|
flood-color="rgb(0,0,0)"
|
||||||
|
result="flood"
|
||||||
|
id="feFlood1061" />
|
||||||
|
<feComposite
|
||||||
|
in="flood"
|
||||||
|
in2="SourceGraphic"
|
||||||
|
operator="in"
|
||||||
|
result="composite1"
|
||||||
|
id="feComposite1063" />
|
||||||
|
<feGaussianBlur
|
||||||
|
in="composite1"
|
||||||
|
stdDeviation="3"
|
||||||
|
result="blur"
|
||||||
|
id="feGaussianBlur1065" />
|
||||||
|
<feOffset
|
||||||
|
dx="6"
|
||||||
|
dy="6"
|
||||||
|
result="offset"
|
||||||
|
id="feOffset1067" />
|
||||||
|
<feComposite
|
||||||
|
in="SourceGraphic"
|
||||||
|
in2="offset"
|
||||||
|
operator="over"
|
||||||
|
result="composite2"
|
||||||
|
id="feComposite1069" />
|
||||||
|
</filter>
|
||||||
|
</defs>
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#0d47a1"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="0.175"
|
||||||
|
inkscape:cx="-361.03654"
|
||||||
|
inkscape:cy="630.78782"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
inkscape:document-rotation="0"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:window-width="1600"
|
||||||
|
inkscape:window-height="838"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="0"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
fit-margin-top="20"
|
||||||
|
fit-margin-left="20"
|
||||||
|
fit-margin-right="20"
|
||||||
|
fit-margin-bottom="20" />
|
||||||
|
<metadata
|
||||||
|
id="metadata5">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Слой 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(-51.12025,-104.74797)">
|
||||||
|
<g
|
||||||
|
id="g1028"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1030"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1032"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1034"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1036"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1038"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1040"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1042"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1044"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1046"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1048"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1050"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1052"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1054"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1056"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<path
|
||||||
|
id="path1128"
|
||||||
|
d="m 307.12025,310.74755 c -50.53732,0 -91.66608,44.85688 -91.66608,99.99965 0,55.14277 41.12954,99.99964 91.66608,99.99964 50.53653,0 91.66607,-44.85687 91.66607,-99.99964 0,-55.14277 -41.12875,-99.99965 -91.66607,-99.99965 z m -34.21238,78.72707 c -1.46484,2.91327 -4.41092,4.60623 -7.45466,4.60623 -1.25312,0 -2.52265,-0.27656 -3.72733,-0.8789 l -12.9398,-6.4781 -12.9398,6.4781 c -4.13436,2.06718 -9.11481,0.37421 -11.18199,-3.72733 -2.05077,-4.11796 -0.39062,-9.11481 3.72733,-11.18199 l 16.66635,-8.33357 c 2.34374,-1.17187 5.11092,-1.17187 7.45466,0 l 16.66635,8.33357 c 4.11951,2.06718 5.77966,7.06403 3.72889,11.18199 z m 58.33338,-24.99991 c -1.46484,2.91327 -4.41092,4.60623 -7.45466,4.60623 -1.25312,0 -2.52264,-0.27656 -3.72733,-0.8789 l -12.93901,-6.47811 -12.9398,6.47811 c -4.13436,2.06718 -9.11481,0.37421 -11.18199,-3.72733 -2.05078,-4.11796 -0.39063,-9.11482 3.72733,-11.182 l 16.66634,-8.33356 c 2.34375,-1.17187 5.11092,-1.17187 7.45466,0 l 16.66635,8.33356 c 4.11874,2.06718 5.77889,7.06404 3.72811,11.182 z m 54.60606,13.81792 c 4.11795,2.06718 5.7781,7.06403 3.72733,11.18199 -1.46484,2.91327 -4.41092,4.60623 -7.45466,4.60623 -1.25312,0 -2.52265,-0.27656 -3.72733,-0.8789 l -12.9398,-6.4781 -12.9398,6.4781 c -4.11795,2.06718 -9.11481,0.37421 -11.18199,-3.72733 -2.05077,-4.11796 -0.39062,-9.11481 3.72733,-11.18199 l 16.66635,-8.33357 c 2.34374,-1.17187 5.11092,-1.17187 7.45466,0 z"
|
||||||
|
style="fill:#ffffff;stroke-width:0.781247" />
|
||||||
|
<path
|
||||||
|
id="path1130"
|
||||||
|
d="m 415.36283,274.00237 c -3.48202,-6.90544 -6.92029,-13.41714 -10.20934,-19.37102 l -8.26716,-14.47964 c -6.79607,-11.51871 -12.25699,-19.90305 -14.78354,-23.66554 -0.7164,-43.32797 -19.12415,-53.79356 -21.25617,-54.86777 -3.20624,-1.5789 -7.09607,-0.97656 -9.6195,1.56249 -12.25621,12.25621 -20.23118,24.4632 -24.00695,30.89286 h -40.20141 c -3.77577,-6.42888 -11.75153,-18.63665 -24.00695,-30.89286 -2.52265,-2.53905 -6.39685,-3.14139 -9.6195,-1.56249 -2.13202,1.07421 -20.54055,11.5398 -21.25617,54.86777 -2.52655,3.76327 -7.98669,12.14605 -14.78276,23.66476 l -8.27341,14.49214 c -3.28983,5.95701 -6.73044,12.47105 -10.21403,19.3804 l -7.4445,15.32572 c -17.72572,38.05377 -34.30066,85.4286 -34.30066,129.72766 0,69.32085 58.26776,128.42064 60.75838,130.89485 0.91171,0.91172 2.03437,1.61171 3.25546,2.01796 1.07421,0.35859 26.78974,8.757 69.31928,8.757 2.21327,0 4.32967,-0.8789 5.89217,-2.4414 l 5.89216,-5.89216 h 9.76559 l 5.89217,5.89216 c 1.56249,1.5625 3.67811,2.4414 5.89216,2.4414 42.52954,0 68.24507,-8.39841 69.31929,-8.757 1.22109,-0.40703 2.34374,-1.10703 3.25546,-2.01796 2.48905,-2.47421 60.75681,-61.57322 60.75681,-130.89485 0,-44.29906 -16.57494,-91.67389 -34.30066,-129.72766 z M 348.7865,227.41426 c 4.60624,0 4.41171,7.35466 4.41171,11.96089 4.60623,0 12.25464,0.1 12.25464,4.70624 0,9.19606 -7.47107,16.66634 -16.66635,16.66634 -9.19528,0 -16.66634,-7.47028 -16.66634,-16.66634 0,-9.19606 7.47106,-16.66713 16.66634,-16.66713 z m -57.69823,30.14364 c 1.28593,-3.10858 4.32967,-5.14295 7.69841,-5.14295 h 16.66635 c 3.36952,0 6.41248,2.03437 7.69841,5.14295 1.28593,3.10858 0.56953,6.70545 -1.80703,9.082 l -8.33356,8.33356 c -1.62734,1.62734 -3.76014,2.4414 -5.89217,2.4414 -2.13202,0 -4.26404,-0.81406 -5.89216,-2.4414 l -8.33357,-8.33356 c -2.37421,-2.37655 -3.09061,-5.97342 -1.80468,-9.082 z m -25.63428,-30.14364 c 4.60623,0 4.4117,7.35466 4.4117,11.96089 4.60623,0 12.25465,0.1 12.25465,4.70624 0,9.19606 -7.47107,16.66634 -16.66635,16.66634 -9.19606,0 -16.66635,-7.47106 -16.66635,-16.66634 -7.8e-4,-9.19606 7.47029,-16.66713 16.66635,-16.66713 z m 41.66626,299.99893 c -59.7326,0 -108.33321,-52.34357 -108.33321,-116.66599 0,-64.32243 48.60061,-116.66599 108.33321,-116.66599 59.73259,0 108.3332,52.34356 108.3332,116.66599 0,64.32242 -48.60061,116.66599 -108.3332,116.66599 z"
|
||||||
|
style="fill:#ffffff;stroke-width:0.781247;filter:url(#filter1059)"
|
||||||
|
sodipodi:nodetypes="cccccccccccccccsccssccssccsccscsssssssssssccsscsscssssss" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1138"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)"
|
||||||
|
inkscape:groupmode="layer" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1140"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1142"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1144"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1146"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1148"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1150"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1152"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1154"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1156"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1158"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1160"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1162"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1164"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1166"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<path
|
||||||
|
style="fill:#ef5350;fill-opacity:1;stroke:none;stroke-width:5.18208;stroke-linecap:round;stroke-linejoin:round"
|
||||||
|
d="m 344.3189,392.83707 c -4.60362,-2.75958 -5.36974,-9.69605 -1.45595,-13.18226 0.54459,-0.48508 5.34567,-3.07035 10.66909,-5.74503 7.5498,-3.79328 10.16725,-4.86303 11.89884,-4.86303 1.73503,0 4.42542,1.10391 12.3172,5.05396 11.72559,5.86898 12.60994,6.68326 12.60994,11.61118 0,3.40408 -0.99553,5.20819 -4.00363,7.25549 -3.08358,2.09867 -5.44113,1.68547 -13.60905,-2.38528 l -7.19926,-3.58796 -7.37198,3.59617 c -8.3911,4.09331 -10.26721,4.39753 -13.8552,2.24676 z"
|
||||||
|
id="path944" />
|
||||||
|
<path
|
||||||
|
style="fill:#ef5350;fill-opacity:1;stroke:none;stroke-width:5.18208;stroke-linecap:round;stroke-linejoin:round"
|
||||||
|
d="m 285.98437,367.98056 c -3.86343,-2.35557 -5.1524,-8.06518 -2.66781,-11.81734 1.64304,-2.48125 20.719,-12.23981 23.92632,-12.23981 1.56364,0 4.61398,1.26582 12.2153,5.06905 8.53551,4.27064 10.3157,5.36752 11.30239,6.96403 1.75651,2.84207 1.95178,5.62136 0.58856,8.37633 -1.52635,3.08463 -3.36973,4.32306 -6.86644,4.61304 -2.68142,0.22236 -3.36743,-0.003 -10.22731,-3.35873 l -7.35311,-3.59707 -7.04119,3.52834 c -7.90523,3.96133 -10.62609,4.44409 -13.87671,2.46216 z"
|
||||||
|
id="path946" />
|
||||||
|
<path
|
||||||
|
style="fill:#ef5350;fill-opacity:1;stroke:none;stroke-width:5.18208;stroke-linecap:round;stroke-linejoin:round"
|
||||||
|
d="m 228.11707,393.18031 c -1.0244,-0.54435 -2.42484,-1.80721 -3.11209,-2.80633 -1.05812,-1.53828 -1.2181,-2.32693 -1.04433,-5.14815 0.29039,-4.71472 1.41139,-5.70783 12.90113,-11.42937 7.71258,-3.84061 9.99443,-4.74971 11.92193,-4.74971 1.94819,0 4.22735,0.92952 12.47354,5.08716 8.66324,4.3679 10.26522,5.3693 11.33052,7.08263 3.53608,5.68714 -0.55313,12.95355 -7.28968,12.95355 -1.25225,0 -4.29453,-1.20187 -9.08226,-3.58799 l -7.19927,-3.58796 -7.37197,3.59617 c -8.07507,3.93914 -10.21699,4.34922 -13.52752,2.59 z"
|
||||||
|
id="path948" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 13 KiB |
7
.idea/inspectionProfiles/Project_Default.xml
generated
7
.idea/inspectionProfiles/Project_Default.xml
generated
@@ -1,8 +1,13 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
<component name="InspectionProjectProfileManager">
|
||||||
<profile version="1.0">
|
<profile version="1.0">
|
||||||
<option name="myName" value="Project Default" />
|
<option name="myName" value="Project Default" />
|
||||||
<inspection_tool class="BooleanLiteralArgument" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
<inspection_tool class="BooleanLiteralArgument" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="Destructure" enabled="true" level="INFO" enabled_by_default="true" />
|
||||||
<inspection_tool class="KeySetIterationMayUseEntrySet" enabled="true" level="WARNING" enabled_by_default="true" />
|
<inspection_tool class="KeySetIterationMayUseEntrySet" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
|
<inspection_tool class="KotlinFunctionArgumentsHelper" enabled="true" level="INFORMATION" enabled_by_default="true">
|
||||||
|
<option name="withoutDefaultValues" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="ReplaceCollectionCountWithSize" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||||
<inspection_tool class="TrailingComma" enabled="true" level="INFORMATION" enabled_by_default="true" />
|
<inspection_tool class="TrailingComma" enabled="true" level="INFORMATION" enabled_by_default="true" />
|
||||||
<inspection_tool class="ZeroLengthArrayInitialization" enabled="true" level="WARNING" enabled_by_default="true" />
|
<inspection_tool class="ZeroLengthArrayInitialization" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
</profile>
|
</profile>
|
||||||
|
|||||||
10
.idea/jarRepositories.xml
generated
10
.idea/jarRepositories.xml
generated
@@ -31,5 +31,15 @@
|
|||||||
<option name="name" value="maven2" />
|
<option name="name" value="maven2" />
|
||||||
<option name="url" value="https://dl.bintray.com/kotlin/kotlin-eap" />
|
<option name="url" value="https://dl.bintray.com/kotlin/kotlin-eap" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="MavenRepo" />
|
||||||
|
<option name="name" value="MavenRepo" />
|
||||||
|
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven2" />
|
||||||
|
<option name="name" value="maven2" />
|
||||||
|
<option name="url" value="https://maven.pkg.github.com/nv95/kotatsu-parsers" />
|
||||||
|
</remote-repository>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
3
.idea/kotlinc.xml
generated
3
.idea/kotlinc.xml
generated
@@ -3,4 +3,7 @@
|
|||||||
<component name="Kotlin2JvmCompilerArguments">
|
<component name="Kotlin2JvmCompilerArguments">
|
||||||
<option name="jvmTarget" value="1.8" />
|
<option name="jvmTarget" value="1.8" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="KotlinJpsPluginSettings">
|
||||||
|
<option name="version" value="1.6.21" />
|
||||||
|
</component>
|
||||||
</project>
|
</project>
|
||||||
7
.idea/ktlint.xml
generated
Normal file
7
.idea/ktlint.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="KtlintProjectConfiguration">
|
||||||
|
<androidMode>true</androidMode>
|
||||||
|
<treatAsErrors>false</treatAsErrors>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
38
.idea/misc.xml
generated
38
.idea/misc.xml
generated
@@ -1,38 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="DesignSurface">
|
|
||||||
<option name="filePathToZoomLevelMap">
|
|
||||||
<map>
|
|
||||||
<entry key="../../../../../../layout/custom_preview.xml" value="0.1" />
|
|
||||||
<entry key="../../../../../../opt/usr/android-sdk/platforms/android-30/data/res/drawable/list_divider_material.xml" value="0.28512820512820514" />
|
|
||||||
<entry key="../../../../../../opt/usr/android-sdk/platforms/android-30/data/res/layout/simple_dropdown_item_1line.xml" value="0.24739583333333334" />
|
|
||||||
<entry key="app/src/main/res/drawable/tab_indicator.xml" value="0.28512820512820514" />
|
|
||||||
<entry key="app/src/main/res/drawable/tabs_background.xml" value="0.28512820512820514" />
|
|
||||||
<entry key="app/src/main/res/layout-w600dp/fragment_details.xml" value="0.14583333333333334" />
|
|
||||||
<entry key="app/src/main/res/layout-w600dp/fragment_list.xml" value="0.14635416666666667" />
|
|
||||||
<entry key="app/src/main/res/layout/dialog_favorite_categories.xml" value="0.2601851851851852" />
|
|
||||||
<entry key="app/src/main/res/layout/dialog_list_mode.xml" value="0.2601851851851852" />
|
|
||||||
<entry key="app/src/main/res/layout/fragment_chapters.xml" value="0.24739583333333334" />
|
|
||||||
<entry key="app/src/main/res/layout/fragment_details.xml" value="0.26145833333333335" />
|
|
||||||
<entry key="app/src/main/res/layout/fragment_favourites.xml" value="0.26296296296296295" />
|
|
||||||
<entry key="app/src/main/res/layout/fragment_feed.xml" value="0.2601851851851852" />
|
|
||||||
<entry key="app/src/main/res/layout/fragment_list.xml" value="0.2601851851851852" />
|
|
||||||
<entry key="app/src/main/res/layout/item_branch.xml" value="0.24739583333333334" />
|
|
||||||
<entry key="app/src/main/res/layout/item_branch_dropdown.xml" value="0.25743589743589745" />
|
|
||||||
<entry key="app/src/main/res/layout/item_category_checkable.xml" value="0.2601851851851852" />
|
|
||||||
<entry key="app/src/main/res/layout/item_manga_grid.xml" value="0.26042632066728455" />
|
|
||||||
<entry key="app/src/main/res/layout/item_manga_list_details.xml" value="0.2601851851851852" />
|
|
||||||
<entry key="app/src/main/res/layout/item_page_thumb.xml" value="0.2601851851851852" />
|
|
||||||
<entry key="app/src/main/res/layout/item_recent.xml" value="0.2601851851851852" />
|
|
||||||
<entry key="app/src/main/res/layout/sheet_pages.xml" value="0.2601851851851852" />
|
|
||||||
<entry key="app/src/main/res/menu/popup_category.xml" value="0.2601851851851852" />
|
|
||||||
</map>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
|
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
|
||||||
</component>
|
|
||||||
<component name="ProjectType">
|
|
||||||
<option name="id" value="Android" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
6
.idea/render.experimental.xml
generated
6
.idea/render.experimental.xml
generated
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="RenderSettings">
|
|
||||||
<option name="quality" value="0.25" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
11
.travis.yml
11
.travis.yml
@@ -1,11 +0,0 @@
|
|||||||
language: android
|
|
||||||
dist: trusty
|
|
||||||
android:
|
|
||||||
components:
|
|
||||||
- android-30
|
|
||||||
- build-tools-30.0.3
|
|
||||||
- platform-tools-30.0.5
|
|
||||||
- tools
|
|
||||||
before_install:
|
|
||||||
- yes | sdkmanager "platforms;android-30"
|
|
||||||
script: ./gradlew -Dorg.gradle.jvmargs=-Xmx1536m assembleDebug lintDebug
|
|
||||||
51
README.md
51
README.md
@@ -1,44 +1,57 @@
|
|||||||
# Kotatsu
|
# Kotatsu
|
||||||
|
|
||||||
Kotatsu is a free and open source manga reader for Android.
|
Kotatsu is a free and open source manga reader for Android.
|
||||||
|
|
||||||
  [](https://travis-ci.org/nv95/Kotatsu)  [](http://4pda.ru/forum/index.php?showtopic=697669)
|
   [](https://hosted.weblate.org/engage/kotatsu/) [](http://4pda.ru/forum/index.php?showtopic=697669) [](https://discord.gg/NNJ5RgVBC5)
|
||||||
|
|
||||||
### Download
|
### Download
|
||||||
|
|
||||||
Latest release: [get here](https://github.com/nv95/Kotatsu/releases/latest)
|
[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
|
||||||
|
alt="Get it on F-Droid"
|
||||||
|
height="80">](https://f-droid.org/packages/org.koitharu.kotatsu)
|
||||||
|
|
||||||
Legacy build (Android 4.1+): [available here](https://github.com/nv95/Kotatsu/releases/tag/v0.4-legacy)
|
Download APK directly from GitHub:
|
||||||
|
|
||||||
|
- **[Latest release](https://github.com/KotatsuApp/Kotatsu/releases/latest)**
|
||||||
|
|
||||||
### Main Features
|
### Main Features
|
||||||
|
|
||||||
* Online manga catalogues
|
* Online manga catalogues
|
||||||
* Search manga by name and genre
|
* Search manga by name and genres
|
||||||
* Reading history
|
* Reading history and bookmarks
|
||||||
* Favourites organized by user-defined categories
|
* Favourites organized by user-defined categories
|
||||||
* Downloading manga and reading it offline. Third-party CBZ archives also supported
|
* Downloading manga and reading it offline. Third-party CBZ archives also supported
|
||||||
* Tablet-optimized material design UI
|
* Tablet-optimized material design UI
|
||||||
* Standard and Webtoon-optimized reader
|
* Standard and Webtoon-optimized reader
|
||||||
* Notifications about new chapters with updates feed
|
* Notifications about new chapters with updates feed
|
||||||
|
* Shikimori integration (manga tracking)
|
||||||
|
* Password/fingerprint protect access to the app
|
||||||
|
|
||||||
### Screenshots
|
### Screenshots
|
||||||
|
|
||||||
|  |  |  |
|
|  |  |  |
|
||||||
|---|---|---|
|
|-----------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|
|
||||||
|  |  |  |
|
|  |  |  |
|
||||||
|
|
||||||
|  |  |
|
|  |  |
|
||||||
|---|---|
|
|-----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------|
|
||||||
|
|
||||||
|
### Localization
|
||||||
|
|
||||||
|
[<img src="https://hosted.weblate.org/widgets/kotatsu/-/287x66-white.png" alt="Translation status">](https://hosted.weblate.org/engage/kotatsu/)
|
||||||
|
|
||||||
|
Kotatsu is localized in a number of different languages, if you would like to help improve these or add new languages,
|
||||||
|
please head over to the [Weblate project page](https://hosted.weblate.org/engage/kotatsu/)
|
||||||
|
|
||||||
### License
|
### License
|
||||||
[](http://www.gnu.org/licenses/gpl-3.0.en.html)
|
|
||||||
|
|
||||||
Kotatsu is Free Software: You can use, study share and improve it at your
|
[](http://www.gnu.org/licenses/gpl-3.0.en.html)
|
||||||
will. Specifically you can redistribute and/or modify it under the terms of the
|
|
||||||
[GNU General Public License](https://www.gnu.org/licenses/gpl.html) as
|
|
||||||
published by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
### Disclaimer
|
You may copy, distribute and modify the software as long as you track changes/dates in source files. Any modifications
|
||||||
|
to or software including (via compiler) GPL-licensed code must also be made available under the GPL along with build &
|
||||||
|
install instructions.
|
||||||
|
|
||||||
The developers of this application does not have any affiliation with the content providers available.
|
### DMCA disclaimer
|
||||||
|
|
||||||
|
The developers of this application does not have any affiliation with the content available in the app.
|
||||||
|
It is collecting from the sources freely available through any web browser.
|
||||||
|
|||||||
142
app/build.gradle
142
app/build.gradle
@@ -6,25 +6,30 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 30
|
compileSdkVersion 32
|
||||||
buildToolsVersion '30.0.3'
|
buildToolsVersion '32.0.0'
|
||||||
|
namespace 'org.koitharu.kotatsu'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId 'org.koitharu.kotatsu'
|
applicationId 'org.koitharu.kotatsu'
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 30
|
targetSdkVersion 32
|
||||||
versionCode 364
|
versionCode 430
|
||||||
versionName '1.0.1'
|
versionName '3.5'
|
||||||
|
generatedDensities = []
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
kapt {
|
kapt {
|
||||||
arguments {
|
arguments {
|
||||||
arg 'room.schemaLocation', "$projectDir/schemas".toString()
|
arg 'room.schemaLocation', "$projectDir/schemas".toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
compileOptions {
|
// define this values in your local.properties file
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
buildConfigField 'String', 'SHIKIMORI_CLIENT_ID', "\"${localProperty('shikimori.clientId')}\""
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
buildConfigField 'String', 'SHIKIMORI_CLIENT_SECRET', "\"${localProperty('shikimori.clientSecret')}\""
|
||||||
|
resValue "string", "acra_login", "${localProperty('acra.login')}"
|
||||||
|
resValue "string", "acra_password", "${localProperty('acra.password')}"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
debug {
|
debug {
|
||||||
@@ -40,67 +45,100 @@ android {
|
|||||||
buildFeatures {
|
buildFeatures {
|
||||||
viewBinding true
|
viewBinding true
|
||||||
}
|
}
|
||||||
lintOptions {
|
sourceSets {
|
||||||
disable 'MissingTranslation'
|
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
|
||||||
abortOnError false
|
|
||||||
}
|
}
|
||||||
testOptions {
|
compileOptions {
|
||||||
unitTests.includeAndroidResources = true
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
unitTests.returnDefaultValues = false
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
}
|
|
||||||
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
|
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
||||||
freeCompilerArgs += [
|
freeCompilerArgs += [
|
||||||
'-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi',
|
'-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi',
|
||||||
'-Xopt-in=org.koin.core.component.KoinApiExtension'
|
'-opt-in=kotlinx.coroutines.FlowPreview',
|
||||||
|
'-opt-in=kotlin.contracts.ExperimentalContracts',
|
||||||
|
'-opt-in=coil.annotation.ExperimentalCoilApi',
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
lint {
|
||||||
|
abortOnError false
|
||||||
|
disable 'MissingTranslation', 'PrivateResource', 'NotifyDataSetChanged'
|
||||||
|
}
|
||||||
|
testOptions {
|
||||||
|
unitTests.includeAndroidResources true
|
||||||
|
unitTests.returnDefaultValues false
|
||||||
|
kotlinOptions {
|
||||||
|
freeCompilerArgs += ['-opt-in=org.koitharu.kotatsu.parsers.InternalParsersApi']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
afterEvaluate {
|
||||||
|
compileDebugKotlin {
|
||||||
|
kotlinOptions {
|
||||||
|
freeCompilerArgs += ['-opt-in=org.koitharu.kotatsu.parsers.InternalParsersApi']
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
implementation('com.github.KotatsuApp:kotatsu-parsers:5cb953eb86') {
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2'
|
exclude group: 'org.json', module: 'json'
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2'
|
}
|
||||||
|
|
||||||
implementation 'androidx.core:core-ktx:1.5.0-rc01'
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
|
||||||
implementation 'androidx.activity:activity-ktx:1.2.2'
|
|
||||||
implementation 'androidx.fragment:fragment-ktx:1.3.2'
|
implementation 'androidx.core:core-ktx:1.8.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
|
implementation 'androidx.activity:activity-ktx:1.5.1'
|
||||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
|
implementation 'androidx.fragment:fragment-ktx:1.5.3'
|
||||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
|
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
|
||||||
implementation 'androidx.lifecycle:lifecycle-service:2.3.1'
|
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
|
||||||
implementation 'androidx.lifecycle:lifecycle-process:2.3.1'
|
implementation 'androidx.lifecycle:lifecycle-service:2.5.1'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
implementation 'androidx.lifecycle:lifecycle-process:2.5.1'
|
||||||
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.2.0-rc01'
|
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
||||||
implementation 'androidx.viewpager2:viewpager2:1.1.0-alpha01'
|
implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01'
|
||||||
implementation 'androidx.preference:preference-ktx:1.1.1'
|
implementation 'androidx.preference:preference-ktx:1.2.0'
|
||||||
implementation 'androidx.work:work-runtime-ktx:2.5.0'
|
implementation 'androidx.work:work-runtime-ktx:2.7.1'
|
||||||
implementation 'com.google.android.material:material:1.3.0'
|
implementation 'androidx.biometric:biometric-ktx:1.2.0-alpha04'
|
||||||
|
implementation 'com.google.android.material:material:1.7.0-rc01'
|
||||||
//noinspection LifecycleAnnotationProcessorWithJava8
|
//noinspection LifecycleAnnotationProcessorWithJava8
|
||||||
kapt 'androidx.lifecycle:lifecycle-compiler:2.3.1'
|
kapt 'androidx.lifecycle:lifecycle-compiler:2.5.1'
|
||||||
|
|
||||||
implementation 'androidx.room:room-runtime:2.2.6'
|
implementation 'androidx.room:room-runtime:2.4.3'
|
||||||
implementation 'androidx.room:room-ktx:2.2.6'
|
implementation 'androidx.room:room-ktx:2.4.3'
|
||||||
kapt 'androidx.room:room-compiler:2.2.6'
|
kapt 'androidx.room:room-compiler:2.4.3'
|
||||||
|
|
||||||
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
|
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
|
||||||
implementation 'com.squareup.okio:okio:2.10.0'
|
implementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:4.9.3'
|
||||||
implementation 'org.jsoup:jsoup:1.13.1'
|
implementation 'com.squareup.okio:okio:3.2.0'
|
||||||
|
|
||||||
implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl:4.3.0'
|
implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl:4.3.2'
|
||||||
implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl-viewbinding:4.3.0'
|
implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl-viewbinding:4.3.2'
|
||||||
|
|
||||||
implementation 'org.koin:koin-android:2.2.2'
|
implementation 'io.insert-koin:koin-android:3.2.0'
|
||||||
implementation 'org.koin:koin-androidx-viewmodel:2.2.2'
|
implementation 'io.coil-kt:coil-base:2.2.1'
|
||||||
implementation 'io.coil-kt:coil-base:1.1.1'
|
|
||||||
implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'
|
implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'
|
||||||
implementation 'com.tomclaw.cache:cache:1.0'
|
implementation 'com.github.solkin:disk-lru-cache:1.4'
|
||||||
|
|
||||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.6'
|
implementation 'ch.acra:acra-http:5.9.6'
|
||||||
|
implementation 'ch.acra:acra-dialog:5.9.6'
|
||||||
|
|
||||||
|
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
testImplementation 'org.json:json:20201115'
|
testImplementation 'org.json:json:20220320'
|
||||||
testImplementation 'org.koin:koin-test:2.2.2'
|
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4'
|
||||||
|
|
||||||
|
androidTestImplementation 'androidx.test:runner:1.4.0'
|
||||||
|
androidTestImplementation 'androidx.test:rules:1.4.0'
|
||||||
|
androidTestImplementation 'androidx.test:core-ktx:1.4.0'
|
||||||
|
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.3'
|
||||||
|
|
||||||
|
androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4'
|
||||||
|
androidTestImplementation 'io.insert-koin:koin-test:3.2.0'
|
||||||
|
androidTestImplementation 'io.insert-koin:koin-test-junit4:3.2.0'
|
||||||
|
|
||||||
|
androidTestImplementation 'androidx.room:room-testing:2.4.3'
|
||||||
|
androidTestImplementation 'com.squareup.moshi:moshi-kotlin:1.14.0'
|
||||||
}
|
}
|
||||||
10
app/proguard-rules.pro
vendored
10
app/proguard-rules.pro
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
-optimizationpasses 8
|
||||||
-dontobfuscate
|
-dontobfuscate
|
||||||
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
|
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
|
||||||
public static void checkExpressionValueIsNotNull(...);
|
public static void checkExpressionValueIsNotNull(...);
|
||||||
@@ -5,9 +6,10 @@
|
|||||||
public static void checkReturnedValueIsNotNull(...);
|
public static void checkReturnedValueIsNotNull(...);
|
||||||
public static void checkFieldIsNotNull(...);
|
public static void checkFieldIsNotNull(...);
|
||||||
public static void checkParameterIsNotNull(...);
|
public static void checkParameterIsNotNull(...);
|
||||||
|
public static void checkNotNullParameter(...);
|
||||||
}
|
}
|
||||||
|
-keep public class ** extends org.koitharu.kotatsu.base.ui.BaseFragment
|
||||||
-keep class org.koitharu.kotatsu.core.db.entity.* { *; }
|
-keep class org.koitharu.kotatsu.core.db.entity.* { *; }
|
||||||
-keepclassmembers public class * extends org.koitharu.kotatsu.core.parser.MangaRepository {
|
-dontwarn okhttp3.internal.platform.ConscryptPlatform
|
||||||
public <init>(...);
|
-keep class org.koitharu.kotatsu.core.exceptions.* { *; }
|
||||||
}
|
-keep class org.koitharu.kotatsu.settings.NotificationSettingsLegacyFragment
|
||||||
-dontwarn okhttp3.internal.platform.ConscryptPlatform
|
|
||||||
8
app/src/androidTest/assets/categories/simple.json
Normal file
8
app/src/androidTest/assets/categories/simple.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"title": "Read later",
|
||||||
|
"sortKey": 1,
|
||||||
|
"order": "NEWEST",
|
||||||
|
"createdAt": 1335906000000,
|
||||||
|
"isTrackingEnabled": true
|
||||||
|
}
|
||||||
163
app/src/androidTest/assets/manga/bad_ids.json
Normal file
163
app/src/androidTest/assets/manga/bad_ids.json
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
{
|
||||||
|
"id": -2096681732556647985,
|
||||||
|
"title": "Странствия Эманон",
|
||||||
|
"url": "/stranstviia_emanon",
|
||||||
|
"publicUrl": "https://readmanga.io/stranstviia_emanon",
|
||||||
|
"rating": 0.9400894,
|
||||||
|
"isNsfw": true,
|
||||||
|
"coverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_p.jpg",
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"title": "Сверхъестественное",
|
||||||
|
"key": "supernatural",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Сэйнэн",
|
||||||
|
"key": "seinen",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Повседневность",
|
||||||
|
"key": "slice_of_life",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Приключения",
|
||||||
|
"key": "adventure",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"state": "FINISHED",
|
||||||
|
"largeCoverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_o.jpg",
|
||||||
|
"description": "Продолжение истории о загадочной девушке по имени Эманон, которая помнит всё, что происходило на Земле за последние три миллиарда лет. \n<br>Начало истории читайте в \"Воспоминаниях Эманон\". \n<div class=\"clearfix\"></div>",
|
||||||
|
"chapters": [
|
||||||
|
{
|
||||||
|
"id": 1552943969433540704,
|
||||||
|
"name": "1 - 1",
|
||||||
|
"number": 1,
|
||||||
|
"url": "/stranstviia_emanon/vol1/1",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433540705,
|
||||||
|
"name": "1 - 2",
|
||||||
|
"number": 2,
|
||||||
|
"url": "/stranstviia_emanon/vol1/2",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433540706,
|
||||||
|
"name": "1 - 3",
|
||||||
|
"number": 3,
|
||||||
|
"url": "/stranstviia_emanon/vol1/3",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433540707,
|
||||||
|
"name": "1 - 4",
|
||||||
|
"number": 4,
|
||||||
|
"url": "/stranstviia_emanon/vol1/4",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433540708,
|
||||||
|
"name": "1 - 5",
|
||||||
|
"number": 5,
|
||||||
|
"url": "/stranstviia_emanon/vol1/5",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433541665,
|
||||||
|
"name": "2 - 1",
|
||||||
|
"number": 6,
|
||||||
|
"url": "/stranstviia_emanon/vol2/1",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1415570400000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433541666,
|
||||||
|
"name": "2 - 2",
|
||||||
|
"number": 7,
|
||||||
|
"url": "/stranstviia_emanon/vol2/2",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1419976800000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433541667,
|
||||||
|
"name": "2 - 3",
|
||||||
|
"number": 8,
|
||||||
|
"url": "/stranstviia_emanon/vol2/3",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1427922000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433541668,
|
||||||
|
"name": "2 - 4",
|
||||||
|
"number": 9,
|
||||||
|
"url": "/stranstviia_emanon/vol2/4",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1436907600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433541669,
|
||||||
|
"name": "2 - 5",
|
||||||
|
"number": 10,
|
||||||
|
"url": "/stranstviia_emanon/vol2/5",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1446674400000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433541670,
|
||||||
|
"name": "2 - 6",
|
||||||
|
"number": 11,
|
||||||
|
"url": "/stranstviia_emanon/vol2/6",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1451512800000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433542626,
|
||||||
|
"name": "3 - 1",
|
||||||
|
"number": 12,
|
||||||
|
"url": "/stranstviia_emanon/vol3/1",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1461618000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433542627,
|
||||||
|
"name": "3 - 2",
|
||||||
|
"number": 13,
|
||||||
|
"url": "/stranstviia_emanon/vol3/2",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1461618000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433542628,
|
||||||
|
"name": "3 - 3",
|
||||||
|
"number": 14,
|
||||||
|
"url": "/stranstviia_emanon/vol3/3",
|
||||||
|
"scanlator": "",
|
||||||
|
"uploadDate": 1465851600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
36
app/src/androidTest/assets/manga/empty.json
Normal file
36
app/src/androidTest/assets/manga/empty.json
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"id": -2096681732556647985,
|
||||||
|
"title": "Странствия Эманон",
|
||||||
|
"url": "/stranstviia_emanon",
|
||||||
|
"publicUrl": "https://readmanga.io/stranstviia_emanon",
|
||||||
|
"rating": 0.9400894,
|
||||||
|
"isNsfw": true,
|
||||||
|
"coverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_p.jpg",
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"title": "Сверхъестественное",
|
||||||
|
"key": "supernatural",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Сэйнэн",
|
||||||
|
"key": "seinen",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Повседневность",
|
||||||
|
"key": "slice_of_life",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Приключения",
|
||||||
|
"key": "adventure",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"state": "FINISHED",
|
||||||
|
"largeCoverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_o.jpg",
|
||||||
|
"description": "Продолжение истории о загадочной девушке по имени Эманон, которая помнит всё, что происходило на Земле за последние три миллиарда лет. \n<br>Начало истории читайте в \"Воспоминаниях Эманон\". \n<div class=\"clearfix\"></div>",
|
||||||
|
"chapters": [],
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
136
app/src/androidTest/assets/manga/first_chapters.json
Normal file
136
app/src/androidTest/assets/manga/first_chapters.json
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
{
|
||||||
|
"id": -2096681732556647985,
|
||||||
|
"title": "Странствия Эманон",
|
||||||
|
"url": "/stranstviia_emanon",
|
||||||
|
"publicUrl": "https://readmanga.io/stranstviia_emanon",
|
||||||
|
"rating": 0.9400894,
|
||||||
|
"isNsfw": true,
|
||||||
|
"coverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_p.jpg",
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"title": "Сверхъестественное",
|
||||||
|
"key": "supernatural",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Сэйнэн",
|
||||||
|
"key": "seinen",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Повседневность",
|
||||||
|
"key": "slice_of_life",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Приключения",
|
||||||
|
"key": "adventure",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"state": "FINISHED",
|
||||||
|
"largeCoverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_o.jpg",
|
||||||
|
"description": "Продолжение истории о загадочной девушке по имени Эманон, которая помнит всё, что происходило на Земле за последние три миллиарда лет. \n<br>Начало истории читайте в \"Воспоминаниях Эманон\". \n<div class=\"clearfix\"></div>",
|
||||||
|
"chapters": [
|
||||||
|
{
|
||||||
|
"id": 3552943969433540704,
|
||||||
|
"name": "1 - 1",
|
||||||
|
"number": 1,
|
||||||
|
"url": "/stranstviia_emanon/vol1/1",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540705,
|
||||||
|
"name": "1 - 2",
|
||||||
|
"number": 2,
|
||||||
|
"url": "/stranstviia_emanon/vol1/2",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540706,
|
||||||
|
"name": "1 - 3",
|
||||||
|
"number": 3,
|
||||||
|
"url": "/stranstviia_emanon/vol1/3",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540707,
|
||||||
|
"name": "1 - 4",
|
||||||
|
"number": 4,
|
||||||
|
"url": "/stranstviia_emanon/vol1/4",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540708,
|
||||||
|
"name": "1 - 5",
|
||||||
|
"number": 5,
|
||||||
|
"url": "/stranstviia_emanon/vol1/5",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541665,
|
||||||
|
"name": "2 - 1",
|
||||||
|
"number": 6,
|
||||||
|
"url": "/stranstviia_emanon/vol2/1",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1415570400000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541666,
|
||||||
|
"name": "2 - 2",
|
||||||
|
"number": 7,
|
||||||
|
"url": "/stranstviia_emanon/vol2/2",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1419976800000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541667,
|
||||||
|
"name": "2 - 3",
|
||||||
|
"number": 8,
|
||||||
|
"url": "/stranstviia_emanon/vol2/3",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1427922000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541668,
|
||||||
|
"name": "2 - 4",
|
||||||
|
"number": 9,
|
||||||
|
"url": "/stranstviia_emanon/vol2/4",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1436907600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541669,
|
||||||
|
"name": "2 - 5",
|
||||||
|
"number": 10,
|
||||||
|
"url": "/stranstviia_emanon/vol2/5",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1446674400000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541670,
|
||||||
|
"name": "2 - 6",
|
||||||
|
"number": 11,
|
||||||
|
"url": "/stranstviia_emanon/vol2/6",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1451512800000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
163
app/src/androidTest/assets/manga/full.json
Normal file
163
app/src/androidTest/assets/manga/full.json
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
{
|
||||||
|
"id": -2096681732556647985,
|
||||||
|
"title": "Странствия Эманон",
|
||||||
|
"url": "/stranstviia_emanon",
|
||||||
|
"publicUrl": "https://readmanga.io/stranstviia_emanon",
|
||||||
|
"rating": 0.9400894,
|
||||||
|
"isNsfw": true,
|
||||||
|
"coverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_p.jpg",
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"title": "Сверхъестественное",
|
||||||
|
"key": "supernatural",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Сэйнэн",
|
||||||
|
"key": "seinen",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Повседневность",
|
||||||
|
"key": "slice_of_life",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Приключения",
|
||||||
|
"key": "adventure",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"state": "FINISHED",
|
||||||
|
"largeCoverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_o.jpg",
|
||||||
|
"description": "Продолжение истории о загадочной девушке по имени Эманон, которая помнит всё, что происходило на Земле за последние три миллиарда лет. \n<br>Начало истории читайте в \"Воспоминаниях Эманон\". \n<div class=\"clearfix\"></div>",
|
||||||
|
"chapters": [
|
||||||
|
{
|
||||||
|
"id": 3552943969433540704,
|
||||||
|
"name": "1 - 1",
|
||||||
|
"number": 1,
|
||||||
|
"url": "/stranstviia_emanon/vol1/1",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540705,
|
||||||
|
"name": "1 - 2",
|
||||||
|
"number": 2,
|
||||||
|
"url": "/stranstviia_emanon/vol1/2",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540706,
|
||||||
|
"name": "1 - 3",
|
||||||
|
"number": 3,
|
||||||
|
"url": "/stranstviia_emanon/vol1/3",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540707,
|
||||||
|
"name": "1 - 4",
|
||||||
|
"number": 4,
|
||||||
|
"url": "/stranstviia_emanon/vol1/4",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540708,
|
||||||
|
"name": "1 - 5",
|
||||||
|
"number": 5,
|
||||||
|
"url": "/stranstviia_emanon/vol1/5",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541665,
|
||||||
|
"name": "2 - 1",
|
||||||
|
"number": 6,
|
||||||
|
"url": "/stranstviia_emanon/vol2/1",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1415570400000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541666,
|
||||||
|
"name": "2 - 2",
|
||||||
|
"number": 7,
|
||||||
|
"url": "/stranstviia_emanon/vol2/2",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1419976800000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541667,
|
||||||
|
"name": "2 - 3",
|
||||||
|
"number": 8,
|
||||||
|
"url": "/stranstviia_emanon/vol2/3",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1427922000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541668,
|
||||||
|
"name": "2 - 4",
|
||||||
|
"number": 9,
|
||||||
|
"url": "/stranstviia_emanon/vol2/4",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1436907600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541669,
|
||||||
|
"name": "2 - 5",
|
||||||
|
"number": 10,
|
||||||
|
"url": "/stranstviia_emanon/vol2/5",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1446674400000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541670,
|
||||||
|
"name": "2 - 6",
|
||||||
|
"number": 11,
|
||||||
|
"url": "/stranstviia_emanon/vol2/6",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1451512800000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433542626,
|
||||||
|
"name": "3 - 1",
|
||||||
|
"number": 12,
|
||||||
|
"url": "/stranstviia_emanon/vol3/1",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1461618000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433542627,
|
||||||
|
"name": "3 - 2",
|
||||||
|
"number": 13,
|
||||||
|
"url": "/stranstviia_emanon/vol3/2",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1461618000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433542628,
|
||||||
|
"name": "3 - 3",
|
||||||
|
"number": 14,
|
||||||
|
"url": "/stranstviia_emanon/vol3/3",
|
||||||
|
"scanlator": "",
|
||||||
|
"uploadDate": 1465851600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
35
app/src/androidTest/assets/manga/header.json
Normal file
35
app/src/androidTest/assets/manga/header.json
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"id": -2096681732556647985,
|
||||||
|
"title": "Странствия Эманон",
|
||||||
|
"url": "/stranstviia_emanon",
|
||||||
|
"publicUrl": "https://readmanga.io/stranstviia_emanon",
|
||||||
|
"rating": 0.9400894,
|
||||||
|
"isNsfw": true,
|
||||||
|
"coverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_p.jpg",
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"title": "Сверхъестественное",
|
||||||
|
"key": "supernatural",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Сэйнэн",
|
||||||
|
"key": "seinen",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Повседневность",
|
||||||
|
"key": "slice_of_life",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Приключения",
|
||||||
|
"key": "adventure",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"state": "FINISHED",
|
||||||
|
"largeCoverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_o.jpg",
|
||||||
|
"description": null,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
154
app/src/androidTest/assets/manga/without_middle_chapter.json
Normal file
154
app/src/androidTest/assets/manga/without_middle_chapter.json
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
{
|
||||||
|
"id": -2096681732556647985,
|
||||||
|
"title": "Странствия Эманон",
|
||||||
|
"url": "/stranstviia_emanon",
|
||||||
|
"publicUrl": "https://readmanga.io/stranstviia_emanon",
|
||||||
|
"rating": 0.9400894,
|
||||||
|
"isNsfw": true,
|
||||||
|
"coverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_p.jpg",
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"title": "Сверхъестественное",
|
||||||
|
"key": "supernatural",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Сэйнэн",
|
||||||
|
"key": "seinen",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Повседневность",
|
||||||
|
"key": "slice_of_life",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Приключения",
|
||||||
|
"key": "adventure",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"state": "FINISHED",
|
||||||
|
"largeCoverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_o.jpg",
|
||||||
|
"description": "Продолжение истории о загадочной девушке по имени Эманон, которая помнит всё, что происходило на Земле за последние три миллиарда лет. \n<br>Начало истории читайте в \"Воспоминаниях Эманон\". \n<div class=\"clearfix\"></div>",
|
||||||
|
"chapters": [
|
||||||
|
{
|
||||||
|
"id": 3552943969433540704,
|
||||||
|
"name": "1 - 1",
|
||||||
|
"number": 1,
|
||||||
|
"url": "/stranstviia_emanon/vol1/1",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540705,
|
||||||
|
"name": "1 - 2",
|
||||||
|
"number": 2,
|
||||||
|
"url": "/stranstviia_emanon/vol1/2",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540706,
|
||||||
|
"name": "1 - 3",
|
||||||
|
"number": 3,
|
||||||
|
"url": "/stranstviia_emanon/vol1/3",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540707,
|
||||||
|
"name": "1 - 4",
|
||||||
|
"number": 4,
|
||||||
|
"url": "/stranstviia_emanon/vol1/4",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540708,
|
||||||
|
"name": "1 - 5",
|
||||||
|
"number": 5,
|
||||||
|
"url": "/stranstviia_emanon/vol1/5",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541666,
|
||||||
|
"name": "2 - 2",
|
||||||
|
"number": 7,
|
||||||
|
"url": "/stranstviia_emanon/vol2/2",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1419976800000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541667,
|
||||||
|
"name": "2 - 3",
|
||||||
|
"number": 8,
|
||||||
|
"url": "/stranstviia_emanon/vol2/3",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1427922000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541668,
|
||||||
|
"name": "2 - 4",
|
||||||
|
"number": 9,
|
||||||
|
"url": "/stranstviia_emanon/vol2/4",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1436907600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541669,
|
||||||
|
"name": "2 - 5",
|
||||||
|
"number": 10,
|
||||||
|
"url": "/stranstviia_emanon/vol2/5",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1446674400000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541670,
|
||||||
|
"name": "2 - 6",
|
||||||
|
"number": 11,
|
||||||
|
"url": "/stranstviia_emanon/vol2/6",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1451512800000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433542626,
|
||||||
|
"name": "3 - 1",
|
||||||
|
"number": 12,
|
||||||
|
"url": "/stranstviia_emanon/vol3/1",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1461618000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433542627,
|
||||||
|
"name": "3 - 2",
|
||||||
|
"number": 13,
|
||||||
|
"url": "/stranstviia_emanon/vol3/2",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1461618000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433542628,
|
||||||
|
"name": "3 - 3",
|
||||||
|
"number": 14,
|
||||||
|
"url": "/stranstviia_emanon/vol3/3",
|
||||||
|
"scanlator": "",
|
||||||
|
"uploadDate": 1465851600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package org.koitharu.kotatsu
|
||||||
|
|
||||||
|
import android.app.Instrumentation
|
||||||
|
import kotlin.coroutines.resume
|
||||||
|
import kotlin.coroutines.suspendCoroutine
|
||||||
|
|
||||||
|
suspend fun Instrumentation.awaitForIdle() = suspendCoroutine<Unit> { cont ->
|
||||||
|
waitForIdle { cont.resume(Unit) }
|
||||||
|
}
|
||||||
54
app/src/androidTest/java/org/koitharu/kotatsu/SampleData.kt
Normal file
54
app/src/androidTest/java/org/koitharu/kotatsu/SampleData.kt
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
package org.koitharu.kotatsu
|
||||||
|
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import com.squareup.moshi.*
|
||||||
|
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
|
||||||
|
import okio.buffer
|
||||||
|
import okio.source
|
||||||
|
import org.koitharu.kotatsu.core.model.FavouriteCategory
|
||||||
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
object SampleData {
|
||||||
|
|
||||||
|
private val moshi = Moshi.Builder()
|
||||||
|
.add(DateAdapter())
|
||||||
|
.add(KotlinJsonAdapterFactory())
|
||||||
|
.build()
|
||||||
|
|
||||||
|
val manga: Manga = loadAsset("manga/header.json", Manga::class)
|
||||||
|
|
||||||
|
val mangaDetails: Manga = loadAsset("manga/full.json", Manga::class)
|
||||||
|
|
||||||
|
val tag = mangaDetails.tags.elementAt(2)
|
||||||
|
|
||||||
|
val chapter = checkNotNull(mangaDetails.chapters)[2]
|
||||||
|
|
||||||
|
val favouriteCategory: FavouriteCategory = loadAsset("categories/simple.json", FavouriteCategory::class)
|
||||||
|
|
||||||
|
fun <T : Any> loadAsset(name: String, cls: KClass<T>): T {
|
||||||
|
val assets = InstrumentationRegistry.getInstrumentation().context.assets
|
||||||
|
return assets.open(name).use {
|
||||||
|
moshi.adapter(cls.java).fromJson(it.source().buffer())
|
||||||
|
} ?: throw RuntimeException("Cannot read asset from json \"$name\"")
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DateAdapter : JsonAdapter<Date>() {
|
||||||
|
|
||||||
|
@FromJson
|
||||||
|
override fun fromJson(reader: JsonReader): Date? {
|
||||||
|
val ms = reader.nextLong()
|
||||||
|
return if (ms == 0L) {
|
||||||
|
null
|
||||||
|
} else {
|
||||||
|
Date(ms)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ToJson
|
||||||
|
override fun toJson(writer: JsonWriter, value: Date?) {
|
||||||
|
writer.value(value?.time ?: 0L)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package org.koitharu.kotatsu.core.db
|
||||||
|
|
||||||
|
import androidx.room.testing.MigrationTestHelper
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class MangaDatabaseTest {
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
val helper: MigrationTestHelper = MigrationTestHelper(
|
||||||
|
InstrumentationRegistry.getInstrumentation(),
|
||||||
|
MangaDatabase::class.java,
|
||||||
|
)
|
||||||
|
|
||||||
|
private val migrations = databaseMigrations
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun versions() {
|
||||||
|
assertEquals(1, migrations.first().startVersion)
|
||||||
|
repeat(migrations.size) { i ->
|
||||||
|
assertEquals(i + 1, migrations[i].startVersion)
|
||||||
|
assertEquals(i + 2, migrations[i].endVersion)
|
||||||
|
}
|
||||||
|
assertEquals(DATABASE_VERSION, migrations.last().endVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun migrateAll() {
|
||||||
|
helper.createDatabase(TEST_DB, 1).close()
|
||||||
|
for (migration in migrations) {
|
||||||
|
helper.runMigrationsAndValidate(
|
||||||
|
TEST_DB,
|
||||||
|
migration.endVersion,
|
||||||
|
true,
|
||||||
|
migration
|
||||||
|
).close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun prePopulate() {
|
||||||
|
val resources = InstrumentationRegistry.getInstrumentation().targetContext.resources
|
||||||
|
helper.createDatabase(TEST_DB, DATABASE_VERSION).use {
|
||||||
|
DatabasePrePopulateCallback(resources).onCreate(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
|
||||||
|
const val TEST_DB = "test-db"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package org.koitharu.kotatsu.core.os
|
||||||
|
|
||||||
|
import android.content.pm.ShortcutInfo
|
||||||
|
import android.content.pm.ShortcutManager
|
||||||
|
import android.os.Build
|
||||||
|
import androidx.core.content.getSystemService
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.koin.test.KoinTest
|
||||||
|
import org.koin.test.inject
|
||||||
|
import org.koitharu.kotatsu.SampleData
|
||||||
|
import org.koitharu.kotatsu.awaitForIdle
|
||||||
|
import org.koitharu.kotatsu.core.db.MangaDatabase
|
||||||
|
import org.koitharu.kotatsu.history.domain.HistoryRepository
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class ShortcutsUpdaterTest : KoinTest {
|
||||||
|
|
||||||
|
private val historyRepository by inject<HistoryRepository>()
|
||||||
|
private val shortcutsUpdater by inject<ShortcutsUpdater>()
|
||||||
|
private val database by inject<MangaDatabase>()
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun setUp() {
|
||||||
|
database.clearAllTables()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testUpdateShortcuts() = runTest {
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
|
||||||
|
return@runTest
|
||||||
|
}
|
||||||
|
awaitUpdate()
|
||||||
|
assertTrue(getShortcuts().isEmpty())
|
||||||
|
historyRepository.addOrUpdate(
|
||||||
|
manga = SampleData.manga,
|
||||||
|
chapterId = SampleData.chapter.id,
|
||||||
|
page = 4,
|
||||||
|
scroll = 2,
|
||||||
|
percent = 0.3f
|
||||||
|
)
|
||||||
|
awaitUpdate()
|
||||||
|
|
||||||
|
val shortcuts = getShortcuts()
|
||||||
|
assertEquals(1, shortcuts.size)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getShortcuts(): List<ShortcutInfo> {
|
||||||
|
val context = InstrumentationRegistry.getInstrumentation().targetContext
|
||||||
|
val manager = checkNotNull(context.getSystemService<ShortcutManager>())
|
||||||
|
return manager.dynamicShortcuts.filterNot { it.id == "com.squareup.leakcanary.dynamic_shortcut" }
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun awaitUpdate() {
|
||||||
|
val instrumentation = InstrumentationRegistry.getInstrumentation()
|
||||||
|
instrumentation.awaitForIdle()
|
||||||
|
shortcutsUpdater.await()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package org.koitharu.kotatsu.settings.backup
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.koin.test.KoinTest
|
||||||
|
import org.koin.test.get
|
||||||
|
import org.koin.test.inject
|
||||||
|
import org.koitharu.kotatsu.SampleData
|
||||||
|
import org.koitharu.kotatsu.core.backup.BackupRepository
|
||||||
|
import org.koitharu.kotatsu.core.db.MangaDatabase
|
||||||
|
import org.koitharu.kotatsu.core.db.entity.toMangaTags
|
||||||
|
import org.koitharu.kotatsu.favourites.domain.FavouritesRepository
|
||||||
|
import org.koitharu.kotatsu.history.domain.HistoryRepository
|
||||||
|
import kotlin.test.*
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class AppBackupAgentTest : KoinTest {
|
||||||
|
|
||||||
|
private val historyRepository by inject<HistoryRepository>()
|
||||||
|
private val favouritesRepository by inject<FavouritesRepository>()
|
||||||
|
private val backupRepository by inject<BackupRepository>()
|
||||||
|
private val database by inject<MangaDatabase>()
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun setUp() {
|
||||||
|
database.clearAllTables()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testBackupRestore() = runTest {
|
||||||
|
val category = favouritesRepository.createCategory(
|
||||||
|
title = SampleData.favouriteCategory.title,
|
||||||
|
sortOrder = SampleData.favouriteCategory.order,
|
||||||
|
isTrackerEnabled = SampleData.favouriteCategory.isTrackingEnabled,
|
||||||
|
)
|
||||||
|
favouritesRepository.addToCategory(categoryId = category.id, mangas = listOf(SampleData.manga))
|
||||||
|
historyRepository.addOrUpdate(
|
||||||
|
manga = SampleData.mangaDetails,
|
||||||
|
chapterId = SampleData.mangaDetails.chapters!![2].id,
|
||||||
|
page = 3,
|
||||||
|
scroll = 40,
|
||||||
|
percent = 0.2f,
|
||||||
|
)
|
||||||
|
val history = checkNotNull(historyRepository.getOne(SampleData.manga))
|
||||||
|
|
||||||
|
val agent = AppBackupAgent()
|
||||||
|
val backup = agent.createBackupFile(get(), backupRepository)
|
||||||
|
|
||||||
|
database.clearAllTables()
|
||||||
|
assertTrue(favouritesRepository.getAllManga().isEmpty())
|
||||||
|
assertNull(historyRepository.getLastOrNull())
|
||||||
|
|
||||||
|
backup.inputStream().use {
|
||||||
|
agent.restoreBackupFile(it.fd, backup.length(), backupRepository)
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(category, favouritesRepository.getCategory(category.id))
|
||||||
|
assertEquals(history, historyRepository.getOne(SampleData.manga))
|
||||||
|
assertContentEquals(listOf(SampleData.manga), favouritesRepository.getManga(category.id))
|
||||||
|
|
||||||
|
val allTags = database.tagsDao.findTags(SampleData.tag.source.name).toMangaTags()
|
||||||
|
assertContains(allTags, SampleData.tag)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,183 @@
|
|||||||
|
package org.koitharu.kotatsu.tracker.domain
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.koin.test.KoinTest
|
||||||
|
import org.koin.test.inject
|
||||||
|
import org.koitharu.kotatsu.SampleData
|
||||||
|
import org.koitharu.kotatsu.base.domain.MangaDataRepository
|
||||||
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertFalse
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class TrackerTest : KoinTest {
|
||||||
|
|
||||||
|
private val repository by inject<TrackingRepository>()
|
||||||
|
private val dataRepository by inject<MangaDataRepository>()
|
||||||
|
private val tracker by inject<Tracker>()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun noUpdates() = runTest {
|
||||||
|
val manga = loadManga("full.json")
|
||||||
|
tracker.deleteTrack(manga.id)
|
||||||
|
|
||||||
|
tracker.checkUpdates(manga, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(manga.id))
|
||||||
|
tracker.checkUpdates(manga, commit = true).apply {
|
||||||
|
assertTrue(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(manga.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun hasUpdates() = runTest {
|
||||||
|
val mangaFirst = loadManga("first_chapters.json")
|
||||||
|
val mangaFull = loadManga("full.json")
|
||||||
|
tracker.deleteTrack(mangaFirst.id)
|
||||||
|
|
||||||
|
tracker.checkUpdates(mangaFirst, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
tracker.checkUpdates(mangaFull, commit = true).apply {
|
||||||
|
assertTrue(isValid)
|
||||||
|
assertEquals(3, newChapters.size)
|
||||||
|
}
|
||||||
|
assertEquals(3, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
tracker.checkUpdates(mangaFull, commit = true).apply {
|
||||||
|
assertTrue(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(3, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun badIds() = runTest {
|
||||||
|
val mangaFirst = loadManga("first_chapters.json")
|
||||||
|
val mangaBad = loadManga("bad_ids.json")
|
||||||
|
tracker.deleteTrack(mangaFirst.id)
|
||||||
|
|
||||||
|
tracker.checkUpdates(mangaFirst, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
tracker.checkUpdates(mangaBad, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
tracker.checkUpdates(mangaFirst, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun badIds2() = runTest {
|
||||||
|
val mangaFirst = loadManga("first_chapters.json")
|
||||||
|
val mangaBad = loadManga("bad_ids.json")
|
||||||
|
val mangaFull = loadManga("full.json")
|
||||||
|
tracker.deleteTrack(mangaFirst.id)
|
||||||
|
|
||||||
|
tracker.checkUpdates(mangaFirst, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
tracker.checkUpdates(mangaFull, commit = true).apply {
|
||||||
|
assertTrue(isValid)
|
||||||
|
assertEquals(3, newChapters.size)
|
||||||
|
}
|
||||||
|
assertEquals(3, repository.getNewChaptersCount(mangaFull.id))
|
||||||
|
tracker.checkUpdates(mangaBad, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun fullReset() = runTest {
|
||||||
|
val mangaFull = loadManga("full.json")
|
||||||
|
val mangaFirst = loadManga("first_chapters.json")
|
||||||
|
val mangaEmpty = loadManga("empty.json")
|
||||||
|
tracker.deleteTrack(mangaFull.id)
|
||||||
|
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFull.id))
|
||||||
|
tracker.checkUpdates(mangaFull, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFull.id))
|
||||||
|
tracker.checkUpdates(mangaEmpty, commit = true).apply {
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFull.id))
|
||||||
|
tracker.checkUpdates(mangaFirst, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFull.id))
|
||||||
|
tracker.checkUpdates(mangaFull, commit = true).apply {
|
||||||
|
assertTrue(isValid)
|
||||||
|
assertEquals(3, newChapters.size)
|
||||||
|
}
|
||||||
|
assertEquals(3, repository.getNewChaptersCount(mangaFull.id))
|
||||||
|
tracker.checkUpdates(mangaEmpty, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFull.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun syncWithHistory() = runTest {
|
||||||
|
val mangaFull = loadManga("full.json")
|
||||||
|
val mangaFirst = loadManga("first_chapters.json")
|
||||||
|
tracker.deleteTrack(mangaFull.id)
|
||||||
|
|
||||||
|
tracker.checkUpdates(mangaFirst, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
tracker.checkUpdates(mangaFull, commit = true).apply {
|
||||||
|
assertTrue(isValid)
|
||||||
|
assertEquals(3, newChapters.size)
|
||||||
|
}
|
||||||
|
assertEquals(3, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
|
||||||
|
var chapter = requireNotNull(mangaFull.chapters).run { get(lastIndex - 1) }
|
||||||
|
repository.syncWithHistory(mangaFull, chapter.id)
|
||||||
|
|
||||||
|
assertEquals(1, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
|
||||||
|
chapter = requireNotNull(mangaFull.chapters).run { get(lastIndex) }
|
||||||
|
repository.syncWithHistory(mangaFull, chapter.id)
|
||||||
|
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
|
||||||
|
tracker.checkUpdates(mangaFull, commit = true).apply {
|
||||||
|
assertTrue(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun loadManga(name: String): Manga {
|
||||||
|
val manga = SampleData.loadAsset("manga/$name", Manga::class)
|
||||||
|
dataRepository.storeManga(manga)
|
||||||
|
return manga
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package org.koitharu.kotatsu.core.parser
|
||||||
|
|
||||||
|
import java.util.*
|
||||||
|
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
||||||
|
import org.koitharu.kotatsu.parsers.MangaParser
|
||||||
|
import org.koitharu.kotatsu.parsers.config.ConfigKey
|
||||||
|
import org.koitharu.kotatsu.parsers.model.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This parser is just for parser development, it should not be used in releases
|
||||||
|
*/
|
||||||
|
class DummyParser(override val context: MangaLoaderContext) : MangaParser(MangaSource.DUMMY) {
|
||||||
|
|
||||||
|
override val configKeyDomain: ConfigKey.Domain
|
||||||
|
get() = ConfigKey.Domain("", null)
|
||||||
|
|
||||||
|
override val sortOrders: Set<SortOrder>
|
||||||
|
get() = EnumSet.allOf(SortOrder::class.java)
|
||||||
|
|
||||||
|
override suspend fun getDetails(manga: Manga): Manga {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun getList(
|
||||||
|
offset: Int,
|
||||||
|
query: String?,
|
||||||
|
tags: Set<MangaTag>?,
|
||||||
|
sortOrder: SortOrder,
|
||||||
|
): List<Manga> {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun getPages(chapter: MangaChapter): List<MangaPage> {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun getTags(): Set<MangaTag> {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package org.koitharu.kotatsu.core.parser
|
||||||
|
|
||||||
|
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
||||||
|
import org.koitharu.kotatsu.parsers.MangaParser
|
||||||
|
import org.koitharu.kotatsu.parsers.model.MangaSource
|
||||||
|
import org.koitharu.kotatsu.parsers.newParser
|
||||||
|
|
||||||
|
fun MangaParser(source: MangaSource, loaderContext: MangaLoaderContext): MangaParser {
|
||||||
|
return if (source == MangaSource.DUMMY) {
|
||||||
|
DummyParser(loaderContext)
|
||||||
|
} else {
|
||||||
|
source.newParser(loaderContext)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package org.koitharu.kotatsu.utils.ext
|
||||||
|
|
||||||
|
fun Throwable.printStackTraceDebug() = printStackTrace()
|
||||||
@@ -4,9 +4,8 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_search_internal"
|
android:id="@id/action_leaks"
|
||||||
android:orderInCategory="26"
|
android:title="@string/leak_canary_display_activity_label"
|
||||||
android:title="@string/search"
|
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
4
app/src/debug/res/values/bools.xml
Normal file
4
app/src/debug/res/values/bools.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<bool name="leak_canary_add_launcher_icon" tools:node="replace">false</bool>
|
||||||
|
</resources>
|
||||||
@@ -1,43 +1,52 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest
|
<manifest
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
package="org.koitharu.kotatsu">
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
|
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name="org.koitharu.kotatsu.KotatsuApp"
|
android:name="org.koitharu.kotatsu.KotatsuApp"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:fullBackupContent="@xml/backup_descriptor"
|
android:backupAgent="org.koitharu.kotatsu.settings.backup.AppBackupAgent"
|
||||||
|
android:dataExtractionRules="@xml/backup_rules"
|
||||||
|
android:fullBackupContent="@xml/backup_content"
|
||||||
|
android:fullBackupOnly="true"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
android:networkSecurityConfig="@xml/network_security_config"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/Theme.Kotatsu"
|
||||||
android:usesCleartextTraffic="true"
|
|
||||||
tools:ignore="UnusedAttribute">
|
tools:ignore="UnusedAttribute">
|
||||||
<activity android:name="org.koitharu.kotatsu.main.ui.MainActivity">
|
|
||||||
|
<activity
|
||||||
|
android:name="org.koitharu.kotatsu.main.ui.MainActivity"
|
||||||
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.app.default_searchable"
|
android:name="android.app.default_searchable"
|
||||||
android:value=".ui.search.SearchActivity" />
|
android:value="org.koitharu.kotatsu.ui.search.SearchActivity" />
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="org.koitharu.kotatsu.details.ui.DetailsActivity">
|
<activity
|
||||||
|
android:name="org.koitharu.kotatsu.details.ui.DetailsActivity"
|
||||||
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="${applicationId}.action.VIEW_MANGA" />
|
<action android:name="${applicationId}.action.VIEW_MANGA" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="org.koitharu.kotatsu.reader.ui.ReaderActivity">
|
<activity
|
||||||
|
android:name="org.koitharu.kotatsu.reader.ui.ReaderActivity"
|
||||||
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="${applicationId}.action.READ_MANGA" />
|
<action android:name="${applicationId}.action.READ_MANGA" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
@@ -46,43 +55,65 @@
|
|||||||
android:name="org.koitharu.kotatsu.search.ui.SearchActivity"
|
android:name="org.koitharu.kotatsu.search.ui.SearchActivity"
|
||||||
android:label="@string/search" />
|
android:label="@string/search" />
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.settings.SettingsActivity"
|
android:name="org.koitharu.kotatsu.search.ui.MangaListActivity"
|
||||||
android:label="@string/settings" />
|
android:label="@string/search_manga" />
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.reader.ui.SimpleSettingsActivity"
|
android:name="org.koitharu.kotatsu.settings.SettingsActivity"
|
||||||
|
android:exported="true"
|
||||||
android:label="@string/settings">
|
android:label="@string/settings">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MANAGE_NETWORK_USAGE" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data android:scheme="kotatsu" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="org.koitharu.kotatsu.browser.BrowserActivity" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.core.ui.CrashActivity"
|
android:name="org.koitharu.kotatsu.browser.BrowserActivity"
|
||||||
android:label="@string/error_occurred"
|
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
|
||||||
android:theme="@android:style/Theme.DeviceDefault"
|
android:windowSoftInputMode="adjustResize" />
|
||||||
android:windowSoftInputMode="stateAlwaysHidden" />
|
<activity
|
||||||
|
android:name="org.koitharu.kotatsu.settings.sources.auth.SourceAuthActivity"
|
||||||
|
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
|
||||||
|
android:windowSoftInputMode="adjustResize" />
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.favourites.ui.categories.CategoriesActivity"
|
android:name="org.koitharu.kotatsu.favourites.ui.categories.CategoriesActivity"
|
||||||
android:label="@string/favourites_categories"
|
android:label="@string/favourites_categories"
|
||||||
android:windowSoftInputMode="stateAlwaysHidden" />
|
android:windowSoftInputMode="stateAlwaysHidden" />
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.widget.shelf.ShelfConfigActivity"
|
android:name="org.koitharu.kotatsu.widget.shelf.ShelfConfigActivity"
|
||||||
android:label="@string/manga_shelf">
|
android:exported="true"
|
||||||
|
android:label="@string/manga_shelf"
|
||||||
|
android:theme="@style/Theme.Kotatsu.DialogWhenLarge">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
|
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.search.ui.global.GlobalSearchActivity"
|
android:name="org.koitharu.kotatsu.search.ui.multi.MultiSearchActivity"
|
||||||
android:label="@string/search" />
|
android:label="@string/search" />
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.main.ui.protect.ProtectActivity"
|
android:name="org.koitharu.kotatsu.main.ui.protect.ProtectActivity"
|
||||||
|
android:noHistory="true"
|
||||||
android:windowSoftInputMode="adjustResize" />
|
android:windowSoftInputMode="adjustResize" />
|
||||||
|
<activity
|
||||||
|
android:name="org.koitharu.kotatsu.settings.protect.ProtectSetupActivity"
|
||||||
|
android:windowSoftInputMode="adjustResize" />
|
||||||
|
<activity
|
||||||
|
android:name="org.koitharu.kotatsu.download.ui.DownloadsActivity"
|
||||||
|
android:label="@string/downloads"
|
||||||
|
android:launchMode="singleTop"
|
||||||
|
android:theme="@style/Theme.Kotatsu.DialogWhenLarge" />
|
||||||
|
<activity android:name="org.koitharu.kotatsu.image.ui.ImageActivity" />
|
||||||
|
<activity
|
||||||
|
android:name="org.koitharu.kotatsu.favourites.ui.categories.edit.FavouritesCategoryEditActivity"
|
||||||
|
android:theme="@style/Theme.Kotatsu.DialogWhenLarge" />
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name="org.koitharu.kotatsu.download.DownloadService"
|
android:name="org.koitharu.kotatsu.download.ui.service.DownloadService"
|
||||||
|
android:stopWithTask="false"
|
||||||
android:foregroundServiceType="dataSync" />
|
android:foregroundServiceType="dataSync" />
|
||||||
|
<service android:name="org.koitharu.kotatsu.local.ui.LocalChaptersRemoveService" />
|
||||||
<service
|
<service
|
||||||
android:name="org.koitharu.kotatsu.widget.shelf.ShelfWidgetService"
|
android:name="org.koitharu.kotatsu.widget.shelf.ShelfWidgetService"
|
||||||
android:permission="android.permission.BIND_REMOTEVIEWS" />
|
android:permission="android.permission.BIND_REMOTEVIEWS" />
|
||||||
@@ -127,9 +158,11 @@
|
|||||||
android:resource="@xml/widget_recent" />
|
android:resource="@xml/widget_recent" />
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<meta-data android:name="android.webkit.WebView.EnableSafeBrowsing"
|
<meta-data
|
||||||
|
android:name="android.webkit.WebView.EnableSafeBrowsing"
|
||||||
android:value="false" />
|
android:value="false" />
|
||||||
<meta-data android:name="android.webkit.WebView.MetricsOptOut"
|
<meta-data
|
||||||
|
android:name="android.webkit.WebView.MetricsOptOut"
|
||||||
android:value="true" />
|
android:value="true" />
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|||||||
@@ -1,34 +1,43 @@
|
|||||||
package org.koitharu.kotatsu
|
package org.koitharu.kotatsu
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
|
import android.content.Context
|
||||||
import android.os.StrictMode
|
import android.os.StrictMode
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
|
import androidx.fragment.app.strictmode.FragmentStrictMode
|
||||||
|
import androidx.room.InvalidationTracker
|
||||||
|
import org.acra.ReportField
|
||||||
|
import org.acra.config.dialog
|
||||||
|
import org.acra.config.httpSender
|
||||||
|
import org.acra.data.StringFormat
|
||||||
|
import org.acra.ktx.initAcra
|
||||||
|
import org.acra.sender.HttpSender
|
||||||
import org.koin.android.ext.android.get
|
import org.koin.android.ext.android.get
|
||||||
|
import org.koin.android.ext.android.getKoin
|
||||||
import org.koin.android.ext.koin.androidContext
|
import org.koin.android.ext.koin.androidContext
|
||||||
import org.koin.core.context.startKoin
|
import org.koin.core.context.startKoin
|
||||||
import org.koitharu.kotatsu.base.domain.MangaLoaderContext
|
import org.koitharu.kotatsu.bookmarks.bookmarksModule
|
||||||
|
import org.koitharu.kotatsu.core.db.MangaDatabase
|
||||||
import org.koitharu.kotatsu.core.db.databaseModule
|
import org.koitharu.kotatsu.core.db.databaseModule
|
||||||
import org.koitharu.kotatsu.core.github.githubModule
|
import org.koitharu.kotatsu.core.github.githubModule
|
||||||
import org.koitharu.kotatsu.core.network.networkModule
|
import org.koitharu.kotatsu.core.network.networkModule
|
||||||
import org.koitharu.kotatsu.core.parser.parserModule
|
|
||||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||||
import org.koitharu.kotatsu.core.ui.AppCrashHandler
|
|
||||||
import org.koitharu.kotatsu.core.ui.uiModule
|
import org.koitharu.kotatsu.core.ui.uiModule
|
||||||
import org.koitharu.kotatsu.details.detailsModule
|
import org.koitharu.kotatsu.details.detailsModule
|
||||||
import org.koitharu.kotatsu.favourites.domain.FavouritesRepository
|
|
||||||
import org.koitharu.kotatsu.favourites.favouritesModule
|
import org.koitharu.kotatsu.favourites.favouritesModule
|
||||||
import org.koitharu.kotatsu.history.domain.HistoryRepository
|
|
||||||
import org.koitharu.kotatsu.history.historyModule
|
import org.koitharu.kotatsu.history.historyModule
|
||||||
import org.koitharu.kotatsu.local.data.PagesCache
|
import org.koitharu.kotatsu.local.data.PagesCache
|
||||||
import org.koitharu.kotatsu.local.domain.LocalMangaRepository
|
import org.koitharu.kotatsu.local.domain.LocalMangaRepository
|
||||||
import org.koitharu.kotatsu.local.localModule
|
import org.koitharu.kotatsu.local.localModule
|
||||||
import org.koitharu.kotatsu.main.mainModule
|
import org.koitharu.kotatsu.main.mainModule
|
||||||
|
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
||||||
import org.koitharu.kotatsu.reader.readerModule
|
import org.koitharu.kotatsu.reader.readerModule
|
||||||
import org.koitharu.kotatsu.remotelist.remoteListModule
|
import org.koitharu.kotatsu.remotelist.remoteListModule
|
||||||
|
import org.koitharu.kotatsu.scrobbling.shikimori.shikimoriModule
|
||||||
import org.koitharu.kotatsu.search.searchModule
|
import org.koitharu.kotatsu.search.searchModule
|
||||||
import org.koitharu.kotatsu.settings.settingsModule
|
import org.koitharu.kotatsu.settings.settingsModule
|
||||||
|
import org.koitharu.kotatsu.suggestions.suggestionsModule
|
||||||
import org.koitharu.kotatsu.tracker.trackerModule
|
import org.koitharu.kotatsu.tracker.trackerModule
|
||||||
import org.koitharu.kotatsu.widget.WidgetUpdater
|
|
||||||
import org.koitharu.kotatsu.widget.appWidgetModule
|
import org.koitharu.kotatsu.widget.appWidgetModule
|
||||||
|
|
||||||
class KotatsuApp : Application() {
|
class KotatsuApp : Application() {
|
||||||
@@ -36,28 +45,12 @@ class KotatsuApp : Application() {
|
|||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
StrictMode.setThreadPolicy(
|
enableStrictMode()
|
||||||
StrictMode.ThreadPolicy.Builder()
|
|
||||||
.detectAll()
|
|
||||||
.penaltyLog()
|
|
||||||
.build()
|
|
||||||
)
|
|
||||||
StrictMode.setVmPolicy(
|
|
||||||
StrictMode.VmPolicy.Builder()
|
|
||||||
.detectAll()
|
|
||||||
.setClassInstanceLimit(LocalMangaRepository::class.java, 1)
|
|
||||||
.setClassInstanceLimit(PagesCache::class.java, 1)
|
|
||||||
.setClassInstanceLimit(MangaLoaderContext::class.java, 1)
|
|
||||||
.penaltyLog()
|
|
||||||
.build()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
initKoin()
|
initKoin()
|
||||||
Thread.setDefaultUncaughtExceptionHandler(AppCrashHandler(applicationContext))
|
|
||||||
AppCompatDelegate.setDefaultNightMode(get<AppSettings>().theme)
|
AppCompatDelegate.setDefaultNightMode(get<AppSettings>().theme)
|
||||||
val widgetUpdater = WidgetUpdater(applicationContext)
|
setupActivityLifecycleCallbacks()
|
||||||
FavouritesRepository.subscribe(widgetUpdater)
|
setupDatabaseObservers()
|
||||||
HistoryRepository.subscribe(widgetUpdater)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initKoin() {
|
private fun initKoin() {
|
||||||
@@ -68,7 +61,6 @@ class KotatsuApp : Application() {
|
|||||||
databaseModule,
|
databaseModule,
|
||||||
githubModule,
|
githubModule,
|
||||||
uiModule,
|
uiModule,
|
||||||
parserModule,
|
|
||||||
mainModule,
|
mainModule,
|
||||||
searchModule,
|
searchModule,
|
||||||
localModule,
|
localModule,
|
||||||
@@ -79,8 +71,87 @@ class KotatsuApp : Application() {
|
|||||||
trackerModule,
|
trackerModule,
|
||||||
settingsModule,
|
settingsModule,
|
||||||
readerModule,
|
readerModule,
|
||||||
appWidgetModule
|
appWidgetModule,
|
||||||
|
suggestionsModule,
|
||||||
|
shikimoriModule,
|
||||||
|
bookmarksModule,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun attachBaseContext(base: Context?) {
|
||||||
|
super.attachBaseContext(base)
|
||||||
|
initAcra {
|
||||||
|
buildConfigClass = BuildConfig::class.java
|
||||||
|
reportFormat = StringFormat.JSON
|
||||||
|
excludeMatchingSharedPreferencesKeys = listOf(
|
||||||
|
"sources_\\w+",
|
||||||
|
)
|
||||||
|
httpSender {
|
||||||
|
uri = getString(R.string.url_error_report)
|
||||||
|
basicAuthLogin = getString(R.string.acra_login)
|
||||||
|
basicAuthPassword = getString(R.string.acra_password)
|
||||||
|
httpMethod = HttpSender.Method.POST
|
||||||
|
}
|
||||||
|
reportContent = listOf(
|
||||||
|
ReportField.PACKAGE_NAME,
|
||||||
|
ReportField.APP_VERSION_CODE,
|
||||||
|
ReportField.APP_VERSION_NAME,
|
||||||
|
ReportField.ANDROID_VERSION,
|
||||||
|
ReportField.PHONE_MODEL,
|
||||||
|
ReportField.STACK_TRACE,
|
||||||
|
ReportField.CRASH_CONFIGURATION,
|
||||||
|
ReportField.SHARED_PREFERENCES,
|
||||||
|
)
|
||||||
|
dialog {
|
||||||
|
text = getString(R.string.crash_text)
|
||||||
|
title = getString(R.string.error_occurred)
|
||||||
|
positiveButtonText = getString(R.string.send)
|
||||||
|
resIcon = R.drawable.ic_alert_outline
|
||||||
|
resTheme = android.R.style.Theme_Material_Light_Dialog_Alert
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupDatabaseObservers() {
|
||||||
|
val observers = getKoin().getAll<InvalidationTracker.Observer>()
|
||||||
|
val database = get<MangaDatabase>()
|
||||||
|
val tracker = database.invalidationTracker
|
||||||
|
observers.forEach {
|
||||||
|
tracker.addObserver(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupActivityLifecycleCallbacks() {
|
||||||
|
val callbacks = getKoin().getAll<ActivityLifecycleCallbacks>()
|
||||||
|
callbacks.forEach {
|
||||||
|
registerActivityLifecycleCallbacks(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun enableStrictMode() {
|
||||||
|
StrictMode.setThreadPolicy(
|
||||||
|
StrictMode.ThreadPolicy.Builder()
|
||||||
|
.detectAll()
|
||||||
|
.penaltyLog()
|
||||||
|
.build(),
|
||||||
|
)
|
||||||
|
StrictMode.setVmPolicy(
|
||||||
|
StrictMode.VmPolicy.Builder()
|
||||||
|
.detectAll()
|
||||||
|
.setClassInstanceLimit(LocalMangaRepository::class.java, 1)
|
||||||
|
.setClassInstanceLimit(PagesCache::class.java, 1)
|
||||||
|
.setClassInstanceLimit(MangaLoaderContext::class.java, 1)
|
||||||
|
.penaltyLog()
|
||||||
|
.build(),
|
||||||
|
)
|
||||||
|
FragmentStrictMode.defaultPolicy = FragmentStrictMode.Policy.Builder()
|
||||||
|
.penaltyDeath()
|
||||||
|
.detectFragmentReuse()
|
||||||
|
.detectWrongFragmentContainer()
|
||||||
|
.detectRetainInstanceUsage()
|
||||||
|
.detectSetUserVisibleHint()
|
||||||
|
.detectFragmentTagUsage()
|
||||||
|
.build()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,19 +2,19 @@ package org.koitharu.kotatsu.base.domain
|
|||||||
|
|
||||||
import androidx.room.withTransaction
|
import androidx.room.withTransaction
|
||||||
import org.koitharu.kotatsu.core.db.MangaDatabase
|
import org.koitharu.kotatsu.core.db.MangaDatabase
|
||||||
import org.koitharu.kotatsu.core.db.entity.MangaEntity
|
import org.koitharu.kotatsu.core.db.entity.*
|
||||||
import org.koitharu.kotatsu.core.db.entity.MangaPrefsEntity
|
|
||||||
import org.koitharu.kotatsu.core.db.entity.TagEntity
|
|
||||||
import org.koitharu.kotatsu.core.model.Manga
|
|
||||||
import org.koitharu.kotatsu.core.prefs.ReaderMode
|
import org.koitharu.kotatsu.core.prefs.ReaderMode
|
||||||
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
|
import org.koitharu.kotatsu.parsers.model.MangaSource
|
||||||
|
import org.koitharu.kotatsu.parsers.model.MangaTag
|
||||||
|
|
||||||
class MangaDataRepository(private val db: MangaDatabase) {
|
class MangaDataRepository(private val db: MangaDatabase) {
|
||||||
|
|
||||||
suspend fun savePreferences(manga: Manga, mode: ReaderMode) {
|
suspend fun savePreferences(manga: Manga, mode: ReaderMode) {
|
||||||
val tags = manga.tags.map(TagEntity.Companion::fromMangaTag)
|
val tags = manga.tags.toEntities()
|
||||||
db.withTransaction {
|
db.withTransaction {
|
||||||
db.tagsDao.upsert(tags)
|
db.tagsDao.upsert(tags)
|
||||||
db.mangaDao.upsert(MangaEntity.from(manga), tags)
|
db.mangaDao.upsert(manga.toEntity(), tags)
|
||||||
db.preferencesDao.upsert(
|
db.preferencesDao.upsert(
|
||||||
MangaPrefsEntity(
|
MangaPrefsEntity(
|
||||||
mangaId = manga.id,
|
mangaId = manga.id,
|
||||||
@@ -34,15 +34,19 @@ class MangaDataRepository(private val db: MangaDatabase) {
|
|||||||
|
|
||||||
suspend fun resolveIntent(intent: MangaIntent): Manga? = when {
|
suspend fun resolveIntent(intent: MangaIntent): Manga? = when {
|
||||||
intent.manga != null -> intent.manga
|
intent.manga != null -> intent.manga
|
||||||
intent.mangaId != MangaIntent.ID_NONE -> db.mangaDao.find(intent.mangaId)?.toManga()
|
intent.mangaId != 0L -> findMangaById(intent.mangaId)
|
||||||
else -> null // TODO resolve uri
|
else -> null // TODO resolve uri
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun storeManga(manga: Manga) {
|
suspend fun storeManga(manga: Manga) {
|
||||||
val tags = manga.tags.map(TagEntity.Companion::fromMangaTag)
|
val tags = manga.tags.toEntities()
|
||||||
db.withTransaction {
|
db.withTransaction {
|
||||||
db.tagsDao.upsert(tags)
|
db.tagsDao.upsert(tags)
|
||||||
db.mangaDao.upsert(MangaEntity.from(manga), tags)
|
db.mangaDao.upsert(manga.toEntity(), tags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun findTags(source: MangaSource): Set<MangaTag> {
|
||||||
|
return db.tagsDao.findTags(source.name).toMangaTags()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -3,31 +3,32 @@ package org.koitharu.kotatsu.base.domain
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import org.koitharu.kotatsu.core.model.Manga
|
import org.koitharu.kotatsu.core.model.parcelable.ParcelableManga
|
||||||
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
|
|
||||||
data class MangaIntent(
|
class MangaIntent private constructor(
|
||||||
val manga: Manga?,
|
val manga: Manga?,
|
||||||
val mangaId: Long,
|
val mangaId: Long,
|
||||||
val uri: Uri?
|
val uri: Uri?,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
constructor(intent: Intent?) : this(
|
||||||
|
manga = intent?.getParcelableExtra<ParcelableManga>(KEY_MANGA)?.manga,
|
||||||
|
mangaId = intent?.getLongExtra(KEY_ID, ID_NONE) ?: ID_NONE,
|
||||||
|
uri = intent?.data
|
||||||
|
)
|
||||||
|
|
||||||
|
constructor(args: Bundle?) : this(
|
||||||
|
manga = args?.getParcelable<ParcelableManga>(KEY_MANGA)?.manga,
|
||||||
|
mangaId = args?.getLong(KEY_ID, ID_NONE) ?: ID_NONE,
|
||||||
|
uri = null
|
||||||
|
)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun from(intent: Intent?) = MangaIntent(
|
|
||||||
manga = intent?.getParcelableExtra(KEY_MANGA),
|
|
||||||
mangaId = intent?.getLongExtra(KEY_ID, ID_NONE) ?: ID_NONE,
|
|
||||||
uri = intent?.data
|
|
||||||
)
|
|
||||||
|
|
||||||
fun from(args: Bundle?) = MangaIntent(
|
|
||||||
manga = args?.getParcelable(KEY_MANGA),
|
|
||||||
mangaId = args?.getLong(KEY_ID, ID_NONE) ?: ID_NONE,
|
|
||||||
uri = null
|
|
||||||
)
|
|
||||||
|
|
||||||
const val ID_NONE = 0L
|
const val ID_NONE = 0L
|
||||||
|
|
||||||
const val KEY_MANGA = "manga"
|
const val KEY_MANGA = "manga"
|
||||||
const val KEY_ID = "id"
|
const val KEY_ID = "id"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
package org.koitharu.kotatsu.base.domain
|
|
||||||
|
|
||||||
import okhttp3.*
|
|
||||||
import org.koin.core.component.KoinComponent
|
|
||||||
import org.koin.core.component.get
|
|
||||||
import org.koitharu.kotatsu.core.model.MangaSource
|
|
||||||
import org.koitharu.kotatsu.core.prefs.SourceSettings
|
|
||||||
import org.koitharu.kotatsu.utils.ext.await
|
|
||||||
|
|
||||||
open class MangaLoaderContext(
|
|
||||||
private val okHttp: OkHttpClient,
|
|
||||||
private val cookieJar: CookieJar
|
|
||||||
) : KoinComponent {
|
|
||||||
|
|
||||||
suspend fun httpGet(url: String): Response {
|
|
||||||
val request = Request.Builder()
|
|
||||||
.get()
|
|
||||||
.url(url)
|
|
||||||
return okHttp.newCall(request.build()).await()
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun httpPost(
|
|
||||||
url: String,
|
|
||||||
form: Map<String, String>
|
|
||||||
): Response {
|
|
||||||
val body = FormBody.Builder()
|
|
||||||
form.forEach { (k, v) ->
|
|
||||||
body.addEncoded(k, v)
|
|
||||||
}
|
|
||||||
val request = Request.Builder()
|
|
||||||
.post(body.build())
|
|
||||||
.url(url)
|
|
||||||
return okHttp.newCall(request.build()).await()
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun httpPost(
|
|
||||||
url: String,
|
|
||||||
payload: String
|
|
||||||
): Response {
|
|
||||||
val body = FormBody.Builder()
|
|
||||||
payload.split('&').forEach {
|
|
||||||
val pos = it.indexOf('=')
|
|
||||||
if (pos != -1) {
|
|
||||||
val k = it.substring(0, pos)
|
|
||||||
val v = it.substring(pos + 1)
|
|
||||||
body.addEncoded(k, v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val request = Request.Builder()
|
|
||||||
.post(body.build())
|
|
||||||
.url(url)
|
|
||||||
return okHttp.newCall(request.build()).await()
|
|
||||||
}
|
|
||||||
|
|
||||||
open fun getSettings(source: MangaSource) = SourceSettings(get(), source)
|
|
||||||
|
|
||||||
fun insertCookies(domain: String, vararg cookies: String) {
|
|
||||||
val url = HttpUrl.Builder()
|
|
||||||
.scheme(SCHEME_HTTP)
|
|
||||||
.host(domain)
|
|
||||||
.build()
|
|
||||||
cookieJar.saveFromResponse(url, cookies.mapNotNull {
|
|
||||||
Cookie.parse(url, it)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
private companion object {
|
|
||||||
|
|
||||||
private const val SCHEME_HTTP = "http"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package org.koitharu.kotatsu.base.domain
|
|
||||||
|
|
||||||
import org.koitharu.kotatsu.core.model.MangaSource
|
|
||||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
|
||||||
|
|
||||||
object MangaProviderFactory {
|
|
||||||
|
|
||||||
fun getSources(settings: AppSettings, includeHidden: Boolean): List<MangaSource> {
|
|
||||||
val list = MangaSource.values().toList() - MangaSource.LOCAL
|
|
||||||
val order = settings.sourcesOrder
|
|
||||||
val hidden = settings.hiddenSources
|
|
||||||
val sorted = list.sortedBy { x ->
|
|
||||||
val e = order.indexOf(x.ordinal)
|
|
||||||
if (e == -1) order.size + x.ordinal else e
|
|
||||||
}
|
|
||||||
return if (includeHidden) {
|
|
||||||
sorted
|
|
||||||
} else {
|
|
||||||
sorted.filterNot { x ->
|
|
||||||
x.name in hidden
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,65 +3,71 @@ package org.koitharu.kotatsu.base.domain
|
|||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.util.Size
|
import android.util.Size
|
||||||
import androidx.annotation.WorkerThread
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.runInterruptible
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import org.koin.core.component.KoinComponent
|
import org.koin.core.component.KoinComponent
|
||||||
import org.koin.core.component.get
|
import org.koin.core.component.get
|
||||||
import org.koitharu.kotatsu.BuildConfig
|
|
||||||
import org.koitharu.kotatsu.core.model.MangaPage
|
|
||||||
import org.koitharu.kotatsu.core.network.CommonHeaders
|
import org.koitharu.kotatsu.core.network.CommonHeaders
|
||||||
import org.koitharu.kotatsu.utils.CacheUtils
|
import org.koitharu.kotatsu.core.parser.MangaRepository
|
||||||
import org.koitharu.kotatsu.utils.ext.await
|
import org.koitharu.kotatsu.parsers.model.MangaPage
|
||||||
import org.koitharu.kotatsu.utils.ext.medianOrNull
|
import org.koitharu.kotatsu.parsers.util.await
|
||||||
|
import java.io.File
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.util.zip.ZipFile
|
import java.util.zip.ZipFile
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
object MangaUtils : KoinComponent {
|
object MangaUtils : KoinComponent {
|
||||||
|
|
||||||
|
private const val MIN_WEBTOON_RATIO = 2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatic determine type of manga by page size
|
* Automatic determine type of manga by page size
|
||||||
* @return ReaderMode.WEBTOON if page is wide
|
* @return ReaderMode.WEBTOON if page is wide
|
||||||
*/
|
*/
|
||||||
@WorkerThread
|
suspend fun determineMangaIsWebtoon(pages: List<MangaPage>): Boolean {
|
||||||
@Suppress("BlockingMethodInNonBlockingContext")
|
val pageIndex = (pages.size * 0.3).roundToInt()
|
||||||
suspend fun determineMangaIsWebtoon(pages: List<MangaPage>): Boolean? {
|
val page = requireNotNull(pages.getOrNull(pageIndex)) { "No pages" }
|
||||||
try {
|
val url = MangaRepository(page.source).getPageUrl(page)
|
||||||
val page = pages.medianOrNull() ?: return null
|
val uri = Uri.parse(url)
|
||||||
val url = page.source.repository.getPageUrl(page)
|
val size = if (uri.scheme == "cbz") {
|
||||||
val uri = Uri.parse(url)
|
runInterruptible(Dispatchers.IO) {
|
||||||
val size = if (uri.scheme == "cbz") {
|
|
||||||
val zip = ZipFile(uri.schemeSpecificPart)
|
val zip = ZipFile(uri.schemeSpecificPart)
|
||||||
val entry = zip.getEntry(uri.fragment)
|
val entry = zip.getEntry(uri.fragment)
|
||||||
zip.getInputStream(entry).use {
|
zip.getInputStream(entry).use {
|
||||||
getBitmapSize(it)
|
getBitmapSize(it)
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
val client = get<OkHttpClient>()
|
} else {
|
||||||
val request = Request.Builder()
|
val request = Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.get()
|
.get()
|
||||||
.header(CommonHeaders.REFERER, page.referer)
|
.header(CommonHeaders.REFERER, page.referer)
|
||||||
.cacheControl(CacheUtils.CONTROL_DISABLED)
|
.cacheControl(CommonHeaders.CACHE_CONTROL_DISABLED)
|
||||||
.build()
|
.build()
|
||||||
client.newCall(request).await().use {
|
get<OkHttpClient>().newCall(request).await().use {
|
||||||
|
runInterruptible(Dispatchers.IO) {
|
||||||
getBitmapSize(it.body?.byteStream())
|
getBitmapSize(it.body?.byteStream())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return size.width * 2 < size.height
|
|
||||||
} catch (e: Exception) {
|
|
||||||
if (BuildConfig.DEBUG) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
return size.width * MIN_WEBTOON_RATIO < size.height
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun getImageMimeType(file: File): String? = runInterruptible(Dispatchers.IO) {
|
||||||
|
val options = BitmapFactory.Options().apply {
|
||||||
|
inJustDecodeBounds = true
|
||||||
|
}
|
||||||
|
BitmapFactory.decodeFile(file.path, options)?.recycle()
|
||||||
|
options.outMimeType
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getBitmapSize(input: InputStream?): Size {
|
private fun getBitmapSize(input: InputStream?): Size {
|
||||||
val options = BitmapFactory.Options().apply {
|
val options = BitmapFactory.Options().apply {
|
||||||
inJustDecodeBounds = true
|
inJustDecodeBounds = true
|
||||||
}
|
}
|
||||||
BitmapFactory.decodeStream(input, null, options)
|
BitmapFactory.decodeStream(input, null, options)?.recycle()
|
||||||
val imageHeight: Int = options.outHeight
|
val imageHeight: Int = options.outHeight
|
||||||
val imageWidth: Int = options.outWidth
|
val imageWidth: Int = options.outWidth
|
||||||
check(imageHeight > 0 && imageWidth > 0)
|
check(imageHeight > 0 && imageWidth > 0)
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package org.koitharu.kotatsu.base.domain
|
||||||
|
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.NonCancellable
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
import org.koitharu.kotatsu.utils.ext.printStackTraceDebug
|
||||||
|
import org.koitharu.kotatsu.utils.ext.processLifecycleScope
|
||||||
|
import org.koitharu.kotatsu.utils.ext.runCatchingCancellable
|
||||||
|
|
||||||
|
fun interface ReversibleHandle {
|
||||||
|
|
||||||
|
suspend fun reverse()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun ReversibleHandle.reverseAsync() = processLifecycleScope.launch(Dispatchers.Default) {
|
||||||
|
runCatchingCancellable {
|
||||||
|
withContext(NonCancellable) {
|
||||||
|
reverse()
|
||||||
|
}
|
||||||
|
}.onFailure {
|
||||||
|
it.printStackTraceDebug()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun ReversibleHandle.plus(other: ReversibleHandle) = ReversibleHandle {
|
||||||
|
this.reverse()
|
||||||
|
other.reverse()
|
||||||
|
}
|
||||||
@@ -5,7 +5,6 @@ import android.os.Bundle
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.annotation.CallSuper
|
import androidx.annotation.CallSuper
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
@@ -18,8 +17,7 @@ abstract class AlertDialogFragment<B : ViewBinding> : DialogFragment() {
|
|||||||
get() = checkNotNull(viewBinding)
|
get() = checkNotNull(viewBinding)
|
||||||
|
|
||||||
final override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
final override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val inflater = activity?.layoutInflater ?: LayoutInflater.from(requireContext())
|
val binding = onInflateView(layoutInflater, null)
|
||||||
val binding = onInflateView(inflater, null)
|
|
||||||
viewBinding = binding
|
viewBinding = binding
|
||||||
return MaterialAlertDialogBuilder(requireContext(), theme)
|
return MaterialAlertDialogBuilder(requireContext(), theme)
|
||||||
.setView(binding.root)
|
.setView(binding.root)
|
||||||
@@ -39,7 +37,7 @@ abstract class AlertDialogFragment<B : ViewBinding> : DialogFragment() {
|
|||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun onBuildDialog(builder: AlertDialog.Builder) = Unit
|
open fun onBuildDialog(builder: MaterialAlertDialogBuilder) = Unit
|
||||||
|
|
||||||
protected fun bindingOrNull(): B? = viewBinding
|
protected fun bindingOrNull(): B? = viewBinding
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +1,59 @@
|
|||||||
package org.koitharu.kotatsu.base.ui
|
package org.koitharu.kotatsu.base.ui
|
||||||
|
|
||||||
|
import android.content.res.Configuration
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.annotation.CallSuper
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.view.ActionMode
|
import androidx.appcompat.view.ActionMode
|
||||||
import androidx.appcompat.widget.ActionBarContextView
|
import androidx.appcompat.widget.ActionBarContextView
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.core.graphics.Insets
|
import androidx.core.view.WindowCompat
|
||||||
import androidx.core.view.*
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
import androidx.core.view.updateLayoutParams
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
import org.koin.android.ext.android.get
|
import org.koin.android.ext.android.get
|
||||||
import org.koitharu.kotatsu.BuildConfig
|
import org.koitharu.kotatsu.BuildConfig
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
|
import org.koitharu.kotatsu.base.ui.util.ActionModeDelegate
|
||||||
|
import org.koitharu.kotatsu.base.ui.util.WindowInsetsDelegate
|
||||||
import org.koitharu.kotatsu.core.exceptions.resolve.ExceptionResolver
|
import org.koitharu.kotatsu.core.exceptions.resolve.ExceptionResolver
|
||||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||||
import org.koitharu.kotatsu.utils.ext.getThemeColor
|
|
||||||
|
|
||||||
abstract class BaseActivity<B : ViewBinding> : AppCompatActivity(), OnApplyWindowInsetsListener {
|
abstract class BaseActivity<B : ViewBinding> :
|
||||||
|
AppCompatActivity(),
|
||||||
|
WindowInsetsDelegate.WindowInsetsListener {
|
||||||
|
|
||||||
protected lateinit var binding: B
|
protected lateinit var binding: B
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
@Suppress("LeakingThis")
|
||||||
|
protected val exceptionResolver = ExceptionResolver(this)
|
||||||
|
|
||||||
protected val exceptionResolver by lazy(LazyThreadSafetyMode.NONE) {
|
@Suppress("LeakingThis")
|
||||||
ExceptionResolver(this, supportFragmentManager)
|
protected val insetsDelegate = WindowInsetsDelegate(this)
|
||||||
}
|
|
||||||
|
val actionModeDelegate = ActionModeDelegate()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
if (get<AppSettings>().isAmoledTheme) {
|
val settings = get<AppSettings>()
|
||||||
setTheme(R.style.AppTheme_Amoled)
|
val isAmoled = settings.isAmoledTheme
|
||||||
|
val isDynamic = settings.isDynamicTheme
|
||||||
|
// TODO support DialogWhenLarge theme
|
||||||
|
when {
|
||||||
|
isAmoled && isDynamic -> setTheme(R.style.Theme_Kotatsu_Monet_Amoled)
|
||||||
|
isAmoled -> setTheme(R.style.Theme_Kotatsu_Amoled)
|
||||||
|
isDynamic -> setTheme(R.style.Theme_Kotatsu_Monet)
|
||||||
}
|
}
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||||
|
insetsDelegate.handleImeInsets = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Use ViewBinding", level = DeprecationLevel.ERROR)
|
@Deprecated("Use ViewBinding", level = DeprecationLevel.ERROR)
|
||||||
@@ -55,13 +71,9 @@ abstract class BaseActivity<B : ViewBinding> : AppCompatActivity(), OnApplyWindo
|
|||||||
protected fun setContentView(binding: B) {
|
protected fun setContentView(binding: B) {
|
||||||
this.binding = binding
|
this.binding = binding
|
||||||
super.setContentView(binding.root)
|
super.setContentView(binding.root)
|
||||||
(binding.root.findViewById<View>(R.id.toolbar) as? Toolbar)?.let(this::setSupportActionBar)
|
val toolbar = (binding.root.findViewById<View>(R.id.toolbar) as? Toolbar)
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(binding.root, this)
|
toolbar?.let(this::setSupportActionBar)
|
||||||
}
|
insetsDelegate.onViewCreated(binding.root)
|
||||||
|
|
||||||
override fun onApplyWindowInsets(v: View, insets: WindowInsetsCompat): WindowInsetsCompat {
|
|
||||||
onWindowInsetsChanged(insets.getInsets(WindowInsetsCompat.Type.systemBars()))
|
|
||||||
return insets
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem) = if (item.itemId == android.R.id.home) {
|
override fun onOptionsItemSelected(item: MenuItem) = if (item.itemId == android.R.id.home) {
|
||||||
@@ -77,26 +89,32 @@ abstract class BaseActivity<B : ViewBinding> : AppCompatActivity(), OnApplyWindo
|
|||||||
return super.onKeyDown(keyCode, event)
|
return super.onKeyDown(keyCode, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract fun onWindowInsetsChanged(insets: Insets)
|
|
||||||
|
|
||||||
private fun setupToolbar() {
|
private fun setupToolbar() {
|
||||||
(findViewById<View>(R.id.toolbar) as? Toolbar)?.let(this::setSupportActionBar)
|
(findViewById<View>(R.id.toolbar) as? Toolbar)?.let(this::setSupportActionBar)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected fun isDarkAmoledTheme(): Boolean {
|
||||||
|
val uiMode = resources.configuration.uiMode
|
||||||
|
val isNight = uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
|
||||||
|
return isNight && get<AppSettings>().isAmoledTheme
|
||||||
|
}
|
||||||
|
|
||||||
|
@CallSuper
|
||||||
override fun onSupportActionModeStarted(mode: ActionMode) {
|
override fun onSupportActionModeStarted(mode: ActionMode) {
|
||||||
super.onSupportActionModeStarted(mode)
|
super.onSupportActionModeStarted(mode)
|
||||||
|
actionModeDelegate.onSupportActionModeStarted(mode)
|
||||||
val insets = ViewCompat.getRootWindowInsets(binding.root)
|
val insets = ViewCompat.getRootWindowInsets(binding.root)
|
||||||
?.getInsets(WindowInsetsCompat.Type.systemBars()) ?: return
|
?.getInsets(WindowInsetsCompat.Type.systemBars()) ?: return
|
||||||
val view = findViewById<ActionBarContextView?>(androidx.appcompat.R.id.action_mode_bar)
|
val view = findViewById<ActionBarContextView?>(androidx.appcompat.R.id.action_mode_bar)
|
||||||
view?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
view?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
topMargin = insets.top
|
topMargin = insets.top
|
||||||
}
|
}
|
||||||
window?.statusBarColor = ContextCompat.getColor(this, R.color.grey_dark)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@CallSuper
|
||||||
override fun onSupportActionModeFinished(mode: ActionMode) {
|
override fun onSupportActionModeFinished(mode: ActionMode) {
|
||||||
super.onSupportActionModeFinished(mode)
|
super.onSupportActionModeFinished(mode)
|
||||||
window?.statusBarColor = getThemeColor(android.R.attr.statusBarColor)
|
actionModeDelegate.onSupportActionModeFinished(mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
|
|||||||
@@ -2,22 +2,31 @@ package org.koitharu.kotatsu.base.ui
|
|||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.DisplayMetrics
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.app.AppCompatDialog
|
import android.view.ViewGroup.LayoutParams
|
||||||
|
import androidx.core.view.updateLayoutParams
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
|
import org.koitharu.kotatsu.base.ui.dialog.AppBottomSheetDialog
|
||||||
|
import org.koitharu.kotatsu.utils.ext.displayCompat
|
||||||
|
import com.google.android.material.R as materialR
|
||||||
|
|
||||||
abstract class BaseBottomSheet<B : ViewBinding> :
|
abstract class BaseBottomSheet<B : ViewBinding> : BottomSheetDialogFragment() {
|
||||||
BottomSheetDialogFragment() {
|
|
||||||
|
|
||||||
private var viewBinding: B? = null
|
private var viewBinding: B? = null
|
||||||
|
|
||||||
protected val binding: B
|
protected val binding: B
|
||||||
get() = checkNotNull(viewBinding)
|
get() = checkNotNull(viewBinding)
|
||||||
|
|
||||||
|
protected val behavior: BottomSheetBehavior<*>?
|
||||||
|
get() = (dialog as? BottomSheetDialog)?.behavior
|
||||||
|
|
||||||
final override fun onCreateView(
|
final override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
@@ -25,6 +34,20 @@ abstract class BaseBottomSheet<B : ViewBinding> :
|
|||||||
): View {
|
): View {
|
||||||
val binding = onInflateView(inflater, container)
|
val binding = onInflateView(inflater, container)
|
||||||
viewBinding = binding
|
viewBinding = binding
|
||||||
|
|
||||||
|
// Enforce max width for tablets
|
||||||
|
val width = resources.getDimensionPixelSize(R.dimen.bottom_sheet_width)
|
||||||
|
if (width > 0) {
|
||||||
|
behavior?.maxWidth = width
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set peek height to 50% display height
|
||||||
|
requireContext().displayCompat?.let {
|
||||||
|
val metrics = DisplayMetrics()
|
||||||
|
it.getRealMetrics(metrics)
|
||||||
|
behavior?.peekHeight = (metrics.heightPixels * 0.4).toInt()
|
||||||
|
}
|
||||||
|
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,10 +57,30 @@ abstract class BaseBottomSheet<B : ViewBinding> :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
return if (resources.getBoolean(R.bool.is_tablet)) {
|
return AppBottomSheetDialog(requireContext(), theme)
|
||||||
AppCompatDialog(context, theme)
|
}
|
||||||
} else super.onCreateDialog(savedInstanceState)
|
|
||||||
|
fun addBottomSheetCallback(callback: BottomSheetBehavior.BottomSheetCallback) {
|
||||||
|
val b = behavior ?: return
|
||||||
|
b.addBottomSheetCallback(callback)
|
||||||
|
val rootView = dialog?.findViewById<View>(materialR.id.design_bottom_sheet)
|
||||||
|
if (rootView != null) {
|
||||||
|
callback.onStateChanged(rootView, b.state)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract fun onInflateView(inflater: LayoutInflater, container: ViewGroup?): B
|
protected abstract fun onInflateView(inflater: LayoutInflater, container: ViewGroup?): B
|
||||||
|
|
||||||
|
protected fun setExpanded(isExpanded: Boolean, isLocked: Boolean) {
|
||||||
|
val b = behavior ?: return
|
||||||
|
if (isExpanded) {
|
||||||
|
b.state = BottomSheetBehavior.STATE_EXPANDED
|
||||||
|
}
|
||||||
|
b.isFitToContents = !isExpanded
|
||||||
|
val rootView = dialog?.findViewById<View>(materialR.id.design_bottom_sheet)
|
||||||
|
rootView?.updateLayoutParams {
|
||||||
|
height = if (isExpanded) LayoutParams.MATCH_PARENT else LayoutParams.WRAP_CONTENT
|
||||||
|
}
|
||||||
|
b.isDraggable = !isLocked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,28 +1,32 @@
|
|||||||
package org.koitharu.kotatsu.base.ui
|
package org.koitharu.kotatsu.base.ui
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.graphics.Insets
|
|
||||||
import androidx.core.view.OnApplyWindowInsetsListener
|
|
||||||
import androidx.core.view.ViewCompat
|
|
||||||
import androidx.core.view.WindowInsetsCompat
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
|
import org.koitharu.kotatsu.base.ui.util.ActionModeDelegate
|
||||||
|
import org.koitharu.kotatsu.base.ui.util.WindowInsetsDelegate
|
||||||
import org.koitharu.kotatsu.core.exceptions.resolve.ExceptionResolver
|
import org.koitharu.kotatsu.core.exceptions.resolve.ExceptionResolver
|
||||||
|
|
||||||
abstract class BaseFragment<B : ViewBinding> : Fragment(), OnApplyWindowInsetsListener {
|
abstract class BaseFragment<B : ViewBinding> :
|
||||||
|
Fragment(),
|
||||||
|
WindowInsetsDelegate.WindowInsetsListener {
|
||||||
|
|
||||||
private var viewBinding: B? = null
|
private var viewBinding: B? = null
|
||||||
|
|
||||||
protected val binding: B
|
protected val binding: B
|
||||||
get() = checkNotNull(viewBinding)
|
get() = checkNotNull(viewBinding)
|
||||||
|
|
||||||
protected val exceptionResolver by lazy(LazyThreadSafetyMode.NONE) {
|
@Suppress("LeakingThis")
|
||||||
ExceptionResolver(viewLifecycleOwner, childFragmentManager)
|
protected val exceptionResolver = ExceptionResolver(this)
|
||||||
}
|
|
||||||
|
@Suppress("LeakingThis")
|
||||||
|
protected val insetsDelegate = WindowInsetsDelegate(this)
|
||||||
|
|
||||||
|
protected val actionModeDelegate: ActionModeDelegate
|
||||||
|
get() = (requireActivity() as BaseActivity<*>).actionModeDelegate
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
@@ -36,31 +40,16 @@ abstract class BaseFragment<B : ViewBinding> : Fragment(), OnApplyWindowInsetsLi
|
|||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(view, this)
|
insetsDelegate.onViewCreated(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
viewBinding = null
|
viewBinding = null
|
||||||
|
insetsDelegate.onDestroyView()
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun getTitle(): CharSequence? = null
|
|
||||||
|
|
||||||
override fun onAttach(context: Context) {
|
|
||||||
super.onAttach(context)
|
|
||||||
getTitle()?.let {
|
|
||||||
activity?.title = it
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onApplyWindowInsets(v: View?, insets: WindowInsetsCompat): WindowInsetsCompat {
|
|
||||||
onWindowInsetsChanged(insets.getInsets(WindowInsetsCompat.Type.systemBars()))
|
|
||||||
return insets
|
|
||||||
}
|
|
||||||
|
|
||||||
protected fun bindingOrNull() = viewBinding
|
protected fun bindingOrNull() = viewBinding
|
||||||
|
|
||||||
protected abstract fun onInflateView(inflater: LayoutInflater, container: ViewGroup?): B
|
protected abstract fun onInflateView(inflater: LayoutInflater, container: ViewGroup?): B
|
||||||
|
}
|
||||||
protected abstract fun onWindowInsetsChanged(insets: Insets)
|
|
||||||
}
|
|
||||||
@@ -7,8 +7,21 @@ import android.view.View
|
|||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
private const val SYSTEM_UI_FLAGS_SHOWN = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||||
|
|
||||||
abstract class BaseFullscreenActivity<B : ViewBinding> : BaseActivity<B>(),
|
@Suppress("DEPRECATION")
|
||||||
|
private const val SYSTEM_UI_FLAGS_HIDDEN = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
||||||
|
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
|
||||||
|
View.SYSTEM_UI_FLAG_FULLSCREEN or
|
||||||
|
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
||||||
|
|
||||||
|
abstract class BaseFullscreenActivity<B : ViewBinding> :
|
||||||
|
BaseActivity<B>(),
|
||||||
View.OnSystemUiVisibilityChangeListener {
|
View.OnSystemUiVisibilityChangeListener {
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@@ -25,33 +38,22 @@ abstract class BaseFullscreenActivity<B : ViewBinding> : BaseActivity<B>(),
|
|||||||
showSystemUI()
|
showSystemUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION", "DeprecatedCallableAddReplaceWith")
|
||||||
|
@Deprecated("Deprecated in Java")
|
||||||
final override fun onSystemUiVisibilityChange(visibility: Int) {
|
final override fun onSystemUiVisibilityChange(visibility: Int) {
|
||||||
onSystemUiVisibilityChanged(visibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0)
|
onSystemUiVisibilityChanged(visibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO WindowInsetsControllerCompat works incorrect
|
// TODO WindowInsetsControllerCompat works incorrect
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
protected fun hideSystemUI() {
|
protected fun hideSystemUI() {
|
||||||
window.decorView.systemUiVisibility = SYSTEM_UI_FLAGS_HIDDEN
|
window.decorView.systemUiVisibility = SYSTEM_UI_FLAGS_HIDDEN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
protected fun showSystemUI() {
|
protected fun showSystemUI() {
|
||||||
window.decorView.systemUiVisibility = SYSTEM_UI_FLAGS_SHOWN
|
window.decorView.systemUiVisibility = SYSTEM_UI_FLAGS_SHOWN
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun onSystemUiVisibilityChanged(isVisible: Boolean) = Unit
|
protected open fun onSystemUiVisibilityChanged(isVisible: Boolean) = Unit
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
private companion object {
|
|
||||||
|
|
||||||
const val SYSTEM_UI_FLAGS_SHOWN = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
|
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
|
||||||
|
|
||||||
const val SYSTEM_UI_FLAGS_HIDDEN = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
|
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
|
||||||
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
|
|
||||||
View.SYSTEM_UI_FLAG_FULLSCREEN or
|
|
||||||
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,38 +2,59 @@ package org.koitharu.kotatsu.base.ui
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import androidx.annotation.CallSuper
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.core.view.OnApplyWindowInsetsListener
|
import androidx.core.graphics.Insets
|
||||||
import androidx.core.view.ViewCompat
|
|
||||||
import androidx.core.view.WindowInsetsCompat
|
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import org.koin.android.ext.android.inject
|
import org.koin.android.ext.android.inject
|
||||||
|
import org.koitharu.kotatsu.base.ui.util.RecyclerViewOwner
|
||||||
|
import org.koitharu.kotatsu.base.ui.util.WindowInsetsDelegate
|
||||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||||
|
import org.koitharu.kotatsu.settings.SettingsHeadersFragment
|
||||||
|
|
||||||
abstract class BasePreferenceFragment(@StringRes private val titleId: Int) :
|
abstract class BasePreferenceFragment(@StringRes private val titleId: Int) :
|
||||||
PreferenceFragmentCompat(), OnApplyWindowInsetsListener {
|
PreferenceFragmentCompat(),
|
||||||
|
WindowInsetsDelegate.WindowInsetsListener,
|
||||||
|
RecyclerViewOwner {
|
||||||
|
|
||||||
protected val settings by inject<AppSettings>()
|
protected val settings by inject<AppSettings>(mode = LazyThreadSafetyMode.NONE)
|
||||||
|
|
||||||
|
@Suppress("LeakingThis")
|
||||||
|
protected val insetsDelegate = WindowInsetsDelegate(this)
|
||||||
|
|
||||||
|
override val recyclerView: RecyclerView
|
||||||
|
get() = listView
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
listView.clipToPadding = false
|
listView.clipToPadding = false
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(view, this)
|
insetsDelegate.onViewCreated(view)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
insetsDelegate.onDestroyView()
|
||||||
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
activity?.setTitle(titleId)
|
if (titleId != 0) {
|
||||||
|
setTitle(getString(titleId))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onApplyWindowInsets(v: View?, insets: WindowInsetsCompat): WindowInsetsCompat {
|
@CallSuper
|
||||||
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
override fun onWindowInsetsChanged(insets: Insets) {
|
||||||
listView.updatePadding(
|
listView.updatePadding(
|
||||||
left = systemBars.left,
|
bottom = insets.bottom
|
||||||
right = systemBars.right,
|
|
||||||
bottom = systemBars.bottom
|
|
||||||
)
|
)
|
||||||
return insets
|
}
|
||||||
|
|
||||||
|
@Suppress("UsePropertyAccessSyntax")
|
||||||
|
protected fun setTitle(title: CharSequence) {
|
||||||
|
(parentFragment as? SettingsHeadersFragment)?.setTitle(title)
|
||||||
|
?: activity?.setTitle(title)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,25 @@
|
|||||||
package org.koitharu.kotatsu.base.ui
|
package org.koitharu.kotatsu.base.ui
|
||||||
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import kotlinx.coroutines.*
|
|
||||||
import org.koitharu.kotatsu.BuildConfig
|
|
||||||
import org.koitharu.kotatsu.utils.SingleLiveEvent
|
|
||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
import kotlin.coroutines.EmptyCoroutineContext
|
import kotlin.coroutines.EmptyCoroutineContext
|
||||||
|
import kotlinx.coroutines.*
|
||||||
|
import org.koitharu.kotatsu.base.ui.util.CountedBooleanLiveData
|
||||||
|
import org.koitharu.kotatsu.utils.SingleLiveEvent
|
||||||
|
import org.koitharu.kotatsu.utils.ext.printStackTraceDebug
|
||||||
|
|
||||||
abstract class BaseViewModel : ViewModel() {
|
abstract class BaseViewModel : ViewModel() {
|
||||||
|
|
||||||
val onError = SingleLiveEvent<Throwable>()
|
protected val loadingCounter = CountedBooleanLiveData()
|
||||||
val isLoading = MutableLiveData(false)
|
protected val errorEvent = SingleLiveEvent<Throwable>()
|
||||||
|
|
||||||
|
val onError: LiveData<Throwable>
|
||||||
|
get() = errorEvent
|
||||||
|
|
||||||
|
val isLoading: LiveData<Boolean>
|
||||||
|
get() = loadingCounter
|
||||||
|
|
||||||
protected fun launchJob(
|
protected fun launchJob(
|
||||||
context: CoroutineContext = EmptyCoroutineContext,
|
context: CoroutineContext = EmptyCoroutineContext,
|
||||||
@@ -25,20 +32,18 @@ abstract class BaseViewModel : ViewModel() {
|
|||||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||||
block: suspend CoroutineScope.() -> Unit
|
block: suspend CoroutineScope.() -> Unit
|
||||||
): Job = viewModelScope.launch(context + createErrorHandler(), start) {
|
): Job = viewModelScope.launch(context + createErrorHandler(), start) {
|
||||||
isLoading.postValue(true)
|
loadingCounter.increment()
|
||||||
try {
|
try {
|
||||||
block()
|
block()
|
||||||
} finally {
|
} finally {
|
||||||
isLoading.postValue(false)
|
loadingCounter.decrement()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createErrorHandler() = CoroutineExceptionHandler { _, throwable ->
|
private fun createErrorHandler() = CoroutineExceptionHandler { _, throwable ->
|
||||||
if (BuildConfig.DEBUG) {
|
throwable.printStackTraceDebug()
|
||||||
throwable.printStackTrace()
|
|
||||||
}
|
|
||||||
if (throwable !is CancellationException) {
|
if (throwable !is CancellationException) {
|
||||||
onError.postCall(throwable)
|
errorEvent.postCall(throwable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui
|
||||||
|
|
||||||
|
import android.app.Service
|
||||||
|
import android.content.Intent
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import kotlinx.coroutines.CoroutineDispatcher
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.sync.Mutex
|
||||||
|
import kotlinx.coroutines.sync.withLock
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
|
abstract class CoroutineIntentService : BaseService() {
|
||||||
|
|
||||||
|
private val mutex = Mutex()
|
||||||
|
protected open val dispatcher: CoroutineDispatcher = Dispatchers.Default
|
||||||
|
|
||||||
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
|
super.onStartCommand(intent, flags, startId)
|
||||||
|
launchCoroutine(intent, startId)
|
||||||
|
return Service.START_REDELIVER_INTENT
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun launchCoroutine(intent: Intent?, startId: Int) = lifecycleScope.launch {
|
||||||
|
mutex.withLock {
|
||||||
|
try {
|
||||||
|
withContext(dispatcher) {
|
||||||
|
processIntent(intent)
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
stopSelf(startId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract suspend fun processIntent(intent: Intent?)
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.dialog
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.view.View
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
|
|
||||||
|
class AppBottomSheetDialog(context: Context, theme: Int) : BottomSheetDialog(context, theme) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://github.com/material-components/material-components-android/issues/2582
|
||||||
|
*/
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
override fun onAttachedToWindow() {
|
||||||
|
val window = window
|
||||||
|
val initialSystemUiVisibility = window?.decorView?.systemUiVisibility ?: 0
|
||||||
|
super.onAttachedToWindow()
|
||||||
|
if (window != null) {
|
||||||
|
// If the navigation bar is translucent at all, the BottomSheet should be edge to edge
|
||||||
|
val drawEdgeToEdge = edgeToEdgeEnabled && Color.alpha(window.navigationBarColor) < 0xFF
|
||||||
|
if (drawEdgeToEdge) {
|
||||||
|
// Copied from super.onAttachedToWindow:
|
||||||
|
val edgeToEdgeFlags = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||||
|
// Fix super-class's window flag bug by respecting the initial system UI visibility:
|
||||||
|
window.decorView.systemUiVisibility = edgeToEdgeFlags or initialSystemUiVisibility
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,18 +2,17 @@ package org.koitharu.kotatsu.base.ui.dialog
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.BaseAdapter
|
import android.widget.BaseAdapter
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.databinding.ItemStorageBinding
|
import org.koitharu.kotatsu.databinding.ItemStorageBinding
|
||||||
import org.koitharu.kotatsu.local.domain.LocalMangaRepository
|
import org.koitharu.kotatsu.local.data.LocalStorageManager
|
||||||
import org.koitharu.kotatsu.utils.ext.getStorageName
|
|
||||||
import org.koitharu.kotatsu.utils.ext.inflate
|
|
||||||
import org.koitharu.kotatsu.utils.ext.longHashCode
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class StorageSelectDialog private constructor(private val delegate: AlertDialog) :
|
class StorageSelectDialog private constructor(private val delegate: AlertDialog) :
|
||||||
@@ -21,19 +20,22 @@ class StorageSelectDialog private constructor(private val delegate: AlertDialog)
|
|||||||
|
|
||||||
fun show() = delegate.show()
|
fun show() = delegate.show()
|
||||||
|
|
||||||
class Builder(context: Context, defaultValue: File?, listener: OnStorageSelectListener) {
|
class Builder(context: Context, storageManager: LocalStorageManager, listener: OnStorageSelectListener) {
|
||||||
|
|
||||||
private val adapter = VolumesAdapter(context)
|
private val adapter = VolumesAdapter(storageManager)
|
||||||
private val delegate = MaterialAlertDialogBuilder(context)
|
private val delegate = MaterialAlertDialogBuilder(context)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (adapter.isEmpty) {
|
if (adapter.isEmpty) {
|
||||||
delegate.setMessage(R.string.cannot_find_available_storage)
|
delegate.setMessage(R.string.cannot_find_available_storage)
|
||||||
} else {
|
} else {
|
||||||
val checked = adapter.volumes.indexOfFirst {
|
val defaultValue = runBlocking {
|
||||||
|
storageManager.getDefaultWriteableDir()
|
||||||
|
}
|
||||||
|
adapter.selectedItemPosition = adapter.volumes.indexOfFirst {
|
||||||
it.first.canonicalPath == defaultValue?.canonicalPath
|
it.first.canonicalPath == defaultValue?.canonicalPath
|
||||||
}
|
}
|
||||||
delegate.setSingleChoiceItems(adapter, checked) { d, i ->
|
delegate.setAdapter(adapter) { d, i ->
|
||||||
listener.onStorageSelected(adapter.getItem(i).first)
|
listener.onStorageSelected(adapter.getItem(i).first)
|
||||||
d.dismiss()
|
d.dismiss()
|
||||||
}
|
}
|
||||||
@@ -58,14 +60,18 @@ class StorageSelectDialog private constructor(private val delegate: AlertDialog)
|
|||||||
fun create() = StorageSelectDialog(delegate.create())
|
fun create() = StorageSelectDialog(delegate.create())
|
||||||
}
|
}
|
||||||
|
|
||||||
private class VolumesAdapter(context: Context) : BaseAdapter() {
|
private class VolumesAdapter(storageManager: LocalStorageManager) : BaseAdapter() {
|
||||||
|
|
||||||
val volumes = getAvailableVolumes(context)
|
var selectedItemPosition: Int = -1
|
||||||
|
val volumes = getAvailableVolumes(storageManager)
|
||||||
|
|
||||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
||||||
val view = convertView ?: parent.inflate(R.layout.item_storage)
|
val view = convertView ?: LayoutInflater.from(parent.context).inflate(R.layout.item_storage, parent, false)
|
||||||
|
val binding = (view.tag as? ItemStorageBinding) ?: ItemStorageBinding.bind(view).also {
|
||||||
|
view.tag = it
|
||||||
|
}
|
||||||
val item = volumes[position]
|
val item = volumes[position]
|
||||||
val binding = ItemStorageBinding.bind(view)
|
binding.imageViewIndicator.isChecked = selectedItemPosition == position
|
||||||
binding.textViewTitle.text = item.second
|
binding.textViewTitle.text = item.second
|
||||||
binding.textViewSubtitle.text = item.first.path
|
binding.textViewSubtitle.text = item.first.path
|
||||||
return view
|
return view
|
||||||
@@ -73,23 +79,23 @@ class StorageSelectDialog private constructor(private val delegate: AlertDialog)
|
|||||||
|
|
||||||
override fun getItem(position: Int): Pair<File, String> = volumes[position]
|
override fun getItem(position: Int): Pair<File, String> = volumes[position]
|
||||||
|
|
||||||
override fun getItemId(position: Int) = volumes[position].first.absolutePath.longHashCode()
|
override fun getItemId(position: Int) = position.toLong()
|
||||||
|
|
||||||
override fun getCount() = volumes.size
|
override fun getCount() = volumes.size
|
||||||
|
|
||||||
|
override fun hasStableIds() = true
|
||||||
|
|
||||||
|
private fun getAvailableVolumes(storageManager: LocalStorageManager): List<Pair<File, String>> {
|
||||||
|
return runBlocking {
|
||||||
|
storageManager.getWriteableDirs().map {
|
||||||
|
it to storageManager.getStorageDisplayName(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun interface OnStorageSelectListener {
|
fun interface OnStorageSelectListener {
|
||||||
|
|
||||||
fun onStorageSelected(file: File)
|
fun onStorageSelected(file: File)
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
|
||||||
|
|
||||||
fun getAvailableVolumes(context: Context): List<Pair<File, String>> {
|
|
||||||
return LocalMangaRepository.getAvailableStorageDirs(context).map {
|
|
||||||
it to it.getStorageName(context)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
package org.koitharu.kotatsu.base.ui.dialog
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.DialogInterface
|
|
||||||
import android.text.InputFilter
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import androidx.annotation.StringRes
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|
||||||
import org.koitharu.kotatsu.databinding.DialogInputBinding
|
|
||||||
|
|
||||||
class TextInputDialog private constructor(
|
|
||||||
private val delegate: AlertDialog
|
|
||||||
) : DialogInterface by delegate {
|
|
||||||
|
|
||||||
fun show() = delegate.show()
|
|
||||||
|
|
||||||
class Builder(context: Context) {
|
|
||||||
|
|
||||||
private val binding = DialogInputBinding.inflate(LayoutInflater.from(context))
|
|
||||||
|
|
||||||
private val delegate = MaterialAlertDialogBuilder(context)
|
|
||||||
.setView(binding.root)
|
|
||||||
|
|
||||||
fun setTitle(@StringRes titleResId: Int): Builder {
|
|
||||||
delegate.setTitle(titleResId)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setTitle(title: CharSequence): Builder {
|
|
||||||
delegate.setTitle(title)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setHint(@StringRes hintResId: Int): Builder {
|
|
||||||
binding.inputLayout.hint = binding.root.context.getString(hintResId)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setMaxLength(maxLength: Int, strict: Boolean): Builder {
|
|
||||||
with(binding.inputLayout) {
|
|
||||||
counterMaxLength = maxLength
|
|
||||||
isCounterEnabled = maxLength > 0
|
|
||||||
}
|
|
||||||
if (strict && maxLength > 0) {
|
|
||||||
binding.inputEdit.filters += InputFilter.LengthFilter(maxLength)
|
|
||||||
}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setInputType(inputType: Int): Builder {
|
|
||||||
binding.inputEdit.inputType = inputType
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setText(text: String): Builder {
|
|
||||||
binding.inputEdit.setText(text)
|
|
||||||
binding.inputEdit.setSelection(text.length)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setPositiveButton(
|
|
||||||
@StringRes textId: Int,
|
|
||||||
listener: (DialogInterface, String) -> Unit
|
|
||||||
): Builder {
|
|
||||||
delegate.setPositiveButton(textId) { dialog, _ ->
|
|
||||||
listener(dialog, binding.inputEdit.text.toString().orEmpty())
|
|
||||||
}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setNegativeButton(
|
|
||||||
@StringRes textId: Int,
|
|
||||||
listener: DialogInterface.OnClickListener? = null
|
|
||||||
): Builder {
|
|
||||||
delegate.setNegativeButton(textId, listener)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setOnCancelListener(listener: DialogInterface.OnCancelListener): Builder {
|
|
||||||
delegate.setOnCancelListener(listener)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun create() =
|
|
||||||
TextInputDialog(delegate.create())
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.list
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import android.view.View.OnClickListener
|
||||||
|
import android.view.View.OnLongClickListener
|
||||||
|
import com.hannesdorfmann.adapterdelegates4.dsl.AdapterDelegateViewBindingViewHolder
|
||||||
|
|
||||||
|
class AdapterDelegateClickListenerAdapter<I>(
|
||||||
|
private val adapterDelegate: AdapterDelegateViewBindingViewHolder<I, *>,
|
||||||
|
private val clickListener: OnListItemClickListener<I>,
|
||||||
|
) : OnClickListener, OnLongClickListener {
|
||||||
|
|
||||||
|
override fun onClick(v: View) {
|
||||||
|
clickListener.onItemClick(adapterDelegate.item, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onLongClick(v: View): Boolean {
|
||||||
|
return clickListener.onItemLongClick(adapterDelegate.item, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package org.koitharu.kotatsu.base.ui.list
|
|
||||||
|
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
@Deprecated("")
|
|
||||||
class AdapterUpdater<T>(oldList: List<T>, newList: List<T>, getId: (T) -> Long) {
|
|
||||||
|
|
||||||
private val diff = DiffUtil.calculateDiff(object : DiffUtil.Callback() {
|
|
||||||
|
|
||||||
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) =
|
|
||||||
getId(oldList[oldItemPosition]) == getId(newList[newItemPosition])
|
|
||||||
|
|
||||||
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) =
|
|
||||||
Objects.equals(oldList[oldItemPosition], newList[newItemPosition])
|
|
||||||
|
|
||||||
override fun getOldListSize() = oldList.size
|
|
||||||
|
|
||||||
override fun getNewListSize() = newList.size
|
|
||||||
})
|
|
||||||
|
|
||||||
operator fun invoke(adapter: RecyclerView.Adapter<*>) {
|
|
||||||
diff.dispatchUpdatesTo(adapter)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package org.koitharu.kotatsu.base.ui.list
|
|
||||||
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import androidx.viewbinding.ViewBinding
|
|
||||||
import org.koin.core.component.KoinComponent
|
|
||||||
|
|
||||||
@Deprecated("")
|
|
||||||
abstract class BaseViewHolder<T, E, B : ViewBinding> protected constructor(val binding: B) :
|
|
||||||
RecyclerView.ViewHolder(binding.root), KoinComponent {
|
|
||||||
|
|
||||||
var boundData: T? = null
|
|
||||||
private set
|
|
||||||
|
|
||||||
val context get() = itemView.context!!
|
|
||||||
|
|
||||||
fun bind(data: T, extra: E) {
|
|
||||||
boundData = data
|
|
||||||
onBind(data, extra)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun requireData(): T {
|
|
||||||
return boundData ?: throw IllegalStateException("Calling requireData() before bind()")
|
|
||||||
}
|
|
||||||
|
|
||||||
open fun onRecycled() = Unit
|
|
||||||
|
|
||||||
abstract fun onBind(data: T, extra: E)
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.list
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.View
|
||||||
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
|
||||||
|
class FitHeightGridLayoutManager : GridLayoutManager {
|
||||||
|
|
||||||
|
constructor(context: Context?, spanCount: Int) : super(context, spanCount)
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
context: Context?,
|
||||||
|
attrs: AttributeSet?,
|
||||||
|
defStyleAttr: Int,
|
||||||
|
defStyleRes: Int,
|
||||||
|
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
context: Context?,
|
||||||
|
spanCount: Int,
|
||||||
|
orientation: Int,
|
||||||
|
reverseLayout: Boolean,
|
||||||
|
) : super(context, spanCount, orientation, reverseLayout)
|
||||||
|
|
||||||
|
|
||||||
|
override fun layoutDecoratedWithMargins(child: View, left: Int, top: Int, right: Int, bottom: Int) {
|
||||||
|
if (orientation == RecyclerView.VERTICAL && child.layoutParams.height == LayoutParams.MATCH_PARENT) {
|
||||||
|
val parentBottom = height - paddingBottom
|
||||||
|
val offset = parentBottom - bottom
|
||||||
|
super.layoutDecoratedWithMargins(child, left, top + offset, right, bottom + offset)
|
||||||
|
} else {
|
||||||
|
super.layoutDecoratedWithMargins(child, left, top, right, bottom)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.list
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.View
|
||||||
|
import androidx.annotation.AttrRes
|
||||||
|
import androidx.annotation.StyleRes
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import androidx.recyclerview.widget.RecyclerView.LayoutParams
|
||||||
|
|
||||||
|
class FitHeightLinearLayoutManager : LinearLayoutManager {
|
||||||
|
|
||||||
|
constructor(context: Context) : super(context)
|
||||||
|
constructor(
|
||||||
|
context: Context,
|
||||||
|
@RecyclerView.Orientation orientation: Int,
|
||||||
|
reverseLayout: Boolean,
|
||||||
|
) : super(context, orientation, reverseLayout)
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
context: Context,
|
||||||
|
attrs: AttributeSet?,
|
||||||
|
@AttrRes defStyleAttr: Int,
|
||||||
|
@StyleRes defStyleRes: Int,
|
||||||
|
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||||
|
|
||||||
|
override fun layoutDecoratedWithMargins(child: View, left: Int, top: Int, right: Int, bottom: Int) {
|
||||||
|
if (orientation == RecyclerView.VERTICAL && child.layoutParams.height == LayoutParams.MATCH_PARENT) {
|
||||||
|
val parentBottom = height - paddingBottom
|
||||||
|
val offset = parentBottom - bottom
|
||||||
|
super.layoutDecoratedWithMargins(child, left, top + offset, right, bottom + offset)
|
||||||
|
} else {
|
||||||
|
super.layoutDecoratedWithMargins(child, left, top, right, bottom)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.list
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuItem
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.appcompat.view.ActionMode
|
||||||
|
import androidx.lifecycle.Lifecycle
|
||||||
|
import androidx.lifecycle.LifecycleEventObserver
|
||||||
|
import androidx.lifecycle.LifecycleOwner
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import androidx.savedstate.SavedStateRegistry
|
||||||
|
import androidx.savedstate.SavedStateRegistryOwner
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import org.koitharu.kotatsu.base.ui.list.decor.AbstractSelectionItemDecoration
|
||||||
|
import kotlin.coroutines.EmptyCoroutineContext
|
||||||
|
|
||||||
|
private const val KEY_SELECTION = "selection"
|
||||||
|
private const val PROVIDER_NAME = "selection_decoration"
|
||||||
|
|
||||||
|
class ListSelectionController(
|
||||||
|
private val activity: Activity,
|
||||||
|
private val decoration: AbstractSelectionItemDecoration,
|
||||||
|
private val registryOwner: SavedStateRegistryOwner,
|
||||||
|
private val callback: Callback,
|
||||||
|
) : ActionMode.Callback, SavedStateRegistry.SavedStateProvider {
|
||||||
|
|
||||||
|
private var actionMode: ActionMode? = null
|
||||||
|
private val stateEventObserver = StateEventObserver()
|
||||||
|
|
||||||
|
val count: Int
|
||||||
|
get() = decoration.checkedItemsCount
|
||||||
|
|
||||||
|
fun snapshot(): Set<Long> {
|
||||||
|
return peekCheckedIds().toSet()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun peekCheckedIds(): Set<Long> {
|
||||||
|
return decoration.checkedItemsIds
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clear() {
|
||||||
|
decoration.clearSelection()
|
||||||
|
notifySelectionChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addAll(ids: Collection<Long>) {
|
||||||
|
if (ids.isEmpty()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
decoration.checkAll(ids)
|
||||||
|
notifySelectionChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun attachToRecyclerView(recyclerView: RecyclerView) {
|
||||||
|
recyclerView.addItemDecoration(decoration)
|
||||||
|
registryOwner.lifecycle.addObserver(stateEventObserver)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun saveState(): Bundle {
|
||||||
|
val bundle = Bundle(1)
|
||||||
|
bundle.putLongArray(KEY_SELECTION, peekCheckedIds().toLongArray())
|
||||||
|
return bundle
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onItemClick(id: Long): Boolean {
|
||||||
|
if (decoration.checkedItemsCount != 0) {
|
||||||
|
decoration.toggleItemChecked(id)
|
||||||
|
if (decoration.checkedItemsCount == 0) {
|
||||||
|
actionMode?.finish()
|
||||||
|
} else {
|
||||||
|
actionMode?.invalidate()
|
||||||
|
}
|
||||||
|
notifySelectionChanged()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onItemLongClick(id: Long): Boolean {
|
||||||
|
startActionMode()
|
||||||
|
return actionMode?.also {
|
||||||
|
decoration.setItemIsChecked(id, true)
|
||||||
|
notifySelectionChanged()
|
||||||
|
} != null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
|
||||||
|
return callback.onCreateActionMode(mode, menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPrepareActionMode(mode: ActionMode, menu: Menu): Boolean {
|
||||||
|
return callback.onPrepareActionMode(mode, menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
||||||
|
return callback.onActionItemClicked(mode, item)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyActionMode(mode: ActionMode) {
|
||||||
|
callback.onDestroyActionMode(mode)
|
||||||
|
clear()
|
||||||
|
actionMode = null
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startActionMode() {
|
||||||
|
if (actionMode == null) {
|
||||||
|
actionMode = (activity as? AppCompatActivity)?.startSupportActionMode(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun notifySelectionChanged() {
|
||||||
|
val count = decoration.checkedItemsCount
|
||||||
|
callback.onSelectionChanged(count)
|
||||||
|
if (count == 0) {
|
||||||
|
actionMode?.finish()
|
||||||
|
} else {
|
||||||
|
actionMode?.invalidate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun restoreState(ids: Collection<Long>) {
|
||||||
|
if (ids.isEmpty() || decoration.checkedItemsCount != 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
decoration.checkAll(ids)
|
||||||
|
startActionMode()
|
||||||
|
notifySelectionChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Callback : ActionMode.Callback {
|
||||||
|
|
||||||
|
fun onSelectionChanged(count: Int)
|
||||||
|
|
||||||
|
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean
|
||||||
|
|
||||||
|
override fun onPrepareActionMode(mode: ActionMode, menu: Menu): Boolean
|
||||||
|
|
||||||
|
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean
|
||||||
|
|
||||||
|
override fun onDestroyActionMode(mode: ActionMode) = Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
private inner class StateEventObserver : LifecycleEventObserver {
|
||||||
|
|
||||||
|
override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
|
||||||
|
if (event == Lifecycle.Event.ON_CREATE) {
|
||||||
|
val registry = registryOwner.savedStateRegistry
|
||||||
|
registry.registerSavedStateProvider(PROVIDER_NAME, this@ListSelectionController)
|
||||||
|
val state = registry.consumeRestoredStateForKey(PROVIDER_NAME)
|
||||||
|
if (state != null) {
|
||||||
|
Dispatchers.Main.dispatch(EmptyCoroutineContext) { // == Handler.post
|
||||||
|
if (source.lifecycle.currentState.isAtLeast(Lifecycle.State.CREATED)) {
|
||||||
|
restoreState(state.getLongArray(KEY_SELECTION)?.toList().orEmpty())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.list.decor
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Context
|
||||||
|
import android.graphics.Canvas
|
||||||
|
import android.graphics.Paint
|
||||||
|
import android.graphics.Rect
|
||||||
|
import android.view.View
|
||||||
|
import androidx.core.content.res.getColorOrThrow
|
||||||
|
import androidx.core.view.children
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.google.android.material.R as materialR
|
||||||
|
|
||||||
|
@SuppressLint("PrivateResource")
|
||||||
|
abstract class AbstractDividerItemDecoration(context: Context) : RecyclerView.ItemDecoration() {
|
||||||
|
|
||||||
|
private val bounds = Rect()
|
||||||
|
private val thickness: Int
|
||||||
|
private val paint = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||||
|
|
||||||
|
init {
|
||||||
|
paint.style = Paint.Style.FILL
|
||||||
|
val ta = context.obtainStyledAttributes(
|
||||||
|
null,
|
||||||
|
materialR.styleable.MaterialDivider,
|
||||||
|
materialR.attr.materialDividerStyle,
|
||||||
|
materialR.style.Widget_Material3_MaterialDivider,
|
||||||
|
)
|
||||||
|
paint.color = ta.getColorOrThrow(materialR.styleable.MaterialDivider_dividerColor)
|
||||||
|
thickness = ta.getDimensionPixelSize(
|
||||||
|
materialR.styleable.MaterialDivider_dividerThickness,
|
||||||
|
context.resources.getDimensionPixelSize(materialR.dimen.material_divider_thickness),
|
||||||
|
)
|
||||||
|
ta.recycle()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun getItemOffsets(
|
||||||
|
outRect: Rect,
|
||||||
|
view: View,
|
||||||
|
parent: RecyclerView,
|
||||||
|
state: RecyclerView.State,
|
||||||
|
) {
|
||||||
|
outRect.set(0, thickness, 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO implement for horizontal lists on demand
|
||||||
|
override fun onDraw(canvas: Canvas, parent: RecyclerView, s: RecyclerView.State) {
|
||||||
|
if (parent.layoutManager == null || thickness == 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
canvas.save()
|
||||||
|
val left: Float
|
||||||
|
val right: Float
|
||||||
|
if (parent.clipToPadding) {
|
||||||
|
left = parent.paddingLeft.toFloat()
|
||||||
|
right = (parent.width - parent.paddingRight).toFloat()
|
||||||
|
canvas.clipRect(
|
||||||
|
left,
|
||||||
|
parent.paddingTop.toFloat(),
|
||||||
|
right,
|
||||||
|
(parent.height - parent.paddingBottom).toFloat()
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
left = 0f
|
||||||
|
right = parent.width.toFloat()
|
||||||
|
}
|
||||||
|
|
||||||
|
var previous: RecyclerView.ViewHolder? = null
|
||||||
|
for (child in parent.children) {
|
||||||
|
val holder = parent.getChildViewHolder(child)
|
||||||
|
if (previous != null && shouldDrawDivider(previous, holder)) {
|
||||||
|
parent.getDecoratedBoundsWithMargins(child, bounds)
|
||||||
|
val top: Float = bounds.top + child.translationY
|
||||||
|
val bottom: Float = top + thickness
|
||||||
|
canvas.drawRect(left, top, right, bottom, paint)
|
||||||
|
}
|
||||||
|
previous = holder
|
||||||
|
}
|
||||||
|
canvas.restore()
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract fun shouldDrawDivider(
|
||||||
|
above: RecyclerView.ViewHolder,
|
||||||
|
below: RecyclerView.ViewHolder,
|
||||||
|
): Boolean
|
||||||
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.list.decor
|
||||||
|
|
||||||
|
import android.graphics.Canvas
|
||||||
|
import android.graphics.Rect
|
||||||
|
import android.graphics.RectF
|
||||||
|
import android.view.View
|
||||||
|
import androidx.core.view.children
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import androidx.recyclerview.widget.RecyclerView.NO_ID
|
||||||
|
|
||||||
|
abstract class AbstractSelectionItemDecoration : RecyclerView.ItemDecoration() {
|
||||||
|
|
||||||
|
private val bounds = Rect()
|
||||||
|
private val boundsF = RectF()
|
||||||
|
protected val selection = HashSet<Long>()
|
||||||
|
|
||||||
|
protected var hasBackground: Boolean = true
|
||||||
|
protected var hasForeground: Boolean = false
|
||||||
|
protected var isIncludeDecorAndMargins: Boolean = true
|
||||||
|
|
||||||
|
val checkedItemsCount: Int
|
||||||
|
get() = selection.size
|
||||||
|
|
||||||
|
val checkedItemsIds: Set<Long>
|
||||||
|
get() = selection
|
||||||
|
|
||||||
|
fun toggleItemChecked(id: Long) {
|
||||||
|
if (!selection.remove(id)) {
|
||||||
|
selection.add(id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setItemIsChecked(id: Long, isChecked: Boolean) {
|
||||||
|
if (isChecked) {
|
||||||
|
selection.add(id)
|
||||||
|
} else {
|
||||||
|
selection.remove(id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun checkAll(ids: Collection<Long>) {
|
||||||
|
selection.addAll(ids)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clearSelection() {
|
||||||
|
selection.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDraw(canvas: Canvas, parent: RecyclerView, state: RecyclerView.State) {
|
||||||
|
if (hasBackground) {
|
||||||
|
doDraw(canvas, parent, state, false)
|
||||||
|
} else {
|
||||||
|
super.onDraw(canvas, parent, state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDrawOver(canvas: Canvas, parent: RecyclerView, state: RecyclerView.State) {
|
||||||
|
if (hasForeground) {
|
||||||
|
doDraw(canvas, parent, state, true)
|
||||||
|
} else {
|
||||||
|
super.onDrawOver(canvas, parent, state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun doDraw(canvas: Canvas, parent: RecyclerView, state: RecyclerView.State, isOver: Boolean) {
|
||||||
|
val checkpoint = canvas.save()
|
||||||
|
if (parent.clipToPadding) {
|
||||||
|
canvas.clipRect(
|
||||||
|
parent.paddingLeft, parent.paddingTop, parent.width - parent.paddingRight,
|
||||||
|
parent.height - parent.paddingBottom
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (child in parent.children) {
|
||||||
|
val itemId = getItemId(parent, child)
|
||||||
|
if (itemId != NO_ID && itemId in selection) {
|
||||||
|
if (isIncludeDecorAndMargins) {
|
||||||
|
parent.getDecoratedBoundsWithMargins(child, bounds)
|
||||||
|
} else {
|
||||||
|
bounds.set(child.left, child.top, child.right, child.bottom)
|
||||||
|
}
|
||||||
|
boundsF.set(bounds)
|
||||||
|
boundsF.offset(child.translationX, child.translationY)
|
||||||
|
if (isOver) {
|
||||||
|
onDrawForeground(canvas, parent, child, boundsF, state)
|
||||||
|
} else {
|
||||||
|
onDrawBackground(canvas, parent, child, boundsF, state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
canvas.restoreToCount(checkpoint)
|
||||||
|
}
|
||||||
|
|
||||||
|
protected open fun getItemId(parent: RecyclerView, child: View) = parent.getChildItemId(child)
|
||||||
|
|
||||||
|
protected open fun onDrawBackground(
|
||||||
|
canvas: Canvas,
|
||||||
|
parent: RecyclerView,
|
||||||
|
child: View,
|
||||||
|
bounds: RectF,
|
||||||
|
state: RecyclerView.State,
|
||||||
|
) = Unit
|
||||||
|
|
||||||
|
protected open fun onDrawForeground(
|
||||||
|
canvas: Canvas,
|
||||||
|
parent: RecyclerView,
|
||||||
|
child: View,
|
||||||
|
bounds: RectF,
|
||||||
|
state: RecyclerView.State,
|
||||||
|
) = Unit
|
||||||
|
}
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
package org.koitharu.kotatsu.base.ui.list.decor
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.graphics.Canvas
|
|
||||||
import android.graphics.Rect
|
|
||||||
import android.view.View
|
|
||||||
import androidx.core.view.children
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import org.koitharu.kotatsu.utils.ext.getThemeDrawable
|
|
||||||
import kotlin.math.roundToInt
|
|
||||||
|
|
||||||
class ItemTypeDividerDecoration(context: Context) : RecyclerView.ItemDecoration() {
|
|
||||||
|
|
||||||
private val divider = context.getThemeDrawable(android.R.attr.listDivider)
|
|
||||||
private val bounds = Rect()
|
|
||||||
|
|
||||||
override fun getItemOffsets(
|
|
||||||
outRect: Rect, view: View,
|
|
||||||
parent: RecyclerView, state: RecyclerView.State
|
|
||||||
) {
|
|
||||||
outRect.set(0, divider?.intrinsicHeight ?: 0, 0, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDraw(canvas: Canvas, parent: RecyclerView, s: RecyclerView.State) {
|
|
||||||
if (parent.layoutManager == null || divider == null) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val adapter = parent.adapter ?: return
|
|
||||||
canvas.save()
|
|
||||||
val left: Int
|
|
||||||
val right: Int
|
|
||||||
if (parent.clipToPadding) {
|
|
||||||
left = parent.paddingLeft
|
|
||||||
right = parent.width - parent.paddingRight
|
|
||||||
canvas.clipRect(
|
|
||||||
left, parent.paddingTop, right,
|
|
||||||
parent.height - parent.paddingBottom
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
left = 0
|
|
||||||
right = parent.width
|
|
||||||
}
|
|
||||||
|
|
||||||
var lastItemType = -1
|
|
||||||
for (child in parent.children) {
|
|
||||||
val itemType = adapter.getItemViewType(parent.getChildAdapterPosition(child))
|
|
||||||
if (lastItemType != -1 && itemType != lastItemType) {
|
|
||||||
parent.getDecoratedBoundsWithMargins(child, bounds)
|
|
||||||
val top: Int = bounds.top + child.translationY.roundToInt()
|
|
||||||
val bottom: Int = top + divider.intrinsicHeight
|
|
||||||
divider.setBounds(left, top, right, bottom)
|
|
||||||
divider.draw(canvas)
|
|
||||||
}
|
|
||||||
lastItemType = itemType
|
|
||||||
}
|
|
||||||
canvas.restore()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
package org.koitharu.kotatsu.base.ui.list.decor
|
|
||||||
|
|
||||||
import android.graphics.Canvas
|
|
||||||
import android.graphics.Rect
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.TextView
|
|
||||||
import androidx.core.view.children
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import org.koitharu.kotatsu.R
|
|
||||||
import org.koitharu.kotatsu.utils.ext.inflate
|
|
||||||
import kotlin.math.max
|
|
||||||
|
|
||||||
/**
|
|
||||||
* https://github.com/paetztm/recycler_view_headers
|
|
||||||
*/
|
|
||||||
class SectionItemDecoration(
|
|
||||||
private val isSticky: Boolean,
|
|
||||||
private val callback: Callback
|
|
||||||
) : RecyclerView.ItemDecoration() {
|
|
||||||
|
|
||||||
private var headerView: TextView? = null
|
|
||||||
private var headerOffset: Int = 0
|
|
||||||
|
|
||||||
override fun getItemOffsets(
|
|
||||||
outRect: Rect,
|
|
||||||
view: View,
|
|
||||||
parent: RecyclerView,
|
|
||||||
state: RecyclerView.State
|
|
||||||
) {
|
|
||||||
if (headerOffset == 0) {
|
|
||||||
headerOffset = parent.resources.getDimensionPixelSize(R.dimen.header_height)
|
|
||||||
}
|
|
||||||
val pos = parent.getChildAdapterPosition(view)
|
|
||||||
outRect.set(0, if (callback.isSection(pos)) headerOffset else 0, 0, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDrawOver(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
|
|
||||||
super.onDrawOver(c, parent, state)
|
|
||||||
val textView = headerView ?: parent.inflate<TextView>(R.layout.item_header).also {
|
|
||||||
headerView = it
|
|
||||||
}
|
|
||||||
fixLayoutSize(textView, parent)
|
|
||||||
|
|
||||||
for (child in parent.children) {
|
|
||||||
val pos = parent.getChildAdapterPosition(child)
|
|
||||||
if (callback.isSection(pos)) {
|
|
||||||
textView.text = callback.getSectionTitle(pos) ?: continue
|
|
||||||
c.save()
|
|
||||||
if (isSticky) {
|
|
||||||
c.translate(
|
|
||||||
0f,
|
|
||||||
max(0f, (child.top - textView.height).toFloat())
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
c.translate(
|
|
||||||
0f,
|
|
||||||
(child.top - textView.height).toFloat()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
textView.draw(c)
|
|
||||||
c.restore()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Measures the header view to make sure its size is greater than 0 and will be drawn
|
|
||||||
* https://yoda.entelect.co.za/view/9627/how-to-android-recyclerview-item-decorations
|
|
||||||
*/
|
|
||||||
private fun fixLayoutSize(view: View, parent: ViewGroup) {
|
|
||||||
val widthSpec = View.MeasureSpec.makeMeasureSpec(parent.width, View.MeasureSpec.EXACTLY)
|
|
||||||
val heightSpec =
|
|
||||||
View.MeasureSpec.makeMeasureSpec(parent.height, View.MeasureSpec.UNSPECIFIED)
|
|
||||||
|
|
||||||
val childWidth = ViewGroup.getChildMeasureSpec(
|
|
||||||
widthSpec,
|
|
||||||
parent.paddingLeft + parent.paddingRight,
|
|
||||||
view.layoutParams.width
|
|
||||||
)
|
|
||||||
val childHeight = ViewGroup.getChildMeasureSpec(
|
|
||||||
heightSpec,
|
|
||||||
parent.paddingTop + parent.paddingBottom,
|
|
||||||
view.layoutParams.height
|
|
||||||
)
|
|
||||||
view.measure(childWidth, childHeight)
|
|
||||||
view.layout(0, 0, view.measuredWidth, view.measuredHeight)
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Callback {
|
|
||||||
|
|
||||||
fun isSection(position: Int): Boolean
|
|
||||||
|
|
||||||
fun getSectionTitle(position: Int): CharSequence?
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.list.decor
|
||||||
|
|
||||||
|
import android.graphics.Rect
|
||||||
|
import android.util.SparseIntArray
|
||||||
|
import android.view.View
|
||||||
|
import androidx.core.util.getOrDefault
|
||||||
|
import androidx.core.util.set
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
|
||||||
|
class TypedSpacingItemDecoration(
|
||||||
|
vararg spacingMapping: Pair<Int, Int>,
|
||||||
|
private val fallbackSpacing: Int = 0,
|
||||||
|
) : RecyclerView.ItemDecoration() {
|
||||||
|
|
||||||
|
private val mapping = SparseIntArray(spacingMapping.size)
|
||||||
|
|
||||||
|
init {
|
||||||
|
spacingMapping.forEach { (k, v) -> mapping[k] = v }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemOffsets(
|
||||||
|
outRect: Rect,
|
||||||
|
view: View,
|
||||||
|
parent: RecyclerView,
|
||||||
|
state: RecyclerView.State
|
||||||
|
) {
|
||||||
|
val itemType = parent.getChildViewHolder(view)?.itemViewType
|
||||||
|
val spacing = if (itemType == null) {
|
||||||
|
fallbackSpacing
|
||||||
|
} else {
|
||||||
|
mapping.getOrDefault(itemType, fallbackSpacing)
|
||||||
|
}
|
||||||
|
outRect.set(spacing, spacing, spacing, spacing)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.util
|
||||||
|
|
||||||
|
import androidx.appcompat.view.ActionMode
|
||||||
|
import androidx.lifecycle.DefaultLifecycleObserver
|
||||||
|
import androidx.lifecycle.LifecycleOwner
|
||||||
|
|
||||||
|
class ActionModeDelegate {
|
||||||
|
|
||||||
|
private var activeActionMode: ActionMode? = null
|
||||||
|
private var listeners: MutableList<ActionModeListener>? = null
|
||||||
|
|
||||||
|
val isActionModeStarted: Boolean
|
||||||
|
get() = activeActionMode != null
|
||||||
|
|
||||||
|
fun onSupportActionModeStarted(mode: ActionMode) {
|
||||||
|
activeActionMode = mode
|
||||||
|
listeners?.forEach { it.onActionModeStarted(mode) }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onSupportActionModeFinished(mode: ActionMode) {
|
||||||
|
activeActionMode = null
|
||||||
|
listeners?.forEach { it.onActionModeFinished(mode) }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addListener(listener: ActionModeListener) {
|
||||||
|
if (listeners == null) {
|
||||||
|
listeners = ArrayList()
|
||||||
|
}
|
||||||
|
checkNotNull(listeners).add(listener)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun removeListener(listener: ActionModeListener) {
|
||||||
|
listeners?.remove(listener)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addListener(listener: ActionModeListener, owner: LifecycleOwner) {
|
||||||
|
addListener(listener)
|
||||||
|
owner.lifecycle.addObserver(ListenerLifecycleObserver(listener))
|
||||||
|
}
|
||||||
|
|
||||||
|
private inner class ListenerLifecycleObserver(
|
||||||
|
private val listener: ActionModeListener,
|
||||||
|
) : DefaultLifecycleObserver {
|
||||||
|
|
||||||
|
override fun onDestroy(owner: LifecycleOwner) {
|
||||||
|
super.onDestroy(owner)
|
||||||
|
removeListener(listener)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.util
|
||||||
|
|
||||||
|
import androidx.appcompat.view.ActionMode
|
||||||
|
|
||||||
|
interface ActionModeListener {
|
||||||
|
|
||||||
|
fun onActionModeStarted(mode: ActionMode)
|
||||||
|
|
||||||
|
fun onActionModeFinished(mode: ActionMode)
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.util
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.app.Application.ActivityLifecycleCallbacks
|
||||||
|
import android.os.Bundle
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class ActivityRecreationHandle : ActivityLifecycleCallbacks {
|
||||||
|
|
||||||
|
private val activities = WeakHashMap<Activity, Unit>()
|
||||||
|
|
||||||
|
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
|
||||||
|
activities[activity] = Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityStarted(activity: Activity) = Unit
|
||||||
|
|
||||||
|
override fun onActivityResumed(activity: Activity) = Unit
|
||||||
|
|
||||||
|
override fun onActivityPaused(activity: Activity) = Unit
|
||||||
|
|
||||||
|
override fun onActivityStopped(activity: Activity) = Unit
|
||||||
|
|
||||||
|
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) = Unit
|
||||||
|
|
||||||
|
override fun onActivityDestroyed(activity: Activity) {
|
||||||
|
activities.remove(activity)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun recreateAll() {
|
||||||
|
val snapshot = activities.keys.toList()
|
||||||
|
snapshot.forEach { it.recreate() }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.util
|
||||||
|
|
||||||
|
import androidx.annotation.AnyThread
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
|
|
||||||
|
class CountedBooleanLiveData : LiveData<Boolean>(false) {
|
||||||
|
|
||||||
|
private val counter = AtomicInteger(0)
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
|
fun increment() {
|
||||||
|
if (counter.getAndIncrement() == 0) {
|
||||||
|
postValue(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
|
fun decrement() {
|
||||||
|
if (counter.decrementAndGet() == 0) {
|
||||||
|
postValue(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
|
fun reset() {
|
||||||
|
if (counter.getAndSet(0) != 0) {
|
||||||
|
postValue(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.util
|
||||||
|
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
|
||||||
|
interface RecyclerViewOwner {
|
||||||
|
|
||||||
|
val recyclerView: RecyclerView
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.util
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.View
|
||||||
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
import androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
|
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||||
|
|
||||||
|
class ShrinkOnScrollBehavior : Behavior<ExtendedFloatingActionButton> {
|
||||||
|
|
||||||
|
@Suppress("unused") constructor() : super()
|
||||||
|
@Suppress("unused") constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
|
||||||
|
|
||||||
|
override fun onStartNestedScroll(
|
||||||
|
coordinatorLayout: CoordinatorLayout,
|
||||||
|
child: ExtendedFloatingActionButton,
|
||||||
|
directTargetChild: View,
|
||||||
|
target: View,
|
||||||
|
axes: Int,
|
||||||
|
type: Int
|
||||||
|
): Boolean {
|
||||||
|
return axes == ViewCompat.SCROLL_AXIS_VERTICAL
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNestedScroll(
|
||||||
|
coordinatorLayout: CoordinatorLayout,
|
||||||
|
child: ExtendedFloatingActionButton,
|
||||||
|
target: View,
|
||||||
|
dxConsumed: Int,
|
||||||
|
dyConsumed: Int,
|
||||||
|
dxUnconsumed: Int,
|
||||||
|
dyUnconsumed: Int,
|
||||||
|
type: Int,
|
||||||
|
consumed: IntArray
|
||||||
|
) {
|
||||||
|
if (dyConsumed > 0) {
|
||||||
|
if (child.isExtended) {
|
||||||
|
child.shrink()
|
||||||
|
}
|
||||||
|
} else if (dyConsumed < 0) {
|
||||||
|
if (!child.isExtended) {
|
||||||
|
child.extend()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.util
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import androidx.core.graphics.Insets
|
||||||
|
import androidx.core.view.OnApplyWindowInsetsListener
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
|
||||||
|
class WindowInsetsDelegate(
|
||||||
|
private val listener: WindowInsetsListener,
|
||||||
|
) : OnApplyWindowInsetsListener, View.OnLayoutChangeListener {
|
||||||
|
|
||||||
|
var handleImeInsets: Boolean = false
|
||||||
|
|
||||||
|
var interceptingWindowInsetsListener: OnApplyWindowInsetsListener? = null
|
||||||
|
|
||||||
|
private var lastInsets: Insets? = null
|
||||||
|
|
||||||
|
override fun onApplyWindowInsets(v: View, insets: WindowInsetsCompat): WindowInsetsCompat {
|
||||||
|
val handledInsets = interceptingWindowInsetsListener?.onApplyWindowInsets(v, insets) ?: insets
|
||||||
|
val newInsets = if (handleImeInsets) {
|
||||||
|
Insets.max(
|
||||||
|
handledInsets.getInsets(WindowInsetsCompat.Type.systemBars()),
|
||||||
|
handledInsets.getInsets(WindowInsetsCompat.Type.ime()),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
handledInsets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
|
}
|
||||||
|
if (newInsets != lastInsets) {
|
||||||
|
listener.onWindowInsetsChanged(newInsets)
|
||||||
|
lastInsets = newInsets
|
||||||
|
}
|
||||||
|
return handledInsets
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onLayoutChange(
|
||||||
|
view: View,
|
||||||
|
left: Int,
|
||||||
|
top: Int,
|
||||||
|
right: Int,
|
||||||
|
bottom: Int,
|
||||||
|
oldLeft: Int,
|
||||||
|
oldTop: Int,
|
||||||
|
oldRight: Int,
|
||||||
|
oldBottom: Int,
|
||||||
|
) {
|
||||||
|
view.removeOnLayoutChangeListener(this)
|
||||||
|
if (lastInsets == null) { // Listener may not be called
|
||||||
|
onApplyWindowInsets(view, ViewCompat.getRootWindowInsets(view) ?: return)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onViewCreated(view: View) {
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(view, this)
|
||||||
|
view.addOnLayoutChangeListener(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onDestroyView() {
|
||||||
|
lastInsets = null
|
||||||
|
}
|
||||||
|
|
||||||
|
interface WindowInsetsListener {
|
||||||
|
|
||||||
|
fun onWindowInsetsChanged(insets: Insets)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import androidx.annotation.AttrRes
|
||||||
|
import androidx.annotation.IdRes
|
||||||
|
import androidx.core.view.children
|
||||||
|
import com.google.android.material.button.MaterialButton
|
||||||
|
|
||||||
|
class CheckableButtonGroup @JvmOverloads constructor(
|
||||||
|
context: Context,
|
||||||
|
attrs: AttributeSet? = null,
|
||||||
|
@AttrRes defStyleAttr: Int = 0,
|
||||||
|
) : LinearLayout(context, attrs, defStyleAttr), View.OnClickListener {
|
||||||
|
|
||||||
|
var onCheckedChangeListener: OnCheckedChangeListener? = null
|
||||||
|
|
||||||
|
override fun addView(child: View?, index: Int, params: ViewGroup.LayoutParams?) {
|
||||||
|
if (child is MaterialButton) {
|
||||||
|
child.setOnClickListener(this)
|
||||||
|
}
|
||||||
|
super.addView(child, index, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onClick(v: View) {
|
||||||
|
setCheckedId(v.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setCheckedId(@IdRes viewRes: Int) {
|
||||||
|
children.forEach {
|
||||||
|
(it as? MaterialButton)?.isChecked = it.id == viewRes
|
||||||
|
}
|
||||||
|
onCheckedChangeListener?.onCheckedChanged(this, viewRes)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun interface OnCheckedChangeListener {
|
||||||
|
fun onCheckedChanged(group: CheckableButtonGroup, checkedId: Int)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,21 @@
|
|||||||
package org.koitharu.kotatsu.base.ui.widgets
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.Parcel
|
||||||
|
import android.os.Parcelable
|
||||||
|
import android.os.Parcelable.Creator
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
import android.view.View
|
||||||
import android.widget.Checkable
|
import android.widget.Checkable
|
||||||
|
import androidx.annotation.AttrRes
|
||||||
import androidx.appcompat.widget.AppCompatImageView
|
import androidx.appcompat.widget.AppCompatImageView
|
||||||
|
import androidx.core.os.ParcelCompat
|
||||||
|
import androidx.customview.view.AbsSavedState
|
||||||
|
|
||||||
class CheckableImageView @JvmOverloads constructor(
|
class CheckableImageView @JvmOverloads constructor(
|
||||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
context: Context,
|
||||||
|
attrs: AttributeSet? = null,
|
||||||
|
@AttrRes defStyleAttr: Int = 0,
|
||||||
) : AppCompatImageView(context, attrs, defStyleAttr), Checkable {
|
) : AppCompatImageView(context, attrs, defStyleAttr), Checkable {
|
||||||
|
|
||||||
private var isCheckedInternal = false
|
private var isCheckedInternal = false
|
||||||
@@ -14,20 +23,6 @@ class CheckableImageView @JvmOverloads constructor(
|
|||||||
|
|
||||||
var onCheckedChangeListener: OnCheckedChangeListener? = null
|
var onCheckedChangeListener: OnCheckedChangeListener? = null
|
||||||
|
|
||||||
init {
|
|
||||||
setOnClickListener {
|
|
||||||
toggle()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setOnCheckedChangeListener(listener: (Boolean) -> Unit) {
|
|
||||||
onCheckedChangeListener = object : OnCheckedChangeListener {
|
|
||||||
override fun onCheckedChanged(view: CheckableImageView, isChecked: Boolean) {
|
|
||||||
listener(isChecked)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun isChecked() = isCheckedInternal
|
override fun isChecked() = isCheckedInternal
|
||||||
|
|
||||||
override fun toggle() {
|
override fun toggle() {
|
||||||
@@ -49,18 +44,61 @@ class CheckableImageView @JvmOverloads constructor(
|
|||||||
override fun onCreateDrawableState(extraSpace: Int): IntArray {
|
override fun onCreateDrawableState(extraSpace: Int): IntArray {
|
||||||
val state = super.onCreateDrawableState(extraSpace + 1)
|
val state = super.onCreateDrawableState(extraSpace + 1)
|
||||||
if (isCheckedInternal) {
|
if (isCheckedInternal) {
|
||||||
mergeDrawableStates(state, CHECKED_STATE_SET)
|
mergeDrawableStates(state, intArrayOf(android.R.attr.state_checked))
|
||||||
}
|
}
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onSaveInstanceState(): Parcelable? {
|
||||||
|
val superState = super.onSaveInstanceState() ?: return null
|
||||||
|
return SavedState(superState, isChecked)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onRestoreInstanceState(state: Parcelable?) {
|
||||||
|
if (state is SavedState) {
|
||||||
|
super.onRestoreInstanceState(state.superState)
|
||||||
|
isChecked = state.isChecked
|
||||||
|
} else {
|
||||||
|
super.onRestoreInstanceState(state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ToggleOnClickListener : OnClickListener {
|
||||||
|
override fun onClick(view: View) {
|
||||||
|
(view as? Checkable)?.toggle()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun interface OnCheckedChangeListener {
|
fun interface OnCheckedChangeListener {
|
||||||
|
|
||||||
fun onCheckedChanged(view: CheckableImageView, isChecked: Boolean)
|
fun onCheckedChanged(view: CheckableImageView, isChecked: Boolean)
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
private class SavedState : AbsSavedState {
|
||||||
|
|
||||||
private val CHECKED_STATE_SET = intArrayOf(android.R.attr.state_checked)
|
val isChecked: Boolean
|
||||||
|
|
||||||
|
constructor(superState: Parcelable, checked: Boolean) : super(superState) {
|
||||||
|
isChecked = checked
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: Parcel, classLoader: ClassLoader?) : super(source, classLoader) {
|
||||||
|
isChecked = ParcelCompat.readBoolean(source)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun writeToParcel(out: Parcel, flags: Int) {
|
||||||
|
super.writeToParcel(out, flags)
|
||||||
|
ParcelCompat.writeBoolean(out, isChecked)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@Suppress("unused")
|
||||||
|
@JvmField
|
||||||
|
val CREATOR: Creator<SavedState> = object : Creator<SavedState> {
|
||||||
|
override fun createFromParcel(`in`: Parcel) = SavedState(`in`, SavedState::class.java.classLoader)
|
||||||
|
|
||||||
|
override fun newArray(size: Int): Array<SavedState?> = arrayOfNulls(size)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,15 +5,15 @@ import android.util.AttributeSet
|
|||||||
import android.view.View.OnClickListener
|
import android.view.View.OnClickListener
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import androidx.core.view.children
|
import androidx.core.view.children
|
||||||
import com.google.android.material.R
|
|
||||||
import com.google.android.material.chip.Chip
|
import com.google.android.material.chip.Chip
|
||||||
|
import com.google.android.material.chip.ChipDrawable
|
||||||
import com.google.android.material.chip.ChipGroup
|
import com.google.android.material.chip.ChipGroup
|
||||||
import org.koitharu.kotatsu.utils.ext.getThemeColor
|
import org.koitharu.kotatsu.R
|
||||||
|
|
||||||
class ChipsView @JvmOverloads constructor(
|
class ChipsView @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
attrs: AttributeSet? = null,
|
attrs: AttributeSet? = null,
|
||||||
defStyleAttr: Int = R.attr.chipGroupStyle
|
defStyleAttr: Int = com.google.android.material.R.attr.chipGroupStyle
|
||||||
) : ChipGroup(context, attrs, defStyleAttr) {
|
) : ChipGroup(context, attrs, defStyleAttr) {
|
||||||
|
|
||||||
private var isLayoutSuppressedCompat = false
|
private var isLayoutSuppressedCompat = false
|
||||||
@@ -21,12 +21,21 @@ class ChipsView @JvmOverloads constructor(
|
|||||||
private var chipOnClickListener = OnClickListener {
|
private var chipOnClickListener = OnClickListener {
|
||||||
onChipClickListener?.onChipClick(it as Chip, it.tag)
|
onChipClickListener?.onChipClick(it as Chip, it.tag)
|
||||||
}
|
}
|
||||||
|
private var chipOnCloseListener = OnClickListener {
|
||||||
|
onChipCloseClickListener?.onChipCloseClick(it as Chip, it.tag)
|
||||||
|
}
|
||||||
var onChipClickListener: OnChipClickListener? = null
|
var onChipClickListener: OnChipClickListener? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
val isChipClickable = value != null
|
val isChipClickable = value != null
|
||||||
children.forEach { it.isClickable = isChipClickable }
|
children.forEach { it.isClickable = isChipClickable }
|
||||||
}
|
}
|
||||||
|
var onChipCloseClickListener: OnChipCloseClickListener? = null
|
||||||
|
set(value) {
|
||||||
|
field = value
|
||||||
|
val isCloseIconVisible = value != null
|
||||||
|
children.forEach { (it as? Chip)?.isCloseIconVisible = isCloseIconVisible }
|
||||||
|
}
|
||||||
|
|
||||||
override fun requestLayout() {
|
override fun requestLayout() {
|
||||||
if (isLayoutSuppressedCompat) {
|
if (isLayoutSuppressedCompat) {
|
||||||
@@ -36,15 +45,15 @@ class ChipsView @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setChips(items: List<ChipModel>) {
|
fun setChips(items: Collection<ChipModel>) {
|
||||||
suppressLayoutCompat(true)
|
suppressLayoutCompat(true)
|
||||||
try {
|
try {
|
||||||
for ((i, model) in items.withIndex()) {
|
for ((i, model) in items.withIndex()) {
|
||||||
val chip = getChildAt(i) as Chip? ?: addChip()
|
val chip = getChildAt(i) as Chip? ?: addChip()
|
||||||
bindChip(chip, model)
|
bindChip(chip, model)
|
||||||
}
|
}
|
||||||
for (i in items.size until childCount) {
|
if (childCount > items.size) {
|
||||||
removeViewAt(i)
|
removeViews(items.size, childCount - items.size)
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
suppressLayoutCompat(false)
|
suppressLayoutCompat(false)
|
||||||
@@ -59,16 +68,19 @@ class ChipsView @JvmOverloads constructor(
|
|||||||
chip.isCheckedIconVisible = true
|
chip.isCheckedIconVisible = true
|
||||||
chip.setChipIconResource(model.icon)
|
chip.setChipIconResource(model.icon)
|
||||||
}
|
}
|
||||||
|
chip.isClickable = onChipClickListener != null
|
||||||
chip.tag = model.data
|
chip.tag = model.data
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addChip(): Chip {
|
private fun addChip(): Chip {
|
||||||
val chip = Chip(context)
|
val chip = Chip(context)
|
||||||
chip.setTextColor(context.getThemeColor(android.R.attr.textColorPrimary))
|
val drawable = ChipDrawable.createFromAttributes(context, null, 0, R.style.Widget_Kotatsu_Chip)
|
||||||
chip.isCloseIconVisible = false
|
chip.setChipDrawable(drawable)
|
||||||
|
chip.isCloseIconVisible = onChipCloseClickListener != null
|
||||||
|
chip.setOnCloseIconClickListener(chipOnCloseListener)
|
||||||
chip.setEnsureMinTouchTargetSize(false)
|
chip.setEnsureMinTouchTargetSize(false)
|
||||||
chip.setOnClickListener(chipOnClickListener)
|
chip.setOnClickListener(chipOnClickListener)
|
||||||
chip.isClickable = onChipClickListener != null
|
chip.isCheckable = false
|
||||||
addView(chip)
|
addView(chip)
|
||||||
return chip
|
return chip
|
||||||
}
|
}
|
||||||
@@ -83,14 +95,40 @@ class ChipsView @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class ChipModel(
|
class ChipModel(
|
||||||
@DrawableRes val icon: Int,
|
@DrawableRes val icon: Int,
|
||||||
val title: CharSequence,
|
val title: CharSequence,
|
||||||
val data: Any? = null
|
val data: Any? = null
|
||||||
)
|
) {
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
if (javaClass != other?.javaClass) return false
|
||||||
|
|
||||||
|
other as ChipModel
|
||||||
|
|
||||||
|
if (icon != other.icon) return false
|
||||||
|
if (title != other.title) return false
|
||||||
|
if (data != other.data) return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var result = icon
|
||||||
|
result = 31 * result + title.hashCode()
|
||||||
|
result = 31 * result + data.hashCode()
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun interface OnChipClickListener {
|
fun interface OnChipClickListener {
|
||||||
|
|
||||||
fun onChipClick(chip: Chip, data: Any?)
|
fun onChipClick(chip: Chip, data: Any?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun interface OnChipCloseClickListener {
|
||||||
|
|
||||||
|
fun onChipCloseClick(chip: Chip, data: Any?)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,52 +2,42 @@ package org.koitharu.kotatsu.base.ui.widgets
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout.HORIZONTAL
|
||||||
import androidx.appcompat.widget.AppCompatImageView
|
import android.widget.LinearLayout.VERTICAL
|
||||||
|
import androidx.annotation.AttrRes
|
||||||
import androidx.core.content.withStyledAttributes
|
import androidx.core.content.withStyledAttributes
|
||||||
|
import com.google.android.material.imageview.ShapeableImageView
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
|
private const val ASPECT_RATIO_HEIGHT = 18f
|
||||||
|
private const val ASPECT_RATIO_WIDTH = 13f
|
||||||
|
|
||||||
class CoverImageView @JvmOverloads constructor(
|
class CoverImageView @JvmOverloads constructor(
|
||||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
context: Context,
|
||||||
) : AppCompatImageView(context, attrs, defStyleAttr) {
|
attrs: AttributeSet? = null,
|
||||||
|
@AttrRes defStyleAttr: Int = 0,
|
||||||
|
) : ShapeableImageView(context, attrs, defStyleAttr) {
|
||||||
|
|
||||||
private var orientation: Int = HORIZONTAL
|
private var orientation: Int = HORIZONTAL
|
||||||
|
|
||||||
init {
|
init {
|
||||||
context.withStyledAttributes(attrs, R.styleable.CoverImageView, defStyleAttr) {
|
context.withStyledAttributes(attrs, R.styleable.CoverImageView, defStyleAttr) {
|
||||||
orientation = getInt(R.styleable.CoverImageView_android_orientation, HORIZONTAL)
|
orientation = getInt(R.styleable.CoverImageView_android_orientation, orientation)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||||
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||||
|
val desiredWidth: Int
|
||||||
|
val desiredHeight: Int
|
||||||
if (orientation == VERTICAL) {
|
if (orientation == VERTICAL) {
|
||||||
val originalHeight = MeasureSpec.getSize(heightMeasureSpec)
|
desiredHeight = measuredHeight
|
||||||
super.onMeasure(
|
desiredWidth = (desiredHeight * ASPECT_RATIO_WIDTH / ASPECT_RATIO_HEIGHT).roundToInt()
|
||||||
MeasureSpec.makeMeasureSpec(
|
|
||||||
(originalHeight * ASPECT_RATIO_WIDTH / ASPECT_RATIO_HEIGHT).toInt(),
|
|
||||||
MeasureSpec.EXACTLY
|
|
||||||
),
|
|
||||||
MeasureSpec.makeMeasureSpec(originalHeight, MeasureSpec.EXACTLY)
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
val originalWidth = MeasureSpec.getSize(widthMeasureSpec)
|
desiredWidth = measuredWidth
|
||||||
super.onMeasure(
|
desiredHeight = (desiredWidth * ASPECT_RATIO_HEIGHT / ASPECT_RATIO_WIDTH).roundToInt()
|
||||||
MeasureSpec.makeMeasureSpec(originalWidth, MeasureSpec.EXACTLY),
|
|
||||||
MeasureSpec.makeMeasureSpec(
|
|
||||||
(originalWidth * ASPECT_RATIO_HEIGHT / ASPECT_RATIO_WIDTH).toInt(),
|
|
||||||
MeasureSpec.EXACTLY
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
setMeasuredDimension(desiredWidth, desiredHeight)
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
const val VERTICAL = LinearLayout.VERTICAL
|
|
||||||
const val HORIZONTAL = LinearLayout.HORIZONTAL
|
|
||||||
|
|
||||||
private const val ASPECT_RATIO_HEIGHT = 18f
|
|
||||||
private const val ASPECT_RATIO_WIDTH = 13f
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.res.ColorStateList
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.widget.FrameLayout
|
||||||
|
import androidx.annotation.ColorInt
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import androidx.core.graphics.drawable.DrawableCompat
|
||||||
|
import androidx.core.view.postDelayed
|
||||||
|
import com.google.android.material.color.MaterialColors
|
||||||
|
import com.google.android.material.shape.MaterialShapeDrawable
|
||||||
|
import com.google.android.material.shape.ShapeAppearanceModel
|
||||||
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
import org.koitharu.kotatsu.databinding.FadingSnackbarLayoutBinding
|
||||||
|
import org.koitharu.kotatsu.utils.ext.getThemeColorStateList
|
||||||
|
import com.google.android.material.R as materialR
|
||||||
|
|
||||||
|
private const val ENTER_DURATION = 300L
|
||||||
|
private const val EXIT_DURATION = 200L
|
||||||
|
private const val SHORT_DURATION_MS = 1_500L
|
||||||
|
private const val LONG_DURATION_MS = 2_750L
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A custom snackbar implementation allowing more control over placement and entry/exit animations.
|
||||||
|
*
|
||||||
|
* Xtimms: Well, my sufferings over the Snackbar in [DetailsActivity] will go away forever... Thanks, Google.
|
||||||
|
*
|
||||||
|
* https://github.com/google/iosched/blob/main/mobile/src/main/java/com/google/samples/apps/iosched/widget/FadingSnackbar.kt
|
||||||
|
*/
|
||||||
|
class FadingSnackbar @JvmOverloads constructor(
|
||||||
|
context: Context,
|
||||||
|
attrs: AttributeSet? = null,
|
||||||
|
defStyleAttr: Int = 0,
|
||||||
|
) : FrameLayout(context, attrs, defStyleAttr) {
|
||||||
|
|
||||||
|
private val binding = FadingSnackbarLayoutBinding.inflate(LayoutInflater.from(context), this)
|
||||||
|
|
||||||
|
init {
|
||||||
|
binding.snackbarLayout.background = createThemedBackground()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun dismiss() {
|
||||||
|
if (visibility == VISIBLE && alpha == 1f) {
|
||||||
|
animate()
|
||||||
|
.alpha(0f)
|
||||||
|
.withEndAction { visibility = GONE }
|
||||||
|
.duration = EXIT_DURATION
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun show(
|
||||||
|
messageText: CharSequence?,
|
||||||
|
@StringRes actionId: Int = 0,
|
||||||
|
duration: Int = Snackbar.LENGTH_SHORT,
|
||||||
|
onActionClick: (FadingSnackbar.() -> Unit)? = null,
|
||||||
|
onDismiss: (() -> Unit)? = null,
|
||||||
|
) {
|
||||||
|
binding.snackbarText.text = messageText
|
||||||
|
if (actionId != 0) {
|
||||||
|
with(binding.snackbarAction) {
|
||||||
|
visibility = VISIBLE
|
||||||
|
text = context.getString(actionId)
|
||||||
|
setOnClickListener {
|
||||||
|
onActionClick?.invoke(this@FadingSnackbar) ?: dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
binding.snackbarAction.visibility = GONE
|
||||||
|
}
|
||||||
|
alpha = 0f
|
||||||
|
visibility = VISIBLE
|
||||||
|
animate()
|
||||||
|
.alpha(1f)
|
||||||
|
.duration = ENTER_DURATION
|
||||||
|
if (duration == Snackbar.LENGTH_INDEFINITE) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val durationMs = ENTER_DURATION + if (duration == Snackbar.LENGTH_LONG) LONG_DURATION_MS else SHORT_DURATION_MS
|
||||||
|
postDelayed(durationMs) {
|
||||||
|
dismiss()
|
||||||
|
onDismiss?.invoke()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createThemedBackground(): Drawable {
|
||||||
|
val backgroundColor = MaterialColors.layer(this, materialR.attr.colorSurface, materialR.attr.colorOnSurface, 1f)
|
||||||
|
val shapeAppearanceModel = ShapeAppearanceModel.builder(
|
||||||
|
context,
|
||||||
|
materialR.style.ShapeAppearance_Material3_Corner_ExtraSmall,
|
||||||
|
0
|
||||||
|
).build()
|
||||||
|
val background = createMaterialShapeDrawableBackground(
|
||||||
|
backgroundColor,
|
||||||
|
shapeAppearanceModel,
|
||||||
|
)
|
||||||
|
val backgroundTint = context.getThemeColorStateList(materialR.attr.colorSurfaceInverse)
|
||||||
|
return if (backgroundTint != null) {
|
||||||
|
val wrappedDrawable = DrawableCompat.wrap(background)
|
||||||
|
DrawableCompat.setTintList(wrappedDrawable, backgroundTint)
|
||||||
|
wrappedDrawable
|
||||||
|
} else {
|
||||||
|
DrawableCompat.wrap(background)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createMaterialShapeDrawableBackground(
|
||||||
|
@ColorInt backgroundColor: Int,
|
||||||
|
shapeAppearanceModel: ShapeAppearanceModel,
|
||||||
|
): MaterialShapeDrawable {
|
||||||
|
val background = MaterialShapeDrawable(shapeAppearanceModel)
|
||||||
|
background.fillColor = ColorStateList.valueOf(backgroundColor)
|
||||||
|
return background
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.res.ColorStateList
|
||||||
|
import android.content.res.TypedArray
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.graphics.drawable.InsetDrawable
|
||||||
|
import android.graphics.drawable.RippleDrawable
|
||||||
|
import android.graphics.drawable.ShapeDrawable
|
||||||
|
import android.graphics.drawable.shapes.RectShape
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import androidx.annotation.AttrRes
|
||||||
|
import androidx.appcompat.widget.AppCompatCheckedTextView
|
||||||
|
import androidx.core.content.withStyledAttributes
|
||||||
|
import com.google.android.material.ripple.RippleUtils
|
||||||
|
import com.google.android.material.shape.MaterialShapeDrawable
|
||||||
|
import com.google.android.material.shape.ShapeAppearanceModel
|
||||||
|
import org.koitharu.kotatsu.R
|
||||||
|
import org.koitharu.kotatsu.utils.ext.getThemeColorStateList
|
||||||
|
|
||||||
|
@SuppressLint("RestrictedApi")
|
||||||
|
class ListItemTextView @JvmOverloads constructor(
|
||||||
|
context: Context,
|
||||||
|
attrs: AttributeSet? = null,
|
||||||
|
@AttrRes defStyleAttr: Int = R.attr.listItemTextViewStyle,
|
||||||
|
) : AppCompatCheckedTextView(context, attrs, defStyleAttr) {
|
||||||
|
|
||||||
|
private var checkedDrawableStart: Drawable? = null
|
||||||
|
private var checkedDrawableEnd: Drawable? = null
|
||||||
|
private var isInitialized = false
|
||||||
|
private var isCheckDrawablesVisible: Boolean = false
|
||||||
|
private var defaultPaddingStart: Int = 0
|
||||||
|
private var defaultPaddingEnd: Int = 0
|
||||||
|
|
||||||
|
init {
|
||||||
|
context.withStyledAttributes(attrs, R.styleable.ListItemTextView, defStyleAttr) {
|
||||||
|
val itemRippleColor = getRippleColor(context)
|
||||||
|
val shape = createShapeDrawable(this)
|
||||||
|
background = RippleDrawable(
|
||||||
|
RippleUtils.sanitizeRippleDrawableColor(itemRippleColor),
|
||||||
|
shape,
|
||||||
|
ShapeDrawable(RectShape()),
|
||||||
|
)
|
||||||
|
checkedDrawableStart = getDrawable(R.styleable.ListItemTextView_checkedDrawableStart)
|
||||||
|
checkedDrawableEnd = getDrawable(R.styleable.ListItemTextView_checkedDrawableEnd)
|
||||||
|
}
|
||||||
|
checkedDrawableStart?.setTintList(textColors)
|
||||||
|
checkedDrawableEnd?.setTintList(textColors)
|
||||||
|
defaultPaddingStart = paddingStart
|
||||||
|
defaultPaddingEnd = paddingEnd
|
||||||
|
isInitialized = true
|
||||||
|
adjustCheckDrawables()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun refreshDrawableState() {
|
||||||
|
super.refreshDrawableState()
|
||||||
|
adjustCheckDrawables()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setTextColor(colors: ColorStateList?) {
|
||||||
|
checkedDrawableStart?.setTintList(colors)
|
||||||
|
checkedDrawableEnd?.setTintList(colors)
|
||||||
|
super.setTextColor(colors)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setPaddingRelative(start: Int, top: Int, end: Int, bottom: Int) {
|
||||||
|
defaultPaddingStart = start
|
||||||
|
defaultPaddingEnd = end
|
||||||
|
super.setPaddingRelative(start, top, end, bottom)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setPadding(left: Int, top: Int, right: Int, bottom: Int) {
|
||||||
|
val isRtl = layoutDirection == LAYOUT_DIRECTION_RTL
|
||||||
|
defaultPaddingStart = if (isRtl) right else left
|
||||||
|
defaultPaddingEnd = if (isRtl) left else right
|
||||||
|
super.setPadding(left, top, right, bottom)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun adjustCheckDrawables() {
|
||||||
|
if (isInitialized && isCheckDrawablesVisible != isChecked) {
|
||||||
|
setCompoundDrawablesRelativeWithIntrinsicBounds(
|
||||||
|
if (isChecked) checkedDrawableStart else null,
|
||||||
|
null,
|
||||||
|
if (isChecked) checkedDrawableEnd else null,
|
||||||
|
null,
|
||||||
|
)
|
||||||
|
super.setPaddingRelative(
|
||||||
|
if (isChecked && checkedDrawableStart != null) {
|
||||||
|
defaultPaddingStart + compoundDrawablePadding
|
||||||
|
} else defaultPaddingStart,
|
||||||
|
paddingTop,
|
||||||
|
if (isChecked && checkedDrawableEnd != null) {
|
||||||
|
defaultPaddingEnd + compoundDrawablePadding
|
||||||
|
} else defaultPaddingEnd,
|
||||||
|
paddingBottom,
|
||||||
|
)
|
||||||
|
isCheckDrawablesVisible = isChecked
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createShapeDrawable(ta: TypedArray): InsetDrawable {
|
||||||
|
val shapeAppearance = ShapeAppearanceModel.builder(
|
||||||
|
context,
|
||||||
|
ta.getResourceId(R.styleable.ListItemTextView_shapeAppearance, 0),
|
||||||
|
ta.getResourceId(R.styleable.ListItemTextView_shapeAppearanceOverlay, 0),
|
||||||
|
).build()
|
||||||
|
val shapeDrawable = MaterialShapeDrawable(shapeAppearance)
|
||||||
|
shapeDrawable.fillColor = ta.getColorStateList(R.styleable.ListItemTextView_backgroundFillColor)
|
||||||
|
return InsetDrawable(
|
||||||
|
shapeDrawable,
|
||||||
|
ta.getDimensionPixelOffset(R.styleable.ListItemTextView_android_insetLeft, 0),
|
||||||
|
ta.getDimensionPixelOffset(R.styleable.ListItemTextView_android_insetTop, 0),
|
||||||
|
ta.getDimensionPixelOffset(R.styleable.ListItemTextView_android_insetRight, 0),
|
||||||
|
ta.getDimensionPixelOffset(R.styleable.ListItemTextView_android_insetBottom, 0),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getRippleColor(context: Context): ColorStateList {
|
||||||
|
return context.getThemeColorStateList(android.R.attr.colorControlHighlight)
|
||||||
|
?: ColorStateList.valueOf(Color.TRANSPARENT)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.text.Selection
|
||||||
|
import android.text.Spannable
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.MotionEvent
|
||||||
|
import androidx.annotation.AttrRes
|
||||||
|
import com.google.android.material.textview.MaterialTextView
|
||||||
|
|
||||||
|
class SelectableTextView @JvmOverloads constructor(
|
||||||
|
context: Context,
|
||||||
|
attrs: AttributeSet? = null,
|
||||||
|
@AttrRes defStyleAttr: Int = android.R.attr.textViewStyle,
|
||||||
|
) : MaterialTextView(context, attrs, defStyleAttr) {
|
||||||
|
|
||||||
|
override fun dispatchTouchEvent(event: MotionEvent?): Boolean {
|
||||||
|
fixSelectionRange()
|
||||||
|
return super.dispatchTouchEvent(event)
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://stackoverflow.com/questions/22810147/error-when-selecting-text-from-textview-java-lang-indexoutofboundsexception-se
|
||||||
|
private fun fixSelectionRange() {
|
||||||
|
if (selectionStart < 0 || selectionEnd < 0) {
|
||||||
|
val spannableText = text as? Spannable ?: return
|
||||||
|
Selection.setSelection(spannableText, text.length)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.Gravity
|
||||||
|
import android.view.View
|
||||||
|
import android.view.WindowInsets
|
||||||
|
import android.widget.FrameLayout
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import androidx.annotation.AttrRes
|
||||||
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
|
||||||
|
class WindowInsetHolder @JvmOverloads constructor(
|
||||||
|
context: Context,
|
||||||
|
attrs: AttributeSet? = null,
|
||||||
|
@AttrRes defStyleAttr: Int = 0,
|
||||||
|
) : View(context, attrs, defStyleAttr) {
|
||||||
|
|
||||||
|
private var desiredHeight = 0
|
||||||
|
private var desiredWidth = 0
|
||||||
|
|
||||||
|
@SuppressLint("RtlHardcoded")
|
||||||
|
override fun dispatchApplyWindowInsets(insets: WindowInsets): WindowInsets {
|
||||||
|
val barsInsets = WindowInsetsCompat.toWindowInsetsCompat(insets, this)
|
||||||
|
.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
|
val gravity = getLayoutGravity()
|
||||||
|
val newWidth = when (gravity and Gravity.HORIZONTAL_GRAVITY_MASK) {
|
||||||
|
Gravity.LEFT -> barsInsets.left
|
||||||
|
Gravity.RIGHT -> barsInsets.right
|
||||||
|
else -> 0
|
||||||
|
}
|
||||||
|
val newHeight = when (gravity and Gravity.VERTICAL_GRAVITY_MASK) {
|
||||||
|
Gravity.TOP -> barsInsets.top
|
||||||
|
Gravity.BOTTOM -> barsInsets.bottom
|
||||||
|
else -> 0
|
||||||
|
}
|
||||||
|
if (newWidth != desiredWidth || newHeight != desiredHeight) {
|
||||||
|
desiredWidth = newWidth
|
||||||
|
desiredHeight = newHeight
|
||||||
|
requestLayout()
|
||||||
|
}
|
||||||
|
return super.dispatchApplyWindowInsets(insets)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||||
|
val widthMode = MeasureSpec.getMode(widthMeasureSpec)
|
||||||
|
val heightMode = MeasureSpec.getMode(heightMeasureSpec)
|
||||||
|
super.onMeasure(
|
||||||
|
if (desiredWidth == 0 || widthMode == MeasureSpec.EXACTLY) {
|
||||||
|
widthMeasureSpec
|
||||||
|
} else {
|
||||||
|
MeasureSpec.makeMeasureSpec(desiredWidth, widthMode)
|
||||||
|
},
|
||||||
|
if (desiredHeight == 0 || heightMode == MeasureSpec.EXACTLY) {
|
||||||
|
heightMeasureSpec
|
||||||
|
} else {
|
||||||
|
MeasureSpec.makeMeasureSpec(desiredHeight, heightMode)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getLayoutGravity(): Int {
|
||||||
|
return when (val lp = layoutParams) {
|
||||||
|
is FrameLayout.LayoutParams -> lp.gravity
|
||||||
|
is LinearLayout.LayoutParams -> lp.gravity
|
||||||
|
is CoordinatorLayout.LayoutParams -> lp.gravity
|
||||||
|
else -> Gravity.NO_GRAVITY
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package org.koitharu.kotatsu.bookmarks
|
||||||
|
|
||||||
|
import org.koin.dsl.module
|
||||||
|
import org.koitharu.kotatsu.bookmarks.domain.BookmarksRepository
|
||||||
|
|
||||||
|
val bookmarksModule
|
||||||
|
get() = module {
|
||||||
|
|
||||||
|
factory { BookmarksRepository(get()) }
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package org.koitharu.kotatsu.bookmarks.data
|
||||||
|
|
||||||
|
import androidx.room.ColumnInfo
|
||||||
|
import androidx.room.Entity
|
||||||
|
import androidx.room.ForeignKey
|
||||||
|
import org.koitharu.kotatsu.core.db.entity.MangaEntity
|
||||||
|
|
||||||
|
@Entity(
|
||||||
|
tableName = "bookmarks",
|
||||||
|
primaryKeys = ["manga_id", "page_id"],
|
||||||
|
foreignKeys = [
|
||||||
|
ForeignKey(
|
||||||
|
entity = MangaEntity::class,
|
||||||
|
parentColumns = ["manga_id"],
|
||||||
|
childColumns = ["manga_id"],
|
||||||
|
onDelete = ForeignKey.CASCADE
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
data class BookmarkEntity(
|
||||||
|
@ColumnInfo(name = "manga_id", index = true) val mangaId: Long,
|
||||||
|
@ColumnInfo(name = "page_id", index = true) val pageId: Long,
|
||||||
|
@ColumnInfo(name = "chapter_id") val chapterId: Long,
|
||||||
|
@ColumnInfo(name = "page") val page: Int,
|
||||||
|
@ColumnInfo(name = "scroll") val scroll: Int,
|
||||||
|
@ColumnInfo(name = "image") val imageUrl: String,
|
||||||
|
@ColumnInfo(name = "created_at") val createdAt: Long,
|
||||||
|
@ColumnInfo(name = "percent") val percent: Float,
|
||||||
|
)
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package org.koitharu.kotatsu.bookmarks.data
|
||||||
|
|
||||||
|
import androidx.room.Embedded
|
||||||
|
import androidx.room.Junction
|
||||||
|
import androidx.room.Relation
|
||||||
|
import org.koitharu.kotatsu.core.db.entity.MangaEntity
|
||||||
|
import org.koitharu.kotatsu.core.db.entity.MangaTagsEntity
|
||||||
|
import org.koitharu.kotatsu.core.db.entity.TagEntity
|
||||||
|
|
||||||
|
class BookmarkWithManga(
|
||||||
|
@Embedded val bookmark: BookmarkEntity,
|
||||||
|
@Relation(
|
||||||
|
parentColumn = "manga_id",
|
||||||
|
entityColumn = "manga_id"
|
||||||
|
)
|
||||||
|
val manga: MangaEntity,
|
||||||
|
@Relation(
|
||||||
|
parentColumn = "manga_id",
|
||||||
|
entityColumn = "tag_id",
|
||||||
|
associateBy = Junction(MangaTagsEntity::class)
|
||||||
|
)
|
||||||
|
val tags: List<TagEntity>,
|
||||||
|
)
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package org.koitharu.kotatsu.bookmarks.data
|
||||||
|
|
||||||
|
import androidx.room.Dao
|
||||||
|
import androidx.room.Delete
|
||||||
|
import androidx.room.Insert
|
||||||
|
import androidx.room.Query
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
abstract class BookmarksDao {
|
||||||
|
|
||||||
|
@Query("SELECT * FROM bookmarks WHERE manga_id = :mangaId AND chapter_id = :chapterId AND page = :page")
|
||||||
|
abstract fun observe(mangaId: Long, chapterId: Long, page: Int): Flow<BookmarkEntity?>
|
||||||
|
|
||||||
|
@Query("SELECT * FROM bookmarks WHERE manga_id = :mangaId ORDER BY created_at DESC")
|
||||||
|
abstract fun observe(mangaId: Long): Flow<List<BookmarkEntity>>
|
||||||
|
|
||||||
|
@Insert
|
||||||
|
abstract suspend fun insert(entity: BookmarkEntity)
|
||||||
|
|
||||||
|
@Delete
|
||||||
|
abstract suspend fun delete(entity: BookmarkEntity)
|
||||||
|
|
||||||
|
@Query("DELETE FROM bookmarks WHERE manga_id = :mangaId AND page_id = :pageId")
|
||||||
|
abstract suspend fun delete(mangaId: Long, pageId: Long)
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package org.koitharu.kotatsu.bookmarks.data
|
||||||
|
|
||||||
|
import org.koitharu.kotatsu.bookmarks.domain.Bookmark
|
||||||
|
import org.koitharu.kotatsu.core.db.entity.toManga
|
||||||
|
import org.koitharu.kotatsu.core.db.entity.toMangaTags
|
||||||
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
fun BookmarkWithManga.toBookmark() = bookmark.toBookmark(
|
||||||
|
manga.toManga(tags.toMangaTags())
|
||||||
|
)
|
||||||
|
|
||||||
|
fun BookmarkEntity.toBookmark(manga: Manga) = Bookmark(
|
||||||
|
manga = manga,
|
||||||
|
pageId = pageId,
|
||||||
|
chapterId = chapterId,
|
||||||
|
page = page,
|
||||||
|
scroll = scroll,
|
||||||
|
imageUrl = imageUrl,
|
||||||
|
createdAt = Date(createdAt),
|
||||||
|
percent = percent,
|
||||||
|
)
|
||||||
|
|
||||||
|
fun Bookmark.toEntity() = BookmarkEntity(
|
||||||
|
mangaId = manga.id,
|
||||||
|
pageId = pageId,
|
||||||
|
chapterId = chapterId,
|
||||||
|
page = page,
|
||||||
|
scroll = scroll,
|
||||||
|
imageUrl = imageUrl,
|
||||||
|
createdAt = createdAt.time,
|
||||||
|
percent = percent,
|
||||||
|
)
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package org.koitharu.kotatsu.bookmarks.domain
|
||||||
|
|
||||||
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class Bookmark(
|
||||||
|
val manga: Manga,
|
||||||
|
val pageId: Long,
|
||||||
|
val chapterId: Long,
|
||||||
|
val page: Int,
|
||||||
|
val scroll: Int,
|
||||||
|
val imageUrl: String,
|
||||||
|
val createdAt: Date,
|
||||||
|
val percent: Float,
|
||||||
|
) {
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
if (javaClass != other?.javaClass) return false
|
||||||
|
|
||||||
|
other as Bookmark
|
||||||
|
|
||||||
|
if (manga != other.manga) return false
|
||||||
|
if (pageId != other.pageId) return false
|
||||||
|
if (chapterId != other.chapterId) return false
|
||||||
|
if (page != other.page) return false
|
||||||
|
if (scroll != other.scroll) return false
|
||||||
|
if (imageUrl != other.imageUrl) return false
|
||||||
|
if (createdAt != other.createdAt) return false
|
||||||
|
if (percent != other.percent) return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var result = manga.hashCode()
|
||||||
|
result = 31 * result + pageId.hashCode()
|
||||||
|
result = 31 * result + chapterId.hashCode()
|
||||||
|
result = 31 * result + page
|
||||||
|
result = 31 * result + scroll
|
||||||
|
result = 31 * result + imageUrl.hashCode()
|
||||||
|
result = 31 * result + createdAt.hashCode()
|
||||||
|
result = 31 * result + percent.hashCode()
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package org.koitharu.kotatsu.bookmarks.domain
|
||||||
|
|
||||||
|
import androidx.room.withTransaction
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.map
|
||||||
|
import org.koitharu.kotatsu.bookmarks.data.toBookmark
|
||||||
|
import org.koitharu.kotatsu.bookmarks.data.toEntity
|
||||||
|
import org.koitharu.kotatsu.core.db.MangaDatabase
|
||||||
|
import org.koitharu.kotatsu.core.db.entity.toEntities
|
||||||
|
import org.koitharu.kotatsu.core.db.entity.toEntity
|
||||||
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
|
import org.koitharu.kotatsu.utils.ext.mapItems
|
||||||
|
|
||||||
|
class BookmarksRepository(
|
||||||
|
private val db: MangaDatabase,
|
||||||
|
) {
|
||||||
|
|
||||||
|
fun observeBookmark(manga: Manga, chapterId: Long, page: Int): Flow<Bookmark?> {
|
||||||
|
return db.bookmarksDao.observe(manga.id, chapterId, page).map { it?.toBookmark(manga) }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun observeBookmarks(manga: Manga): Flow<List<Bookmark>> {
|
||||||
|
return db.bookmarksDao.observe(manga.id).mapItems { it.toBookmark(manga) }
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun addBookmark(bookmark: Bookmark) {
|
||||||
|
db.withTransaction {
|
||||||
|
val tags = bookmark.manga.tags.toEntities()
|
||||||
|
db.tagsDao.upsert(tags)
|
||||||
|
db.mangaDao.upsert(bookmark.manga.toEntity(), tags)
|
||||||
|
db.bookmarksDao.insert(bookmark.toEntity())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun removeBookmark(mangaId: Long, pageId: Long) {
|
||||||
|
db.bookmarksDao.delete(mangaId, pageId)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package org.koitharu.kotatsu.bookmarks.ui
|
||||||
|
|
||||||
|
import androidx.lifecycle.LifecycleOwner
|
||||||
|
import coil.ImageLoader
|
||||||
|
import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding
|
||||||
|
import org.koitharu.kotatsu.R
|
||||||
|
import org.koitharu.kotatsu.base.ui.list.AdapterDelegateClickListenerAdapter
|
||||||
|
import org.koitharu.kotatsu.base.ui.list.OnListItemClickListener
|
||||||
|
import org.koitharu.kotatsu.bookmarks.domain.Bookmark
|
||||||
|
import org.koitharu.kotatsu.databinding.ItemBookmarkBinding
|
||||||
|
import org.koitharu.kotatsu.utils.ext.disposeImageRequest
|
||||||
|
import org.koitharu.kotatsu.utils.ext.enqueueWith
|
||||||
|
import org.koitharu.kotatsu.utils.ext.newImageRequest
|
||||||
|
import org.koitharu.kotatsu.utils.ext.referer
|
||||||
|
|
||||||
|
fun bookmarkListAD(
|
||||||
|
coil: ImageLoader,
|
||||||
|
lifecycleOwner: LifecycleOwner,
|
||||||
|
clickListener: OnListItemClickListener<Bookmark>,
|
||||||
|
) = adapterDelegateViewBinding<Bookmark, Bookmark, ItemBookmarkBinding>(
|
||||||
|
{ inflater, parent -> ItemBookmarkBinding.inflate(inflater, parent, false) }
|
||||||
|
) {
|
||||||
|
|
||||||
|
val listener = AdapterDelegateClickListenerAdapter(this, clickListener)
|
||||||
|
|
||||||
|
binding.root.setOnClickListener(listener)
|
||||||
|
binding.root.setOnLongClickListener(listener)
|
||||||
|
|
||||||
|
bind {
|
||||||
|
binding.imageViewThumb.newImageRequest(item.imageUrl)?.run {
|
||||||
|
referer(item.manga.publicUrl)
|
||||||
|
placeholder(R.drawable.ic_placeholder)
|
||||||
|
fallback(R.drawable.ic_placeholder)
|
||||||
|
error(R.drawable.ic_placeholder)
|
||||||
|
allowRgb565(true)
|
||||||
|
lifecycle(lifecycleOwner)
|
||||||
|
enqueueWith(coil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onViewRecycled {
|
||||||
|
binding.imageViewThumb.disposeImageRequest()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package org.koitharu.kotatsu.bookmarks.ui
|
||||||
|
|
||||||
|
import androidx.lifecycle.LifecycleOwner
|
||||||
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
|
import coil.ImageLoader
|
||||||
|
import com.hannesdorfmann.adapterdelegates4.AsyncListDifferDelegationAdapter
|
||||||
|
import org.koitharu.kotatsu.base.ui.list.OnListItemClickListener
|
||||||
|
import org.koitharu.kotatsu.bookmarks.domain.Bookmark
|
||||||
|
|
||||||
|
class BookmarksAdapter(
|
||||||
|
coil: ImageLoader,
|
||||||
|
lifecycleOwner: LifecycleOwner,
|
||||||
|
clickListener: OnListItemClickListener<Bookmark>,
|
||||||
|
) : AsyncListDifferDelegationAdapter<Bookmark>(
|
||||||
|
DiffCallback(),
|
||||||
|
bookmarkListAD(coil, lifecycleOwner, clickListener)
|
||||||
|
) {
|
||||||
|
|
||||||
|
private class DiffCallback : DiffUtil.ItemCallback<Bookmark>() {
|
||||||
|
|
||||||
|
override fun areItemsTheSame(oldItem: Bookmark, newItem: Bookmark): Boolean {
|
||||||
|
return oldItem.manga.id == newItem.manga.id && oldItem.chapterId == newItem.chapterId
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun areContentsTheSame(oldItem: Bookmark, newItem: Bookmark): Boolean {
|
||||||
|
return oldItem.imageUrl == newItem.imageUrl
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,8 +11,10 @@ import android.view.MenuItem
|
|||||||
import androidx.core.graphics.Insets
|
import androidx.core.graphics.Insets
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
|
import com.google.android.material.R as materialR
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.base.ui.BaseActivity
|
import org.koitharu.kotatsu.base.ui.BaseActivity
|
||||||
|
import org.koitharu.kotatsu.core.network.UserAgentInterceptor
|
||||||
import org.koitharu.kotatsu.databinding.ActivityBrowserBinding
|
import org.koitharu.kotatsu.databinding.ActivityBrowserBinding
|
||||||
|
|
||||||
@SuppressLint("SetJavaScriptEnabled")
|
@SuppressLint("SetJavaScriptEnabled")
|
||||||
@@ -23,12 +25,17 @@ class BrowserActivity : BaseActivity<ActivityBrowserBinding>(), BrowserCallback
|
|||||||
setContentView(ActivityBrowserBinding.inflate(layoutInflater))
|
setContentView(ActivityBrowserBinding.inflate(layoutInflater))
|
||||||
supportActionBar?.run {
|
supportActionBar?.run {
|
||||||
setDisplayHomeAsUpEnabled(true)
|
setDisplayHomeAsUpEnabled(true)
|
||||||
setHomeAsUpIndicator(R.drawable.ic_cross)
|
setHomeAsUpIndicator(materialR.drawable.abc_ic_clear_material)
|
||||||
}
|
}
|
||||||
with(binding.webView.settings) {
|
with(binding.webView.settings) {
|
||||||
javaScriptEnabled = true
|
javaScriptEnabled = true
|
||||||
|
userAgentString = UserAgentInterceptor.userAgent
|
||||||
}
|
}
|
||||||
binding.webView.webViewClient = BrowserClient(this)
|
binding.webView.webViewClient = BrowserClient(this)
|
||||||
|
binding.webView.webChromeClient = ProgressChromeClient(binding.progressBar)
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
val url = intent?.dataString
|
val url = intent?.dataString
|
||||||
if (url.isNullOrEmpty()) {
|
if (url.isNullOrEmpty()) {
|
||||||
finishAfterTransition()
|
finishAfterTransition()
|
||||||
@@ -41,7 +48,17 @@ class BrowserActivity : BaseActivity<ActivityBrowserBinding>(), BrowserCallback
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
|
super.onSaveInstanceState(outState)
|
||||||
|
binding.webView.saveState(outState)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
||||||
|
super.onRestoreInstanceState(savedInstanceState)
|
||||||
|
binding.webView.restoreState(savedInstanceState)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
menuInflater.inflate(R.menu.opt_browser, menu)
|
menuInflater.inflate(R.menu.opt_browser, menu)
|
||||||
return super.onCreateOptionsMenu(menu)
|
return super.onCreateOptionsMenu(menu)
|
||||||
}
|
}
|
||||||
@@ -82,6 +99,11 @@ class BrowserActivity : BaseActivity<ActivityBrowserBinding>(), BrowserCallback
|
|||||||
binding.webView.onResume()
|
binding.webView.onResume()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
binding.webView.destroy()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onLoadingStateChanged(isLoading: Boolean) {
|
override fun onLoadingStateChanged(isLoading: Boolean) {
|
||||||
binding.progressBar.isVisible = isLoading
|
binding.progressBar.isVisible = isLoading
|
||||||
}
|
}
|
||||||
@@ -92,8 +114,16 @@ class BrowserActivity : BaseActivity<ActivityBrowserBinding>(), BrowserCallback
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onWindowInsetsChanged(insets: Insets) {
|
override fun onWindowInsetsChanged(insets: Insets) {
|
||||||
binding.appbar.updatePadding(top = insets.top)
|
binding.appbar.updatePadding(
|
||||||
binding.webView.updatePadding(bottom = insets.bottom)
|
top = insets.top,
|
||||||
|
left = insets.left,
|
||||||
|
right = insets.right,
|
||||||
|
)
|
||||||
|
binding.root.updatePadding(
|
||||||
|
left = insets.left,
|
||||||
|
right = insets.right,
|
||||||
|
bottom = insets.bottom,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
@@ -1,17 +1,10 @@
|
|||||||
package org.koitharu.kotatsu.browser
|
package org.koitharu.kotatsu.browser
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.webkit.WebResourceResponse
|
|
||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
import okhttp3.OkHttpClient
|
import android.webkit.WebViewClient
|
||||||
import okhttp3.Request
|
|
||||||
import org.koin.core.component.KoinComponent
|
|
||||||
import org.koin.core.component.inject
|
|
||||||
import org.koitharu.kotatsu.core.network.WebViewClientCompat
|
|
||||||
|
|
||||||
class BrowserClient(private val callback: BrowserCallback) : WebViewClientCompat(), KoinComponent {
|
class BrowserClient(private val callback: BrowserCallback) : WebViewClient() {
|
||||||
|
|
||||||
private val okHttp by inject<OkHttpClient>()
|
|
||||||
|
|
||||||
override fun onPageFinished(webView: WebView, url: String) {
|
override fun onPageFinished(webView: WebView, url: String) {
|
||||||
super.onPageFinished(webView, url)
|
super.onPageFinished(webView, url)
|
||||||
@@ -27,19 +20,4 @@ class BrowserClient(private val callback: BrowserCallback) : WebViewClientCompat
|
|||||||
super.onPageCommitVisible(view, url)
|
super.onPageCommitVisible(view, url)
|
||||||
callback.onTitleChanged(view.title.orEmpty(), url)
|
callback.onTitleChanged(view.title.orEmpty(), url)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldInterceptRequestCompat(view: WebView, url: String): WebResourceResponse? {
|
|
||||||
return runCatching {
|
|
||||||
val request = Request.Builder()
|
|
||||||
.url(url)
|
|
||||||
.build()
|
|
||||||
val response = okHttp.newCall(request).execute()
|
|
||||||
val ct = response.body?.contentType()
|
|
||||||
WebResourceResponse(
|
|
||||||
"${ct?.type}/${ct?.subtype}",
|
|
||||||
ct?.charset()?.name() ?: "utf-8",
|
|
||||||
response.body?.byteStream()
|
|
||||||
)
|
|
||||||
}.getOrNull()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package org.koitharu.kotatsu.browser
|
||||||
|
|
||||||
|
import android.webkit.WebChromeClient
|
||||||
|
import android.webkit.WebView
|
||||||
|
import android.widget.ProgressBar
|
||||||
|
import androidx.core.view.isVisible
|
||||||
|
import org.koitharu.kotatsu.utils.ext.setProgressCompat
|
||||||
|
|
||||||
|
private const val PROGRESS_MAX = 100
|
||||||
|
|
||||||
|
class ProgressChromeClient(
|
||||||
|
private val progressIndicator: ProgressBar,
|
||||||
|
) : WebChromeClient() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
progressIndicator.max = PROGRESS_MAX
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onProgressChanged(view: WebView?, newProgress: Int) {
|
||||||
|
super.onProgressChanged(view, newProgress)
|
||||||
|
if (!progressIndicator.isVisible) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (newProgress in 1 until PROGRESS_MAX) {
|
||||||
|
progressIndicator.isIndeterminate = false
|
||||||
|
progressIndicator.setProgressCompat(newProgress.coerceAtMost(PROGRESS_MAX), true)
|
||||||
|
} else {
|
||||||
|
progressIndicator.isIndeterminate = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,19 +2,19 @@ package org.koitharu.kotatsu.browser.cloudflare
|
|||||||
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
|
import android.webkit.WebViewClient
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import org.koitharu.kotatsu.core.network.AndroidCookieJar
|
import org.koitharu.kotatsu.core.network.AndroidCookieJar
|
||||||
import org.koitharu.kotatsu.core.network.WebViewClientCompat
|
|
||||||
|
private const val CF_CLEARANCE = "cf_clearance"
|
||||||
|
|
||||||
class CloudFlareClient(
|
class CloudFlareClient(
|
||||||
private val cookieJar: AndroidCookieJar,
|
private val cookieJar: AndroidCookieJar,
|
||||||
private val callback: CloudFlareCallback,
|
private val callback: CloudFlareCallback,
|
||||||
private val targetUrl: String
|
private val targetUrl: String,
|
||||||
) : WebViewClientCompat() {
|
) : WebViewClient() {
|
||||||
|
|
||||||
init {
|
private val oldClearance = getClearance()
|
||||||
cookieJar.remove(targetUrl, CF_UID, CF_CLEARANCE)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) {
|
override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) {
|
||||||
super.onPageStarted(view, url, favicon)
|
super.onPageStarted(view, url, favicon)
|
||||||
@@ -32,16 +32,14 @@ class CloudFlareClient(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun checkClearance() {
|
private fun checkClearance() {
|
||||||
val cookies = cookieJar.loadForRequest(targetUrl.toHttpUrl())
|
val clearance = getClearance()
|
||||||
if (cookies.any { it.name == CF_CLEARANCE }) {
|
if (clearance != null && clearance != oldClearance) {
|
||||||
callback.onCheckPassed()
|
callback.onCheckPassed()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
private fun getClearance(): String? {
|
||||||
|
return cookieJar.loadForRequest(targetUrl.toHttpUrl())
|
||||||
const val CF_UID = "__cfduid"
|
.find { it.name == CF_CLEARANCE }?.value
|
||||||
const val CF_CLEARANCE = "cf_clearance"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user