mirror of
https://github.com/rebelonion/Dantotsu.git
synced 2026-01-12 23:27:39 +00:00
Compare commits
1277 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3f6d0ecee | ||
|
|
5124d6a2d8 | ||
|
|
e83a0fe7da | ||
|
|
61a8350043 | ||
|
|
baffbc845c | ||
|
|
afd9f6b884 | ||
|
|
7d0894cd92 | ||
|
|
dec2ed7959 | ||
|
|
e4630df3e0 | ||
|
|
6fd3515d2c | ||
|
|
6fa2f11db2 | ||
|
|
a5babea27c | ||
|
|
8a9b8cca7e | ||
|
|
7479f5f43b | ||
|
|
3ac9307329 | ||
|
|
f606bef2a5 | ||
|
|
f9f9767ecc | ||
|
|
31a67c8edb | ||
|
|
7fc69b4edd | ||
|
|
9dd59bb592 | ||
|
|
a8958a76cf | ||
|
|
482e867516 | ||
|
|
495322547e | ||
|
|
19740c82f9 | ||
|
|
3abfa821c7 | ||
|
|
ef70fb5238 | ||
|
|
4e8b6b5ff4 | ||
|
|
a90b7d5203 | ||
|
|
d422a1586f | ||
|
|
986d0fa4a8 | ||
|
|
66ed167bc8 | ||
|
|
1bb5f4d0ab | ||
|
|
f6d05ec375 | ||
|
|
c48028f3cd | ||
|
|
e41ab2ddac | ||
|
|
0779c0ca71 | ||
|
|
c229a5c717 | ||
|
|
7c4689dea6 | ||
|
|
eec8605069 | ||
|
|
0d365d55c5 | ||
|
|
7b8af6ea8a | ||
|
|
38d68a7976 | ||
|
|
30d6f48d23 | ||
|
|
88feb4d811 | ||
|
|
116de6324e | ||
|
|
b3e767d33d | ||
|
|
43dee6ee49 | ||
|
|
12c13be2aa | ||
|
|
6f1bb10dec | ||
|
|
f0a8d9bfd4 | ||
|
|
01a64c25fd | ||
|
|
b04a176870 | ||
|
|
eac4604b3d | ||
|
|
1686854632 | ||
|
|
8ad8637fce | ||
|
|
6d32900568 | ||
|
|
ce332d7ae5 | ||
|
|
0d22c92e3e | ||
|
|
0057363f4d | ||
|
|
d1400ff422 | ||
|
|
f13225e032 | ||
|
|
404d265a2d | ||
|
|
c2d69509fb | ||
|
|
d01e1c89e0 | ||
|
|
ff3372754a | ||
|
|
a4bd367f98 | ||
|
|
9fa326c571 | ||
|
|
3d4f5aaf4a | ||
|
|
90c6c08b48 | ||
|
|
d1e2ca8b5e | ||
|
|
56e557738c | ||
|
|
489dcc0b52 | ||
|
|
a993935433 | ||
|
|
5c1c639f53 | ||
|
|
02ec4a3605 | ||
|
|
441094ca17 | ||
|
|
b2d7af85c0 | ||
|
|
95b558118a | ||
|
|
b703337a16 | ||
|
|
3071f88681 | ||
|
|
c242770435 | ||
|
|
0fa2cf98d8 | ||
|
|
ffd9fecf26 | ||
|
|
7ec889a915 | ||
|
|
949ab7e87b | ||
|
|
cddad8edf1 | ||
|
|
4e76e8e6e7 | ||
|
|
a9331ffa32 | ||
|
|
545abf1f9a | ||
|
|
f191502a97 | ||
|
|
652ef219dd | ||
|
|
e8ca3f2222 | ||
|
|
bd1f3388f7 | ||
|
|
c37fefde73 | ||
|
|
74e88838f0 | ||
|
|
2cf73be675 | ||
|
|
b594258d28 | ||
|
|
f9ce897197 | ||
|
|
68b6fd030f | ||
|
|
f0536b3cad | ||
|
|
6a077fa48d | ||
|
|
ebb61d94dd | ||
|
|
a7cef9323e | ||
|
|
a8f7ff2a19 | ||
|
|
0214e6611b | ||
|
|
04b9b9e7ff | ||
|
|
7366aa1bf2 | ||
|
|
09c5d9ce91 | ||
|
|
79742f415b | ||
|
|
b09f26ed34 | ||
|
|
6eb654bf51 | ||
|
|
b109d50d89 | ||
|
|
f62bdf9360 | ||
|
|
46d16be835 | ||
|
|
c22fd6b66d | ||
|
|
ae95b61298 | ||
|
|
2180086573 | ||
|
|
665b558b1f | ||
|
|
37ba9341cc | ||
|
|
feb765448b | ||
|
|
a8ccf8d246 | ||
|
|
2f06ac6071 | ||
|
|
ed24e64b78 | ||
|
|
43fc9c17f5 | ||
|
|
83e7e4591d | ||
|
|
563a96cf98 | ||
|
|
124f4eb261 | ||
|
|
0052eba828 | ||
|
|
eda213a765 | ||
|
|
899af3ee1a | ||
|
|
124c8f5ed7 | ||
|
|
1670383619 | ||
|
|
903423b842 | ||
|
|
3ae59b8d22 | ||
|
|
d488d11573 | ||
|
|
6f685a4388 | ||
|
|
b644ba1866 | ||
|
|
74cab22eca | ||
|
|
ce7ae28e1e | ||
|
|
fdc1b31c44 | ||
|
|
1b4c8704ea | ||
|
|
5473ac8238 | ||
|
|
e52ea2628a | ||
|
|
0f8218482a | ||
|
|
8822ef6805 | ||
|
|
6ce41b8fbb | ||
|
|
11655bd38d | ||
|
|
ea75197120 | ||
|
|
6878d12b5c | ||
|
|
5800dcf3e7 | ||
|
|
b30047804a | ||
|
|
0b32636c1b | ||
|
|
43e560a893 | ||
|
|
b256f02f14 | ||
|
|
46c17dced1 | ||
|
|
72fe910c59 | ||
|
|
fb65cb601e | ||
|
|
5a78d68f67 | ||
|
|
f205463a51 | ||
|
|
2de8ffd367 | ||
|
|
f3f0daf7e7 | ||
|
|
2b4c9bf7a9 | ||
|
|
21e25fe7a7 | ||
|
|
7b36cd0d29 | ||
|
|
ce488ea536 | ||
|
|
7717974b9e | ||
|
|
37949c7e8e | ||
|
|
e7a60e07d8 | ||
|
|
7bce053202 | ||
|
|
a5304477c7 | ||
|
|
945018653e | ||
|
|
5e38b00c1f | ||
|
|
dec990c24c | ||
|
|
e7cf0f7b03 | ||
|
|
560eef491f | ||
|
|
94ffc2595c | ||
|
|
3d187a01ec | ||
|
|
773b7f5dd0 | ||
|
|
d06c980a57 | ||
|
|
e5ec6a6526 | ||
|
|
4ccf6fa1c8 | ||
|
|
143eed8cb2 | ||
|
|
0008da200a | ||
|
|
48ccb2c581 | ||
|
|
039e3d63fe | ||
|
|
fd42533b40 | ||
|
|
66805bdf05 | ||
|
|
b3ed8acd5b | ||
|
|
fe1a7af7ac | ||
|
|
10df1986e8 | ||
|
|
c2a10c233d | ||
|
|
1c736640b2 | ||
|
|
212bce09c8 | ||
|
|
ea045c185d | ||
|
|
41ed5a66da | ||
|
|
2c3eb82e4b | ||
|
|
1dd3bddeb9 | ||
|
|
d12ddc9c0d | ||
|
|
91f728150c | ||
|
|
ab360b3a75 | ||
|
|
114be6fe5a | ||
|
|
f53d27bd53 | ||
|
|
bfa847130e | ||
|
|
949bcc418a | ||
|
|
df2867c7db | ||
|
|
6c1176a182 | ||
|
|
f1d16ba16a | ||
|
|
fd8dd26435 | ||
|
|
ac531cd3e8 | ||
|
|
2c521b4ac6 | ||
|
|
a3b1d3db57 | ||
|
|
b0b51c4347 | ||
|
|
001c384d11 | ||
|
|
d355cc561e | ||
|
|
6e3a3bb6f8 | ||
|
|
fa659c7da0 | ||
|
|
a0fabd3ca6 | ||
|
|
831b99ae40 | ||
|
|
13e2e37225 | ||
|
|
988e4def64 | ||
|
|
e1a865c973 | ||
|
|
be97229618 | ||
|
|
b3d3913d56 | ||
|
|
e7b6ba80c3 | ||
|
|
4ac53da4b8 | ||
|
|
7e504df55a | ||
|
|
9d13920f63 | ||
|
|
7fdd8d5d6e | ||
|
|
fda68a7ca2 | ||
|
|
40c2989b34 | ||
|
|
636a56fb7f | ||
|
|
abcf9fcbef | ||
|
|
b187cf06be | ||
|
|
14f29d09df | ||
|
|
390c709f5d | ||
|
|
7aa0951cdf | ||
|
|
aae80f6493 | ||
|
|
f86086cc7a | ||
|
|
425ca158a3 | ||
|
|
7bdc7c1719 | ||
|
|
126fe75c46 | ||
|
|
dc19694d68 | ||
|
|
95c0b574b0 | ||
|
|
a1b9f90500 | ||
|
|
d5be21882e | ||
|
|
e9551be62d | ||
|
|
3a88656e21 | ||
|
|
97ff591b62 | ||
|
|
a3e1cc45b3 | ||
|
|
deda67a070 | ||
|
|
e32bfa0cfa | ||
|
|
f03af6856a | ||
|
|
8a0224e6b0 | ||
|
|
71870ff235 | ||
|
|
31c509f88c | ||
|
|
4362dd94c1 | ||
|
|
9b132e9cb6 | ||
|
|
1431027cf3 | ||
|
|
2d2f058d27 | ||
|
|
85835b5c2e | ||
|
|
08c3806d0d | ||
|
|
74fcd581b0 | ||
|
|
0ea1ec1c35 | ||
|
|
42330032c8 | ||
|
|
fdb7f45a3d | ||
|
|
390ce9a022 | ||
|
|
95a9d289c9 | ||
|
|
69fb86d015 | ||
|
|
4fc96b77e3 | ||
|
|
040b0845de | ||
|
|
eca38070cb | ||
|
|
e9a60eafb6 | ||
|
|
0967721897 | ||
|
|
ed0e06d1af | ||
|
|
a7589a0296 | ||
|
|
e30124d342 | ||
|
|
140737bb40 | ||
|
|
8b582a9d32 | ||
|
|
0a0da65f7c | ||
|
|
ea48809d07 | ||
|
|
a573fbdc89 | ||
|
|
c947dbdb70 | ||
|
|
90b9b7bef3 | ||
|
|
133354a22d | ||
|
|
73ef5f4bbc | ||
|
|
140dd2e0c3 | ||
|
|
90e611dc4f | ||
|
|
7ecdbfd42f | ||
|
|
f4c95b6cc0 | ||
|
|
da456d3067 | ||
|
|
856deb7755 | ||
|
|
55ad8dccad | ||
|
|
e81773f2b5 | ||
|
|
c5a03c4455 | ||
|
|
d2127f92a1 | ||
|
|
870cb751a4 | ||
|
|
4ffe9d7505 | ||
|
|
513b937e59 | ||
|
|
6113a10556 | ||
|
|
233f4bfb48 | ||
|
|
3fd01d582a | ||
|
|
00758af458 | ||
|
|
4477e3a0e1 | ||
|
|
e475cc5c01 | ||
|
|
3622d91886 | ||
|
|
3c46c21a25 | ||
|
|
44178b2de2 | ||
|
|
13f5d0978d | ||
|
|
70a50ece43 | ||
|
|
24147e746a | ||
|
|
386e02a564 | ||
|
|
865b96a219 | ||
|
|
dd38bb156b | ||
|
|
72c07b7d7a | ||
|
|
3f19cadffc | ||
|
|
670d16bd8e | ||
|
|
3d1040b280 | ||
|
|
cd3bb20afd | ||
|
|
91d1d2cf1d | ||
|
|
f8a6fad513 | ||
|
|
9d3d394c7d | ||
|
|
820a09b28f | ||
|
|
108285021e | ||
|
|
1d005585c8 | ||
|
|
714591dd2e | ||
|
|
6e399b32e1 | ||
|
|
4b413b78fe | ||
|
|
126bc6134e | ||
|
|
bf33f5d9c8 | ||
|
|
a8ff4fdc26 | ||
|
|
7ca44480a9 | ||
|
|
ea29449413 | ||
|
|
9ec448e503 | ||
|
|
70be4e92fb | ||
|
|
c0e3243ee6 | ||
|
|
b961701189 | ||
|
|
3619355cb4 | ||
|
|
674a512630 | ||
|
|
5e5277404e | ||
|
|
c242d9dd99 | ||
|
|
a5a94e5003 | ||
|
|
9b6dc1318d | ||
|
|
87535a9239 | ||
|
|
6be589618c | ||
|
|
a51e025c03 | ||
|
|
29e115ce41 | ||
|
|
f96d2ffaa5 | ||
|
|
47d05e737d | ||
|
|
3666758e6e | ||
|
|
e49f0dbf32 | ||
|
|
abe3f883ae | ||
|
|
e5cb7c7fdf | ||
|
|
79337b5e7f | ||
|
|
ae5907e6b3 | ||
|
|
04fb31eff9 | ||
|
|
9f7e01a1fb | ||
|
|
9ace8e5235 | ||
|
|
771cdcc163 | ||
|
|
58d5b5bc41 | ||
|
|
04538c52f2 | ||
|
|
dd994dcfab | ||
|
|
594b71dc16 | ||
|
|
cf7ccaebd1 | ||
|
|
8bde831794 | ||
|
|
2f30bdb6a8 | ||
|
|
4d28ae2e3e | ||
|
|
5fcbfeb3db | ||
|
|
f6c7b09d9b | ||
|
|
72c69e7c79 | ||
|
|
13a65c2bfa | ||
|
|
d2f118a86c | ||
|
|
ce11c71e95 | ||
|
|
e4574d6c03 | ||
|
|
d8c311fbd7 | ||
|
|
d6e6c6f8fb | ||
|
|
63c3058f5b | ||
|
|
0d5815d3c9 | ||
|
|
dec4996760 | ||
|
|
e0df092a70 | ||
|
|
da56aecd5e | ||
|
|
7688ffa39f | ||
|
|
d08e89bb63 | ||
|
|
5979479619 | ||
|
|
e1b968bfe0 | ||
|
|
36c476bc36 | ||
|
|
6bfadfa962 | ||
|
|
720b40afa7 | ||
|
|
b5b7dac247 | ||
|
|
75e90541c9 | ||
|
|
47b1940ace | ||
|
|
012b1cd79d | ||
|
|
ff3131d988 | ||
|
|
ba1725224a | ||
|
|
55bc2add85 | ||
|
|
9e96fd1e20 | ||
|
|
79d20b0b63 | ||
|
|
b2a44cfe09 | ||
|
|
146805af49 | ||
|
|
aabbe9198a | ||
|
|
a815bac15d | ||
|
|
86427a4c3c | ||
|
|
0d8a82568a | ||
|
|
95b2939532 | ||
|
|
76e11e5a3e | ||
|
|
2d5d02fd67 | ||
|
|
f30e6b7809 | ||
|
|
04f2034dd1 | ||
|
|
99b3bbaaad | ||
|
|
c0bccc027f | ||
|
|
51beac2d03 | ||
|
|
63a5150cea | ||
|
|
e34a20bce6 | ||
|
|
ca482ea9d4 | ||
|
|
e31d2ada4f | ||
|
|
c29147a681 | ||
|
|
92be9bf626 | ||
|
|
a02b8b7b0a | ||
|
|
1c1d14fff1 | ||
|
|
eff0a34c54 | ||
|
|
2dc3035a7c | ||
|
|
78f6ec27b3 | ||
|
|
6b868fa824 | ||
|
|
7951c2cf37 | ||
|
|
ea678ef55e | ||
|
|
fbbbf41595 | ||
|
|
f83d1d8d84 | ||
|
|
7bcc01b94e | ||
|
|
ff72f9dbdf | ||
|
|
b1210570d1 | ||
|
|
ef97b5679e | ||
|
|
6dfe0269bf | ||
|
|
77c57846ed | ||
|
|
19b5b11b07 | ||
|
|
27d4ce3c5b | ||
|
|
859aa01ec2 | ||
|
|
6d102f7be3 | ||
|
|
5ae1ead2c9 | ||
|
|
b1982013dc | ||
|
|
954fdde1c4 | ||
|
|
f177e2cf7c | ||
|
|
845ebb4868 | ||
|
|
b43171bb31 | ||
|
|
be07fad8f1 | ||
|
|
3375496ef2 | ||
|
|
df23b2f62f | ||
|
|
95cddbd409 | ||
|
|
d46f1b25eb | ||
|
|
378abe73c9 | ||
|
|
b5eda797b5 | ||
|
|
f704e322af | ||
|
|
dc21d28b83 | ||
|
|
eb17862177 | ||
|
|
fc023f307a | ||
|
|
ad1905c8fe | ||
|
|
85d54e8f5e | ||
|
|
ba09f7533c | ||
|
|
fa6e3a34b5 | ||
|
|
85ef4b3c12 | ||
|
|
89e18b0e2f | ||
|
|
1b50ffcf11 | ||
|
|
b3f83816c5 | ||
|
|
75b78886ae | ||
|
|
26d97da066 | ||
|
|
ab7bc15573 | ||
|
|
d43d643bbd | ||
|
|
3ca5efc177 | ||
|
|
04c858e6fd | ||
|
|
25046e4c11 | ||
|
|
5134776e2f | ||
|
|
cc29ebd75b | ||
|
|
2233f1ce44 | ||
|
|
a189802061 | ||
|
|
dca6ffdbbe | ||
|
|
859946a751 | ||
|
|
08bf1a2336 | ||
|
|
27743e3427 | ||
|
|
52b0cc4129 | ||
|
|
22abc2e21d | ||
|
|
fc8425b12a | ||
|
|
60fc1fa74b | ||
|
|
190e3ce7bb | ||
|
|
012024ab77 | ||
|
|
529bdd74c8 | ||
|
|
6e349b84c0 | ||
|
|
ab9b92035e | ||
|
|
37ec165319 | ||
|
|
958aa634b1 | ||
|
|
125a95285d | ||
|
|
bbaae2e776 | ||
|
|
f9090f59b7 | ||
|
|
1d740d33a0 | ||
|
|
633ec19c90 | ||
|
|
9b2015f4cf | ||
|
|
e65e7a79a5 | ||
|
|
0996639cac | ||
|
|
e5f58f20c7 | ||
|
|
d1e03b8237 | ||
|
|
917ffe644f | ||
|
|
02efc01a10 | ||
|
|
3016792f95 | ||
|
|
e1b50c86f3 | ||
|
|
59784de727 | ||
|
|
42f23e4345 | ||
|
|
adb304f138 | ||
|
|
3bbf9efe63 | ||
|
|
b454a2e3d9 | ||
|
|
23e6323f92 | ||
|
|
b0dbd7a348 | ||
|
|
0f9bf3c5b1 | ||
|
|
4035aee1f9 | ||
|
|
f707f8cc33 | ||
|
|
fa7126d80d | ||
|
|
7d5f69888a | ||
|
|
51841cf05f | ||
|
|
6d2c01ff2b | ||
|
|
0bd4755814 | ||
|
|
927ba5ac86 | ||
|
|
808d4e6bf5 | ||
|
|
a39db5ea93 | ||
|
|
ca2409ef91 | ||
|
|
7b1f1a1357 | ||
|
|
9471683501 | ||
|
|
deeefb8e35 | ||
|
|
c777888fdb | ||
|
|
ce50627989 | ||
|
|
9f84845ada | ||
|
|
6a8e422a30 | ||
|
|
39d6f0fbd6 | ||
|
|
c240664fda | ||
|
|
a0f6320eee | ||
|
|
3434aa9744 | ||
|
|
3e84cfe09a | ||
|
|
22dccaa24b | ||
|
|
ffe921a223 | ||
|
|
1fd91b9ec6 | ||
|
|
cf10229574 | ||
|
|
5c2ae57d77 | ||
|
|
353452dd21 | ||
|
|
92fa0c117d | ||
|
|
9f4cd0ba0d | ||
|
|
385198e69a | ||
|
|
89fe3b82a3 | ||
|
|
af1bc944d8 | ||
|
|
a0b22e8d56 | ||
|
|
c47d1afa1a | ||
|
|
12a5b602e9 | ||
|
|
25b85569fe | ||
|
|
b373a52218 | ||
|
|
b0e46cd904 | ||
|
|
89a54b4509 | ||
|
|
56aefef693 | ||
|
|
a8ad018c44 | ||
|
|
726f461ff6 | ||
|
|
9c0861a8e4 | ||
|
|
ca0162fb9c | ||
|
|
cfb8c3c733 | ||
|
|
fea448f850 | ||
|
|
c033bb0445 | ||
|
|
bb110be9ab | ||
|
|
fd39c4f391 | ||
|
|
9a3f9c6de2 | ||
|
|
cf9799da7c | ||
|
|
c054e2f2ac | ||
|
|
8177dfdcef | ||
|
|
813b64980d | ||
|
|
fda809bc8a | ||
|
|
5d1b220105 | ||
|
|
de21365c90 | ||
|
|
a24d1515b3 | ||
|
|
a3d6f841c6 | ||
|
|
b770bca6ba | ||
|
|
eaefbc13f9 | ||
|
|
7fcc23c5bf | ||
|
|
29364bf30a | ||
|
|
a9b4916dd8 | ||
|
|
d4ab0ad57d | ||
|
|
e3f8096749 | ||
|
|
94aae33d10 | ||
|
|
96e29a8c59 | ||
|
|
34a9a55d4f | ||
|
|
cf93f6d657 | ||
|
|
91bcacc978 | ||
|
|
e79a824a04 | ||
|
|
e00bbb2d8e | ||
|
|
12c77604f1 | ||
|
|
9a1ec8567c | ||
|
|
5dbc01dba3 | ||
|
|
c5abfa15e0 | ||
|
|
b69e466853 | ||
|
|
9e371778b7 | ||
|
|
ff036165df | ||
|
|
4ed74b664b | ||
|
|
ddd59643c5 | ||
|
|
6122eb3669 | ||
|
|
1b5149f143 | ||
|
|
b654824eb7 | ||
|
|
4d2a08c258 | ||
|
|
19697f4f39 | ||
|
|
41eea667e5 | ||
|
|
f0040b8392 | ||
|
|
291f61551a | ||
|
|
6e8bd08828 | ||
|
|
e915dd619d | ||
|
|
8fb6357fb5 | ||
|
|
07662a91f4 | ||
|
|
37c618cb28 | ||
|
|
5536f3b994 | ||
|
|
bdbbe62570 | ||
|
|
4838e69aea | ||
|
|
408737d510 | ||
|
|
a0f05928e0 | ||
|
|
a35887d4ac | ||
|
|
dbce7c5b29 | ||
|
|
1028ac66cb | ||
|
|
eb5e2623a0 | ||
|
|
867a4f36b3 | ||
|
|
913d74b285 | ||
|
|
eb2eae7d6c | ||
|
|
8e5e548e16 | ||
|
|
af1a481bdb | ||
|
|
92089067f1 | ||
|
|
d04ced94ea | ||
|
|
14115ada4c | ||
|
|
7f36eba709 | ||
|
|
7504bb9081 | ||
|
|
64df08f91c | ||
|
|
98f4d4f30b | ||
|
|
a9b03c45c6 | ||
|
|
3af7926d20 | ||
|
|
e0cd43c63c | ||
|
|
2742f58af5 | ||
|
|
49175a962a | ||
|
|
46d8248ffd | ||
|
|
4ba1408f0f | ||
|
|
95fa5dcd9b | ||
|
|
a2ca16355a | ||
|
|
7ac679f927 | ||
|
|
e2eae6250b | ||
|
|
2855093f5f | ||
|
|
e50a65571f | ||
|
|
acef7c3d5e | ||
|
|
18778f3c5a | ||
|
|
03dae8c1b0 | ||
|
|
c862c072b5 | ||
|
|
251f1e89cf | ||
|
|
3632055081 | ||
|
|
bd64454c15 | ||
|
|
31afbd547e | ||
|
|
8da0092561 | ||
|
|
36c64951c7 | ||
|
|
120e63ea8a | ||
|
|
ad82faba3f | ||
|
|
4c4bbe3214 | ||
|
|
ecbc7efebc | ||
|
|
89b6f28b9f | ||
|
|
8a1097cd35 | ||
|
|
47d74de7ce | ||
|
|
f3c89b3ac5 | ||
|
|
a2ecc5e30e | ||
|
|
db50975174 | ||
|
|
ab14c4815f | ||
|
|
7ad586c994 | ||
|
|
db979de829 | ||
|
|
5218d5cd28 | ||
|
|
9e4684e61c | ||
|
|
9b408e7520 | ||
|
|
10bd7d0918 | ||
|
|
5279b0cd65 | ||
|
|
d181dcf837 | ||
|
|
49dc9d55b5 | ||
|
|
852e9d0d29 | ||
|
|
7a1ed4f83e | ||
|
|
2673b7d9bc | ||
|
|
1587aff433 | ||
|
|
26b3f50fe0 | ||
|
|
286297aa38 | ||
|
|
99a805826d | ||
|
|
be1711b51e | ||
|
|
51beea1dc8 | ||
|
|
297e9dd756 | ||
|
|
03b8e7dab6 | ||
|
|
dbe837be28 | ||
|
|
945d5886ea | ||
|
|
93fa29829f | ||
|
|
a9f8d223e9 | ||
|
|
d2876d04f5 | ||
|
|
fcd5c621de | ||
|
|
5fb0204376 | ||
|
|
790ab1a343 | ||
|
|
86ed721796 | ||
|
|
2837cad762 | ||
|
|
500de4e45e | ||
|
|
533148069f | ||
|
|
42b0a3b62b | ||
|
|
c720aed4fc | ||
|
|
00dad2ad48 | ||
|
|
ce62a9c645 | ||
|
|
1e4e2fd701 | ||
|
|
103be31a43 | ||
|
|
63fa3c829e | ||
|
|
ab5c623e53 | ||
|
|
5e307bb796 | ||
|
|
a5567ef909 | ||
|
|
da22347267 | ||
|
|
a401ab89f3 | ||
|
|
6e6429db82 | ||
|
|
05fc97a933 | ||
|
|
b9eb9d82f1 | ||
|
|
976acd4af2 | ||
|
|
c5cbe408c1 | ||
|
|
1316d5a698 | ||
|
|
89aaef8355 | ||
|
|
94e3dff909 | ||
|
|
6240c61a11 | ||
|
|
f226614980 | ||
|
|
0ab283b254 | ||
|
|
449485f06a | ||
|
|
60752e83ed | ||
|
|
dfd8b597cd | ||
|
|
e256fb1560 | ||
|
|
2f7c6e734e | ||
|
|
efe5f546a2 | ||
|
|
a8bd9ef97b | ||
|
|
e93ca5d86e | ||
|
|
7f943d34ac | ||
|
|
8a922bd083 | ||
|
|
d5c87c46aa | ||
|
|
f128dee3e4 | ||
|
|
9de129a35b | ||
|
|
6d6b0b975a | ||
|
|
bff8983b23 | ||
|
|
55e156579b | ||
|
|
a251dd4ffb | ||
|
|
526098f2bf | ||
|
|
6ccdc10208 | ||
|
|
ce355c108e | ||
|
|
612936476d | ||
|
|
7ba117ec25 | ||
|
|
8ea6bf85b8 | ||
|
|
70c87b4067 | ||
|
|
4628282715 | ||
|
|
6c14a2eccf | ||
|
|
8944941d80 | ||
|
|
78da98bd1d | ||
|
|
57833be7df | ||
|
|
506a0576df | ||
|
|
458f4d1ff9 | ||
|
|
21b9d51a35 | ||
|
|
82922b9792 | ||
|
|
160f783c6d | ||
|
|
ba7c665a9d | ||
|
|
b2f01a24b2 | ||
|
|
84ae520f93 | ||
|
|
4f61f4cf2c | ||
|
|
eba774618e | ||
|
|
a74b9e985d | ||
|
|
0c2e2db1dc | ||
|
|
98b227876b | ||
|
|
1fe50d2cca | ||
|
|
420c0348f9 | ||
|
|
9be81aa4a9 | ||
|
|
64c8f4225c | ||
|
|
a7c9604c43 | ||
|
|
68cc81e56c | ||
|
|
c9a64b1638 | ||
|
|
ee7cff0fea | ||
|
|
4c35f9a0cf | ||
|
|
9d9c4f026d | ||
|
|
b4c7ea5f26 | ||
|
|
093bee94c6 | ||
|
|
fb99429dd7 | ||
|
|
a73c4cd678 | ||
|
|
1694a1cb24 | ||
|
|
aaf9bdd00c | ||
|
|
129adc5825 | ||
|
|
07e7456ed8 | ||
|
|
7168e08587 | ||
|
|
efb3b27317 | ||
|
|
2c3247c194 | ||
|
|
d37ebf8cdd | ||
|
|
a73b049fd4 | ||
|
|
b3de2f805f | ||
|
|
0bec4f4d61 | ||
|
|
4be4a0968d | ||
|
|
97b957a0ab | ||
|
|
a22083dfcd | ||
|
|
9dbc3db1b8 | ||
|
|
7af71ba217 | ||
|
|
80f3523f2e | ||
|
|
0afad1d9ae | ||
|
|
915c6c1dfe | ||
|
|
e319aeb342 | ||
|
|
ac20426689 | ||
|
|
d778cd4350 | ||
|
|
83c07467a9 | ||
|
|
0225b28fea | ||
|
|
1e2a740dae | ||
|
|
22e687b9d8 | ||
|
|
f088b90964 | ||
|
|
ab199a3502 | ||
|
|
2493935349 | ||
|
|
c9699ba1fc | ||
|
|
051012be2d | ||
|
|
a38f1a2b2b | ||
|
|
0b66275995 | ||
|
|
7879fe4355 | ||
|
|
4aa88244ed | ||
|
|
bfe4d69b8a | ||
|
|
69fead70d1 | ||
|
|
92c663cd38 | ||
|
|
b829ed26f3 | ||
|
|
3d4834507d | ||
|
|
0758241e06 | ||
|
|
b093b5f979 | ||
|
|
d86481a0f7 | ||
|
|
de1788950f | ||
|
|
1e7b546b75 | ||
|
|
d53781e75a | ||
|
|
aa1830f12c | ||
|
|
17a87aa8c8 | ||
|
|
2662017fb7 | ||
|
|
f2b9cc3b3e | ||
|
|
2912ee5f73 | ||
|
|
9bb4c702f3 | ||
|
|
c4630f9243 | ||
|
|
57581d6f54 | ||
|
|
b5cfb5d567 | ||
|
|
04306a981f | ||
|
|
95409f7eda | ||
|
|
8741d820ad | ||
|
|
6020636a66 | ||
|
|
d15ffe7708 | ||
|
|
f77269e468 | ||
|
|
a2e44da99d | ||
|
|
8d7b86a667 | ||
|
|
0c6fad91ca | ||
|
|
c0f3fed142 | ||
|
|
21f5d503cd | ||
|
|
18b4f858d9 | ||
|
|
a101cac503 | ||
|
|
3f4c1953f8 | ||
|
|
a599b5b632 | ||
|
|
9fad3597bb | ||
|
|
f4b9889d67 | ||
|
|
d27b4f6905 | ||
|
|
855c7e623a | ||
|
|
a7e7bd0230 | ||
|
|
1d46897086 | ||
|
|
7af0721a75 | ||
|
|
884d738de9 | ||
|
|
ef71ca8a76 | ||
|
|
d4df12505b | ||
|
|
670d9b3913 | ||
|
|
19df5355ba | ||
|
|
8ca1c3be1f | ||
|
|
ed19aac553 | ||
|
|
7a67fbb980 | ||
|
|
d80b250650 | ||
|
|
300f2c2fb0 | ||
|
|
c2f108bf44 | ||
|
|
15abcd77d0 | ||
|
|
462f82e3fb | ||
|
|
eade3ce341 | ||
|
|
b4487159ed | ||
|
|
d12022266e | ||
|
|
13074a0f72 | ||
|
|
dc2c0c1027 | ||
|
|
97ed84127e | ||
|
|
d3f097f675 | ||
|
|
402e0576c8 | ||
|
|
aa8d41eecf | ||
|
|
54b53dbe56 | ||
|
|
2214c47c0c | ||
|
|
ed6275b0e8 | ||
|
|
97d062ffc2 | ||
|
|
c57c33c088 | ||
|
|
025d31102e | ||
|
|
cd96b6ab06 | ||
|
|
9358f86d43 | ||
|
|
7e51e067cd | ||
|
|
10ae66d1d0 | ||
|
|
cbdd1a2538 | ||
|
|
829292399b | ||
|
|
f7c7b8050f | ||
|
|
a3be59bd02 | ||
|
|
49e90a27b8 | ||
|
|
b559a13bab | ||
|
|
4d682f014d | ||
|
|
1a346e6b5a | ||
|
|
37a53748a2 | ||
|
|
9c2c932e75 | ||
|
|
c853d5bdf8 | ||
|
|
1f98e349dc | ||
|
|
883c14bf0d | ||
|
|
178abf0f83 | ||
|
|
c242fedfee | ||
|
|
922ccdfb27 | ||
|
|
965adddf8d | ||
|
|
8020b32541 | ||
|
|
33d798727c | ||
|
|
a0949c4e36 | ||
|
|
f00a0367cf | ||
|
|
eb5b83564f | ||
|
|
6b9dce10cf | ||
|
|
5d789bf96c | ||
|
|
17431734fb | ||
|
|
63c80fa526 | ||
|
|
2b79d437fc | ||
|
|
1e6041f99e | ||
|
|
fad4032a78 | ||
|
|
36ad006021 | ||
|
|
f6db690454 | ||
|
|
26575cfa0d | ||
|
|
73be639397 | ||
|
|
0ebd067bc2 | ||
|
|
49b3c33fbc | ||
|
|
4a5eab13c9 | ||
|
|
00ce6ce755 | ||
|
|
0aa95889aa | ||
|
|
3fdec074c6 | ||
|
|
29c6863b00 | ||
|
|
97eacb58a6 | ||
|
|
67bb28d027 | ||
|
|
513ed31b08 | ||
|
|
da5d95c7e5 | ||
|
|
7b9450807b | ||
|
|
8bc3631964 | ||
|
|
ab038983e5 | ||
|
|
79cff1ec9d | ||
|
|
4893cd0b03 | ||
|
|
b8fbeed785 | ||
|
|
8a9668bc79 | ||
|
|
d02d542207 | ||
|
|
4c797c5eb1 | ||
|
|
3fa2690277 | ||
|
|
67d482bad6 | ||
|
|
60981ba224 | ||
|
|
cb8ebfccb6 | ||
|
|
e5f0b71cf0 | ||
|
|
4218d81c49 | ||
|
|
9fa422ebf3 | ||
|
|
3ec488675f | ||
|
|
78b7d07500 | ||
|
|
a316de3957 | ||
|
|
c3f5a820e4 | ||
|
|
daa5ec7bed | ||
|
|
de91f1f3fa | ||
|
|
9c67a7e357 | ||
|
|
f70ce39fb7 | ||
|
|
20ffe2273c | ||
|
|
f333051073 | ||
|
|
a58f8fa76b | ||
|
|
625c7d738b | ||
|
|
563e4f2cbe | ||
|
|
627bed2407 | ||
|
|
8313d639d7 | ||
|
|
c603de70e3 | ||
|
|
4508cada0f | ||
|
|
ab8dc2ee8b | ||
|
|
acf2dd9a8a | ||
|
|
f562e7d7cf | ||
|
|
25372d5251 | ||
|
|
efb346d0a8 | ||
|
|
6d05fb4413 | ||
|
|
d67a51791e | ||
|
|
332857b2c9 | ||
|
|
a0018b5fb6 | ||
|
|
734c5d0571 | ||
|
|
8e93f66ba8 | ||
|
|
5d8cf8a605 | ||
|
|
87c2d82462 | ||
|
|
45a341397b | ||
|
|
b018d0f090 | ||
|
|
3c992f89f4 | ||
|
|
8067e0d0ac | ||
|
|
4cee512572 | ||
|
|
87a9df4c12 | ||
|
|
ea96291bfc | ||
|
|
b1eedce229 | ||
|
|
0d32342765 | ||
|
|
d81391f593 | ||
|
|
3bd9dc031a | ||
|
|
4f07421df7 | ||
|
|
8eadd20968 | ||
|
|
c6d04d99b3 | ||
|
|
91b1f4775b | ||
|
|
5bd8f1a3c7 | ||
|
|
39fc508cfe | ||
|
|
664b5a4bdd | ||
|
|
ff02280239 | ||
|
|
26b6564825 | ||
|
|
5459908201 | ||
|
|
3693179c78 | ||
|
|
9416c88511 | ||
|
|
f18399d529 | ||
|
|
6b2ffdaf4f | ||
|
|
d16dd7ed67 | ||
|
|
8142c966c0 | ||
|
|
b7cc35207c | ||
|
|
e398238fe6 | ||
|
|
51a5609395 | ||
|
|
4e6842862e | ||
|
|
ddde08c61b | ||
|
|
05b3f57a76 | ||
|
|
0464cc08c3 | ||
|
|
4be3ded9c8 | ||
|
|
6a42832855 | ||
|
|
84fc5e6e2c | ||
|
|
8375cb5c03 | ||
|
|
2fdee06248 | ||
|
|
f861b3621f | ||
|
|
0cfcfcb9ac | ||
|
|
68ccff2259 | ||
|
|
aa972c916a | ||
|
|
b0673d4f78 | ||
|
|
5170288050 | ||
|
|
61150066bd | ||
|
|
bd6197031a | ||
|
|
98cb11e841 | ||
|
|
52dadf34cf | ||
|
|
f038dcb255 | ||
|
|
a851c0f715 | ||
|
|
a0b6956ca4 | ||
|
|
2f41515b33 | ||
|
|
063d314c36 | ||
|
|
e7631e021e | ||
|
|
e65fa8d565 | ||
|
|
14d08b9491 | ||
|
|
cc5b512441 | ||
|
|
84e300482a | ||
|
|
46b84ffc76 | ||
|
|
ad1979505e | ||
|
|
310f068e79 | ||
|
|
431617e6b5 | ||
|
|
33bb60baad | ||
|
|
e847ec21c3 | ||
|
|
e0a1f6534f | ||
|
|
1ba67280a6 | ||
|
|
419d33a3ac | ||
|
|
f12a4de04b | ||
|
|
3077f39c9d | ||
|
|
97cd3dd43b | ||
|
|
038b8f7ff7 | ||
|
|
3d3c9feaec | ||
|
|
7e5def3a37 | ||
|
|
e3e3965795 | ||
|
|
158ea60047 | ||
|
|
2e13d79615 | ||
|
|
f5297f4927 | ||
|
|
326b848e57 | ||
|
|
01f9e86475 | ||
|
|
af992bd19c | ||
|
|
51b3aac0c0 | ||
|
|
8df2107ef9 | ||
|
|
4286232d17 | ||
|
|
ef30869b62 | ||
|
|
ae8b952b4c | ||
|
|
486be4827e | ||
|
|
98a3a1107b | ||
|
|
7228817c68 | ||
|
|
7dbf951d5a | ||
|
|
3ff492d94c | ||
|
|
7fae64bee9 | ||
|
|
d16fbd9a43 | ||
|
|
41830dba4d | ||
|
|
5561c003cf | ||
|
|
62b1a3b900 | ||
|
|
c9649751d2 | ||
|
|
bbc986784b | ||
|
|
7684a15e94 | ||
|
|
42c3b42c05 | ||
|
|
a8711241a7 | ||
|
|
549d7f9db3 | ||
|
|
e83a580486 | ||
|
|
bf908c5e37 | ||
|
|
ebabff4667 | ||
|
|
c352222e3a | ||
|
|
d177087ae6 | ||
|
|
38c5ae447a | ||
|
|
eb75d299d2 | ||
|
|
5339593e17 | ||
|
|
0bacfb8494 | ||
|
|
7ebb539bba | ||
|
|
d7c6d63d71 | ||
|
|
11d04ecb58 | ||
|
|
74328cf4cf | ||
|
|
cfd59a6ba0 | ||
|
|
1779276154 | ||
|
|
dfc10d5520 | ||
|
|
f090f6c630 | ||
|
|
a13f98f6da | ||
|
|
cc98e2f307 | ||
|
|
5c4e9d7696 | ||
|
|
b180625636 | ||
|
|
31482674c0 | ||
|
|
c7bc6241dc | ||
|
|
86b74f022b | ||
|
|
7336c73561 | ||
|
|
528f70c6de | ||
|
|
2c0d698ac9 | ||
|
|
d404202371 | ||
|
|
ebeffa2135 | ||
|
|
51015dc2f4 | ||
|
|
b840cdb695 | ||
|
|
e6cb10df19 | ||
|
|
1cd1b8af23 | ||
|
|
2b38869c41 | ||
|
|
6c310713d6 | ||
|
|
0a2ecdd190 | ||
|
|
3db4363100 | ||
|
|
713960e247 | ||
|
|
b6be7075b0 | ||
|
|
82bc215da5 | ||
|
|
e8f3d5525d | ||
|
|
d1cf8c4e10 | ||
|
|
f19e112d0a | ||
|
|
9eb29361dc | ||
|
|
133959a34e | ||
|
|
bd48ff05eb | ||
|
|
1d2ce6ccaa | ||
|
|
3a3857e9eb | ||
|
|
38c4440d45 | ||
|
|
85f03ece85 | ||
|
|
e2f02dc93c | ||
|
|
88c4d1f8a7 | ||
|
|
2c24a56446 | ||
|
|
d11b370415 | ||
|
|
f81c566f12 | ||
|
|
9a4ed7ad54 | ||
|
|
07793b11d6 | ||
|
|
aad3c3fed3 | ||
|
|
f79bd9194a | ||
|
|
5ad68f2bd2 | ||
|
|
f463275a73 | ||
|
|
ac6b22f659 | ||
|
|
ac9d3a2363 | ||
|
|
38a27c45a1 | ||
|
|
33bfbd65fb | ||
|
|
ac98417355 | ||
|
|
876304065d | ||
|
|
9fc80d6397 | ||
|
|
8797af0cbc | ||
|
|
97a4cba680 | ||
|
|
acc5069c83 | ||
|
|
fab978dba4 | ||
|
|
ad1734d640 | ||
|
|
d687911c85 | ||
|
|
1d4257b1b3 | ||
|
|
55521ab9fc | ||
|
|
17e53a54af | ||
|
|
dc1edc9a42 | ||
|
|
b8782b0507 | ||
|
|
0d422a57e7 | ||
|
|
1bbc98d350 | ||
|
|
7ae6831628 | ||
|
|
65e89398d9 | ||
|
|
2b77b7578c | ||
|
|
e77ab2800a | ||
|
|
c1a0eeb361 | ||
|
|
393ab1e513 | ||
|
|
e26a6c647f | ||
|
|
ea83b722a6 | ||
|
|
34a3e9e5a3 | ||
|
|
7f92ac686d | ||
|
|
b6c79dae40 | ||
|
|
8c957007ab | ||
|
|
c728eae2ba | ||
|
|
3ded6ba87a | ||
|
|
111fb16266 | ||
|
|
121be4bc6f | ||
|
|
afa960c808 | ||
|
|
1df528c0dc | ||
|
|
f792296f78 | ||
|
|
d512929387 | ||
|
|
c7bc1ffe9e | ||
|
|
32f918450a | ||
|
|
f01377f0b1 | ||
|
|
c2a07278fc | ||
|
|
0a17bed243 | ||
|
|
c5ed8acfa3 | ||
|
|
e5f2bb6566 | ||
|
|
b4093b0c47 | ||
|
|
d0fd62abf2 | ||
|
|
4d0c3e5849 | ||
|
|
d131562f34 | ||
|
|
cf2d9ad654 | ||
|
|
af326c8258 | ||
|
|
ba351df331 | ||
|
|
d4c2df37ae | ||
|
|
79d1c44e63 | ||
|
|
38faedb4b5 | ||
|
|
39b0f28127 | ||
|
|
a1913ed968 | ||
|
|
f7917df907 | ||
|
|
84c58fbe6c | ||
|
|
75895d851f | ||
|
|
6d05a42168 | ||
|
|
594fa4daa9 | ||
|
|
8d9254140d | ||
|
|
533aa9f56e | ||
|
|
c310bea0e9 | ||
|
|
813f7a0992 | ||
|
|
4c0f56d3e3 | ||
|
|
1f44d32f35 | ||
|
|
d937f447ef | ||
|
|
187262a266 | ||
|
|
f40ebc9d09 | ||
|
|
3998d88297 | ||
|
|
4db301ca7a | ||
|
|
3dfcc9fc31 | ||
|
|
df63586c02 | ||
|
|
d7372d4dbb | ||
|
|
f4266d0da3 | ||
|
|
736b06bdbe | ||
|
|
5543d29317 | ||
|
|
2fc351f57a | ||
|
|
eee1242964 | ||
|
|
a58e9a523a | ||
|
|
cd3aad1c33 | ||
|
|
5a482d8307 | ||
|
|
91d869005c | ||
|
|
05e73269d3 | ||
|
|
3dac48ced8 | ||
|
|
8c5726ab8a | ||
|
|
076516be23 | ||
|
|
1059a3c17e | ||
|
|
c75df942f2 | ||
|
|
cfe7be5cdb | ||
|
|
390fc18c4c | ||
|
|
4c82c56828 | ||
|
|
da5c480ba7 | ||
|
|
20acd71b1a | ||
|
|
231c9c5b98 | ||
|
|
4cfdcdb23c | ||
|
|
acb0225699 | ||
|
|
ebffaaa742 | ||
|
|
1760064555 | ||
|
|
44a6db3fc2 | ||
|
|
aab25d157e | ||
|
|
8a4be86ddc | ||
|
|
31baf729be | ||
|
|
b98e3dc780 | ||
|
|
878d58679e | ||
|
|
f500ba6cf0 | ||
|
|
d124736556 | ||
|
|
1a825e2509 | ||
|
|
6e14c2221d | ||
|
|
5b6e351a56 | ||
|
|
c310708401 | ||
|
|
f0093b903a | ||
|
|
d33568f0ad | ||
|
|
26f9f40042 | ||
|
|
7545870f38 | ||
|
|
3368a1bc8d | ||
|
|
9c0ef7a788 | ||
|
|
960c2b4113 | ||
|
|
1eb85d4419 | ||
|
|
20bea76e6c | ||
|
|
866bd3b3a9 | ||
|
|
3567b8dced | ||
|
|
d109914537 | ||
|
|
da4d55a9a8 | ||
|
|
63526c6ed3 | ||
|
|
dc165fa6bc | ||
|
|
dc959796e6 | ||
|
|
0b9f2bb019 | ||
|
|
6ddbd4760c | ||
|
|
d1270c7c83 | ||
|
|
79618e1963 | ||
|
|
da81646297 | ||
|
|
41b90e3a39 | ||
|
|
57a584a820 | ||
|
|
dbe573131e | ||
|
|
3007e7d86e | ||
|
|
7aa8b2db52 | ||
|
|
2876677b57 | ||
|
|
5749268b84 |
13
.github/FUNDING.yml
vendored
Normal file
13
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [rebelonion]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||
custom: ['https://www.buymeacoffee.com/rebelonion']
|
||||
9
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
9
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: 🧑💻 Dantotsu Help on Discord
|
||||
url: https://discord.com/invite/4HPZ5nAWwM
|
||||
about: Get support, ask questions, and join the community discussions.
|
||||
|
||||
- name: 📱 Dantotsu Help on Telegram
|
||||
url: https://t.me/dantotsuapp
|
||||
about: Connect with the community, ask questions, and get help directly on Telegram.
|
||||
35
.github/ISSUE_TEMPLATE/question.yml
vendored
Normal file
35
.github/ISSUE_TEMPLATE/question.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
name: ❓ Question
|
||||
description: Submit a question or query related to Dantotsu
|
||||
labels: [question]
|
||||
body:
|
||||
- type: textarea
|
||||
id: question-details
|
||||
attributes:
|
||||
label: Question Details
|
||||
description: Provide a detailed explanation of your question or query.
|
||||
placeholder: |
|
||||
Example:
|
||||
"How do I customize the settings in Dartotsu to optimize performance?"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: related-features
|
||||
attributes:
|
||||
label: Related Features (if applicable)
|
||||
description: Mention any specific feature or section of Dantotsu related to your question.
|
||||
placeholder: |
|
||||
Example: "Settings > Performance"
|
||||
|
||||
- type: checkboxes
|
||||
id: submission-checklist
|
||||
attributes:
|
||||
label: Submission Checklist
|
||||
description: Review the following items before submitting your question.
|
||||
options:
|
||||
- label: I have searched existing issues to see if this question has already been answered.
|
||||
required: true
|
||||
- label: I have provided a clear and concise question title.
|
||||
required: true
|
||||
- label: I have provided all relevant details to understand my question fully.
|
||||
required: true
|
||||
101
.github/ISSUE_TEMPLATE/report_issue.yml
vendored
Normal file
101
.github/ISSUE_TEMPLATE/report_issue.yml
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
name: 🐛 Issue Report
|
||||
description: Report a bug or problem in Dantotsu
|
||||
labels: [bug]
|
||||
body:
|
||||
- type: textarea
|
||||
id: steps-to-reproduce
|
||||
attributes:
|
||||
label: Steps to Reproduce
|
||||
description: Outline the steps needed to trigger the issue.
|
||||
placeholder: |
|
||||
Example:
|
||||
1. Navigate to the home screen.
|
||||
2. Click on "Start."
|
||||
3. Observe the error message.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: expected-outcome
|
||||
attributes:
|
||||
label: Expected Outcome
|
||||
description: Describe what you expected to happen.
|
||||
placeholder: |
|
||||
Example:
|
||||
"The application should have successfully loaded the dashboard..."
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: actual-outcome
|
||||
attributes:
|
||||
label: Actual Outcome
|
||||
description: Detail what actually occurred when following the steps.
|
||||
placeholder: |
|
||||
Example:
|
||||
"The app crashed and displayed an error message instead..."
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: error-logs
|
||||
attributes:
|
||||
label: Error Logs (if applicable)
|
||||
description: |
|
||||
If the issue involves crashes, please attach relevant logs. Access them via **Settings → About → Log to file → Share**.
|
||||
placeholder: |
|
||||
Paste the logs here or upload as an attachment.
|
||||
|
||||
- type: input
|
||||
id: dartotsu-version
|
||||
attributes:
|
||||
label: Dartotsu Version
|
||||
description: Specify the version of Dartotsu in which the issue occurred.
|
||||
placeholder: |
|
||||
Example: "1.2.3"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: os-version
|
||||
attributes:
|
||||
label: Operating System Version
|
||||
description: Mention the OS version you are using.
|
||||
placeholder: |
|
||||
Example: "Android 12"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: device-info
|
||||
attributes:
|
||||
label: Device Information
|
||||
description: Provide your device name and model.
|
||||
placeholder: |
|
||||
Example: "Samsung Galaxy S21"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: additional-information
|
||||
attributes:
|
||||
label: Additional Information
|
||||
placeholder: |
|
||||
Include any other relevant details or attachments that may help diagnose the issue.
|
||||
|
||||
- type: checkboxes
|
||||
id: submission-checklist
|
||||
attributes:
|
||||
label: Submission Checklist
|
||||
description: Ensure you've reviewed these items before submitting your report.
|
||||
options:
|
||||
- label: I have searched existing issues to confirm this is not a duplicate.
|
||||
required: true
|
||||
- label: I have provided a clear and descriptive title.
|
||||
required: true
|
||||
- label: I am using the **[latest](https://github.com/rebelonion/Dantotsu/latest)** version of Dantotsu. If not, I have provided a reason for not updating.
|
||||
required: true
|
||||
- label: I have updated all relevant extensions or dependencies.
|
||||
required: true
|
||||
- label: I have filled out all the requested information accurately.
|
||||
required: true
|
||||
54
.github/ISSUE_TEMPLATE/request_feature.yml
vendored
Normal file
54
.github/ISSUE_TEMPLATE/request_feature.yml
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
name: 🚀 Feature Request
|
||||
description: Propose a new feature to enhance Dantotsu
|
||||
labels: [enhancement]
|
||||
body:
|
||||
- type: textarea
|
||||
id: feature-summary
|
||||
attributes:
|
||||
label: Feature Summary
|
||||
description: Provide a concise summary of the feature you'd like to see.
|
||||
placeholder: |
|
||||
Example:
|
||||
"Add support for dark mode..."
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: detailed-description
|
||||
attributes:
|
||||
label: Detailed Description
|
||||
description: Elaborate on how this feature should function and its potential impact.
|
||||
placeholder: |
|
||||
Example:
|
||||
"The dark mode should automatically activate based on system settings..."
|
||||
value: |
|
||||
### Current Behavior
|
||||
- Describe the current functionality or lack thereof.
|
||||
|
||||
### Proposed Solution
|
||||
- Detail how the feature should work and any potential benefits.
|
||||
|
||||
### Considerations
|
||||
- Mention any potential challenges or alternatives.
|
||||
|
||||
- type: textarea
|
||||
id: additional-context
|
||||
attributes:
|
||||
label: Additional Context
|
||||
description: Provide any other information, relevant screenshots, or references.
|
||||
placeholder: "Include links to relevant resources, external tools, or related issues."
|
||||
|
||||
- type: checkboxes
|
||||
id: checklist
|
||||
attributes:
|
||||
label: Submission Checklist
|
||||
description: Ensure you've completed these before submitting.
|
||||
options:
|
||||
- label: I have searched the existing issues and confirm that this feature has not been requested before.
|
||||
required: true
|
||||
- label: I have provided a clear and descriptive title.
|
||||
required: true
|
||||
- label: I am using the **[latest](https://github.com/rebelonion/Dantotsu/releases/latest)** version of Dantotsu. If not, I have provided a reason for using an older version.
|
||||
required: true
|
||||
- label: I understand that not all feature requests will be accepted, and if declined, I won't resubmit the same request.
|
||||
required: true
|
||||
366
.github/workflows/beta.yml
vendored
Normal file
366
.github/workflows/beta.yml
vendored
Normal file
@@ -0,0 +1,366 @@
|
||||
name: Build APK and Notify Discord
|
||||
|
||||
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- main
|
||||
- l10n_dev_crowdin
|
||||
- custom-download-location
|
||||
paths-ignore:
|
||||
- '**/README.md'
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
env:
|
||||
CI: true
|
||||
SKIP_BUILD: false
|
||||
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Download last SHA artifact
|
||||
uses: dawidd6/action-download-artifact@v6
|
||||
with:
|
||||
workflow: beta.yml
|
||||
name: last-sha
|
||||
path: .
|
||||
continue-on-error: true
|
||||
|
||||
- name: Get Commits Since Last Run
|
||||
run: |
|
||||
if [ -f last_sha.txt ]; then
|
||||
LAST_SHA=$(cat last_sha.txt)
|
||||
else
|
||||
# Fallback to first commit if no previous SHA available
|
||||
LAST_SHA=$(git rev-list --max-parents=0 HEAD)
|
||||
fi
|
||||
echo "Commits since $LAST_SHA:"
|
||||
# Accumulate commit logs in a shell variable
|
||||
COMMIT_LOGS=$(git log $LAST_SHA..HEAD --pretty=format:"● %s ~%an [֍](https://github.com/${{ github.repository }}/commit/%H)" --max-count=10)
|
||||
# Replace commit messages with pull request links
|
||||
COMMIT_LOGS=$(echo "$COMMIT_LOGS" | sed -E 's/#([0-9]+)/[#\1](https:\/\/github.com\/rebelonion\/Dantotsu\/pull\/\1)/g')
|
||||
# URL-encode the newline characters for GitHub Actions
|
||||
COMMIT_LOGS="${COMMIT_LOGS//'%'/'%25'}"
|
||||
COMMIT_LOGS="${COMMIT_LOGS//$'\n'/'%0A'}"
|
||||
COMMIT_LOGS="${COMMIT_LOGS//$'\r'/'%0D'}"
|
||||
# Append the encoded commit logs to the COMMIT_LOG environment variable
|
||||
echo "COMMIT_LOG=${COMMIT_LOGS}" >> $GITHUB_ENV
|
||||
# Debugging: Print the variable to check its content
|
||||
echo "$COMMIT_LOGS"
|
||||
echo "$COMMIT_LOGS" > commit_log.txt
|
||||
# Extract branch name from github.ref
|
||||
BRANCH=${{ github.ref }}
|
||||
BRANCH=${BRANCH#refs/heads/}
|
||||
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
|
||||
shell: /usr/bin/bash -e {0}
|
||||
env:
|
||||
CI: true
|
||||
continue-on-error: true
|
||||
|
||||
- name: Save Current SHA for Next Run
|
||||
run: echo ${{ github.sha }} > last_sha.txt
|
||||
|
||||
- name: Set variables
|
||||
run: |
|
||||
VER=$(grep -E -o "versionName \".*\"" app/build.gradle | sed -e 's/versionName //g' | tr -d '"')
|
||||
SHA=${{ github.sha }}
|
||||
VERSION="$VER+${SHA:0:7}"
|
||||
echo "Version $VERSION"
|
||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||
|
||||
- name: List files in the directory
|
||||
run: ls -l
|
||||
|
||||
- name: Setup JDK 17
|
||||
if: ${{ env.SKIP_BUILD != 'true' }}
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
cache: gradle
|
||||
|
||||
- name: Decode Keystore File
|
||||
if: ${{ github.repository == 'rebelonion/Dantotsu' }}
|
||||
run: echo "${{ secrets.KEYSTORE_FILE }}" | base64 -d > $GITHUB_WORKSPACE/key.keystore
|
||||
|
||||
- name: Make gradlew executable
|
||||
if: ${{ env.SKIP_BUILD != 'true' }}
|
||||
run: chmod +x ./gradlew
|
||||
|
||||
- name: Build with Gradle
|
||||
if: ${{ env.SKIP_BUILD != 'true' }}
|
||||
run: |
|
||||
if [ "${{ github.repository }}" == "rebelonion/Dantotsu" ]; then
|
||||
./gradlew assembleGoogleAlpha \
|
||||
-Pandroid.injected.signing.store.file=$GITHUB_WORKSPACE/key.keystore \
|
||||
-Pandroid.injected.signing.store.password=${{ secrets.KEYSTORE_PASSWORD }} \
|
||||
-Pandroid.injected.signing.key.alias=${{ secrets.KEY_ALIAS }} \
|
||||
-Pandroid.injected.signing.key.password=${{ secrets.KEY_PASSWORD }};
|
||||
else
|
||||
./gradlew assembleGoogleAlpha;
|
||||
fi
|
||||
|
||||
- name: Upload a Build Artifact
|
||||
if: ${{ env.SKIP_BUILD != 'true' }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Dantotsu
|
||||
retention-days: 5
|
||||
compression-level: 9
|
||||
path: "app/build/outputs/apk/google/alpha/app-google-alpha.apk"
|
||||
|
||||
- name: Upload APK to Discord and Telegram
|
||||
if: ${{ github.repository == 'rebelonion/Dantotsu' }}
|
||||
shell: bash
|
||||
run: |
|
||||
# Prepare Discord embed
|
||||
fetch_user_details() {
|
||||
local login=$1
|
||||
user_details=$(curl -s "https://api.github.com/users/$login")
|
||||
name=$(echo "$user_details" | jq -r '.name // .login')
|
||||
login=$(echo "$user_details" | jq -r '.login')
|
||||
avatar_url=$(echo "$user_details" | jq -r '.avatar_url')
|
||||
echo "$name|$login|$avatar_url"
|
||||
}
|
||||
|
||||
# Additional information for the goats
|
||||
declare -A additional_info
|
||||
additional_info["ibo"]="\n Discord: <@951737931159187457>\n AniList: [takarealist112](<https://anilist.co/user/5790266/>)"
|
||||
additional_info["aayush262"]="\n Discord: <@918825160654598224>\n AniList: [aayush262](<https://anilist.co/user/5144645/>)"
|
||||
additional_info["rebel onion"]="\n Discord: <@714249925248024617>\n AniList: [rebelonion](<https://anilist.co/user/6077251/>)\n PornHub: [rebelonion](<https://www.cornhub.com/model/rebelonion>)"
|
||||
additional_info["Ankit Grai"]="\n Discord: <@1125628254330560623>\n AniList: [bheshnarayan](<https://anilist.co/user/6417303/>)"
|
||||
|
||||
# Decimal color codes for contributors
|
||||
declare -A contributor_colors
|
||||
default_color="#bf2cc8"
|
||||
contributor_colors["ibo"]="#ff9b46"
|
||||
contributor_colors["aayush262"]="#5d689d"
|
||||
contributor_colors["Sadwhy"]="#ff7e95"
|
||||
contributor_colors["grayankit"]="#c51aa1"
|
||||
contributor_colors["rebelonion"]="#d4e5ed"
|
||||
|
||||
hex_to_decimal() { printf '%d' "0x${1#"#"}"; }
|
||||
|
||||
# Count recent commits and create an associative array Okay
|
||||
declare -A recent_commit_counts
|
||||
echo "Debug: Processing COMMIT_LOG:"
|
||||
echo "$COMMIT_LOG"
|
||||
while read -r count name; do
|
||||
recent_commit_counts["$name"]=$count
|
||||
echo "Debug: Commit count for $name: $count"
|
||||
done < <(echo "$COMMIT_LOG" | sed 's/%0A/\n/g' | grep -oP '(?<=~)[^[]*' | sort | uniq -c | sort -rn)
|
||||
|
||||
echo "Debug: Fetching contributors from GitHub"
|
||||
# Fetch contributors from GitHub
|
||||
contributors=$(curl -s "https://api.github.com/repos/${{ github.repository }}/contributors")
|
||||
echo "Debug: Contributors response:"
|
||||
echo "$contributors"
|
||||
|
||||
# Create a sorted list of contributors based on recent commit counts
|
||||
sorted_contributors=$(for login in $(echo "$contributors" | jq -r '.[].login'); do
|
||||
user_info=$(fetch_user_details "$login")
|
||||
name=$(echo "$user_info" | cut -d'|' -f1)
|
||||
count=${recent_commit_counts["$name"]:-0}
|
||||
echo "$count|$login"
|
||||
done | sort -rn | cut -d'|' -f2)
|
||||
|
||||
# Initialize needed variables
|
||||
developers=""
|
||||
committers_count=0
|
||||
max_commits=0
|
||||
top_contributor=""
|
||||
top_contributor_count=0
|
||||
top_contributor_avatar=""
|
||||
embed_color=$(hex_to_decimal "$default_color")
|
||||
|
||||
# Process contributors in the new order
|
||||
while read -r login; do
|
||||
user_info=$(fetch_user_details "$login")
|
||||
name=$(echo "$user_info" | cut -d'|' -f1)
|
||||
login=$(echo "$user_info" | cut -d'|' -f2)
|
||||
avatar_url=$(echo "$user_info" | cut -d'|' -f3)
|
||||
|
||||
# Only process if they have recent commits
|
||||
commit_count=${recent_commit_counts["$name"]:-0}
|
||||
if [ $commit_count -gt 0 ]; then
|
||||
# Update top contributor information
|
||||
if [ $commit_count -gt $max_commits ]; then
|
||||
max_commits=$commit_count
|
||||
top_contributors=("$login")
|
||||
top_contributor_count=1
|
||||
top_contributor_avatar="$avatar_url"
|
||||
embed_color=$(hex_to_decimal "${contributor_colors[$name]:-$default_color}")
|
||||
elif [ $commit_count -eq $max_commits ]; then
|
||||
top_contributors+=("$login")
|
||||
top_contributor_count=$((top_contributor_count + 1))
|
||||
embed_color=$(hex_to_decimal "$default_color")
|
||||
fi
|
||||
echo "Debug top contributors:"
|
||||
echo "$top_contributors"
|
||||
|
||||
# Get commit count for this contributor on the dev branch
|
||||
branch_commit_count=$(git log --author="$login" --author="$name" --oneline | awk '!seen[$0]++' | wc -l)
|
||||
|
||||
# Debug: Print recent_commit_counts
|
||||
echo "Debug: recent_commit_counts contents:"
|
||||
for key in "${!recent_commit_counts[@]}"; do
|
||||
echo "$key: ${recent_commit_counts[$key]}"
|
||||
done
|
||||
|
||||
extra_info="${additional_info[$name]}"
|
||||
if [ -n "$extra_info" ]; then
|
||||
extra_info=$(echo "$extra_info" | sed 's/\\n/\n- /g')
|
||||
fi
|
||||
|
||||
# Construct the developer entry
|
||||
developer_entry="◗ **${name}** ${extra_info}
|
||||
- Github: [${login}](https://github.com/${login})
|
||||
- Commits: ${branch_commit_count}"
|
||||
|
||||
# Add the entry to developers, with a newline if it's not the first entry
|
||||
if [ -n "$developers" ]; then
|
||||
developers="${developers}
|
||||
${developer_entry}"
|
||||
else
|
||||
developers="${developer_entry}"
|
||||
fi
|
||||
committers_count=$((committers_count + 1))
|
||||
fi
|
||||
done <<< "$sorted_contributors"
|
||||
|
||||
# Set the thumbnail URL and color based on top contributor(s)
|
||||
if [ $top_contributor_count -eq 1 ]; then
|
||||
thumbnail_url="$top_contributor_avatar"
|
||||
else
|
||||
thumbnail_url="https://i.imgur.com/5o3Y9Jb.gif"
|
||||
embed_color=$(hex_to_decimal "$default_color")
|
||||
fi
|
||||
|
||||
# Truncate field values
|
||||
max_length=1000
|
||||
commit_messages=$(echo "$COMMIT_LOG" | sed 's/%0A/\n/g; s/^/\n/')
|
||||
if [ ${#developers} -gt $max_length ]; then
|
||||
developers="${developers:0:$max_length}... (truncated)"
|
||||
fi
|
||||
if [ ${#commit_messages} -gt $max_length ]; then
|
||||
commit_messages="${commit_messages:0:$max_length}... (truncated)"
|
||||
fi
|
||||
|
||||
# Construct Discord payload
|
||||
discord_data=$(jq -nc \
|
||||
--arg field_value "$commit_messages" \
|
||||
--arg author_value "$developers" \
|
||||
--arg footer_text "Version $VERSION" \
|
||||
--arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)" \
|
||||
--arg thumbnail_url "$thumbnail_url" \
|
||||
--arg embed_color "$embed_color" \
|
||||
'{
|
||||
"content": "<@&1225347048321191996>",
|
||||
"embeds": [
|
||||
{
|
||||
"title": "New Alpha-Build dropped",
|
||||
"color": $embed_color,
|
||||
"fields": [
|
||||
{
|
||||
"name": "Commits:",
|
||||
"value": $field_value,
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
"name": "Developers:",
|
||||
"value": $author_value,
|
||||
"inline": false
|
||||
}
|
||||
],
|
||||
"footer": {
|
||||
"text": $footer_text
|
||||
},
|
||||
"timestamp": $timestamp,
|
||||
"thumbnail": {
|
||||
"url": $thumbnail_url
|
||||
}
|
||||
}
|
||||
],
|
||||
"attachments": []
|
||||
}')
|
||||
echo "Debug: Final Discord payload:"
|
||||
echo "$discord_data"
|
||||
|
||||
# Send Discord message
|
||||
curl -H "Content-Type: application/json" \
|
||||
-d "$discord_data" \
|
||||
${{ secrets.DISCORD_WEBHOOK }}
|
||||
echo "You have only send an embed to discord due to SKIP_BUILD being set to true"
|
||||
|
||||
# Upload APK to Discord
|
||||
if [ "$SKIP_BUILD" != "true" ]; then
|
||||
curl -F "payload_json=${contentbody}" \
|
||||
-F "dantotsu_debug=@app/build/outputs/apk/google/alpha/app-google-alpha.apk" \
|
||||
${{ secrets.DISCORD_WEBHOOK }}
|
||||
else
|
||||
echo "Skipping APK upload to Discord due to SKIP_BUILD being set to true"
|
||||
fi
|
||||
|
||||
# Format commit messages for Telegram
|
||||
telegram_commit_messages=$(echo "$COMMIT_LOG" | sed 's/%0A/\n/g' | while read -r line; do
|
||||
message=$(echo "$line" | sed -E 's/● (.*) ~(.*) \[֍\]\((.*)\)/● \1 ~\2 <a href="\3">֍<\/a>/')
|
||||
message=$(echo "$message" | sed -E 's/\[#([0-9]+)\]\((https:\/\/github\.com\/[^)]+)\)/<a href="\2">#\1<\/a>/g')
|
||||
echo "$message"
|
||||
done)
|
||||
telegram_commit_messages="<blockquote>${telegram_commit_messages}</blockquote>"
|
||||
|
||||
# Configuring dev info
|
||||
echo "$developers" > dev_info.txt
|
||||
echo "$developers"
|
||||
# making the file executable
|
||||
chmod +x workflowscripts/tel_parser.sed
|
||||
./workflowscripts/tel_parser.sed dev_info.txt >> output.txt
|
||||
dev_info_tel=$(< output.txt)
|
||||
|
||||
telegram_dev_info="<blockquote>${dev_info_tel}</blockquote>"
|
||||
echo "$telegram_dev_info"
|
||||
|
||||
# Upload APK to Telegram
|
||||
if [ "$SKIP_BUILD" != "true" ]; then
|
||||
APK_PATH="app/build/outputs/apk/google/alpha/app-google-alpha.apk"
|
||||
response=$(curl -sS -f -X POST \
|
||||
"https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument" \
|
||||
-F "chat_id=-1002117798698" \
|
||||
-F "message_thread_id=7044" \
|
||||
-F "document=@$APK_PATH" \
|
||||
-F "caption=New Alpha-Build dropped 🔥
|
||||
|
||||
Commits:
|
||||
${telegram_commit_messages}
|
||||
Dev:
|
||||
${telegram_dev_info}
|
||||
version: ${VERSION}" \
|
||||
-F "parse_mode=HTML")
|
||||
else
|
||||
echo "skipping because skip build set to true"
|
||||
fi
|
||||
|
||||
env:
|
||||
COMMIT_LOG: ${{ env.COMMIT_LOG }}
|
||||
VERSION: ${{ env.VERSION }}
|
||||
|
||||
- name: Upload Current SHA as Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: last-sha
|
||||
path: last_sha.txt
|
||||
|
||||
- name: Upload Commit log as Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: commit-log
|
||||
path: commit_log.txt
|
||||
84
.github/workflows/bug_greetings.yml
vendored
Normal file
84
.github/workflows/bug_greetings.yml
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
name: Bug Report Greeting
|
||||
on:
|
||||
issues:
|
||||
types: [opened]
|
||||
jobs:
|
||||
greeting:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v2
|
||||
- name: Check if the issue is labeled as a Bug Report
|
||||
id: check_bug_label
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
ISSUE_NUMBER=$(jq -r '.issue.number' "$GITHUB_EVENT_PATH")
|
||||
LABELS=$(gh issue view $ISSUE_NUMBER --json labels --jq '.labels[].name')
|
||||
|
||||
if echo "$LABELS" | grep -q 'bug'; then
|
||||
echo "This issue is labeled as a bug report. Checking if the issue creator is the repository owner."
|
||||
echo "skip_label_check=false" >> $GITHUB_ENV
|
||||
else
|
||||
echo "This issue is not labeled as a bug report. Skipping greeting message."
|
||||
echo "skip_label_check=true" >> $GITHUB_ENV
|
||||
fi
|
||||
- name: Check if the issue creator is the repo owner
|
||||
if: env.skip_label_check == 'false'
|
||||
id: check_owner
|
||||
run: |
|
||||
ISSUE_AUTHOR=$(jq -r '.issue.user.login' "$GITHUB_EVENT_PATH")
|
||||
REPO_OWNER=$(jq -r '.repository.owner.login' "$GITHUB_EVENT_PATH")
|
||||
if [ "$ISSUE_AUTHOR" = "$REPO_OWNER" ]; then
|
||||
echo "The issue creator is the repository owner. Skipping greeting message."
|
||||
echo "skip=true" >> $GITHUB_ENV
|
||||
else
|
||||
echo "The issue creator is not the repository owner. Checking for previous bug reports..."
|
||||
echo "skip=false" >> $GITHUB_ENV
|
||||
fi
|
||||
- name: Check if the user has submitted a bug report before
|
||||
if: env.skip == 'false'
|
||||
id: check_first_bug_report
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
ISSUE_AUTHOR=$(jq -r '.issue.user.login' "$GITHUB_EVENT_PATH")
|
||||
ISSUE_NUMBER=$(jq -r '.issue.number' "$GITHUB_EVENT_PATH")
|
||||
|
||||
# Get all issues (both open and closed) by the author except the current one
|
||||
PREVIOUS_REPORTS=$(gh issue list --author "$ISSUE_AUTHOR" --label "Bug" --state all --json number --jq '. | map(select(.number != '$ISSUE_NUMBER')) | length')
|
||||
echo "User $ISSUE_AUTHOR has submitted $PREVIOUS_REPORTS bug report(s) previously"
|
||||
|
||||
if [ "$PREVIOUS_REPORTS" -eq 0 ]; then
|
||||
echo "This is the user's first bug report. Sending greeting message."
|
||||
echo "skip_first_report=false" >> $GITHUB_ENV
|
||||
else
|
||||
echo "User has previous bug reports. Skipping greeting message."
|
||||
echo "skip_first_report=true" >> $GITHUB_ENV
|
||||
fi
|
||||
- name: Send Greeting Message
|
||||
if: env.skip_label_check == 'false' && env.skip != 'true' && env.skip_first_report != 'true'
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
const issueNumber = context.payload.issue.number;
|
||||
const message = `
|
||||
**🛠️ Thank you for reporting a bug!**
|
||||
Your issue has been successfully submitted and is now awaiting review. We appreciate your help in making Dantotsu better.
|
||||
**🔍 What Happens Next**
|
||||
- Our team will investigate the issue and provide updates as soon as possible.
|
||||
- You may be asked for additional details or clarification if needed.
|
||||
- Once resolved, we'll notify you of the fix or provide a workaround.
|
||||
**👥 Connect with Us**
|
||||
- **[Discord](https://discord.com/invite/4HPZ5nAWwM)**: Engage with our community and ask questions.
|
||||
- **[Telegram](https://t.me/dantotsuapp)**: Reach out for real-time discussions and updates.
|
||||
We're working hard to resolve the issue and appreciate your patience!
|
||||
`;
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueNumber,
|
||||
body: message
|
||||
});
|
||||
112
.github/workflows/extension-issue-handling.yml
vendored
Normal file
112
.github/workflows/extension-issue-handling.yml
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
name: Extension Issue Handling
|
||||
on:
|
||||
issues:
|
||||
types: [opened, labeled]
|
||||
|
||||
jobs:
|
||||
handle-extension-issues:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check Issue Content
|
||||
id: check-issue
|
||||
env:
|
||||
ISSUE_TITLE: ${{ github.event.issue.title }}
|
||||
ISSUE_BODY: ${{ github.event.issue.body }}
|
||||
run: |
|
||||
# Regex patterns for extension-related issues
|
||||
EXTENSION_REGEX_PATTERNS=(
|
||||
# Extension not working (more flexible match)
|
||||
".*(\w+)\s*(extension)?\s*(not working|doesn't work|does not work|cant work|can't work).*"
|
||||
|
||||
# No extension available
|
||||
".*(no|can't find|cannot find|missing).*extension.*"
|
||||
|
||||
# No repo or repositories available
|
||||
".*(no|can't find|cannot find|missing).*repo(s)?\s*(available|found|accessible).*"
|
||||
|
||||
# Specific server/stream issues
|
||||
".*(no streams|server).*(available|working).*"
|
||||
|
||||
# Variants of extension problems
|
||||
".*{.*}.*not working.*"
|
||||
".*{.*}.*extension.*(issue|problem).*"
|
||||
)
|
||||
|
||||
# Convert to lowercase for case-insensitive matching
|
||||
LOWER_TITLE=$(echo "$ISSUE_TITLE" | tr '[:upper:]' '[:lower:]')
|
||||
LOWER_BODY=$(echo "$ISSUE_BODY" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
# Flag to track issue type
|
||||
IS_EXTENSION_ISSUE=false
|
||||
IS_NO_EXTENSION_ISSUE=false
|
||||
|
||||
# Check title and body against regex patterns
|
||||
for pattern in "${EXTENSION_REGEX_PATTERNS[@]}"; do
|
||||
if [[ "$LOWER_TITLE" =~ $pattern ]] || [[ "$LOWER_BODY" =~ $pattern ]]; then
|
||||
IS_EXTENSION_ISSUE=true
|
||||
|
||||
# Special check for no extensions available
|
||||
if [[ "$LOWER_TITLE" =~ "no extension" ]] || [[ "$LOWER_TITLE" =~ "can't find extension" ]]; then
|
||||
IS_NO_EXTENSION_ISSUE=true
|
||||
fi
|
||||
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Explicitly output boolean values
|
||||
if [ "$IS_EXTENSION_ISSUE" = true ]; then
|
||||
echo "is_extension_issue=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "is_extension_issue=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
if [ "$IS_NO_EXTENSION_ISSUE" = true ]; then
|
||||
echo "is_no_extension_issue=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "is_no_extension_issue=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Comment and Close Extension Issue
|
||||
if: steps.check-issue.outputs.is_extension_issue == 'true'
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
const issueNumber = context.issue.number;
|
||||
|
||||
// Check if it's a "No Extension" issue
|
||||
if (${{ steps.check-issue.outputs.is_no_extension_issue }}) {
|
||||
// DMCA notice message
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueNumber,
|
||||
body: "# Automated Message\n" +
|
||||
"On 13 June 2024, the official Aniyomi repository got a DMCA notice and had to remove all of their extensions. Because of this, we will not be providing anyone with any links or extensions to avoid legal problems.\n" +
|
||||
"# How to add repos?\n" +
|
||||
"Although we do not give or maintain any repositories, we support adding custom repository links to your Dantotsu. \n" +
|
||||
"Go to `Profile > Settings > Extensions` then paste your anime or manga links there.\n" +
|
||||
"# How to find repos?\n" +
|
||||
"It's very easy. Search on Google. But remember that the URL must end with <u><b>index.min.json</b></u> or else it won't work.\n" +
|
||||
"`TLDR: We will not give repo links.`"
|
||||
});
|
||||
} else {
|
||||
// Standard extension issue message
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueNumber,
|
||||
body: `Dantotsu doesn't maintain extensions.
|
||||
If the extension doesn't work we cannot help you.
|
||||
Contact the owner of Respective Repo for extension-related problems`
|
||||
});
|
||||
}
|
||||
|
||||
// Close the issue
|
||||
await github.rest.issues.update({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueNumber,
|
||||
state: 'closed'
|
||||
});
|
||||
86
.github/workflows/feature_greetings.yml
vendored
Normal file
86
.github/workflows/feature_greetings.yml
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
name: Feature Request Greeting
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [opened]
|
||||
|
||||
jobs:
|
||||
greeting:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Check if the issue is labeled as a Feature Request
|
||||
id: check_feature_label
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
ISSUE_NUMBER=$(jq -r '.issue.number' "$GITHUB_EVENT_PATH")
|
||||
LABELS=$(gh issue view $ISSUE_NUMBER --json labels --jq '.labels[].name')
|
||||
|
||||
if echo "$LABELS" | grep -q 'enhancement'; then
|
||||
echo "This issue is labeled as a feature request. Checking if the issue creator is the repository owner."
|
||||
echo "skip_label_check=false" >> $GITHUB_ENV
|
||||
else
|
||||
echo "This issue is not labeled as a feature request. Skipping greeting message."
|
||||
echo "skip_label_check=true" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Check if the user has submitted a feature request before
|
||||
if: env.skip_label_check == 'false'
|
||||
id: check_first_request
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
ISSUE_AUTHOR=$(jq -r '.issue.user.login' "$GITHUB_EVENT_PATH")
|
||||
REPO_OWNER=$(jq -r '.repository.owner.login' "$GITHUB_EVENT_PATH")
|
||||
ISSUE_NUMBER=$(jq -r '.issue.number' "$GITHUB_EVENT_PATH")
|
||||
|
||||
if [ "$ISSUE_AUTHOR" = "$REPO_OWNER" ]; then
|
||||
echo "The issue creator is the repository owner. Skipping greeting message."
|
||||
echo "skip_first_request=true" >> $GITHUB_ENV
|
||||
else
|
||||
echo "Checking for previous feature requests..."
|
||||
# Get all issues (both open and closed) by the author except the current one
|
||||
PREVIOUS_REQUESTS=$(gh issue list --author "$ISSUE_AUTHOR" --label "New Feature" --state all --json number --jq '. | map(select(.number != '$ISSUE_NUMBER')) | length')
|
||||
echo "User $ISSUE_AUTHOR has submitted $PREVIOUS_REQUESTS feature request(s) previously"
|
||||
|
||||
if [ "$PREVIOUS_REQUESTS" -eq 0 ]; then
|
||||
echo "This is the user's first feature request. Sending greeting message."
|
||||
echo "skip_first_request=false" >> $GITHUB_ENV
|
||||
else
|
||||
echo "User has previous feature requests. Skipping greeting message."
|
||||
echo "skip_first_request=true" >> $GITHUB_ENV
|
||||
fi
|
||||
fi
|
||||
|
||||
- name: Send Greeting Message
|
||||
if: env.skip_label_check == 'false' && env.skip_first_request == 'false'
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
const issueNumber = context.payload.issue.number;
|
||||
const message = `
|
||||
**💡 Thank you for your feature request!**
|
||||
Your request has been successfully submitted and is now under consideration. We value your input in shaping the future of Dantotsu.
|
||||
|
||||
**📈 What to Expect Next**
|
||||
- Our team will review your request and assess its feasibility.
|
||||
- We may reach out for additional details or clarification.
|
||||
- Updates on the request will be provided, and it may be scheduled for future development.
|
||||
|
||||
**👥 Stay Connected**
|
||||
- **[Discord](https://discord.com/invite/4HPZ5nAWwM)**: Join our community to discuss ideas and stay updated.
|
||||
- **[Telegram](https://t.me/dantotsuapp)**: Connect with us directly for real-time updates.
|
||||
|
||||
We appreciate your suggestion and look forward to potentially implementing it!
|
||||
`;
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueNumber,
|
||||
body: message
|
||||
});
|
||||
80
.github/workflows/pr_greetings.yml
vendored
Normal file
80
.github/workflows/pr_greetings.yml
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
name: PR Greetings
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened]
|
||||
pull_request_target:
|
||||
types: [opened]
|
||||
|
||||
jobs:
|
||||
greeting:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Check if the PR creator is the repo owner or Weblate
|
||||
id: check_owner
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
PR_AUTHOR=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH")
|
||||
REPO_OWNER=$(jq -r '.repository.owner.login' "$GITHUB_EVENT_PATH")
|
||||
|
||||
if [ "$PR_AUTHOR" = "$REPO_OWNER" ] || [ "$PR_AUTHOR" = "weblate" ]; then
|
||||
echo "The PR creator is the repository owner or Weblate. Skipping greeting message."
|
||||
echo "skip=true" >> $GITHUB_ENV
|
||||
else
|
||||
echo "The PR creator is not the repository owner or Weblate. Checking for previous PRs..."
|
||||
|
||||
# Check for both open and closed pull requests by the author
|
||||
OPEN_PRS=$(gh pr list --author "$PR_AUTHOR" --state open --json number --jq '. | length')
|
||||
CLOSED_PRS=$(gh pr list --author "$PR_AUTHOR" --state closed --json number --jq '. | length')
|
||||
TOTAL_PRS=$((OPEN_PRS + CLOSED_PRS))
|
||||
|
||||
echo "User $PR_AUTHOR has created $TOTAL_PRS pull request(s) in total"
|
||||
echo "Open PRs: $OPEN_PRS"
|
||||
echo "Closed PRs: $CLOSED_PRS"
|
||||
|
||||
if [ "$TOTAL_PRS" -eq 1 ]; then
|
||||
echo "This is the user's first pull request. Sending greeting message."
|
||||
echo "skip=false" >> $GITHUB_ENV
|
||||
else
|
||||
echo "User has previous pull requests. Skipping greeting message."
|
||||
echo "skip=true" >> $GITHUB_ENV
|
||||
fi
|
||||
fi
|
||||
|
||||
- name: Send Greeting Message
|
||||
if: env.skip != 'true'
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
const prNumber = context.payload.pull_request.number;
|
||||
const message = `
|
||||
**🎉 Thank you for your contribution!**
|
||||
|
||||
Your Pull Request has been successfully submitted and is now awaiting review. We truly appreciate your efforts to improve Dantotsu.
|
||||
|
||||
**👥 Connect with the Community**
|
||||
|
||||
While you're here, why not join our communities to stay engaged?
|
||||
- **[Discord](https://discord.com/invite/4HPZ5nAWwM)**: Chat with fellow developers, ask questions, and get the latest updates.
|
||||
- **[Telegram](https://t.me/dantotsuapp)**: Connect directly with us for real-time discussions and updates.
|
||||
|
||||
**📋 What to Expect Next**
|
||||
- Our team will review your pull request as soon as possible.
|
||||
- You'll receive notifications if further information or changes are needed.
|
||||
- Once approved, your changes will be merged into the main project.
|
||||
|
||||
We're excited to collaborate with you. Stay tuned for updates!
|
||||
`;
|
||||
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: prNumber,
|
||||
body: message
|
||||
});
|
||||
18
.gitignore
vendored
18
.gitignore
vendored
@@ -2,12 +2,18 @@
|
||||
.gradle/
|
||||
build/
|
||||
|
||||
#kotlin
|
||||
.kotlin/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
local.properties
|
||||
|
||||
# Log/OS Files
|
||||
*.log
|
||||
|
||||
# Secrets
|
||||
apikey.properties
|
||||
|
||||
# Android Studio generated files and folders
|
||||
captures/
|
||||
.externalNativeBuild/
|
||||
@@ -23,8 +29,14 @@ output.json
|
||||
*.jks
|
||||
*.keystore
|
||||
|
||||
# Google Services (e.g. APIs or Firebase)
|
||||
google-services.json
|
||||
|
||||
# Android Profiling
|
||||
*.hprof
|
||||
|
||||
#other
|
||||
scripts/
|
||||
|
||||
#crowdin
|
||||
crowdin.yml
|
||||
|
||||
#vscode
|
||||
.vscode
|
||||
675
LICENSE.md
675
LICENSE.md
@@ -1,674 +1,17 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
## Unabandon Public License (UPL)
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
**Preamble**
|
||||
|
||||
Preamble
|
||||
This Unabandon Public License (UPL) is designed to ensure the continued development and public availability of source code based on works released under the GNU General Public License Version 3 (GPLv3) while upholding the core principles of GPLv3. This license extends GPLv3 by mandating public accessibility of source code for any derivative works.
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
**Body**
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
1. **Incorporation of GPLv3:** This UPL incorporates all terms and conditions of the GNU General Public License Version 3 (GPLv3) as published by the Free Software Foundation. You can find the complete text of GPLv3 at [https://www.gnu.org/licenses/licenses.en.html](https://www.gnu.org/licenses/licenses.en.html).
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
2. **Public Source Requirement:** In addition to the terms of GPLv3, the source code for any software distributed under this license, including modifications and derivative works, must be publicly available. Public availability means the source code must be accessible to anyone through a publicly accessible repository or download link without any access restrictions or fees.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
3. **Source Code Availability:** The source code must be made publicly available using a recognized open-source hosting platform (e.g., GitHub, GitLab) or be downloadable from a publicly accessible website. The chosen method must clearly identify the source code and its corresponding licensed work.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
**Termination**
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
This UPL terminates automatically if the terms and conditions are not followed by the licensee.
|
||||
|
||||
137
README.md
137
README.md
@@ -1,111 +1,58 @@
|
||||
# **Dantotsu** (🚧 ALPHA 🚧)
|
||||
|
||||
> ⚠️ **WARNING**: This project is in alpha stage. Things may not work as expected.
|
||||
|
||||
<p align="center">
|
||||
<a href="https://discord.gg/4HPZ5nAWwM"><img src="https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white"></a>
|
||||
<a href="https://github.com/saikou-app/saikou/releases"><img src="https://img.shields.io/github/downloads/rebelonion/Dantotsu/total?color=%233DDC84&logo=android&logoColor=%23fff&style=for-the-badge"></a>
|
||||
<img src="https://pbxt.replicate.delivery/2PX94viD6lJSDVayQrGyDH7CGu7IjQ6e8HEtOGDeelefXRdOC/out.png" alt="Dantotsu Banner" width=100% >
|
||||
</p>
|
||||
Dantotsu is crafted from the ashes of Saikou and based on simplistic yet state-of-the-art elegance. It is an <a href="https://anilist.co/">Anilist</a> only client, which also lets you stream-download Anime & Manga through extensions.
|
||||
<br><br>
|
||||
<i>Dantotsu (断トツ; Dan-totsu) literally means the best of the best in Japanese. Well, we would like to say this is the best open source app for anime and manga on Android, but hey, try it out yourself & judge!
|
||||
</i>
|
||||
<br>
|
||||
<br>
|
||||
<a href="https://www.buymeacoffee.com/rebelonion"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=rebelonion&button_colour=FFDD00&font_colour=000000&font_family=Poppins&outline_colour=000000&coffee_colour=ffffff" /></a>
|
||||
<br>
|
||||
|
||||
### 🌟STAR THIS REPOSITORY TO SUPPORT THE DEVELOPER AND ENCOURAGE THE DEVELOPMENT OF THE APPLICATION!
|
||||
|
||||
> **Warning**
|
||||
>
|
||||
> Please do not attempt to upload Dantotsu or any of it's forks on Playstore or any other Android appstores on the internet. Doing so, may infringe their terms and conditions. This may result to legal action or immediate take-down of the app.
|
||||
|
||||
## Extension Status
|
||||
|
||||
| Type | Status |
|
||||
| ---------------- | ------- |
|
||||
| Anime Extensions | Working |
|
||||
| Manga Extensions | Not Working |
|
||||
| Light Novel Extensions | Not Working |
|
||||
|
||||
|
||||
|
||||
## APP FEATURES
|
||||
|
||||
- Easy and functional way to both, watch anime and read manga, ad-free.
|
||||
|
||||
- A completely open source app with a nice UI & Animations :)
|
||||
|
||||
- Aniyomi extension support built right into the app.
|
||||
|
||||
- Synchronize anime and manga real-time with AniList and MyAnimeList. Easily categorise anime and manga based on your current status. (Powered by AniList)
|
||||
|
||||
- Find all shows using thoroughly and frequently updated list of all trending, popular and ongoing anime based on scores.
|
||||
|
||||
- View extensive details about anime shows, movies and manga titles. It also features ability to countdown to the next episode of airing anime. (Powered by AniList & MyAnimeList)
|
||||
|
||||
- Get notified when new episodes/chapters are released!
|
||||
|
||||
|
||||
* **Available Anime sources:-**
|
||||
NONE BUILT IN!
|
||||
add your own extensions in the settings menu (Dantotsu has no affiliation with any of the extensions)
|
||||
|
||||
|
||||
* **Available Manga sources:-**
|
||||
NONE BUILT IN!
|
||||
add your own extensions in the settings menu (Dantotsu has no affiliation with any of the extensions)
|
||||
|
||||
## Planned Stuff
|
||||
|
||||
- get app out of alpha
|
||||
|
||||
- Accent Color Change (RIP Hot Pink Supremacy.)
|
||||
|
||||
|
||||
## Rejected Stuff (still rejected)
|
||||
|
||||
- Sources of any language except English
|
||||
|
||||
- News Section in the App
|
||||
|
||||
- Comment Section
|
||||
|
||||
|
||||
## WANT TO CONTRIBUTE?
|
||||
|
||||
- All contributions are welcome, from code to documentation to graphics to design suggestions to bug reports. Please use GitHub to its fullest; contribute Pull Requests, contribute tutorials or other content- whatever you have to offer, we can use it!
|
||||
|
||||
- You can come hang out with our awesome community and request new features and report any bugs or issue at our discord server too.
|
||||
|
||||
### Official Discord Server
|
||||
|
||||
<p align="center">
|
||||
<a href="https://discord.gg/4HPZ5nAWwM">
|
||||
<img src="https://invidget.switchblade.xyz/2T7TunuwFZ">
|
||||
</a>
|
||||
<img src="https://img.shields.io/badge/platforms-android-blueviolet?style=for-the-badge"/>
|
||||
<a href="https://github.com/rebelonion/Dantotsu/releases"><img src="https://img.shields.io/github/downloads/rebelonion/Dantotsu/total?color=%233DDC84&logo=android&logoColor=%23fff&style=for-the-badge"></a>
|
||||
<a href="https://www.codefactor.io/repository/github/rebelonion/dantotsu"><img src="https://www.codefactor.io/repository/github/rebelonion/dantotsu/badge?color=%233DDC84&logo=android&logoColor=%23fff&style=for-the-badge" alt="CodeFactor" /></a>
|
||||
<a href="https://discord.gg/4HPZ5nAWwM"><img src="https://img.shields.io/discord/358599430502481920.svg?style=for-the-badge&logo=discord&colorB=7289DA"></a>
|
||||
</p>
|
||||
|
||||
# **Dantotsu** 🌟
|
||||
|
||||
### VISIT FOR MORE INFORMATION:-
|
||||
Dantotsu is an [Anilist](https://anilist.co/) only client.
|
||||
|
||||
no website yet :(
|
||||
> **Dantotsu (断トツ; Dan-totsu)** literally means "the best of the best" in Japanese. Try it out for yourself and be the judge!
|
||||
|
||||
## DISCLAIMER
|
||||
## Terms of Use
|
||||
By downloading, installing, or using this application, you agree to:
|
||||
- Use the application in compliance with all applicable laws
|
||||
- Not use the application to infringe on copyrighted content
|
||||
- Take full responsibility for any extensions you install or use
|
||||
- Understand that the developer(s) are not responsible for third-party extensions or user actions
|
||||
|
||||
* Dantotsu by itself only provides an anime and manga tracker and does not provide any anime or manga streaming or downloading capabilities.
|
||||
This application is designed for anime tracking and legal streaming service integration. The developers do not provide, maintain, or endorse any extensions that enable access to unauthorized content.
|
||||
|
||||
* Dantotsu or any of its developer/staff don't host any of the content found inside Dantotsu. Any and all images and anime/manga information found in the app are taken from various public APIs (AniList, MyAnimeList, Kitsu).
|
||||
## Important Notice
|
||||
This application is an anime tracking and management tool. The extension system is designed to integrate with legal streaming services like Jellyfin.
|
||||
|
||||
* Furthermore, all of the anime/manga links found in Dantotsu are taken from various 3rd party plugins and have no affiliation with Dantotsu or its staff.
|
||||
We do not:
|
||||
- Provide or maintain any streaming extensions
|
||||
- Host or distribute copyrighted content
|
||||
- Endorse or encourage copyright infringement
|
||||
|
||||
* Dantotsu or it's owners aren't liable for any misuse of any of the contents found inside or outside of the app and cannot be held accountable for the distribution of any of the contents found inside the app.
|
||||
Users are responsible for ensuring their use of this software complies with local laws and regulations.
|
||||
|
||||
* By using Dantotsu, you comply to the fact that the developer of the app is not responsible for any of the contents found in the app. You also agree to the fact that you may not use Dantotsu to download or stream any copyrighted content.
|
||||
### 🚀 STAR THIS REPOSITORY TO SUPPORT THE DEVELOPER AND ENCOURAGE THE DEVELOPMENT OF THE APPLICATION!
|
||||
|
||||
* If the internet infringement issues are involved, please contact the source website. The developer does not assume any legal responsibility.
|
||||
## WANT TO CONTRIBUTE? 🤝
|
||||
|
||||
## License
|
||||
All contributions are welcome, from code to documentation to graphics to design suggestions to bug reports. Please use GitHub to its fullest; contribute Pull Requests, contribute tutorials or other content - whatever you have to offer, we can use!
|
||||
|
||||
Dantotsu is licensed under the [GNU General Public License v3.0](LICENSE.md)
|
||||
You can come hang out with our awesome community, request new features, and report any bugs or issues at our Discord server too. 📣
|
||||
|
||||
### OFFICIAL DISCORD SERVER 🚀
|
||||
|
||||
<p align="center">
|
||||
<a href="https://discord.gg/4HPZ5nAWwM">
|
||||
<img src="https://invidget.switchblade.xyz/4HPZ5nAWwM">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## VISITORS
|
||||
|
||||
<img src="https://count.getloli.com/get/@:rebeloniondantotsu" alt=":rebeloniondantotsu" />
|
||||
|
||||
## LICENSE 📜
|
||||
|
||||
Dantotsu is licensed under the Unabandon Public License (UPL). More info can be found [here.](LICENSE.md)
|
||||
|
||||
4
app/.gitignore
vendored
4
app/.gitignore
vendored
@@ -1,4 +1,8 @@
|
||||
/build
|
||||
/debug
|
||||
/debug/output-metadata.json
|
||||
/alpha
|
||||
/alpha/output-metadata.json
|
||||
/google/*
|
||||
/fdroid/*
|
||||
/release
|
||||
146
app/build.gradle
146
app/build.gradle
@@ -1,12 +1,9 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'com.google.gms.google-services'
|
||||
id 'com.google.firebase.crashlytics'
|
||||
id 'kotlin-android'
|
||||
id 'kotlinx-serialization'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
id 'com.google.devtools.ksp'
|
||||
|
||||
}
|
||||
|
||||
def gitCommitHash = providers.exec {
|
||||
@@ -14,30 +11,65 @@ def gitCommitHash = providers.exec {
|
||||
}.standardOutput.asText.get().trim()
|
||||
|
||||
android {
|
||||
compileSdk 34
|
||||
compileSdk 35
|
||||
|
||||
defaultConfig {
|
||||
applicationId "ani.dantotsu"
|
||||
minSdk 23
|
||||
targetSdk 34
|
||||
versionCode ((System.currentTimeMillis() / 60000).toInteger())
|
||||
versionName "0.0.1"
|
||||
minSdk 21
|
||||
targetSdk 35
|
||||
versionCode((System.currentTimeMillis() / 60000).toInteger())
|
||||
versionName "3.2.1"
|
||||
versionCode versionName.split("\\.").collect { it.toInteger() * 100 }.join("") as Integer
|
||||
signingConfig signingConfigs.debug
|
||||
|
||||
}
|
||||
|
||||
flavorDimensions += "store"
|
||||
productFlavors {
|
||||
fdroid {
|
||||
// F-Droid specific configuration
|
||||
dimension "store"
|
||||
versionNameSuffix "-fdroid"
|
||||
}
|
||||
google {
|
||||
// Google Play specific configuration
|
||||
dimension "store"
|
||||
isDefault true
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
apply plugin: 'com.google.firebase.crashlytics'
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
//applicationIdSuffix ".beta"
|
||||
alpha {
|
||||
applicationIdSuffix ".beta" // keep as beta by popular request
|
||||
versionNameSuffix "-alpha01-" + gitCommitHash
|
||||
manifestPlaceholders.icon_placeholder = "@mipmap/ic_launcher_alpha"
|
||||
manifestPlaceholders.icon_placeholder_round = "@mipmap/ic_launcher_alpha_round"
|
||||
debuggable System.getenv("CI") == null
|
||||
isDefault true
|
||||
debuggable true
|
||||
versionNameSuffix "." + gitCommitHash
|
||||
jniDebuggable true
|
||||
minifyEnabled false
|
||||
shrinkResources false
|
||||
}
|
||||
debug {
|
||||
applicationIdSuffix ".beta"
|
||||
versionNameSuffix "-beta01"
|
||||
manifestPlaceholders.icon_placeholder = "@mipmap/ic_launcher_beta"
|
||||
manifestPlaceholders.icon_placeholder_round = "@mipmap/ic_launcher_beta_round"
|
||||
debuggable false
|
||||
}
|
||||
release {
|
||||
manifestPlaceholders.icon_placeholder = "@mipmap/ic_launcher"
|
||||
manifestPlaceholders.icon_placeholder_round = "@mipmap/ic_launcher_round"
|
||||
debuggable false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-gson.pro', 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
buildConfig true
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
@@ -51,22 +83,33 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Core
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
implementation 'androidx.browser:browser:1.6.0'
|
||||
implementation 'androidx.core:core-ktx:1.12.0'
|
||||
implementation 'androidx.fragment:fragment-ktx:1.6.1'
|
||||
|
||||
// FireBase
|
||||
googleImplementation platform('com.google.firebase:firebase-bom:33.13.0')
|
||||
googleImplementation 'com.google.firebase:firebase-analytics-ktx:22.4.0'
|
||||
googleImplementation 'com.google.firebase:firebase-crashlytics-ktx:19.4.3'
|
||||
// Core
|
||||
implementation 'androidx.appcompat:appcompat:1.7.0'
|
||||
implementation 'androidx.browser:browser:1.8.0'
|
||||
implementation 'androidx.core:core-ktx:1.16.0'
|
||||
implementation 'androidx.fragment:fragment-ktx:1.8.6'
|
||||
implementation 'androidx.activity:activity-ktx:1.10.1'
|
||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'androidx.multidex:multidex:2.0.1'
|
||||
implementation "androidx.work:work-runtime-ktx:2.8.1"
|
||||
implementation "androidx.work:work-runtime-ktx:2.10.1"
|
||||
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation 'com.google.code.gson:gson:2.10.1'
|
||||
implementation 'com.github.Blatzar:NiceHttp:0.4.4'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3'
|
||||
implementation 'androidx.preference:preference-ktx:1.2.1'
|
||||
implementation 'androidx.webkit:webkit:1.13.0'
|
||||
implementation "com.anggrayudi:storage:1.5.5"
|
||||
implementation "androidx.biometric:biometric:1.1.0"
|
||||
|
||||
implementation 'com.github.Blatzar:NiceHttp:0.4.3'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0'
|
||||
|
||||
// Glide
|
||||
// Glide
|
||||
ext.glide_version = '4.16.0'
|
||||
api "com.github.bumptech.glide:glide:$glide_version"
|
||||
implementation "com.github.bumptech.glide:glide:$glide_version"
|
||||
@@ -74,46 +117,67 @@ dependencies {
|
||||
implementation "com.github.bumptech.glide:okhttp3-integration:$glide_version"
|
||||
implementation 'jp.wasabeef:glide-transformations:4.3.0'
|
||||
|
||||
// FireBase
|
||||
implementation platform('com.google.firebase:firebase-bom:32.2.3')
|
||||
implementation 'com.google.firebase:firebase-analytics-ktx:21.3.0'
|
||||
implementation 'com.google.firebase:firebase-crashlytics-ktx:18.4.3'
|
||||
|
||||
// Exoplayer
|
||||
ext.exo_version = '1.1.1'
|
||||
// Exoplayer
|
||||
ext.exo_version = '1.6.1'
|
||||
implementation "androidx.media3:media3-exoplayer:$exo_version"
|
||||
implementation "androidx.media3:media3-ui:$exo_version"
|
||||
implementation "androidx.media3:media3-exoplayer-hls:$exo_version"
|
||||
implementation "androidx.media3:media3-exoplayer-dash:$exo_version"
|
||||
implementation "androidx.media3:media3-datasource-okhttp:$exo_version"
|
||||
implementation "androidx.media3:media3-session:$exo_version"
|
||||
// Media3 Casting
|
||||
implementation "androidx.media3:media3-cast:$exo_version"
|
||||
implementation "androidx.mediarouter:mediarouter:1.7.0"
|
||||
// Media3 extension
|
||||
implementation "com.github.anilbeesetti.nextlib:nextlib-media3ext:0.8.4"
|
||||
|
||||
// UI
|
||||
implementation 'com.google.android.material:material:1.10.0'
|
||||
implementation 'nl.joery.animatedbottombar:library:1.1.0'
|
||||
implementation 'io.noties.markwon:core:4.6.2'
|
||||
// UI
|
||||
implementation 'com.google.android.material:material:1.12.0'
|
||||
implementation 'com.github.RepoDevil:AnimatedBottomBar:7fcb9af'
|
||||
implementation 'com.flaviofaria:kenburnsview:1.0.7'
|
||||
implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'
|
||||
implementation 'com.alexvasilkov:gesture-views:2.8.3'
|
||||
implementation 'com.github.VipulOG:ebook-reader:0.1.6'
|
||||
implementation 'androidx.paging:paging-runtime-ktx:3.3.6'
|
||||
implementation 'com.github.eltos:simpledialogfragments:v3.7'
|
||||
implementation 'com.github.AAChartModel:AAChartCore-Kotlin:7.2.3'
|
||||
|
||||
// Aniyomi
|
||||
// Markwon
|
||||
ext.markwon_version = '4.6.2'
|
||||
implementation "io.noties.markwon:core:$markwon_version"
|
||||
implementation "io.noties.markwon:editor:$markwon_version"
|
||||
implementation "io.noties.markwon:ext-strikethrough:$markwon_version"
|
||||
implementation "io.noties.markwon:ext-tables:$markwon_version"
|
||||
implementation "io.noties.markwon:ext-tasklist:$markwon_version"
|
||||
implementation "io.noties.markwon:html:$markwon_version"
|
||||
implementation "io.noties.markwon:image-glide:$markwon_version"
|
||||
|
||||
// Groupie
|
||||
ext.groupie_version = '2.10.1'
|
||||
implementation "com.github.lisawray.groupie:groupie:$groupie_version"
|
||||
implementation "com.github.lisawray.groupie:groupie-viewbinding:$groupie_version"
|
||||
|
||||
// String Matching
|
||||
implementation 'me.xdrop:fuzzywuzzy:1.4.0'
|
||||
|
||||
// Aniyomi
|
||||
implementation 'io.reactivex:rxjava:1.3.8'
|
||||
implementation 'io.reactivex:rxandroid:1.2.1'
|
||||
implementation 'ru.beryukhov:flowreactivenetwork:1.0.4'
|
||||
implementation 'ca.gosyer:voyager-navigator:1.0.0-rc07'
|
||||
implementation 'com.squareup.logcat:logcat:0.1'
|
||||
implementation 'com.github.inorichi.injekt:injekt-core:65b0440'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.11'
|
||||
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.11'
|
||||
implementation 'uy.kohesive.injekt:injekt-core:1.16.+'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.14'
|
||||
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.14'
|
||||
implementation 'com.squareup.okhttp3:okhttp-dnsoverhttps'
|
||||
implementation 'com.squareup.okio:okio:3.3.0'
|
||||
implementation 'ch.acra:acra-http:5.9.7'
|
||||
implementation 'org.jsoup:jsoup:1.15.4'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json-okio:1.5.0'
|
||||
implementation 'com.squareup.okio:okio:3.9.1'
|
||||
implementation 'com.squareup.okhttp3:okhttp-brotli:5.0.0-alpha.14'
|
||||
implementation 'org.jsoup:jsoup:1.18.1'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json-okio:1.7.3'
|
||||
implementation 'com.jakewharton.rxrelay:rxrelay:1.2.0'
|
||||
implementation 'com.github.tachiyomiorg:unifile:17bec43'
|
||||
implementation 'com.github.gpanther:java-nat-sort:natural-comparator-1.1'
|
||||
implementation 'androidx.preference:preference-ktx:1.2.0'
|
||||
implementation 'androidx.preference:preference-ktx:1.2.1'
|
||||
implementation 'app.cash.quickjs:quickjs-android:0.9.2'
|
||||
|
||||
}
|
||||
|
||||
86
app/google-services.json
Normal file
86
app/google-services.json
Normal file
@@ -0,0 +1,86 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "1039200814590",
|
||||
"project_id": "dantotsu-1e50f",
|
||||
"storage_bucket": "dantotsu-1e50f.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:1039200814590:android:c372b8c1b92b825f1aacaf",
|
||||
"android_client_info": {
|
||||
"package_name": "ani.Dantotsu"
|
||||
}
|
||||
},
|
||||
"oauth_client": [],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyCiXo_q4S2ofA5oCztsoLnlDqJi3GtTJjY"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:1039200814590:android:40e14720ee97917e1aacaf",
|
||||
"android_client_info": {
|
||||
"package_name": "ani.dantotsu.beta"
|
||||
}
|
||||
},
|
||||
"oauth_client": [],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyCiXo_q4S2ofA5oCztsoLnlDqJi3GtTJjY"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:1039200814590:android:40e14720ee97917e1aacaf",
|
||||
"android_client_info": {
|
||||
"package_name": "ani.dantotsu.alpha"
|
||||
}
|
||||
},
|
||||
"oauth_client": [],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyCiXo_q4S2ofA5oCztsoLnlDqJi3GtTJjY"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:1039200814590:android:40e14720ee97917e1aacaf",
|
||||
"android_client_info": {
|
||||
"package_name": "ani.dantotsu"
|
||||
}
|
||||
},
|
||||
"oauth_client": [],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyCiXo_q4S2ofA5oCztsoLnlDqJi3GtTJjY"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
||||
19
app/proguard-rules.pro
vendored
19
app/proguard-rules.pro
vendored
@@ -43,6 +43,25 @@
|
||||
public static <1> INSTANCE;
|
||||
kotlinx.serialization.KSerializer serializer(...);
|
||||
}
|
||||
-keep class ani.dantotsu.** { *; }
|
||||
-keep class ani.dantotsu.download.DownloadsManager { *; }
|
||||
-keepattributes Signature
|
||||
-keep class uy.kohesive.injekt.** { *; }
|
||||
-keep class eu.kanade.tachiyomi.** { *; }
|
||||
-keep class kotlin.** { *; }
|
||||
-dontwarn kotlin.**
|
||||
-keep class kotlinx.** { *; }
|
||||
-keepclassmembers class uy.kohesive.injekt.api.FullTypeReference {
|
||||
<init>(...);
|
||||
}
|
||||
-keep class com.google.gson.** { *; }
|
||||
-keepattributes *Annotation*
|
||||
-keepattributes EnclosingMethod
|
||||
-keep class com.google.gson.reflect.TypeToken { *; }
|
||||
-keep class org.jsoup.** { *; }
|
||||
-keepclassmembers class org.jsoup.nodes.Document { *; }
|
||||
|
||||
|
||||
|
||||
# @Serializable and @Polymorphic are used at runtime for polymorphic serialization.
|
||||
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault
|
||||
|
||||
376
app/src/alpha/res/drawable/anim_splash.xml
Normal file
376
app/src/alpha/res/drawable/anim_splash.xml
Normal file
@@ -0,0 +1,376 @@
|
||||
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt">
|
||||
<aapt:attr name="android:drawable">
|
||||
<vector
|
||||
android:name="vector"
|
||||
android:width="768dp"
|
||||
android:height="768dp"
|
||||
android:viewportWidth="768"
|
||||
android:viewportHeight="768">
|
||||
<group
|
||||
android:name="wrapper"
|
||||
android:pivotX="384"
|
||||
android:pivotY="384">
|
||||
<clip-path
|
||||
android:name="clippath"
|
||||
android:pathData="M 384 128.04 C 329.836 127.869 276.99 144.889 233.11 176.638 C 189.23 208.387 156.539 253.255 139.769 304.75 C 122.999 356.244 122.999 411.756 139.769 463.25 C 156.539 514.745 189.23 559.613 233.11 591.362 C 276.99 623.111 329.836 640.131 384 639.96 C 451.869 639.96 517.028 612.974 565.019 564.991 C 613.01 517.008 640 451.859 640 384 C 640 316.141 613.01 250.992 565.019 203.009 C 517.028 155.026 451.869 128.04 384 128.04 Z" />
|
||||
<group android:name="group">
|
||||
<group android:name="group_1">
|
||||
<path
|
||||
android:name="path"
|
||||
android:fillColor="#ED0021"
|
||||
android:pathData="M 128 128 L 640 128 L 640 639.96 L 128 639.96 Z"
|
||||
android:strokeWidth="1" />
|
||||
<group
|
||||
android:name="group_12"
|
||||
android:pivotX="384"
|
||||
android:pivotY="384">
|
||||
<path
|
||||
android:name="path_2"
|
||||
android:fillColor="#D40037"
|
||||
android:pathData="M 384 211.74 C 338.331 211.74 294.486 229.901 262.194 262.194 C 229.901 294.486 211.74 338.331 211.74 384 C 211.74 429.669 229.901 473.514 262.194 505.806 C 294.486 538.099 338.331 556.26 384 556.26 C 429.669 556.26 473.514 538.099 505.806 505.806 C 538.099 473.514 556.26 429.669 556.26 384 C 556.26 338.331 538.099 294.486 505.806 262.194 C 473.514 229.901 429.669 211.74 384 211.74 Z"
|
||||
android:strokeWidth="1" />
|
||||
</group>
|
||||
</group>
|
||||
<group android:name="group_2">
|
||||
<group android:name="group_7">
|
||||
<group android:name="group_10">
|
||||
<group
|
||||
android:name="group_11"
|
||||
android:pivotX="94"
|
||||
android:pivotY="440"
|
||||
android:rotation="-90">
|
||||
<path
|
||||
android:name="path_1"
|
||||
android:fillColor="#A70060"
|
||||
android:pathData="M 128 128 L 128 463.26 C 151.32 466.96 175.23 468.89 199.58 468.89 C 411.17 468.89 588.92 323.99 639.01 128 L 128 128 Z"
|
||||
android:strokeWidth="1" />
|
||||
<clip-path
|
||||
android:name="mask_2"
|
||||
android:pathData="M 128 128 L 128 463.26 C 151.32 466.96 175.23 468.89 199.58 468.89 C 411.17 468.89 588.92 323.99 639.01 128 L 128 128 Z" />
|
||||
</group>
|
||||
</group>
|
||||
<group
|
||||
android:name="group_13"
|
||||
android:pivotX="384"
|
||||
android:pivotY="384">
|
||||
<clip-path
|
||||
android:name="mask_1"
|
||||
android:pathData="M 384 211.74 C 338.331 211.74 294.486 229.901 262.194 262.194 C 229.901 294.486 211.74 338.331 211.74 384 C 211.74 429.669 229.901 473.514 262.194 505.806 C 294.486 538.099 338.331 556.26 384 556.26 C 429.669 556.26 473.514 538.099 505.806 505.806 C 538.099 473.514 556.26 429.669 556.26 384 C 556.26 338.331 538.099 294.486 505.806 262.194 C 473.514 229.901 429.669 211.74 384 211.74 Z" />
|
||||
<group
|
||||
android:name="group_9"
|
||||
android:pivotX="94"
|
||||
android:pivotY="440"
|
||||
android:rotation="-90">
|
||||
<path
|
||||
android:name="path_3"
|
||||
android:fillColor="#BF005E"
|
||||
android:pathData="M 128 128 L 128 463.26 C 151.32 466.96 175.23 468.89 199.58 468.89 C 411.17 468.89 588.92 323.99 639.01 128 L 128 128 Z"
|
||||
android:strokeWidth="1" />
|
||||
</group>
|
||||
</group>
|
||||
<group
|
||||
android:name="group_6"
|
||||
android:pivotX="94"
|
||||
android:pivotY="440"
|
||||
android:rotation="-5"
|
||||
android:scaleX="1.2"
|
||||
android:scaleY="1.2" />
|
||||
</group>
|
||||
<group
|
||||
android:name="group_8"
|
||||
android:pivotX="94"
|
||||
android:pivotY="440"
|
||||
android:rotation="-90">
|
||||
<group
|
||||
android:name="group_14"
|
||||
android:pivotX="94"
|
||||
android:pivotY="440">
|
||||
<path
|
||||
android:name="path_4"
|
||||
android:fillColor="#C70051"
|
||||
android:pathData="M 539.28 128 C 503.71 317.07 337.72 460.12 138.31 460.12 C 134.86 460.12 131.42 460.06 128 459.98 L 128 465.73 C 168.23 476.19 210.43 481.78 253.93 481.78 C 409.53 481.78 548.48 410.55 640 298.94 L 640 128.01 L 539.28 128.01 Z"
|
||||
android:strokeWidth="1" />
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<group
|
||||
android:name="group_3"
|
||||
android:translateX="-360">
|
||||
<path
|
||||
android:name="path_6"
|
||||
android:fillColor="#251528"
|
||||
android:pathData="M 481.82 384 C 481.82 438.03 438.02 481.82 384 481.82 L 0 481.82 L 0 286.18 L 384 286.18 C 438.02 286.18 481.82 329.98 481.82 384 Z"
|
||||
android:strokeWidth="1" />
|
||||
</group>
|
||||
<group
|
||||
android:name="group_4"
|
||||
android:pivotX="384"
|
||||
android:pivotY="384"
|
||||
android:scaleX="1.5"
|
||||
android:scaleY="1.5">
|
||||
<path
|
||||
android:name="path_5"
|
||||
android:fillColor="#251528"
|
||||
android:pathData="M 44.26 128 C 44.26 174.25 81.75 211.74 128 211.74 L 384 211.74 C 479.13 211.74 556.26 288.86 556.26 384 C 556.26 479.13 479.14 556.26 384 556.26 L 128 556.26 C 81.76 556.26 44.28 593.73 44.26 639.97 L 768 639.97 L 768 128 L 44.26 128 Z"
|
||||
android:strokeWidth="1" />
|
||||
</group>
|
||||
<group
|
||||
android:name="group_5"
|
||||
android:pivotX="384"
|
||||
android:pivotY="384"
|
||||
android:rotation="-15"
|
||||
android:scaleX="3"
|
||||
android:scaleY="3">
|
||||
<path
|
||||
android:name="path_7"
|
||||
android:fillAlpha="0"
|
||||
android:fillColor="#FFD8DF"
|
||||
android:pathData="M 442 366.7 L 365.98 322.81 C 352.66 315.12 336.02 324.73 336.02 340.11 L 336.02 427.89 C 336.02 443.27 352.67 452.88 365.98 445.19 L 442 401.3 C 455.32 393.61 455.32 374.39 442 366.7 Z"
|
||||
android:strokeWidth="1" />
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
</vector>
|
||||
</aapt:attr>
|
||||
<target android:name="wrapper">
|
||||
<aapt:attr name="android:animation">
|
||||
<set>
|
||||
<objectAnimator
|
||||
android:duration="500"
|
||||
android:interpolator="@android:anim/overshoot_interpolator"
|
||||
android:propertyName="scaleX"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="500"
|
||||
android:interpolator="@android:anim/overshoot_interpolator"
|
||||
android:propertyName="scaleY"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
</set>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_6">
|
||||
<aapt:attr name="android:animation">
|
||||
<set>
|
||||
<objectAnimator
|
||||
android:duration="550"
|
||||
android:interpolator="@android:anim/overshoot_interpolator"
|
||||
android:propertyName="rotation"
|
||||
android:startOffset="350"
|
||||
android:valueFrom="-10"
|
||||
android:valueTo="0"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="300"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="scaleX"
|
||||
android:startOffset="350"
|
||||
android:valueFrom="1.2"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="300"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="scaleY"
|
||||
android:startOffset="350"
|
||||
android:valueFrom="1.2"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
</set>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_3">
|
||||
<aapt:attr name="android:animation">
|
||||
<objectAnimator
|
||||
android:duration="400"
|
||||
android:interpolator="@android:anim/overshoot_interpolator"
|
||||
android:propertyName="translateX"
|
||||
android:startOffset="250"
|
||||
android:valueFrom="-360"
|
||||
android:valueTo="0"
|
||||
android:valueType="floatType" />
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_4">
|
||||
<aapt:attr name="android:animation">
|
||||
<set>
|
||||
<objectAnimator
|
||||
android:duration="350"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="scaleX"
|
||||
android:startOffset="400"
|
||||
android:valueFrom="1.5"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="350"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="scaleY"
|
||||
android:startOffset="400"
|
||||
android:valueFrom="1.5"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
</set>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="path_7">
|
||||
<aapt:attr name="android:animation">
|
||||
<objectAnimator
|
||||
android:duration="550"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="fillAlpha"
|
||||
android:startOffset="350"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_5">
|
||||
<aapt:attr name="android:animation">
|
||||
<set>
|
||||
<objectAnimator
|
||||
android:duration="550"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:propertyName="rotation"
|
||||
android:startOffset="350"
|
||||
android:valueFrom="-45"
|
||||
android:valueTo="0"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="550"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="scaleX"
|
||||
android:startOffset="350"
|
||||
android:valueFrom="3"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="550"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="scaleY"
|
||||
android:startOffset="350"
|
||||
android:valueFrom="3"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
</set>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_8">
|
||||
<aapt:attr name="android:animation">
|
||||
<objectAnimator
|
||||
android:duration="350"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="rotation"
|
||||
android:startOffset="100"
|
||||
android:valueFrom="-90"
|
||||
android:valueTo="0"
|
||||
android:valueType="floatType" />
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_9">
|
||||
<aapt:attr name="android:animation">
|
||||
<set>
|
||||
<objectAnimator
|
||||
android:duration="350"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="rotation"
|
||||
android:startOffset="100"
|
||||
android:valueFrom="-90"
|
||||
android:valueTo="0"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="350"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="scaleX"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="350"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="scaleY"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
</set>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_11">
|
||||
<aapt:attr name="android:animation">
|
||||
<objectAnimator
|
||||
android:duration="350"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="rotation"
|
||||
android:startOffset="100"
|
||||
android:valueFrom="-90"
|
||||
android:valueTo="0"
|
||||
android:valueType="floatType" />
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_12">
|
||||
<aapt:attr name="android:animation">
|
||||
<set>
|
||||
<objectAnimator
|
||||
android:duration="550"
|
||||
android:interpolator="@android:anim/overshoot_interpolator"
|
||||
android:propertyName="scaleX"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="550"
|
||||
android:interpolator="@android:anim/overshoot_interpolator"
|
||||
android:propertyName="scaleY"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
</set>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_13">
|
||||
<aapt:attr name="android:animation">
|
||||
<set>
|
||||
<objectAnimator
|
||||
android:duration="550"
|
||||
android:interpolator="@android:anim/overshoot_interpolator"
|
||||
android:propertyName="scaleX"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="550"
|
||||
android:interpolator="@android:anim/overshoot_interpolator"
|
||||
android:propertyName="scaleY"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
</set>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_14">
|
||||
<aapt:attr name="android:animation">
|
||||
<set>
|
||||
<objectAnimator
|
||||
android:duration="200"
|
||||
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
|
||||
android:propertyName="rotation"
|
||||
android:startOffset="350"
|
||||
android:valueFrom="5"
|
||||
android:valueTo="0"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="100"
|
||||
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
|
||||
android:propertyName="rotation"
|
||||
android:startOffset="250"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="5"
|
||||
android:valueType="floatType" />
|
||||
</set>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
</animated-vector>
|
||||
4
app/src/alpha/res/values/strings.xml
Normal file
4
app/src/alpha/res/values/strings.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Dantotsu α</string>
|
||||
</resources>
|
||||
376
app/src/debug/res/drawable/anim_splash.xml
Normal file
376
app/src/debug/res/drawable/anim_splash.xml
Normal file
@@ -0,0 +1,376 @@
|
||||
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt">
|
||||
<aapt:attr name="android:drawable">
|
||||
<vector
|
||||
android:name="vector"
|
||||
android:width="768dp"
|
||||
android:height="768dp"
|
||||
android:viewportWidth="768"
|
||||
android:viewportHeight="768">
|
||||
<group
|
||||
android:name="wrapper"
|
||||
android:pivotX="384"
|
||||
android:pivotY="384">
|
||||
<clip-path
|
||||
android:name="clippath"
|
||||
android:pathData="M 384 128.04 C 329.836 127.869 276.99 144.889 233.11 176.638 C 189.23 208.387 156.539 253.255 139.769 304.75 C 122.999 356.244 122.999 411.756 139.769 463.25 C 156.539 514.745 189.23 559.613 233.11 591.362 C 276.99 623.111 329.836 640.131 384 639.96 C 451.869 639.96 517.028 612.974 565.019 564.991 C 613.01 517.008 640 451.859 640 384 C 640 316.141 613.01 250.992 565.019 203.009 C 517.028 155.026 451.869 128.04 384 128.04 Z" />
|
||||
<group android:name="group">
|
||||
<group android:name="group_1">
|
||||
<path
|
||||
android:name="path"
|
||||
android:fillColor="#6901fd"
|
||||
android:pathData="M 128 128 L 640 128 L 640 639.96 L 128 639.96 Z"
|
||||
android:strokeWidth="1" />
|
||||
<group
|
||||
android:name="group_12"
|
||||
android:pivotX="384"
|
||||
android:pivotY="384">
|
||||
<path
|
||||
android:name="path_2"
|
||||
android:fillColor="#4800e5"
|
||||
android:pathData="M 384 211.74 C 338.331 211.74 294.486 229.901 262.194 262.194 C 229.901 294.486 211.74 338.331 211.74 384 C 211.74 429.669 229.901 473.514 262.194 505.806 C 294.486 538.099 338.331 556.26 384 556.26 C 429.669 556.26 473.514 538.099 505.806 505.806 C 538.099 473.514 556.26 429.669 556.26 384 C 556.26 338.331 538.099 294.486 505.806 262.194 C 473.514 229.901 429.669 211.74 384 211.74 Z"
|
||||
android:strokeWidth="1" />
|
||||
</group>
|
||||
</group>
|
||||
<group android:name="group_2">
|
||||
<group android:name="group_7">
|
||||
<group android:name="group_10">
|
||||
<group
|
||||
android:name="group_11"
|
||||
android:pivotX="94"
|
||||
android:pivotY="440"
|
||||
android:rotation="-90">
|
||||
<path
|
||||
android:name="path_1"
|
||||
android:fillColor="#2000bd"
|
||||
android:pathData="M 128 128 L 128 463.26 C 151.32 466.96 175.23 468.89 199.58 468.89 C 411.17 468.89 588.92 323.99 639.01 128 L 128 128 Z"
|
||||
android:strokeWidth="1" />
|
||||
<clip-path
|
||||
android:name="mask_2"
|
||||
android:pathData="M 128 128 L 128 463.26 C 151.32 466.96 175.23 468.89 199.58 468.89 C 411.17 468.89 588.92 323.99 639.01 128 L 128 128 Z" />
|
||||
</group>
|
||||
</group>
|
||||
<group
|
||||
android:name="group_13"
|
||||
android:pivotX="384"
|
||||
android:pivotY="384">
|
||||
<clip-path
|
||||
android:name="mask_1"
|
||||
android:pathData="M 384 211.74 C 338.331 211.74 294.486 229.901 262.194 262.194 C 229.901 294.486 211.74 338.331 211.74 384 C 211.74 429.669 229.901 473.514 262.194 505.806 C 294.486 538.099 338.331 556.26 384 556.26 C 429.669 556.26 473.514 538.099 505.806 505.806 C 538.099 473.514 556.26 429.669 556.26 384 C 556.26 338.331 538.099 294.486 505.806 262.194 C 473.514 229.901 429.669 211.74 384 211.74 Z" />
|
||||
<group
|
||||
android:name="group_9"
|
||||
android:pivotX="94"
|
||||
android:pivotY="440"
|
||||
android:rotation="-90">
|
||||
<path
|
||||
android:name="path_3"
|
||||
android:fillColor="#1e00d1"
|
||||
android:pathData="M 128 128 L 128 463.26 C 151.32 466.96 175.23 468.89 199.58 468.89 C 411.17 468.89 588.92 323.99 639.01 128 L 128 128 Z"
|
||||
android:strokeWidth="1" />
|
||||
</group>
|
||||
</group>
|
||||
<group
|
||||
android:name="group_6"
|
||||
android:pivotX="94"
|
||||
android:pivotY="440"
|
||||
android:rotation="-5"
|
||||
android:scaleX="1.2"
|
||||
android:scaleY="1.2" />
|
||||
</group>
|
||||
<group
|
||||
android:name="group_8"
|
||||
android:pivotX="94"
|
||||
android:pivotY="440"
|
||||
android:rotation="-90">
|
||||
<group
|
||||
android:name="group_14"
|
||||
android:pivotX="94"
|
||||
android:pivotY="440">
|
||||
<path
|
||||
android:name="path_4"
|
||||
android:fillColor="#2900da"
|
||||
android:pathData="M 539.28 128 C 503.71 317.07 337.72 460.12 138.31 460.12 C 134.86 460.12 131.42 460.06 128 459.98 L 128 465.73 C 168.23 476.19 210.43 481.78 253.93 481.78 C 409.53 481.78 548.48 410.55 640 298.94 L 640 128.01 L 539.28 128.01 Z"
|
||||
android:strokeWidth="1" />
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<group
|
||||
android:name="group_3"
|
||||
android:translateX="-360">
|
||||
<path
|
||||
android:name="path_6"
|
||||
android:fillColor="#1f1f30"
|
||||
android:pathData="M 481.82 384 C 481.82 438.03 438.02 481.82 384 481.82 L 0 481.82 L 0 286.18 L 384 286.18 C 438.02 286.18 481.82 329.98 481.82 384 Z"
|
||||
android:strokeWidth="1" />
|
||||
</group>
|
||||
<group
|
||||
android:name="group_4"
|
||||
android:pivotX="384"
|
||||
android:pivotY="384"
|
||||
android:scaleX="1.5"
|
||||
android:scaleY="1.5">
|
||||
<path
|
||||
android:name="path_5"
|
||||
android:fillColor="#1f1f30"
|
||||
android:pathData="M 44.26 128 C 44.26 174.25 81.75 211.74 128 211.74 L 384 211.74 C 479.13 211.74 556.26 288.86 556.26 384 C 556.26 479.13 479.14 556.26 384 556.26 L 128 556.26 C 81.76 556.26 44.28 593.73 44.26 639.97 L 768 639.97 L 768 128 L 44.26 128 Z"
|
||||
android:strokeWidth="1" />
|
||||
</group>
|
||||
<group
|
||||
android:name="group_5"
|
||||
android:pivotX="384"
|
||||
android:pivotY="384"
|
||||
android:rotation="-15"
|
||||
android:scaleX="3"
|
||||
android:scaleY="3">
|
||||
<path
|
||||
android:name="path_7"
|
||||
android:fillAlpha="0"
|
||||
android:fillColor="#efe7ff"
|
||||
android:pathData="M 442 366.7 L 365.98 322.81 C 352.66 315.12 336.02 324.73 336.02 340.11 L 336.02 427.89 C 336.02 443.27 352.67 452.88 365.98 445.19 L 442 401.3 C 455.32 393.61 455.32 374.39 442 366.7 Z"
|
||||
android:strokeWidth="1" />
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
</vector>
|
||||
</aapt:attr>
|
||||
<target android:name="wrapper">
|
||||
<aapt:attr name="android:animation">
|
||||
<set>
|
||||
<objectAnimator
|
||||
android:duration="500"
|
||||
android:interpolator="@android:anim/overshoot_interpolator"
|
||||
android:propertyName="scaleX"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="500"
|
||||
android:interpolator="@android:anim/overshoot_interpolator"
|
||||
android:propertyName="scaleY"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
</set>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_6">
|
||||
<aapt:attr name="android:animation">
|
||||
<set>
|
||||
<objectAnimator
|
||||
android:duration="550"
|
||||
android:interpolator="@android:anim/overshoot_interpolator"
|
||||
android:propertyName="rotation"
|
||||
android:startOffset="350"
|
||||
android:valueFrom="-10"
|
||||
android:valueTo="0"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="300"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="scaleX"
|
||||
android:startOffset="350"
|
||||
android:valueFrom="1.2"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="300"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="scaleY"
|
||||
android:startOffset="350"
|
||||
android:valueFrom="1.2"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
</set>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_3">
|
||||
<aapt:attr name="android:animation">
|
||||
<objectAnimator
|
||||
android:duration="400"
|
||||
android:interpolator="@android:anim/overshoot_interpolator"
|
||||
android:propertyName="translateX"
|
||||
android:startOffset="250"
|
||||
android:valueFrom="-360"
|
||||
android:valueTo="0"
|
||||
android:valueType="floatType" />
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_4">
|
||||
<aapt:attr name="android:animation">
|
||||
<set>
|
||||
<objectAnimator
|
||||
android:duration="350"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="scaleX"
|
||||
android:startOffset="400"
|
||||
android:valueFrom="1.5"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="350"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="scaleY"
|
||||
android:startOffset="400"
|
||||
android:valueFrom="1.5"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
</set>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="path_7">
|
||||
<aapt:attr name="android:animation">
|
||||
<objectAnimator
|
||||
android:duration="550"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="fillAlpha"
|
||||
android:startOffset="350"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_5">
|
||||
<aapt:attr name="android:animation">
|
||||
<set>
|
||||
<objectAnimator
|
||||
android:duration="550"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:propertyName="rotation"
|
||||
android:startOffset="350"
|
||||
android:valueFrom="-45"
|
||||
android:valueTo="0"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="550"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="scaleX"
|
||||
android:startOffset="350"
|
||||
android:valueFrom="3"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="550"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="scaleY"
|
||||
android:startOffset="350"
|
||||
android:valueFrom="3"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
</set>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_8">
|
||||
<aapt:attr name="android:animation">
|
||||
<objectAnimator
|
||||
android:duration="350"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="rotation"
|
||||
android:startOffset="100"
|
||||
android:valueFrom="-90"
|
||||
android:valueTo="0"
|
||||
android:valueType="floatType" />
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_9">
|
||||
<aapt:attr name="android:animation">
|
||||
<set>
|
||||
<objectAnimator
|
||||
android:duration="350"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="rotation"
|
||||
android:startOffset="100"
|
||||
android:valueFrom="-90"
|
||||
android:valueTo="0"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="350"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="scaleX"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="350"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="scaleY"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
</set>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_11">
|
||||
<aapt:attr name="android:animation">
|
||||
<objectAnimator
|
||||
android:duration="350"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||
android:propertyName="rotation"
|
||||
android:startOffset="100"
|
||||
android:valueFrom="-90"
|
||||
android:valueTo="0"
|
||||
android:valueType="floatType" />
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_12">
|
||||
<aapt:attr name="android:animation">
|
||||
<set>
|
||||
<objectAnimator
|
||||
android:duration="550"
|
||||
android:interpolator="@android:anim/overshoot_interpolator"
|
||||
android:propertyName="scaleX"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="550"
|
||||
android:interpolator="@android:anim/overshoot_interpolator"
|
||||
android:propertyName="scaleY"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
</set>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_13">
|
||||
<aapt:attr name="android:animation">
|
||||
<set>
|
||||
<objectAnimator
|
||||
android:duration="550"
|
||||
android:interpolator="@android:anim/overshoot_interpolator"
|
||||
android:propertyName="scaleX"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="550"
|
||||
android:interpolator="@android:anim/overshoot_interpolator"
|
||||
android:propertyName="scaleY"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="1"
|
||||
android:valueType="floatType" />
|
||||
</set>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
<target android:name="group_14">
|
||||
<aapt:attr name="android:animation">
|
||||
<set>
|
||||
<objectAnimator
|
||||
android:duration="200"
|
||||
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
|
||||
android:propertyName="rotation"
|
||||
android:startOffset="350"
|
||||
android:valueFrom="5"
|
||||
android:valueTo="0"
|
||||
android:valueType="floatType" />
|
||||
<objectAnimator
|
||||
android:duration="100"
|
||||
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
|
||||
android:propertyName="rotation"
|
||||
android:startOffset="250"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="5"
|
||||
android:valueType="floatType" />
|
||||
</set>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
</animated-vector>
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Dantotsu α</string>
|
||||
<string name="app_name">Dantotsu β</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,9 @@
|
||||
package ani.dantotsu.connections.crashlytics
|
||||
|
||||
class CrashlyticsFactory {
|
||||
companion object {
|
||||
fun createCrashlytics(): CrashlyticsInterface {
|
||||
return CrashlyticsStub()
|
||||
}
|
||||
}
|
||||
}
|
||||
40
app/src/fdroid/java/ani/dantotsu/others/AppUpdater.kt
Normal file
40
app/src/fdroid/java/ani/dantotsu/others/AppUpdater.kt
Normal file
@@ -0,0 +1,40 @@
|
||||
package ani.dantotsu.others
|
||||
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
||||
object AppUpdater {
|
||||
suspend fun check(activity: FragmentActivity, post: Boolean = false) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class GithubResponse(
|
||||
@SerialName("html_url")
|
||||
val htmlUrl: String,
|
||||
@SerialName("tag_name")
|
||||
val tagName: String,
|
||||
val prerelease: Boolean,
|
||||
@SerialName("created_at")
|
||||
val createdAt: String,
|
||||
val body: String? = null,
|
||||
val assets: List<Asset>? = null
|
||||
) {
|
||||
@Serializable
|
||||
data class Asset(
|
||||
@SerialName("browser_download_url")
|
||||
val browserDownloadURL: String
|
||||
)
|
||||
|
||||
fun timeStamp(): Long {
|
||||
return dateFormat.parse(createdAt)!!.time
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package ani.dantotsu.connections.crashlytics
|
||||
|
||||
class CrashlyticsFactory {
|
||||
companion object {
|
||||
fun createCrashlytics(): CrashlyticsInterface {
|
||||
return FirebaseCrashlytics()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package ani.dantotsu.connections.crashlytics
|
||||
|
||||
import android.content.Context
|
||||
import com.google.firebase.FirebaseApp
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||
import com.google.firebase.ktx.Firebase
|
||||
|
||||
class FirebaseCrashlytics : CrashlyticsInterface {
|
||||
override fun initialize(context: Context) {
|
||||
FirebaseApp.initializeApp(context)
|
||||
}
|
||||
|
||||
override fun logException(e: Throwable) {
|
||||
FirebaseCrashlytics.getInstance().recordException(e)
|
||||
}
|
||||
|
||||
override fun log(message: String) {
|
||||
FirebaseCrashlytics.getInstance().log(message)
|
||||
}
|
||||
|
||||
override fun setUserId(id: String) {
|
||||
Firebase.crashlytics.setUserId(id)
|
||||
}
|
||||
|
||||
override fun setCustomKey(key: String, value: String) {
|
||||
FirebaseCrashlytics.getInstance().setCustomKey(key, value)
|
||||
}
|
||||
|
||||
override fun setCrashlyticsCollectionEnabled(enabled: Boolean) {
|
||||
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(enabled)
|
||||
}
|
||||
|
||||
}
|
||||
289
app/src/google/java/ani/dantotsu/others/AppUpdater.kt
Normal file
289
app/src/google/java/ani/dantotsu/others/AppUpdater.kt
Normal file
@@ -0,0 +1,289 @@
|
||||
package ani.dantotsu.others
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.app.DownloadManager
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.net.Uri
|
||||
import android.os.Environment
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.getSystemService
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import ani.dantotsu.BuildConfig
|
||||
import ani.dantotsu.Mapper
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.buildMarkwon
|
||||
import ani.dantotsu.client
|
||||
import ani.dantotsu.connections.comments.CommentsAPI
|
||||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.decodeBase64ToString
|
||||
import ani.dantotsu.logError
|
||||
import ani.dantotsu.openLinkInBrowser
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.toast
|
||||
import ani.dantotsu.tryWithSuspend
|
||||
import ani.dantotsu.util.Logger
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonArray
|
||||
import kotlinx.serialization.json.decodeFromJsonElement
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
||||
object AppUpdater {
|
||||
private val fallbackStableUrl: String
|
||||
get() = "aHR0cHM6Ly9hcGkuZGFudG90c3UuYXBwL3VwZGF0ZXMvc3RhYmxl".decodeBase64ToString()
|
||||
private val fallbackBetaUrl: String
|
||||
get() = "aHR0cHM6Ly9hcGkuZGFudG90c3UuYXBwL3VwZGF0ZXMvYmV0YQ==".decodeBase64ToString()
|
||||
|
||||
@Serializable
|
||||
data class FallbackResponse(
|
||||
val version: String,
|
||||
val changelog: String,
|
||||
val downloadUrl: String? = null
|
||||
)
|
||||
|
||||
private suspend fun fetchUpdateInfo(repo: String, isDebug: Boolean): Pair<String, String>? {
|
||||
return try {
|
||||
fetchFromGithub(repo, isDebug)
|
||||
} catch (e: Exception) {
|
||||
Logger.log("Github fetch failed, trying fallback: ${e.message}")
|
||||
try {
|
||||
fetchFromFallback(isDebug)
|
||||
} catch (e: Exception) {
|
||||
Logger.log("Fallback fetch failed: ${e.message}")
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun fetchFromGithub(repo: String, isDebug: Boolean): Pair<String, String> {
|
||||
return if (isDebug) {
|
||||
val res = client.get("https://api.github.com/repos/$repo/releases")
|
||||
.parsed<JsonArray>().map {
|
||||
Mapper.json.decodeFromJsonElement<GithubResponse>(it)
|
||||
}
|
||||
val r = res.filter { it.prerelease }.filter { !it.tagName.contains("fdroid") }
|
||||
.maxByOrNull {
|
||||
it.timeStamp()
|
||||
} ?: throw Exception("No Pre Release Found")
|
||||
val v = r.tagName.substringAfter("v", "")
|
||||
(r.body ?: "") to v.ifEmpty { throw Exception("Weird Version : ${r.tagName}") }
|
||||
} else {
|
||||
val res = client.get("https://raw.githubusercontent.com/$repo/main/stable.md").text
|
||||
res to res.substringAfter("# ").substringBefore("\n")
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun fetchFromFallback(isDebug: Boolean): Pair<String, String> {
|
||||
val url = if (isDebug) fallbackBetaUrl else fallbackStableUrl
|
||||
val response = CommentsAPI.requestBuilder().get(url).parsed<FallbackResponse>()
|
||||
return response.changelog to response.version
|
||||
}
|
||||
|
||||
private suspend fun fetchApkUrl(repo: String, version: String, isDebug: Boolean): String? {
|
||||
return try {
|
||||
fetchApkUrlFromGithub(repo, version)
|
||||
} catch (e: Exception) {
|
||||
Logger.log("Github APK fetch failed, trying fallback: ${e.message}")
|
||||
try {
|
||||
fetchApkUrlFromFallback(version, isDebug)
|
||||
} catch (e: Exception) {
|
||||
Logger.log("Fallback APK fetch failed: ${e.message}")
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun fetchApkUrlFromGithub(repo: String, version: String): String? {
|
||||
val apks = client.get("https://api.github.com/repos/$repo/releases/tags/v$version")
|
||||
.parsed<GithubResponse>().assets?.filter {
|
||||
it.browserDownloadURL.endsWith(".apk")
|
||||
}
|
||||
return apks?.firstOrNull()?.browserDownloadURL
|
||||
}
|
||||
|
||||
private suspend fun fetchApkUrlFromFallback(version: String, isDebug: Boolean): String? {
|
||||
val url = if (isDebug) fallbackBetaUrl else fallbackStableUrl
|
||||
return CommentsAPI.requestBuilder().get("$url/$version").parsed<FallbackResponse>().downloadUrl
|
||||
}
|
||||
|
||||
suspend fun check(activity: FragmentActivity, post: Boolean = false) {
|
||||
if (post) snackString(currContext()?.getString(R.string.checking_for_update))
|
||||
val repo = activity.getString(R.string.repo)
|
||||
tryWithSuspend {
|
||||
val (md, version) = fetchUpdateInfo(repo, BuildConfig.DEBUG) ?: return@tryWithSuspend
|
||||
|
||||
Logger.log("Git Version : $version")
|
||||
val dontShow = PrefManager.getCustomVal("dont_ask_for_update_$version", false)
|
||||
if (compareVersion(version) && !dontShow && !activity.isDestroyed) activity.runOnUiThread {
|
||||
CustomBottomDialog.newInstance().apply {
|
||||
setTitleText(
|
||||
"${if (BuildConfig.DEBUG) "Beta " else ""}Update " + currContext()!!.getString(
|
||||
R.string.available
|
||||
)
|
||||
)
|
||||
addView(
|
||||
TextView(activity).apply {
|
||||
val markWon = try {
|
||||
buildMarkwon(activity, false)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
return@runOnUiThread
|
||||
}
|
||||
markWon.setMarkdown(this, md)
|
||||
}
|
||||
)
|
||||
|
||||
setCheck(
|
||||
currContext()!!.getString(R.string.dont_show_again, version),
|
||||
false
|
||||
) { isChecked ->
|
||||
if (isChecked) {
|
||||
PrefManager.setCustomVal("dont_ask_for_update_$version", true)
|
||||
}
|
||||
}
|
||||
setPositiveButton(currContext()!!.getString(R.string.lets_go)) {
|
||||
MainScope().launch(Dispatchers.IO) {
|
||||
try {
|
||||
val apkUrl = fetchApkUrl(repo, version, BuildConfig.DEBUG)
|
||||
if (apkUrl != null) {
|
||||
activity.downloadUpdate(version, apkUrl)
|
||||
} else {
|
||||
openLinkInBrowser("https://github.com/repos/$repo/releases/tag/v$version")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
logError(e)
|
||||
}
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
setNegativeButton(currContext()!!.getString(R.string.cope)) {
|
||||
dismiss()
|
||||
}
|
||||
show(activity.supportFragmentManager, "dialog")
|
||||
}
|
||||
} else {
|
||||
if (post) snackString(currContext()?.getString(R.string.no_update_found))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun compareVersion(version: String): Boolean {
|
||||
return when (BuildConfig.BUILD_TYPE) {
|
||||
"debug" -> BuildConfig.VERSION_NAME != version
|
||||
"alpha" -> false
|
||||
else -> {
|
||||
fun toDouble(list: List<String>): Double {
|
||||
return list.mapIndexed { i: Int, s: String ->
|
||||
when (i) {
|
||||
0 -> s.toDouble() * 100
|
||||
1 -> s.toDouble() * 10
|
||||
2 -> s.toDouble()
|
||||
else -> s.toDoubleOrNull() ?: 0.0
|
||||
}
|
||||
}.sum()
|
||||
}
|
||||
|
||||
val new = toDouble(version.split("."))
|
||||
val curr = toDouble(BuildConfig.VERSION_NAME.split("."))
|
||||
new > curr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Blatantly kanged from https://github.com/LagradOst/CloudStream-3/blob/master/app/src/main/java/com/lagradost/cloudstream3/utils/InAppUpdater.kt
|
||||
private fun Activity.downloadUpdate(version: String, url: String) {
|
||||
toast(getString(R.string.downloading_update, version))
|
||||
|
||||
val downloadManager = this.getSystemService<DownloadManager>()!!
|
||||
|
||||
val request = DownloadManager.Request(Uri.parse(url))
|
||||
.setMimeType("application/vnd.android.package-archive")
|
||||
.setTitle("Downloading Dantotsu $version")
|
||||
.setDestinationInExternalPublicDir(
|
||||
Environment.DIRECTORY_DOWNLOADS,
|
||||
"Dantotsu $version.apk"
|
||||
)
|
||||
.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI or DownloadManager.Request.NETWORK_MOBILE)
|
||||
.setAllowedOverRoaming(true)
|
||||
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||
|
||||
val id = try {
|
||||
downloadManager.enqueue(request)
|
||||
} catch (e: Exception) {
|
||||
logError(e)
|
||||
-1
|
||||
}
|
||||
if (id == -1L) return
|
||||
ContextCompat.registerReceiver(
|
||||
this,
|
||||
object : BroadcastReceiver() {
|
||||
@SuppressLint("Range")
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
try {
|
||||
val downloadId = intent?.getLongExtra(
|
||||
DownloadManager.EXTRA_DOWNLOAD_ID, id
|
||||
) ?: id
|
||||
|
||||
downloadManager.getUriForDownloadedFile(downloadId)?.let {
|
||||
openApk(this@downloadUpdate, it)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
logError(e)
|
||||
}
|
||||
}
|
||||
}, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE),
|
||||
ContextCompat.RECEIVER_EXPORTED
|
||||
)
|
||||
}
|
||||
|
||||
private fun openApk(context: Context, uri: Uri) {
|
||||
try {
|
||||
uri.path?.let {
|
||||
val installIntent = Intent(Intent.ACTION_VIEW).apply {
|
||||
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true)
|
||||
data = uri
|
||||
}
|
||||
context.startActivity(installIntent)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
logError(e)
|
||||
}
|
||||
}
|
||||
|
||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US)
|
||||
|
||||
@Serializable
|
||||
data class GithubResponse(
|
||||
@SerialName("html_url")
|
||||
val htmlUrl: String,
|
||||
@SerialName("tag_name")
|
||||
val tagName: String,
|
||||
val prerelease: Boolean,
|
||||
@SerialName("created_at")
|
||||
val createdAt: String,
|
||||
val body: String? = null,
|
||||
val assets: List<Asset>? = null
|
||||
) {
|
||||
@Serializable
|
||||
data class Asset(
|
||||
@SerialName("browser_download_url")
|
||||
val browserDownloadURL: String
|
||||
)
|
||||
|
||||
fun timeStamp(): Long {
|
||||
return dateFormat.parse(createdAt)!!.time
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,33 +2,56 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-sdk tools:overrideLibrary="go.server.gojni" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.software.leanback"
|
||||
android:required="false" />
|
||||
<uses-feature
|
||||
android:name="android.hardware.touchscreen"
|
||||
android:required="false" />
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission
|
||||
android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"
|
||||
tools:ignore="LeanbackUsesWifi" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="29"
|
||||
tools:ignore="ScopedStorage" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
|
||||
<!-- For background jobs -->
|
||||
android:maxSdkVersion="29" />
|
||||
<uses-permission
|
||||
android:name="android.permission.READ_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="32" /> <!-- For background jobs -->
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||
|
||||
<!-- For managing extensions -->
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> <!-- For managing extensions -->
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.UPDATE_PACKAGES_WITHOUT_USER_ACTION" />
|
||||
<!-- To view extension packages in API 30+ -->
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||
<uses-permission android:name="android.permission.UPDATE_PACKAGES_WITHOUT_USER_ACTION" /> <!-- To view extension packages in API 30+ -->
|
||||
<uses-permission
|
||||
android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||
tools:ignore="QueryAllPackagesPermission" />
|
||||
|
||||
<uses-permission android:name="android.permission.READ_APP_SPECIFIC_LOCALES"
|
||||
<uses-permission
|
||||
android:name="android.permission.READ_APP_SPECIFIC_LOCALES"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
|
||||
<!-- ExoPlayer: Bluetooth Headsets -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.bluetooth"
|
||||
android:required="false" />
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.BLUETOOTH"
|
||||
android:maxSdkVersion="30" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
<!-- ExoPlayer: Bluetooth Headsets -->
|
||||
|
||||
<queries>
|
||||
<package android:name="idm.internet.download.manager.plus" />
|
||||
<package android:name="idm.internet.download.manager" />
|
||||
@@ -39,53 +62,156 @@
|
||||
<application
|
||||
android:name=".App"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:banner="@mipmap/ic_banner_foreground"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
android:icon="${icon_placeholder}"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:roundIcon="${icon_placeholder_round}"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Dantotsu"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:ignore="AllowBackup"
|
||||
>
|
||||
tools:targetApi="tiramisu">
|
||||
|
||||
<receiver
|
||||
android:name=".widgets.upcoming.UpcomingWidget"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="android.appwidget.provider"
|
||||
android:resource="@xml/upcoming_widget_info" />
|
||||
</receiver>
|
||||
<activity
|
||||
android:name="ani.dantotsu.media.novel.novelreader.NovelReaderActivity"
|
||||
android:name=".widgets.upcoming.UpcomingWidgetConfigure"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<receiver
|
||||
android:name=".widgets.statistics.ProfileStatsWidget"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="android.appwidget.provider"
|
||||
android:resource="@xml/statistics_widget_info" />
|
||||
</receiver>
|
||||
<receiver android:name=".notifications.IncognitoNotificationClickReceiver" />
|
||||
|
||||
<activity
|
||||
android:name=".media.novel.novelreader.NovelReaderActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:exported="true" >
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:mimeType="application/epub+zip" />
|
||||
<data android:mimeType="application/epub+zip"/>
|
||||
<data android:mimeType="application/x-mobipocket-ebook" />
|
||||
<data android:mimeType="application/vnd.amazon.ebook" />
|
||||
<data android:mimeType="application/fb2+zip" />
|
||||
<data android:mimeType="application/vnd.comicbook+zip" />
|
||||
|
||||
<data android:pathPattern=".*\\.epub" />
|
||||
<data android:pathPattern=".*\\.mobi" />
|
||||
<data android:pathPattern=".*\\.kf8" />
|
||||
<data android:pathPattern=".*\\.fb2" />
|
||||
<data android:pathPattern=".*\\.cbz" />
|
||||
|
||||
<data android:scheme="content" />
|
||||
<data android:scheme="file" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".settings.FAQActivity" />
|
||||
<activity android:name=".settings.ReaderSettingsActivity" />
|
||||
<activity android:name=".others.calc.CalcActivity"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
<activity android:name=".settings.AnilistSettingsActivity"/>
|
||||
<activity android:name=".settings.UserInterfaceSettingsActivity" />
|
||||
<activity android:name=".settings.PlayerSettingsActivity" />
|
||||
<activity android:name=".settings.ReaderSettingsActivity" />
|
||||
<activity android:name=".settings.FAQActivity" />
|
||||
<activity
|
||||
android:name=".settings.SettingsActivity"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
<activity
|
||||
android:name=".settings.SettingsAboutActivity"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
<activity
|
||||
android:name=".home.status.StatusActivity"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
<activity
|
||||
android:name=".settings.SettingsAccountActivity"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
<activity
|
||||
android:name=".settings.SettingsAnimeActivity"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
<activity
|
||||
android:name=".settings.SettingsCommonActivity"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
<activity
|
||||
android:name=".settings.SettingsExtensionsActivity"
|
||||
android:parentActivityName=".MainActivity"
|
||||
android:windowSoftInputMode="adjustPan"/>
|
||||
<activity
|
||||
android:name=".settings.SettingsAddonActivity"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
<activity
|
||||
android:name=".settings.SettingsMangaActivity"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
<activity
|
||||
android:name=".settings.SettingsNotificationActivity"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
<activity
|
||||
android:name=".settings.SettingsThemeActivity"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
<activity
|
||||
android:name=".settings.ExtensionsActivity"
|
||||
android:parentActivityName=".MainActivity"
|
||||
android:windowSoftInputMode="adjustResize|stateHidden" />
|
||||
<activity
|
||||
android:name=".widgets.statistics.ProfileStatsConfigure"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".profile.ProfileActivity"
|
||||
android:parentActivityName=".MainActivity"
|
||||
android:windowSoftInputMode="adjustResize|stateHidden" />
|
||||
<activity
|
||||
android:name=".profile.FollowActivity"
|
||||
android:parentActivityName=".MainActivity"
|
||||
android:windowSoftInputMode="adjustResize|stateHidden" />
|
||||
<activity
|
||||
android:name=".profile.activity.FeedActivity"
|
||||
android:configChanges="orientation|screenSize|screenLayout"
|
||||
android:label="Inbox Activity"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
<activity
|
||||
android:name=".profile.notification.NotificationActivity"
|
||||
android:label="Inbox Activity"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
<activity
|
||||
android:name=".others.imagesearch.ImageSearchActivity"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
<activity
|
||||
android:name=".util.ActivityMarkdownCreator"
|
||||
android:windowSoftInputMode="adjustResize|stateVisible" />
|
||||
<activity android:name=".parsers.ParserTestActivity" />
|
||||
<activity
|
||||
android:name=".media.ReviewActivity"
|
||||
android:parentActivityName=".media.MediaDetailsActivity" />
|
||||
<activity
|
||||
android:name=".media.ReviewViewActivity"
|
||||
android:parentActivityName=".media.ReviewActivity" />
|
||||
<activity
|
||||
android:name=".media.SearchActivity"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
@@ -94,22 +220,34 @@
|
||||
<activity
|
||||
android:name=".media.CalendarActivity"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
<activity android:name="ani.dantotsu.media.user.ListActivity" />
|
||||
<activity android:name=".media.user.ListActivity" />
|
||||
<activity
|
||||
android:name="ani.dantotsu.media.manga.mangareader.MangaReaderActivity"
|
||||
android:name=".profile.SingleStatActivity"
|
||||
android:parentActivityName=".profile.ProfileActivity" />
|
||||
<activity
|
||||
android:name=".media.manga.mangareader.MangaReaderActivity"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="true"
|
||||
android:label="@string/manga"
|
||||
android:launchMode="singleTask" />
|
||||
<activity android:name=".media.GenreActivity" />
|
||||
<activity
|
||||
android:name=".media.MediaListViewActivity"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
<activity
|
||||
android:name=".media.MediaDetailsActivity"
|
||||
android:parentActivityName=".MainActivity"
|
||||
android:theme="@style/Theme.Dantotsu.NeverCutout" />
|
||||
android:theme="@style/Theme.Dantotsu.NeverCutout"
|
||||
android:windowSoftInputMode="adjustResize|stateHidden" />
|
||||
<activity android:name=".media.CharacterDetailsActivity" />
|
||||
<activity android:name=".home.NoInternet" />
|
||||
<activity android:name=".others.CrashActivity"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="true"
|
||||
android:process=":error_process"
|
||||
android:launchMode="singleTask" />
|
||||
<activity
|
||||
android:name="ani.dantotsu.media.anime.ExoplayerView"
|
||||
android:name=".media.anime.ExoplayerView"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="true"
|
||||
@@ -118,7 +256,7 @@
|
||||
android:supportsPictureInPicture="true"
|
||||
tools:targetApi="n" />
|
||||
<activity
|
||||
android:name="ani.dantotsu.connections.anilist.Login"
|
||||
android:name=".connections.anilist.Login"
|
||||
android:configChanges="orientation|screenSize|layoutDirection"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="true"
|
||||
@@ -135,7 +273,7 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="ani.dantotsu.connections.mal.Login"
|
||||
android:name=".connections.mal.Login"
|
||||
android:configChanges="orientation|screenSize|layoutDirection"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="true"
|
||||
@@ -151,8 +289,8 @@
|
||||
android:scheme="dantotsu" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name="ani.dantotsu.connections.discord.Login"
|
||||
<activity
|
||||
android:name=".connections.discord.Login"
|
||||
android:configChanges="orientation|screenSize|layoutDirection"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="true"
|
||||
@@ -163,15 +301,32 @@
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="dantotsu"/>
|
||||
<data android:scheme="dantotsu" />
|
||||
<data android:scheme="http" />
|
||||
<data android:scheme="https" />
|
||||
<data android:host="discord.dantotsu.com"/>
|
||||
<data android:host="discord.dantotsu.com" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="ani.dantotsu.connections.anilist.UrlMedia"
|
||||
android:name=".others.webview.CookieCatcher"
|
||||
android:configChanges="orientation|screenSize|layoutDirection"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTask">
|
||||
<intent-filter android:label="Discord Login for Dantotsu">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="dantotsu" />
|
||||
<data android:scheme="http" />
|
||||
<data android:scheme="https" />
|
||||
<data android:host="discord.dantotsu.com" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".connections.anilist.UrlMedia"
|
||||
android:configChanges="orientation|screenSize|layoutDirection"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="true"
|
||||
@@ -200,6 +355,17 @@
|
||||
<data android:host="myanimelist.net" />
|
||||
<data android:pathPrefix="/anime" />
|
||||
</intent-filter>
|
||||
<intent-filter android:label="@string/view_profile_in_dantotsu">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="http" />
|
||||
<data android:scheme="https" />
|
||||
<data android:host="anilist.co" />
|
||||
<data android:pathPrefix="/user" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
@@ -207,19 +373,53 @@
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.Main" />
|
||||
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:scheme="content" />
|
||||
<data android:scheme="file" />
|
||||
<data android:mimeType="*/*" />
|
||||
<data android:pathPattern=".*\\.ani" />
|
||||
<data android:pathPattern=".*\\.sani" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:host="add-repo"/>
|
||||
<data android:scheme="tachiyomi"/>
|
||||
<data android:scheme="aniyomi"/>
|
||||
<data android:scheme="novelyomi"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="eu.kanade.tachiyomi.extension.util.ExtensionInstallActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.AppCompat" />
|
||||
|
||||
<receiver
|
||||
android:name=".subcriptions.AlarmReceiver"
|
||||
android:name=".notifications.AlarmPermissionStateReceiver"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.app.action.SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver
|
||||
android:name=".notifications.BootCompletedReceiver"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="Aani.dantotsu.ACTION_ALARM"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver android:name=".notifications.anilist.AnilistNotificationReceiver" />
|
||||
<receiver android:name=".notifications.comment.CommentNotificationReceiver" />
|
||||
<receiver android:name=".notifications.subscription.SubscriptionNotificationReceiver" />
|
||||
|
||||
<meta-data
|
||||
android:name="preloaded_fonts"
|
||||
@@ -236,15 +436,43 @@
|
||||
android:resource="@xml/provider_paths" />
|
||||
</provider>
|
||||
|
||||
<service android:name=".download.video.MyDownloadService"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="androidx.media3.exoplayer.downloadService.action.RESTART"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service android:name=".aniyomi.anime.util.AnimeExtensionInstallService"
|
||||
android:exported="false" />
|
||||
<service
|
||||
android:name=".widgets.upcoming.UpcomingRemoteViewsService"
|
||||
android:exported="true"
|
||||
android:permission="android.permission.BIND_REMOTEVIEWS" />
|
||||
<service
|
||||
android:name="eu.kanade.tachiyomi.extension.util.ExtensionInstallService"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="dataSync" />
|
||||
<service
|
||||
android:name=".download.manga.MangaDownloaderService"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="dataSync" />
|
||||
<service
|
||||
android:name=".download.novel.NovelDownloaderService"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="dataSync" />
|
||||
<service
|
||||
android:name=".download.anime.AnimeDownloaderService"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="dataSync" />
|
||||
<service
|
||||
android:name=".connections.discord.DiscordService"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="dataSync" />
|
||||
<service
|
||||
android:name="androidx.media3.exoplayer.scheduler.PlatformScheduler$PlatformSchedulerService"
|
||||
android:exported="true"
|
||||
android:permission="android.permission.BIND_JOB_SERVICE" />
|
||||
<service
|
||||
android:name=".addons.torrent.TorrentServerService"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="dataSync"
|
||||
android:stopWithTask="true" />
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
|
||||
android:value="androidx.media3.cast.DefaultCastOptionsProvider" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
BIN
app/src/main/ic_launcher-playstore.png
Normal file
BIN
app/src/main/ic_launcher-playstore.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
BIN
app/src/main/ic_launcher_alpha-playstore.png
Normal file
BIN
app/src/main/ic_launcher_alpha-playstore.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
BIN
app/src/main/ic_launcher_beta-playstore.png
Normal file
BIN
app/src/main/ic_launcher_beta-playstore.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -4,22 +4,52 @@ import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.multidex.MultiDex
|
||||
import androidx.multidex.MultiDexApplication
|
||||
import ani.dantotsu.addons.download.DownloadAddonManager
|
||||
import ani.dantotsu.addons.torrent.TorrentAddonManager
|
||||
import ani.dantotsu.aniyomi.anime.custom.AppModule
|
||||
import ani.dantotsu.aniyomi.anime.custom.PreferenceModule
|
||||
import ani.dantotsu.aniyomi.data.Notifications
|
||||
import ani.dantotsu.aniyomi.util.logcat
|
||||
import ani.dantotsu.connections.comments.CommentsAPI
|
||||
import ani.dantotsu.connections.crashlytics.CrashlyticsInterface
|
||||
import ani.dantotsu.notifications.TaskScheduler
|
||||
import ani.dantotsu.others.DisabledReports
|
||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||
import com.google.firebase.ktx.Firebase
|
||||
import ani.dantotsu.parsers.AnimeSources
|
||||
import ani.dantotsu.parsers.MangaSources
|
||||
import ani.dantotsu.parsers.NovelSources
|
||||
import ani.dantotsu.parsers.novel.NovelExtensionManager
|
||||
import ani.dantotsu.settings.SettingsActivity
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.util.FinalExceptionHandler
|
||||
import ani.dantotsu.util.Logger
|
||||
import com.google.android.material.color.DynamicColors
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import eu.kanade.tachiyomi.extension.anime.AnimeExtensionManager
|
||||
import eu.kanade.tachiyomi.extension.manga.MangaExtensionManager
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.launch
|
||||
import logcat.AndroidLogcatLogger
|
||||
import logcat.LogPriority
|
||||
import logcat.LogcatLogger
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.addSingletonFactory
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
class App : MultiDexApplication() {
|
||||
private lateinit var animeExtensionManager: AnimeExtensionManager
|
||||
private lateinit var mangaExtensionManager: MangaExtensionManager
|
||||
private lateinit var novelExtensionManager: NovelExtensionManager
|
||||
private lateinit var torrentAddonManager: TorrentAddonManager
|
||||
private lateinit var downloadAddonManager: DownloadAddonManager
|
||||
|
||||
override fun attachBaseContext(base: Context?) {
|
||||
super.attachBaseContext(base)
|
||||
MultiDex.install(this)
|
||||
@@ -31,34 +61,119 @@ class App : MultiDexApplication() {
|
||||
|
||||
val mFTActivityLifecycleCallbacks = FTActivityLifecycleCallbacks()
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
registerActivityLifecycleCallbacks(mFTActivityLifecycleCallbacks)
|
||||
PrefManager.init(this)
|
||||
|
||||
Firebase.crashlytics.setCrashlyticsCollectionEnabled(!DisabledReports)
|
||||
initializeNetwork(baseContext)
|
||||
val crashlytics =
|
||||
ani.dantotsu.connections.crashlytics.CrashlyticsFactory.createCrashlytics()
|
||||
Injekt.addSingletonFactory<CrashlyticsInterface> { crashlytics }
|
||||
crashlytics.initialize(this)
|
||||
Logger.init(this)
|
||||
Thread.setDefaultUncaughtExceptionHandler(FinalExceptionHandler())
|
||||
Logger.log(Log.WARN, "App: Logging started")
|
||||
|
||||
Injekt.importModule(AppModule(this))
|
||||
Injekt.importModule(PreferenceModule(this))
|
||||
|
||||
|
||||
val useMaterialYou: Boolean = PrefManager.getVal(PrefName.UseMaterialYou)
|
||||
if (useMaterialYou) {
|
||||
DynamicColors.applyToActivitiesIfAvailable(this)
|
||||
}
|
||||
registerActivityLifecycleCallbacks(mFTActivityLifecycleCallbacks)
|
||||
|
||||
crashlytics.setCrashlyticsCollectionEnabled(!DisabledReports)
|
||||
(PrefManager.getVal(PrefName.SharedUserID) as Boolean).let {
|
||||
if (!it) return@let
|
||||
val dUsername = PrefManager.getVal(PrefName.DiscordUserName, null as String?)
|
||||
val aUsername = PrefManager.getVal(PrefName.AnilistUserName, null as String?)
|
||||
if (dUsername != null) {
|
||||
crashlytics.setCustomKey("dUsername", dUsername)
|
||||
}
|
||||
if (aUsername != null) {
|
||||
crashlytics.setCustomKey("aUsername", aUsername)
|
||||
}
|
||||
}
|
||||
crashlytics.setCustomKey("device Info", SettingsActivity.getDeviceInfo())
|
||||
|
||||
initializeNetwork()
|
||||
|
||||
setupNotificationChannels()
|
||||
if (!LogcatLogger.isInstalled) {
|
||||
LogcatLogger.install(AndroidLogcatLogger(LogPriority.VERBOSE))
|
||||
}
|
||||
|
||||
if (PrefManager.getVal<Int>(PrefName.CommentsEnabled) == 0) {
|
||||
if (BuildConfig.FLAVOR.contains("fdroid")) {
|
||||
PrefManager.setVal(PrefName.CommentsEnabled, 2)
|
||||
} else {
|
||||
PrefManager.setVal(PrefName.CommentsEnabled, 1)
|
||||
}
|
||||
}
|
||||
|
||||
val scope = CoroutineScope(Dispatchers.IO)
|
||||
scope.launch {
|
||||
animeExtensionManager = Injekt.get()
|
||||
launch {
|
||||
animeExtensionManager.findAvailableExtensions()
|
||||
}
|
||||
Logger.log("Anime Extensions: ${animeExtensionManager.installedExtensionsFlow.first()}")
|
||||
AnimeSources.init(animeExtensionManager.installedExtensionsFlow)
|
||||
}
|
||||
scope.launch {
|
||||
mangaExtensionManager = Injekt.get()
|
||||
launch {
|
||||
mangaExtensionManager.findAvailableExtensions()
|
||||
}
|
||||
Logger.log("Manga Extensions: ${mangaExtensionManager.installedExtensionsFlow.first()}")
|
||||
MangaSources.init(mangaExtensionManager.installedExtensionsFlow)
|
||||
}
|
||||
scope.launch {
|
||||
novelExtensionManager = Injekt.get()
|
||||
launch {
|
||||
novelExtensionManager.findAvailableExtensions()
|
||||
}
|
||||
Logger.log("Novel Extensions: ${novelExtensionManager.installedExtensionsFlow.first()}")
|
||||
NovelSources.init(novelExtensionManager.installedExtensionsFlow)
|
||||
}
|
||||
GlobalScope.launch {
|
||||
torrentAddonManager = Injekt.get()
|
||||
downloadAddonManager = Injekt.get()
|
||||
torrentAddonManager.init()
|
||||
downloadAddonManager.init()
|
||||
if (PrefManager.getVal<Int>(PrefName.CommentsEnabled) == 1) {
|
||||
CommentsAPI.fetchAuthToken(this@App)
|
||||
}
|
||||
|
||||
val useAlarmManager = PrefManager.getVal<Boolean>(PrefName.UseAlarmManager)
|
||||
val scheduler = TaskScheduler.create(this@App, useAlarmManager)
|
||||
try {
|
||||
scheduler.scheduleAllTasks(this@App)
|
||||
} catch (e: IllegalStateException) {
|
||||
Logger.log("Failed to schedule tasks")
|
||||
Logger.log(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupNotificationChannels() {
|
||||
try {
|
||||
Notifications.createChannels(this)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e) { "Failed to modify notification channels" }
|
||||
Logger.log("Failed to modify notification channels")
|
||||
Logger.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
inner class FTActivityLifecycleCallbacks : ActivityLifecycleCallbacks {
|
||||
var currentActivity: Activity? = null
|
||||
override fun onActivityCreated(p0: Activity, p1: Bundle?) {}
|
||||
var lastActivity: String? = null
|
||||
override fun onActivityCreated(p0: Activity, p1: Bundle?) {
|
||||
lastActivity = p0.javaClass.simpleName
|
||||
}
|
||||
|
||||
override fun onActivityStarted(p0: Activity) {
|
||||
currentActivity = p0
|
||||
}
|
||||
@@ -74,8 +189,12 @@ class App : MultiDexApplication() {
|
||||
}
|
||||
|
||||
companion object {
|
||||
private var instance: App? = null
|
||||
var context : Context? = null
|
||||
var instance: App? = null
|
||||
|
||||
/** Reference to the application context.
|
||||
*
|
||||
* USE WITH EXTREME CAUTION!**/
|
||||
var context: Context? = null
|
||||
fun currentContext(): Context? {
|
||||
return instance?.mFTActivityLifecycleCallbacks?.currentActivity ?: context
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,11 @@
|
||||
package ani.dantotsu
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.drawable.Animatable
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
@@ -15,19 +18,26 @@ import android.view.animation.AnticipateInterpolator
|
||||
import android.widget.TextView
|
||||
import androidx.activity.addCallback
|
||||
import androidx.activity.viewModels
|
||||
import androidx.annotation.OptIn
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.animation.doOnEnd
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.doOnAttach
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.core.view.updateMargins
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.media3.common.util.UnstableApi
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
import ani.dantotsu.aniyomi.anime.AnimeExtensionManager
|
||||
import ani.dantotsu.addons.torrent.TorrentAddonManager
|
||||
import ani.dantotsu.addons.torrent.TorrentServerService
|
||||
import ani.dantotsu.connections.anilist.Anilist
|
||||
import ani.dantotsu.connections.anilist.AnilistHomeViewModel
|
||||
import ani.dantotsu.databinding.ActivityMainBinding
|
||||
import ani.dantotsu.databinding.DialogUserAgentBinding
|
||||
import ani.dantotsu.databinding.SplashScreenBinding
|
||||
import ani.dantotsu.home.AnimeFragment
|
||||
import ani.dantotsu.home.HomeFragment
|
||||
@@ -35,183 +45,501 @@ import ani.dantotsu.home.LoginFragment
|
||||
import ani.dantotsu.home.MangaFragment
|
||||
import ani.dantotsu.home.NoInternet
|
||||
import ani.dantotsu.media.MediaDetailsActivity
|
||||
import ani.dantotsu.notifications.TaskScheduler
|
||||
import ani.dantotsu.others.CustomBottomDialog
|
||||
import ani.dantotsu.parsers.AnimeSources
|
||||
import ani.dantotsu.settings.UserInterfaceSettings
|
||||
import ani.dantotsu.subcriptions.Subscription.Companion.startSubscription
|
||||
import ani.dantotsu.others.calc.CalcActivity
|
||||
import ani.dantotsu.profile.ProfileActivity
|
||||
import ani.dantotsu.profile.activity.FeedActivity
|
||||
import ani.dantotsu.profile.notification.NotificationActivity
|
||||
import ani.dantotsu.settings.AddRepositoryBottomSheet
|
||||
import ani.dantotsu.settings.ExtensionsActivity
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefManager.asLiveBool
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.settings.saving.SharedPreferenceBooleanLiveData
|
||||
import ani.dantotsu.settings.saving.internal.PreferenceKeystore
|
||||
import ani.dantotsu.settings.saving.internal.PreferencePackager
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.util.AudioHelper
|
||||
import ani.dantotsu.util.Logger
|
||||
import ani.dantotsu.util.customAlertDialog
|
||||
import com.google.android.material.snackbar.BaseTransientBottomBar
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import io.noties.markwon.Markwon
|
||||
import io.noties.markwon.SoftBreakAddsNewLinePlugin
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import nl.joery.animatedbottombar.AnimatedBottomBar
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import tachiyomi.core.util.lang.launchIO
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.io.Serializable
|
||||
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityMainBinding
|
||||
private lateinit var incognitoLiveData: SharedPreferenceBooleanLiveData
|
||||
private val scope = lifecycleScope
|
||||
private var load = false
|
||||
|
||||
private var uiSettings = UserInterfaceSettings()
|
||||
private val animeExtensionManager: AnimeExtensionManager by injectLazy()
|
||||
|
||||
@kotlin.OptIn(DelicateCoroutinesApi::class)
|
||||
@SuppressLint("InternalInsetResource", "DiscouragedApi")
|
||||
@OptIn(UnstableApi::class)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
ThemeManager(this).applyTheme()
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
//get FRAGMENT_CLASS_NAME from intent
|
||||
val fragment = intent.getStringExtra("FRAGMENT_CLASS_NAME")
|
||||
|
||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
val myScope = CoroutineScope(Dispatchers.Default)
|
||||
myScope.launch {
|
||||
animeExtensionManager.findAvailableExtensions()
|
||||
AnimeSources.init(animeExtensionManager.installedExtensionsFlow)
|
||||
|
||||
TaskScheduler.scheduleSingleWork(this)
|
||||
if (!CalcActivity.hasPermission) {
|
||||
val pin: String = PrefManager.getVal(PrefName.AppPassword)
|
||||
if (pin.isNotEmpty()) {
|
||||
ContextCompat.startActivity(
|
||||
this@MainActivity,
|
||||
Intent(this@MainActivity, CalcActivity::class.java)
|
||||
.putExtra("code", pin)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK),
|
||||
null
|
||||
)
|
||||
finish()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (Intent.ACTION_VIEW == intent.action) {
|
||||
handleViewIntent(intent)
|
||||
}
|
||||
|
||||
val bottomNavBar = findViewById<AnimatedBottomBar>(R.id.navbar)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
|
||||
val backgroundDrawable = bottomNavBar.background as GradientDrawable
|
||||
val currentColor = backgroundDrawable.color?.defaultColor ?: 0
|
||||
val semiTransparentColor = (currentColor and 0x00FFFFFF) or 0xF9000000.toInt()
|
||||
backgroundDrawable.setColor(semiTransparentColor)
|
||||
bottomNavBar.background = backgroundDrawable
|
||||
}
|
||||
bottomNavBar.background = ContextCompat.getDrawable(this, R.drawable.bottom_nav_gray)
|
||||
|
||||
val offset = try {
|
||||
val statusBarHeightId = resources.getIdentifier("status_bar_height", "dimen", "android")
|
||||
resources.getDimensionPixelSize(statusBarHeightId)
|
||||
} catch (e: Exception) {
|
||||
statusBarHeight
|
||||
}
|
||||
val layoutParams = binding.incognito.layoutParams as ViewGroup.MarginLayoutParams
|
||||
layoutParams.topMargin = 11 * offset / 12
|
||||
binding.incognito.layoutParams = layoutParams
|
||||
incognitoLiveData = PrefManager.getLiveVal(
|
||||
PrefName.Incognito,
|
||||
false
|
||||
).asLiveBool()
|
||||
incognitoLiveData.observe(this) {
|
||||
if (it) {
|
||||
val slideDownAnim = ObjectAnimator.ofFloat(
|
||||
binding.incognito,
|
||||
View.TRANSLATION_Y,
|
||||
-(binding.incognito.height.toFloat() + statusBarHeight),
|
||||
0f
|
||||
)
|
||||
slideDownAnim.duration = 200
|
||||
slideDownAnim.start()
|
||||
binding.incognito.visibility = View.VISIBLE
|
||||
} else {
|
||||
val slideUpAnim = ObjectAnimator.ofFloat(
|
||||
binding.incognito,
|
||||
View.TRANSLATION_Y,
|
||||
0f,
|
||||
-(binding.incognito.height.toFloat() + statusBarHeight)
|
||||
)
|
||||
slideUpAnim.duration = 200
|
||||
slideUpAnim.start()
|
||||
//wait for animation to finish
|
||||
Handler(Looper.getMainLooper()).postDelayed(
|
||||
{ binding.incognito.visibility = View.GONE },
|
||||
200
|
||||
)
|
||||
}
|
||||
}
|
||||
incognitoNotification(this)
|
||||
|
||||
var doubleBackToExitPressedOnce = false
|
||||
onBackPressedDispatcher.addCallback(this) {
|
||||
if (doubleBackToExitPressedOnce) {
|
||||
finish()
|
||||
}
|
||||
doubleBackToExitPressedOnce = true
|
||||
snackString(this@MainActivity.getString(R.string.back_to_exit))
|
||||
Handler(Looper.getMainLooper()).postDelayed(
|
||||
{ doubleBackToExitPressedOnce = false },
|
||||
2000
|
||||
)
|
||||
snackString(this@MainActivity.getString(R.string.back_to_exit)).apply {
|
||||
this?.addCallback(object : BaseTransientBottomBar.BaseCallback<Snackbar>() {
|
||||
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
|
||||
super.onDismissed(transientBottomBar, event)
|
||||
doubleBackToExitPressedOnce = false
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
binding.root.isMotionEventSplittingEnabled = false
|
||||
|
||||
lifecycleScope.launch {
|
||||
val splash = SplashScreenBinding.inflate(layoutInflater)
|
||||
binding.root.addView(splash.root)
|
||||
(splash.splashImage.drawable as Animatable).start()
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
|
||||
val splash = SplashScreenBinding.inflate(layoutInflater)
|
||||
binding.root.addView(splash.root)
|
||||
(splash.splashImage.drawable as Animatable).start()
|
||||
|
||||
// Wait for 2 seconds (2000 milliseconds)
|
||||
delay(2000)
|
||||
delay(1200)
|
||||
|
||||
// Now perform the animation
|
||||
ObjectAnimator.ofFloat(
|
||||
splash.root,
|
||||
View.TRANSLATION_Y,
|
||||
0f,
|
||||
-splash.root.height.toFloat()
|
||||
).apply {
|
||||
interpolator = AnticipateInterpolator()
|
||||
duration = 200L
|
||||
doOnEnd { binding.root.removeView(splash.root) }
|
||||
start()
|
||||
ObjectAnimator.ofFloat(
|
||||
splash.root,
|
||||
View.TRANSLATION_Y,
|
||||
0f,
|
||||
-splash.root.height.toFloat()
|
||||
).apply {
|
||||
interpolator = AnticipateInterpolator()
|
||||
duration = 200L
|
||||
doOnEnd { binding.root.removeView(splash.root) }
|
||||
start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
splashScreen.setOnExitAnimationListener { splashScreenView ->
|
||||
ObjectAnimator.ofFloat(
|
||||
splashScreenView,
|
||||
View.TRANSLATION_Y,
|
||||
0f,
|
||||
-splashScreenView.height.toFloat()
|
||||
).apply {
|
||||
interpolator = AnticipateInterpolator()
|
||||
duration = 200L
|
||||
doOnEnd { splashScreenView.remove() }
|
||||
start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
binding.root.doOnAttach {
|
||||
initActivity(this)
|
||||
uiSettings = loadData("ui_settings") ?: uiSettings
|
||||
selectedOption = uiSettings.defaultStartUpTab
|
||||
binding.navbarContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
val preferences: SourcePreferences = Injekt.get()
|
||||
if (preferences.animeExtensionUpdatesCount()
|
||||
.get() > 0 || preferences.mangaExtensionUpdatesCount().get() > 0
|
||||
) {
|
||||
snackString(R.string.extension_updates_available)
|
||||
?.setDuration(Snackbar.LENGTH_SHORT)
|
||||
?.setAction(R.string.review) {
|
||||
startActivity(Intent(this, ExtensionsActivity::class.java))
|
||||
}
|
||||
}
|
||||
window.navigationBarColor = ContextCompat.getColor(this, android.R.color.transparent)
|
||||
selectedOption = if (fragment != null) {
|
||||
when (fragment) {
|
||||
AnimeFragment::class.java.name -> 0
|
||||
HomeFragment::class.java.name -> 1
|
||||
MangaFragment::class.java.name -> 2
|
||||
else -> 1
|
||||
}
|
||||
} else {
|
||||
PrefManager.getVal(PrefName.DefaultStartUpTab)
|
||||
}
|
||||
val navbar = binding.includedNavbar.navbar
|
||||
bottomBar = navbar
|
||||
navbar.visibility = View.VISIBLE
|
||||
binding.mainProgressBar.visibility = View.GONE
|
||||
val mainViewPager = binding.viewpager
|
||||
mainViewPager.isUserInputEnabled = false
|
||||
mainViewPager.adapter =
|
||||
ViewPagerAdapter(supportFragmentManager, lifecycle)
|
||||
mainViewPager.setPageTransformer(ZoomOutPageTransformer())
|
||||
navbar.selectTabAt(selectedOption)
|
||||
navbar.setOnTabSelectListener(object :
|
||||
AnimatedBottomBar.OnTabSelectListener {
|
||||
override fun onTabSelected(
|
||||
lastIndex: Int,
|
||||
lastTab: AnimatedBottomBar.Tab?,
|
||||
newIndex: Int,
|
||||
newTab: AnimatedBottomBar.Tab
|
||||
) {
|
||||
navbar.animate().translationZ(12f).setDuration(200).start()
|
||||
selectedOption = newIndex
|
||||
mainViewPager.setCurrentItem(newIndex, false)
|
||||
}
|
||||
})
|
||||
if (mainViewPager.currentItem != selectedOption) {
|
||||
mainViewPager.post {
|
||||
mainViewPager.setCurrentItem(
|
||||
selectedOption,
|
||||
false
|
||||
)
|
||||
}
|
||||
}
|
||||
binding.includedNavbar.navbarContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = navBarHeight
|
||||
}
|
||||
}
|
||||
|
||||
var launched = false
|
||||
intent.extras?.let { extras ->
|
||||
val fragmentToLoad = extras.getString("FRAGMENT_TO_LOAD")
|
||||
val mediaId = extras.getInt("mediaId", -1)
|
||||
val commentId = extras.getInt("commentId", -1)
|
||||
val activityId = extras.getInt("activityId", -1)
|
||||
|
||||
if (fragmentToLoad != null && mediaId != -1 && commentId != -1) {
|
||||
val detailIntent = Intent(this, MediaDetailsActivity::class.java).apply {
|
||||
putExtra("FRAGMENT_TO_LOAD", fragmentToLoad)
|
||||
putExtra("mediaId", mediaId)
|
||||
putExtra("commentId", commentId)
|
||||
}
|
||||
launched = true
|
||||
startActivity(detailIntent)
|
||||
} else if (fragmentToLoad == "FEED" && activityId != -1) {
|
||||
val feedIntent = Intent(this, FeedActivity::class.java).apply {
|
||||
putExtra("FRAGMENT_TO_LOAD", "NOTIFICATIONS")
|
||||
putExtra("activityId", activityId)
|
||||
|
||||
}
|
||||
launched = true
|
||||
startActivity(feedIntent)
|
||||
} else if (fragmentToLoad == "NOTIFICATIONS" && activityId != -1) {
|
||||
Logger.log("MainActivity, onCreate: $activityId")
|
||||
val notificationIntent = Intent(this, NotificationActivity::class.java).apply {
|
||||
putExtra("activityId", activityId)
|
||||
}
|
||||
launched = true
|
||||
startActivity(notificationIntent)
|
||||
}
|
||||
}
|
||||
val offlineMode: Boolean = PrefManager.getVal(PrefName.OfflineMode)
|
||||
if (!isOnline(this)) {
|
||||
snackString(this@MainActivity.getString(R.string.no_internet_connection))
|
||||
startActivity(Intent(this, NoInternet::class.java))
|
||||
} else {
|
||||
val model: AnilistHomeViewModel by viewModels()
|
||||
model.genres.observe(this) {
|
||||
if (it != null) {
|
||||
if (it) {
|
||||
val navbar = binding.navbar
|
||||
bottomBar = navbar
|
||||
navbar.visibility = View.VISIBLE
|
||||
binding.mainProgressBar.visibility = View.GONE
|
||||
val mainViewPager = binding.viewpager
|
||||
mainViewPager.isUserInputEnabled = false
|
||||
mainViewPager.adapter = ViewPagerAdapter(supportFragmentManager, lifecycle)
|
||||
mainViewPager.setPageTransformer(ZoomOutPageTransformer(uiSettings))
|
||||
navbar.setOnTabSelectListener(object :
|
||||
AnimatedBottomBar.OnTabSelectListener {
|
||||
override fun onTabSelected(
|
||||
lastIndex: Int,
|
||||
lastTab: AnimatedBottomBar.Tab?,
|
||||
newIndex: Int,
|
||||
newTab: AnimatedBottomBar.Tab
|
||||
) {
|
||||
navbar.animate().translationZ(12f).setDuration(200).start()
|
||||
selectedOption = newIndex
|
||||
mainViewPager.setCurrentItem(newIndex, false)
|
||||
if (offlineMode) {
|
||||
snackString(this@MainActivity.getString(R.string.no_internet_connection))
|
||||
startActivity(Intent(this, NoInternet::class.java))
|
||||
} else {
|
||||
val model: AnilistHomeViewModel by viewModels()
|
||||
|
||||
//Load Data
|
||||
if (!load && !launched) {
|
||||
scope.launch(Dispatchers.IO) {
|
||||
model.loadMain(this@MainActivity)
|
||||
val id = intent.extras?.getInt("mediaId", 0)
|
||||
val isMAL = intent.extras?.getBoolean("mal") ?: false
|
||||
val cont = intent.extras?.getBoolean("continue") ?: false
|
||||
if (id != null && id != 0) {
|
||||
val media = withContext(Dispatchers.IO) {
|
||||
Anilist.query.getMedia(id, isMAL)
|
||||
}
|
||||
})
|
||||
navbar.selectTabAt(selectedOption)
|
||||
mainViewPager.post { mainViewPager.setCurrentItem(selectedOption, false) }
|
||||
} else {
|
||||
binding.mainProgressBar.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
//Load Data
|
||||
if (!load) {
|
||||
scope.launch(Dispatchers.IO) {
|
||||
model.loadMain(this@MainActivity)
|
||||
val id = intent.extras?.getInt("mediaId", 0)
|
||||
val isMAL = intent.extras?.getBoolean("mal") ?: false
|
||||
val cont = intent.extras?.getBoolean("continue") ?: false
|
||||
if (id != null && id != 0) {
|
||||
val media = withContext(Dispatchers.IO) {
|
||||
Anilist.query.getMedia(id, isMAL)
|
||||
}
|
||||
if (media != null) {
|
||||
media.cameFromContinue = cont
|
||||
startActivity(
|
||||
Intent(this@MainActivity, MediaDetailsActivity::class.java)
|
||||
.putExtra("media", media as Serializable)
|
||||
)
|
||||
} else {
|
||||
snackString(this@MainActivity.getString(R.string.anilist_not_found))
|
||||
}
|
||||
}
|
||||
delay(500)
|
||||
startSubscription()
|
||||
}
|
||||
load = true
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
if (loadData<Boolean>("allow_opening_links", this) != true) {
|
||||
CustomBottomDialog.newInstance().apply {
|
||||
title = "Allow Dantotsu to automatically open Anilist & MAL Links?"
|
||||
val md = "Open settings & click +Add Links & select Anilist & Mal urls"
|
||||
addView(TextView(this@MainActivity).apply {
|
||||
val markWon =
|
||||
Markwon.builder(this@MainActivity)
|
||||
.usePlugin(SoftBreakAddsNewLinePlugin.create()).build()
|
||||
markWon.setMarkdown(this, md)
|
||||
})
|
||||
|
||||
setNegativeButton(this@MainActivity.getString(R.string.no)) {
|
||||
saveData("allow_opening_links", true, this@MainActivity)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
setPositiveButton(this@MainActivity.getString(R.string.yes)) {
|
||||
saveData("allow_opening_links", true, this@MainActivity)
|
||||
tryWith(true) {
|
||||
if (media != null) {
|
||||
media.cameFromContinue = cont
|
||||
startActivity(
|
||||
Intent(Settings.ACTION_APP_OPEN_BY_DEFAULT_SETTINGS)
|
||||
.setData(Uri.parse("package:$packageName"))
|
||||
Intent(this@MainActivity, MediaDetailsActivity::class.java)
|
||||
.putExtra("media", media as Serializable)
|
||||
)
|
||||
} else {
|
||||
snackString(this@MainActivity.getString(R.string.anilist_not_found))
|
||||
}
|
||||
}
|
||||
val username = intent.extras?.getString("username")
|
||||
if (username != null) {
|
||||
val nameInt = username.toIntOrNull()
|
||||
if (nameInt != null) {
|
||||
startActivity(
|
||||
Intent(this@MainActivity, ProfileActivity::class.java)
|
||||
.putExtra("userId", nameInt)
|
||||
)
|
||||
} else {
|
||||
startActivity(
|
||||
Intent(this@MainActivity, ProfileActivity::class.java)
|
||||
.putExtra("username", username)
|
||||
)
|
||||
}
|
||||
}
|
||||
}.show(supportFragmentManager, "dialog")
|
||||
}
|
||||
load = true
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
if (!(PrefManager.getVal(PrefName.AllowOpeningLinks) as Boolean)) {
|
||||
CustomBottomDialog.newInstance().apply {
|
||||
title = "Allow Dantotsu to automatically open Anilist & MAL Links?"
|
||||
val md = "Open settings & click +Add Links & select Anilist & Mal urls"
|
||||
addView(TextView(this@MainActivity).apply {
|
||||
val markWon =
|
||||
Markwon.builder(this@MainActivity)
|
||||
.usePlugin(SoftBreakAddsNewLinePlugin.create()).build()
|
||||
markWon.setMarkdown(this, md)
|
||||
})
|
||||
|
||||
setNegativeButton(this@MainActivity.getString(R.string.no)) {
|
||||
PrefManager.setVal(PrefName.AllowOpeningLinks, true)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
setPositiveButton(this@MainActivity.getString(R.string.yes)) {
|
||||
PrefManager.setVal(PrefName.AllowOpeningLinks, true)
|
||||
tryWith(true) {
|
||||
startActivity(
|
||||
Intent(Settings.ACTION_APP_OPEN_BY_DEFAULT_SETTINGS)
|
||||
.setData(Uri.parse("package:$packageName"))
|
||||
)
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
}.show(supportFragmentManager, "dialog")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (PrefManager.getVal(PrefName.OC)) {
|
||||
AudioHelper.run(this, R.raw.audio)
|
||||
PrefManager.setVal(PrefName.OC, false)
|
||||
}
|
||||
val torrentManager = Injekt.get<TorrentAddonManager>()
|
||||
fun startTorrent() {
|
||||
if (torrentManager.isAvailable() && PrefManager.getVal(PrefName.TorrentEnabled)) {
|
||||
launchIO {
|
||||
if (!TorrentServerService.isRunning()) {
|
||||
TorrentServerService.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (torrentManager.isInitialized.value == false) {
|
||||
torrentManager.isInitialized.observe(this) {
|
||||
if (it) {
|
||||
startTorrent()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
startTorrent()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRestart() {
|
||||
super.onRestart()
|
||||
window.navigationBarColor = ContextCompat.getColor(this, android.R.color.transparent)
|
||||
}
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
val margin = if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) 8 else 32
|
||||
val params: ViewGroup.MarginLayoutParams =
|
||||
binding.includedNavbar.navbar.layoutParams as ViewGroup.MarginLayoutParams
|
||||
params.updateMargins(bottom = margin.toPx)
|
||||
}
|
||||
|
||||
private fun handleViewIntent(intent: Intent) {
|
||||
val uri: Uri? = intent.data
|
||||
try {
|
||||
if (uri == null) {
|
||||
throw Exception("Uri is null")
|
||||
}
|
||||
if ((uri.scheme == "tachiyomi" || uri.scheme == "aniyomi" || uri.scheme == "novelyomi") && uri.host == "add-repo") {
|
||||
val url = uri.getQueryParameter("url") ?: throw Exception("No url for repo import")
|
||||
val (prefName, name) = when (uri.scheme) {
|
||||
"tachiyomi" -> PrefName.MangaExtensionRepos to "Manga"
|
||||
"aniyomi" -> PrefName.AnimeExtensionRepos to "Anime"
|
||||
"novelyomi" -> PrefName.NovelExtensionRepos to "Novel"
|
||||
else -> throw Exception("Invalid scheme")
|
||||
}
|
||||
val savedRepos: Set<String> = PrefManager.getVal(prefName)
|
||||
val newRepos = savedRepos.toMutableSet()
|
||||
AddRepositoryBottomSheet.addRepoWarning(this) {
|
||||
newRepos.add(url)
|
||||
PrefManager.setVal(prefName, newRepos)
|
||||
toast("$name Extension Repo added")
|
||||
}
|
||||
return
|
||||
}
|
||||
if (intent.type == null) return
|
||||
val jsonString =
|
||||
contentResolver.openInputStream(uri)?.readBytes()
|
||||
?: throw Exception("Error reading file")
|
||||
val name =
|
||||
DocumentFile.fromSingleUri(this, uri)?.name ?: "settings"
|
||||
//.sani is encrypted, .ani is not
|
||||
if (name.endsWith(".sani")) {
|
||||
passwordAlertDialog { password ->
|
||||
if (password != null) {
|
||||
val salt = jsonString.copyOfRange(0, 16)
|
||||
val encrypted = jsonString.copyOfRange(16, jsonString.size)
|
||||
val decryptedJson = try {
|
||||
PreferenceKeystore.decryptWithPassword(
|
||||
password,
|
||||
encrypted,
|
||||
salt
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
toast("Incorrect password")
|
||||
return@passwordAlertDialog
|
||||
}
|
||||
if (PreferencePackager.unpack(decryptedJson)) {
|
||||
val newIntent = Intent(this, this.javaClass)
|
||||
this.finish()
|
||||
startActivity(newIntent)
|
||||
}
|
||||
} else {
|
||||
toast("Password cannot be empty")
|
||||
}
|
||||
}
|
||||
} else if (name.endsWith(".ani")) {
|
||||
val decryptedJson = jsonString.toString(Charsets.UTF_8)
|
||||
if (PreferencePackager.unpack(decryptedJson)) {
|
||||
val newIntent = Intent(this, this.javaClass)
|
||||
this.finish()
|
||||
startActivity(newIntent)
|
||||
}
|
||||
} else {
|
||||
toast("Invalid file type")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
toast("Error importing settings")
|
||||
}
|
||||
}
|
||||
|
||||
private fun passwordAlertDialog(callback: (CharArray?) -> Unit) {
|
||||
val password = CharArray(16).apply { fill('0') }
|
||||
|
||||
// Inflate the dialog layout
|
||||
val dialogView = DialogUserAgentBinding.inflate(layoutInflater).apply {
|
||||
userAgentTextBox.hint = "Password"
|
||||
subtitle.visibility = View.VISIBLE
|
||||
subtitle.text = getString(R.string.enter_password_to_decrypt_file)
|
||||
}
|
||||
customAlertDialog().apply {
|
||||
setTitle("Enter Password")
|
||||
setCustomView(dialogView.root)
|
||||
setPosButton(R.string.yes) {
|
||||
val editText = dialogView.userAgentTextBox
|
||||
if (editText.text?.isNotBlank() == true) {
|
||||
editText.text?.toString()?.trim()?.toCharArray(password)
|
||||
callback(password)
|
||||
} else {
|
||||
toast("Password cannot be empty")
|
||||
}
|
||||
}
|
||||
setNegButton(R.string.cancel) {
|
||||
password.fill('0')
|
||||
callback(null)
|
||||
}
|
||||
show()
|
||||
}
|
||||
}
|
||||
|
||||
//ViewPager
|
||||
|
||||
@@ -1,65 +1,59 @@
|
||||
package ani.dantotsu
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import ani.dantotsu.others.webview.CloudFlare
|
||||
import ani.dantotsu.others.webview.WebViewBottomDialog
|
||||
import ani.dantotsu.util.Logger
|
||||
import com.lagradost.nicehttp.Requests
|
||||
import com.lagradost.nicehttp.ResponseParser
|
||||
import com.lagradost.nicehttp.addGenericDns
|
||||
import kotlinx.coroutines.*
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper.Companion.defaultUserAgentProvider
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.InternalSerializationApi
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.serializer
|
||||
import okhttp3.Cache
|
||||
import okhttp3.OkHttpClient
|
||||
import java.io.File
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.io.PrintWriter
|
||||
import java.io.Serializable
|
||||
import java.io.StringWriter
|
||||
import java.util.concurrent.*
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.KFunction
|
||||
|
||||
val defaultHeaders = mapOf(
|
||||
"User-Agent" to
|
||||
"Mozilla/5.0 (Linux; Android %s; %s) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Mobile Safari/537.36"
|
||||
.format(Build.VERSION.RELEASE, Build.MODEL)
|
||||
)
|
||||
lateinit var cache: Cache
|
||||
lateinit var defaultHeaders: Map<String, String>
|
||||
|
||||
lateinit var okHttpClient: OkHttpClient
|
||||
lateinit var client: Requests
|
||||
|
||||
fun initializeNetwork(context: Context) {
|
||||
val dns = loadData<Int>("settings_dns")
|
||||
cache = Cache(
|
||||
File(context.cacheDir, "http_cache"),
|
||||
5 * 1024L * 1024L // 5 MiB
|
||||
fun initializeNetwork() {
|
||||
|
||||
val networkHelper = Injekt.get<NetworkHelper>()
|
||||
|
||||
defaultHeaders = mapOf(
|
||||
"User-Agent" to
|
||||
defaultUserAgentProvider()
|
||||
.format(Build.VERSION.RELEASE, Build.MODEL)
|
||||
)
|
||||
okHttpClient = OkHttpClient.Builder()
|
||||
.followRedirects(true)
|
||||
.followSslRedirects(true)
|
||||
.cache(cache)
|
||||
.apply {
|
||||
when (dns) {
|
||||
1 -> addGoogleDns()
|
||||
2 -> addCloudFlareDns()
|
||||
3 -> addAdGuardDns()
|
||||
}
|
||||
}
|
||||
.build()
|
||||
|
||||
okHttpClient = networkHelper.client
|
||||
client = Requests(
|
||||
okHttpClient,
|
||||
networkHelper.client,
|
||||
defaultHeaders,
|
||||
defaultCacheTime = 6,
|
||||
defaultCacheTimeUnit = TimeUnit.HOURS,
|
||||
responseParser = Mapper
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
object Mapper : ResponseParser {
|
||||
@@ -111,6 +105,7 @@ fun logError(e: Throwable, post: Boolean = true, snackbar: Boolean = true) {
|
||||
toast(e.localizedMessage)
|
||||
}
|
||||
e.printStackTrace()
|
||||
Logger.log(e)
|
||||
}
|
||||
|
||||
fun <T> tryWith(post: Boolean = false, snackbar: Boolean = true, call: () -> T): T? {
|
||||
@@ -122,7 +117,11 @@ fun <T> tryWith(post: Boolean = false, snackbar: Boolean = true, call: () -> T):
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun <T> tryWithSuspend(post: Boolean = false, snackbar: Boolean = true, call: suspend () -> T): T? {
|
||||
suspend fun <T> tryWithSuspend(
|
||||
post: Boolean = false,
|
||||
snackbar: Boolean = true,
|
||||
call: suspend () -> T
|
||||
): T? {
|
||||
return try {
|
||||
call.invoke()
|
||||
} catch (e: Throwable) {
|
||||
@@ -137,13 +136,15 @@ suspend fun <T> tryWithSuspend(post: Boolean = false, snackbar: Boolean = true,
|
||||
* A url, which can also have headers
|
||||
* **/
|
||||
data class FileUrl(
|
||||
val url: String,
|
||||
val headers: Map<String, String> = mapOf()
|
||||
var url: String,
|
||||
var headers: Map<String, String> = mapOf()
|
||||
) : Serializable {
|
||||
companion object {
|
||||
operator fun get(url: String?, headers: Map<String, String> = mapOf()): FileUrl? {
|
||||
return FileUrl(url ?: return null, headers)
|
||||
}
|
||||
|
||||
private const val serialVersionUID = 1L
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,28 +203,29 @@ fun OkHttpClient.Builder.addAdGuardDns() = (
|
||||
|
||||
@Suppress("BlockingMethodInNonBlockingContext")
|
||||
suspend fun webViewInterface(webViewDialog: WebViewBottomDialog): Map<String, String>? {
|
||||
var map : Map<String,String>? = null
|
||||
var map: Map<String, String>? = null
|
||||
|
||||
val latch = CountDownLatch(1)
|
||||
webViewDialog.callback = {
|
||||
map = it
|
||||
latch.countDown()
|
||||
}
|
||||
val fragmentManager = (currContext() as FragmentActivity?)?.supportFragmentManager ?: return null
|
||||
val fragmentManager =
|
||||
(currContext() as FragmentActivity?)?.supportFragmentManager ?: return null
|
||||
webViewDialog.show(fragmentManager, "web-view")
|
||||
delay(0)
|
||||
latch.await(2,TimeUnit.MINUTES)
|
||||
latch.await(2, TimeUnit.MINUTES)
|
||||
return map
|
||||
}
|
||||
|
||||
suspend fun webViewInterface(type: String, url: FileUrl): Map<String, String>? {
|
||||
val webViewDialog: WebViewBottomDialog = when (type) {
|
||||
"Cloudflare" -> CloudFlare.newInstance(url)
|
||||
else -> return null
|
||||
else -> return null
|
||||
}
|
||||
return webViewInterface(webViewDialog)
|
||||
}
|
||||
|
||||
suspend fun webViewInterface(type: String, url: String): Map<String, String>? {
|
||||
return webViewInterface(type,FileUrl(url))
|
||||
return webViewInterface(type, FileUrl(url))
|
||||
}
|
||||
15
app/src/main/java/ani/dantotsu/addons/Addon.kt
Normal file
15
app/src/main/java/ani/dantotsu/addons/Addon.kt
Normal file
@@ -0,0 +1,15 @@
|
||||
package ani.dantotsu.addons
|
||||
|
||||
abstract class Addon {
|
||||
abstract val name: String
|
||||
abstract val pkgName: String
|
||||
abstract val versionName: String
|
||||
abstract val versionCode: Long
|
||||
|
||||
abstract class Installed(
|
||||
override val name: String,
|
||||
override val pkgName: String,
|
||||
override val versionName: String,
|
||||
override val versionCode: Long,
|
||||
) : Addon()
|
||||
}
|
||||
128
app/src/main/java/ani/dantotsu/addons/AddonDownloader.kt
Normal file
128
app/src/main/java/ani/dantotsu/addons/AddonDownloader.kt
Normal file
@@ -0,0 +1,128 @@
|
||||
package ani.dantotsu.addons
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import ani.dantotsu.Mapper
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.client
|
||||
import ani.dantotsu.logError
|
||||
import ani.dantotsu.openLinkInBrowser
|
||||
import ani.dantotsu.others.AppUpdater
|
||||
import ani.dantotsu.settings.InstallerSteps
|
||||
import ani.dantotsu.toast
|
||||
import ani.dantotsu.util.Logger
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.serialization.json.JsonArray
|
||||
import kotlinx.serialization.json.decodeFromJsonElement
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
|
||||
class AddonDownloader {
|
||||
companion object {
|
||||
private suspend fun check(repo: String): Pair<String, String> {
|
||||
return try {
|
||||
val res = client.get("https://api.github.com/repos/$repo/releases")
|
||||
.parsed<JsonArray>().map {
|
||||
Mapper.json.decodeFromJsonElement<AppUpdater.GithubResponse>(it)
|
||||
}
|
||||
val r = res.maxByOrNull {
|
||||
it.timeStamp()
|
||||
} ?: throw Exception("No Pre Release Found")
|
||||
val v = r.tagName.substringAfter("v", "")
|
||||
val md = r.body ?: ""
|
||||
val version = v.ifEmpty { throw Exception("Weird Version : ${r.tagName}") }
|
||||
|
||||
Logger.log("Git Version for $repo: $version")
|
||||
Pair(md, version)
|
||||
} catch (e: Exception) {
|
||||
Logger.log("Error checking for update")
|
||||
Logger.log(e)
|
||||
Pair("", "")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun hasUpdate(repo: String, currentVersion: String): Boolean {
|
||||
val (_, version) = check(repo)
|
||||
return compareVersion(version, currentVersion)
|
||||
}
|
||||
|
||||
suspend fun update(
|
||||
activity: Activity,
|
||||
manager: AddonManager<*>,
|
||||
repo: String,
|
||||
currentVersion: String
|
||||
) {
|
||||
val (_, version) = check(repo)
|
||||
if (!compareVersion(version, currentVersion)) {
|
||||
toast(activity.getString(R.string.no_update_found))
|
||||
return
|
||||
}
|
||||
MainScope().launch(Dispatchers.IO) {
|
||||
try {
|
||||
val apks =
|
||||
client.get("https://api.github.com/repos/$repo/releases/tags/v$version")
|
||||
.parsed<AppUpdater.GithubResponse>().assets?.filter {
|
||||
it.browserDownloadURL.endsWith(
|
||||
".apk"
|
||||
)
|
||||
}
|
||||
val apkToDownload =
|
||||
apks?.find { it.browserDownloadURL.contains(getCurrentABI()) }
|
||||
?: apks?.find { it.browserDownloadURL.contains("universal") }
|
||||
?: apks?.first()
|
||||
apkToDownload?.browserDownloadURL.apply {
|
||||
if (this != null) {
|
||||
val notificationManager =
|
||||
activity.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
val installerSteps = InstallerSteps(notificationManager, activity)
|
||||
manager.install(this)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{ installStep -> installerSteps.onInstallStep(installStep) {} },
|
||||
{ error -> installerSteps.onError(error) {} },
|
||||
{ installerSteps.onComplete {} }
|
||||
)
|
||||
} else openLinkInBrowser("https://github.com/repos/$repo/releases/tag/v$version")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
logError(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ABI that the app is most likely running on.
|
||||
* @return The primary ABI for the device.
|
||||
*/
|
||||
private fun getCurrentABI(): String {
|
||||
return if (Build.SUPPORTED_ABIS.isNotEmpty()) {
|
||||
Build.SUPPORTED_ABIS[0]
|
||||
} else "Unknown"
|
||||
}
|
||||
|
||||
private fun compareVersion(newVersion: String, oldVersion: String): Boolean {
|
||||
fun toDouble(list: List<String>): Double {
|
||||
return try {
|
||||
list.mapIndexed { i: Int, s: String ->
|
||||
when (i) {
|
||||
0 -> s.toDouble() * 100
|
||||
1 -> s.toDouble() * 10
|
||||
2 -> s.toDouble()
|
||||
else -> s.toDoubleOrNull() ?: 0.0
|
||||
}
|
||||
}.sum()
|
||||
} catch (e: NumberFormatException) {
|
||||
0.0
|
||||
}
|
||||
}
|
||||
|
||||
val new = toDouble(newVersion.split("."))
|
||||
val curr = toDouble(oldVersion.split("."))
|
||||
return new > curr
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
131
app/src/main/java/ani/dantotsu/addons/AddonInstallReceiver.kt
Normal file
131
app/src/main/java/ani/dantotsu/addons/AddonInstallReceiver.kt
Normal file
@@ -0,0 +1,131 @@
|
||||
package ani.dantotsu.addons
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.core.content.ContextCompat
|
||||
import ani.dantotsu.addons.download.DownloadAddonManager
|
||||
import ani.dantotsu.addons.torrent.TorrentAddonManager
|
||||
import ani.dantotsu.media.AddonType
|
||||
import eu.kanade.tachiyomi.extension.util.ExtensionInstallReceiver
|
||||
import eu.kanade.tachiyomi.extension.util.ExtensionInstallReceiver.Companion.filter
|
||||
import eu.kanade.tachiyomi.extension.util.ExtensionInstallReceiver.Companion.getPackageNameFromIntent
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import tachiyomi.core.util.lang.launchNow
|
||||
|
||||
internal class AddonInstallReceiver : BroadcastReceiver() {
|
||||
private var listener: AddonListener? = null
|
||||
private var type: AddonType? = null
|
||||
|
||||
/**
|
||||
* Registers this broadcast receiver
|
||||
*/
|
||||
fun register(context: Context) {
|
||||
ContextCompat.registerReceiver(context, this, filter, ContextCompat.RECEIVER_EXPORTED)
|
||||
}
|
||||
|
||||
fun setListener(listener: AddonListener, type: AddonType): AddonInstallReceiver {
|
||||
this.listener = listener
|
||||
this.type = type
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when one of the events of the [filter] is received. When the package is an extension,
|
||||
* it's loaded in background and it notifies the [listener] when finished.
|
||||
*/
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
override fun onReceive(context: Context, intent: Intent?) {
|
||||
if (intent == null) return
|
||||
|
||||
when (intent.action) {
|
||||
Intent.ACTION_PACKAGE_ADDED -> {
|
||||
if (ExtensionInstallReceiver.isReplacing(intent)) return
|
||||
launchNow {
|
||||
when (type) {
|
||||
AddonType.DOWNLOAD -> {
|
||||
getPackageNameFromIntent(intent)?.let { packageName ->
|
||||
if (packageName != DownloadAddonManager.DOWNLOAD_PACKAGE) return@launchNow
|
||||
listener?.onAddonInstalled(
|
||||
AddonLoader.loadFromPkgName(
|
||||
context,
|
||||
packageName,
|
||||
AddonType.DOWNLOAD
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
AddonType.TORRENT -> {
|
||||
getPackageNameFromIntent(intent)?.let { packageName ->
|
||||
if (packageName != TorrentAddonManager.TORRENT_PACKAGE) return@launchNow
|
||||
listener?.onAddonInstalled(
|
||||
AddonLoader.loadFromPkgName(
|
||||
context,
|
||||
packageName,
|
||||
AddonType.TORRENT
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Intent.ACTION_PACKAGE_REPLACED -> {
|
||||
launchNow {
|
||||
when (type) {
|
||||
AddonType.DOWNLOAD -> {
|
||||
getPackageNameFromIntent(intent)?.let { packageName ->
|
||||
if (packageName != DownloadAddonManager.DOWNLOAD_PACKAGE) return@launchNow
|
||||
listener?.onAddonUpdated(
|
||||
AddonLoader.loadFromPkgName(
|
||||
context,
|
||||
packageName,
|
||||
AddonType.DOWNLOAD
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
AddonType.TORRENT -> {
|
||||
getPackageNameFromIntent(intent)?.let { packageName ->
|
||||
if (packageName != TorrentAddonManager.TORRENT_PACKAGE) return@launchNow
|
||||
listener?.onAddonUpdated(
|
||||
AddonLoader.loadFromPkgName(
|
||||
context,
|
||||
packageName,
|
||||
AddonType.TORRENT
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Intent.ACTION_PACKAGE_REMOVED -> {
|
||||
if (ExtensionInstallReceiver.isReplacing(intent)) return
|
||||
getPackageNameFromIntent(intent)?.let { packageName ->
|
||||
when (type) {
|
||||
AddonType.DOWNLOAD -> {
|
||||
if (packageName != DownloadAddonManager.DOWNLOAD_PACKAGE) return
|
||||
listener?.onAddonUninstalled(packageName)
|
||||
}
|
||||
|
||||
AddonType.TORRENT -> {
|
||||
if (packageName != TorrentAddonManager.TORRENT_PACKAGE) return
|
||||
listener?.onAddonUninstalled(packageName)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
app/src/main/java/ani/dantotsu/addons/AddonListener.kt
Normal file
11
app/src/main/java/ani/dantotsu/addons/AddonListener.kt
Normal file
@@ -0,0 +1,11 @@
|
||||
package ani.dantotsu.addons
|
||||
|
||||
interface AddonListener {
|
||||
fun onAddonInstalled(result: LoadResult?)
|
||||
fun onAddonUpdated(result: LoadResult?)
|
||||
fun onAddonUninstalled(pkgName: String)
|
||||
|
||||
enum class ListenerAction {
|
||||
INSTALL, UPDATE, UNINSTALL
|
||||
}
|
||||
}
|
||||
176
app/src/main/java/ani/dantotsu/addons/AddonLoader.kt
Normal file
176
app/src/main/java/ani/dantotsu/addons/AddonLoader.kt
Normal file
@@ -0,0 +1,176 @@
|
||||
package ani.dantotsu.addons
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import androidx.core.content.pm.PackageInfoCompat
|
||||
import ani.dantotsu.addons.download.DownloadAddon
|
||||
import ani.dantotsu.addons.download.DownloadAddonApiV2
|
||||
import ani.dantotsu.addons.download.DownloadAddonManager
|
||||
import ani.dantotsu.addons.download.DownloadLoadResult
|
||||
import ani.dantotsu.addons.torrent.TorrentAddon
|
||||
import ani.dantotsu.addons.torrent.TorrentAddonApi
|
||||
import ani.dantotsu.addons.torrent.TorrentAddonManager
|
||||
import ani.dantotsu.addons.torrent.TorrentLoadResult
|
||||
import ani.dantotsu.media.AddonType
|
||||
import ani.dantotsu.util.Logger
|
||||
import dalvik.system.PathClassLoader
|
||||
import eu.kanade.tachiyomi.extension.util.ExtensionLoader
|
||||
import eu.kanade.tachiyomi.util.system.getApplicationIcon
|
||||
|
||||
class AddonLoader {
|
||||
companion object {
|
||||
|
||||
/**
|
||||
* Load an extension from a package name with a specific class name
|
||||
* @param context the context
|
||||
* @param packageName the package name of the extension
|
||||
* @param type the type of extension
|
||||
* @return the loaded extension
|
||||
* @throws IllegalStateException if the extension is not of the correct type
|
||||
* @throws ClassNotFoundException if the extension class is not found
|
||||
* @throws NoClassDefFoundError if the extension class is not found
|
||||
* @throws Exception if any other error occurs
|
||||
* @throws PackageManager.NameNotFoundException if the package is not found
|
||||
* @throws IllegalStateException if the extension is not found
|
||||
*/
|
||||
fun loadExtension(
|
||||
context: Context,
|
||||
packageName: String,
|
||||
className: String,
|
||||
type: AddonType
|
||||
): LoadResult? {
|
||||
val pkgManager = context.packageManager
|
||||
|
||||
val installedPkgs = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
pkgManager.getInstalledPackages(PackageManager.PackageInfoFlags.of(ExtensionLoader.PACKAGE_FLAGS.toLong()))
|
||||
} else {
|
||||
pkgManager.getInstalledPackages(ExtensionLoader.PACKAGE_FLAGS)
|
||||
}
|
||||
|
||||
val extPkgs = installedPkgs.filter {
|
||||
isPackageAnExtension(
|
||||
packageName,
|
||||
it
|
||||
)
|
||||
}
|
||||
|
||||
if (extPkgs.isEmpty()) return null
|
||||
if (extPkgs.size > 1) throw IllegalStateException("Multiple extensions with the same package name found")
|
||||
|
||||
val pkgName = extPkgs.first().packageName
|
||||
val pkgInfo = extPkgs.first()
|
||||
|
||||
val appInfo = try {
|
||||
pkgManager.getApplicationInfo(pkgName, PackageManager.GET_META_DATA)
|
||||
} catch (error: PackageManager.NameNotFoundException) {
|
||||
// Unlikely, but the package may have been uninstalled at this point
|
||||
Logger.log(error)
|
||||
throw error
|
||||
}
|
||||
|
||||
val extName =
|
||||
pkgManager.getApplicationLabel(appInfo).toString().substringAfter("Dantotsu: ")
|
||||
val versionName = pkgInfo.versionName
|
||||
val versionCode = PackageInfoCompat.getLongVersionCode(pkgInfo)
|
||||
|
||||
if (versionName.isNullOrEmpty()) {
|
||||
Logger.log("Missing versionName for extension $extName")
|
||||
throw IllegalStateException("Missing versionName for extension $extName")
|
||||
}
|
||||
val classLoader =
|
||||
PathClassLoader(appInfo.sourceDir, appInfo.nativeLibraryDir, context.classLoader)
|
||||
val loadedClass = try {
|
||||
Class.forName(className, false, classLoader)
|
||||
} catch (e: ClassNotFoundException) {
|
||||
Logger.log("ClassNotFoundException load error: $extName ($className)")
|
||||
Logger.log(e)
|
||||
throw e
|
||||
} catch (e: NoClassDefFoundError) {
|
||||
Logger.log("NoClassDefFoundError load error: $extName ($className)")
|
||||
Logger.log(e)
|
||||
throw e
|
||||
} catch (e: Exception) {
|
||||
Logger.log("Extension load error: $extName ($className)")
|
||||
Logger.log(e)
|
||||
throw e
|
||||
}
|
||||
val instance = loadedClass.getDeclaredConstructor().newInstance()
|
||||
|
||||
return when (type) {
|
||||
AddonType.TORRENT -> {
|
||||
val extension = instance as? TorrentAddonApi
|
||||
?: throw IllegalStateException("Extension is not a TorrentAddonApi")
|
||||
TorrentLoadResult.Success(
|
||||
TorrentAddon.Installed(
|
||||
name = extName,
|
||||
pkgName = pkgName,
|
||||
versionName = versionName,
|
||||
versionCode = versionCode,
|
||||
extension = extension,
|
||||
icon = context.getApplicationIcon(pkgName),
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
AddonType.DOWNLOAD -> {
|
||||
val extension = instance as? DownloadAddonApiV2
|
||||
?: throw IllegalStateException("Extension is not a DownloadAddonApiV2")
|
||||
DownloadLoadResult.Success(
|
||||
DownloadAddon.Installed(
|
||||
name = extName,
|
||||
pkgName = pkgName,
|
||||
versionName = versionName,
|
||||
versionCode = versionCode,
|
||||
extension = extension,
|
||||
icon = context.getApplicationIcon(pkgName),
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an extension from a package name (class is determined by type)
|
||||
* @param context the context
|
||||
* @param packageName the package name of the extension
|
||||
* @param type the type of extension
|
||||
* @return the loaded extension
|
||||
*/
|
||||
fun loadFromPkgName(context: Context, packageName: String, type: AddonType): LoadResult? {
|
||||
return try {
|
||||
when (type) {
|
||||
AddonType.TORRENT -> loadExtension(
|
||||
context,
|
||||
packageName,
|
||||
TorrentAddonManager.TORRENT_CLASS,
|
||||
type
|
||||
)
|
||||
|
||||
AddonType.DOWNLOAD -> loadExtension(
|
||||
context,
|
||||
packageName,
|
||||
DownloadAddonManager.DOWNLOAD_CLASS,
|
||||
type
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Logger.log("Error loading extension from package name: $packageName")
|
||||
Logger.log(e)
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a package is an extension by comparing the package name
|
||||
* @param type the type of extension
|
||||
* @param pkgInfo the package info
|
||||
* @return true if the package is an extension
|
||||
*/
|
||||
private fun isPackageAnExtension(type: String, pkgInfo: PackageInfo): Boolean {
|
||||
return pkgInfo.packageName.equals(type)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
46
app/src/main/java/ani/dantotsu/addons/AddonManager.kt
Normal file
46
app/src/main/java/ani/dantotsu/addons/AddonManager.kt
Normal file
@@ -0,0 +1,46 @@
|
||||
package ani.dantotsu.addons
|
||||
|
||||
import android.content.Context
|
||||
import ani.dantotsu.media.AddonType
|
||||
import eu.kanade.tachiyomi.extension.InstallStep
|
||||
import eu.kanade.tachiyomi.extension.util.ExtensionInstaller
|
||||
import rx.Observable
|
||||
|
||||
abstract class AddonManager<T : Addon.Installed>(
|
||||
private val context: Context
|
||||
) {
|
||||
abstract var extension: T?
|
||||
abstract var name: String
|
||||
abstract var type: AddonType
|
||||
protected val installer by lazy { ExtensionInstaller(context) }
|
||||
var hasUpdate: Boolean = false
|
||||
protected set
|
||||
|
||||
protected var onListenerAction: ((AddonListener.ListenerAction) -> Unit)? = null
|
||||
|
||||
abstract suspend fun init()
|
||||
abstract fun isAvailable(andEnabled: Boolean = true): Boolean
|
||||
abstract fun getVersion(): String?
|
||||
abstract fun getPackageName(): String?
|
||||
abstract fun hadError(context: Context): String?
|
||||
abstract fun updateInstallStep(id: Long, step: InstallStep)
|
||||
abstract fun setInstalling(id: Long)
|
||||
|
||||
fun uninstall() {
|
||||
getPackageName()?.let {
|
||||
installer.uninstallApk(it)
|
||||
}
|
||||
}
|
||||
|
||||
fun addListenerAction(action: (AddonListener.ListenerAction) -> Unit) {
|
||||
onListenerAction = action
|
||||
}
|
||||
|
||||
fun removeListenerAction() {
|
||||
onListenerAction = null
|
||||
}
|
||||
|
||||
fun install(url: String): Observable<InstallStep> {
|
||||
return installer.downloadAndInstall(url, getPackageName() ?: "", name, type)
|
||||
}
|
||||
}
|
||||
8
app/src/main/java/ani/dantotsu/addons/LoadResult.kt
Normal file
8
app/src/main/java/ani/dantotsu/addons/LoadResult.kt
Normal file
@@ -0,0 +1,8 @@
|
||||
package ani.dantotsu.addons
|
||||
|
||||
abstract class LoadResult {
|
||||
|
||||
abstract class Success : LoadResult()
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package ani.dantotsu.addons.download
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import ani.dantotsu.addons.Addon
|
||||
|
||||
sealed class DownloadAddon : Addon() {
|
||||
|
||||
data class Installed(
|
||||
override val name: String,
|
||||
override val pkgName: String,
|
||||
override val versionName: String,
|
||||
override val versionCode: Long,
|
||||
val extension: DownloadAddonApiV2,
|
||||
val icon: Drawable?,
|
||||
val hasUpdate: Boolean = false,
|
||||
) : Addon.Installed(name, pkgName, versionName, versionCode)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package ani.dantotsu.addons.download
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
|
||||
interface DownloadAddonApiV2 {
|
||||
|
||||
fun cancelDownload(sessionId: Long)
|
||||
|
||||
fun setDownloadPath(context: Context, uri: Uri): String
|
||||
|
||||
fun getReadPath(context: Context, uri: Uri): String
|
||||
|
||||
suspend fun executeFFProbe(
|
||||
videoUrl: String,
|
||||
headers: Map<String, String> = emptyMap(),
|
||||
logCallback: (String) -> Unit
|
||||
)
|
||||
|
||||
suspend fun executeFFMpeg(
|
||||
videoUrl: String,
|
||||
downloadPath: String,
|
||||
headers: Map<String, String> = emptyMap(),
|
||||
subtitleUrls: List<Pair<String, String>> = emptyList(),
|
||||
audioUrls: List<Pair<String, String>> = emptyList(),
|
||||
statCallback: (Double) -> Unit
|
||||
): Long
|
||||
|
||||
suspend fun customFFMpeg(
|
||||
command: String,
|
||||
videoUrls: List<String>,
|
||||
logCallback: (String) -> Unit
|
||||
): Long
|
||||
|
||||
suspend fun customFFProbe(
|
||||
command: String,
|
||||
videoUrls: List<String>,
|
||||
logCallback: (String) -> Unit
|
||||
)
|
||||
|
||||
fun getState(sessionId: Long): String
|
||||
|
||||
fun getStackTrace(sessionId: Long): String?
|
||||
|
||||
fun hadError(sessionId: Long): Boolean
|
||||
|
||||
fun getFileExtension(): Pair<String, String> = Pair("mkv", "video/x-matroska")
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package ani.dantotsu.addons.download
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.addons.AddonDownloader
|
||||
import ani.dantotsu.addons.AddonInstallReceiver
|
||||
import ani.dantotsu.addons.AddonListener
|
||||
import ani.dantotsu.addons.AddonLoader
|
||||
import ani.dantotsu.addons.AddonManager
|
||||
import ani.dantotsu.addons.LoadResult
|
||||
import ani.dantotsu.media.AddonType
|
||||
import ani.dantotsu.util.Logger
|
||||
import eu.kanade.tachiyomi.extension.InstallStep
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class DownloadAddonManager(
|
||||
private val context: Context
|
||||
) : AddonManager<DownloadAddon.Installed>(context) {
|
||||
|
||||
override var extension: DownloadAddon.Installed? = null
|
||||
override var name: String = "Download Addon"
|
||||
override var type = AddonType.DOWNLOAD
|
||||
|
||||
private val _isInitialized = MutableLiveData(false)
|
||||
val isInitialized: LiveData<Boolean> = _isInitialized
|
||||
|
||||
private var error: String? = null
|
||||
|
||||
override suspend fun init() {
|
||||
extension = null
|
||||
error = null
|
||||
hasUpdate = false
|
||||
withContext(Dispatchers.Main) {
|
||||
_isInitialized.value = false
|
||||
}
|
||||
|
||||
AddonInstallReceiver()
|
||||
.setListener(InstallationListener(), type)
|
||||
.register(context)
|
||||
try {
|
||||
val result = AddonLoader.loadExtension(
|
||||
context,
|
||||
DOWNLOAD_PACKAGE,
|
||||
DOWNLOAD_CLASS,
|
||||
AddonType.DOWNLOAD
|
||||
) as? DownloadLoadResult
|
||||
result?.let {
|
||||
if (it is DownloadLoadResult.Success) {
|
||||
extension = it.extension
|
||||
hasUpdate = AddonDownloader.hasUpdate(REPO, it.extension.versionName)
|
||||
}
|
||||
}
|
||||
Logger.log("Download addon initialized successfully")
|
||||
withContext(Dispatchers.Main) {
|
||||
_isInitialized.value = true
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Logger.log("Error initializing Download addon")
|
||||
Logger.log(e)
|
||||
error = e.message
|
||||
}
|
||||
}
|
||||
|
||||
override fun isAvailable(andEnabled: Boolean): Boolean {
|
||||
return extension?.extension != null
|
||||
}
|
||||
|
||||
override fun getVersion(): String? {
|
||||
return extension?.versionName
|
||||
}
|
||||
|
||||
override fun getPackageName(): String? {
|
||||
return extension?.pkgName
|
||||
}
|
||||
|
||||
override fun hadError(context: Context): String? {
|
||||
return if (isInitialized.value == true) {
|
||||
if (error != null) {
|
||||
error
|
||||
} else if (extension != null) {
|
||||
context.getString(R.string.loaded_successfully)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private inner class InstallationListener : AddonListener {
|
||||
override fun onAddonInstalled(result: LoadResult?) {
|
||||
if (result is DownloadLoadResult.Success) {
|
||||
extension = result.extension
|
||||
hasUpdate = false
|
||||
onListenerAction?.invoke(AddonListener.ListenerAction.INSTALL)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAddonUpdated(result: LoadResult?) {
|
||||
if (result is DownloadLoadResult.Success) {
|
||||
extension = result.extension
|
||||
hasUpdate = false
|
||||
onListenerAction?.invoke(AddonListener.ListenerAction.UPDATE)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAddonUninstalled(pkgName: String) {
|
||||
if (extension?.pkgName == pkgName) {
|
||||
extension = null
|
||||
hasUpdate = false
|
||||
onListenerAction?.invoke(AddonListener.ListenerAction.UNINSTALL)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun updateInstallStep(id: Long, step: InstallStep) {
|
||||
installer.updateInstallStep(id, step)
|
||||
}
|
||||
|
||||
override fun setInstalling(id: Long) {
|
||||
installer.updateInstallStep(id, InstallStep.Installing)
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
|
||||
const val DOWNLOAD_PACKAGE = "dantotsu.downloadAddon"
|
||||
const val DOWNLOAD_CLASS = "ani.dantotsu.downloadAddon.DownloadAddon"
|
||||
const val REPO = "rebelonion/Dantotsu-Download-Addon"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package ani.dantotsu.addons.download
|
||||
|
||||
import ani.dantotsu.addons.LoadResult
|
||||
|
||||
open class DownloadLoadResult : LoadResult() {
|
||||
class Success(val extension: DownloadAddon.Installed) : DownloadLoadResult()
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package ani.dantotsu.addons.torrent
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import ani.dantotsu.addons.Addon
|
||||
|
||||
sealed class TorrentAddon : Addon() {
|
||||
data class Installed(
|
||||
override val name: String,
|
||||
override val pkgName: String,
|
||||
override val versionName: String,
|
||||
override val versionCode: Long,
|
||||
val extension: TorrentAddonApi,
|
||||
val icon: Drawable?,
|
||||
val hasUpdate: Boolean = false,
|
||||
) : Addon.Installed(name, pkgName, versionName, versionCode)
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package ani.dantotsu.addons.torrent
|
||||
|
||||
import eu.kanade.tachiyomi.data.torrentServer.model.Torrent
|
||||
|
||||
interface TorrentAddonApi {
|
||||
|
||||
fun startServer(path: String)
|
||||
|
||||
fun stopServer()
|
||||
|
||||
fun echo(): String
|
||||
|
||||
fun removeTorrent(torrent: String)
|
||||
|
||||
fun addTorrent(
|
||||
link: String,
|
||||
title: String,
|
||||
poster: String,
|
||||
data: String,
|
||||
save: Boolean,
|
||||
): Torrent
|
||||
|
||||
fun getLink(torrent: Torrent, index: Int): String
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package ani.dantotsu.addons.torrent
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.addons.AddonDownloader.Companion.hasUpdate
|
||||
import ani.dantotsu.addons.AddonInstallReceiver
|
||||
import ani.dantotsu.addons.AddonListener
|
||||
import ani.dantotsu.addons.AddonLoader
|
||||
import ani.dantotsu.addons.AddonManager
|
||||
import ani.dantotsu.addons.LoadResult
|
||||
import ani.dantotsu.media.AddonType
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.util.Logger
|
||||
import eu.kanade.tachiyomi.extension.InstallStep
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class TorrentAddonManager(
|
||||
private val context: Context
|
||||
) : AddonManager<TorrentAddon.Installed>(context) {
|
||||
override var extension: TorrentAddon.Installed? = null
|
||||
override var name: String = "Torrent Addon"
|
||||
override var type: AddonType = AddonType.TORRENT
|
||||
var torrentHash: String? = null
|
||||
|
||||
private val _isInitialized = MutableLiveData(false)
|
||||
val isInitialized: LiveData<Boolean> = _isInitialized
|
||||
|
||||
private var error: String? = null
|
||||
|
||||
override suspend fun init() {
|
||||
extension = null
|
||||
error = null
|
||||
hasUpdate = false
|
||||
withContext(Dispatchers.Main) {
|
||||
_isInitialized.value = false
|
||||
}
|
||||
if (Build.VERSION.SDK_INT < 23) {
|
||||
Logger.log("Torrent extension is not supported on this device.")
|
||||
error = context.getString(R.string.torrent_extension_not_supported)
|
||||
return
|
||||
}
|
||||
|
||||
AddonInstallReceiver()
|
||||
.setListener(InstallationListener(), type)
|
||||
.register(context)
|
||||
try {
|
||||
val result = AddonLoader.loadExtension(
|
||||
context,
|
||||
TORRENT_PACKAGE,
|
||||
TORRENT_CLASS,
|
||||
type
|
||||
) as TorrentLoadResult?
|
||||
result?.let {
|
||||
if (it is TorrentLoadResult.Success) {
|
||||
extension = it.extension
|
||||
hasUpdate = hasUpdate(REPO, it.extension.versionName)
|
||||
}
|
||||
}
|
||||
Logger.log("Torrent addon initialized successfully")
|
||||
withContext(Dispatchers.Main) {
|
||||
_isInitialized.value = true
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Logger.log("Error initializing torrent addon")
|
||||
Logger.log(e)
|
||||
error = e.message
|
||||
}
|
||||
}
|
||||
|
||||
override fun isAvailable(andEnabled: Boolean): Boolean {
|
||||
return extension?.extension != null && if (andEnabled) {
|
||||
PrefManager.getVal(PrefName.TorrentEnabled)
|
||||
} else true
|
||||
}
|
||||
|
||||
override fun getVersion(): String? {
|
||||
return extension?.versionName
|
||||
}
|
||||
|
||||
override fun getPackageName(): String? {
|
||||
return extension?.pkgName
|
||||
}
|
||||
|
||||
override fun hadError(context: Context): String? {
|
||||
return if (isInitialized.value == true) {
|
||||
if (error != null) {
|
||||
error
|
||||
} else if (extension != null) {
|
||||
context.getString(R.string.loaded_successfully)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private inner class InstallationListener : AddonListener {
|
||||
override fun onAddonInstalled(result: LoadResult?) {
|
||||
if (result is TorrentLoadResult.Success) {
|
||||
extension = result.extension
|
||||
hasUpdate = false
|
||||
onListenerAction?.invoke(AddonListener.ListenerAction.INSTALL)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAddonUpdated(result: LoadResult?) {
|
||||
if (result is TorrentLoadResult.Success) {
|
||||
extension = result.extension
|
||||
hasUpdate = false
|
||||
onListenerAction?.invoke(AddonListener.ListenerAction.UPDATE)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAddonUninstalled(pkgName: String) {
|
||||
if (pkgName == TORRENT_PACKAGE) {
|
||||
extension = null
|
||||
hasUpdate = false
|
||||
onListenerAction?.invoke(AddonListener.ListenerAction.UNINSTALL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateInstallStep(id: Long, step: InstallStep) {
|
||||
installer.updateInstallStep(id, step)
|
||||
}
|
||||
|
||||
override fun setInstalling(id: Long) {
|
||||
installer.updateInstallStep(id, InstallStep.Installing)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TORRENT_PACKAGE = "dantotsu.torrentAddon"
|
||||
const val TORRENT_CLASS = "ani.dantotsu.torrentAddon.TorrentAddon"
|
||||
const val REPO = "rebelonion/Dantotsu-Torrent-Addon"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package ani.dantotsu.addons.torrent
|
||||
|
||||
import ani.dantotsu.addons.LoadResult
|
||||
|
||||
open class TorrentLoadResult : LoadResult() {
|
||||
class Success(val extension: TorrentAddon.Installed) : TorrentLoadResult()
|
||||
}
|
||||
180
app/src/main/java/ani/dantotsu/addons/torrent/TorrentService.kt
Normal file
180
app/src/main/java/ani/dantotsu/addons/torrent/TorrentService.kt
Normal file
@@ -0,0 +1,180 @@
|
||||
/**
|
||||
* modified source from
|
||||
* https://github.com/rebelonion/Dantotsu/pull/305
|
||||
* and https://github.com/LuftVerbot/kuukiyomi
|
||||
* all credits to the original authors
|
||||
*/
|
||||
|
||||
package ani.dantotsu.addons.torrent
|
||||
|
||||
import android.app.ActivityManager
|
||||
import android.app.Application
|
||||
import android.app.PendingIntent
|
||||
import android.app.Service
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.ServiceInfo
|
||||
import android.os.Build
|
||||
import android.os.IBinder
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.util.Logger
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications.CHANNEL_TORRENT_SERVER
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications.ID_TORRENT_SERVER
|
||||
import eu.kanade.tachiyomi.util.system.cancelNotification
|
||||
import eu.kanade.tachiyomi.util.system.notificationBuilder
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
|
||||
|
||||
class TorrentServerService : Service() {
|
||||
private val serviceScope = CoroutineScope(EmptyCoroutineContext)
|
||||
private val applicationContext = Injekt.get<Application>()
|
||||
private lateinit var extension: TorrentAddonApi
|
||||
|
||||
override fun onBind(intent: Intent?): IBinder? = null
|
||||
|
||||
override fun onStartCommand(
|
||||
intent: Intent?,
|
||||
flags: Int,
|
||||
startId: Int,
|
||||
): Int {
|
||||
extension =
|
||||
Injekt.get<TorrentAddonManager>().extension?.extension ?: return START_NOT_STICKY
|
||||
intent?.let {
|
||||
if (it.action != null) {
|
||||
when (it.action) {
|
||||
ACTION_START -> {
|
||||
startServer()
|
||||
notification(applicationContext)
|
||||
return START_STICKY
|
||||
}
|
||||
|
||||
ACTION_STOP -> {
|
||||
stopServer()
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
|
||||
private fun startServer() {
|
||||
serviceScope.launch {
|
||||
val echo = extension.echo()
|
||||
if (echo == "") {
|
||||
extension.startServer(filesDir.absolutePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun stopServer() {
|
||||
serviceScope.launch {
|
||||
extension.stopServer()
|
||||
applicationContext.cancelNotification(ID_TORRENT_SERVER)
|
||||
stopSelf()
|
||||
}
|
||||
}
|
||||
|
||||
private fun notification(context: Context) {
|
||||
val exitPendingIntent =
|
||||
PendingIntent.getService(
|
||||
applicationContext,
|
||||
0,
|
||||
Intent(applicationContext, TorrentServerService::class.java).apply {
|
||||
action = ACTION_STOP
|
||||
},
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
|
||||
)
|
||||
val builder = context.notificationBuilder(CHANNEL_TORRENT_SERVER) {
|
||||
setSmallIcon(R.drawable.notification_icon)
|
||||
setContentText("Torrent Server")
|
||||
setContentTitle("Server is running…")
|
||||
setAutoCancel(false)
|
||||
setOngoing(true)
|
||||
setUsesChronometer(true)
|
||||
addAction(
|
||||
R.drawable.ic_circle_cancel,
|
||||
"Stop",
|
||||
exitPendingIntent,
|
||||
)
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
startForeground(
|
||||
ID_TORRENT_SERVER,
|
||||
builder.build(),
|
||||
ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC,
|
||||
)
|
||||
} else {
|
||||
startForeground(ID_TORRENT_SERVER, builder.build())
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val ACTION_START = "start_torrent_server"
|
||||
const val ACTION_STOP = "stop_torrent_server"
|
||||
|
||||
fun isRunning(): Boolean {
|
||||
with(Injekt.get<Application>().getSystemService(ACTIVITY_SERVICE) as ActivityManager) {
|
||||
@Suppress("DEPRECATION") // We only need our services
|
||||
getRunningServices(Int.MAX_VALUE).forEach {
|
||||
if (TorrentServerService::class.java.name.equals(it.service.className)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun start() {
|
||||
if (Injekt.get<TorrentAddonManager>().extension?.extension == null) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
val intent =
|
||||
Intent(Injekt.get<Application>(), TorrentServerService::class.java).apply {
|
||||
action = ACTION_START
|
||||
}
|
||||
Injekt.get<Application>().startService(intent)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun stop() {
|
||||
try {
|
||||
val intent =
|
||||
Intent(Injekt.get<Application>(), TorrentServerService::class.java).apply {
|
||||
action = ACTION_STOP
|
||||
}
|
||||
Injekt.get<Application>().startService(intent)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
fun wait(timeout: Int = -1): Boolean {
|
||||
var count = 0
|
||||
if (timeout < 0) {
|
||||
count = -20
|
||||
}
|
||||
var echo = Injekt.get<TorrentAddonManager>().extension?.extension?.echo()
|
||||
while (echo == "") {
|
||||
Thread.sleep(1000)
|
||||
count++
|
||||
if (count > timeout) {
|
||||
return false
|
||||
}
|
||||
echo = Injekt.get<TorrentAddonManager>().extension?.extension?.echo()
|
||||
}
|
||||
Logger.log("ServerService: Server started: $echo")
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
@@ -1,3 +0,0 @@
|
||||
NOTICE
|
||||
|
||||
This software includes code modified from Aniyomi, available at https://github.com/aniyomiorg/aniyomi/.
|
||||
@@ -1,187 +0,0 @@
|
||||
package ani.dantotsu.aniyomi.anime.api
|
||||
|
||||
import android.content.Context
|
||||
import ani.dantotsu.aniyomi.util.extension.ExtensionUpdateNotifier
|
||||
import ani.dantotsu.aniyomi.anime.AnimeExtensionManager
|
||||
import ani.dantotsu.aniyomi.anime.model.AnimeExtension
|
||||
import ani.dantotsu.aniyomi.anime.model.AnimeLoadResult
|
||||
import ani.dantotsu.aniyomi.anime.model.AvailableAnimeSources
|
||||
import ani.dantotsu.aniyomi.anime.util.AnimeExtensionLoader
|
||||
import ani.dantotsu.aniyomi.core.preference.PreferenceStore
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import eu.kanade.tachiyomi.network.awaitSuccess
|
||||
import eu.kanade.tachiyomi.network.parseAs
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
import logcat.LogPriority
|
||||
//import ani.dantotsu.aniyomi.core.preference.Preference
|
||||
//import ani.dantotsu.aniyomi.core.preference.PreferenceStore
|
||||
import ani.dantotsu.aniyomi.util.withIOContext
|
||||
import ani.dantotsu.aniyomi.util.logcat
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
internal class AnimeExtensionGithubApi {
|
||||
|
||||
private val networkService: NetworkHelper by injectLazy()
|
||||
private val preferenceStore: PreferenceStore by injectLazy()
|
||||
private val animeExtensionManager: AnimeExtensionManager by injectLazy()
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
//private val lastExtCheck: Preference<Long> by lazy {
|
||||
// preferenceStore.getLong("last_ext_check", 0)
|
||||
//}
|
||||
private val lastExtCheck: Long = 0
|
||||
|
||||
private var requiresFallbackSource = false
|
||||
|
||||
suspend fun findExtensions(): List<AnimeExtension.Available> {
|
||||
return withIOContext {
|
||||
val githubResponse = if (requiresFallbackSource) {
|
||||
null
|
||||
} else {
|
||||
try {
|
||||
networkService.client
|
||||
.newCall(GET("${REPO_URL_PREFIX}index.min.json"))
|
||||
.awaitSuccess()
|
||||
} catch (e: Throwable) {
|
||||
logcat(LogPriority.ERROR, e) { "Failed to get extensions from GitHub" }
|
||||
requiresFallbackSource = true
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
val response = githubResponse ?: run {
|
||||
networkService.client
|
||||
.newCall(GET("${FALLBACK_REPO_URL_PREFIX}index.min.json"))
|
||||
.awaitSuccess()
|
||||
}
|
||||
|
||||
val extensions = with(json) {
|
||||
response
|
||||
.parseAs<List<AnimeExtensionJsonObject>>()
|
||||
.toExtensions()
|
||||
}
|
||||
|
||||
// Sanity check - a small number of extensions probably means something broke
|
||||
// with the repo generator
|
||||
if (extensions.size < 10) {
|
||||
throw Exception()
|
||||
}
|
||||
|
||||
extensions
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun checkForUpdates(context: Context, fromAvailableExtensionList: Boolean = false): List<AnimeExtension.Installed>? {
|
||||
// Limit checks to once a day at most
|
||||
//if (fromAvailableExtensionList && Date().time < lastExtCheck.get() + 1.days.inWholeMilliseconds) {
|
||||
// return null
|
||||
//}
|
||||
|
||||
val extensions = if (fromAvailableExtensionList) {
|
||||
animeExtensionManager.availableExtensionsFlow.value
|
||||
} else {
|
||||
findExtensions().also { }//lastExtCheck.set(Date().time) }
|
||||
}
|
||||
|
||||
val installedExtensions = AnimeExtensionLoader.loadExtensions(context)
|
||||
.filterIsInstance<AnimeLoadResult.Success>()
|
||||
.map { it.extension }
|
||||
|
||||
val extensionsWithUpdate = mutableListOf<AnimeExtension.Installed>()
|
||||
for (installedExt in installedExtensions) {
|
||||
val pkgName = installedExt.pkgName
|
||||
val availableExt = extensions.find { it.pkgName == pkgName } ?: continue
|
||||
|
||||
val hasUpdatedVer = availableExt.versionCode > installedExt.versionCode
|
||||
val hasUpdatedLib = availableExt.libVersion > installedExt.libVersion
|
||||
val hasUpdate = installedExt.isUnofficial.not() && (hasUpdatedVer || hasUpdatedLib)
|
||||
if (hasUpdate) {
|
||||
extensionsWithUpdate.add(installedExt)
|
||||
}
|
||||
}
|
||||
|
||||
if (extensionsWithUpdate.isNotEmpty()) {
|
||||
ExtensionUpdateNotifier(context).promptUpdates(extensionsWithUpdate.map { it.name })
|
||||
}
|
||||
|
||||
return extensionsWithUpdate
|
||||
}
|
||||
|
||||
private fun List<AnimeExtensionJsonObject>.toExtensions(): List<AnimeExtension.Available> {
|
||||
return this
|
||||
.filter {
|
||||
val libVersion = it.extractLibVersion()
|
||||
libVersion >= AnimeExtensionLoader.LIB_VERSION_MIN && libVersion <= AnimeExtensionLoader.LIB_VERSION_MAX
|
||||
}
|
||||
.map {
|
||||
AnimeExtension.Available(
|
||||
name = it.name.substringAfter("Aniyomi: "),
|
||||
pkgName = it.pkg,
|
||||
versionName = it.version,
|
||||
versionCode = it.code,
|
||||
libVersion = it.extractLibVersion(),
|
||||
lang = it.lang,
|
||||
isNsfw = it.nsfw == 1,
|
||||
hasReadme = it.hasReadme == 1,
|
||||
hasChangelog = it.hasChangelog == 1,
|
||||
sources = it.sources?.toAnimeExtensionSources().orEmpty(),
|
||||
apkName = it.apk,
|
||||
iconUrl = "${getUrlPrefix()}icon/${it.apk.replace(".apk", ".png")}",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun List<AnimeExtensionSourceJsonObject>.toAnimeExtensionSources(): List<AvailableAnimeSources> {
|
||||
return this.map {
|
||||
AvailableAnimeSources(
|
||||
id = it.id,
|
||||
lang = it.lang,
|
||||
name = it.name,
|
||||
baseUrl = it.baseUrl,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun getApkUrl(extension: AnimeExtension.Available): String {
|
||||
return "${getUrlPrefix()}apk/${extension.apkName}"
|
||||
}
|
||||
|
||||
private fun getUrlPrefix(): String {
|
||||
return if (requiresFallbackSource) {
|
||||
FALLBACK_REPO_URL_PREFIX
|
||||
} else {
|
||||
REPO_URL_PREFIX
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun AnimeExtensionJsonObject.extractLibVersion(): Double {
|
||||
return version.substringBeforeLast('.').toDouble()
|
||||
}
|
||||
|
||||
private const val REPO_URL_PREFIX = "https://raw.githubusercontent.com/aniyomiorg/aniyomi-extensions/repo/"
|
||||
private const val FALLBACK_REPO_URL_PREFIX = "https://gcore.jsdelivr.net/gh/aniyomiorg/aniyomi-extensions@repo/"
|
||||
|
||||
@Serializable
|
||||
private data class AnimeExtensionJsonObject(
|
||||
val name: String,
|
||||
val pkg: String,
|
||||
val apk: String,
|
||||
val lang: String,
|
||||
val code: Long,
|
||||
val version: String,
|
||||
val nsfw: Int,
|
||||
val hasReadme: Int = 0,
|
||||
val hasChangelog: Int = 0,
|
||||
val sources: List<AnimeExtensionSourceJsonObject>?,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
private data class AnimeExtensionSourceJsonObject(
|
||||
val id: Long,
|
||||
val lang: String,
|
||||
val name: String,
|
||||
val baseUrl: String,
|
||||
)
|
||||
@@ -1,30 +0,0 @@
|
||||
package ani.dantotsu.aniyomi.anime.custom
|
||||
/*
|
||||
import android.app.Application
|
||||
import ani.dantotsu.aniyomi.data.Notifications
|
||||
import ani.dantotsu.aniyomi.util.logcat
|
||||
import logcat.AndroidLogcatLogger
|
||||
import logcat.LogPriority
|
||||
import logcat.LogcatLogger
|
||||
import uy.kohesive.injekt.Injekt
|
||||
|
||||
class App : Application() {
|
||||
override fun onCreate() {
|
||||
super<Application>.onCreate()
|
||||
Injekt.importModule(AppModule(this))
|
||||
Injekt.importModule(PreferenceModule(this))
|
||||
|
||||
setupNotificationChannels()
|
||||
if (!LogcatLogger.isInstalled) {
|
||||
LogcatLogger.install(AndroidLogcatLogger(LogPriority.VERBOSE))
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupNotificationChannels() {
|
||||
try {
|
||||
Notifications.createChannels(this)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e) { "Failed to modify notification channels" }
|
||||
}
|
||||
}
|
||||
}*/
|
||||
@@ -1,13 +1,29 @@
|
||||
package ani.dantotsu.aniyomi.anime.custom
|
||||
|
||||
|
||||
import android.app.Application
|
||||
import ani.dantotsu.aniyomi.anime.AnimeExtensionManager
|
||||
import ani.dantotsu.aniyomi.core.preference.PreferenceStore
|
||||
import ani.dantotsu.aniyomi.domain.base.BasePreferences
|
||||
import ani.dantotsu.aniyomi.domain.source.service.SourcePreferences
|
||||
import ani.dantotsu.aniyomi.core.preference.AndroidPreferenceStore
|
||||
import androidx.annotation.OptIn
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.media3.common.util.UnstableApi
|
||||
import androidx.media3.database.StandaloneDatabaseProvider
|
||||
import ani.dantotsu.addons.download.DownloadAddonManager
|
||||
import ani.dantotsu.addons.torrent.TorrentAddonManager
|
||||
import ani.dantotsu.download.DownloadsManager
|
||||
import ani.dantotsu.media.manga.MangaCache
|
||||
import ani.dantotsu.parsers.novel.NovelExtensionManager
|
||||
import eu.kanade.domain.base.BasePreferences
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.core.preference.AndroidPreferenceStore
|
||||
import eu.kanade.tachiyomi.extension.anime.AnimeExtensionManager
|
||||
import eu.kanade.tachiyomi.extension.manga.MangaExtensionManager
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import eu.kanade.tachiyomi.source.anime.AndroidAnimeSourceManager
|
||||
import eu.kanade.tachiyomi.source.manga.AndroidMangaSourceManager
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.json.Json
|
||||
import tachiyomi.core.preference.PreferenceStore
|
||||
import tachiyomi.domain.source.anime.service.AnimeSourceManager
|
||||
import tachiyomi.domain.source.manga.service.MangaSourceManager
|
||||
import uy.kohesive.injekt.api.InjektModule
|
||||
import uy.kohesive.injekt.api.InjektRegistrar
|
||||
import uy.kohesive.injekt.api.addSingleton
|
||||
@@ -15,12 +31,24 @@ import uy.kohesive.injekt.api.addSingletonFactory
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class AppModule(val app: Application) : InjektModule {
|
||||
@kotlin.OptIn(ExperimentalSerializationApi::class)
|
||||
@OptIn(UnstableApi::class)
|
||||
override fun InjektRegistrar.registerInjectables() {
|
||||
addSingleton(app)
|
||||
|
||||
addSingletonFactory { DownloadsManager(app) }
|
||||
|
||||
addSingletonFactory { NetworkHelper(app) }
|
||||
addSingletonFactory { NetworkHelper(app).client }
|
||||
|
||||
addSingletonFactory { AnimeExtensionManager(app) }
|
||||
addSingletonFactory { MangaExtensionManager(app) }
|
||||
addSingletonFactory { NovelExtensionManager(app) }
|
||||
addSingletonFactory { TorrentAddonManager(app) }
|
||||
addSingletonFactory { DownloadAddonManager(app) }
|
||||
|
||||
addSingletonFactory<AnimeSourceManager> { AndroidAnimeSourceManager(app, get()) }
|
||||
addSingletonFactory<MangaSourceManager> { AndroidMangaSourceManager(app, get()) }
|
||||
|
||||
addSingletonFactory {
|
||||
Json {
|
||||
@@ -28,6 +56,15 @@ class AppModule(val app: Application) : InjektModule {
|
||||
explicitNulls = false
|
||||
}
|
||||
}
|
||||
|
||||
addSingletonFactory { StandaloneDatabaseProvider(app) }
|
||||
|
||||
addSingletonFactory { MangaCache() }
|
||||
|
||||
ContextCompat.getMainExecutor(app).execute {
|
||||
get<AnimeSourceManager>()
|
||||
get<MangaSourceManager>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,170 +0,0 @@
|
||||
package ani.dantotsu.aniyomi.anime.installer
|
||||
|
||||
import android.app.Service
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.net.Uri
|
||||
import androidx.annotation.CallSuper
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import ani.dantotsu.aniyomi.util.extension.InstallStep
|
||||
import ani.dantotsu.aniyomi.anime.AnimeExtensionManager
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.util.Collections
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
/**
|
||||
* Base implementation class for extension installer. To be used inside a foreground [Service].
|
||||
*/
|
||||
abstract class InstallerAnime(private val service: Service) {
|
||||
|
||||
private val extensionManager: AnimeExtensionManager by injectLazy()
|
||||
|
||||
private var waitingInstall = AtomicReference<Entry>(null)
|
||||
private val queue = Collections.synchronizedList(mutableListOf<Entry>())
|
||||
|
||||
private val cancelReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
val downloadId = intent.getLongExtra(EXTRA_DOWNLOAD_ID, -1).takeIf { it >= 0 } ?: return
|
||||
cancelQueue(downloadId)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Installer readiness. If false, queue check will not run.
|
||||
*
|
||||
* @see checkQueue
|
||||
*/
|
||||
abstract var ready: Boolean
|
||||
|
||||
/**
|
||||
* Add an item to install queue.
|
||||
*
|
||||
* @param downloadId Download ID as known by [ExtensionManager]
|
||||
* @param uri Uri of APK to install
|
||||
*/
|
||||
fun addToQueue(downloadId: Long, uri: Uri) {
|
||||
queue.add(Entry(downloadId, uri))
|
||||
checkQueue()
|
||||
}
|
||||
|
||||
/**
|
||||
* Proceeds to install the APK of this entry inside this method. Call [continueQueue]
|
||||
* when the install process for this entry is finished to continue the queue.
|
||||
*
|
||||
* @param entry The [Entry] of item to process
|
||||
* @see continueQueue
|
||||
*/
|
||||
@CallSuper
|
||||
open fun processEntry(entry: Entry) {
|
||||
extensionManager.setInstalling(entry.downloadId)
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before queue continues. Override this to handle when the removed entry is
|
||||
* currently being processed.
|
||||
*
|
||||
* @return true if this entry can be removed from queue.
|
||||
*/
|
||||
open fun cancelEntry(entry: Entry): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells the queue to continue processing the next entry and updates the install step
|
||||
* of the completed entry ([waitingInstall]) to [ExtensionManager].
|
||||
*
|
||||
* @param resultStep new install step for the processed entry.
|
||||
* @see waitingInstall
|
||||
*/
|
||||
fun continueQueue(resultStep: InstallStep) {
|
||||
val completedEntry = waitingInstall.getAndSet(null)
|
||||
if (completedEntry != null) {
|
||||
extensionManager.updateInstallStep(completedEntry.downloadId, resultStep)
|
||||
checkQueue()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the queue. The provided service will be stopped if the queue is empty.
|
||||
* Will not be run when not ready.
|
||||
*
|
||||
* @see ready
|
||||
*/
|
||||
fun checkQueue() {
|
||||
if (!ready) {
|
||||
return
|
||||
}
|
||||
if (queue.isEmpty()) {
|
||||
service.stopSelf()
|
||||
return
|
||||
}
|
||||
val nextEntry = queue.first()
|
||||
if (waitingInstall.compareAndSet(null, nextEntry)) {
|
||||
queue.removeFirst()
|
||||
processEntry(nextEntry)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this method when the provided service is destroyed.
|
||||
*/
|
||||
@CallSuper
|
||||
open fun onDestroy() {
|
||||
LocalBroadcastManager.getInstance(service).unregisterReceiver(cancelReceiver)
|
||||
queue.forEach { extensionManager.updateInstallStep(it.downloadId, InstallStep.Error) }
|
||||
queue.clear()
|
||||
waitingInstall.set(null)
|
||||
}
|
||||
|
||||
protected fun getActiveEntry(): Entry? = waitingInstall.get()
|
||||
|
||||
/**
|
||||
* Cancels queue for the provided download ID if exists.
|
||||
*
|
||||
* @param downloadId Download ID as known by [ExtensionManager]
|
||||
*/
|
||||
private fun cancelQueue(downloadId: Long) {
|
||||
val waitingInstall = this.waitingInstall.get()
|
||||
val toCancel = queue.find { it.downloadId == downloadId } ?: waitingInstall ?: return
|
||||
if (cancelEntry(toCancel)) {
|
||||
queue.remove(toCancel)
|
||||
if (waitingInstall == toCancel) {
|
||||
// Currently processing removed entry, continue queue
|
||||
this.waitingInstall.set(null)
|
||||
checkQueue()
|
||||
}
|
||||
extensionManager.updateInstallStep(downloadId, InstallStep.Idle)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Install item to queue.
|
||||
*
|
||||
* @param downloadId Download ID as known by [ExtensionManager]
|
||||
* @param uri Uri of APK to install
|
||||
*/
|
||||
data class Entry(val downloadId: Long, val uri: Uri)
|
||||
|
||||
init {
|
||||
val filter = IntentFilter(ACTION_CANCEL_QUEUE)
|
||||
LocalBroadcastManager.getInstance(service).registerReceiver(cancelReceiver, filter)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val ACTION_CANCEL_QUEUE = "InstallerAnime.action.CANCEL_QUEUE"
|
||||
private const val EXTRA_DOWNLOAD_ID = "InstallerAnime.extra.DOWNLOAD_ID"
|
||||
|
||||
/**
|
||||
* Attempts to cancel the installation entry for the provided download ID.
|
||||
*
|
||||
* @param downloadId Download ID as known by [ExtensionManager]
|
||||
*/
|
||||
fun cancelInstallQueue(context: Context, downloadId: Long) {
|
||||
val intent = Intent(ACTION_CANCEL_QUEUE)
|
||||
intent.putExtra(EXTRA_DOWNLOAD_ID, downloadId)
|
||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intent)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package ani.dantotsu.aniyomi.anime.util
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import ani.dantotsu.aniyomi.util.extension.InstallStep
|
||||
import ani.dantotsu.aniyomi.anime.AnimeExtensionManager
|
||||
import ani.dantotsu.aniyomi.util.system.hasMiuiPackageInstaller
|
||||
import ani.dantotsu.aniyomi.util.toast
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
/**
|
||||
* Activity used to install extensions, because we can only receive the result of the installation
|
||||
* with [startActivityForResult], which we need to update the UI.
|
||||
*/
|
||||
class AnimeExtensionInstallActivity : Activity() {
|
||||
|
||||
// MIUI package installer bug workaround
|
||||
private var ignoreUntil = 0L
|
||||
private var ignoreResult = false
|
||||
private var hasIgnoredResult = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
val installIntent = Intent(Intent.ACTION_INSTALL_PACKAGE)
|
||||
.setDataAndType(intent.data, intent.type)
|
||||
.putExtra(Intent.EXTRA_RETURN_RESULT, true)
|
||||
.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||
|
||||
if (hasMiuiPackageInstaller) {
|
||||
ignoreResult = true
|
||||
ignoreUntil = System.nanoTime() + 1.seconds.inWholeNanoseconds
|
||||
}
|
||||
|
||||
try {
|
||||
startActivityForResult(installIntent, INSTALL_REQUEST_CODE)
|
||||
} catch (error: Exception) {
|
||||
// Either install package can't be found (probably bots) or there's a security exception
|
||||
// with the download manager. Nothing we can workaround.
|
||||
toast(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (ignoreResult && System.nanoTime() < ignoreUntil) {
|
||||
hasIgnoredResult = true
|
||||
return
|
||||
}
|
||||
if (requestCode == INSTALL_REQUEST_CODE) {
|
||||
checkInstallationResult(resultCode)
|
||||
}
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
if (hasIgnoredResult) {
|
||||
checkInstallationResult(RESULT_CANCELED)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkInstallationResult(resultCode: Int) {
|
||||
val downloadId = intent.extras!!.getLong(AnimeExtensionInstaller.EXTRA_DOWNLOAD_ID)
|
||||
val extensionManager = Injekt.get<AnimeExtensionManager>()
|
||||
val newStep = when (resultCode) {
|
||||
RESULT_OK -> InstallStep.Installed
|
||||
RESULT_CANCELED -> InstallStep.Idle
|
||||
else -> InstallStep.Error
|
||||
}
|
||||
extensionManager.updateInstallStep(downloadId, newStep)
|
||||
}
|
||||
}
|
||||
|
||||
private const val INSTALL_REQUEST_CODE = 500
|
||||
@@ -1,130 +0,0 @@
|
||||
package ani.dantotsu.aniyomi.anime.util
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import ani.dantotsu.aniyomi.anime.model.AnimeExtension
|
||||
import ani.dantotsu.aniyomi.anime.model.AnimeLoadResult
|
||||
import kotlinx.coroutines.CoroutineStart
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.async
|
||||
import logcat.LogPriority
|
||||
import ani.dantotsu.aniyomi.util.launchNow
|
||||
import ani.dantotsu.aniyomi.util.logcat
|
||||
|
||||
/**
|
||||
* Broadcast receiver that listens for the system's packages installed, updated or removed, and only
|
||||
* notifies the given [listener] when the package is an extension.
|
||||
*
|
||||
* @param listener The listener that should be notified of extension installation events.
|
||||
*/
|
||||
internal class AnimeExtensionInstallReceiver(private val listener: Listener) :
|
||||
BroadcastReceiver() {
|
||||
|
||||
/**
|
||||
* Registers this broadcast receiver
|
||||
*/
|
||||
fun register(context: Context) {
|
||||
context.registerReceiver(this, filter)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the intent filter this receiver should subscribe to.
|
||||
*/
|
||||
private val filter
|
||||
get() = IntentFilter().apply {
|
||||
addAction(Intent.ACTION_PACKAGE_ADDED)
|
||||
addAction(Intent.ACTION_PACKAGE_REPLACED)
|
||||
addAction(Intent.ACTION_PACKAGE_REMOVED)
|
||||
addDataScheme("package")
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when one of the events of the [filter] is received. When the package is an extension,
|
||||
* it's loaded in background and it notifies the [listener] when finished.
|
||||
*/
|
||||
override fun onReceive(context: Context, intent: Intent?) {
|
||||
if (intent == null) return
|
||||
|
||||
when (intent.action) {
|
||||
Intent.ACTION_PACKAGE_ADDED -> {
|
||||
if (isReplacing(intent)) return
|
||||
|
||||
launchNow {
|
||||
when (val result = getExtensionFromIntent(context, intent)) {
|
||||
is AnimeLoadResult.Success -> listener.onExtensionInstalled(result.extension)
|
||||
|
||||
is AnimeLoadResult.Untrusted -> listener.onExtensionUntrusted(result.extension)
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
Intent.ACTION_PACKAGE_REPLACED -> {
|
||||
launchNow {
|
||||
when (val result = getExtensionFromIntent(context, intent)) {
|
||||
is AnimeLoadResult.Success -> listener.onExtensionUpdated(result.extension)
|
||||
// Not needed as a package can't be upgraded if the signature is different
|
||||
// is LoadResult.Untrusted -> {}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
Intent.ACTION_PACKAGE_REMOVED -> {
|
||||
if (isReplacing(intent)) return
|
||||
|
||||
val pkgName = getPackageNameFromIntent(intent)
|
||||
if (pkgName != null) {
|
||||
listener.onPackageUninstalled(pkgName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this package is performing an update.
|
||||
*
|
||||
* @param intent The intent that triggered the event.
|
||||
*/
|
||||
private fun isReplacing(intent: Intent): Boolean {
|
||||
return intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the extension triggered by the given intent.
|
||||
*
|
||||
* @param context The application context.
|
||||
* @param intent The intent containing the package name of the extension.
|
||||
*/
|
||||
private suspend fun getExtensionFromIntent(context: Context, intent: Intent?): AnimeLoadResult {
|
||||
val pkgName = getPackageNameFromIntent(intent)
|
||||
if (pkgName == null) {
|
||||
logcat(LogPriority.WARN) { "Package name not found" }
|
||||
return AnimeLoadResult.Error
|
||||
}
|
||||
return GlobalScope.async(Dispatchers.Default, CoroutineStart.DEFAULT) {
|
||||
AnimeExtensionLoader.loadExtensionFromPkgName(
|
||||
context,
|
||||
pkgName,
|
||||
)
|
||||
}.await()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the package name of the installed, updated or removed application.
|
||||
*/
|
||||
private fun getPackageNameFromIntent(intent: Intent?): String? {
|
||||
return intent?.data?.encodedSchemeSpecificPart ?: return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Listener that receives extension installation events.
|
||||
*/
|
||||
interface Listener {
|
||||
fun onExtensionInstalled(extension: AnimeExtension.Installed)
|
||||
fun onExtensionUpdated(extension: AnimeExtension.Installed)
|
||||
fun onExtensionUntrusted(extension: AnimeExtension.Untrusted)
|
||||
fun onPackageUninstalled(pkgName: String)
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package ani.dantotsu.aniyomi.anime.util
|
||||
|
||||
import android.app.Service
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.IBinder
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.aniyomi.domain.base.BasePreferences
|
||||
import ani.dantotsu.aniyomi.data.Notifications
|
||||
import ani.dantotsu.aniyomi.anime.installer.InstallerAnime
|
||||
import ani.dantotsu.aniyomi.anime.installer.PackageInstallerInstallerAnime
|
||||
import ani.dantotsu.aniyomi.anime.util.AnimeExtensionInstaller.Companion.EXTRA_DOWNLOAD_ID
|
||||
import ani.dantotsu.aniyomi.util.system.getSerializableExtraCompat
|
||||
import ani.dantotsu.aniyomi.util.system.notificationBuilder
|
||||
import logcat.LogPriority
|
||||
import ani.dantotsu.aniyomi.util.logcat
|
||||
|
||||
class AnimeExtensionInstallService : Service() {
|
||||
|
||||
private var installer: InstallerAnime? = null
|
||||
|
||||
override fun onCreate() {
|
||||
val notification = notificationBuilder(Notifications.CHANNEL_EXTENSIONS_UPDATE) {
|
||||
setSmallIcon(R.drawable.spinner_icon)
|
||||
setAutoCancel(false)
|
||||
setOngoing(true)
|
||||
setShowWhen(false)
|
||||
setContentTitle("Installing Anime Extension...")
|
||||
setProgress(100, 100, true)
|
||||
}.build()
|
||||
startForeground(Notifications.ID_EXTENSION_INSTALLER, notification)
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
val uri = intent?.data
|
||||
val id = intent?.getLongExtra(EXTRA_DOWNLOAD_ID, -1)?.takeIf { it != -1L }
|
||||
val installerUsed = intent?.getSerializableExtraCompat<BasePreferences.ExtensionInstaller>(
|
||||
EXTRA_INSTALLER,
|
||||
)
|
||||
if (uri == null || id == null || installerUsed == null) {
|
||||
stopSelf()
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
|
||||
if (installer == null) {
|
||||
installer = when (installerUsed) {
|
||||
BasePreferences.ExtensionInstaller.PACKAGEINSTALLER -> PackageInstallerInstallerAnime(this)
|
||||
else -> {
|
||||
logcat(LogPriority.ERROR) { "Not implemented for installer $installerUsed" }
|
||||
stopSelf()
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
}
|
||||
}
|
||||
installer!!.addToQueue(id, uri)
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
installer?.onDestroy()
|
||||
installer = null
|
||||
}
|
||||
|
||||
override fun onBind(i: Intent?): IBinder? = null
|
||||
|
||||
companion object {
|
||||
private const val EXTRA_INSTALLER = "EXTRA_INSTALLER"
|
||||
|
||||
fun getIntent(
|
||||
context: Context,
|
||||
downloadId: Long,
|
||||
uri: Uri,
|
||||
installer: BasePreferences.ExtensionInstaller,
|
||||
): Intent {
|
||||
return Intent(context, AnimeExtensionInstallService::class.java)
|
||||
.setDataAndType(uri, AnimeExtensionInstaller.APK_MIME)
|
||||
.putExtra(EXTRA_DOWNLOAD_ID, downloadId)
|
||||
.putExtra(EXTRA_INSTALLER, installer)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,232 +0,0 @@
|
||||
package ani.dantotsu.aniyomi.anime.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import androidx.core.content.pm.PackageInfoCompat
|
||||
import dalvik.system.PathClassLoader
|
||||
import ani.dantotsu.aniyomi.domain.source.service.SourcePreferences
|
||||
import ani.dantotsu.aniyomi.animesource.AnimeCatalogueSource
|
||||
import ani.dantotsu.aniyomi.animesource.AnimeSource
|
||||
import ani.dantotsu.aniyomi.animesource.AnimeSourceFactory
|
||||
import ani.dantotsu.aniyomi.anime.model.AnimeExtension
|
||||
import ani.dantotsu.aniyomi.anime.model.AnimeLoadResult
|
||||
import ani.dantotsu.aniyomi.util.lang.Hash
|
||||
import ani.dantotsu.aniyomi.util.system.getApplicationIcon
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import logcat.LogPriority
|
||||
import ani.dantotsu.aniyomi.util.logcat
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
/**
|
||||
* Class that handles the loading of the extensions installed in the system.
|
||||
*/
|
||||
@SuppressLint("PackageManagerGetSignatures")
|
||||
internal object AnimeExtensionLoader {
|
||||
|
||||
private val preferences: SourcePreferences by injectLazy()
|
||||
private val loadNsfwSource by lazy {
|
||||
preferences.showNsfwSource().get()
|
||||
}
|
||||
|
||||
private const val EXTENSION_FEATURE = "tachiyomi.animeextension"
|
||||
private const val METADATA_SOURCE_CLASS = "tachiyomi.animeextension.class"
|
||||
private const val METADATA_SOURCE_FACTORY = "tachiyomi.animeextension.factory"
|
||||
private const val METADATA_NSFW = "tachiyomi.animeextension.nsfw"
|
||||
private const val METADATA_HAS_README = "tachiyomi.animeextension.hasReadme"
|
||||
private const val METADATA_HAS_CHANGELOG = "tachiyomi.animeextension.hasChangelog"
|
||||
const val LIB_VERSION_MIN = 12
|
||||
const val LIB_VERSION_MAX = 15
|
||||
|
||||
private const val PACKAGE_FLAGS = PackageManager.GET_CONFIGURATIONS or PackageManager.GET_SIGNATURES
|
||||
|
||||
// jmir1's key
|
||||
private const val officialSignature = "50ab1d1e3a20d204d0ad6d334c7691c632e41b98dfa132bf385695fdfa63839c"
|
||||
|
||||
/**
|
||||
* List of the trusted signatures.
|
||||
*/
|
||||
var trustedSignatures = mutableSetOf<String>() + preferences.trustedSignatures().get() + officialSignature
|
||||
|
||||
/**
|
||||
* Return a list of all the installed extensions initialized concurrently.
|
||||
*
|
||||
* @param context The application context.
|
||||
*/
|
||||
fun loadExtensions(context: Context): List<AnimeLoadResult> {
|
||||
val pkgManager = context.packageManager
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
val installedPkgs = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
pkgManager.getInstalledPackages(PackageManager.PackageInfoFlags.of(PACKAGE_FLAGS.toLong()))
|
||||
} else {
|
||||
pkgManager.getInstalledPackages(PACKAGE_FLAGS)
|
||||
}
|
||||
|
||||
val extPkgs = installedPkgs.filter { isPackageAnExtension(it) }
|
||||
|
||||
if (extPkgs.isEmpty()) return emptyList()
|
||||
|
||||
// Load each extension concurrently and wait for completion
|
||||
return runBlocking {
|
||||
val deferred = extPkgs.map {
|
||||
async { loadExtension(context, it.packageName, it) }
|
||||
}
|
||||
deferred.map { it.await() }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to load an extension from the given package name. It checks if the extension
|
||||
* contains the required feature flag before trying to load it.
|
||||
*/
|
||||
fun loadExtensionFromPkgName(context: Context, pkgName: String): AnimeLoadResult {
|
||||
val pkgInfo = try {
|
||||
context.packageManager.getPackageInfo(pkgName, PACKAGE_FLAGS)
|
||||
} catch (error: PackageManager.NameNotFoundException) {
|
||||
// Unlikely, but the package may have been uninstalled at this point
|
||||
logcat(LogPriority.ERROR, error)
|
||||
return AnimeLoadResult.Error
|
||||
}
|
||||
if (!isPackageAnExtension(pkgInfo)) {
|
||||
logcat(LogPriority.WARN) { "Tried to load a package that wasn't a extension ($pkgName)" }
|
||||
return AnimeLoadResult.Error
|
||||
}
|
||||
return loadExtension(context, pkgName, pkgInfo)
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads an extension given its package name.
|
||||
*
|
||||
* @param context The application context.
|
||||
* @param pkgName The package name of the extension to load.
|
||||
* @param pkgInfo The package info of the extension.
|
||||
*/
|
||||
private fun loadExtension(context: Context, pkgName: String, pkgInfo: PackageInfo): AnimeLoadResult {
|
||||
val pkgManager = context.packageManager
|
||||
|
||||
val appInfo = try {
|
||||
pkgManager.getApplicationInfo(pkgName, PackageManager.GET_META_DATA)
|
||||
} catch (error: PackageManager.NameNotFoundException) {
|
||||
// Unlikely, but the package may have been uninstalled at this point
|
||||
logcat(LogPriority.ERROR, error)
|
||||
return AnimeLoadResult.Error
|
||||
}
|
||||
|
||||
val extName = pkgManager.getApplicationLabel(appInfo).toString().substringAfter("Aniyomi: ")
|
||||
val versionName = pkgInfo.versionName
|
||||
val versionCode = PackageInfoCompat.getLongVersionCode(pkgInfo)
|
||||
|
||||
if (versionName.isNullOrEmpty()) {
|
||||
logcat(LogPriority.WARN) { "Missing versionName for extension $extName" }
|
||||
return AnimeLoadResult.Error
|
||||
}
|
||||
|
||||
// Validate lib version
|
||||
val libVersion = versionName.substringBeforeLast('.').toDoubleOrNull()
|
||||
if (libVersion == null || libVersion < LIB_VERSION_MIN || libVersion > LIB_VERSION_MAX) {
|
||||
logcat(LogPriority.WARN) {
|
||||
"Lib version is $libVersion, while only versions " +
|
||||
"$LIB_VERSION_MIN to $LIB_VERSION_MAX are allowed"
|
||||
}
|
||||
return AnimeLoadResult.Error
|
||||
}
|
||||
|
||||
val signatureHash = getSignatureHash(pkgInfo)
|
||||
|
||||
if (signatureHash == null) {
|
||||
logcat(LogPriority.WARN) { "Package $pkgName isn't signed" }
|
||||
return AnimeLoadResult.Error
|
||||
} else if (signatureHash !in trustedSignatures) {
|
||||
val extension = AnimeExtension.Untrusted(extName, pkgName, versionName, versionCode, libVersion, signatureHash)
|
||||
logcat(LogPriority.WARN, message = { "Extension $pkgName isn't trusted" })
|
||||
return AnimeLoadResult.Untrusted(extension)
|
||||
}
|
||||
|
||||
val isNsfw = appInfo.metaData.getInt(METADATA_NSFW) == 1
|
||||
if (!loadNsfwSource && isNsfw) {
|
||||
logcat(LogPriority.WARN) { "NSFW extension $pkgName not allowed" }
|
||||
return AnimeLoadResult.Error
|
||||
}
|
||||
|
||||
val hasReadme = appInfo.metaData.getInt(METADATA_HAS_README, 0) == 1
|
||||
val hasChangelog = appInfo.metaData.getInt(METADATA_HAS_CHANGELOG, 0) == 1
|
||||
|
||||
val classLoader = PathClassLoader(appInfo.sourceDir, null, context.classLoader)
|
||||
|
||||
val sources = appInfo.metaData.getString(METADATA_SOURCE_CLASS)!!
|
||||
.split(";")
|
||||
.map {
|
||||
val sourceClass = it.trim()
|
||||
if (sourceClass.startsWith(".")) {
|
||||
pkgInfo.packageName + sourceClass
|
||||
} else {
|
||||
sourceClass
|
||||
}
|
||||
}
|
||||
.flatMap {
|
||||
try {
|
||||
when (val obj = Class.forName(it, false, classLoader).newInstance()) {
|
||||
is AnimeSource -> listOf(obj)
|
||||
is AnimeSourceFactory -> obj.createSources()
|
||||
else -> throw Exception("Unknown source class type! ${obj.javaClass}")
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
logcat(LogPriority.ERROR, e) { "Extension load error: $extName ($it)" }
|
||||
return AnimeLoadResult.Error
|
||||
}
|
||||
}
|
||||
|
||||
val langs = sources.filterIsInstance<AnimeCatalogueSource>()
|
||||
.map { it.lang }
|
||||
.toSet()
|
||||
val lang = when (langs.size) {
|
||||
0 -> ""
|
||||
1 -> langs.first()
|
||||
else -> "all"
|
||||
}
|
||||
|
||||
val extension = AnimeExtension.Installed(
|
||||
name = extName,
|
||||
pkgName = pkgName,
|
||||
versionName = versionName,
|
||||
versionCode = versionCode,
|
||||
libVersion = libVersion,
|
||||
lang = lang,
|
||||
isNsfw = isNsfw,
|
||||
hasReadme = hasReadme,
|
||||
hasChangelog = hasChangelog,
|
||||
sources = sources,
|
||||
pkgFactory = appInfo.metaData.getString(METADATA_SOURCE_FACTORY),
|
||||
isUnofficial = signatureHash != officialSignature,
|
||||
icon = context.getApplicationIcon(pkgName),
|
||||
)
|
||||
return AnimeLoadResult.Success(extension)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given package is an extension.
|
||||
*
|
||||
* @param pkgInfo The package info of the application.
|
||||
*/
|
||||
private fun isPackageAnExtension(pkgInfo: PackageInfo): Boolean {
|
||||
return pkgInfo.reqFeatures.orEmpty().any { it.name == EXTENSION_FEATURE }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the signature hash of the package or null if it's not signed.
|
||||
*
|
||||
* @param pkgInfo The package info of the application.
|
||||
*/
|
||||
private fun getSignatureHash(pkgInfo: PackageInfo): String? {
|
||||
val signatures = pkgInfo.signatures
|
||||
return if (signatures != null && signatures.isNotEmpty()) {
|
||||
Hash.sha256(signatures.first().toByteArray())
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package ani.dantotsu.aniyomi.animesource
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimesPage
|
||||
import rx.Observable
|
||||
|
||||
interface AnimeCatalogueSource : AnimeSource {
|
||||
|
||||
/**
|
||||
* An ISO 639-1 compliant language code (two letters in lower case).
|
||||
*/
|
||||
override val lang: String
|
||||
|
||||
/**
|
||||
* Whether the source has support for latest updates.
|
||||
*/
|
||||
val supportsLatest: Boolean
|
||||
|
||||
/**
|
||||
* Returns an observable containing a page with a list of anime.
|
||||
*
|
||||
* @param page the page number to retrieve.
|
||||
*/
|
||||
fun fetchPopularAnime(page: Int): Observable<AnimesPage>
|
||||
|
||||
/**
|
||||
* Returns an observable containing a page with a list of anime.
|
||||
*
|
||||
* @param page the page number to retrieve.
|
||||
* @param query the search query.
|
||||
* @param filters the list of filters to apply.
|
||||
*/
|
||||
fun fetchSearchAnime(page: Int, query: String, filters: AnimeFilterList): Observable<AnimesPage>
|
||||
|
||||
/**
|
||||
* Returns an observable containing a page with a list of latest anime updates.
|
||||
*
|
||||
* @param page the page number to retrieve.
|
||||
*/
|
||||
fun fetchLatestUpdates(page: Int): Observable<AnimesPage>
|
||||
|
||||
/**
|
||||
* Returns the list of filters for the source.
|
||||
*/
|
||||
fun getFilterList(): AnimeFilterList
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
package eu.kanade.tachiyomi.animesource.model
|
||||
|
||||
import android.net.Uri
|
||||
import ani.dantotsu.aniyomi.util.network.ProgressListener
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import okhttp3.Headers
|
||||
import rx.subjects.Subject
|
||||
|
||||
data class Track(val url: String, val lang: String)
|
||||
|
||||
open class Video(
|
||||
val url: String = "",
|
||||
val quality: String = "",
|
||||
var videoUrl: String? = null,
|
||||
val headers: Headers? = null,
|
||||
// "url", "language-label-2", "url2", "language-label-2"
|
||||
val subtitleTracks: List<Track> = emptyList(),
|
||||
val audioTracks: List<Track> = emptyList(),
|
||||
) : ProgressListener {
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
constructor(
|
||||
url: String,
|
||||
quality: String,
|
||||
videoUrl: String?,
|
||||
uri: Uri? = null,
|
||||
headers: Headers? = null,
|
||||
) : this(url, quality, videoUrl, headers)
|
||||
|
||||
@Transient
|
||||
@Volatile
|
||||
var status: State = State.QUEUE
|
||||
set(value) {
|
||||
field = value
|
||||
}
|
||||
|
||||
@Transient
|
||||
private val _progressFlow = MutableStateFlow(0)
|
||||
|
||||
@Transient
|
||||
val progressFlow = _progressFlow.asStateFlow()
|
||||
var progress: Int
|
||||
get() = _progressFlow.value
|
||||
set(value) {
|
||||
_progressFlow.value = value
|
||||
}
|
||||
|
||||
@Transient
|
||||
@Volatile
|
||||
var totalBytesDownloaded: Long = 0L
|
||||
|
||||
@Transient
|
||||
@Volatile
|
||||
var totalContentLength: Long = 0L
|
||||
|
||||
@Transient
|
||||
@Volatile
|
||||
var bytesDownloaded: Long = 0L
|
||||
set(value) {
|
||||
totalBytesDownloaded += if (value < field) {
|
||||
value
|
||||
} else {
|
||||
value - field
|
||||
}
|
||||
field = value
|
||||
}
|
||||
|
||||
@Transient
|
||||
var progressSubject: Subject<State, State>? = null
|
||||
|
||||
override fun update(bytesRead: Long, contentLength: Long, done: Boolean) {
|
||||
bytesDownloaded = bytesRead
|
||||
if (contentLength > totalContentLength) {
|
||||
totalContentLength = contentLength
|
||||
}
|
||||
val newProgress = if (totalContentLength > 0) {
|
||||
(100 * totalBytesDownloaded / totalContentLength).toInt()
|
||||
} else {
|
||||
-1
|
||||
}
|
||||
if (progress != newProgress) progress = newProgress
|
||||
}
|
||||
|
||||
enum class State {
|
||||
QUEUE,
|
||||
LOAD_VIDEO,
|
||||
DOWNLOAD_IMAGE,
|
||||
READY,
|
||||
ERROR,
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package eu.kanade.tachiyomi.network
|
||||
|
||||
import android.content.Context
|
||||
import ani.dantotsu.aniyomi.util.network.AndroidCookieJar
|
||||
import ani.dantotsu.aniyomi.util.network.PREF_DOH_CLOUDFLARE
|
||||
import ani.dantotsu.aniyomi.util.network.PREF_DOH_GOOGLE
|
||||
import ani.dantotsu.aniyomi.util.network.dohCloudflare
|
||||
import ani.dantotsu.aniyomi.util.network.dohGoogle
|
||||
import ani.dantotsu.aniyomi.util.network.interceptor.CloudflareInterceptor
|
||||
import eu.kanade.tachiyomi.network.interceptor.UncaughtExceptionInterceptor
|
||||
import eu.kanade.tachiyomi.network.interceptor.UserAgentInterceptor
|
||||
import okhttp3.Cache
|
||||
import okhttp3.OkHttpClient
|
||||
import java.io.File
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class NetworkHelper(
|
||||
context: Context,
|
||||
) {
|
||||
|
||||
private val cacheDir = File(context.cacheDir, "network_cache")
|
||||
private val cacheSize = 5L * 1024 * 1024 // 5 MiB
|
||||
|
||||
val cookieJar = AndroidCookieJar()
|
||||
|
||||
private val userAgentInterceptor by lazy {
|
||||
UserAgentInterceptor(::defaultUserAgentProvider)
|
||||
}
|
||||
private val cloudflareInterceptor by lazy {
|
||||
CloudflareInterceptor(context, cookieJar, ::defaultUserAgentProvider)
|
||||
}
|
||||
|
||||
private val baseClientBuilder: OkHttpClient.Builder
|
||||
get() {
|
||||
val builder = OkHttpClient.Builder()
|
||||
.cookieJar(cookieJar)
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.callTimeout(2, TimeUnit.MINUTES)
|
||||
.addInterceptor(UncaughtExceptionInterceptor())
|
||||
.addInterceptor(userAgentInterceptor)
|
||||
|
||||
/*if (preferences.verboseLogging().get()) {
|
||||
val httpLoggingInterceptor = HttpLoggingInterceptor().apply {
|
||||
level = HttpLoggingInterceptor.Level.HEADERS
|
||||
}
|
||||
builder.addNetworkInterceptor(httpLoggingInterceptor)
|
||||
}*/
|
||||
|
||||
//when (preferences.dohProvider().get()) {
|
||||
when (PREF_DOH_CLOUDFLARE) {
|
||||
PREF_DOH_CLOUDFLARE -> builder.dohCloudflare()
|
||||
PREF_DOH_GOOGLE -> builder.dohGoogle()
|
||||
/*PREF_DOH_ADGUARD -> builder.dohAdGuard()
|
||||
PREF_DOH_QUAD9 -> builder.dohQuad9()
|
||||
PREF_DOH_ALIDNS -> builder.dohAliDNS()
|
||||
PREF_DOH_DNSPOD -> builder.dohDNSPod()
|
||||
PREF_DOH_360 -> builder.doh360()
|
||||
PREF_DOH_QUAD101 -> builder.dohQuad101()
|
||||
PREF_DOH_MULLVAD -> builder.dohMullvad()
|
||||
PREF_DOH_CONTROLD -> builder.dohControlD()
|
||||
PREF_DOH_NJALLA -> builder.dohNajalla()
|
||||
PREF_DOH_SHECAN -> builder.dohShecan()*/
|
||||
}
|
||||
|
||||
return builder
|
||||
}
|
||||
|
||||
val client by lazy { baseClientBuilder.cache(Cache(cacheDir, cacheSize)).build() }
|
||||
|
||||
@Suppress("UNUSED")
|
||||
val cloudflareClient by lazy {
|
||||
client.newBuilder()
|
||||
.addInterceptor(cloudflareInterceptor)
|
||||
.build()
|
||||
}
|
||||
|
||||
fun defaultUserAgentProvider() = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:110.0) Gecko/20100101 Firefox/110.0"//preferences.defaultUserAgent().get().trim()
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
package ani.dantotsu.aniyomi.util.srcapi
|
||||
|
||||
//actual suspend fun <T> Observable<T>.awaitSingle(): T = awaitSingle()
|
||||
@@ -6,34 +6,40 @@ import ani.dantotsu.connections.anilist.Anilist
|
||||
import ani.dantotsu.connections.mal.MAL
|
||||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.media.Media
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.toast
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
fun updateProgress(media: Media, number: String) {
|
||||
if (Anilist.userid != null) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val a = number.toFloatOrNull()?.roundToInt()
|
||||
if (a != media.userProgress) {
|
||||
Anilist.mutation.editList(
|
||||
media.id,
|
||||
a,
|
||||
status = if (media.userStatus == "REPEATING") media.userStatus else "CURRENT"
|
||||
)
|
||||
MAL.query.editList(
|
||||
media.idMAL,
|
||||
media.anime != null,
|
||||
a, null,
|
||||
if (media.userStatus == "REPEATING") media.userStatus!! else "CURRENT"
|
||||
)
|
||||
toast(currContext()?.getString(R.string.setting_progress, a))
|
||||
val incognito: Boolean = PrefManager.getVal(PrefName.Incognito)
|
||||
if (!incognito) {
|
||||
if (Anilist.userid != null) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val a = number.toFloatOrNull()?.toInt()
|
||||
if ((a ?: 0) > (media.userProgress ?: -1)) {
|
||||
Anilist.mutation.editList(
|
||||
media.id,
|
||||
a,
|
||||
status = if (media.userStatus == "REPEATING") media.userStatus else "CURRENT"
|
||||
)
|
||||
MAL.query.editList(
|
||||
media.idMAL,
|
||||
media.anime != null,
|
||||
a, null,
|
||||
if (media.userStatus == "REPEATING") media.userStatus!! else "CURRENT"
|
||||
)
|
||||
toast(currContext()?.getString(R.string.setting_progress, a))
|
||||
}
|
||||
media.userProgress = a
|
||||
Refresh.all()
|
||||
}
|
||||
media.userProgress = a
|
||||
Refresh.all()
|
||||
} else {
|
||||
toast(currContext()?.getString(R.string.login_anilist_account))
|
||||
}
|
||||
} else {
|
||||
toast(currContext()?.getString(R.string.login_anilist_account))
|
||||
toast("Sneaky sneaky :3")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package ani.dantotsu.connections.anilist
|
||||
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.media.Author
|
||||
import ani.dantotsu.media.Character
|
||||
import ani.dantotsu.media.Media
|
||||
import ani.dantotsu.media.Studio
|
||||
import ani.dantotsu.profile.User
|
||||
import java.io.Serializable
|
||||
|
||||
interface SearchResults<T> {
|
||||
var search: String?
|
||||
var page: Int
|
||||
var results: MutableList<T>
|
||||
var hasNextPage: Boolean
|
||||
}
|
||||
|
||||
data class AniMangaSearchResults(
|
||||
val type: String,
|
||||
var isAdult: Boolean,
|
||||
var onList: Boolean? = null,
|
||||
var perPage: Int? = null,
|
||||
var countryOfOrigin: String? = null,
|
||||
var sort: String? = null,
|
||||
var genres: MutableList<String>? = null,
|
||||
var excludedGenres: MutableList<String>? = null,
|
||||
var tags: MutableList<String>? = null,
|
||||
var excludedTags: MutableList<String>? = null,
|
||||
var status: String? = null,
|
||||
var source: String? = null,
|
||||
var format: String? = null,
|
||||
var seasonYear: Int? = null,
|
||||
var startYear: Int? = null,
|
||||
var season: String? = null,
|
||||
override var search: String? = null,
|
||||
override var page: Int = 1,
|
||||
override var results: MutableList<Media>,
|
||||
override var hasNextPage: Boolean,
|
||||
) : SearchResults<Media>, Serializable {
|
||||
fun toChipList(): List<SearchChip> {
|
||||
val list = mutableListOf<SearchChip>()
|
||||
sort?.let {
|
||||
val c = currContext()!!
|
||||
list.add(
|
||||
SearchChip(
|
||||
"SORT",
|
||||
c.getString(
|
||||
R.string.filter_sort,
|
||||
c.resources.getStringArray(R.array.sort_by)[Anilist.sortBy.indexOf(it)]
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
status?.let {
|
||||
list.add(SearchChip("STATUS", currContext()!!.getString(R.string.filter_status, it)))
|
||||
}
|
||||
source?.let {
|
||||
list.add(SearchChip("SOURCE", currContext()!!.getString(R.string.filter_source, it)))
|
||||
}
|
||||
format?.let {
|
||||
list.add(SearchChip("FORMAT", currContext()!!.getString(R.string.filter_format, it)))
|
||||
}
|
||||
countryOfOrigin?.let {
|
||||
list.add(SearchChip("COUNTRY", currContext()!!.getString(R.string.filter_country, it)))
|
||||
}
|
||||
season?.let {
|
||||
list.add(SearchChip("SEASON", it))
|
||||
}
|
||||
startYear?.let {
|
||||
list.add(SearchChip("START_YEAR", it.toString()))
|
||||
}
|
||||
seasonYear?.let {
|
||||
list.add(SearchChip("SEASON_YEAR", it.toString()))
|
||||
}
|
||||
genres?.forEach {
|
||||
list.add(SearchChip("GENRE", it))
|
||||
}
|
||||
excludedGenres?.forEach {
|
||||
list.add(
|
||||
SearchChip(
|
||||
"EXCLUDED_GENRE",
|
||||
currContext()!!.getString(R.string.filter_exclude, it)
|
||||
)
|
||||
)
|
||||
}
|
||||
tags?.forEach {
|
||||
list.add(SearchChip("TAG", it))
|
||||
}
|
||||
excludedTags?.forEach {
|
||||
list.add(
|
||||
SearchChip(
|
||||
"EXCLUDED_TAG",
|
||||
currContext()!!.getString(R.string.filter_exclude, it)
|
||||
)
|
||||
)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
fun removeChip(chip: SearchChip) {
|
||||
when (chip.type) {
|
||||
"SORT" -> sort = null
|
||||
"STATUS" -> status = null
|
||||
"SOURCE" -> source = null
|
||||
"FORMAT" -> format = null
|
||||
"COUNTRY" -> countryOfOrigin = null
|
||||
"SEASON" -> season = null
|
||||
"START_YEAR" -> startYear = null
|
||||
"SEASON_YEAR" -> seasonYear = null
|
||||
"GENRE" -> genres?.remove(chip.text)
|
||||
"EXCLUDED_GENRE" -> excludedGenres?.remove(chip.text)
|
||||
"TAG" -> tags?.remove(chip.text)
|
||||
"EXCLUDED_TAG" -> excludedTags?.remove(chip.text)
|
||||
}
|
||||
}
|
||||
|
||||
data class SearchChip(
|
||||
val type: String,
|
||||
val text: String
|
||||
)
|
||||
}
|
||||
|
||||
data class CharacterSearchResults(
|
||||
override var search: String?,
|
||||
override var page: Int = 1,
|
||||
override var results: MutableList<Character>,
|
||||
override var hasNextPage: Boolean,
|
||||
) : SearchResults<Character>, Serializable
|
||||
|
||||
data class StudioSearchResults(
|
||||
override var search: String?,
|
||||
override var page: Int = 1,
|
||||
override var results: MutableList<Studio>,
|
||||
override var hasNextPage: Boolean,
|
||||
) : SearchResults<Studio>, Serializable
|
||||
|
||||
|
||||
data class StaffSearchResults(
|
||||
override var search: String?,
|
||||
override var page: Int = 1,
|
||||
override var results: MutableList<Author>,
|
||||
override var hasNextPage: Boolean,
|
||||
) : SearchResults<Author>, Serializable
|
||||
|
||||
data class UserSearchResults(
|
||||
override var search: String?,
|
||||
override var page: Int = 1,
|
||||
override var results: MutableList<User>,
|
||||
override var hasNextPage: Boolean,
|
||||
) : SearchResults<User>, Serializable
|
||||
@@ -6,11 +6,17 @@ import android.net.Uri
|
||||
import androidx.browser.customtabs.CustomTabsIntent
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.client
|
||||
import ani.dantotsu.connections.comments.CommentsAPI
|
||||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.openLinkInBrowser
|
||||
import ani.dantotsu.tryWithSuspend
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.toast
|
||||
import ani.dantotsu.util.Logger
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
import kotlin.math.abs
|
||||
|
||||
object Anilist {
|
||||
val query: AnilistQueries = AnilistQueries()
|
||||
@@ -18,29 +24,84 @@ object Anilist {
|
||||
|
||||
var token: String? = null
|
||||
var username: String? = null
|
||||
var adult: Boolean = false
|
||||
|
||||
var userid: Int? = null
|
||||
var avatar: String? = null
|
||||
var bg: String? = null
|
||||
var episodesWatched: Int? = null
|
||||
var chapterRead: Int? = null
|
||||
var unreadNotificationCount: Int = 0
|
||||
|
||||
var genres: ArrayList<String>? = null
|
||||
var tags: Map<Boolean, List<String>>? = null
|
||||
|
||||
var rateLimitReset: Long = 0
|
||||
|
||||
var initialized = false
|
||||
var adult: Boolean = false
|
||||
var titleLanguage: String? = null
|
||||
var staffNameLanguage: String? = null
|
||||
var airingNotifications: Boolean = false
|
||||
var restrictMessagesToFollowing: Boolean = false
|
||||
var scoreFormat: String? = null
|
||||
var rowOrder: String? = null
|
||||
var activityMergeTime: Int? = null
|
||||
var timezone: String? = null
|
||||
var animeCustomLists: List<String>? = null
|
||||
var mangaCustomLists: List<String>? = null
|
||||
|
||||
val sortBy = listOf(
|
||||
"SCORE_DESC","POPULARITY_DESC","TRENDING_DESC","TITLE_ENGLISH","TITLE_ENGLISH_DESC","SCORE"
|
||||
"SCORE_DESC",
|
||||
"POPULARITY_DESC",
|
||||
"TRENDING_DESC",
|
||||
"START_DATE_DESC",
|
||||
"TITLE_ENGLISH",
|
||||
"TITLE_ENGLISH_DESC",
|
||||
"SCORE"
|
||||
)
|
||||
|
||||
val source = listOf(
|
||||
"ORIGINAL",
|
||||
"MANGA",
|
||||
"LIGHT NOVEL",
|
||||
"VISUAL NOVEL",
|
||||
"VIDEO GAME",
|
||||
"OTHER",
|
||||
"NOVEL",
|
||||
"DOUJINSHI",
|
||||
"ANIME",
|
||||
"WEB NOVEL",
|
||||
"LIVE ACTION",
|
||||
"GAME",
|
||||
"COMIC",
|
||||
"MULTIMEDIA PROJECT",
|
||||
"PICTURE BOOK"
|
||||
)
|
||||
|
||||
val animeStatus = listOf(
|
||||
"FINISHED",
|
||||
"RELEASING",
|
||||
"NOT YET RELEASED",
|
||||
"CANCELLED"
|
||||
)
|
||||
|
||||
val mangaStatus = listOf(
|
||||
"FINISHED",
|
||||
"RELEASING",
|
||||
"NOT YET RELEASED",
|
||||
"HIATUS",
|
||||
"CANCELLED"
|
||||
)
|
||||
|
||||
val seasons = listOf(
|
||||
"WINTER", "SPRING", "SUMMER", "FALL"
|
||||
)
|
||||
|
||||
val anime_formats = listOf(
|
||||
val animeFormats = listOf(
|
||||
"TV", "TV SHORT", "MOVIE", "SPECIAL", "OVA", "ONA", "MUSIC"
|
||||
)
|
||||
|
||||
val manga_formats = listOf(
|
||||
val mangaFormats = listOf(
|
||||
"MANGA", "NOVEL", "ONE SHOT"
|
||||
)
|
||||
|
||||
@@ -48,14 +109,121 @@ object Anilist {
|
||||
"Original Creator", "Story & Art", "Story"
|
||||
)
|
||||
|
||||
val timeZone = listOf(
|
||||
"(GMT-11:00) Pago Pago",
|
||||
"(GMT-10:00) Hawaii Time",
|
||||
"(GMT-09:00) Alaska Time",
|
||||
"(GMT-08:00) Pacific Time",
|
||||
"(GMT-07:00) Mountain Time",
|
||||
"(GMT-06:00) Central Time",
|
||||
"(GMT-05:00) Eastern Time",
|
||||
"(GMT-04:00) Atlantic Time - Halifax",
|
||||
"(GMT-03:00) Sao Paulo",
|
||||
"(GMT-02:00) Mid-Atlantic",
|
||||
"(GMT-01:00) Azores",
|
||||
"(GMT+00:00) London",
|
||||
"(GMT+01:00) Berlin",
|
||||
"(GMT+02:00) Helsinki",
|
||||
"(GMT+03:00) Istanbul",
|
||||
"(GMT+04:00) Dubai",
|
||||
"(GMT+04:30) Kabul",
|
||||
"(GMT+05:00) Maldives",
|
||||
"(GMT+05:30) India Standard Time",
|
||||
"(GMT+05:45) Kathmandu",
|
||||
"(GMT+06:00) Dhaka",
|
||||
"(GMT+06:30) Cocos",
|
||||
"(GMT+07:00) Bangkok",
|
||||
"(GMT+08:00) Hong Kong",
|
||||
"(GMT+08:30) Pyongyang",
|
||||
"(GMT+09:00) Tokyo",
|
||||
"(GMT+09:30) Central Time - Darwin",
|
||||
"(GMT+10:00) Eastern Time - Brisbane",
|
||||
"(GMT+10:30) Central Time - Adelaide",
|
||||
"(GMT+11:00) Eastern Time - Melbourne, Sydney",
|
||||
"(GMT+12:00) Nauru",
|
||||
"(GMT+13:00) Auckland",
|
||||
"(GMT+14:00) Kiritimati",
|
||||
)
|
||||
|
||||
val titleLang = listOf(
|
||||
"English (Attack on Titan)",
|
||||
"Romaji (Shingeki no Kyojin)",
|
||||
"Native (進撃の巨人)"
|
||||
)
|
||||
|
||||
val staffNameLang = listOf(
|
||||
"Romaji, Western Order (Killua Zoldyck)",
|
||||
"Romaji (Zoldyck Killua)",
|
||||
"Native (キルア=ゾルディック)"
|
||||
)
|
||||
|
||||
val scoreFormats = listOf(
|
||||
"100 Point (55/100)",
|
||||
"10 Point Decimal (5.5/10)",
|
||||
"10 Point (5/10)",
|
||||
"5 Star (3/5)",
|
||||
"3 Point Smiley :)"
|
||||
)
|
||||
|
||||
val rowOrderMap = mapOf(
|
||||
"Score" to "score",
|
||||
"Title" to "title",
|
||||
"Last Updated" to "updatedAt",
|
||||
"Last Added" to "id"
|
||||
)
|
||||
|
||||
val activityMergeTimeMap = mapOf(
|
||||
"Never" to 0,
|
||||
"30 mins" to 30,
|
||||
"69 mins" to 69,
|
||||
"1 hour" to 60,
|
||||
"2 hours" to 120,
|
||||
"3 hours" to 180,
|
||||
"6 hours" to 360,
|
||||
"12 hours" to 720,
|
||||
"1 day" to 1440,
|
||||
"2 days" to 2880,
|
||||
"3 days" to 4320,
|
||||
"1 week" to 10080,
|
||||
"2 weeks" to 20160,
|
||||
"Always" to 29160
|
||||
)
|
||||
|
||||
private val cal: Calendar = Calendar.getInstance()
|
||||
private val currentYear = cal.get(Calendar.YEAR)
|
||||
private val currentSeason: Int = when (cal.get(Calendar.MONTH)) {
|
||||
0, 1, 2 -> 0
|
||||
3, 4, 5 -> 1
|
||||
6, 7, 8 -> 2
|
||||
0, 1, 2 -> 0
|
||||
3, 4, 5 -> 1
|
||||
6, 7, 8 -> 2
|
||||
9, 10, 11 -> 3
|
||||
else -> 0
|
||||
else -> 0
|
||||
}
|
||||
|
||||
fun getDisplayTimezone(apiTimezone: String, context: Context): String {
|
||||
val noTimezone = context.getString(R.string.selected_no_time_zone)
|
||||
val parts = apiTimezone.split(":")
|
||||
if (parts.size != 2) return noTimezone
|
||||
|
||||
val hours = parts[0].toIntOrNull() ?: 0
|
||||
val minutes = parts[1].toIntOrNull() ?: 0
|
||||
val sign = if (hours >= 0) "+" else "-"
|
||||
val formattedHours = String.format(Locale.US, "%02d", abs(hours))
|
||||
val formattedMinutes = String.format(Locale.US, "%02d", minutes)
|
||||
|
||||
val searchString = "(GMT$sign$formattedHours:$formattedMinutes)"
|
||||
return timeZone.find { it.contains(searchString) } ?: noTimezone
|
||||
}
|
||||
|
||||
fun getApiTimezone(displayTimezone: String): String {
|
||||
val regex = """\(GMT([+-])(\d{2}):(\d{2})\)""".toRegex()
|
||||
val matchResult = regex.find(displayTimezone)
|
||||
return if (matchResult != null) {
|
||||
val (sign, hours, minutes) = matchResult.destructured
|
||||
val formattedSign = if (sign == "+") "" else "-"
|
||||
"$formattedSign$hours:$minutes"
|
||||
} else {
|
||||
"00:00"
|
||||
}
|
||||
}
|
||||
|
||||
private fun getSeason(next: Boolean): Pair<String, Int> {
|
||||
@@ -89,15 +257,12 @@ object Anilist {
|
||||
}
|
||||
}
|
||||
|
||||
fun getSavedToken(context: Context): Boolean {
|
||||
if ("anilistToken" in context.fileList()) {
|
||||
token = File(context.filesDir, "anilistToken").readText()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
fun getSavedToken(): Boolean {
|
||||
token = PrefManager.getVal(PrefName.AnilistToken, null as String?)
|
||||
return !token.isNullOrEmpty()
|
||||
}
|
||||
|
||||
fun removeSavedToken(context: Context) {
|
||||
fun removeSavedToken() {
|
||||
token = null
|
||||
username = null
|
||||
adult = false
|
||||
@@ -106,9 +271,10 @@ object Anilist {
|
||||
bg = null
|
||||
episodesWatched = null
|
||||
chapterRead = null
|
||||
if ("anilistToken" in context.fileList()) {
|
||||
File(context.filesDir, "anilistToken").delete()
|
||||
}
|
||||
PrefManager.removeVal(PrefName.AnilistToken)
|
||||
//logout from comments api
|
||||
CommentsAPI.logout()
|
||||
|
||||
}
|
||||
|
||||
suspend inline fun <reified T : Any> executeQuery(
|
||||
@@ -119,24 +285,51 @@ object Anilist {
|
||||
show: Boolean = false,
|
||||
cache: Int? = null
|
||||
): T? {
|
||||
return tryWithSuspend {
|
||||
return try {
|
||||
if (show) Logger.log("Anilist Query: $query")
|
||||
if (rateLimitReset > System.currentTimeMillis() / 1000) {
|
||||
toast("Rate limited. Try after ${rateLimitReset - (System.currentTimeMillis() / 1000)} seconds")
|
||||
throw Exception("Rate limited after ${rateLimitReset - (System.currentTimeMillis() / 1000)} seconds")
|
||||
}
|
||||
val data = mapOf(
|
||||
"query" to query,
|
||||
"variables" to variables
|
||||
)
|
||||
val headers = mutableMapOf(
|
||||
"Content-Type" to "application/json",
|
||||
"Content-Type" to "application/json; charset=utf-8",
|
||||
"Accept" to "application/json"
|
||||
)
|
||||
|
||||
if (token != null || force) {
|
||||
if (token != null && useToken) headers["Authorization"] = "Bearer $token"
|
||||
|
||||
val json = client.post("https://graphql.anilist.co/", headers, data = data, cacheTime = cache ?: 10)
|
||||
if (!json.text.startsWith("{")) throw Exception(currContext()?.getString(R.string.anilist_down))
|
||||
if (show) println("Response : ${json.text}")
|
||||
val json = client.post(
|
||||
"https://graphql.anilist.co/",
|
||||
headers,
|
||||
data = data,
|
||||
cacheTime = cache ?: 10
|
||||
)
|
||||
val remaining = json.headers["X-RateLimit-Remaining"]?.toIntOrNull() ?: -1
|
||||
Logger.log("Remaining requests: $remaining")
|
||||
if (json.code == 429) {
|
||||
val retry = json.headers["Retry-After"]?.toIntOrNull() ?: -1
|
||||
val passedLimitReset = json.headers["X-RateLimit-Reset"]?.toLongOrNull() ?: 0
|
||||
if (retry > 0) {
|
||||
rateLimitReset = passedLimitReset
|
||||
}
|
||||
|
||||
toast("Rate limited. Try after $retry seconds")
|
||||
throw Exception("Rate limited after $retry seconds")
|
||||
}
|
||||
if (!json.text.startsWith("{")) {
|
||||
throw Exception(currContext()?.getString(R.string.anilist_down))
|
||||
}
|
||||
json.parsed()
|
||||
} else null
|
||||
} catch (e: Exception) {
|
||||
if (show) snackString("Error fetching Anilist data: ${e.message}")
|
||||
Logger.log("Anilist Query Error: ${e.message}")
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,179 @@ package ani.dantotsu.connections.anilist
|
||||
|
||||
import ani.dantotsu.connections.anilist.Anilist.executeQuery
|
||||
import ani.dantotsu.connections.anilist.api.FuzzyDate
|
||||
import ani.dantotsu.connections.anilist.api.Query
|
||||
import ani.dantotsu.connections.anilist.api.ToggleLike
|
||||
import ani.dantotsu.currContext
|
||||
import com.google.gson.Gson
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
class AnilistMutations {
|
||||
|
||||
suspend fun updateSettings(
|
||||
timezone: String? = null,
|
||||
titleLanguage: String? = null,
|
||||
staffNameLanguage: String? = null,
|
||||
activityMergeTime: Int? = null,
|
||||
airingNotifications: Boolean? = null,
|
||||
displayAdultContent: Boolean? = null,
|
||||
restrictMessagesToFollowing: Boolean? = null,
|
||||
scoreFormat: String? = null,
|
||||
rowOrder: String? = null,
|
||||
) {
|
||||
val query = """
|
||||
mutation (
|
||||
${"$"}timezone: String,
|
||||
${"$"}titleLanguage: UserTitleLanguage,
|
||||
${"$"}staffNameLanguage: UserStaffNameLanguage,
|
||||
${"$"}activityMergeTime: Int,
|
||||
${"$"}airingNotifications: Boolean,
|
||||
${"$"}displayAdultContent: Boolean,
|
||||
${"$"}restrictMessagesToFollowing: Boolean,
|
||||
${"$"}scoreFormat: ScoreFormat,
|
||||
${"$"}rowOrder: String
|
||||
) {
|
||||
UpdateUser(
|
||||
timezone: ${"$"}timezone,
|
||||
titleLanguage: ${"$"}titleLanguage,
|
||||
staffNameLanguage: ${"$"}staffNameLanguage,
|
||||
activityMergeTime: ${"$"}activityMergeTime,
|
||||
airingNotifications: ${"$"}airingNotifications,
|
||||
displayAdultContent: ${"$"}displayAdultContent,
|
||||
restrictMessagesToFollowing: ${"$"}restrictMessagesToFollowing,
|
||||
scoreFormat: ${"$"}scoreFormat,
|
||||
rowOrder: ${"$"}rowOrder,
|
||||
) {
|
||||
id
|
||||
options {
|
||||
timezone
|
||||
titleLanguage
|
||||
staffNameLanguage
|
||||
activityMergeTime
|
||||
airingNotifications
|
||||
displayAdultContent
|
||||
restrictMessagesToFollowing
|
||||
}
|
||||
mediaListOptions {
|
||||
scoreFormat
|
||||
rowOrder
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
val variables = """
|
||||
{
|
||||
${timezone?.let { """"timezone":"$it"""" } ?: ""}
|
||||
${titleLanguage?.let { """"titleLanguage":"$it"""" } ?: ""}
|
||||
${staffNameLanguage?.let { """"staffNameLanguage":"$it"""" } ?: ""}
|
||||
${activityMergeTime?.let { """"activityMergeTime":$it""" } ?: ""}
|
||||
${airingNotifications?.let { """"airingNotifications":$it""" } ?: ""}
|
||||
${displayAdultContent?.let { """"displayAdultContent":$it""" } ?: ""}
|
||||
${restrictMessagesToFollowing?.let { """"restrictMessagesToFollowing":$it""" } ?: ""}
|
||||
${scoreFormat?.let { """"scoreFormat":"$it"""" } ?: ""}
|
||||
${rowOrder?.let { """"rowOrder":"$it"""" } ?: ""}
|
||||
}
|
||||
""".trimIndent().replace("\n", "").replace(""" """, "").replace(",}", "}")
|
||||
|
||||
executeQuery<JsonObject>(query, variables)
|
||||
}
|
||||
|
||||
suspend fun toggleFav(anime: Boolean = true, id: Int) {
|
||||
val query =
|
||||
"""mutation (${"$"}animeId: Int,${"$"}mangaId:Int) { ToggleFavourite(animeId:${"$"}animeId,mangaId:${"$"}mangaId){ anime { edges { id } } manga { edges { id } } } }"""
|
||||
val query = """
|
||||
mutation (${"$"}animeId: Int, ${"$"}mangaId: Int) {
|
||||
ToggleFavourite(animeId: ${"$"}animeId, mangaId: ${"$"}mangaId) {
|
||||
anime {
|
||||
edges {
|
||||
id
|
||||
}
|
||||
}
|
||||
manga {
|
||||
edges {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
val variables = if (anime) """{"animeId":"$id"}""" else """{"mangaId":"$id"}"""
|
||||
executeQuery<JsonObject>(query, variables)
|
||||
}
|
||||
|
||||
suspend fun toggleFav(type: FavType, id: Int): Boolean {
|
||||
val filter = when (type) {
|
||||
FavType.ANIME -> "animeId"
|
||||
FavType.MANGA -> "mangaId"
|
||||
FavType.CHARACTER -> "characterId"
|
||||
FavType.STAFF -> "staffId"
|
||||
FavType.STUDIO -> "studioId"
|
||||
}
|
||||
val query = """
|
||||
mutation {
|
||||
ToggleFavourite($filter: $id) {
|
||||
anime {
|
||||
pageInfo {
|
||||
total
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
val result = executeQuery<JsonObject>(query)
|
||||
return result?.get("errors") == null && result != null
|
||||
}
|
||||
|
||||
enum class FavType {
|
||||
ANIME, MANGA, CHARACTER, STAFF, STUDIO
|
||||
}
|
||||
|
||||
suspend fun deleteCustomList(name: String, type: String): Boolean {
|
||||
val query = """
|
||||
mutation (${"$"}name: String, ${"$"}type: MediaType) {
|
||||
DeleteCustomList(customList: ${"$"}name, type: ${"$"}type) {
|
||||
deleted
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
val variables = """
|
||||
{
|
||||
"name": "$name",
|
||||
"type": "$type"
|
||||
}
|
||||
""".trimIndent()
|
||||
val result = executeQuery<JsonObject>(query, variables)
|
||||
return result?.get("errors") == null
|
||||
}
|
||||
|
||||
suspend fun updateCustomLists(
|
||||
animeCustomLists: List<String>?,
|
||||
mangaCustomLists: List<String>?
|
||||
): Boolean {
|
||||
val query = """
|
||||
mutation (${"$"}animeListOptions: MediaListOptionsInput, ${"$"}mangaListOptions: MediaListOptionsInput) {
|
||||
UpdateUser(animeListOptions: ${"$"}animeListOptions, mangaListOptions: ${"$"}mangaListOptions) {
|
||||
mediaListOptions {
|
||||
animeList {
|
||||
customLists
|
||||
}
|
||||
mangaList {
|
||||
customLists
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
val variables = """
|
||||
{
|
||||
${animeCustomLists?.let { """"animeListOptions": {"customLists": ${Gson().toJson(it)}}""" } ?: ""}
|
||||
${if (animeCustomLists != null && mangaCustomLists != null) "," else ""}
|
||||
${mangaCustomLists?.let { """"mangaListOptions": {"customLists": ${Gson().toJson(it)}}""" } ?: ""}
|
||||
}
|
||||
""".trimIndent().replace("\n", "").replace(""" """, "").replace(",}", "}")
|
||||
|
||||
val result = executeQuery<JsonObject>(query, variables)
|
||||
return result?.get("errors") == null
|
||||
}
|
||||
|
||||
suspend fun editList(
|
||||
mediaID: Int,
|
||||
progress: Int? = null,
|
||||
@@ -20,19 +182,50 @@ class AnilistMutations {
|
||||
repeat: Int? = null,
|
||||
notes: String? = null,
|
||||
status: String? = null,
|
||||
private:Boolean? = null,
|
||||
private: Boolean? = null,
|
||||
startedAt: FuzzyDate? = null,
|
||||
completedAt: FuzzyDate? = null,
|
||||
customList: List<String>? = null
|
||||
) {
|
||||
|
||||
val query = """
|
||||
mutation ( ${"$"}mediaID: Int, ${"$"}progress: Int,${"$"}private:Boolean,${"$"}repeat: Int, ${"$"}notes: String, ${"$"}customLists: [String], ${"$"}scoreRaw:Int, ${"$"}status:MediaListStatus, ${"$"}start:FuzzyDateInput${if (startedAt != null) "=" + startedAt.toVariableString() else ""}, ${"$"}completed:FuzzyDateInput${if (completedAt != null) "=" + completedAt.toVariableString() else ""} ) {
|
||||
SaveMediaListEntry( mediaId: ${"$"}mediaID, progress: ${"$"}progress, repeat: ${"$"}repeat, notes: ${"$"}notes, private: ${"$"}private, scoreRaw: ${"$"}scoreRaw, status:${"$"}status, startedAt: ${"$"}start, completedAt: ${"$"}completed , customLists: ${"$"}customLists ) {
|
||||
score(format:POINT_10_DECIMAL) startedAt{year month day} completedAt{year month day}
|
||||
mutation (
|
||||
${"$"}mediaID: Int,
|
||||
${"$"}progress: Int,
|
||||
${"$"}private: Boolean,
|
||||
${"$"}repeat: Int,
|
||||
${"$"}notes: String,
|
||||
${"$"}customLists: [String],
|
||||
${"$"}scoreRaw: Int,
|
||||
${"$"}status: MediaListStatus,
|
||||
${"$"}start: FuzzyDateInput${if (startedAt != null) "=" + startedAt.toVariableString() else ""},
|
||||
${"$"}completed: FuzzyDateInput${if (completedAt != null) "=" + completedAt.toVariableString() else ""}
|
||||
) {
|
||||
SaveMediaListEntry(
|
||||
mediaId: ${"$"}mediaID,
|
||||
progress: ${"$"}progress,
|
||||
repeat: ${"$"}repeat,
|
||||
notes: ${"$"}notes,
|
||||
private: ${"$"}private,
|
||||
scoreRaw: ${"$"}scoreRaw,
|
||||
status: ${"$"}status,
|
||||
startedAt: ${"$"}start,
|
||||
completedAt: ${"$"}completed,
|
||||
customLists: ${"$"}customLists
|
||||
) {
|
||||
score(format: POINT_10_DECIMAL)
|
||||
startedAt {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
completedAt {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
}
|
||||
}
|
||||
""".replace("\n", "").replace(""" """, "")
|
||||
""".trimIndent()
|
||||
|
||||
val variables = """{"mediaID":$mediaID
|
||||
${if (private != null) ""","private":$private""" else ""}
|
||||
@@ -41,15 +234,201 @@ class AnilistMutations {
|
||||
${if (repeat != null) ""","repeat":$repeat""" else ""}
|
||||
${if (notes != null) ""","notes":"${notes.replace("\n", "\\n")}"""" else ""}
|
||||
${if (status != null) ""","status":"$status"""" else ""}
|
||||
${if (customList !=null) ""","customLists":[${customList.joinToString { "\"$it\"" }}]""" else ""}
|
||||
${if (customList != null) ""","customLists":[${customList.joinToString { "\"$it\"" }}]""" else ""}
|
||||
}""".replace("\n", "").replace(""" """, "")
|
||||
println(variables)
|
||||
executeQuery<JsonObject>(query, variables, show = true)
|
||||
}
|
||||
|
||||
suspend fun deleteList(listId: Int) {
|
||||
val query = "mutation(${"$"}id:Int){DeleteMediaListEntry(id:${"$"}id){deleted}}"
|
||||
val query = """
|
||||
mutation(${"$"}id: Int) {
|
||||
DeleteMediaListEntry(id: ${"$"}id) {
|
||||
deleted
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
val variables = """{"id":"$listId"}"""
|
||||
executeQuery<JsonObject>(query, variables)
|
||||
}
|
||||
|
||||
suspend fun rateReview(reviewId: Int, rating: String): Query.RateReviewResponse? {
|
||||
val query = """
|
||||
mutation {
|
||||
RateReview(reviewId: $reviewId, rating: $rating) {
|
||||
id
|
||||
mediaId
|
||||
mediaType
|
||||
summary
|
||||
body(asHtml: true)
|
||||
rating
|
||||
ratingAmount
|
||||
userRating
|
||||
score
|
||||
private
|
||||
siteUrl
|
||||
createdAt
|
||||
updatedAt
|
||||
user {
|
||||
id
|
||||
name
|
||||
bannerImage
|
||||
avatar {
|
||||
medium
|
||||
large
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
return executeQuery<Query.RateReviewResponse>(query)
|
||||
}
|
||||
|
||||
suspend fun toggleFollow(id: Int): Query.ToggleFollow? {
|
||||
return executeQuery<Query.ToggleFollow>(
|
||||
"""
|
||||
mutation {
|
||||
ToggleFollow(userId: $id) {
|
||||
id
|
||||
isFollowing
|
||||
isFollower
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun toggleLike(id: Int, type: String): ToggleLike? {
|
||||
return executeQuery<ToggleLike>(
|
||||
"""
|
||||
mutation Like {
|
||||
ToggleLikeV2(id: $id, type: $type) {
|
||||
__typename
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun postActivity(text: String, edit: Int? = null): String {
|
||||
val encodedText = text.stringSanitizer()
|
||||
val query = """
|
||||
mutation {
|
||||
SaveTextActivity(${if (edit != null) "id: $edit," else ""} text: $encodedText) {
|
||||
siteUrl
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
val result = executeQuery<JsonObject>(query)
|
||||
val errors = result?.get("errors")
|
||||
return errors?.toString() ?: (currContext()?.getString(ani.dantotsu.R.string.success)
|
||||
?: "Success")
|
||||
}
|
||||
|
||||
suspend fun postMessage(
|
||||
userId: Int,
|
||||
text: String,
|
||||
edit: Int? = null,
|
||||
isPrivate: Boolean = false
|
||||
): String {
|
||||
val encodedText = text.replace("", "").stringSanitizer()
|
||||
val query = """
|
||||
mutation {
|
||||
SaveMessageActivity(
|
||||
${if (edit != null) "id: $edit," else ""}
|
||||
recipientId: $userId,
|
||||
message: $encodedText,
|
||||
private: $isPrivate
|
||||
) {
|
||||
id
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
val result = executeQuery<JsonObject>(query)
|
||||
val errors = result?.get("errors")
|
||||
return errors?.toString() ?: (currContext()?.getString(ani.dantotsu.R.string.success)
|
||||
?: "Success")
|
||||
}
|
||||
|
||||
suspend fun postReply(activityId: Int, text: String, edit: Int? = null): String {
|
||||
val encodedText = text.stringSanitizer()
|
||||
val query = """
|
||||
mutation {
|
||||
SaveActivityReply(
|
||||
${if (edit != null) "id: $edit," else ""}
|
||||
activityId: $activityId,
|
||||
text: $encodedText
|
||||
) {
|
||||
id
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
val result = executeQuery<JsonObject>(query)
|
||||
val errors = result?.get("errors")
|
||||
return errors?.toString() ?: (currContext()?.getString(ani.dantotsu.R.string.success)
|
||||
?: "Success")
|
||||
}
|
||||
|
||||
suspend fun postReview(summary: String, body: String, mediaId: Int, score: Int): String {
|
||||
val encodedSummary = summary.stringSanitizer()
|
||||
val encodedBody = body.stringSanitizer()
|
||||
val query = """
|
||||
mutation {
|
||||
SaveReview(
|
||||
mediaId: $mediaId,
|
||||
summary: $encodedSummary,
|
||||
body: $encodedBody,
|
||||
score: $score
|
||||
) {
|
||||
siteUrl
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
val result = executeQuery<JsonObject>(query)
|
||||
val errors = result?.get("errors")
|
||||
return errors?.toString() ?: (currContext()?.getString(ani.dantotsu.R.string.success)
|
||||
?: "Success")
|
||||
}
|
||||
|
||||
suspend fun deleteActivityReply(activityId: Int): Boolean {
|
||||
val query = """
|
||||
mutation {
|
||||
DeleteActivityReply(id: $activityId) {
|
||||
deleted
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
val result = executeQuery<JsonObject>(query)
|
||||
val errors = result?.get("errors")
|
||||
return errors == null
|
||||
}
|
||||
|
||||
suspend fun deleteActivity(activityId: Int): Boolean {
|
||||
val query = """
|
||||
mutation {
|
||||
DeleteActivity(id: $activityId) {
|
||||
deleted
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
val result = executeQuery<JsonObject>(query)
|
||||
val errors = result?.get("errors")
|
||||
return errors == null
|
||||
}
|
||||
|
||||
private fun String.stringSanitizer(): String {
|
||||
val sb = StringBuilder()
|
||||
var i = 0
|
||||
while (i < this.length) {
|
||||
val codePoint = this.codePointAt(i)
|
||||
if (codePoint > 0xFFFF) {
|
||||
sb.append("&#").append(codePoint).append(";")
|
||||
i += 2
|
||||
} else {
|
||||
sb.append(this[i])
|
||||
i++
|
||||
}
|
||||
}
|
||||
return Gson().toJson(sb.toString())
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,81 +5,118 @@ import androidx.fragment.app.FragmentActivity
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import ani.dantotsu.BuildConfig
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.connections.discord.Discord
|
||||
import ani.dantotsu.loadData
|
||||
import ani.dantotsu.connections.mal.MAL
|
||||
import ani.dantotsu.media.Media
|
||||
import ani.dantotsu.others.AppUpdater
|
||||
import ani.dantotsu.profile.User
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.tryWithSuspend
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
suspend fun getUserId(context: Context, block: () -> Unit) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
if (Discord.userid == null && Discord.token != null) {
|
||||
if (!Discord.getUserData())
|
||||
snackString(context.getString(R.string.error_loading_discord_user_data))
|
||||
}
|
||||
}
|
||||
|
||||
val anilist = if (Anilist.userid == null && Anilist.token != null) {
|
||||
if (!Anilist.initialized && PrefManager.getVal<String>(PrefName.AnilistToken) != "") {
|
||||
if (Anilist.query.getUserData()) {
|
||||
tryWithSuspend {
|
||||
if (MAL.token != null && !MAL.query.getUserData())
|
||||
snackString(context.getString(R.string.error_loading_mal_user_data))
|
||||
}
|
||||
true
|
||||
} else {
|
||||
snackString(context.getString(R.string.error_loading_anilist_user_data))
|
||||
false
|
||||
}
|
||||
} else true
|
||||
|
||||
if(anilist) block.invoke()
|
||||
}
|
||||
block.invoke()
|
||||
}
|
||||
|
||||
class AnilistHomeViewModel : ViewModel() {
|
||||
private val listImages: MutableLiveData<ArrayList<String?>> = MutableLiveData<ArrayList<String?>>(arrayListOf())
|
||||
private val listImages: MutableLiveData<ArrayList<String?>> =
|
||||
MutableLiveData<ArrayList<String?>>(arrayListOf())
|
||||
|
||||
fun getListImages(): LiveData<ArrayList<String?>> = listImages
|
||||
suspend fun setListImages() = listImages.postValue(Anilist.query.getBannerImages())
|
||||
|
||||
private val animeContinue: MutableLiveData<ArrayList<Media>> = MutableLiveData<ArrayList<Media>>(null)
|
||||
private val animeContinue: MutableLiveData<ArrayList<Media>> =
|
||||
MutableLiveData<ArrayList<Media>>(null)
|
||||
|
||||
fun getAnimeContinue(): LiveData<ArrayList<Media>> = animeContinue
|
||||
suspend fun setAnimeContinue() = animeContinue.postValue(Anilist.query.continueMedia("ANIME"))
|
||||
|
||||
private val animeFav: MutableLiveData<ArrayList<Media>> = MutableLiveData<ArrayList<Media>>(null)
|
||||
private val animeFav: MutableLiveData<ArrayList<Media>> =
|
||||
MutableLiveData<ArrayList<Media>>(null)
|
||||
|
||||
fun getAnimeFav(): LiveData<ArrayList<Media>> = animeFav
|
||||
suspend fun setAnimeFav() = animeFav.postValue(Anilist.query.favMedia(true))
|
||||
|
||||
private val animePlanned: MutableLiveData<ArrayList<Media>> = MutableLiveData<ArrayList<Media>>(null)
|
||||
private val animePlanned: MutableLiveData<ArrayList<Media>> =
|
||||
MutableLiveData<ArrayList<Media>>(null)
|
||||
|
||||
fun getAnimePlanned(): LiveData<ArrayList<Media>> = animePlanned
|
||||
suspend fun setAnimePlanned() = animePlanned.postValue(Anilist.query.continueMedia("ANIME", true))
|
||||
|
||||
private val mangaContinue: MutableLiveData<ArrayList<Media>> = MutableLiveData<ArrayList<Media>>(null)
|
||||
private val mangaContinue: MutableLiveData<ArrayList<Media>> =
|
||||
MutableLiveData<ArrayList<Media>>(null)
|
||||
|
||||
fun getMangaContinue(): LiveData<ArrayList<Media>> = mangaContinue
|
||||
suspend fun setMangaContinue() = mangaContinue.postValue(Anilist.query.continueMedia("MANGA"))
|
||||
|
||||
private val mangaFav: MutableLiveData<ArrayList<Media>> = MutableLiveData<ArrayList<Media>>(null)
|
||||
private val mangaFav: MutableLiveData<ArrayList<Media>> =
|
||||
MutableLiveData<ArrayList<Media>>(null)
|
||||
|
||||
fun getMangaFav(): LiveData<ArrayList<Media>> = mangaFav
|
||||
suspend fun setMangaFav() = mangaFav.postValue(Anilist.query.favMedia(false))
|
||||
|
||||
private val mangaPlanned: MutableLiveData<ArrayList<Media>> = MutableLiveData<ArrayList<Media>>(null)
|
||||
private val mangaPlanned: MutableLiveData<ArrayList<Media>> =
|
||||
MutableLiveData<ArrayList<Media>>(null)
|
||||
|
||||
fun getMangaPlanned(): LiveData<ArrayList<Media>> = mangaPlanned
|
||||
suspend fun setMangaPlanned() = mangaPlanned.postValue(Anilist.query.continueMedia("MANGA", true))
|
||||
|
||||
private val recommendation: MutableLiveData<ArrayList<Media>> = MutableLiveData<ArrayList<Media>>(null)
|
||||
private val recommendation: MutableLiveData<ArrayList<Media>> =
|
||||
MutableLiveData<ArrayList<Media>>(null)
|
||||
|
||||
fun getRecommendation(): LiveData<ArrayList<Media>> = recommendation
|
||||
suspend fun setRecommendation() = recommendation.postValue(Anilist.query.recommendations())
|
||||
|
||||
private val userStatus: MutableLiveData<ArrayList<User>> =
|
||||
MutableLiveData<ArrayList<User>>(null)
|
||||
|
||||
fun getUserStatus(): LiveData<ArrayList<User>> = userStatus
|
||||
suspend fun initUserStatus() {
|
||||
val res = Anilist.query.getUserStatus()
|
||||
res?.let { userStatus.postValue(it) }
|
||||
}
|
||||
|
||||
private val hidden: MutableLiveData<ArrayList<Media>> =
|
||||
MutableLiveData<ArrayList<Media>>(null)
|
||||
|
||||
fun getHidden(): LiveData<ArrayList<Media>> = hidden
|
||||
|
||||
suspend fun initHomePage() {
|
||||
val res = Anilist.query.initHomePage()
|
||||
res["currentAnime"]?.let { animeContinue.postValue(it) }
|
||||
res["favoriteAnime"]?.let { animeFav.postValue(it) }
|
||||
res["currentAnimePlanned"]?.let { animePlanned.postValue(it) }
|
||||
res["currentManga"]?.let { mangaContinue.postValue(it) }
|
||||
res["favoriteManga"]?.let { mangaFav.postValue(it) }
|
||||
res["currentMangaPlanned"]?.let { mangaPlanned.postValue(it) }
|
||||
res["recommendations"]?.let { recommendation.postValue(it) }
|
||||
res["hidden"]?.let { hidden.postValue(it) }
|
||||
}
|
||||
|
||||
suspend fun loadMain(context: FragmentActivity) {
|
||||
Anilist.getSavedToken(context)
|
||||
MAL.getSavedToken(context)
|
||||
Discord.getSavedToken(context)
|
||||
if (loadData<Boolean>("check_update") != false) AppUpdater.check(context)
|
||||
genres.postValue(Anilist.query.getGenresAndTags(context))
|
||||
Anilist.getSavedToken()
|
||||
MAL.getSavedToken()
|
||||
Discord.getSavedToken()
|
||||
if (!BuildConfig.FLAVOR.contains("fdroid")) {
|
||||
if (PrefManager.getVal(PrefName.CheckUpdate))
|
||||
context.lifecycleScope.launch(Dispatchers.IO) {
|
||||
AppUpdater.check(context, false)
|
||||
}
|
||||
}
|
||||
val ret = Anilist.query.getGenresAndTags()
|
||||
withContext(Dispatchers.Main) {
|
||||
genres.value = ret
|
||||
}
|
||||
}
|
||||
|
||||
val empty = MutableLiveData<Boolean>(null)
|
||||
@@ -91,51 +128,53 @@ class AnilistHomeViewModel : ViewModel() {
|
||||
class AnilistAnimeViewModel : ViewModel() {
|
||||
var searched = false
|
||||
var notSet = true
|
||||
lateinit var searchResults: SearchResults
|
||||
lateinit var aniMangaSearchResults: AniMangaSearchResults
|
||||
private val type = "ANIME"
|
||||
private val trending: MutableLiveData<MutableList<Media>> = MutableLiveData<MutableList<Media>>(null)
|
||||
private val trending: MutableLiveData<MutableList<Media>> =
|
||||
MutableLiveData<MutableList<Media>>(null)
|
||||
|
||||
fun getTrending(): LiveData<MutableList<Media>> = trending
|
||||
suspend fun loadTrending(i: Int) {
|
||||
val (season, year) = Anilist.currentSeasons[i]
|
||||
trending.postValue(
|
||||
Anilist.query.search(
|
||||
Anilist.query.searchAniManga(
|
||||
type,
|
||||
perPage = 12,
|
||||
sort = Anilist.sortBy[2],
|
||||
season = season,
|
||||
seasonYear = year,
|
||||
hd = true
|
||||
hd = true,
|
||||
adultOnly = PrefManager.getVal(PrefName.AdultOnly)
|
||||
)?.results
|
||||
)
|
||||
}
|
||||
|
||||
private val updated: MutableLiveData<MutableList<Media>> = MutableLiveData<MutableList<Media>>(null)
|
||||
fun getUpdated(): LiveData<MutableList<Media>> = updated
|
||||
suspend fun loadUpdated() = updated.postValue(Anilist.query.recentlyUpdated())
|
||||
|
||||
private val animePopular = MutableLiveData<SearchResults?>(null)
|
||||
fun getPopular(): LiveData<SearchResults?> = animePopular
|
||||
private val animePopular = MutableLiveData<AniMangaSearchResults?>(null)
|
||||
|
||||
fun getPopular(): LiveData<AniMangaSearchResults?> = animePopular
|
||||
suspend fun loadPopular(
|
||||
type: String,
|
||||
search_val: String? = null,
|
||||
searchVal: String? = null,
|
||||
genres: ArrayList<String>? = null,
|
||||
sort: String = Anilist.sortBy[1],
|
||||
onList: Boolean = true,
|
||||
) {
|
||||
animePopular.postValue(
|
||||
Anilist.query.search(
|
||||
Anilist.query.searchAniManga(
|
||||
type,
|
||||
search = search_val,
|
||||
search = searchVal,
|
||||
onList = if (onList) null else false,
|
||||
sort = sort,
|
||||
genres = genres
|
||||
genres = genres,
|
||||
adultOnly = PrefManager.getVal(PrefName.AdultOnly)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
suspend fun loadNextPage(r: SearchResults) = animePopular.postValue(
|
||||
Anilist.query.search(
|
||||
suspend fun loadNextPage(r: AniMangaSearchResults) = animePopular.postValue(
|
||||
Anilist.query.searchAniManga(
|
||||
r.type,
|
||||
r.page + 1,
|
||||
r.perPage,
|
||||
@@ -143,53 +182,90 @@ class AnilistAnimeViewModel : ViewModel() {
|
||||
r.sort,
|
||||
r.genres,
|
||||
r.tags,
|
||||
r.status,
|
||||
r.source,
|
||||
r.format,
|
||||
r.countryOfOrigin,
|
||||
r.isAdult,
|
||||
r.onList
|
||||
r.onList,
|
||||
adultOnly = PrefManager.getVal(PrefName.AdultOnly),
|
||||
)
|
||||
)
|
||||
|
||||
var loaded: Boolean = false
|
||||
private val updated: MutableLiveData<MutableList<Media>> =
|
||||
MutableLiveData<MutableList<Media>>(null)
|
||||
|
||||
fun getUpdated(): LiveData<MutableList<Media>> = updated
|
||||
|
||||
private val popularMovies: MutableLiveData<MutableList<Media>> =
|
||||
MutableLiveData<MutableList<Media>>(null)
|
||||
|
||||
fun getMovies(): LiveData<MutableList<Media>> = popularMovies
|
||||
|
||||
private val topRatedAnime: MutableLiveData<MutableList<Media>> =
|
||||
MutableLiveData<MutableList<Media>>(null)
|
||||
|
||||
fun getTopRated(): LiveData<MutableList<Media>> = topRatedAnime
|
||||
|
||||
private val mostFavAnime: MutableLiveData<MutableList<Media>> =
|
||||
MutableLiveData<MutableList<Media>>(null)
|
||||
|
||||
fun getMostFav(): LiveData<MutableList<Media>> = mostFavAnime
|
||||
suspend fun loadAll() {
|
||||
val list = Anilist.query.loadAnimeList()
|
||||
updated.postValue(list["recentUpdates"])
|
||||
popularMovies.postValue(list["trendingMovies"])
|
||||
topRatedAnime.postValue(list["topRated"])
|
||||
mostFavAnime.postValue(list["mostFav"])
|
||||
}
|
||||
}
|
||||
|
||||
class AnilistMangaViewModel : ViewModel() {
|
||||
var searched = false
|
||||
var notSet = true
|
||||
lateinit var searchResults: SearchResults
|
||||
lateinit var aniMangaSearchResults: AniMangaSearchResults
|
||||
private val type = "MANGA"
|
||||
private val trending: MutableLiveData<MutableList<Media>> = MutableLiveData<MutableList<Media>>(null)
|
||||
private val trending: MutableLiveData<MutableList<Media>> =
|
||||
MutableLiveData<MutableList<Media>>(null)
|
||||
|
||||
fun getTrending(): LiveData<MutableList<Media>> = trending
|
||||
suspend fun loadTrending() =
|
||||
trending.postValue(Anilist.query.search(type, perPage = 10, sort = Anilist.sortBy[2], hd = true)?.results)
|
||||
trending.postValue(
|
||||
Anilist.query.searchAniManga(
|
||||
type,
|
||||
perPage = 10,
|
||||
sort = Anilist.sortBy[2],
|
||||
hd = true,
|
||||
adultOnly = PrefManager.getVal(PrefName.AdultOnly)
|
||||
)?.results
|
||||
)
|
||||
|
||||
private val updated: MutableLiveData<MutableList<Media>> = MutableLiveData<MutableList<Media>>(null)
|
||||
fun getTrendingNovel(): LiveData<MutableList<Media>> = updated
|
||||
suspend fun loadTrendingNovel() =
|
||||
updated.postValue(Anilist.query.search(type, perPage = 10, sort = Anilist.sortBy[2], format = "NOVEL")?.results)
|
||||
|
||||
private val mangaPopular = MutableLiveData<SearchResults?>(null)
|
||||
fun getPopular(): LiveData<SearchResults?> = mangaPopular
|
||||
private val mangaPopular = MutableLiveData<AniMangaSearchResults?>(null)
|
||||
fun getPopular(): LiveData<AniMangaSearchResults?> = mangaPopular
|
||||
suspend fun loadPopular(
|
||||
type: String,
|
||||
search_val: String? = null,
|
||||
searchVal: String? = null,
|
||||
genres: ArrayList<String>? = null,
|
||||
sort: String = Anilist.sortBy[1],
|
||||
onList: Boolean = true,
|
||||
) {
|
||||
mangaPopular.postValue(
|
||||
Anilist.query.search(
|
||||
Anilist.query.searchAniManga(
|
||||
type,
|
||||
search = search_val,
|
||||
search = searchVal,
|
||||
onList = if (onList) null else false,
|
||||
sort = sort,
|
||||
genres = genres
|
||||
genres = genres,
|
||||
adultOnly = PrefManager.getVal(PrefName.AdultOnly)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
suspend fun loadNextPage(r: SearchResults) = mangaPopular.postValue(
|
||||
Anilist.query.search(
|
||||
suspend fun loadNextPage(r: AniMangaSearchResults) = mangaPopular.postValue(
|
||||
Anilist.query.searchAniManga(
|
||||
r.type,
|
||||
r.page + 1,
|
||||
r.perPage,
|
||||
@@ -197,28 +273,183 @@ class AnilistMangaViewModel : ViewModel() {
|
||||
r.sort,
|
||||
r.genres,
|
||||
r.tags,
|
||||
r.status,
|
||||
r.source,
|
||||
r.format,
|
||||
r.countryOfOrigin,
|
||||
r.isAdult,
|
||||
r.onList,
|
||||
r.excludedGenres,
|
||||
r.excludedTags,
|
||||
r.startYear,
|
||||
r.seasonYear,
|
||||
r.season
|
||||
r.season,
|
||||
adultOnly = PrefManager.getVal(PrefName.AdultOnly)
|
||||
)
|
||||
)
|
||||
|
||||
var loaded: Boolean = false
|
||||
|
||||
private val popularManga: MutableLiveData<MutableList<Media>> =
|
||||
MutableLiveData<MutableList<Media>>(null)
|
||||
|
||||
fun getPopularManga(): LiveData<MutableList<Media>> = popularManga
|
||||
|
||||
private val popularManhwa: MutableLiveData<MutableList<Media>> =
|
||||
MutableLiveData<MutableList<Media>>(null)
|
||||
|
||||
fun getPopularManhwa(): LiveData<MutableList<Media>> = popularManhwa
|
||||
|
||||
private val popularNovel: MutableLiveData<MutableList<Media>> =
|
||||
MutableLiveData<MutableList<Media>>(null)
|
||||
|
||||
fun getPopularNovel(): LiveData<MutableList<Media>> = popularNovel
|
||||
|
||||
private val topRatedManga: MutableLiveData<MutableList<Media>> =
|
||||
MutableLiveData<MutableList<Media>>(null)
|
||||
|
||||
fun getTopRated(): LiveData<MutableList<Media>> = topRatedManga
|
||||
|
||||
private val mostFavManga: MutableLiveData<MutableList<Media>> =
|
||||
MutableLiveData<MutableList<Media>>(null)
|
||||
|
||||
fun getMostFav(): LiveData<MutableList<Media>> = mostFavManga
|
||||
suspend fun loadAll() {
|
||||
val list = Anilist.query.loadMangaList()
|
||||
popularManga.postValue(list["trendingManga"])
|
||||
popularManhwa.postValue(list["trendingManhwa"])
|
||||
popularNovel.postValue(list["trendingNovel"])
|
||||
topRatedManga.postValue(list["topRated"])
|
||||
mostFavManga.postValue(list["mostFav"])
|
||||
}
|
||||
}
|
||||
|
||||
class AnilistSearch : ViewModel() {
|
||||
|
||||
enum class SearchType {
|
||||
ANIME, MANGA, CHARACTER, STAFF, STUDIO, USER;
|
||||
|
||||
companion object {
|
||||
|
||||
fun SearchType.toAnilistString(): String {
|
||||
return when (this) {
|
||||
ANIME -> "ANIME"
|
||||
MANGA -> "MANGA"
|
||||
CHARACTER -> "CHARACTER"
|
||||
STAFF -> "STAFF"
|
||||
STUDIO -> "STUDIO"
|
||||
USER -> "USER"
|
||||
}
|
||||
}
|
||||
|
||||
fun fromString(string: String): SearchType {
|
||||
return when (string.uppercase()) {
|
||||
"ANIME" -> ANIME
|
||||
"MANGA" -> MANGA
|
||||
"CHARACTER" -> CHARACTER
|
||||
"STAFF" -> STAFF
|
||||
"STUDIO" -> STUDIO
|
||||
"USER" -> USER
|
||||
else -> throw IllegalArgumentException("Invalid search type")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var searched = false
|
||||
var notSet = true
|
||||
lateinit var searchResults: SearchResults
|
||||
private val result: MutableLiveData<SearchResults?> = MutableLiveData<SearchResults?>(null)
|
||||
lateinit var aniMangaSearchResults: AniMangaSearchResults
|
||||
private val aniMangaResult: MutableLiveData<AniMangaSearchResults?> =
|
||||
MutableLiveData<AniMangaSearchResults?>(null)
|
||||
|
||||
fun getSearch(): LiveData<SearchResults?> = result
|
||||
suspend fun loadSearch(r: SearchResults) = result.postValue(
|
||||
Anilist.query.search(
|
||||
lateinit var characterSearchResults: CharacterSearchResults
|
||||
private val characterResult: MutableLiveData<CharacterSearchResults?> =
|
||||
MutableLiveData<CharacterSearchResults?>(null)
|
||||
|
||||
lateinit var studioSearchResults: StudioSearchResults
|
||||
private val studioResult: MutableLiveData<StudioSearchResults?> =
|
||||
MutableLiveData<StudioSearchResults?>(null)
|
||||
|
||||
lateinit var staffSearchResults: StaffSearchResults
|
||||
private val staffResult: MutableLiveData<StaffSearchResults?> =
|
||||
MutableLiveData<StaffSearchResults?>(null)
|
||||
|
||||
lateinit var userSearchResults: UserSearchResults
|
||||
private val userResult: MutableLiveData<UserSearchResults?> =
|
||||
MutableLiveData<UserSearchResults?>(null)
|
||||
|
||||
fun <T> getSearch(type: SearchType): MutableLiveData<T?> {
|
||||
return when (type) {
|
||||
SearchType.ANIME, SearchType.MANGA -> aniMangaResult as MutableLiveData<T?>
|
||||
SearchType.CHARACTER -> characterResult as MutableLiveData<T?>
|
||||
SearchType.STUDIO -> studioResult as MutableLiveData<T?>
|
||||
SearchType.STAFF -> staffResult as MutableLiveData<T?>
|
||||
SearchType.USER -> userResult as MutableLiveData<T?>
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun loadSearch(type: SearchType) {
|
||||
when (type) {
|
||||
SearchType.ANIME, SearchType.MANGA -> loadAniMangaSearch(aniMangaSearchResults)
|
||||
SearchType.CHARACTER -> loadCharacterSearch(characterSearchResults)
|
||||
SearchType.STUDIO -> loadStudiosSearch(studioSearchResults)
|
||||
SearchType.STAFF -> loadStaffSearch(staffSearchResults)
|
||||
SearchType.USER -> loadUserSearch(userSearchResults)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun loadNextPage(type: SearchType) {
|
||||
when (type) {
|
||||
SearchType.ANIME, SearchType.MANGA -> loadNextAniMangaPage(aniMangaSearchResults)
|
||||
SearchType.CHARACTER -> loadNextCharacterPage(characterSearchResults)
|
||||
SearchType.STUDIO -> loadNextStudiosPage(studioSearchResults)
|
||||
SearchType.STAFF -> loadNextStaffPage(staffSearchResults)
|
||||
SearchType.USER -> loadNextUserPage(userSearchResults)
|
||||
}
|
||||
}
|
||||
|
||||
fun hasNextPage(type: SearchType): Boolean {
|
||||
return when (type) {
|
||||
SearchType.ANIME, SearchType.MANGA -> aniMangaSearchResults.hasNextPage
|
||||
SearchType.CHARACTER -> characterSearchResults.hasNextPage
|
||||
SearchType.STUDIO -> studioSearchResults.hasNextPage
|
||||
SearchType.STAFF -> staffSearchResults.hasNextPage
|
||||
SearchType.USER -> userSearchResults.hasNextPage
|
||||
}
|
||||
}
|
||||
|
||||
fun resultsIsNotEmpty(type: SearchType): Boolean {
|
||||
return when (type) {
|
||||
SearchType.ANIME, SearchType.MANGA -> aniMangaSearchResults.results.isNotEmpty()
|
||||
SearchType.CHARACTER -> characterSearchResults.results.isNotEmpty()
|
||||
SearchType.STUDIO -> studioSearchResults.results.isNotEmpty()
|
||||
SearchType.STAFF -> staffSearchResults.results.isNotEmpty()
|
||||
SearchType.USER -> userSearchResults.results.isNotEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
fun size(type: SearchType): Int {
|
||||
return when (type) {
|
||||
SearchType.ANIME, SearchType.MANGA -> aniMangaSearchResults.results.size
|
||||
SearchType.CHARACTER -> characterSearchResults.results.size
|
||||
SearchType.STUDIO -> studioSearchResults.results.size
|
||||
SearchType.STAFF -> staffSearchResults.results.size
|
||||
SearchType.USER -> userSearchResults.results.size
|
||||
}
|
||||
}
|
||||
|
||||
fun clearResults(type: SearchType) {
|
||||
when (type) {
|
||||
SearchType.ANIME, SearchType.MANGA -> aniMangaSearchResults.results.clear()
|
||||
SearchType.CHARACTER -> characterSearchResults.results.clear()
|
||||
SearchType.STUDIO -> studioSearchResults.results.clear()
|
||||
SearchType.STAFF -> staffSearchResults.results.clear()
|
||||
SearchType.USER -> userSearchResults.results.clear()
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun loadAniMangaSearch(r: AniMangaSearchResults) = aniMangaResult.postValue(
|
||||
Anilist.query.searchAniManga(
|
||||
r.type,
|
||||
r.page,
|
||||
r.perPage,
|
||||
@@ -226,18 +457,50 @@ class AnilistSearch : ViewModel() {
|
||||
r.sort,
|
||||
r.genres,
|
||||
r.tags,
|
||||
r.status,
|
||||
r.source,
|
||||
r.format,
|
||||
r.countryOfOrigin,
|
||||
r.isAdult,
|
||||
r.onList,
|
||||
r.excludedGenres,
|
||||
r.excludedTags,
|
||||
r.startYear,
|
||||
r.seasonYear,
|
||||
r.season
|
||||
r.season,
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun loadNextPage(r: SearchResults) = result.postValue(
|
||||
Anilist.query.search(
|
||||
private suspend fun loadCharacterSearch(r: CharacterSearchResults) = characterResult.postValue(
|
||||
Anilist.query.searchCharacters(
|
||||
r.page,
|
||||
r.search,
|
||||
)
|
||||
)
|
||||
|
||||
private suspend fun loadStudiosSearch(r: StudioSearchResults) = studioResult.postValue(
|
||||
Anilist.query.searchStudios(
|
||||
r.page,
|
||||
r.search,
|
||||
)
|
||||
)
|
||||
|
||||
private suspend fun loadStaffSearch(r: StaffSearchResults) = staffResult.postValue(
|
||||
Anilist.query.searchStaff(
|
||||
r.page,
|
||||
r.search,
|
||||
)
|
||||
)
|
||||
|
||||
private suspend fun loadUserSearch(r: UserSearchResults) = userResult.postValue(
|
||||
Anilist.query.searchUsers(
|
||||
r.page,
|
||||
r.search,
|
||||
)
|
||||
)
|
||||
|
||||
private suspend fun loadNextAniMangaPage(r: AniMangaSearchResults) = aniMangaResult.postValue(
|
||||
Anilist.query.searchAniManga(
|
||||
r.type,
|
||||
r.page + 1,
|
||||
r.perPage,
|
||||
@@ -245,15 +508,48 @@ class AnilistSearch : ViewModel() {
|
||||
r.sort,
|
||||
r.genres,
|
||||
r.tags,
|
||||
r.status,
|
||||
r.source,
|
||||
r.format,
|
||||
r.countryOfOrigin,
|
||||
r.isAdult,
|
||||
r.onList,
|
||||
r.excludedGenres,
|
||||
r.excludedTags,
|
||||
r.startYear,
|
||||
r.seasonYear,
|
||||
r.season
|
||||
)
|
||||
)
|
||||
|
||||
private suspend fun loadNextCharacterPage(r: CharacterSearchResults) =
|
||||
characterResult.postValue(
|
||||
Anilist.query.searchCharacters(
|
||||
r.page + 1,
|
||||
r.search,
|
||||
)
|
||||
)
|
||||
|
||||
private suspend fun loadNextStudiosPage(r: StudioSearchResults) = studioResult.postValue(
|
||||
Anilist.query.searchStudios(
|
||||
r.page + 1,
|
||||
r.search,
|
||||
)
|
||||
)
|
||||
|
||||
private suspend fun loadNextStaffPage(r: StaffSearchResults) = staffResult.postValue(
|
||||
Anilist.query.searchStaff(
|
||||
r.page + 1,
|
||||
r.search,
|
||||
)
|
||||
)
|
||||
|
||||
private suspend fun loadNextUserPage(r: UserSearchResults) = userResult.postValue(
|
||||
Anilist.query.searchUsers(
|
||||
r.page + 1,
|
||||
r.search,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
class GenresViewModel : ViewModel() {
|
||||
@@ -273,4 +569,40 @@ class GenresViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ProfileViewModel : ViewModel() {
|
||||
|
||||
private val mangaFav: MutableLiveData<ArrayList<Media>> =
|
||||
MutableLiveData<ArrayList<Media>>(null)
|
||||
|
||||
fun getMangaFav(): LiveData<ArrayList<Media>> = mangaFav
|
||||
|
||||
private val animeFav: MutableLiveData<ArrayList<Media>> =
|
||||
MutableLiveData<ArrayList<Media>>(null)
|
||||
|
||||
fun getAnimeFav(): LiveData<ArrayList<Media>> = animeFav
|
||||
|
||||
suspend fun setData(id: Int) {
|
||||
val res = Anilist.query.initProfilePage(id)
|
||||
val mangaList = res?.data?.favoriteManga?.favourites?.manga?.edges?.mapNotNull {
|
||||
it.node?.let { i ->
|
||||
Media(i).apply { isFav = true }
|
||||
}
|
||||
}
|
||||
mangaFav.postValue(ArrayList(mangaList ?: arrayListOf()))
|
||||
val animeList = res?.data?.favoriteAnime?.favourites?.anime?.edges?.mapNotNull {
|
||||
it.node?.let { i ->
|
||||
Media(i).apply { isFav = true }
|
||||
}
|
||||
}
|
||||
animeFav.postValue(ArrayList(animeList ?: arrayListOf()))
|
||||
|
||||
}
|
||||
|
||||
fun refresh() {
|
||||
mangaFav.postValue(mangaFav.value)
|
||||
animeFav.postValue(animeFav.value)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,24 @@
|
||||
package ani.dantotsu.connections.anilist
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import ani.dantotsu.logError
|
||||
import ani.dantotsu.logger
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.startMainActivity
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
|
||||
class Login : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
ThemeManager(this).applyTheme()
|
||||
val data: Uri? = intent?.data
|
||||
logger(data.toString())
|
||||
try {
|
||||
Anilist.token = Regex("""(?<=access_token=).+(?=&token_type)""").find(data.toString())!!.value
|
||||
val filename = "anilistToken"
|
||||
this.openFileOutput(filename, Context.MODE_PRIVATE).use {
|
||||
it.write(Anilist.token!!.toByteArray())
|
||||
}
|
||||
Anilist.token =
|
||||
Regex("""(?<=access_token=).+(?=&token_type)""").find(data.toString())!!.value
|
||||
PrefManager.setVal(PrefName.AnilistToken, Anilist.token ?: "")
|
||||
} catch (e: Exception) {
|
||||
logError(e)
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
package ani.dantotsu.connections.anilist
|
||||
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.media.Media
|
||||
import java.io.Serializable
|
||||
|
||||
data class SearchResults(
|
||||
val type: String,
|
||||
var isAdult: Boolean,
|
||||
var onList: Boolean? = null,
|
||||
var perPage: Int? = null,
|
||||
var search: String? = null,
|
||||
var sort: String? = null,
|
||||
var genres: MutableList<String>? = null,
|
||||
var excludedGenres: MutableList<String>? = null,
|
||||
var tags: MutableList<String>? = null,
|
||||
var excludedTags: MutableList<String>? = null,
|
||||
var format: String? = null,
|
||||
var seasonYear: Int? = null,
|
||||
var season: String? = null,
|
||||
var page: Int = 1,
|
||||
var results: MutableList<Media>,
|
||||
var hasNextPage: Boolean,
|
||||
) : Serializable {
|
||||
fun toChipList(): List<SearchChip> {
|
||||
val list = mutableListOf<SearchChip>()
|
||||
sort?.let {
|
||||
val c = currContext()!!
|
||||
list.add(SearchChip("SORT", c.getString(R.string.filter_sort, c.resources.getStringArray(R.array.sort_by)[Anilist.sortBy.indexOf(it)])))
|
||||
}
|
||||
format?.let {
|
||||
list.add(SearchChip("FORMAT", currContext()!!.getString(R.string.filter_format, it)))
|
||||
}
|
||||
season?.let {
|
||||
list.add(SearchChip("SEASON", it))
|
||||
}
|
||||
seasonYear?.let {
|
||||
list.add(SearchChip("SEASON_YEAR", it.toString()))
|
||||
}
|
||||
genres?.forEach {
|
||||
list.add(SearchChip("GENRE", it))
|
||||
}
|
||||
excludedGenres?.forEach {
|
||||
list.add(SearchChip("EXCLUDED_GENRE", currContext()!!.getString(R.string.filter_exclude, it)))
|
||||
}
|
||||
tags?.forEach {
|
||||
list.add(SearchChip("TAG", it))
|
||||
}
|
||||
excludedTags?.forEach {
|
||||
list.add(SearchChip("EXCLUDED_TAG", currContext()!!.getString(R.string.filter_exclude, it)))
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
fun removeChip(chip: SearchChip) {
|
||||
when (chip.type) {
|
||||
"SORT" -> sort = null
|
||||
"FORMAT" -> format = null
|
||||
"SEASON" -> season = null
|
||||
"SEASON_YEAR" -> seasonYear = null
|
||||
"GENRE" -> genres?.remove(chip.text)
|
||||
"EXCLUDED_GENRE" -> excludedGenres?.remove(chip.text)
|
||||
"TAG" -> tags?.remove(chip.text)
|
||||
"EXCLUDED_TAG" -> excludedTags?.remove(chip.text)
|
||||
}
|
||||
}
|
||||
|
||||
data class SearchChip(
|
||||
val type: String,
|
||||
val text: String
|
||||
)
|
||||
}
|
||||
@@ -6,19 +6,30 @@ import android.os.Bundle
|
||||
import androidx.core.os.bundleOf
|
||||
import ani.dantotsu.loadMedia
|
||||
import ani.dantotsu.startMainActivity
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
|
||||
class UrlMedia : Activity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
var id: Int? = intent?.extras?.getInt("media", 0) ?: 0
|
||||
var isMAL = false
|
||||
var continueMedia = true
|
||||
if (id == 0) {
|
||||
continueMedia = false
|
||||
val data: Uri? = intent?.data
|
||||
isMAL = data?.host != "anilist.co"
|
||||
id = data?.pathSegments?.getOrNull(1)?.toIntOrNull()
|
||||
} else loadMedia = id
|
||||
startMainActivity(this, bundleOf("mediaId" to id, "mal" to isMAL, "continue" to continueMedia))
|
||||
ThemeManager(this).applyTheme()
|
||||
val data: Uri? = intent?.data
|
||||
val type = data?.pathSegments?.getOrNull(0)
|
||||
if (type != "user") {
|
||||
var id: Int? = intent?.extras?.getInt("media", 0) ?: 0
|
||||
var isMAL = false
|
||||
var continueMedia = true
|
||||
if (id == 0) {
|
||||
continueMedia = false
|
||||
isMAL = data?.host != "anilist.co"
|
||||
id = data?.pathSegments?.getOrNull(1)?.toIntOrNull()
|
||||
} else loadMedia = id
|
||||
startMainActivity(
|
||||
this,
|
||||
bundleOf("mediaId" to id, "mal" to isMAL, "continue" to continueMedia)
|
||||
)
|
||||
} else {
|
||||
val username = data.pathSegments?.getOrNull(1)
|
||||
startMainActivity(this, bundleOf("username" to username))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,431 @@
|
||||
package ani.dantotsu.connections.anilist
|
||||
|
||||
val standardPageInformation = """
|
||||
pageInfo {
|
||||
total
|
||||
perPage
|
||||
currentPage
|
||||
lastPage
|
||||
hasNextPage
|
||||
}
|
||||
""".prepare()
|
||||
|
||||
fun String.prepare() = this.trimIndent().replace("\n", " ").replace(""" """, "")
|
||||
|
||||
fun characterInformation(includeMediaInfo: Boolean) = """
|
||||
id
|
||||
name {
|
||||
first
|
||||
middle
|
||||
last
|
||||
full
|
||||
native
|
||||
userPreferred
|
||||
}
|
||||
image {
|
||||
large
|
||||
medium
|
||||
}
|
||||
age
|
||||
gender
|
||||
description
|
||||
dateOfBirth {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
${
|
||||
if (includeMediaInfo) """
|
||||
media(page: 0,sort:[POPULARITY_DESC,SCORE_DESC]) {
|
||||
$standardPageInformation
|
||||
edges {
|
||||
id
|
||||
voiceActors {
|
||||
id,
|
||||
name {
|
||||
userPreferred
|
||||
}
|
||||
languageV2,
|
||||
image {
|
||||
medium,
|
||||
large
|
||||
}
|
||||
}
|
||||
characterRole
|
||||
node {
|
||||
id
|
||||
idMal
|
||||
isAdult
|
||||
status
|
||||
chapters
|
||||
episodes
|
||||
nextAiringEpisode { episode }
|
||||
type
|
||||
meanScore
|
||||
isFavourite
|
||||
format
|
||||
bannerImage
|
||||
countryOfOrigin
|
||||
coverImage { large }
|
||||
title {
|
||||
english
|
||||
romaji
|
||||
userPreferred
|
||||
}
|
||||
mediaListEntry {
|
||||
progress
|
||||
private
|
||||
score(format: POINT_100)
|
||||
status
|
||||
}
|
||||
}
|
||||
}
|
||||
}""".prepare() else ""
|
||||
}
|
||||
""".prepare()
|
||||
|
||||
fun studioInformation(page: Int, perPage: Int) = """
|
||||
id
|
||||
name
|
||||
isFavourite
|
||||
favourites
|
||||
media(page: $page, sort:START_DATE_DESC, perPage: $perPage) {
|
||||
$standardPageInformation
|
||||
edges {
|
||||
id
|
||||
node {
|
||||
id
|
||||
idMal
|
||||
isAdult
|
||||
status
|
||||
chapters
|
||||
episodes
|
||||
nextAiringEpisode { episode }
|
||||
type
|
||||
meanScore
|
||||
startDate{ year }
|
||||
isFavourite
|
||||
format
|
||||
bannerImage
|
||||
countryOfOrigin
|
||||
coverImage { large }
|
||||
title {
|
||||
english
|
||||
romaji
|
||||
userPreferred
|
||||
}
|
||||
mediaListEntry {
|
||||
progress
|
||||
private
|
||||
score(format: POINT_100)
|
||||
status
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""".prepare()
|
||||
|
||||
fun staffInformation(page: Int, perPage: Int) = """
|
||||
id
|
||||
name {
|
||||
first
|
||||
middle
|
||||
last
|
||||
full
|
||||
native
|
||||
userPreferred
|
||||
}
|
||||
image {
|
||||
large
|
||||
medium
|
||||
}
|
||||
dateOfBirth {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
dateOfDeath {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
age
|
||||
yearsActive
|
||||
homeTown
|
||||
staffMedia(page: $page,sort:START_DATE_DESC, perPage: $perPage) {
|
||||
$standardPageInformation
|
||||
edges {
|
||||
staffRole
|
||||
id
|
||||
node {
|
||||
id
|
||||
idMal
|
||||
isAdult
|
||||
status
|
||||
chapters
|
||||
episodes
|
||||
nextAiringEpisode { episode }
|
||||
type
|
||||
meanScore
|
||||
startDate{ year }
|
||||
isFavourite
|
||||
format
|
||||
bannerImage
|
||||
countryOfOrigin
|
||||
coverImage { large }
|
||||
title {
|
||||
english
|
||||
romaji
|
||||
userPreferred
|
||||
}
|
||||
mediaListEntry {
|
||||
progress
|
||||
private
|
||||
score(format: POINT_100)
|
||||
status
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""".prepare()
|
||||
|
||||
fun userInformation() = """
|
||||
id
|
||||
name
|
||||
about(asHtml: true)
|
||||
avatar {
|
||||
large
|
||||
medium
|
||||
}
|
||||
bannerImage
|
||||
isFollowing
|
||||
isFollower
|
||||
isBlocked
|
||||
siteUrl
|
||||
""".prepare()
|
||||
|
||||
fun aniMangaSearch(perPage: Int?) = """
|
||||
query (${"$"}page: Int = 1, ${"$"}id: Int, ${"$"}type: MediaType, ${"$"}isAdult: Boolean = false, ${"$"}search: String, ${"$"}format: [MediaFormat], ${"$"}status: MediaStatus, ${"$"}countryOfOrigin: CountryCode, ${"$"}source: MediaSource, ${"$"}season: MediaSeason, ${"$"}seasonYear: Int, ${"$"}year: String, ${"$"}onList: Boolean, ${"$"}yearLesser: FuzzyDateInt, ${"$"}yearGreater: FuzzyDateInt, ${"$"}episodeLesser: Int, ${"$"}episodeGreater: Int, ${"$"}durationLesser: Int, ${"$"}durationGreater: Int, ${"$"}chapterLesser: Int, ${"$"}chapterGreater: Int, ${"$"}volumeLesser: Int, ${"$"}volumeGreater: Int, ${"$"}licensedBy: [String], ${"$"}isLicensed: Boolean, ${"$"}genres: [String], ${"$"}excludedGenres: [String], ${"$"}tags: [String], ${"$"}excludedTags: [String], ${"$"}minimumTagRank: Int, ${"$"}sort: [MediaSort] = [POPULARITY_DESC, SCORE_DESC, START_DATE_DESC]) {
|
||||
Page(page: ${"$"}page, perPage: ${perPage ?: 50}) {
|
||||
$standardPageInformation
|
||||
media(id: ${"$"}id, type: ${"$"}type, season: ${"$"}season, format_in: ${"$"}format, status: ${"$"}status, countryOfOrigin: ${"$"}countryOfOrigin, source: ${"$"}source, search: ${"$"}search, onList: ${"$"}onList, seasonYear: ${"$"}seasonYear, startDate_like: ${"$"}year, startDate_lesser: ${"$"}yearLesser, startDate_greater: ${"$"}yearGreater, episodes_lesser: ${"$"}episodeLesser, episodes_greater: ${"$"}episodeGreater, duration_lesser: ${"$"}durationLesser, duration_greater: ${"$"}durationGreater, chapters_lesser: ${"$"}chapterLesser, chapters_greater: ${"$"}chapterGreater, volumes_lesser: ${"$"}volumeLesser, volumes_greater: ${"$"}volumeGreater, licensedBy_in: ${"$"}licensedBy, isLicensed: ${"$"}isLicensed, genre_in: ${"$"}genres, genre_not_in: ${"$"}excludedGenres, tag_in: ${"$"}tags, tag_not_in: ${"$"}excludedTags, minimumTagRank: ${"$"}minimumTagRank, sort: ${"$"}sort, isAdult: ${"$"}isAdult) {
|
||||
${standardMediaInformation()}
|
||||
}
|
||||
}
|
||||
}
|
||||
""".prepare()
|
||||
|
||||
fun standardMediaInformation() = """
|
||||
id
|
||||
idMal
|
||||
siteUrl
|
||||
isAdult
|
||||
status(version: 2)
|
||||
chapters
|
||||
episodes
|
||||
nextAiringEpisode {
|
||||
episode
|
||||
airingAt
|
||||
}
|
||||
type
|
||||
genres
|
||||
meanScore
|
||||
popularity
|
||||
favourites
|
||||
isFavourite
|
||||
format
|
||||
bannerImage
|
||||
countryOfOrigin
|
||||
coverImage {
|
||||
large
|
||||
extraLarge
|
||||
}
|
||||
title {
|
||||
english
|
||||
romaji
|
||||
userPreferred
|
||||
}
|
||||
mediaListEntry {
|
||||
progress
|
||||
private
|
||||
score(format: POINT_100)
|
||||
status
|
||||
}
|
||||
""".prepare()
|
||||
|
||||
fun fullMediaInformation(id: Int) = """
|
||||
{
|
||||
Media(id: $id) {
|
||||
streamingEpisodes {
|
||||
title
|
||||
thumbnail
|
||||
url
|
||||
site
|
||||
}
|
||||
mediaListEntry {
|
||||
id
|
||||
status
|
||||
score(format: POINT_100)
|
||||
progress
|
||||
private
|
||||
notes
|
||||
repeat
|
||||
customLists
|
||||
updatedAt
|
||||
startedAt {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
completedAt {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
}
|
||||
reviews(perPage: 3, sort: SCORE_DESC) {
|
||||
nodes {
|
||||
id
|
||||
mediaId
|
||||
mediaType
|
||||
summary
|
||||
body(asHtml: true)
|
||||
rating
|
||||
ratingAmount
|
||||
userRating
|
||||
score
|
||||
private
|
||||
siteUrl
|
||||
createdAt
|
||||
updatedAt
|
||||
user {
|
||||
id
|
||||
name
|
||||
bannerImage
|
||||
avatar {
|
||||
medium
|
||||
large
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
${standardMediaInformation()}
|
||||
source
|
||||
duration
|
||||
season
|
||||
seasonYear
|
||||
startDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
endDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
studios(isMain: true) {
|
||||
nodes {
|
||||
id
|
||||
name
|
||||
siteUrl
|
||||
}
|
||||
}
|
||||
description
|
||||
trailer {
|
||||
site
|
||||
id
|
||||
}
|
||||
synonyms
|
||||
tags {
|
||||
name
|
||||
rank
|
||||
isMediaSpoiler
|
||||
}
|
||||
characters(sort: [ROLE, FAVOURITES_DESC], perPage: 25, page: 1) {
|
||||
edges {
|
||||
role
|
||||
voiceActors {
|
||||
id
|
||||
name {
|
||||
first
|
||||
middle
|
||||
last
|
||||
full
|
||||
native
|
||||
userPreferred
|
||||
}
|
||||
image {
|
||||
large
|
||||
medium
|
||||
}
|
||||
languageV2
|
||||
}
|
||||
node {
|
||||
id
|
||||
image {
|
||||
medium
|
||||
}
|
||||
name {
|
||||
userPreferred
|
||||
}
|
||||
isFavourite
|
||||
}
|
||||
}
|
||||
}
|
||||
relations {
|
||||
edges {
|
||||
relationType(version: 2)
|
||||
node {
|
||||
${standardMediaInformation()}
|
||||
}
|
||||
}
|
||||
}
|
||||
staffPreview: staff(perPage: 8, sort: [RELEVANCE, ID]) {
|
||||
edges {
|
||||
role
|
||||
node {
|
||||
id
|
||||
image {
|
||||
large
|
||||
medium
|
||||
}
|
||||
name {
|
||||
userPreferred
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
recommendations(sort: RATING_DESC) {
|
||||
nodes {
|
||||
mediaRecommendation {
|
||||
${standardMediaInformation()}
|
||||
}
|
||||
}
|
||||
}
|
||||
externalLinks {
|
||||
url
|
||||
site
|
||||
}
|
||||
}
|
||||
Page(page: 1) {
|
||||
$standardPageInformation
|
||||
mediaList(isFollowing: true, sort: [STATUS], mediaId: $id) {
|
||||
id
|
||||
status
|
||||
score(format: POINT_100)
|
||||
progress
|
||||
progressVolumes
|
||||
user {
|
||||
id
|
||||
name
|
||||
avatar {
|
||||
large
|
||||
medium
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
""".prepare()
|
||||
@@ -46,7 +46,7 @@ data class Character(
|
||||
|
||||
// Notes for site moderators
|
||||
@SerialName("modNotes") var modNotes: String?,
|
||||
)
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class CharacterConnection(
|
||||
@@ -55,8 +55,8 @@ data class CharacterConnection(
|
||||
@SerialName("nodes") var nodes: List<Character>?,
|
||||
|
||||
// The pagination information
|
||||
// @SerialName("pageInfo") var pageInfo: PageInfo?,
|
||||
)
|
||||
@SerialName("pageInfo") var pageInfo: PageInfo?,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class CharacterEdge(
|
||||
@@ -72,7 +72,7 @@ data class CharacterEdge(
|
||||
@SerialName("name") var name: String?,
|
||||
|
||||
// The voice actors of the character
|
||||
// @SerialName("voiceActors") var voiceActors: List<Staff>?,
|
||||
@SerialName("voiceActors") var voiceActors: List<Staff>?,
|
||||
|
||||
// The voice actors of the character with role date
|
||||
// @SerialName("voiceActorRoles") var voiceActorRoles: List<StaffRoleType>?,
|
||||
@@ -82,7 +82,7 @@ data class CharacterEdge(
|
||||
|
||||
// The order the character should be displayed from the users favourites
|
||||
@SerialName("favouriteOrder") var favouriteOrder: Int?,
|
||||
)
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class CharacterName(
|
||||
@@ -109,7 +109,7 @@ data class CharacterName(
|
||||
|
||||
// The currently authenticated users preferred name language. Default romaji for non-authenticated
|
||||
@SerialName("userPreferred") var userPreferred: String?,
|
||||
)
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class CharacterImage(
|
||||
@@ -118,4 +118,4 @@ data class CharacterImage(
|
||||
|
||||
// The character's image of media at medium size
|
||||
@SerialName("medium") var medium: String?,
|
||||
)
|
||||
) : java.io.Serializable
|
||||
@@ -3,39 +3,42 @@ package ani.dantotsu.connections.anilist.api
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
class Query{
|
||||
class Query {
|
||||
@Serializable
|
||||
data class Viewer(
|
||||
@SerialName("data")
|
||||
val data : Data?
|
||||
){
|
||||
val data: Data?
|
||||
) {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("Viewer")
|
||||
val user: ani.dantotsu.connections.anilist.api.User?
|
||||
)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class Media(
|
||||
@SerialName("data")
|
||||
val data : Data?
|
||||
){
|
||||
val data: Data?
|
||||
) {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("Media")
|
||||
val media: ani.dantotsu.connections.anilist.api.Media?
|
||||
val media: ani.dantotsu.connections.anilist.api.Media?,
|
||||
@SerialName("Page")
|
||||
val page: ani.dantotsu.connections.anilist.api.Page?
|
||||
)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class Page(
|
||||
@SerialName("data")
|
||||
val data : Data?
|
||||
){
|
||||
val data: Data?
|
||||
) {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("Page")
|
||||
val page : ani.dantotsu.connections.anilist.api.Page?
|
||||
val page: ani.dantotsu.connections.anilist.api.Page?
|
||||
)
|
||||
}
|
||||
// data class AiringSchedule(
|
||||
@@ -49,8 +52,8 @@ class Query{
|
||||
@Serializable
|
||||
data class Character(
|
||||
@SerialName("data")
|
||||
val data : Data?
|
||||
){
|
||||
val data: Data?
|
||||
) {
|
||||
|
||||
@Serializable
|
||||
data class Data(
|
||||
@@ -63,7 +66,7 @@ class Query{
|
||||
data class Studio(
|
||||
@SerialName("data")
|
||||
val data: Data?
|
||||
){
|
||||
) {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("Studio")
|
||||
@@ -76,7 +79,7 @@ class Query{
|
||||
data class Author(
|
||||
@SerialName("data")
|
||||
val data: Data?
|
||||
){
|
||||
) {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("Staff")
|
||||
@@ -95,8 +98,8 @@ class Query{
|
||||
@Serializable
|
||||
data class MediaListCollection(
|
||||
@SerialName("data")
|
||||
val data : Data?
|
||||
){
|
||||
val data: Data?
|
||||
) {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("MediaListCollection")
|
||||
@@ -104,41 +107,677 @@ class Query{
|
||||
)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class CombinedMediaListResponse(
|
||||
@SerialName("data")
|
||||
val data: Data?
|
||||
) {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("current") val current: ani.dantotsu.connections.anilist.api.MediaListCollection?,
|
||||
@SerialName("planned") val planned: ani.dantotsu.connections.anilist.api.MediaListCollection?,
|
||||
@SerialName("repeating") val repeating: ani.dantotsu.connections.anilist.api.MediaListCollection?,
|
||||
)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class HomePageMedia(
|
||||
@SerialName("data")
|
||||
val data: Data?
|
||||
) {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("currentAnime") val currentAnime: ani.dantotsu.connections.anilist.api.MediaListCollection?,
|
||||
@SerialName("repeatingAnime") val repeatingAnime: ani.dantotsu.connections.anilist.api.MediaListCollection?,
|
||||
@SerialName("favoriteAnime") val favoriteAnime: ani.dantotsu.connections.anilist.api.User?,
|
||||
@SerialName("plannedAnime") val plannedAnime: ani.dantotsu.connections.anilist.api.MediaListCollection?,
|
||||
@SerialName("currentManga") val currentManga: ani.dantotsu.connections.anilist.api.MediaListCollection?,
|
||||
@SerialName("repeatingManga") val repeatingManga: ani.dantotsu.connections.anilist.api.MediaListCollection?,
|
||||
@SerialName("favoriteManga") val favoriteManga: ani.dantotsu.connections.anilist.api.User?,
|
||||
@SerialName("plannedManga") val plannedManga: ani.dantotsu.connections.anilist.api.MediaListCollection?,
|
||||
@SerialName("recommendationQuery") val recommendationQuery: ani.dantotsu.connections.anilist.api.Page?,
|
||||
@SerialName("recommendationPlannedQueryAnime") val recommendationPlannedQueryAnime: ani.dantotsu.connections.anilist.api.MediaListCollection?,
|
||||
@SerialName("recommendationPlannedQueryManga") val recommendationPlannedQueryManga: ani.dantotsu.connections.anilist.api.MediaListCollection?,
|
||||
@SerialName("Page1") val page1: ActivityPage?,
|
||||
@SerialName("Page2") val page2: ActivityPage?
|
||||
)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class ProfilePageMedia(
|
||||
@SerialName("data")
|
||||
val data: Data?
|
||||
) {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("favoriteAnime") val favoriteAnime: ani.dantotsu.connections.anilist.api.User?,
|
||||
@SerialName("favoriteManga") val favoriteManga: ani.dantotsu.connections.anilist.api.User?
|
||||
)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class AnimeList(
|
||||
@SerialName("data")
|
||||
val data: Data?
|
||||
) {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("recentUpdates") val recentUpdates: ani.dantotsu.connections.anilist.api.Page?,
|
||||
@SerialName("trendingMovies") val trendingMovies: ani.dantotsu.connections.anilist.api.Page?,
|
||||
@SerialName("topRated") val topRated: ani.dantotsu.connections.anilist.api.Page?,
|
||||
@SerialName("mostFav") val mostFav: ani.dantotsu.connections.anilist.api.Page?,
|
||||
)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class MangaList(
|
||||
@SerialName("data")
|
||||
val data: Data?
|
||||
) {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("trendingManga") val trendingManga: ani.dantotsu.connections.anilist.api.Page?,
|
||||
@SerialName("trendingManhwa") val trendingManhwa: ani.dantotsu.connections.anilist.api.Page?,
|
||||
@SerialName("trendingNovel") val trendingNovel: ani.dantotsu.connections.anilist.api.Page?,
|
||||
@SerialName("topRated") val topRated: ani.dantotsu.connections.anilist.api.Page?,
|
||||
@SerialName("mostFav") val mostFav: ani.dantotsu.connections.anilist.api.Page?,
|
||||
)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class ToggleFollow(
|
||||
@SerialName("data")
|
||||
val data: Data?
|
||||
) : java.io.Serializable {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("ToggleFollow")
|
||||
val toggleFollow: FollowData
|
||||
) : java.io.Serializable
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class GenreCollection(
|
||||
@SerialName("data")
|
||||
val data: Data
|
||||
){
|
||||
) : java.io.Serializable {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("GenreCollection")
|
||||
val genreCollection: List<String>?
|
||||
)
|
||||
) : java.io.Serializable
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class MediaTagCollection(
|
||||
@SerialName("data")
|
||||
val data: Data
|
||||
){
|
||||
) : java.io.Serializable {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("MediaTagCollection")
|
||||
val mediaTagCollection: List<MediaTag>?
|
||||
)
|
||||
) : java.io.Serializable
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class User(
|
||||
@SerialName("data")
|
||||
val data: Data
|
||||
){
|
||||
) : java.io.Serializable {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("User")
|
||||
val user: ani.dantotsu.connections.anilist.api.User?
|
||||
)
|
||||
) : java.io.Serializable
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class UserProfileResponse(
|
||||
@SerialName("data")
|
||||
val data: Data
|
||||
) : java.io.Serializable {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("followerPage")
|
||||
val followerPage: UserProfilePage?,
|
||||
@SerialName("followingPage")
|
||||
val followingPage: UserProfilePage?,
|
||||
@SerialName("user")
|
||||
val user: UserProfile?
|
||||
) : java.io.Serializable
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class UserProfilePage(
|
||||
@SerialName("pageInfo")
|
||||
val pageInfo: PageInfo,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Following(
|
||||
@SerialName("data")
|
||||
val data: Data
|
||||
) : java.io.Serializable {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("Page")
|
||||
val page: FollowingPage?
|
||||
) : java.io.Serializable
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class Follower(
|
||||
@SerialName("data")
|
||||
val data: Data
|
||||
) : java.io.Serializable {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("Page")
|
||||
val page: FollowerPage?
|
||||
) : java.io.Serializable
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class FollowerPage(
|
||||
@SerialName("followers")
|
||||
val followers: List<ani.dantotsu.connections.anilist.api.User>?
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class FollowingPage(
|
||||
@SerialName("following")
|
||||
val following: List<ani.dantotsu.connections.anilist.api.User>?
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ReviewsResponse(
|
||||
@SerialName("data")
|
||||
val data: Data
|
||||
) : java.io.Serializable {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("Page")
|
||||
val page: ReviewPage?
|
||||
) : java.io.Serializable
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class ReviewPage(
|
||||
@SerialName("pageInfo")
|
||||
val pageInfo: PageInfo,
|
||||
@SerialName("reviews")
|
||||
val reviews: List<Review>?
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class RateReviewResponse(
|
||||
@SerialName("data")
|
||||
val data: Data
|
||||
) : java.io.Serializable {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("RateReview")
|
||||
val rateReview: Review
|
||||
) : java.io.Serializable
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class Review(
|
||||
@SerialName("id")
|
||||
val id: Int,
|
||||
@SerialName("mediaId")
|
||||
val mediaId: Int,
|
||||
@SerialName("mediaType")
|
||||
val mediaType: String,
|
||||
@SerialName("summary")
|
||||
val summary: String,
|
||||
@SerialName("body")
|
||||
val body: String,
|
||||
@SerialName("rating")
|
||||
var rating: Int,
|
||||
@SerialName("ratingAmount")
|
||||
var ratingAmount: Int,
|
||||
@SerialName("userRating")
|
||||
var userRating: String,
|
||||
@SerialName("score")
|
||||
val score: Int,
|
||||
@SerialName("private")
|
||||
val private: Boolean,
|
||||
@SerialName("siteUrl")
|
||||
val siteUrl: String,
|
||||
@SerialName("createdAt")
|
||||
val createdAt: Int,
|
||||
@SerialName("updatedAt")
|
||||
val updatedAt: Int?,
|
||||
@SerialName("user")
|
||||
val user: ani.dantotsu.connections.anilist.api.User?,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class UserProfile(
|
||||
@SerialName("id")
|
||||
val id: Int,
|
||||
@SerialName("name")
|
||||
val name: String,
|
||||
@SerialName("about")
|
||||
val about: String?,
|
||||
@SerialName("avatar")
|
||||
val avatar: UserAvatar?,
|
||||
@SerialName("bannerImage")
|
||||
val bannerImage: String?,
|
||||
@SerialName("isFollowing")
|
||||
var isFollowing: Boolean,
|
||||
@SerialName("isFollower")
|
||||
val isFollower: Boolean,
|
||||
@SerialName("isBlocked")
|
||||
val isBlocked: Boolean,
|
||||
@SerialName("favourites")
|
||||
val favourites: UserFavourites?,
|
||||
@SerialName("statistics")
|
||||
val statistics: NNUserStatisticTypes,
|
||||
@SerialName("siteUrl")
|
||||
val siteUrl: String,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class NNUserStatisticTypes(
|
||||
@SerialName("anime") var anime: NNUserStatistics,
|
||||
@SerialName("manga") var manga: NNUserStatistics
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class NNUserStatistics(
|
||||
@SerialName("count") var count: Int,
|
||||
@SerialName("meanScore") var meanScore: Float,
|
||||
@SerialName("standardDeviation") var standardDeviation: Float,
|
||||
@SerialName("minutesWatched") var minutesWatched: Int,
|
||||
@SerialName("episodesWatched") var episodesWatched: Int,
|
||||
@SerialName("chaptersRead") var chaptersRead: Int,
|
||||
@SerialName("volumesRead") var volumesRead: Int,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class UserFavourites(
|
||||
@SerialName("anime")
|
||||
val anime: UserMediaFavouritesCollection,
|
||||
@SerialName("manga")
|
||||
val manga: UserMediaFavouritesCollection,
|
||||
@SerialName("characters")
|
||||
val characters: UserCharacterFavouritesCollection,
|
||||
@SerialName("staff")
|
||||
val staff: UserStaffFavouritesCollection,
|
||||
@SerialName("studios")
|
||||
val studios: UserStudioFavouritesCollection,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class UserMediaFavouritesCollection(
|
||||
@SerialName("nodes")
|
||||
val nodes: List<UserMediaImageFavorite>,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class UserMediaImageFavorite(
|
||||
@SerialName("id")
|
||||
val id: Int,
|
||||
@SerialName("coverImage")
|
||||
val coverImage: MediaCoverImage
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class UserCharacterFavouritesCollection(
|
||||
@SerialName("nodes")
|
||||
val nodes: List<UserCharacterImageFavorite>,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class UserCharacterImageFavorite(
|
||||
@SerialName("id")
|
||||
val id: Int,
|
||||
@SerialName("name")
|
||||
val name: CharacterName,
|
||||
@SerialName("image")
|
||||
val image: CharacterImage,
|
||||
@SerialName("isFavourite")
|
||||
val isFavourite: Boolean
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class UserStaffFavouritesCollection(
|
||||
@SerialName("nodes")
|
||||
val nodes: List<UserCharacterImageFavorite>, //downstream it's the same as character
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class UserStudioFavouritesCollection(
|
||||
@SerialName("nodes")
|
||||
val nodes: List<UserStudioFavorite>,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class UserStudioFavorite(
|
||||
@SerialName("id")
|
||||
val id: Int,
|
||||
@SerialName("name")
|
||||
val name: String,
|
||||
) : java.io.Serializable
|
||||
|
||||
//----------------------------------------
|
||||
// Statistics
|
||||
|
||||
@Serializable
|
||||
data class StatisticsResponse(
|
||||
@SerialName("data")
|
||||
val data: Data
|
||||
) : java.io.Serializable {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("User")
|
||||
val user: StatisticsUser?
|
||||
) : java.io.Serializable
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class StatisticsUser(
|
||||
@SerialName("id")
|
||||
val id: Int,
|
||||
@SerialName("name")
|
||||
val name: String,
|
||||
@SerialName("mediaListOptions")
|
||||
val mediaListOptions: MediaListOptions,
|
||||
@SerialName("statistics")
|
||||
val statistics: StatisticsTypes
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class StatisticsTypes(
|
||||
@SerialName("anime")
|
||||
val anime: Statistics,
|
||||
@SerialName("manga")
|
||||
val manga: Statistics
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Statistics(
|
||||
@SerialName("count")
|
||||
val count: Int,
|
||||
@SerialName("meanScore")
|
||||
val meanScore: Float,
|
||||
@SerialName("standardDeviation")
|
||||
val standardDeviation: Float,
|
||||
@SerialName("minutesWatched")
|
||||
val minutesWatched: Int,
|
||||
@SerialName("episodesWatched")
|
||||
val episodesWatched: Int,
|
||||
@SerialName("chaptersRead")
|
||||
val chaptersRead: Int,
|
||||
@SerialName("volumesRead")
|
||||
val volumesRead: Int,
|
||||
@SerialName("formats")
|
||||
val formats: List<StatisticsFormat>,
|
||||
@SerialName("statuses")
|
||||
val statuses: List<StatisticsStatus>,
|
||||
@SerialName("scores")
|
||||
val scores: List<StatisticsScore>,
|
||||
@SerialName("lengths")
|
||||
val lengths: List<StatisticsLength>,
|
||||
@SerialName("releaseYears")
|
||||
val releaseYears: List<StatisticsReleaseYear>,
|
||||
@SerialName("startYears")
|
||||
val startYears: List<StatisticsStartYear>,
|
||||
@SerialName("genres")
|
||||
val genres: List<StatisticsGenre>,
|
||||
@SerialName("tags")
|
||||
val tags: List<StatisticsTag>,
|
||||
@SerialName("countries")
|
||||
val countries: List<StatisticsCountry>,
|
||||
@SerialName("voiceActors")
|
||||
val voiceActors: List<StatisticsVoiceActor>,
|
||||
@SerialName("staff")
|
||||
val staff: List<StatisticsStaff>,
|
||||
@SerialName("studios")
|
||||
val studios: List<StatisticsStudio>
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class StatisticsFormat(
|
||||
@SerialName("count")
|
||||
val count: Int,
|
||||
@SerialName("meanScore")
|
||||
val meanScore: Float,
|
||||
@SerialName("minutesWatched")
|
||||
val minutesWatched: Int,
|
||||
@SerialName("chaptersRead")
|
||||
val chaptersRead: Int,
|
||||
@SerialName("mediaIds")
|
||||
val mediaIds: List<Int>,
|
||||
@SerialName("format")
|
||||
val format: String
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class StatisticsStatus(
|
||||
@SerialName("count")
|
||||
val count: Int,
|
||||
@SerialName("meanScore")
|
||||
val meanScore: Float,
|
||||
@SerialName("minutesWatched")
|
||||
val minutesWatched: Int,
|
||||
@SerialName("chaptersRead")
|
||||
val chaptersRead: Int,
|
||||
@SerialName("mediaIds")
|
||||
val mediaIds: List<Int>,
|
||||
@SerialName("status")
|
||||
val status: String
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class StatisticsScore(
|
||||
@SerialName("count")
|
||||
val count: Int,
|
||||
@SerialName("meanScore")
|
||||
val meanScore: Float,
|
||||
@SerialName("minutesWatched")
|
||||
val minutesWatched: Int,
|
||||
@SerialName("chaptersRead")
|
||||
val chaptersRead: Int,
|
||||
@SerialName("mediaIds")
|
||||
val mediaIds: List<Int>,
|
||||
@SerialName("score")
|
||||
val score: Int
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class StatisticsLength(
|
||||
@SerialName("count")
|
||||
val count: Int,
|
||||
@SerialName("meanScore")
|
||||
val meanScore: Float,
|
||||
@SerialName("minutesWatched")
|
||||
val minutesWatched: Int,
|
||||
@SerialName("chaptersRead")
|
||||
val chaptersRead: Int,
|
||||
@SerialName("mediaIds")
|
||||
val mediaIds: List<Int>,
|
||||
@SerialName("length")
|
||||
val length: String? //can be null for manga
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class StatisticsReleaseYear(
|
||||
@SerialName("count")
|
||||
val count: Int,
|
||||
@SerialName("meanScore")
|
||||
val meanScore: Float,
|
||||
@SerialName("minutesWatched")
|
||||
val minutesWatched: Int,
|
||||
@SerialName("chaptersRead")
|
||||
val chaptersRead: Int,
|
||||
@SerialName("mediaIds")
|
||||
val mediaIds: List<Int>,
|
||||
@SerialName("releaseYear")
|
||||
val releaseYear: Int
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class StatisticsStartYear(
|
||||
@SerialName("count")
|
||||
val count: Int,
|
||||
@SerialName("meanScore")
|
||||
val meanScore: Float,
|
||||
@SerialName("minutesWatched")
|
||||
val minutesWatched: Int,
|
||||
@SerialName("chaptersRead")
|
||||
val chaptersRead: Int,
|
||||
@SerialName("mediaIds")
|
||||
val mediaIds: List<Int>,
|
||||
@SerialName("startYear")
|
||||
val startYear: Int
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class StatisticsGenre(
|
||||
@SerialName("count")
|
||||
val count: Int,
|
||||
@SerialName("meanScore")
|
||||
val meanScore: Float,
|
||||
@SerialName("minutesWatched")
|
||||
val minutesWatched: Int,
|
||||
@SerialName("chaptersRead")
|
||||
val chaptersRead: Int,
|
||||
@SerialName("mediaIds")
|
||||
val mediaIds: List<Int>,
|
||||
@SerialName("genre")
|
||||
val genre: String
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class StatisticsTag(
|
||||
@SerialName("count")
|
||||
val count: Int,
|
||||
@SerialName("meanScore")
|
||||
val meanScore: Float,
|
||||
@SerialName("minutesWatched")
|
||||
val minutesWatched: Int,
|
||||
@SerialName("chaptersRead")
|
||||
val chaptersRead: Int,
|
||||
@SerialName("mediaIds")
|
||||
val mediaIds: List<Int>,
|
||||
@SerialName("tag")
|
||||
val tag: Tag
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Tag(
|
||||
@SerialName("id")
|
||||
val id: Int,
|
||||
@SerialName("name")
|
||||
val name: String
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class StatisticsCountry(
|
||||
@SerialName("count")
|
||||
val count: Int,
|
||||
@SerialName("meanScore")
|
||||
val meanScore: Float,
|
||||
@SerialName("minutesWatched")
|
||||
val minutesWatched: Int,
|
||||
@SerialName("chaptersRead")
|
||||
val chaptersRead: Int,
|
||||
@SerialName("mediaIds")
|
||||
val mediaIds: List<Int>,
|
||||
@SerialName("country")
|
||||
val country: String
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class StatisticsVoiceActor(
|
||||
@SerialName("count")
|
||||
val count: Int,
|
||||
@SerialName("meanScore")
|
||||
val meanScore: Float,
|
||||
@SerialName("minutesWatched")
|
||||
val minutesWatched: Int,
|
||||
@SerialName("chaptersRead")
|
||||
val chaptersRead: Int,
|
||||
@SerialName("mediaIds")
|
||||
val mediaIds: List<Int>,
|
||||
@SerialName("voiceActor")
|
||||
val voiceActor: VoiceActor,
|
||||
@SerialName("characterIds")
|
||||
val characterIds: List<Int>
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class VoiceActor(
|
||||
@SerialName("id")
|
||||
val id: Int,
|
||||
@SerialName("name")
|
||||
val name: StaffName
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class StaffName(
|
||||
@SerialName("first")
|
||||
val first: String?,
|
||||
@SerialName("middle")
|
||||
val middle: String?,
|
||||
@SerialName("last")
|
||||
val last: String?,
|
||||
@SerialName("full")
|
||||
val full: String?,
|
||||
@SerialName("native")
|
||||
val native: String?,
|
||||
@SerialName("alternative")
|
||||
val alternative: List<String>?,
|
||||
@SerialName("userPreferred")
|
||||
val userPreferred: String?
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class StatisticsStaff(
|
||||
@SerialName("count")
|
||||
val count: Int,
|
||||
@SerialName("meanScore")
|
||||
val meanScore: Float,
|
||||
@SerialName("minutesWatched")
|
||||
val minutesWatched: Int,
|
||||
@SerialName("chaptersRead")
|
||||
val chaptersRead: Int,
|
||||
@SerialName("mediaIds")
|
||||
val mediaIds: List<Int>,
|
||||
@SerialName("staff")
|
||||
val staff: VoiceActor
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class StatisticsStudio(
|
||||
@SerialName("count")
|
||||
val count: Int,
|
||||
@SerialName("meanScore")
|
||||
val meanScore: Float,
|
||||
@SerialName("minutesWatched")
|
||||
val minutesWatched: Int,
|
||||
@SerialName("chaptersRead")
|
||||
val chaptersRead: Int,
|
||||
@SerialName("mediaIds")
|
||||
val mediaIds: List<Int>,
|
||||
@SerialName("studio")
|
||||
val studio: StatStudio
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class StatStudio(
|
||||
@SerialName("id")
|
||||
val id: Int,
|
||||
@SerialName("name")
|
||||
val name: String,
|
||||
@SerialName("isAnimationStudio")
|
||||
val isAnimationStudio: Boolean
|
||||
) : java.io.Serializable
|
||||
|
||||
}
|
||||
|
||||
//data class WhaData(
|
||||
@@ -168,7 +807,7 @@ class Query{
|
||||
// // Activity reply query
|
||||
// val ActivityReply: ActivityReply?,
|
||||
|
||||
// // Comment query
|
||||
// // CommentNotificationWorker query
|
||||
// val ThreadComment: List<ThreadComment>?,
|
||||
|
||||
// // Notification query
|
||||
|
||||
132
app/src/main/java/ani/dantotsu/connections/anilist/api/Feed.kt
Normal file
132
app/src/main/java/ani/dantotsu/connections/anilist/api/Feed.kt
Normal file
@@ -0,0 +1,132 @@
|
||||
package ani.dantotsu.connections.anilist.api
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class FeedResponse(
|
||||
@SerialName("data")
|
||||
val data: Data
|
||||
) : java.io.Serializable {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("Page")
|
||||
val page: ActivityPage
|
||||
) : java.io.Serializable
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class ActivityPage(
|
||||
@SerialName("activities")
|
||||
val activities: List<Activity>
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Activity(
|
||||
@SerialName("__typename")
|
||||
val typename: String,
|
||||
@SerialName("id")
|
||||
val id: Int,
|
||||
@SerialName("recipientId")
|
||||
val recipientId: Int?,
|
||||
@SerialName("messengerId")
|
||||
val messengerId: Int?,
|
||||
@SerialName("userId")
|
||||
val userId: Int?,
|
||||
@SerialName("type")
|
||||
val type: String,
|
||||
@SerialName("replyCount")
|
||||
val replyCount: Int = 0,
|
||||
@SerialName("status")
|
||||
val status: String?,
|
||||
@SerialName("progress")
|
||||
val progress: String?,
|
||||
@SerialName("text")
|
||||
val text: String?,
|
||||
@SerialName("message")
|
||||
val message: String?,
|
||||
@SerialName("siteUrl")
|
||||
val siteUrl: String?,
|
||||
@SerialName("isLocked")
|
||||
val isLocked: Boolean?,
|
||||
@SerialName("isSubscribed")
|
||||
val isSubscribed: Boolean?,
|
||||
@SerialName("likeCount")
|
||||
var likeCount: Int?,
|
||||
@SerialName("isLiked")
|
||||
var isLiked: Boolean?,
|
||||
@SerialName("isPinned")
|
||||
val isPinned: Boolean?,
|
||||
@SerialName("isPrivate")
|
||||
val isPrivate: Boolean?,
|
||||
@SerialName("createdAt")
|
||||
val createdAt: Int,
|
||||
@SerialName("user")
|
||||
val user: User?,
|
||||
@SerialName("recipient")
|
||||
val recipient: User?,
|
||||
@SerialName("messenger")
|
||||
val messenger: User?,
|
||||
@SerialName("media")
|
||||
val media: Media?,
|
||||
@SerialName("replies")
|
||||
val replies: List<ActivityReply>?,
|
||||
@SerialName("likes")
|
||||
val likes: List<User>?,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ReplyResponse(
|
||||
@SerialName("data")
|
||||
val data: Data
|
||||
) : java.io.Serializable {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("Page")
|
||||
val page: ReplyPage
|
||||
) : java.io.Serializable
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class ReplyPage(
|
||||
@SerialName("activityReplies")
|
||||
val activityReplies: List<ActivityReply>
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ActivityReply(
|
||||
@SerialName("id")
|
||||
val id: Int,
|
||||
@SerialName("userId")
|
||||
val userId: Int,
|
||||
@SerialName("text")
|
||||
val text: String,
|
||||
@SerialName("likeCount")
|
||||
var likeCount: Int,
|
||||
@SerialName("isLiked")
|
||||
var isLiked: Boolean,
|
||||
@SerialName("createdAt")
|
||||
val createdAt: Int,
|
||||
@SerialName("user")
|
||||
val user: User,
|
||||
@SerialName("likes")
|
||||
val likes: List<User>?,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ToggleLike(
|
||||
@SerialName("data")
|
||||
val data: Data
|
||||
) : java.io.Serializable {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("ToggleLikeV2")
|
||||
val toggleLike: LikeData
|
||||
) : java.io.Serializable
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class LikeData(
|
||||
@SerialName("__typename")
|
||||
val typename: String
|
||||
) : java.io.Serializable
|
||||
@@ -3,7 +3,7 @@ package ani.dantotsu.connections.anilist.api
|
||||
import kotlinx.serialization.SerialName
|
||||
import java.io.Serializable
|
||||
import java.text.DateFormatSymbols
|
||||
import java.util.*
|
||||
import java.util.Calendar
|
||||
|
||||
@kotlinx.serialization.Serializable
|
||||
data class FuzzyDate(
|
||||
@@ -16,9 +16,11 @@ data class FuzzyDate(
|
||||
fun isEmpty(): Boolean {
|
||||
return year == null && month == null && day == null
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return if ( isEmpty() ) "??" else toStringOrEmpty()
|
||||
return if (isEmpty()) "??" else toStringOrEmpty()
|
||||
}
|
||||
|
||||
fun toStringOrEmpty(): String {
|
||||
return listOfNotNull(
|
||||
day?.toString(),
|
||||
@@ -29,16 +31,21 @@ data class FuzzyDate(
|
||||
|
||||
fun getToday(): FuzzyDate {
|
||||
val cal = Calendar.getInstance()
|
||||
return FuzzyDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH))
|
||||
return FuzzyDate(
|
||||
cal.get(Calendar.YEAR),
|
||||
cal.get(Calendar.MONTH) + 1,
|
||||
cal.get(Calendar.DAY_OF_MONTH)
|
||||
)
|
||||
}
|
||||
|
||||
fun toVariableString(): String {
|
||||
return listOfNotNull(
|
||||
year?.let {"year:$it"},
|
||||
month?.let {"month:$it"},
|
||||
day?.let {"day:$it"}
|
||||
year?.let { "year:$it" },
|
||||
month?.let { "month:$it" },
|
||||
day?.let { "day:$it" }
|
||||
).joinToString(",", "{", "}")
|
||||
}
|
||||
|
||||
fun toMALString(): String {
|
||||
val padding = '0'
|
||||
val values = listOf(
|
||||
@@ -46,7 +53,7 @@ data class FuzzyDate(
|
||||
month?.toString()?.padStart(2, padding),
|
||||
day?.toString()?.padStart(2, padding)
|
||||
)
|
||||
return values.takeWhile {it is String}.joinToString("-")
|
||||
return values.takeWhile { it is String }.joinToString("-")
|
||||
}
|
||||
|
||||
// fun toInt(): Int {
|
||||
@@ -54,8 +61,8 @@ data class FuzzyDate(
|
||||
// }
|
||||
|
||||
override fun compareTo(other: FuzzyDate): Int = when {
|
||||
year != other.year -> (year ?: 0) - (other.year ?: 0)
|
||||
year != other.year -> (year ?: 0) - (other.year ?: 0)
|
||||
month != other.month -> (month ?: 0) - (other.month ?: 0)
|
||||
else -> (day ?: 0) - (other.day ?: 0)
|
||||
else -> (day ?: 0) - (other.day ?: 0)
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ data class Media(
|
||||
@SerialName("characters") var characters: CharacterConnection?,
|
||||
|
||||
// The staff who produced the media
|
||||
@SerialName("staffPreview") var staff: StaffConnection?,
|
||||
@SerialName("staffPreview") var staff: StaffConnection?,
|
||||
|
||||
// The companies who produced the media
|
||||
@SerialName("studios") var studios: StudioConnection?,
|
||||
@@ -143,7 +143,7 @@ data class Media(
|
||||
@SerialName("externalLinks") var externalLinks: List<MediaExternalLink>?,
|
||||
|
||||
// Data and links to legal streaming episodes on external sites
|
||||
// @SerialName("streamingEpisodes") var streamingEpisodes: List<MediaStreamingEpisode>?,
|
||||
@SerialName("streamingEpisodes") var streamingEpisodes: List<MediaStreamingEpisode>?,
|
||||
|
||||
// The ranking of the media in a particular time span and format compared to other media
|
||||
// @SerialName("rankings") var rankings: List<MediaRank>?,
|
||||
@@ -152,7 +152,7 @@ data class Media(
|
||||
@SerialName("mediaListEntry") var mediaListEntry: MediaList?,
|
||||
|
||||
// User reviews of the media
|
||||
// @SerialName("reviews") var reviews: ReviewConnection?,
|
||||
@SerialName("reviews") var reviews: ReviewConnection?,
|
||||
|
||||
// User recommendations for similar media
|
||||
@SerialName("recommendations") var recommendations: RecommendationConnection?,
|
||||
@@ -174,7 +174,7 @@ data class Media(
|
||||
|
||||
// Notes for site moderators
|
||||
@SerialName("modNotes") var modNotes: String?,
|
||||
)
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class MediaTitle(
|
||||
@@ -189,7 +189,7 @@ data class MediaTitle(
|
||||
|
||||
// The currently authenticated users preferred title language. Default romaji for non-authenticated
|
||||
@SerialName("userPreferred") var userPreferred: String,
|
||||
)
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
enum class MediaType {
|
||||
@@ -205,15 +205,17 @@ enum class MediaStatus {
|
||||
FINISHED, RELEASING, NOT_YET_RELEASED, CANCELLED, HIATUS;
|
||||
|
||||
override fun toString(): String {
|
||||
return when (super.toString()) {
|
||||
"FINISHED" -> currContext()!!.getString(R.string.status_finished)
|
||||
"RELEASING" -> currContext()!!.getString(R.string.status_releasing)
|
||||
"NOT_YET_RELEASED" -> currContext()!!.getString(R.string.status_not_yet_released)
|
||||
"CANCELLED" -> currContext()!!.getString(R.string.status_cancelled)
|
||||
"HIATUS" -> currContext()!!.getString(R.string.status_hiatus)
|
||||
else -> ""
|
||||
currContext()?.let {
|
||||
return when (super.toString()) {
|
||||
"FINISHED" -> it.getString(R.string.status_finished)
|
||||
"RELEASING" -> it.getString(R.string.status_releasing)
|
||||
"NOT_YET_RELEASED" -> it.getString(R.string.status_not_yet_released)
|
||||
"CANCELLED" -> it.getString(R.string.status_cancelled)
|
||||
"HIATUS" -> it.getString(R.string.status_hiatus)
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
return super.toString().replace("_", " ")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,6 +240,21 @@ data class AiringSchedule(
|
||||
@SerialName("media") var media: Media?,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class MediaStreamingEpisode(
|
||||
// The title of the episode
|
||||
@SerialName("title") var title: String?,
|
||||
|
||||
// The thumbnail image of the episode
|
||||
@SerialName("thumbnail") var thumbnail: String?,
|
||||
|
||||
// The url of the episode
|
||||
@SerialName("url") var url: String?,
|
||||
|
||||
// The site location of the streaming episode
|
||||
@SerialName("site") var site: String?,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class MediaCoverImage(
|
||||
// The cover image url of the media at its largest size. If this size isn't available, large will be provided instead.
|
||||
@@ -251,7 +268,7 @@ data class MediaCoverImage(
|
||||
|
||||
// Average #hex color of cover image
|
||||
@SerialName("color") var color: String?,
|
||||
)
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class MediaList(
|
||||
@@ -292,7 +309,7 @@ data class MediaList(
|
||||
@SerialName("hiddenFromStatusLists") var hiddenFromStatusLists: Boolean?,
|
||||
|
||||
// Map of booleans for which custom lists the entry are in
|
||||
@SerialName("customLists") var customLists: Map<String,Boolean>?,
|
||||
@SerialName("customLists") var customLists: Map<String, Boolean>?,
|
||||
|
||||
// Map of advanced scores with name keys
|
||||
// @SerialName("advancedScores") var advancedScores: Json?,
|
||||
@@ -355,7 +372,7 @@ data class MediaTrailer(
|
||||
|
||||
@Serializable
|
||||
data class MediaTagCollection(
|
||||
@SerialName("tags") var tags : List<MediaTag>?
|
||||
@SerialName("tags") var tags: List<MediaTag>?
|
||||
)
|
||||
|
||||
@Serializable
|
||||
@@ -431,7 +448,7 @@ data class MediaEdge(
|
||||
@SerialName("staffRole") var staffRole: String?,
|
||||
|
||||
// The voice actors of the character
|
||||
// @SerialName("voiceActors") var voiceActors: List<Staff>?,
|
||||
@SerialName("voiceActors") var voiceActors: List<Staff>?,
|
||||
|
||||
// The voice actors of the character with role date
|
||||
// @SerialName("voiceActorRoles") var voiceActorRoles: List<StaffRoleType>?,
|
||||
@@ -445,17 +462,20 @@ enum class MediaRelation {
|
||||
ADAPTATION, PREQUEL, SEQUEL, PARENT, SIDE_STORY, CHARACTER, SUMMARY, ALTERNATIVE, SPIN_OFF, OTHER, SOURCE, COMPILATION, CONTAINS;
|
||||
|
||||
override fun toString(): String {
|
||||
return when (super.toString()) {
|
||||
"ADAPTATION" -> currContext()!!.getString(R.string.type_adaptation)
|
||||
"PARENT" -> currContext()!!.getString(R.string.type_parent)
|
||||
"CHARACTER" -> currContext()!!.getString(R.string.type_character)
|
||||
"SUMMARY" -> currContext()!!.getString(R.string.type_summary)
|
||||
"ALTERNATIVE" -> currContext()!!.getString(R.string.type_alternative)
|
||||
"OTHER" -> currContext()!!.getString(R.string.type_other)
|
||||
"SOURCE" -> currContext()!!.getString(R.string.type_source)
|
||||
"CONTAINS" -> currContext()!!.getString(R.string.type_contains)
|
||||
else -> super.toString().replace("_", " ")
|
||||
currContext()?.let {
|
||||
return when (super.toString()) {
|
||||
"ADAPTATION" -> it.getString(R.string.type_adaptation)
|
||||
"PARENT" -> it.getString(R.string.type_parent)
|
||||
"CHARACTER" -> it.getString(R.string.type_character)
|
||||
"SUMMARY" -> it.getString(R.string.type_summary)
|
||||
"ALTERNATIVE" -> it.getString(R.string.type_alternative)
|
||||
"OTHER" -> it.getString(R.string.type_other)
|
||||
"SOURCE" -> it.getString(R.string.type_source)
|
||||
"CONTAINS" -> it.getString(R.string.type_contains)
|
||||
else -> super.toString().replace("_", " ")
|
||||
}
|
||||
}
|
||||
return super.toString().replace("_", " ")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -490,7 +510,7 @@ data class MediaExternalLink(
|
||||
|
||||
// isDisabled: Boolean
|
||||
@SerialName("notes") var notes: String?,
|
||||
)
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
enum class ExternalLinkType {
|
||||
@@ -512,7 +532,13 @@ data class MediaListCollection(
|
||||
// If there is another chunk
|
||||
@SerialName("hasNextChunk") var hasNextChunk: Boolean?,
|
||||
|
||||
)
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class FollowData(
|
||||
@SerialName("id") var id: Int,
|
||||
@SerialName("isFollowing") var isFollowing: Boolean,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class MediaListGroup(
|
||||
@@ -526,4 +552,9 @@ data class MediaListGroup(
|
||||
@SerialName("isSplitCompletedList") var isSplitCompletedList: Boolean?,
|
||||
|
||||
@SerialName("status") var status: MediaListStatus?,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ReviewConnection(
|
||||
@SerialName("nodes") var nodes: List<Query.Review>?,
|
||||
)
|
||||
@@ -0,0 +1,140 @@
|
||||
package ani.dantotsu.connections.anilist.api
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import java.util.Locale
|
||||
|
||||
enum class NotificationType(val value: String) {
|
||||
ACTIVITY_MESSAGE("ACTIVITY_MESSAGE"),
|
||||
ACTIVITY_REPLY("ACTIVITY_REPLY"),
|
||||
FOLLOWING("FOLLOWING"),
|
||||
ACTIVITY_MENTION("ACTIVITY_MENTION"),
|
||||
THREAD_COMMENT_MENTION("THREAD_COMMENT_MENTION"),
|
||||
THREAD_SUBSCRIBED("THREAD_SUBSCRIBED"),
|
||||
THREAD_COMMENT_REPLY("THREAD_COMMENT_REPLY"),
|
||||
AIRING("AIRING"),
|
||||
ACTIVITY_LIKE("ACTIVITY_LIKE"),
|
||||
ACTIVITY_REPLY_LIKE("ACTIVITY_REPLY_LIKE"),
|
||||
THREAD_LIKE("THREAD_LIKE"),
|
||||
THREAD_COMMENT_LIKE("THREAD_COMMENT_LIKE"),
|
||||
ACTIVITY_REPLY_SUBSCRIBED("ACTIVITY_REPLY_SUBSCRIBED"),
|
||||
RELATED_MEDIA_ADDITION("RELATED_MEDIA_ADDITION"),
|
||||
MEDIA_DATA_CHANGE("MEDIA_DATA_CHANGE"),
|
||||
MEDIA_MERGE("MEDIA_MERGE"),
|
||||
MEDIA_DELETION("MEDIA_DELETION"),
|
||||
|
||||
//custom
|
||||
COMMENT_REPLY("COMMENT_REPLY"),
|
||||
COMMENT_WARNING("COMMENT_WARNING"),
|
||||
DANTOTSU_UPDATE("DANTOTSU_UPDATE"),
|
||||
SUBSCRIPTION("SUBSCRIPTION");
|
||||
|
||||
fun toFormattedString(): String {
|
||||
return this.value.replace("_", " ").lowercase(Locale.ROOT)
|
||||
.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.ROOT) else it.toString() }
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun String.fromFormattedString(): String {
|
||||
return this.replace(" ", "_").uppercase(Locale.ROOT)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class NotificationResponse(
|
||||
@SerialName("data")
|
||||
val data: Data,
|
||||
) : java.io.Serializable {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("User")
|
||||
val user: NotificationUser,
|
||||
@SerialName("Page")
|
||||
val page: NotificationPage,
|
||||
) : java.io.Serializable
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class NotificationUser(
|
||||
@SerialName("unreadNotificationCount")
|
||||
var unreadNotificationCount: Int,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class NotificationPage(
|
||||
@SerialName("pageInfo")
|
||||
val pageInfo: PageInfo,
|
||||
@SerialName("notifications")
|
||||
val notifications: List<Notification>,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Notification(
|
||||
@SerialName("__typename")
|
||||
val typename: String,
|
||||
@SerialName("id")
|
||||
val id: Int,
|
||||
@SerialName("userId")
|
||||
val userId: Int? = null,
|
||||
@SerialName("CommentId")
|
||||
val commentId: Int?,
|
||||
@SerialName("type")
|
||||
val notificationType: String,
|
||||
@SerialName("activityId")
|
||||
val activityId: Int? = null,
|
||||
@SerialName("animeId")
|
||||
val mediaId: Int? = null,
|
||||
@SerialName("episode")
|
||||
val episode: Int? = null,
|
||||
@SerialName("contexts")
|
||||
val contexts: List<String>? = null,
|
||||
@SerialName("context")
|
||||
val context: String? = null,
|
||||
@SerialName("reason")
|
||||
val reason: String? = null,
|
||||
@SerialName("deletedMediaTitle")
|
||||
val deletedMediaTitle: String? = null,
|
||||
@SerialName("deletedMediaTitles")
|
||||
val deletedMediaTitles: List<String>? = null,
|
||||
@SerialName("createdAt")
|
||||
val createdAt: Int,
|
||||
@SerialName("media")
|
||||
val media: Media? = null,
|
||||
@SerialName("user")
|
||||
val user: User? = null,
|
||||
@SerialName("message")
|
||||
val message: MessageActivity? = null,
|
||||
@SerialName("activity")
|
||||
val activity: ActivityUnion? = null,
|
||||
@SerialName("Thread")
|
||||
val thread: Thread? = null,
|
||||
@SerialName("comment")
|
||||
val comment: ThreadComment? = null,
|
||||
val image: String? = null,
|
||||
val banner: String? = null,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class MessageActivity(
|
||||
@SerialName("id")
|
||||
val id: Int?,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ActivityUnion(
|
||||
@SerialName("id")
|
||||
val id: Int?,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Thread(
|
||||
@SerialName("id")
|
||||
val id: Int?,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ThreadComment(
|
||||
@SerialName("id")
|
||||
val id: Int?,
|
||||
) : java.io.Serializable
|
||||
@@ -2,6 +2,7 @@ package ani.dantotsu.connections.anilist.api
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Recommendation(
|
||||
// The id of the recommendation
|
||||
@@ -22,6 +23,7 @@ data class Recommendation(
|
||||
// The user that first created the recommendation
|
||||
@SerialName("user") var user: User?,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class RecommendationConnection(
|
||||
//@SerialName("edges") var edges: List<RecommendationEdge>?,
|
||||
|
||||
@@ -9,13 +9,13 @@ data class Staff(
|
||||
@SerialName("id") var id: Int,
|
||||
|
||||
// The names of the staff member
|
||||
@SerialName("name") var name: StaffName?,
|
||||
@SerialName("name") var name: StaffName?,
|
||||
|
||||
// The primary language of the staff member. Current values: Japanese, English, Korean, Italian, Spanish, Portuguese, French, German, Hebrew, Hungarian, Chinese, Arabic, Filipino, Catalan, Finnish, Turkish, Dutch, Swedish, Thai, Tagalog, Malaysian, Indonesian, Vietnamese, Nepali, Hindi, Urdu
|
||||
@SerialName("languageV2") var languageV2: String?,
|
||||
|
||||
// The staff images
|
||||
// @SerialName("image") var image: StaffImage?,
|
||||
@SerialName("image") var image: StaffImage?,
|
||||
|
||||
// A general description of the staff member
|
||||
@SerialName("description") var description: String?,
|
||||
@@ -80,8 +80,8 @@ data class Staff(
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class StaffName (
|
||||
var userPreferred:String?
|
||||
data class StaffName(
|
||||
var userPreferred: String?
|
||||
)
|
||||
|
||||
@Serializable
|
||||
@@ -94,8 +94,17 @@ data class StaffConnection(
|
||||
// @SerialName("pageInfo") var pageInfo: PageInfo?,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class StaffImage(
|
||||
// The character's image of media at its largest size
|
||||
@SerialName("large") var large: String?,
|
||||
|
||||
// The character's image of media at medium size
|
||||
@SerialName("medium") var medium: String?,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class StaffEdge(
|
||||
var role:String?,
|
||||
var role: String?,
|
||||
var node: Staff?
|
||||
)
|
||||
@@ -46,7 +46,7 @@ data class User(
|
||||
@SerialName("statistics") var statistics: UserStatisticTypes?,
|
||||
|
||||
// The number of unread notifications the user has
|
||||
// @SerialName("unreadNotificationCount") var unreadNotificationCount: Int?,
|
||||
@SerialName("unreadNotificationCount") var unreadNotificationCount: Int?,
|
||||
|
||||
// The url for the user page on the AniList website
|
||||
// @SerialName("siteUrl") var siteUrl: String?,
|
||||
@@ -69,36 +69,36 @@ data class User(
|
||||
// The user's previously used names.
|
||||
// @SerialName("previousNames") var previousNames: List<UserPreviousName>?,
|
||||
|
||||
)
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class UserOptions(
|
||||
// The language the user wants to see media titles in
|
||||
// @SerialName("titleLanguage") var titleLanguage: UserTitleLanguage?,
|
||||
@SerialName("titleLanguage") var titleLanguage: UserTitleLanguage?,
|
||||
|
||||
// Whether the user has enabled viewing of 18+ content
|
||||
@SerialName("displayAdultContent") var displayAdultContent: Boolean?,
|
||||
|
||||
// Whether the user receives notifications when a show they are watching aires
|
||||
@SerialName("airingNotifications") var airingNotifications: Boolean?,
|
||||
@SerialName("airingNotifications") var airingNotifications: Boolean?,
|
||||
//
|
||||
// Profile highlight color (blue, purple, pink, orange, red, green, gray)
|
||||
@SerialName("profileColor") var profileColor: String?,
|
||||
// Profile highlight color (blue, purple, pink, orange, red, green, gray)
|
||||
@SerialName("profileColor") var profileColor: String?,
|
||||
//
|
||||
// // Notification options
|
||||
// // @SerialName("notificationOptions") var notificationOptions: List<NotificationOption>?,
|
||||
//
|
||||
// // The user's timezone offset (Auth user only)
|
||||
// @SerialName("timezone") var timezone: String?,
|
||||
// The user's timezone offset (Auth user only)
|
||||
@SerialName("timezone") var timezone: String?,
|
||||
//
|
||||
// // Minutes between activity for them to be merged together. 0 is Never, Above 2 weeks (20160 mins) is Always.
|
||||
// @SerialName("activityMergeTime") var activityMergeTime: Int?,
|
||||
// Minutes between activity for them to be merged together. 0 is Never, Above 2 weeks (20160 mins) is Always.
|
||||
@SerialName("activityMergeTime") var activityMergeTime: Int?,
|
||||
//
|
||||
// // The language the user wants to see staff and character names in
|
||||
// // @SerialName("staffNameLanguage") var staffNameLanguage: UserStaffNameLanguage?,
|
||||
// The language the user wants to see staff and character names in
|
||||
@SerialName("staffNameLanguage") var staffNameLanguage: UserStaffNameLanguage?,
|
||||
//
|
||||
// // Whether the user only allow messages from users they follow
|
||||
// @SerialName("restrictMessagesToFollowing") var restrictMessagesToFollowing: Boolean?,
|
||||
// Whether the user only allow messages from users they follow
|
||||
@SerialName("restrictMessagesToFollowing") var restrictMessagesToFollowing: Boolean?,
|
||||
|
||||
// The list activity types the user has disabled from being created from list updates
|
||||
// @SerialName("disabledListActivity") var disabledListActivity: List<ListActivityOption>?,
|
||||
@@ -111,7 +111,7 @@ data class UserAvatar(
|
||||
|
||||
// The avatar of user at medium size
|
||||
@SerialName("medium") var medium: String?,
|
||||
)
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class UserStatisticTypes(
|
||||
@@ -119,6 +119,48 @@ data class UserStatisticTypes(
|
||||
@SerialName("manga") var manga: UserStatistics?
|
||||
)
|
||||
|
||||
@Serializable
|
||||
enum class UserTitleLanguage {
|
||||
@SerialName("ENGLISH")
|
||||
ENGLISH,
|
||||
|
||||
@SerialName("ROMAJI")
|
||||
ROMAJI,
|
||||
|
||||
@SerialName("NATIVE")
|
||||
NATIVE
|
||||
}
|
||||
|
||||
@Serializable
|
||||
enum class UserStaffNameLanguage {
|
||||
@SerialName("ROMAJI_WESTERN")
|
||||
ROMAJI_WESTERN,
|
||||
|
||||
@SerialName("ROMAJI")
|
||||
ROMAJI,
|
||||
|
||||
@SerialName("NATIVE")
|
||||
NATIVE
|
||||
}
|
||||
|
||||
@Serializable
|
||||
enum class ScoreFormat {
|
||||
@SerialName("POINT_100")
|
||||
POINT_100,
|
||||
|
||||
@SerialName("POINT_10_DECIMAL")
|
||||
POINT_10_DECIMAL,
|
||||
|
||||
@SerialName("POINT_10")
|
||||
POINT_10,
|
||||
|
||||
@SerialName("POINT_5")
|
||||
POINT_5,
|
||||
|
||||
@SerialName("POINT_3")
|
||||
POINT_3,
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class UserStatistics(
|
||||
//
|
||||
@@ -164,7 +206,7 @@ data class Favourites(
|
||||
@Serializable
|
||||
data class MediaListOptions(
|
||||
// The score format the user is using for media lists
|
||||
// @SerialName("scoreFormat") var scoreFormat: ScoreFormat?,
|
||||
@SerialName("scoreFormat") var scoreFormat: ScoreFormat?,
|
||||
|
||||
// The default order list rows should be displayed in
|
||||
@SerialName("rowOrder") var rowOrder: String?,
|
||||
@@ -181,8 +223,8 @@ data class MediaListTypeOptions(
|
||||
// The order each list should be displayed in
|
||||
@SerialName("sectionOrder") var sectionOrder: List<String>?,
|
||||
|
||||
// If the completed sections of the list should be separated by format
|
||||
@SerialName("splitCompletedSectionByFormat") var splitCompletedSectionByFormat: Boolean?,
|
||||
// // If the completed sections of the list should be separated by format
|
||||
// @SerialName("splitCompletedSectionByFormat") var splitCompletedSectionByFormat: Boolean?,
|
||||
|
||||
// The names of the user's custom lists
|
||||
@SerialName("customLists") var customLists: List<String>?,
|
||||
|
||||
@@ -0,0 +1,595 @@
|
||||
package ani.dantotsu.connections.comments
|
||||
|
||||
import android.content.Context
|
||||
import ani.dantotsu.connections.anilist.Anilist
|
||||
import ani.dantotsu.isOnline
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.toast
|
||||
import ani.dantotsu.util.Logger
|
||||
import com.lagradost.nicehttp.NiceResponse
|
||||
import com.lagradost.nicehttp.Requests
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.descriptors.PrimitiveKind
|
||||
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.FormBody
|
||||
import okhttp3.OkHttpClient
|
||||
import okio.IOException
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
object CommentsAPI {
|
||||
private const val API_ADDRESS: String = "https://api.dantotsu.app"
|
||||
private const val LOCAL_HOST: String = "https://127.0.0.1"
|
||||
private var isOnline: Boolean = true
|
||||
private var commentsEnabled = PrefManager.getVal<Int>(PrefName.CommentsEnabled) == 1
|
||||
private val ADDRESS: String get() = if (commentsEnabled) API_ADDRESS else LOCAL_HOST
|
||||
var authToken: String? = null
|
||||
var userId: String? = null
|
||||
var isBanned: Boolean = false
|
||||
var isAdmin: Boolean = false
|
||||
var isMod: Boolean = false
|
||||
var totalVotes: Int = 0
|
||||
|
||||
suspend fun getCommentsForId(
|
||||
id: Int,
|
||||
page: Int = 1,
|
||||
tag: Int?,
|
||||
sort: String?
|
||||
): CommentResponse? {
|
||||
var url = "$ADDRESS/comments/$id/$page"
|
||||
val request = requestBuilder()
|
||||
tag?.let {
|
||||
url += "?tag=$it"
|
||||
}
|
||||
sort?.let {
|
||||
url += if (tag != null) "&sort=$it" else "?sort=$it"
|
||||
}
|
||||
val json = try {
|
||||
request.get(url)
|
||||
} catch (e: IOException) {
|
||||
Logger.log(e)
|
||||
errorMessage("Failed to fetch comments")
|
||||
return null
|
||||
}
|
||||
if (!json.text.startsWith("{")) return null
|
||||
val res = json.code == 200
|
||||
if (!res && json.code != 404) {
|
||||
errorReason(json.code, json.text)
|
||||
}
|
||||
val parsed = try {
|
||||
Json.decodeFromString<CommentResponse>(json.text)
|
||||
} catch (e: Exception) {
|
||||
return null
|
||||
}
|
||||
return parsed
|
||||
}
|
||||
|
||||
suspend fun getRepliesFromId(id: Int, page: Int = 1): CommentResponse? {
|
||||
val url = "$ADDRESS/comments/parent/$id/$page"
|
||||
val request = requestBuilder()
|
||||
val json = try {
|
||||
request.get(url)
|
||||
} catch (e: IOException) {
|
||||
Logger.log(e)
|
||||
errorMessage("Failed to fetch comments")
|
||||
return null
|
||||
}
|
||||
if (!json.text.startsWith("{")) return null
|
||||
val res = json.code == 200
|
||||
if (!res && json.code != 404) {
|
||||
errorReason(json.code, json.text)
|
||||
}
|
||||
val parsed = try {
|
||||
Json.decodeFromString<CommentResponse>(json.text)
|
||||
} catch (e: Exception) {
|
||||
return null
|
||||
}
|
||||
return parsed
|
||||
}
|
||||
|
||||
suspend fun getSingleComment(id: Int): Comment? {
|
||||
val url = "$ADDRESS/comments/$id"
|
||||
val request = requestBuilder()
|
||||
val json = try {
|
||||
request.get(url)
|
||||
} catch (e: IOException) {
|
||||
Logger.log(e)
|
||||
errorMessage("Failed to fetch comment")
|
||||
return null
|
||||
}
|
||||
if (!json.text.startsWith("{")) return null
|
||||
val res = json.code == 200
|
||||
if (!res && json.code != 404) {
|
||||
errorReason(json.code, json.text)
|
||||
}
|
||||
val parsed = try {
|
||||
Json.decodeFromString<Comment>(json.text)
|
||||
} catch (e: Exception) {
|
||||
return null
|
||||
}
|
||||
return parsed
|
||||
}
|
||||
|
||||
suspend fun vote(commentId: Int, voteType: Int): Boolean {
|
||||
val url = "$ADDRESS/comments/vote/$commentId/$voteType"
|
||||
val request = requestBuilder()
|
||||
val json = try {
|
||||
request.post(url)
|
||||
} catch (e: IOException) {
|
||||
Logger.log(e)
|
||||
errorMessage("Failed to vote")
|
||||
return false
|
||||
}
|
||||
val res = json.code == 200
|
||||
if (!res) {
|
||||
errorReason(json.code, json.text)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
suspend fun comment(mediaId: Int, parentCommentId: Int?, content: String, tag: Int?): Comment? {
|
||||
val url = "$ADDRESS/comments"
|
||||
val body = FormBody.Builder()
|
||||
.add("user_id", userId ?: return null)
|
||||
.add("media_id", mediaId.toString())
|
||||
.add("content", content)
|
||||
if (tag != null) {
|
||||
body.add("tag", tag.toString())
|
||||
}
|
||||
parentCommentId?.let {
|
||||
body.add("parent_comment_id", it.toString())
|
||||
}
|
||||
val request = requestBuilder()
|
||||
val json = try {
|
||||
request.post(url, requestBody = body.build())
|
||||
} catch (e: IOException) {
|
||||
Logger.log(e)
|
||||
errorMessage("Failed to comment")
|
||||
return null
|
||||
}
|
||||
val res = json.code == 200
|
||||
if (!res) {
|
||||
errorReason(json.code, json.text)
|
||||
return null
|
||||
}
|
||||
val parsed = try {
|
||||
Json.decodeFromString<ReturnedComment>(json.text)
|
||||
} catch (e: Exception) {
|
||||
Logger.log(e)
|
||||
errorMessage("Failed to parse comment")
|
||||
return null
|
||||
}
|
||||
return Comment(
|
||||
parsed.id,
|
||||
parsed.userId,
|
||||
parsed.mediaId,
|
||||
parsed.parentCommentId,
|
||||
parsed.content,
|
||||
parsed.timestamp,
|
||||
parsed.deleted,
|
||||
parsed.tag,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
Anilist.username ?: "",
|
||||
Anilist.avatar,
|
||||
totalVotes = totalVotes
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun deleteComment(commentId: Int): Boolean {
|
||||
val url = "$ADDRESS/comments/$commentId"
|
||||
val request = requestBuilder()
|
||||
val json = try {
|
||||
request.delete(url)
|
||||
} catch (e: IOException) {
|
||||
Logger.log(e)
|
||||
errorMessage("Failed to delete comment")
|
||||
return false
|
||||
}
|
||||
val res = json.code == 200
|
||||
if (!res) {
|
||||
errorReason(json.code, json.text)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
suspend fun editComment(commentId: Int, content: String): Boolean {
|
||||
val url = "$ADDRESS/comments/$commentId"
|
||||
val body = FormBody.Builder()
|
||||
.add("content", content)
|
||||
.build()
|
||||
val request = requestBuilder()
|
||||
val json = try {
|
||||
request.put(url, requestBody = body)
|
||||
} catch (e: IOException) {
|
||||
Logger.log(e)
|
||||
errorMessage("Failed to edit comment")
|
||||
return false
|
||||
}
|
||||
val res = json.code == 200
|
||||
if (!res) {
|
||||
errorReason(json.code, json.text)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
suspend fun banUser(userId: String): Boolean {
|
||||
val url = "$ADDRESS/ban/$userId"
|
||||
val request = requestBuilder()
|
||||
val json = try {
|
||||
request.post(url)
|
||||
} catch (e: IOException) {
|
||||
Logger.log(e)
|
||||
errorMessage("Failed to ban user")
|
||||
return false
|
||||
}
|
||||
val res = json.code == 200
|
||||
if (!res) {
|
||||
errorReason(json.code, json.text)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
suspend fun reportComment(
|
||||
commentId: Int,
|
||||
username: String,
|
||||
mediaTitle: String,
|
||||
reportedId: String
|
||||
): Boolean {
|
||||
val url = "$ADDRESS/report/$commentId"
|
||||
val body = FormBody.Builder()
|
||||
.add("username", username)
|
||||
.add("mediaName", mediaTitle)
|
||||
.add("reporter", Anilist.username ?: "unknown")
|
||||
.add("reportedId", reportedId)
|
||||
.build()
|
||||
val request = requestBuilder()
|
||||
val json = try {
|
||||
request.post(url, requestBody = body)
|
||||
} catch (e: IOException) {
|
||||
Logger.log(e)
|
||||
errorMessage("Failed to report comment")
|
||||
return false
|
||||
}
|
||||
val res = json.code == 200
|
||||
if (!res) {
|
||||
errorReason(json.code, json.text)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
suspend fun getNotifications(client: OkHttpClient): NotificationResponse? {
|
||||
val url = "$ADDRESS/notification/reply"
|
||||
val request = requestBuilder(client)
|
||||
val json = try {
|
||||
request.get(url)
|
||||
} catch (e: IOException) {
|
||||
return null
|
||||
}
|
||||
if (!json.text.startsWith("{")) return null
|
||||
val res = json.code == 200
|
||||
if (!res) {
|
||||
return null
|
||||
}
|
||||
val parsed = try {
|
||||
Json.decodeFromString<NotificationResponse>(json.text)
|
||||
} catch (e: Exception) {
|
||||
return null
|
||||
}
|
||||
return parsed
|
||||
}
|
||||
|
||||
private suspend fun getUserDetails(client: OkHttpClient? = null): User? {
|
||||
val url = "$ADDRESS/user"
|
||||
val request = if (client != null) requestBuilder(client) else requestBuilder()
|
||||
val json = try {
|
||||
request.get(url)
|
||||
} catch (e: IOException) {
|
||||
return null
|
||||
}
|
||||
if (json.code == 200) {
|
||||
val parsed = try {
|
||||
Json.decodeFromString<UserResponse>(json.text)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
return null
|
||||
}
|
||||
isBanned = parsed.user.isBanned ?: false
|
||||
isAdmin = parsed.user.isAdmin ?: false
|
||||
isMod = parsed.user.isMod ?: false
|
||||
totalVotes = parsed.user.totalVotes
|
||||
return parsed.user
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
suspend fun fetchAuthToken(context: Context, client: OkHttpClient? = null) {
|
||||
isOnline = isOnline(context)
|
||||
if (authToken != null) return
|
||||
val MAX_RETRIES = 5
|
||||
val tokenLifetime: Long = 1000 * 60 * 60 * 24 * 6 // 6 days
|
||||
val tokenExpiry = PrefManager.getVal<Long>(PrefName.CommentTokenExpiry)
|
||||
if (tokenExpiry < System.currentTimeMillis() + tokenLifetime) {
|
||||
val commentResponse =
|
||||
PrefManager.getNullableVal<AuthResponse>(PrefName.CommentAuthResponse, null)
|
||||
if (commentResponse != null) {
|
||||
authToken = commentResponse.authToken
|
||||
userId = commentResponse.user.id
|
||||
isBanned = commentResponse.user.isBanned ?: false
|
||||
isAdmin = commentResponse.user.isAdmin ?: false
|
||||
isMod = commentResponse.user.isMod ?: false
|
||||
totalVotes = commentResponse.user.totalVotes
|
||||
if (getUserDetails(client) != null) return
|
||||
}
|
||||
|
||||
}
|
||||
val url = "$ADDRESS/authenticate"
|
||||
val token = PrefManager.getVal(PrefName.AnilistToken, null as String?) ?: return
|
||||
repeat(MAX_RETRIES) {
|
||||
try {
|
||||
val json = authRequest(token, url, client)
|
||||
if (json.code == 200) {
|
||||
if (!json.text.startsWith("{")) throw IOException("Invalid response")
|
||||
val parsed = try {
|
||||
Json.decodeFromString<AuthResponse>(json.text)
|
||||
} catch (e: Exception) {
|
||||
Logger.log(e)
|
||||
errorMessage("Failed to login to comments API: ${e.printStackTrace()}")
|
||||
return
|
||||
}
|
||||
PrefManager.setVal(PrefName.CommentAuthResponse, parsed)
|
||||
PrefManager.setVal(
|
||||
PrefName.CommentTokenExpiry,
|
||||
System.currentTimeMillis() + tokenLifetime
|
||||
)
|
||||
authToken = parsed.authToken
|
||||
userId = parsed.user.id
|
||||
isBanned = parsed.user.isBanned ?: false
|
||||
isAdmin = parsed.user.isAdmin ?: false
|
||||
isMod = parsed.user.isMod ?: false
|
||||
totalVotes = parsed.user.totalVotes
|
||||
return
|
||||
} else if (json.code != 429) {
|
||||
errorReason(json.code, json.text)
|
||||
return
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Logger.log(e)
|
||||
errorMessage("Failed to login to comments API")
|
||||
return
|
||||
}
|
||||
kotlinx.coroutines.delay(60000)
|
||||
}
|
||||
errorMessage("Failed to login after multiple attempts")
|
||||
}
|
||||
|
||||
private fun errorMessage(reason: String) {
|
||||
if (commentsEnabled) Logger.log(reason)
|
||||
if (isOnline && commentsEnabled) snackString(reason)
|
||||
}
|
||||
|
||||
fun logout() {
|
||||
PrefManager.removeVal(PrefName.CommentAuthResponse)
|
||||
PrefManager.removeVal(PrefName.CommentTokenExpiry)
|
||||
authToken = null
|
||||
userId = null
|
||||
isBanned = false
|
||||
isAdmin = false
|
||||
isMod = false
|
||||
totalVotes = 0
|
||||
}
|
||||
|
||||
private suspend fun authRequest(
|
||||
token: String,
|
||||
url: String,
|
||||
client: OkHttpClient? = null
|
||||
): NiceResponse {
|
||||
val body: FormBody = FormBody.Builder()
|
||||
.add("token", token)
|
||||
.build()
|
||||
val request = if (client != null) requestBuilder(client) else requestBuilder()
|
||||
return request.post(url, requestBody = body)
|
||||
}
|
||||
|
||||
private fun headerBuilder(): Map<String, String> {
|
||||
val map = mutableMapOf(
|
||||
"appauth" to "6*45Qp%W2RS@t38jkXoSKY588Ynj%n"
|
||||
)
|
||||
if (authToken != null) {
|
||||
map["Authorization"] = authToken!!
|
||||
}
|
||||
return map
|
||||
}
|
||||
|
||||
fun requestBuilder(client: OkHttpClient = Injekt.get<NetworkHelper>().client): Requests {
|
||||
return Requests(
|
||||
client,
|
||||
headerBuilder()
|
||||
)
|
||||
}
|
||||
|
||||
private fun errorReason(code: Int, reason: String? = null) {
|
||||
val error = when (code) {
|
||||
429 -> "Rate limited. :("
|
||||
else -> "Failed to connect"
|
||||
}
|
||||
val parsed = try {
|
||||
Json.decodeFromString<ErrorResponse>(reason!!)
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
val message = parsed?.message ?: reason ?: error
|
||||
val fullMessage = if (code == 500) message else "$code: $message"
|
||||
|
||||
toast(fullMessage)
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class ErrorResponse(
|
||||
@SerialName("message")
|
||||
val message: String
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class NotificationResponse(
|
||||
@SerialName("notifications")
|
||||
val notifications: List<Notification>
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Notification(
|
||||
@SerialName("username")
|
||||
val username: String,
|
||||
@SerialName("media_id")
|
||||
val mediaId: Int,
|
||||
@SerialName("comment_id")
|
||||
val commentId: Int,
|
||||
@SerialName("type")
|
||||
val type: Int? = null,
|
||||
@SerialName("content")
|
||||
val content: String? = null,
|
||||
@SerialName("notification_id")
|
||||
val notificationId: Int
|
||||
)
|
||||
|
||||
|
||||
@Serializable
|
||||
data class AuthResponse(
|
||||
@SerialName("authToken")
|
||||
val authToken: String,
|
||||
@SerialName("user")
|
||||
val user: User
|
||||
) : java.io.Serializable {
|
||||
companion object {
|
||||
private const val serialVersionUID: Long = 1
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class UserResponse(
|
||||
@SerialName("user")
|
||||
val user: User
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class User(
|
||||
@SerialName("user_id")
|
||||
val id: String,
|
||||
@SerialName("username")
|
||||
val username: String,
|
||||
@SerialName("profile_picture_url")
|
||||
val profilePictureUrl: String? = null,
|
||||
@SerialName("is_banned")
|
||||
@Serializable(with = NumericBooleanSerializer::class)
|
||||
val isBanned: Boolean? = null,
|
||||
@SerialName("is_mod")
|
||||
@Serializable(with = NumericBooleanSerializer::class)
|
||||
val isAdmin: Boolean? = null,
|
||||
@SerialName("is_admin")
|
||||
@Serializable(with = NumericBooleanSerializer::class)
|
||||
val isMod: Boolean? = null,
|
||||
@SerialName("total_votes")
|
||||
val totalVotes: Int,
|
||||
@SerialName("warnings")
|
||||
val warnings: Int
|
||||
) : java.io.Serializable {
|
||||
companion object {
|
||||
private const val serialVersionUID: Long = 1
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class CommentResponse(
|
||||
@SerialName("comments")
|
||||
val comments: List<Comment>,
|
||||
@SerialName("totalPages")
|
||||
val totalPages: Int
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Comment(
|
||||
@SerialName("comment_id")
|
||||
val commentId: Int,
|
||||
@SerialName("user_id")
|
||||
val userId: String,
|
||||
@SerialName("media_id")
|
||||
val mediaId: Int,
|
||||
@SerialName("parent_comment_id")
|
||||
val parentCommentId: Int?,
|
||||
@SerialName("content")
|
||||
var content: String,
|
||||
@SerialName("timestamp")
|
||||
var timestamp: String,
|
||||
@SerialName("deleted")
|
||||
@Serializable(with = NumericBooleanSerializer::class)
|
||||
val deleted: Boolean?,
|
||||
@SerialName("tag")
|
||||
val tag: Int?,
|
||||
@SerialName("upvotes")
|
||||
var upvotes: Int,
|
||||
@SerialName("downvotes")
|
||||
var downvotes: Int,
|
||||
@SerialName("user_vote_type")
|
||||
var userVoteType: Int?,
|
||||
@SerialName("username")
|
||||
val username: String,
|
||||
@SerialName("profile_picture_url")
|
||||
val profilePictureUrl: String?,
|
||||
@SerialName("is_mod")
|
||||
@Serializable(with = NumericBooleanSerializer::class)
|
||||
val isMod: Boolean? = null,
|
||||
@SerialName("is_admin")
|
||||
@Serializable(with = NumericBooleanSerializer::class)
|
||||
val isAdmin: Boolean? = null,
|
||||
@SerialName("reply_count")
|
||||
val replyCount: Int? = null,
|
||||
@SerialName("total_votes")
|
||||
val totalVotes: Int
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class ReturnedComment(
|
||||
@SerialName("id")
|
||||
var id: Int,
|
||||
@SerialName("comment_id")
|
||||
var commentId: Int?,
|
||||
@SerialName("user_id")
|
||||
val userId: String,
|
||||
@SerialName("media_id")
|
||||
val mediaId: Int,
|
||||
@SerialName("parent_comment_id")
|
||||
val parentCommentId: Int? = null,
|
||||
@SerialName("content")
|
||||
val content: String,
|
||||
@SerialName("timestamp")
|
||||
val timestamp: String,
|
||||
@SerialName("deleted")
|
||||
@Serializable(with = NumericBooleanSerializer::class)
|
||||
val deleted: Boolean?,
|
||||
@SerialName("tag")
|
||||
val tag: Int? = null,
|
||||
)
|
||||
|
||||
object NumericBooleanSerializer : KSerializer<Boolean> {
|
||||
override val descriptor: SerialDescriptor =
|
||||
PrimitiveSerialDescriptor("NumericBoolean", PrimitiveKind.INT)
|
||||
|
||||
override fun serialize(encoder: Encoder, value: Boolean) {
|
||||
encoder.encodeInt(if (value) 1 else 0)
|
||||
}
|
||||
|
||||
override fun deserialize(decoder: Decoder): Boolean {
|
||||
return decoder.decodeInt() != 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package ani.dantotsu.connections.crashlytics
|
||||
|
||||
import android.content.Context
|
||||
|
||||
interface CrashlyticsInterface {
|
||||
fun initialize(context: Context)
|
||||
fun logException(e: Throwable)
|
||||
fun log(message: String)
|
||||
fun setUserId(id: String)
|
||||
fun setCustomKey(key: String, value: String)
|
||||
fun setCrashlyticsCollectionEnabled(enabled: Boolean)
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package ani.dantotsu.connections.crashlytics
|
||||
|
||||
import android.content.Context
|
||||
import ani.dantotsu.util.Logger
|
||||
|
||||
class CrashlyticsStub : CrashlyticsInterface {
|
||||
override fun initialize(context: Context) {
|
||||
//no-op
|
||||
}
|
||||
|
||||
override fun logException(e: Throwable) {
|
||||
Logger.log(e)
|
||||
}
|
||||
|
||||
override fun log(message: String) {
|
||||
Logger.log(message)
|
||||
}
|
||||
|
||||
override fun setUserId(id: String) {
|
||||
//no-op
|
||||
}
|
||||
|
||||
override fun setCustomKey(key: String, value: String) {
|
||||
//no-op
|
||||
}
|
||||
|
||||
override fun setCrashlyticsCollectionEnabled(enabled: Boolean) {
|
||||
//no-op
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,16 +3,14 @@ package ani.dantotsu.connections.discord
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.edit
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.connections.discord.serializers.User
|
||||
import ani.dantotsu.others.CustomBottomDialog
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.toast
|
||||
import ani.dantotsu.tryWith
|
||||
import ani.dantotsu.tryWithSuspend
|
||||
import io.noties.markwon.Markwon
|
||||
import io.noties.markwon.SoftBreakAddsNewLinePlugin
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import java.io.File
|
||||
|
||||
object Discord {
|
||||
@@ -21,37 +19,20 @@ object Discord {
|
||||
var userid: String? = null
|
||||
var avatar: String? = null
|
||||
|
||||
private const val TOKEN = "discord_token"
|
||||
|
||||
fun getSavedToken(context: Context): Boolean {
|
||||
val sharedPref = context.getSharedPreferences(
|
||||
context.getString(R.string.preference_file_key),
|
||||
Context.MODE_PRIVATE
|
||||
fun getSavedToken(): Boolean {
|
||||
token = PrefManager.getVal(
|
||||
PrefName.DiscordToken, null as String?
|
||||
)
|
||||
token = sharedPref.getString(TOKEN, null)
|
||||
return token != null
|
||||
}
|
||||
|
||||
fun saveToken(context: Context, token: String) {
|
||||
val sharedPref = context.getSharedPreferences(
|
||||
context.getString(R.string.preference_file_key),
|
||||
Context.MODE_PRIVATE
|
||||
)
|
||||
sharedPref.edit {
|
||||
putString(TOKEN, token)
|
||||
commit()
|
||||
}
|
||||
fun saveToken(token: String) {
|
||||
PrefManager.setVal(PrefName.DiscordToken, token)
|
||||
}
|
||||
|
||||
fun removeSavedToken(context: Context) {
|
||||
val sharedPref = context.getSharedPreferences(
|
||||
context.getString(R.string.preference_file_key),
|
||||
Context.MODE_PRIVATE
|
||||
)
|
||||
sharedPref.edit {
|
||||
remove(TOKEN)
|
||||
commit()
|
||||
}
|
||||
PrefManager.removeVal(PrefName.DiscordToken)
|
||||
|
||||
tryWith(true) {
|
||||
val dir = File(context.filesDir?.parentFile, "app_webview")
|
||||
@@ -60,17 +41,7 @@ object Discord {
|
||||
}
|
||||
}
|
||||
|
||||
private var rpc : RPC? = null
|
||||
suspend fun getUserData() = tryWithSuspend(true) {
|
||||
if(rpc==null) {
|
||||
val rpc = RPC(token!!, Dispatchers.IO).also { rpc = it }
|
||||
val user: User = rpc.getUserData()
|
||||
userid = user.username
|
||||
avatar = user.userAvatar()
|
||||
rpc.close()
|
||||
true
|
||||
} else true
|
||||
} ?: false
|
||||
private var rpc: RPC? = null
|
||||
|
||||
|
||||
fun warning(context: Context) = CustomBottomDialog().apply {
|
||||
@@ -97,16 +68,9 @@ object Discord {
|
||||
context.startActivity(intent)
|
||||
}
|
||||
|
||||
fun defaultRPC(): RPC? {
|
||||
return token?.let {
|
||||
RPC(it, Dispatchers.IO).apply {
|
||||
applicationId = "1163925779692912771"
|
||||
smallImage = RPC.Link(
|
||||
"Dantotsu",
|
||||
"mp:attachments/1163940221063278672/1163940262423298141/bitmap1024.png"
|
||||
)
|
||||
buttons.add(RPC.Link("Stream on Dantotsu", "https://github.com/rebelonion/Dantotsu/"))
|
||||
}
|
||||
}
|
||||
}
|
||||
const val application_Id = "1163925779692912771"
|
||||
const val small_Image: String =
|
||||
"mp:external/9NqpMxXs4ZNQtMG42L7hqINW92GqqDxgxS9Oh0Sp880/%3Fsize%3D48%26quality%3Dlossless%26name%3DDantotsu/https/cdn.discordapp.com/emojis/1167344924874784828.gif"
|
||||
const val small_Image_AniList: String =
|
||||
"https://anilist.co/img/icons/android-chrome-512x512.png"
|
||||
}
|
||||
@@ -0,0 +1,418 @@
|
||||
package ani.dantotsu.connections.discord
|
||||
|
||||
import android.Manifest
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.app.Service
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.os.IBinder
|
||||
import android.os.PowerManager
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import ani.dantotsu.MainActivity
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.connections.discord.serializers.Presence
|
||||
import ani.dantotsu.connections.discord.serializers.User
|
||||
import ani.dantotsu.isOnline
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.util.Logger
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonObject
|
||||
import com.google.gson.JsonParser
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import okhttp3.WebSocket
|
||||
import okhttp3.WebSocketListener
|
||||
import java.io.File
|
||||
|
||||
class DiscordService : Service() {
|
||||
private var heartbeat: Int = 0
|
||||
private var sequence: Int? = null
|
||||
private var sessionId: String = ""
|
||||
private var resume = false
|
||||
private lateinit var logFile: File
|
||||
private lateinit var webSocket: WebSocket
|
||||
private lateinit var heartbeatThread: Thread
|
||||
private lateinit var client: OkHttpClient
|
||||
private lateinit var wakeLock: PowerManager.WakeLock
|
||||
private val shouldLog = false
|
||||
var presenceStore = ""
|
||||
val json = Json {
|
||||
encodeDefaults = true
|
||||
allowStructuredMapKeys = true
|
||||
ignoreUnknownKeys = true
|
||||
coerceInputValues = true
|
||||
}
|
||||
var log = ""
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
log("Service onCreate()")
|
||||
val powerManager = baseContext.getSystemService(Context.POWER_SERVICE) as PowerManager
|
||||
wakeLock = powerManager.newWakeLock(
|
||||
PowerManager.PARTIAL_WAKE_LOCK,
|
||||
"discordRPC:backgroundPresence"
|
||||
)
|
||||
wakeLock.acquire(30 * 60 * 1000L /*30 minutes*/)
|
||||
log("WakeLock Acquired")
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val serviceChannel = NotificationChannel(
|
||||
"discordPresence",
|
||||
"Discord Presence Service Channel",
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
)
|
||||
val manager = getSystemService(NotificationManager::class.java)
|
||||
manager.createNotificationChannel(serviceChannel)
|
||||
}
|
||||
val intent = Intent(this, MainActivity::class.java).apply {
|
||||
action = Intent.ACTION_MAIN
|
||||
addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
}
|
||||
val pendingIntent =
|
||||
PendingIntent.getActivity(applicationContext, 0, intent, PendingIntent.FLAG_IMMUTABLE)
|
||||
val builder = NotificationCompat.Builder(this, "discordPresence")
|
||||
.setSmallIcon(R.mipmap.ic_launcher_round)
|
||||
.setContentTitle("Discord Presence")
|
||||
.setContentText("Running in the background")
|
||||
.setContentIntent(pendingIntent)
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
startForeground(1, builder.build())
|
||||
log("Foreground service started, notification shown")
|
||||
client = OkHttpClient()
|
||||
client.newWebSocket(
|
||||
Request.Builder().url("wss://gateway.discord.gg/?v=10&encoding=json").build(),
|
||||
DiscordWebSocketListener()
|
||||
)
|
||||
client.dispatcher.executorService.shutdown()
|
||||
SERVICE_RUNNING = true
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
log("Service onStartCommand()")
|
||||
if (intent != null) {
|
||||
if (intent.hasExtra("presence")) {
|
||||
log("Service onStartCommand() setPresence")
|
||||
val lPresence = intent.getStringExtra("presence")
|
||||
if (this::webSocket.isInitialized) webSocket.send(lPresence!!)
|
||||
presenceStore = lPresence!!
|
||||
} else {
|
||||
log("Service onStartCommand() no presence")
|
||||
DiscordServiceRunningSingleton.running = false
|
||||
//kill the client
|
||||
client = OkHttpClient()
|
||||
stopSelf()
|
||||
}
|
||||
}
|
||||
return START_REDELIVER_INTENT
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
log("Service Destroyed")
|
||||
if (DiscordServiceRunningSingleton.running) {
|
||||
log("Accidental Service Destruction, restarting service")
|
||||
val intent = Intent(baseContext, DiscordService::class.java)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
baseContext.startForegroundService(intent)
|
||||
} else {
|
||||
baseContext.startService(intent)
|
||||
}
|
||||
} else {
|
||||
if (this::webSocket.isInitialized)
|
||||
setPresence(
|
||||
json.encodeToString(
|
||||
Presence.Response(
|
||||
3,
|
||||
Presence(status = "offline")
|
||||
)
|
||||
)
|
||||
)
|
||||
wakeLock.release()
|
||||
}
|
||||
SERVICE_RUNNING = false
|
||||
client = OkHttpClient()
|
||||
if (this::webSocket.isInitialized) webSocket.close(1000, "Closed by user")
|
||||
super.onDestroy()
|
||||
//saveLogToFile()
|
||||
}
|
||||
|
||||
fun saveProfile(response: String) {
|
||||
val user = json.decodeFromString<User.Response>(response).d.user
|
||||
log("User data: $user")
|
||||
PrefManager.setVal(PrefName.DiscordUserName, user.username)
|
||||
PrefManager.setVal(PrefName.DiscordId, user.id)
|
||||
PrefManager.setVal(PrefName.DiscordAvatar, user.avatar)
|
||||
}
|
||||
|
||||
override fun onBind(p0: Intent?): IBinder? = null
|
||||
|
||||
inner class DiscordWebSocketListener : WebSocketListener() {
|
||||
|
||||
private var retryAttempts = 0
|
||||
private val maxRetryAttempts = 10
|
||||
override fun onOpen(webSocket: WebSocket, response: Response) {
|
||||
super.onOpen(webSocket, response)
|
||||
this@DiscordService.webSocket = webSocket
|
||||
log("WebSocket: Opened")
|
||||
}
|
||||
|
||||
override fun onMessage(webSocket: WebSocket, text: String) {
|
||||
super.onMessage(webSocket, text)
|
||||
val json = JsonParser.parseString(text).asJsonObject
|
||||
log("WebSocket: Received op code ${json.get("op")}")
|
||||
when (json.get("op").asInt) {
|
||||
0 -> {
|
||||
if (json.has("s")) {
|
||||
log("WebSocket: Sequence ${json.get("s")} Received")
|
||||
sequence = json.get("s").asInt
|
||||
}
|
||||
if (json.get("t").asString != "READY") return
|
||||
saveProfile(text)
|
||||
log(text)
|
||||
sessionId = json.get("d").asJsonObject.get("session_id").asString
|
||||
log("WebSocket: SessionID ${json.get("d").asJsonObject.get("session_id")} Received")
|
||||
if (presenceStore.isNotEmpty()) setPresence(presenceStore)
|
||||
sendBroadcast(Intent("ServiceToConnectButton"))
|
||||
}
|
||||
|
||||
1 -> {
|
||||
log("WebSocket: Received Heartbeat request, sending heartbeat")
|
||||
heartbeatThread.interrupt()
|
||||
heartbeatSend(webSocket, sequence)
|
||||
heartbeatThread = Thread(HeartbeatRunnable())
|
||||
heartbeatThread.start()
|
||||
}
|
||||
|
||||
7 -> {
|
||||
resume = true
|
||||
log("WebSocket: Requested to Restart, restarting")
|
||||
webSocket.close(1000, "Requested to Restart by the server")
|
||||
client = OkHttpClient()
|
||||
client.newWebSocket(
|
||||
Request.Builder().url("wss://gateway.discord.gg/?v=10&encoding=json")
|
||||
.build(),
|
||||
DiscordWebSocketListener()
|
||||
)
|
||||
client.dispatcher.executorService.shutdown()
|
||||
}
|
||||
|
||||
9 -> {
|
||||
log("WebSocket: Invalid Session, restarting")
|
||||
webSocket.close(1000, "Invalid Session")
|
||||
Thread.sleep(5000)
|
||||
client = OkHttpClient()
|
||||
client.newWebSocket(
|
||||
Request.Builder().url("wss://gateway.discord.gg/?v=10&encoding=json")
|
||||
.build(),
|
||||
DiscordWebSocketListener()
|
||||
)
|
||||
client.dispatcher.executorService.shutdown()
|
||||
}
|
||||
|
||||
10 -> {
|
||||
heartbeat = json.get("d").asJsonObject.get("heartbeat_interval").asInt
|
||||
heartbeatThread = Thread(HeartbeatRunnable())
|
||||
heartbeatThread.start()
|
||||
if (resume) {
|
||||
log("WebSocket: Resuming because server requested")
|
||||
resume()
|
||||
resume = false
|
||||
} else {
|
||||
identify(webSocket)
|
||||
log("WebSocket: Identified")
|
||||
}
|
||||
}
|
||||
|
||||
11 -> {
|
||||
log("WebSocket: Heartbeat ACKed")
|
||||
heartbeatThread = Thread(HeartbeatRunnable())
|
||||
heartbeatThread.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun identify(webSocket: WebSocket) {
|
||||
val properties = JsonObject()
|
||||
properties.addProperty("os", "linux")
|
||||
properties.addProperty("browser", "unknown")
|
||||
properties.addProperty("device", "unknown")
|
||||
val d = JsonObject()
|
||||
d.addProperty("token", getToken())
|
||||
d.addProperty("intents", 0)
|
||||
d.add("properties", properties)
|
||||
val payload = JsonObject()
|
||||
payload.addProperty("op", 2)
|
||||
payload.add("d", d)
|
||||
webSocket.send(payload.toString())
|
||||
}
|
||||
|
||||
override fun onFailure(webSocket: WebSocket, t: Throwable, response: Response?) {
|
||||
super.onFailure(webSocket, t, response)
|
||||
if (!isOnline(baseContext)) {
|
||||
log("WebSocket: Error, onFailure() reason: No Internet")
|
||||
errorNotification("Could not set the presence", "No Internet")
|
||||
return
|
||||
} else {
|
||||
retryAttempts++
|
||||
if (retryAttempts >= maxRetryAttempts) {
|
||||
log("WebSocket: Error, onFailure() reason: Max Retry Attempts")
|
||||
errorNotification("Timeout setting presence", "Max Retry Attempts")
|
||||
return
|
||||
}
|
||||
}
|
||||
t.message?.let { Logger.log("onFailure() $it") }
|
||||
log("WebSocket: Error, onFailure() reason: ${t.message}")
|
||||
client = OkHttpClient()
|
||||
client.newWebSocket(
|
||||
Request.Builder().url("wss://gateway.discord.gg/?v=10&encoding=json").build(),
|
||||
DiscordWebSocketListener()
|
||||
)
|
||||
client.dispatcher.executorService.shutdown()
|
||||
if (::heartbeatThread.isInitialized && !heartbeatThread.isInterrupted) {
|
||||
heartbeatThread.interrupt()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClosing(webSocket: WebSocket, code: Int, reason: String) {
|
||||
super.onClosing(webSocket, code, reason)
|
||||
Logger.log("onClosing() $code $reason")
|
||||
if (::heartbeatThread.isInitialized && !heartbeatThread.isInterrupted) {
|
||||
heartbeatThread.interrupt()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClosed(webSocket: WebSocket, code: Int, reason: String) {
|
||||
super.onClosed(webSocket, code, reason)
|
||||
Logger.log("onClosed() $code $reason")
|
||||
if (code >= 4000) {
|
||||
log("WebSocket: Error, code: $code reason: $reason")
|
||||
client = OkHttpClient()
|
||||
client.newWebSocket(
|
||||
Request.Builder().url("wss://gateway.discord.gg/?v=10&encoding=json").build(),
|
||||
DiscordWebSocketListener()
|
||||
)
|
||||
client.dispatcher.executorService.shutdown()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getToken(): String {
|
||||
val token = PrefManager.getVal(PrefName.DiscordToken, null as String?)
|
||||
return if (token == null) {
|
||||
log("WebSocket: Token not found")
|
||||
errorNotification("Could not set the presence", "token not found")
|
||||
""
|
||||
} else {
|
||||
token
|
||||
}
|
||||
}
|
||||
|
||||
fun heartbeatSend(webSocket: WebSocket, seq: Int?) {
|
||||
val json = JsonObject()
|
||||
json.addProperty("op", 1)
|
||||
json.addProperty("d", seq)
|
||||
webSocket.send(json.toString())
|
||||
}
|
||||
|
||||
private fun errorNotification(title: String, text: String) {
|
||||
val intent = Intent(this@DiscordService, MainActivity::class.java).apply {
|
||||
action = Intent.ACTION_MAIN
|
||||
addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
}
|
||||
val pendingIntent =
|
||||
PendingIntent.getActivity(applicationContext, 0, intent, PendingIntent.FLAG_IMMUTABLE)
|
||||
val builder = NotificationCompat.Builder(this@DiscordService, "discordPresence")
|
||||
.setSmallIcon(R.mipmap.ic_launcher_round)
|
||||
.setContentTitle(title)
|
||||
.setContentText(text)
|
||||
.setContentIntent(pendingIntent)
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
val notificationManager = NotificationManagerCompat.from(applicationContext)
|
||||
if (ActivityCompat.checkSelfPermission(
|
||||
this,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
) != PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
return
|
||||
}
|
||||
notificationManager.notify(2, builder.build())
|
||||
log("Error Notified")
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
fun saveSimpleTestPresence() {
|
||||
val file = File(baseContext.cacheDir, "payload")
|
||||
//fill with test payload
|
||||
val payload = JsonObject()
|
||||
payload.addProperty("op", 3)
|
||||
payload.add("d", JsonObject().apply {
|
||||
addProperty("status", "online")
|
||||
addProperty("afk", false)
|
||||
add("activities", JsonArray().apply {
|
||||
add(JsonObject().apply {
|
||||
addProperty("name", "Test")
|
||||
addProperty("type", 0)
|
||||
})
|
||||
})
|
||||
})
|
||||
file.writeText(payload.toString())
|
||||
log("WebSocket: Simple Test Presence Saved")
|
||||
}
|
||||
|
||||
fun setPresence(string: String) {
|
||||
log("WebSocket: Sending Presence payload")
|
||||
log(string)
|
||||
webSocket.send(string)
|
||||
}
|
||||
|
||||
fun log(string: String) {
|
||||
if (shouldLog) {
|
||||
Logger.log(string)
|
||||
}
|
||||
}
|
||||
|
||||
fun resume() {
|
||||
log("Sending Resume payload")
|
||||
val d = JsonObject()
|
||||
d.addProperty("token", getToken())
|
||||
d.addProperty("session_id", sessionId)
|
||||
d.addProperty("seq", sequence)
|
||||
val json = JsonObject()
|
||||
json.addProperty("op", 6)
|
||||
json.add("d", d)
|
||||
log(json.toString())
|
||||
webSocket.send(json.toString())
|
||||
}
|
||||
|
||||
inner class HeartbeatRunnable : Runnable {
|
||||
override fun run() {
|
||||
try {
|
||||
Thread.sleep(heartbeat.toLong())
|
||||
heartbeatSend(webSocket, sequence)
|
||||
log("WebSocket: Heartbeat Sent")
|
||||
} catch (ignored: InterruptedException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
var SERVICE_RUNNING = false
|
||||
}
|
||||
}
|
||||
|
||||
object DiscordServiceRunningSingleton {
|
||||
var running = false
|
||||
|
||||
}
|
||||
@@ -1,50 +1,81 @@
|
||||
package ani.dantotsu.connections.discord
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Application.getProcessName
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.webkit.WebResourceRequest
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.connections.discord.Discord.saveToken
|
||||
import ani.dantotsu.startMainActivity
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
|
||||
class Login : AppCompatActivity() {
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
ThemeManager(this).applyTheme()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
val process = getProcessName()
|
||||
if (packageName != process) WebView.setDataDirectorySuffix(process)
|
||||
}
|
||||
setContentView(R.layout.activity_discord)
|
||||
|
||||
val webView = findViewById<WebView>(R.id.discordWebview)
|
||||
|
||||
webView.apply {
|
||||
settings.javaScriptEnabled = true
|
||||
settings.databaseEnabled = true
|
||||
settings.domStorageEnabled = true
|
||||
}
|
||||
|
||||
WebView.setWebContentsDebuggingEnabled(true)
|
||||
webView.webViewClient = object : WebViewClient() {
|
||||
override fun onPageFinished(view: WebView?, url: String?) {
|
||||
if (url != null && url.endsWith("/app")) {
|
||||
webView.stopLoading()
|
||||
webView.evaluateJavascript("""
|
||||
(function() {
|
||||
const wreq = webpackChunkdiscord_app.push([[Symbol()], {}, w => w])
|
||||
webpackChunkdiscord_app.pop()
|
||||
const token = Object.values(wreq.c).find(m => m.exports?.Z?.getToken).exports.Z.getToken();
|
||||
return token;
|
||||
})()
|
||||
""".trimIndent()){
|
||||
login(it.trim('"'))
|
||||
}
|
||||
override fun shouldOverrideUrlLoading(
|
||||
view: WebView?,
|
||||
request: WebResourceRequest?
|
||||
): Boolean {
|
||||
// Check if the URL is the one expected after a successful login
|
||||
if (request?.url.toString() != "https://discord.com/login") {
|
||||
// Delay the script execution to ensure the page is fully loaded
|
||||
view?.postDelayed({
|
||||
view.evaluateJavascript(
|
||||
"""
|
||||
(function() {
|
||||
const m = []; webpackChunkdiscord_app.push([[""], {}, e => {for (let c in e.c)m.push(e.c[c])}]);
|
||||
return m.find(n => n?.exports?.default?.getToken !== void 0)?.exports?.default?.getToken();
|
||||
})()
|
||||
""".trimIndent()
|
||||
) { result ->
|
||||
login(result.trim('"'))
|
||||
}
|
||||
}, 2000)
|
||||
}
|
||||
return super.shouldOverrideUrlLoading(view, request)
|
||||
}
|
||||
|
||||
override fun onPageFinished(view: WebView?, url: String?) {
|
||||
super.onPageFinished(view, url)
|
||||
}
|
||||
}
|
||||
|
||||
webView.loadUrl("https://discord.com/login")
|
||||
}
|
||||
|
||||
private fun login(token: String) {
|
||||
if (token.isEmpty() || token == "null") {
|
||||
Toast.makeText(this, "Failed to retrieve token", Toast.LENGTH_SHORT).show()
|
||||
finish()
|
||||
return
|
||||
}
|
||||
Toast.makeText(this, "Logged in successfully", Toast.LENGTH_SHORT).show()
|
||||
finish()
|
||||
saveToken(this, token)
|
||||
saveToken(token)
|
||||
startMainActivity(this@Login)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,235 +1,85 @@
|
||||
package ani.dantotsu.connections.discord
|
||||
|
||||
import ani.dantotsu.connections.discord.serializers.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Deferred
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.serialization.Serializable
|
||||
import ani.dantotsu.connections.discord.Discord.token
|
||||
import ani.dantotsu.connections.discord.serializers.Activity
|
||||
import ani.dantotsu.connections.discord.serializers.Presence
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import kotlinx.serialization.json.long
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import okhttp3.WebSocket
|
||||
import okhttp3.WebSocketListener
|
||||
import java.util.concurrent.TimeUnit.*
|
||||
import java.util.concurrent.TimeUnit.SECONDS
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import ani.dantotsu.client as app
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
open class RPC(val token: String, val coroutineContext: CoroutineContext) {
|
||||
|
||||
private val json = Json {
|
||||
encodeDefaults = true
|
||||
allowStructuredMapKeys = true
|
||||
ignoreUnknownKeys = true
|
||||
}
|
||||
|
||||
private val client = OkHttpClient.Builder()
|
||||
.connectTimeout(10, SECONDS)
|
||||
.readTimeout(10, SECONDS)
|
||||
.writeTimeout(10, SECONDS)
|
||||
.build()
|
||||
|
||||
private val request = Request.Builder()
|
||||
.url("wss://gateway.discord.gg/?encoding=json&v=10")
|
||||
.build()
|
||||
|
||||
private var webSocket = client.newWebSocket(request, Listener())
|
||||
|
||||
var applicationId: String? = null
|
||||
var type: Type? = null
|
||||
var activityName: String? = null
|
||||
var details: String? = null
|
||||
var state: String? = null
|
||||
var largeImage: Link? = null
|
||||
var smallImage: Link? = null
|
||||
var status: String? = null
|
||||
var startTimestamp: Long? = null
|
||||
var stopTimestamp: Long? = null
|
||||
|
||||
enum class Type {
|
||||
PLAYING, STREAMING, LISTENING, WATCHING, COMPETING
|
||||
}
|
||||
|
||||
var buttons = mutableListOf<Link>()
|
||||
|
||||
data class Link(val label: String, val url: String)
|
||||
|
||||
private suspend fun createPresence(): String {
|
||||
return json.encodeToString(Presence.Response(
|
||||
3,
|
||||
Presence(
|
||||
activities = listOf(
|
||||
Activity(
|
||||
name = activityName,
|
||||
state = state,
|
||||
details = details,
|
||||
type = type?.ordinal,
|
||||
timestamps = if (startTimestamp != null)
|
||||
Activity.Timestamps(startTimestamp, stopTimestamp)
|
||||
else null,
|
||||
assets = Activity.Assets(
|
||||
largeImage = largeImage?.url?.discordUrl(),
|
||||
largeText = largeImage?.label,
|
||||
smallImage = smallImage?.url?.discordUrl(),
|
||||
smallText = smallImage?.label
|
||||
),
|
||||
buttons = buttons.map { it.label },
|
||||
metadata = Activity.Metadata(
|
||||
buttonUrls = buttons.map { it.url }
|
||||
),
|
||||
applicationId = applicationId,
|
||||
)
|
||||
),
|
||||
afk = true,
|
||||
since = startTimestamp,
|
||||
status = status
|
||||
)
|
||||
))
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class KizzyApi(val id: String)
|
||||
val api = "https://kizzy-api.vercel.app/image?url="
|
||||
private suspend fun String.discordUrl(): String? {
|
||||
if (startsWith("mp:")) return this
|
||||
val json = app.get("$api$this").parsedSafe<KizzyApi>()
|
||||
return json?.id
|
||||
}
|
||||
|
||||
private fun sendIdentify() {
|
||||
val response = Identity.Response(
|
||||
op = 2,
|
||||
d = Identity(
|
||||
token = token,
|
||||
properties = Identity.Properties(
|
||||
os = "windows",
|
||||
browser = "Chrome",
|
||||
device = "disco"
|
||||
),
|
||||
compress = false,
|
||||
intents = 0
|
||||
)
|
||||
companion object {
|
||||
data class RPCData(
|
||||
val applicationId: String,
|
||||
val type: Type? = null,
|
||||
val activityName: String? = null,
|
||||
val details: String? = null,
|
||||
val state: String? = null,
|
||||
val largeImage: Link? = null,
|
||||
val smallImage: Link? = null,
|
||||
val status: String? = null,
|
||||
val startTimestamp: Long? = null,
|
||||
val stopTimestamp: Long? = null,
|
||||
val buttons: MutableList<Link> = mutableListOf()
|
||||
)
|
||||
webSocket.send(json.encodeToString(response))
|
||||
}
|
||||
|
||||
fun send(block: RPC.() -> Unit) {
|
||||
block.invoke(this)
|
||||
send()
|
||||
}
|
||||
|
||||
var started = false
|
||||
var whenStarted: ((User) -> Unit)? = null
|
||||
|
||||
fun send() {
|
||||
val send = {
|
||||
CoroutineScope(coroutineContext).launch {
|
||||
webSocket.send(createPresence())
|
||||
suspend fun createPresence(data: RPCData): String {
|
||||
val json = Json {
|
||||
encodeDefaults = true
|
||||
allowStructuredMapKeys = true
|
||||
ignoreUnknownKeys = true
|
||||
}
|
||||
}
|
||||
if (!started) whenStarted = {
|
||||
send.invoke()
|
||||
whenStarted = null
|
||||
}
|
||||
else send.invoke()
|
||||
}
|
||||
val client = OkHttpClient.Builder()
|
||||
.connectTimeout(10, SECONDS)
|
||||
.readTimeout(10, SECONDS)
|
||||
.writeTimeout(10, SECONDS)
|
||||
.build()
|
||||
|
||||
fun close() {
|
||||
webSocket.send(
|
||||
json.encodeToString(
|
||||
Presence.Response(
|
||||
3,
|
||||
Presence(status = "offline")
|
||||
val assetApi = RPCExternalAsset(data.applicationId, token!!, client, json)
|
||||
suspend fun String.discordUrl() = assetApi.getDiscordUri(this)
|
||||
|
||||
return json.encodeToString(Presence.Response(
|
||||
3,
|
||||
Presence(
|
||||
activities = listOf(
|
||||
Activity(
|
||||
name = data.activityName,
|
||||
state = data.state,
|
||||
details = data.details,
|
||||
type = data.type?.ordinal,
|
||||
timestamps = if (data.startTimestamp != null)
|
||||
Activity.Timestamps(data.startTimestamp, data.stopTimestamp)
|
||||
else null,
|
||||
assets = Activity.Assets(
|
||||
largeImage = data.largeImage?.url?.discordUrl(),
|
||||
largeText = data.largeImage?.label,
|
||||
smallImage = if (PrefManager.getVal(PrefName.ShowAniListIcon)) Discord.small_Image_AniList.discordUrl() else Discord.small_Image.discordUrl(),
|
||||
smallText = if (PrefManager.getVal(PrefName.ShowAniListIcon)) "Anilist" else "Dantotsu",
|
||||
),
|
||||
buttons = data.buttons.map { it.label },
|
||||
metadata = Activity.Metadata(
|
||||
buttonUrls = data.buttons.map { it.url }
|
||||
),
|
||||
applicationId = data.applicationId,
|
||||
)
|
||||
),
|
||||
afk = true,
|
||||
since = data.startTimestamp,
|
||||
status = PrefManager.getVal(PrefName.DiscordStatus)
|
||||
)
|
||||
)
|
||||
)
|
||||
webSocket.close(4000, "Interrupt")
|
||||
}
|
||||
|
||||
//I hate this, but couldn't find any better way to solve it
|
||||
suspend fun getUserData(): User {
|
||||
var user : User? = null
|
||||
whenStarted = {
|
||||
user = it
|
||||
whenStarted = null
|
||||
}
|
||||
while (user == null) {
|
||||
delay(100)
|
||||
}
|
||||
return user!!
|
||||
}
|
||||
|
||||
var onReceiveUserData: ((User) -> Deferred<Unit>)? = null
|
||||
|
||||
inner class Listener : WebSocketListener() {
|
||||
private var seq: Int? = null
|
||||
private var heartbeatInterval: Long? = null
|
||||
|
||||
var scope = CoroutineScope(coroutineContext)
|
||||
|
||||
private fun sendHeartBeat() {
|
||||
scope.cancel()
|
||||
scope = CoroutineScope(coroutineContext)
|
||||
scope.launch {
|
||||
delay(heartbeatInterval!!)
|
||||
webSocket.send("{\"op\":1, \"d\":$seq}")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMessage(webSocket: WebSocket, text: String) {
|
||||
println("Message : $text")
|
||||
|
||||
val map = json.decodeFromString<Res>(text)
|
||||
seq = map.s
|
||||
|
||||
when (map.op) {
|
||||
10 -> {
|
||||
map.d as JsonObject
|
||||
heartbeatInterval = map.d["heartbeat_interval"]!!.jsonPrimitive.long
|
||||
sendHeartBeat()
|
||||
sendIdentify()
|
||||
}
|
||||
|
||||
0 -> if (map.t == "READY") {
|
||||
val user = json.decodeFromString<User.Response>(text).d.user
|
||||
started = true
|
||||
whenStarted?.invoke(user)
|
||||
}
|
||||
|
||||
1 -> {
|
||||
if (scope.isActive) scope.cancel()
|
||||
webSocket.send("{\"op\":1, \"d\":$seq}")
|
||||
}
|
||||
|
||||
11 -> sendHeartBeat()
|
||||
7 -> webSocket.close(400, "Reconnect")
|
||||
9 -> {
|
||||
sendHeartBeat()
|
||||
sendIdentify()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClosed(webSocket: WebSocket, code: Int, reason: String) {
|
||||
println("Server Closed : $code $reason")
|
||||
if (code == 4000) {
|
||||
scope.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(webSocket: WebSocket, t: Throwable, response: Response?) {
|
||||
println("Failure : ${t.message}")
|
||||
if (t.message != "Interrupt") {
|
||||
this@RPC.webSocket = client.newWebSocket(request, Listener())
|
||||
}
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
// this code was kanged from the greatest mind of this era, aka shivam brahmkshatriya
|
||||
// please subscribe to my only fans here: https://github.com/brahmkshatriya
|
||||
package ani.dantotsu.connections.discord
|
||||
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.Call
|
||||
import okhttp3.Callback
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import okhttp3.Response
|
||||
import okio.IOException
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.coroutines.resumeWithException
|
||||
import kotlin.coroutines.suspendCoroutine
|
||||
|
||||
class RPCExternalAsset(
|
||||
applicationId: String,
|
||||
private val token: String,
|
||||
private val client: OkHttpClient,
|
||||
private val json: Json
|
||||
) {
|
||||
|
||||
@Serializable
|
||||
data class ExternalAsset(
|
||||
val url: String? = null,
|
||||
@SerialName("external_asset_path")
|
||||
val externalAssetPath: String? = null
|
||||
)
|
||||
|
||||
private val api = "https://discord.com/api/v9/applications/$applicationId/external-assets"
|
||||
suspend fun getDiscordUri(imageUrl: String): String? {
|
||||
if (imageUrl.startsWith("mp:")) return imageUrl
|
||||
val request = Request.Builder().url(api).header("Authorization", token)
|
||||
.post("{\"urls\":[\"$imageUrl\"]}".toRequestBody("application/json".toMediaType()))
|
||||
.build()
|
||||
return runCatching {
|
||||
val res = client.newCall(request).await()
|
||||
json.decodeFromString<List<ExternalAsset>>(res.body.string())
|
||||
.firstOrNull()?.externalAssetPath?.let { "mp:$it" }
|
||||
}.getOrNull()
|
||||
}
|
||||
|
||||
private suspend inline fun Call.await(): Response {
|
||||
return suspendCoroutine {
|
||||
enqueue(object : Callback {
|
||||
override fun onFailure(call: Call, e: IOException) {
|
||||
it.resumeWithException(e)
|
||||
}
|
||||
|
||||
override fun onResponse(call: Call, response: Response) {
|
||||
it.resume(response)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,9 @@ package ani.dantotsu.connections.discord.serializers
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Activity (
|
||||
data class Activity(
|
||||
@SerialName("application_id")
|
||||
val applicationId: String? = null,
|
||||
val name: String? = null,
|
||||
@@ -39,6 +40,7 @@ data class Activity (
|
||||
@Serializable
|
||||
data class Timestamps(
|
||||
val start: Long? = null,
|
||||
@SerialName("end")
|
||||
val stop: Long? = null
|
||||
)
|
||||
}
|
||||
@@ -12,13 +12,13 @@ data class Identity(
|
||||
) {
|
||||
|
||||
@Serializable
|
||||
data class Response (
|
||||
data class Response(
|
||||
val op: Long,
|
||||
val d: Identity
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Properties (
|
||||
data class Properties(
|
||||
@SerialName("\$os")
|
||||
val os: String,
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@ package ani.dantotsu.connections.discord.serializers
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Presence (
|
||||
data class Presence(
|
||||
val activities: List<Activity> = listOf(),
|
||||
val afk: Boolean = true,
|
||||
val since: Long? = null,
|
||||
val status: String? = null
|
||||
){
|
||||
) {
|
||||
@Serializable
|
||||
data class Response (
|
||||
data class Response(
|
||||
val op: Long,
|
||||
val d: Presence
|
||||
)
|
||||
|
||||
@@ -1,60 +1,60 @@
|
||||
package ani.dantotsu.connections.discord.serializers
|
||||
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.*
|
||||
import kotlinx.serialization.encoding.*
|
||||
import kotlinx.serialization.json.*
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
|
||||
|
||||
@Serializable
|
||||
data class User (
|
||||
val verified: Boolean,
|
||||
data class User(
|
||||
val verified: Boolean? = null,
|
||||
val username: String,
|
||||
|
||||
@SerialName("purchased_flags")
|
||||
val purchasedFlags: Long,
|
||||
val purchasedFlags: Long? = null,
|
||||
|
||||
@SerialName("public_flags")
|
||||
val publicFlags: Long,
|
||||
val publicFlags: Long? = null,
|
||||
|
||||
val pronouns: String,
|
||||
val pronouns: String? = null,
|
||||
|
||||
@SerialName("premium_type")
|
||||
val premiumType: Long,
|
||||
val premiumType: Long? = null,
|
||||
|
||||
val premium: Boolean,
|
||||
val phone: String,
|
||||
val premium: Boolean? = null,
|
||||
val phone: String? = null,
|
||||
|
||||
@SerialName("nsfw_allowed")
|
||||
val nsfwAllowed: Boolean,
|
||||
val nsfwAllowed: Boolean? = null,
|
||||
|
||||
val mobile: Boolean,
|
||||
val mobile: Boolean? = null,
|
||||
|
||||
@SerialName("mfa_enabled")
|
||||
val mfaEnabled: Boolean,
|
||||
val mfaEnabled: Boolean? = null,
|
||||
|
||||
val id: String,
|
||||
|
||||
@SerialName("global_name")
|
||||
val globalName: String,
|
||||
val globalName: String? = null,
|
||||
|
||||
val flags: Long,
|
||||
val email: String,
|
||||
val discriminator: String,
|
||||
val desktop: Boolean,
|
||||
val bio: String,
|
||||
val flags: Long? = null,
|
||||
val email: String? = null,
|
||||
val discriminator: String? = null,
|
||||
val desktop: Boolean? = null,
|
||||
val bio: String? = null,
|
||||
|
||||
@SerialName("banner_color")
|
||||
val bannerColor: String,
|
||||
val bannerColor: String? = null,
|
||||
|
||||
val banner: JsonElement? = null,
|
||||
|
||||
@SerialName("avatar_decoration")
|
||||
val avatarDecoration: JsonElement? = null,
|
||||
|
||||
val avatar: String,
|
||||
val avatar: String? = null,
|
||||
|
||||
@SerialName("accent_color")
|
||||
val accentColor: Long
|
||||
val accentColor: Long? = null
|
||||
) {
|
||||
@Serializable
|
||||
data class Response(
|
||||
@@ -70,7 +70,7 @@ data class User (
|
||||
)
|
||||
}
|
||||
|
||||
fun userAvatar():String{
|
||||
fun userAvatar(): String {
|
||||
return "https://cdn.discordapp.com/avatars/$id/$avatar.png"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package ani.dantotsu.connections.github
|
||||
|
||||
import ani.dantotsu.Mapper
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.client
|
||||
import ani.dantotsu.getAppString
|
||||
import ani.dantotsu.settings.Developer
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonArray
|
||||
import kotlinx.serialization.json.decodeFromJsonElement
|
||||
|
||||
class Contributors {
|
||||
|
||||
fun getContributors(): Array<Developer> {
|
||||
var developers = arrayOf<Developer>()
|
||||
runBlocking(Dispatchers.IO) {
|
||||
val repo = getAppString(R.string.repo)
|
||||
val res = client.get("https://api.github.com/repos/$repo/contributors")
|
||||
.parsed<JsonArray>().map {
|
||||
Mapper.json.decodeFromJsonElement<GithubResponse>(it)
|
||||
}
|
||||
res.forEach {
|
||||
if (it.login == "SunglassJerry") return@forEach
|
||||
val role = when (it.login) {
|
||||
"rebelonion" -> "Owner & Maintainer"
|
||||
"sneazy-ibo" -> "Contributor & Comment Moderator"
|
||||
"WaiWhat" -> "Icon Designer"
|
||||
"itsmechinmoy" -> "Discord and Telegram Admin/Helper, Comment Moderator & Translator"
|
||||
else -> "Contributor"
|
||||
}
|
||||
developers = developers.plus(
|
||||
Developer(
|
||||
it.login,
|
||||
it.avatarUrl,
|
||||
role,
|
||||
it.htmlUrl
|
||||
)
|
||||
)
|
||||
}
|
||||
developers = developers.plus(
|
||||
arrayOf(
|
||||
Developer(
|
||||
"MarshMeadow",
|
||||
"https://avatars.githubusercontent.com/u/88599122?v=4",
|
||||
"Beta Icon Designer & Website Maintainer",
|
||||
"https://github.com/MarshMeadow?tab=repositories"
|
||||
),
|
||||
Developer(
|
||||
"Zaxx69",
|
||||
"https://s4.anilist.co/file/anilistcdn/user/avatar/large/b6342562-kxE8m4i7KUMK.png",
|
||||
"Telegram Admin",
|
||||
"https://anilist.co/user/6342562"
|
||||
),
|
||||
Developer(
|
||||
"Arif Alam",
|
||||
"https://s4.anilist.co/file/anilistcdn/user/avatar/large/b6011177-2n994qtayiR9.jpg",
|
||||
"Discord & Comment Moderator",
|
||||
"https://anilist.co/user/6011177"
|
||||
),
|
||||
Developer(
|
||||
"SunglassJeery",
|
||||
"https://s4.anilist.co/file/anilistcdn/user/avatar/large/b5804776-FEKfP5wbz2xv.png",
|
||||
"Head Discord & Comment Moderator",
|
||||
"https://anilist.co/user/5804776"
|
||||
),
|
||||
Developer(
|
||||
"Excited",
|
||||
"https://s4.anilist.co/file/anilistcdn/user/avatar/large/b6131921-toSoGWmKbRA1.png",
|
||||
"Comment Moderator",
|
||||
"https://anilist.co/user/6131921"
|
||||
),
|
||||
Developer(
|
||||
"Gurjshan",
|
||||
"https://s4.anilist.co/file/anilistcdn/user/avatar/large/b6363228-rWQ3Pl3WuxzL.png",
|
||||
"Comment Moderator",
|
||||
"https://anilist.co/user/6363228"
|
||||
),
|
||||
Developer(
|
||||
"NekoMimi",
|
||||
"https://s4.anilist.co/file/anilistcdn/user/avatar/large/b6244220-HOpImMGMQAxW.jpg",
|
||||
"Comment Moderator",
|
||||
"https://anilist.co/user/6244220"
|
||||
),
|
||||
Developer(
|
||||
"Ziadsenior",
|
||||
"https://s4.anilist.co/file/anilistcdn/user/avatar/large/b6049773-8cjYeUOFUguv.jpg",
|
||||
"Comment Moderator and Arabic Translator",
|
||||
"https://anilist.co/user/6049773"
|
||||
),
|
||||
Developer(
|
||||
"Dawnusedyeet",
|
||||
"https://s4.anilist.co/file/anilistcdn/user/avatar/large/b6237399-RHFvRHriXjwS.png",
|
||||
"Contributor",
|
||||
"https://anilist.co/user/Dawnusedyeet/"
|
||||
),
|
||||
Developer(
|
||||
"hastsu",
|
||||
"https://s4.anilist.co/file/anilistcdn/user/avatar/large/b6183359-9os7zUhYdF64.jpg",
|
||||
"Comment Moderator and Arabic Translator",
|
||||
"https://anilist.co/user/6183359"
|
||||
),
|
||||
)
|
||||
)
|
||||
}
|
||||
return developers
|
||||
}
|
||||
|
||||
|
||||
@Serializable
|
||||
data class GithubResponse(
|
||||
@SerialName("login")
|
||||
val login: String,
|
||||
@SerialName("avatar_url")
|
||||
val avatarUrl: String,
|
||||
@SerialName("html_url")
|
||||
val htmlUrl: String
|
||||
)
|
||||
}
|
||||
@@ -4,19 +4,29 @@ import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import ani.dantotsu.*
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.client
|
||||
import ani.dantotsu.connections.mal.MAL.clientId
|
||||
import ani.dantotsu.connections.mal.MAL.saveResponse
|
||||
import ani.dantotsu.logError
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.startMainActivity
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.tryWithSuspend
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class Login : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
ThemeManager(this).applyTheme()
|
||||
try {
|
||||
val data: Uri = intent?.data
|
||||
?: throw Exception(getString(R.string.mal_login_uri_not_found))
|
||||
val codeChallenge: String = loadData("malCodeChallenge", this)
|
||||
val codeChallenge = PrefManager.getVal(PrefName.MALCodeChallenge, null as String?)
|
||||
?: throw Exception(getString(R.string.mal_login_code_challenge_not_found))
|
||||
val code = data.getQueryParameter("code")
|
||||
?: throw Exception(getString(R.string.mal_login_code_not_present))
|
||||
@@ -42,9 +52,8 @@ class Login : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e:Exception){
|
||||
logError(e,snackbar = false)
|
||||
} catch (e: Exception) {
|
||||
logError(e, snackbar = false)
|
||||
startMainActivity(this)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,15 @@ import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.util.Base64
|
||||
import androidx.browser.customtabs.CustomTabsIntent
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import ani.dantotsu.*
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.client
|
||||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.openLinkInBrowser
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.tryWithSuspend
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import java.io.File
|
||||
import java.security.SecureRandom
|
||||
|
||||
object MAL {
|
||||
@@ -28,7 +32,7 @@ object MAL {
|
||||
.replace("/", "_")
|
||||
.replace("\n", "")
|
||||
|
||||
saveData("malCodeChallenge", codeChallenge, context)
|
||||
PrefManager.setVal(PrefName.MALCodeChallenge, codeChallenge)
|
||||
val request =
|
||||
"https://myanimelist.net/v1/oauth2/authorize?response_type=code&client_id=$clientId&code_challenge=$codeChallenge"
|
||||
try {
|
||||
@@ -41,11 +45,9 @@ object MAL {
|
||||
}
|
||||
}
|
||||
|
||||
private const val MAL_TOKEN = "malToken"
|
||||
|
||||
private suspend fun refreshToken(): ResponseToken? {
|
||||
return tryWithSuspend {
|
||||
val token = loadData<ResponseToken>(MAL_TOKEN)
|
||||
val token = PrefManager.getNullableVal<ResponseToken>(PrefName.MALToken, null)
|
||||
?: throw Exception(currContext()?.getString(R.string.refresh_token_load_failed))
|
||||
val res = client.post(
|
||||
"https://myanimelist.net/v1/oauth2/token",
|
||||
@@ -61,10 +63,11 @@ object MAL {
|
||||
}
|
||||
|
||||
|
||||
suspend fun getSavedToken(context: FragmentActivity): Boolean {
|
||||
suspend fun getSavedToken(): Boolean {
|
||||
return tryWithSuspend(false) {
|
||||
var res: ResponseToken = loadData(MAL_TOKEN, context)
|
||||
?: return@tryWithSuspend false
|
||||
var res: ResponseToken =
|
||||
PrefManager.getNullableVal<ResponseToken>(PrefName.MALToken, null)
|
||||
?: return@tryWithSuspend false
|
||||
if (System.currentTimeMillis() > res.expiresIn)
|
||||
res = refreshToken()
|
||||
?: throw Exception(currContext()?.getString(R.string.refreshing_token_failed))
|
||||
@@ -73,19 +76,17 @@ object MAL {
|
||||
} ?: false
|
||||
}
|
||||
|
||||
fun removeSavedToken(context: Context) {
|
||||
fun removeSavedToken() {
|
||||
token = null
|
||||
username = null
|
||||
userid = null
|
||||
avatar = null
|
||||
if (MAL_TOKEN in context.fileList()) {
|
||||
File(context.filesDir, MAL_TOKEN).delete()
|
||||
}
|
||||
PrefManager.removeVal(PrefName.MALToken)
|
||||
}
|
||||
|
||||
fun saveResponse(res: ResponseToken) {
|
||||
res.expiresIn += System.currentTimeMillis()
|
||||
saveData(MAL_TOKEN, res)
|
||||
PrefManager.setVal(PrefName.MALToken, res)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@@ -94,6 +95,10 @@ object MAL {
|
||||
@SerialName("expires_in") var expiresIn: Long,
|
||||
@SerialName("access_token") val accessToken: String,
|
||||
@SerialName("refresh_token") val refreshToken: String,
|
||||
): java.io.Serializable
|
||||
) : java.io.Serializable {
|
||||
companion object {
|
||||
private const val serialVersionUID = 1L
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package ani.dantotsu.connections.mal
|
||||
|
||||
import ani.dantotsu.connections.anilist.api.FuzzyDate
|
||||
import ani.dantotsu.client
|
||||
import ani.dantotsu.connections.anilist.api.FuzzyDate
|
||||
import ani.dantotsu.tryWithSuspend
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@@ -43,18 +43,18 @@ class MALQueries {
|
||||
start: FuzzyDate? = null,
|
||||
end: FuzzyDate? = null
|
||||
) {
|
||||
if(idMAL==null) return
|
||||
if (idMAL == null) return
|
||||
val data = mutableMapOf("status" to convertStatus(isAnime, status))
|
||||
if (progress != null)
|
||||
data[if (isAnime) "num_watched_episodes" else "num_chapters_read"] = progress.toString()
|
||||
data[if (isAnime) "is_rewatching" else "is_rereading"] = (status == "REPEATING").toString()
|
||||
if (score != null)
|
||||
data["score"] = score.div(10).toString()
|
||||
if(rewatch!=null)
|
||||
data[if(isAnime) "num_times_rewatched" else "num_times_reread"] = rewatch.toString()
|
||||
if(start!=null)
|
||||
if (rewatch != null)
|
||||
data[if (isAnime) "num_times_rewatched" else "num_times_reread"] = rewatch.toString()
|
||||
if (start != null)
|
||||
data["start_date"] = start.toMALString()
|
||||
if(end!=null)
|
||||
if (end != null)
|
||||
data["finish_date"] = end.toMALString()
|
||||
tryWithSuspend {
|
||||
client.put(
|
||||
@@ -65,8 +65,8 @@ class MALQueries {
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun deleteList(isAnime: Boolean, idMAL: Int?){
|
||||
if(idMAL==null) return
|
||||
suspend fun deleteList(isAnime: Boolean, idMAL: Int?) {
|
||||
if (idMAL == null) return
|
||||
tryWithSuspend {
|
||||
client.delete(
|
||||
"$apiUrl/${if (isAnime) "anime" else "manga"}/$idMAL/my_list_status",
|
||||
|
||||
384
app/src/main/java/ani/dantotsu/download/DownloadCompat.kt
Normal file
384
app/src/main/java/ani/dantotsu/download/DownloadCompat.kt
Normal file
@@ -0,0 +1,384 @@
|
||||
package ani.dantotsu.download
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.os.Environment
|
||||
import android.widget.Toast
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.connections.crashlytics.CrashlyticsInterface
|
||||
import ani.dantotsu.currActivity
|
||||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.download.anime.OfflineAnimeModel
|
||||
import ani.dantotsu.download.manga.OfflineMangaModel
|
||||
import ani.dantotsu.media.Media
|
||||
import ani.dantotsu.media.MediaNameAdapter
|
||||
import ani.dantotsu.media.MediaType
|
||||
import ani.dantotsu.parsers.Episode
|
||||
import ani.dantotsu.parsers.MangaChapter
|
||||
import ani.dantotsu.parsers.MangaImage
|
||||
import ani.dantotsu.parsers.Subtitle
|
||||
import ani.dantotsu.parsers.SubtitleType
|
||||
import ani.dantotsu.util.Logger
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.InstanceCreator
|
||||
import eu.kanade.tachiyomi.animesource.model.SAnime
|
||||
import eu.kanade.tachiyomi.animesource.model.SAnimeImpl
|
||||
import eu.kanade.tachiyomi.animesource.model.SEpisode
|
||||
import eu.kanade.tachiyomi.animesource.model.SEpisodeImpl
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SChapterImpl
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.io.File
|
||||
import java.util.Locale
|
||||
|
||||
@Deprecated("external storage is deprecated, use SAF instead")
|
||||
class DownloadCompat {
|
||||
companion object {
|
||||
@Deprecated("external storage is deprecated, use SAF instead")
|
||||
fun loadMediaCompat(downloadedType: DownloadedType): Media? {
|
||||
val type = when (downloadedType.type) {
|
||||
MediaType.MANGA -> "Manga"
|
||||
MediaType.ANIME -> "Anime"
|
||||
else -> "Novel"
|
||||
}
|
||||
val directory = File(
|
||||
currContext()?.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
|
||||
"Dantotsu/$type/${downloadedType.titleName}"
|
||||
)
|
||||
//load media.json and convert to media class with gson
|
||||
return try {
|
||||
val gson = GsonBuilder()
|
||||
.registerTypeAdapter(SChapter::class.java, InstanceCreator<SChapter> {
|
||||
SChapterImpl() // Provide an instance of SChapterImpl
|
||||
})
|
||||
.registerTypeAdapter(SAnime::class.java, InstanceCreator<SAnime> {
|
||||
SAnimeImpl() // Provide an instance of SAnimeImpl
|
||||
})
|
||||
.registerTypeAdapter(SEpisode::class.java, InstanceCreator<SEpisode> {
|
||||
SEpisodeImpl() // Provide an instance of SEpisodeImpl
|
||||
})
|
||||
.create()
|
||||
val media = File(directory, "media.json")
|
||||
val mediaJson = media.readText()
|
||||
gson.fromJson(mediaJson, Media::class.java)
|
||||
} catch (e: Exception) {
|
||||
Logger.log("Error loading media.json: ${e.message}")
|
||||
Logger.log(e)
|
||||
Injekt.get<CrashlyticsInterface>().logException(e)
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("external storage is deprecated, use SAF instead")
|
||||
fun loadOfflineAnimeModelCompat(downloadedType: DownloadedType): OfflineAnimeModel {
|
||||
val type = when (downloadedType.type) {
|
||||
MediaType.MANGA -> "Manga"
|
||||
MediaType.ANIME -> "Anime"
|
||||
else -> "Novel"
|
||||
}
|
||||
val directory = File(
|
||||
currContext()?.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
|
||||
"Dantotsu/$type/${downloadedType.titleName}"
|
||||
)
|
||||
//load media.json and convert to media class with gson
|
||||
try {
|
||||
val mediaModel = loadMediaCompat(downloadedType)!!
|
||||
val cover = File(directory, "cover.jpg")
|
||||
val coverUri: Uri? = if (cover.exists()) {
|
||||
Uri.fromFile(cover)
|
||||
} else null
|
||||
val banner = File(directory, "banner.jpg")
|
||||
val bannerUri: Uri? = if (banner.exists()) {
|
||||
Uri.fromFile(banner)
|
||||
} else null
|
||||
val title = mediaModel.mainName()
|
||||
val score = ((if (mediaModel.userScore == 0) (mediaModel.meanScore
|
||||
?: 0) else mediaModel.userScore) / 10.0).toString()
|
||||
val isOngoing =
|
||||
mediaModel.status == currActivity()!!.getString(R.string.status_releasing)
|
||||
val isUserScored = mediaModel.userScore != 0
|
||||
val watchedEpisodes = (mediaModel.userProgress ?: "~").toString()
|
||||
val totalEpisode =
|
||||
if (mediaModel.anime?.nextAiringEpisode != null) (mediaModel.anime.nextAiringEpisode.toString() + " | " + (mediaModel.anime.totalEpisodes
|
||||
?: "~").toString()) else (mediaModel.anime?.totalEpisodes ?: "~").toString()
|
||||
val chapters = " Chapters"
|
||||
val totalEpisodesList =
|
||||
if (mediaModel.anime?.nextAiringEpisode != null) (mediaModel.anime.nextAiringEpisode.toString()) else (mediaModel.anime?.totalEpisodes
|
||||
?: "~").toString()
|
||||
return OfflineAnimeModel(
|
||||
title,
|
||||
score,
|
||||
totalEpisode,
|
||||
totalEpisodesList,
|
||||
watchedEpisodes,
|
||||
type,
|
||||
chapters,
|
||||
isOngoing,
|
||||
isUserScored,
|
||||
coverUri,
|
||||
bannerUri
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Logger.log("Error loading media.json: ${e.message}")
|
||||
Logger.log(e)
|
||||
Injekt.get<CrashlyticsInterface>().logException(e)
|
||||
return OfflineAnimeModel(
|
||||
downloadedType.titleName,
|
||||
"0",
|
||||
"??",
|
||||
"??",
|
||||
"??",
|
||||
"movie",
|
||||
"hmm",
|
||||
isOngoing = false,
|
||||
isUserScored = false,
|
||||
null,
|
||||
null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("external storage is deprecated, use SAF instead")
|
||||
fun loadOfflineMangaModelCompat(downloadedType: DownloadedType): OfflineMangaModel {
|
||||
val type = when (downloadedType.type) {
|
||||
MediaType.MANGA -> "Manga"
|
||||
MediaType.ANIME -> "Anime"
|
||||
else -> "Novel"
|
||||
}
|
||||
val directory = File(
|
||||
currContext()?.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
|
||||
"Dantotsu/$type/${downloadedType.titleName}"
|
||||
)
|
||||
//load media.json and convert to media class with gson
|
||||
try {
|
||||
val mediaModel = loadMediaCompat(downloadedType)!!
|
||||
val cover = File(directory, "cover.jpg")
|
||||
val coverUri: Uri? = if (cover.exists()) {
|
||||
Uri.fromFile(cover)
|
||||
} else null
|
||||
val banner = File(directory, "banner.jpg")
|
||||
val bannerUri: Uri? = if (banner.exists()) {
|
||||
Uri.fromFile(banner)
|
||||
} else null
|
||||
val title = mediaModel.mainName()
|
||||
val score = ((if (mediaModel.userScore == 0) (mediaModel.meanScore
|
||||
?: 0) else mediaModel.userScore) / 10.0).toString()
|
||||
val isOngoing =
|
||||
mediaModel.status == currActivity()!!.getString(R.string.status_releasing)
|
||||
val isUserScored = mediaModel.userScore != 0
|
||||
val readchapter = (mediaModel.userProgress ?: "~").toString()
|
||||
val totalchapter = "${mediaModel.manga?.totalChapters ?: "??"}"
|
||||
val chapters = " Chapters"
|
||||
return OfflineMangaModel(
|
||||
title,
|
||||
score,
|
||||
totalchapter,
|
||||
readchapter,
|
||||
type,
|
||||
chapters,
|
||||
isOngoing,
|
||||
isUserScored,
|
||||
coverUri,
|
||||
bannerUri
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Logger.log("Error loading media.json: ${e.message}")
|
||||
Logger.log(e)
|
||||
Injekt.get<CrashlyticsInterface>().logException(e)
|
||||
return OfflineMangaModel(
|
||||
downloadedType.titleName,
|
||||
"0",
|
||||
"??",
|
||||
"??",
|
||||
"movie",
|
||||
"hmm",
|
||||
isOngoing = false,
|
||||
isUserScored = false,
|
||||
null,
|
||||
null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("external storage is deprecated, use SAF instead")
|
||||
suspend fun loadEpisodesCompat(
|
||||
animeLink: String,
|
||||
extra: Map<String, String>?,
|
||||
sAnime: SAnime
|
||||
): List<Episode> {
|
||||
|
||||
val directory = File(
|
||||
currContext()?.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
|
||||
"${animeLocation}/$animeLink"
|
||||
)
|
||||
//get all of the folder names and add them to the list
|
||||
val episodes = mutableListOf<Episode>()
|
||||
if (directory.exists()) {
|
||||
directory.listFiles()?.forEach {
|
||||
//put the title and episdode number in the extra data
|
||||
val extraData = mutableMapOf<String, String>()
|
||||
extraData["title"] = animeLink
|
||||
extraData["episode"] = it.name
|
||||
if (it.isDirectory) {
|
||||
val episode = Episode(
|
||||
it.name,
|
||||
"$animeLink - ${it.name}",
|
||||
it.name,
|
||||
null,
|
||||
null,
|
||||
extra = extraData,
|
||||
sEpisode = SEpisodeImpl()
|
||||
)
|
||||
episodes.add(episode)
|
||||
}
|
||||
}
|
||||
episodes.sortBy { MediaNameAdapter.findEpisodeNumber(it.number) }
|
||||
return episodes
|
||||
}
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
@Deprecated("external storage is deprecated, use SAF instead")
|
||||
suspend fun loadChaptersCompat(
|
||||
mangaLink: String,
|
||||
extra: Map<String, String>?,
|
||||
sManga: SManga
|
||||
): List<MangaChapter> {
|
||||
val directory = File(
|
||||
currContext()?.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
|
||||
"Dantotsu/Manga/$mangaLink"
|
||||
)
|
||||
//get all of the folder names and add them to the list
|
||||
val chapters = mutableListOf<MangaChapter>()
|
||||
if (directory.exists()) {
|
||||
directory.listFiles()?.forEach {
|
||||
if (it.isDirectory) {
|
||||
val chapter = MangaChapter(
|
||||
it.name,
|
||||
"$mangaLink/${it.name}",
|
||||
it.name,
|
||||
null,
|
||||
"Unknown",
|
||||
SChapter.create()
|
||||
)
|
||||
chapters.add(chapter)
|
||||
}
|
||||
}
|
||||
chapters.sortBy { MediaNameAdapter.findChapterNumber(it.number) }
|
||||
return chapters
|
||||
}
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
@Deprecated("external storage is deprecated, use SAF instead")
|
||||
suspend fun loadImagesCompat(chapterLink: String, sChapter: SChapter): List<MangaImage> {
|
||||
val directory = File(
|
||||
currContext()?.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
|
||||
"Dantotsu/Manga/$chapterLink"
|
||||
)
|
||||
val images = mutableListOf<MangaImage>()
|
||||
val imageNumberRegex = Regex("""(\d+)\.jpg$""")
|
||||
if (directory.exists()) {
|
||||
directory.listFiles()?.forEach {
|
||||
if (it.isFile) {
|
||||
val image = MangaImage(it.absolutePath, false, null)
|
||||
images.add(image)
|
||||
}
|
||||
}
|
||||
images.sortBy { image ->
|
||||
val matchResult = imageNumberRegex.find(image.url.url)
|
||||
matchResult?.groups?.get(1)?.value?.toIntOrNull() ?: Int.MAX_VALUE
|
||||
}
|
||||
for (image in images) {
|
||||
Logger.log("imageNumber: ${image.url.url}")
|
||||
}
|
||||
return images
|
||||
}
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
@Deprecated("external storage is deprecated, use SAF instead")
|
||||
fun loadSubtitleCompat(title: String, episode: String): List<Subtitle>? {
|
||||
currContext()?.let {
|
||||
File(
|
||||
it.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
|
||||
"$animeLocation/$title/$episode"
|
||||
).listFiles()?.forEach {
|
||||
if (it.name.contains("subtitle")) {
|
||||
return listOf(
|
||||
Subtitle(
|
||||
"Downloaded Subtitle",
|
||||
Uri.fromFile(it).toString(),
|
||||
determineSubtitletype(it.absolutePath)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private fun determineSubtitletype(url: String): SubtitleType {
|
||||
return when {
|
||||
url.lowercase(Locale.ROOT).endsWith("ass") -> SubtitleType.ASS
|
||||
url.lowercase(Locale.ROOT).endsWith("vtt") -> SubtitleType.VTT
|
||||
else -> SubtitleType.SRT
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("external storage is deprecated, use SAF instead")
|
||||
fun removeMediaCompat(context: Context, title: String, type: MediaType) {
|
||||
val subDirectory = if (type == MediaType.MANGA) {
|
||||
"Manga"
|
||||
} else if (type == MediaType.ANIME) {
|
||||
"Anime"
|
||||
} else {
|
||||
"Novel"
|
||||
}
|
||||
val directory = File(
|
||||
context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
|
||||
"Dantotsu/$subDirectory/$title"
|
||||
)
|
||||
if (directory.exists()) {
|
||||
directory.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("external storage is deprecated, use SAF instead")
|
||||
fun removeDownloadCompat(context: Context, downloadedType: DownloadedType, toast: Boolean) {
|
||||
val directory = if (downloadedType.type == MediaType.MANGA) {
|
||||
File(
|
||||
context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
|
||||
"Dantotsu/Manga/${downloadedType.titleName}/${downloadedType.chapterName}"
|
||||
)
|
||||
} else if (downloadedType.type == MediaType.ANIME) {
|
||||
File(
|
||||
context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
|
||||
"Dantotsu/Anime/${downloadedType.titleName}/${downloadedType.chapterName}"
|
||||
)
|
||||
} else {
|
||||
File(
|
||||
context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
|
||||
"Dantotsu/Novel/${downloadedType.titleName}/${downloadedType.chapterName}"
|
||||
)
|
||||
}
|
||||
|
||||
// Check if the directory exists and delete it recursively
|
||||
if (directory.exists()) {
|
||||
val deleted = directory.deleteRecursively()
|
||||
if (toast) {
|
||||
if (deleted) {
|
||||
Toast.makeText(context, "Successfully deleted", Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
Toast.makeText(context, "Failed to delete directory", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val animeLocation = "Dantotsu/Anime"
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user