Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30efe6bd0a | ||
|
|
5d67c71791 | ||
|
|
c8d9887070 | ||
|
|
8268592e8e | ||
|
|
3b63c5c3f9 | ||
|
|
d3918df4e3 | ||
|
|
7e586da521 | ||
|
|
2f5407736c | ||
|
|
b29a98e680 | ||
|
|
239a996846 | ||
|
|
421ecf527d | ||
|
|
c60e55832e | ||
|
|
b1f9568f8a | ||
|
|
dd1adb433b | ||
|
|
5a4bcfbac5 | ||
|
|
179642fa8f | ||
|
|
33111c4f31 | ||
|
|
03721e8090 | ||
|
|
0c025e0497 | ||
|
|
8cec40f672 | ||
|
|
4f7044bffa | ||
|
|
2c6c857e55 | ||
|
|
ede8c4ebad | ||
|
|
88dc85c401 | ||
|
|
7a94f78d78 | ||
|
|
6cacf6b2c5 | ||
|
|
69d198117e | ||
|
|
eb035c1023 | ||
|
|
6dabc7a331 | ||
|
|
58fe29e526 | ||
|
|
20688d6395 | ||
|
|
044dd7fea9 | ||
|
|
2c1f5081f2 | ||
|
|
9243e90e90 | ||
|
|
0dc7813c40 | ||
|
|
847bedb65c | ||
|
|
8e6e0cf673 | ||
|
|
0da3045c73 | ||
|
|
d8accce9e7 | ||
|
|
dbfd27301c | ||
|
|
5ef5d8c343 | ||
|
|
6ff8282f9f | ||
|
|
e3930e0588 | ||
|
|
129db0ad21 | ||
|
|
13a9ed902c | ||
|
|
4e9435418e | ||
|
|
9d990644dd | ||
|
|
c733cab39e | ||
|
|
5a004eeed4 | ||
|
|
012ce933d3 | ||
|
|
9a2c6bc1ff | ||
|
|
f0877e192d | ||
|
|
a04175a106 | ||
|
|
0cdd4cd6ed | ||
|
|
c64d2a4fa4 | ||
|
|
0b4b5a0b56 | ||
|
|
42ff4e877a | ||
|
|
96f206e1a0 | ||
|
|
d2bce7a1e2 | ||
|
|
f1f64eaba1 | ||
|
|
817eaf1bb2 | ||
|
|
16de3fdb97 | ||
|
|
2452f09714 | ||
|
|
b02c1311ff | ||
|
|
21c35f7744 | ||
|
|
bd2f22e9d7 | ||
|
|
d27776fd26 | ||
|
|
416ce15d1d | ||
|
|
9f9abc6d3e | ||
|
|
995f042fc8 | ||
|
|
e905a50ed0 | ||
|
|
5e036992b0 | ||
|
|
cb81a87200 | ||
|
|
fad2ba23b7 | ||
|
|
e093c0820d | ||
|
|
a65c729906 | ||
|
|
1b7fc89d8b | ||
|
|
246b8512e4 | ||
|
|
4209f0e86d | ||
|
|
653f57ea5d | ||
|
|
1766111e1d | ||
|
|
8caa08843e | ||
|
|
a08ae6f977 | ||
|
|
db246b38f2 | ||
|
|
1119d47a80 | ||
|
|
d4ddfad838 | ||
|
|
e2d0799d17 | ||
|
|
f68f31c80f | ||
|
|
b7c8e72ce2 | ||
|
|
9f5b286a45 | ||
|
|
1de204ff02 | ||
|
|
cc4d364f75 | ||
|
|
cd629065b8 | ||
|
|
46dfd9c44e | ||
|
|
edc797035f | ||
|
|
c1eb7d70b7 | ||
|
|
921636ea69 | ||
|
|
40c2262f47 | ||
|
|
b91e8fd0a1 | ||
|
|
ad7ca59532 | ||
|
|
802c16c0df | ||
|
|
efbb0e1b1c | ||
|
|
607f6e9b6c | ||
|
|
72b775e179 | ||
|
|
491f312036 | ||
|
|
31221062dd | ||
|
|
73e6fa24a8 | ||
|
|
b335fd30d1 | ||
|
|
37395003cb | ||
|
|
39b360b132 | ||
|
|
34b16c2da9 | ||
|
|
525108bf26 | ||
|
|
7563bdf900 | ||
|
|
64785be947 | ||
|
|
a714e9b985 | ||
|
|
bc69a8768c | ||
|
|
7d67761ed8 | ||
|
|
3d9b508335 | ||
|
|
78f0c8823d | ||
|
|
145a3c44b7 | ||
|
|
2063f51289 | ||
|
|
da2bfd8fc9 | ||
|
|
eedcd188c3 | ||
|
|
af8b5b63d5 | ||
|
|
4485d0833e | ||
|
|
a163a6af88 | ||
|
|
38bb5af04b | ||
|
|
11804d1cb8 | ||
|
|
22529fc1d2 | ||
|
|
62b0c5fd62 | ||
|
|
1ed28a4fd4 | ||
|
|
5044aea1d7 | ||
|
|
47fda0ccca | ||
|
|
742490775a | ||
|
|
95bbed2b21 | ||
|
|
2b446e227d | ||
|
|
ea6417dbb1 | ||
|
|
d902417959 | ||
|
|
358197db03 | ||
|
|
102fd1f1a1 | ||
|
|
fe9168c6cf | ||
|
|
f7663fc17f | ||
|
|
e370ec36ab | ||
|
|
8f181c74d4 | ||
|
|
8134ec84c6 | ||
|
|
e2fc5bcbb1 | ||
|
|
67af09c4bd | ||
|
|
b81abf4da5 | ||
|
|
2c288bb34d | ||
|
|
df762e8910 | ||
|
|
253aa19701 | ||
|
|
ea608d875b | ||
|
|
d4340a8b95 | ||
|
|
33b3aafb14 | ||
|
|
6cedc2fe35 | ||
|
|
1bb03015d9 | ||
|
|
c5bef72c63 | ||
|
|
8b7c00b337 | ||
|
|
6199d4fab4 | ||
|
|
2063d8647a | ||
|
|
c0a9f85f77 | ||
|
|
b1651c5b01 | ||
|
|
1a8af2caee | ||
|
|
a593070b9f | ||
|
|
1d700b0663 | ||
|
|
2233885142 | ||
|
|
faf87d2942 | ||
|
|
706673aed0 | ||
|
|
eaea688e33 | ||
|
|
256be3521d | ||
|
|
cec1e8593d | ||
|
|
e18f9be810 | ||
|
|
69dca2db43 | ||
|
|
c03321b55e | ||
|
|
f8b4287229 | ||
|
|
ce2fa0c116 | ||
|
|
ebe9a230fd | ||
|
|
a05ceea4bc | ||
|
|
67c2ded1f0 | ||
|
|
66d09c886e | ||
|
|
bbff7513f1 | ||
|
|
4195279c5d | ||
|
|
464d967a0a | ||
|
|
4dd7bf8916 | ||
|
|
4b134eaef9 | ||
|
|
ece62c8b18 | ||
|
|
b430c185b1 | ||
|
|
5c13ccf9e7 | ||
|
|
cb0e2ba305 | ||
|
|
011fbb38cb | ||
|
|
0a69450bc0 | ||
|
|
b4a97f4347 | ||
|
|
96f7aa95ee | ||
|
|
e92f2177e8 | ||
|
|
e4a3cc5290 | ||
|
|
a3a58a25ef | ||
|
|
ab7bda402e | ||
|
|
d78c168e16 | ||
|
|
2b04b4f008 | ||
|
|
a6cc0d742c | ||
|
|
e7e9a2755c | ||
|
|
56ea4ce2f5 | ||
|
|
05528f6dfd | ||
|
|
49cd36c33e | ||
|
|
898d96ce3a | ||
|
|
b257836b76 | ||
|
|
8fab4e56ef | ||
|
|
8e34c230d7 | ||
|
|
b32f2e2973 | ||
|
|
1047d1a598 | ||
|
|
1e5115b743 | ||
|
|
e1e12de91b | ||
|
|
58950afb99 | ||
|
|
89b64b165f | ||
|
|
90ab927bdc | ||
|
|
50ebf4eacb | ||
|
|
064ba080ab | ||
|
|
4ee0345217 | ||
|
|
d45cbbba98 | ||
|
|
612a7a7063 | ||
|
|
62e3ca4068 | ||
|
|
34dcdc89c3 | ||
|
|
bcc202ff3b | ||
|
|
d4a56b3823 | ||
|
|
626239038b | ||
|
|
f7da431e61 | ||
|
|
6ff59c423b | ||
|
|
076d4977e3 | ||
|
|
2a737a9d72 | ||
|
|
8c77a19eb6 | ||
|
|
3918696477 | ||
|
|
8a6a2b8577 | ||
|
|
584023380c | ||
|
|
1f4dd2bdb7 | ||
|
|
f7d5a0732b | ||
|
|
2a6cc882a5 | ||
|
|
f385339da3 | ||
|
|
c37566a999 | ||
|
|
f90a4b1374 | ||
|
|
b649680d3e | ||
|
|
b84c2abe14 | ||
|
|
58aff762c0 | ||
|
|
e5eef69c91 | ||
|
|
54f91b7a88 | ||
|
|
17676173ef | ||
|
|
31f4aa944a | ||
|
|
b30bd495b7 | ||
|
|
06f893436e | ||
|
|
20a2b3ed90 | ||
|
|
b1e3bc46c8 | ||
|
|
8bc5932889 | ||
|
|
3cd597d71e | ||
|
|
48d5ad462e | ||
|
|
40cab87640 | ||
|
|
f405947ad8 | ||
|
|
fd550c15a5 | ||
|
|
d18537cf04 | ||
|
|
f01f0229a8 | ||
|
|
b369eb2d40 | ||
|
|
f08c65c5bf | ||
|
|
1043f4ecd7 | ||
|
|
4f17a32373 | ||
|
|
2203aae6e6 | ||
|
|
7b60c7b6c5 | ||
|
|
be98e06efc | ||
|
|
45239bca34 | ||
|
|
84509ec1a8 | ||
|
|
2493ce7ed7 | ||
|
|
2b1e53b371 | ||
|
|
d643a1769f | ||
|
|
a63b7a188c | ||
|
|
f9c0162b8a | ||
|
|
cda3cb3512 | ||
|
|
766f6938a7 | ||
|
|
8e1ccb517b | ||
|
|
540aab6f83 | ||
|
|
d1969d7897 | ||
|
|
b69e8fd649 | ||
|
|
2e95cf908d | ||
|
|
b589bae2b0 | ||
|
|
e7e4891d82 | ||
|
|
79df676a13 | ||
|
|
03a46decba | ||
|
|
d80482f443 | ||
|
|
735cce7614 | ||
|
|
8ea35a0b36 | ||
|
|
ad90bd3d05 | ||
|
|
fa3856e845 | ||
|
|
752d4ddc8c | ||
|
|
fd2d7a05d1 | ||
|
|
ccf4675867 | ||
|
|
bc043c73ca | ||
|
|
291ab247bc | ||
|
|
d901f470a1 | ||
|
|
0ebb01e39d | ||
|
|
20ac99bf8d | ||
|
|
90e86e1575 | ||
|
|
28652031e7 | ||
|
|
cd8be40cc8 | ||
|
|
52fc937f96 | ||
|
|
68e4722387 | ||
|
|
5f5b38b2f9 | ||
|
|
65f8d3ce81 | ||
|
|
ac571fd63d | ||
|
|
ea2d6e9f31 | ||
|
|
80b999d648 | ||
|
|
54720039e4 | ||
|
|
8c6717c201 | ||
|
|
6610754e25 | ||
|
|
d38622d8a2 | ||
|
|
cd2750a489 | ||
|
|
30140629ae | ||
|
|
0ce29337ef | ||
|
|
6715f29ebb | ||
|
|
b4a8dc9e26 | ||
|
|
c349a0bf00 | ||
|
|
0dc6c142be | ||
|
|
e46c1d9120 | ||
|
|
27ad554ea1 | ||
|
|
5660772b46 | ||
|
|
dab80642ab | ||
|
|
da46191208 | ||
|
|
6484c4de79 | ||
|
|
6716b6042a | ||
|
|
0686859fa7 | ||
|
|
4180862c3a | ||
|
|
7aa20d3211 | ||
|
|
b694b55710 | ||
|
|
024b613063 | ||
|
|
8768d11a20 | ||
|
|
5898303ba4 | ||
|
|
e79d09941c | ||
|
|
c52a60fe77 | ||
|
|
e64f9aa427 | ||
|
|
ee343f78ef | ||
|
|
1f20d5821f | ||
|
|
b0c512e946 | ||
|
|
0d13b7abd1 | ||
|
|
43fd8285c9 | ||
|
|
2f7e8d618a | ||
|
|
a0b910deeb | ||
|
|
e9dc45613c | ||
|
|
b5e90ec3d2 | ||
|
|
3d9f42c1e1 | ||
|
|
e62f430f37 | ||
|
|
9c53564c46 | ||
|
|
f7add6f6cd | ||
|
|
7786e6a827 | ||
|
|
b213e2aabf | ||
|
|
ebca0fafca | ||
|
|
ac8a2ca985 | ||
|
|
6380d7cc02 | ||
|
|
9056ba6b8d | ||
|
|
23801363c4 | ||
|
|
1cdcd7327f | ||
|
|
50ec50003e | ||
|
|
5ff4db1a3f | ||
|
|
394b44c343 | ||
|
|
eb2aa6f773 | ||
|
|
81130e04e5 | ||
|
|
c0ec0758f4 | ||
|
|
e21f7c545e | ||
|
|
c16dd2fcf6 | ||
|
|
90974e6d73 | ||
|
|
8e4f75d85b | ||
|
|
792ee2adb8 | ||
|
|
2c57489c07 | ||
|
|
e3321770fd | ||
|
|
848673f028 | ||
|
|
e6d3003ecf | ||
|
|
90551b7ce7 | ||
|
|
aabac5da13 | ||
|
|
4fad77f9c1 | ||
|
|
0fb6d746eb | ||
|
|
7fc712d19b | ||
|
|
d6018cfe10 | ||
|
|
5b8f231a98 | ||
|
|
cb503f84e1 | ||
|
|
a34f9b80ac | ||
|
|
3e6696b516 | ||
|
|
9cd8bd439a | ||
|
|
ca5b99e23d | ||
|
|
c44fd74f5b | ||
|
|
f82c4834c3 | ||
|
|
dda95bd69c | ||
|
|
a623cb57a7 | ||
|
|
e798d930fb | ||
|
|
f91b0c9e2f | ||
|
|
b6824cf242 | ||
|
|
41477fdac1 | ||
|
|
d4e8afc2f1 | ||
|
|
d42cbfe3e4 | ||
|
|
c7c3ef52e6 | ||
|
|
92344325b6 | ||
|
|
a8172fb3f9 | ||
|
|
a73ec783d5 | ||
|
|
5c9fc4c9e4 | ||
|
|
494ff38ef3 | ||
|
|
b7e6cbf1ab | ||
|
|
b33623b74f | ||
|
|
4f939ce6fc | ||
|
|
4f45f360df | ||
|
|
4ad54f34fe | ||
|
|
574dda5286 | ||
|
|
d788623509 | ||
|
|
f047f6a23b | ||
|
|
48b30f6b03 | ||
|
|
67d32164d9 | ||
|
|
6672a21049 | ||
|
|
b833019a14 | ||
|
|
00eeeb2a5a | ||
|
|
06a0a68143 | ||
|
|
1a7ae468bd | ||
|
|
e8f74d7358 | ||
|
|
984f01da23 | ||
|
|
d6e75410a5 | ||
|
|
7627e1b58c | ||
|
|
5fb31b18ae | ||
|
|
20903e8217 | ||
|
|
8fe348d4eb | ||
|
|
24cda8a179 | ||
|
|
fc954a968b | ||
|
|
aae53a54cd | ||
|
|
cfedcffc98 | ||
|
|
0e74c74a6c | ||
|
|
fb86c45e78 | ||
|
|
124300b215 | ||
|
|
6746c0627b | ||
|
|
0f2cd3b132 | ||
|
|
e94d6fdc1e | ||
|
|
e301b3071c | ||
|
|
3d3dad5e4a | ||
|
|
f8a9033738 | ||
|
|
edb25f5bcd | ||
|
|
bcb239efd1 | ||
|
|
d208211c6f | ||
|
|
0b20b72241 | ||
|
|
5c29459af2 | ||
|
|
e54fd38784 | ||
|
|
94774f13df | ||
|
|
43ec35fe67 | ||
|
|
b2645dc444 | ||
|
|
c79624a82c | ||
|
|
8201f3c9a6 | ||
|
|
e0ac6a1c38 | ||
|
|
400da5566d | ||
|
|
9b67037774 | ||
|
|
48596542c7 | ||
|
|
9715d65d88 | ||
|
|
2e14b31a69 | ||
|
|
1c8ce6c3db | ||
|
|
dc74a6213d | ||
|
|
e9a66bb7a7 | ||
|
|
3c6d4b5f19 | ||
|
|
f04eebe0d8 | ||
|
|
63b5227ccc | ||
|
|
934d9b1df4 | ||
|
|
8994cb3a6e | ||
|
|
4a32de482b | ||
|
|
95f47793d2 | ||
|
|
f27048618d | ||
|
|
c90ad419e8 | ||
|
|
2cdc3ecb9d | ||
|
|
9f89fcd968 | ||
|
|
7c2d51f811 | ||
|
|
41fe7a29cd | ||
|
|
54f3eec303 | ||
|
|
cd91013f69 | ||
|
|
0af16ef05f | ||
|
|
5ba830d56e | ||
|
|
81919e963a | ||
|
|
8a1d4bb958 | ||
|
|
eabac0e709 | ||
|
|
d90783d7c8 | ||
|
|
faf8211e5c | ||
|
|
65d90947c5 | ||
|
|
752e918d26 | ||
|
|
ad08cc69f4 | ||
|
|
da3882fd5e | ||
|
|
c04c7a55d9 | ||
|
|
3318846b43 | ||
|
|
e0860feeb9 | ||
|
|
c0253a69b9 | ||
|
|
9242c7e6e0 | ||
|
|
0bfc579ae4 | ||
|
|
5fad06756b | ||
|
|
5be6afa6c1 | ||
|
|
5ba3b8be7a | ||
|
|
0eb62f541d | ||
|
|
6baff881c7 | ||
|
|
8c23c1e795 | ||
|
|
9706c66a27 | ||
|
|
f4f7252537 | ||
|
|
430d200151 | ||
|
|
7be82d03f3 | ||
|
|
15aaef742d | ||
|
|
e443ba09da | ||
|
|
8235d1f1f7 | ||
|
|
9a39dcceee | ||
|
|
a707b7fc86 | ||
|
|
b6fea85ef4 | ||
|
|
7e3b3f55ae | ||
|
|
d2d3bbe8a1 | ||
|
|
41a65c0f9d | ||
|
|
165ddd58a6 | ||
|
|
09dc04c0de | ||
|
|
57d5dbc0d0 | ||
|
|
11af75e127 | ||
|
|
f8d82a3020 | ||
|
|
81d7b1cfd7 | ||
|
|
e15c1bcb32 | ||
|
|
826d414d9f | ||
|
|
0da6fca727 | ||
|
|
2327bc1705 | ||
|
|
3bb76cecac | ||
|
|
e3f82bb237 | ||
|
|
fcd6270f2d | ||
|
|
d5411703ca | ||
|
|
8fc2058db8 | ||
|
|
d03949f5d1 | ||
|
|
ff01786063 | ||
|
|
bb117ab4da | ||
|
|
f5ec247b47 | ||
|
|
6e6dd00523 | ||
|
|
c9fb98f033 | ||
|
|
75ecff5e6d | ||
|
|
91a9f918fb | ||
|
|
03305f90ca | ||
|
|
9428bc07c5 | ||
|
|
f38f9c3502 | ||
|
|
64a796aece | ||
|
|
63039fe8c9 | ||
|
|
3f2b723d0f | ||
|
|
ffd7fb1cf9 | ||
|
|
b049b206cf | ||
|
|
35f56dc8a9 | ||
|
|
a71cd326cc | ||
|
|
cc841d1c7c | ||
|
|
16ecdcf96e | ||
|
|
96ec56d1ad | ||
|
|
9b15bafc9f | ||
|
|
aa02f2e465 | ||
|
|
15464617ef | ||
|
|
60ecceb59d | ||
|
|
3fe943e989 | ||
|
|
5e7d039454 | ||
|
|
f928df146a | ||
|
|
6e57cb49c4 | ||
|
|
2f8494b013 | ||
|
|
6f1b93bd9f | ||
|
|
19b928d7f6 | ||
|
|
b849be6f5e | ||
|
|
86096df1a4 | ||
|
|
98a465c7b4 | ||
|
|
3315f61ae4 | ||
|
|
f977445d7a | ||
|
|
095d5e1cec | ||
|
|
69fbfa4b33 | ||
|
|
1c89d33726 | ||
|
|
acee907932 | ||
|
|
08ad216fe2 | ||
|
|
3cc7a0937c | ||
|
|
322cad5548 | ||
|
|
73d70dd480 | ||
|
|
56bc569d4a | ||
|
|
981ae58f6a | ||
|
|
b2bfa4c002 | ||
|
|
8b6003c5e3 | ||
|
|
017b6237ca | ||
|
|
d5496c2e9a | ||
|
|
5ef8961c33 | ||
|
|
e8bea48577 | ||
|
|
6cae78f5c2 | ||
|
|
d9d31a0620 | ||
|
|
3682c5fca2 | ||
|
|
14b04a14b6 | ||
|
|
f218d90bfb | ||
|
|
020f936ad4 | ||
|
|
224e5efe48 | ||
|
|
439ab2c8c0 | ||
|
|
26d0209763 | ||
|
|
29086fc783 | ||
|
|
bb656a265f | ||
|
|
b11ad9dc5b | ||
|
|
2b1667e532 | ||
|
|
228a198598 | ||
|
|
2843308fb8 | ||
|
|
793f0c05f7 | ||
|
|
cf7271dc57 | ||
|
|
54664b0c32 | ||
|
|
ecf910dc55 | ||
|
|
460daec72e | ||
|
|
4dd67adcab | ||
|
|
023c83ee78 | ||
|
|
2b8ed16616 | ||
|
|
6ae4d72b68 | ||
|
|
c6bd93ef5c | ||
|
|
e1c02ce74c | ||
|
|
efc6d68403 | ||
|
|
7412d0899f | ||
|
|
42eb0a8384 | ||
|
|
27e83e8ed9 | ||
|
|
dd66042766 | ||
|
|
dc790d5450 | ||
|
|
01ac844024 | ||
|
|
c8064ac7bc | ||
|
|
f5da44dc6f | ||
|
|
cbdff29684 | ||
|
|
19d6c84113 | ||
|
|
d9f4ed3d54 | ||
|
|
fdb26b7700 | ||
|
|
94cb7a65a2 | ||
|
|
9298065934 | ||
|
|
1cf01a5d12 | ||
|
|
e3aa96cbd5 | ||
|
|
c7678da664 | ||
|
|
52701048ad | ||
|
|
776c02828f | ||
|
|
69308413f6 | ||
|
|
84e376a7cf | ||
|
|
1822b21af8 | ||
|
|
8b222435e6 | ||
|
|
fdd251ec2c | ||
|
|
78170d4e10 | ||
|
|
837981b8b6 | ||
|
|
be23c6703f | ||
|
|
0c72889917 | ||
|
|
02746bc35f | ||
|
|
85a5c33bd8 | ||
|
|
5067c0f6d7 | ||
|
|
89938ab120 | ||
|
|
9a32396daa | ||
|
|
ddb1796891 | ||
|
|
76253b7b9d | ||
|
|
74fef1d2f4 | ||
|
|
7306ffa709 | ||
|
|
6f289293cc | ||
|
|
783f924bb9 | ||
|
|
044a35aacf | ||
|
|
78448894d2 | ||
|
|
aca348e783 | ||
|
|
e6c1874cbb | ||
|
|
1b06dbd78c | ||
|
|
a26f37aa49 | ||
|
|
8af3c09458 | ||
|
|
fed6579e08 | ||
|
|
6621f8b2ee | ||
|
|
737b6d7c26 | ||
|
|
59c71b71fb | ||
|
|
f89148b92e | ||
|
|
88fbebe5c4 | ||
|
|
e8abb18350 | ||
|
|
cc9dead1eb | ||
|
|
f9dd8188ee | ||
|
|
579785d2c6 | ||
|
|
257a1ceb51 | ||
|
|
5c60cd136c | ||
|
|
2bfe548c52 | ||
|
|
164fd92a18 | ||
|
|
0036a19659 | ||
|
|
ef4d7ba1bf | ||
|
|
8dbffa7993 | ||
|
|
17ff2ed5f4 | ||
|
|
6fe470cfc1 | ||
|
|
301e9b213f | ||
|
|
2b533524fc | ||
|
|
632b1f526b | ||
|
|
81b11bac93 | ||
|
|
a88e404ccf | ||
|
|
a7cbdbfbbb | ||
|
|
ad5146e2ee | ||
|
|
36be91962c | ||
|
|
ff5a1bb09f | ||
|
|
5060554640 | ||
|
|
93cb319e97 | ||
|
|
a42dfa5649 | ||
|
|
6a938b8da1 | ||
|
|
4f994072ad | ||
|
|
7c0ef179ec | ||
|
|
5fdd0c6672 | ||
|
|
e9f523d7cb | ||
|
|
c1b13dcd24 | ||
|
|
0daa043f14 | ||
|
|
1a6b716046 | ||
|
|
945baa24f0 | ||
|
|
30d4e709f0 | ||
|
|
8d8782a5a9 | ||
|
|
087e8553c4 | ||
|
|
2984398051 | ||
|
|
e9251db647 | ||
|
|
6c88337180 | ||
|
|
74b488ad0f | ||
|
|
fc7af6d1fc | ||
|
|
737d8f19b3 | ||
|
|
d613d8954d | ||
|
|
04e468b43d | ||
|
|
dc8178769b | ||
|
|
8b631f7860 | ||
|
|
e521ddfab6 | ||
|
|
6b164bdb27 | ||
|
|
2eb399b8a7 | ||
|
|
46f558d6e0 | ||
|
|
00bed39733 | ||
|
|
2048795c92 | ||
|
|
8c9bd53934 | ||
|
|
01178d00bf | ||
|
|
7541e4b660 | ||
|
|
2366c938b5 | ||
|
|
59480ad114 | ||
|
|
ce7779607f | ||
|
|
04bc74babe | ||
|
|
ac2b674ba5 | ||
|
|
e53901e7a4 | ||
|
|
3ede41f496 | ||
|
|
0adeaaa04d | ||
|
|
57d1fbfa83 | ||
|
|
27bbe40874 | ||
|
|
60da6093f3 | ||
|
|
259c9cef20 | ||
|
|
6d61b2acaf | ||
|
|
72f687b079 | ||
|
|
0ce3c8bcbd | ||
|
|
f9621d2f60 | ||
|
|
e634132a39 | ||
|
|
59b428100b | ||
|
|
36e0c91e27 | ||
|
|
03225957aa | ||
|
|
77f70e48de | ||
|
|
cbdc3513c7 | ||
|
|
394479bea0 | ||
|
|
b9592e46a7 | ||
|
|
5810a83c66 | ||
|
|
389c7d23ca | ||
|
|
defc7d216a | ||
|
|
852702112a | ||
|
|
dd91bc6667 | ||
|
|
cdbbd56a58 | ||
|
|
d6a1eba657 | ||
|
|
da899bfddd | ||
|
|
b7b746fb2a | ||
|
|
c8053355df | ||
|
|
1ddb6eca00 | ||
|
|
f42c624cba | ||
|
|
f8fbeef9b7 | ||
|
|
46b82a81ce | ||
|
|
48342e5bd3 | ||
|
|
147f89f870 | ||
|
|
8b39ba9c92 | ||
|
|
13d32dc1f7 | ||
|
|
0d1312e497 | ||
|
|
ff4f8324e7 | ||
|
|
b4bf10d409 | ||
|
|
ae37861f7d | ||
|
|
1da03cdd65 | ||
|
|
a7443d0992 | ||
|
|
5a953464ab | ||
|
|
953bde5a42 | ||
|
|
481d0d0285 | ||
|
|
7b3a005ad6 | ||
|
|
4f9d341f69 | ||
|
|
9e7d1d1617 | ||
|
|
4f03c2a35d | ||
|
|
db3c5396e9 | ||
|
|
455af239a1 | ||
|
|
d8bc26f5f8 | ||
|
|
543ac209e4 | ||
|
|
c8b5cefeb5 | ||
|
|
f1411011e6 | ||
|
|
f3964dda17 | ||
|
|
d207e88e18 | ||
|
|
2643e98fc0 | ||
|
|
410648e316 | ||
|
|
373221703d | ||
|
|
fbcb8620f9 | ||
|
|
a8ac4970cc | ||
|
|
195e33ae32 | ||
|
|
9acf695802 | ||
|
|
e6aaccfc74 | ||
|
|
87c74fe78b | ||
|
|
7dc319c1bd | ||
|
|
c093548b71 | ||
|
|
b067a2d3d5 | ||
|
|
a9ae7bfdb8 | ||
|
|
9dcf22614c | ||
|
|
c7564d439e | ||
|
|
157dc01673 | ||
|
|
cce6e1d0ab | ||
|
|
b935cb5cf1 | ||
|
|
9ab37ac525 |
@@ -1,13 +1,8 @@
|
|||||||
# editorconfig.org
|
|
||||||
root = true
|
root = true
|
||||||
|
|
||||||
[*]
|
[*]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
end_of_line = lf
|
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
trim_trailing_whitespace = true
|
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
[*.md]
|
|
||||||
trim_trailing_whitespace = false
|
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Create a report to help us improve
|
|
||||||
labels: bug
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Steps to reproduce
|
|
||||||
|
|
||||||
1.
|
|
||||||
2.
|
|
||||||
3.
|
|
||||||
|
|
||||||
### Expected behaviour
|
|
||||||
- Tell us what should happen
|
|
||||||
|
|
||||||
### Actual behaviour
|
|
||||||
- Tell us what happens
|
|
||||||
|
|
||||||
### Environment data
|
|
||||||
|
|
||||||
Audiobookshelf Version:
|
|
||||||
|
|
||||||
- [ ] Android App?
|
|
||||||
- [ ] iOS App?
|
|
||||||
|
|
||||||
#### Android Issue
|
|
||||||
Android version:
|
|
||||||
|
|
||||||
Device model:
|
|
||||||
|
|
||||||
Stock or customized system:
|
|
||||||
|
|
||||||
#### iOS Issue
|
|
||||||
iOS Version:
|
|
||||||
|
|
||||||
iPhone model:
|
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
name: 🐞 ABS App Bug Report
|
||||||
|
description: File a bug/issue and help us improve the Audiobookshelf mobile apps.
|
||||||
|
title: '[Bug]: '
|
||||||
|
labels: ['bug', 'triage']
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: '## App Bug Description'
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: 'Thank you for filing a bug report! 🐛'
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: 'Join the [discord server](https://discord.gg/HQgCbd6E75) for questions or if you are not sure about a bug.'
|
||||||
|
- type: textarea
|
||||||
|
id: what-happened
|
||||||
|
attributes:
|
||||||
|
label: What was the Problem?
|
||||||
|
description: Please help us understand the problem.
|
||||||
|
placeholder: Describe the problem you saw or experienced in detail! Include a screenshot or video, if applicable.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: steps-to-reproduce
|
||||||
|
attributes:
|
||||||
|
label: Steps to Reproduce the Issue
|
||||||
|
description: Please help us understand how we can reliably reproduce the issue.
|
||||||
|
placeholder: '1. Go to the library page of a Podcast library and...'
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: what-was-expected
|
||||||
|
attributes:
|
||||||
|
label: What was Expected?
|
||||||
|
description: Please help us understand what should have happened.
|
||||||
|
placeholder: Please help us visualize by including a doodle or screenshot.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: '## Mobile Environment'
|
||||||
|
- type: input
|
||||||
|
id: phone-model
|
||||||
|
attributes:
|
||||||
|
label: Phone Model
|
||||||
|
description: What kind of phone are you using?
|
||||||
|
placeholder: e.g. Pixel 6, iPhone 14, Samusung Galaxy s23, etc
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: phone-os
|
||||||
|
attributes:
|
||||||
|
label: Phone OS
|
||||||
|
description: What operating system? If Android, is it stock or a custom system?
|
||||||
|
placeholder: e.g. Android 14, iOS 17.4, etc
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
id: app-version
|
||||||
|
attributes:
|
||||||
|
label: Audiobookshelf App Version
|
||||||
|
description: Please ensure your app is up to date. *If you are using a 3rd-party app, please reach out to them directly.*
|
||||||
|
multiple: true
|
||||||
|
options:
|
||||||
|
- Android App - 0.9.77
|
||||||
|
- iOS App - 0.9.77
|
||||||
|
- Android App - 0.9.76
|
||||||
|
- iOS App - 0.9.76
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
id: install-source
|
||||||
|
attributes:
|
||||||
|
label: Installation Source
|
||||||
|
multiple: true
|
||||||
|
options:
|
||||||
|
- Google Play Store
|
||||||
|
- Testflight
|
||||||
|
- SideStore
|
||||||
|
- Other (List in "Additional Notes")
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: additional-notes
|
||||||
|
attributes:
|
||||||
|
label: Additional Notes
|
||||||
|
description: Anything else you want to add?
|
||||||
|
placeholder: 'e.g. I have tried X, Y, and Z.'
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Suggest an idea for this project
|
|
||||||
labels: enhancement
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Is your feature request related to a problem? Please describe.
|
|
||||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
||||||
|
|
||||||
### Describe the solution you'd like
|
|
||||||
A clear and concise description of what you want to happen.
|
|
||||||
|
|
||||||
### Describe alternatives you've considered
|
|
||||||
A clear and concise description of any alternative solutions or features you've considered.
|
|
||||||
|
|
||||||
### Additional context
|
|
||||||
Add any other context or screenshots about the feature request here.
|
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
name: 🚀 App Feature Request
|
||||||
|
description: Request a feature/enhancement
|
||||||
|
title: '[Enhancement]: '
|
||||||
|
labels: ['enhancement']
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: '## App Feature Request Description'
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: 'Please first search in both issues & discussions for your enhancement and make sure your app is up to date.'
|
||||||
|
- type: textarea
|
||||||
|
id: describe
|
||||||
|
attributes:
|
||||||
|
label: Describe the Feature/Enhancement
|
||||||
|
description: Please help us understand what you want.
|
||||||
|
placeholder: What is your vision?
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: the-why
|
||||||
|
attributes:
|
||||||
|
label: Why would this be helpful?
|
||||||
|
description: Please help us understand why this would enhance your experience.
|
||||||
|
placeholder: Explain the "why" or "use case".
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: image
|
||||||
|
attributes:
|
||||||
|
label: Future Implementation (Screenshot)
|
||||||
|
description: Please help us visualize by including a doodle or screenshot.
|
||||||
|
placeholder: How could this look or where could it go?
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: '## App Current Implementation'
|
||||||
|
- type: dropdown
|
||||||
|
id: version
|
||||||
|
attributes:
|
||||||
|
label: Audiobookshelf App Version
|
||||||
|
description: Please ensure your app is up to date. *If you are using a 3rd-party app, please reach out to them directly.*
|
||||||
|
multiple: true
|
||||||
|
options:
|
||||||
|
- Android App - 0.9.77
|
||||||
|
- iOS App - 0.9.77
|
||||||
|
- Android App - 0.9.76
|
||||||
|
- iOS App - 0.9.76
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: current-image
|
||||||
|
attributes:
|
||||||
|
label: Current Implementation (Screenshot)
|
||||||
|
description: What screen were you looking at when you thought of this enhancement?
|
||||||
|
placeholder: If an image is not applicable, please explain why.
|
||||||
@@ -16,10 +16,16 @@ jobs:
|
|||||||
- name: checkout sources
|
- name: checkout sources
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: use Node.js 16.x
|
- name: use Node.js 20.x
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 16
|
node-version: 20
|
||||||
|
|
||||||
|
- name: Set up Java
|
||||||
|
uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
distribution: "temurin"
|
||||||
|
java-version: 17
|
||||||
|
|
||||||
- name: install dependencies
|
- name: install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
name: Close fixed issues on release.
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
issues: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
comment:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Close issues marked as fixed upon a release.
|
||||||
|
uses: gcampbell-msft/fixed-pending-release@7fa1b75a0c04bcd4b375110522878e5f6100cff5
|
||||||
|
with:
|
||||||
|
label: 'awaiting release'
|
||||||
|
removeLabel: true
|
||||||
|
applyToAll: true
|
||||||
|
message: Fixed in [${releaseTag}](${releaseUrl}).
|
||||||
@@ -15,10 +15,16 @@ jobs:
|
|||||||
- name: checkout sources
|
- name: checkout sources
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: use Node.js 16.x
|
- name: use Node.js 20.x
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 16
|
node-version: 20
|
||||||
|
|
||||||
|
- name: Set up Java
|
||||||
|
uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
distribution: "temurin"
|
||||||
|
java-version: 17
|
||||||
|
|
||||||
- name: install dependencies
|
- name: install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
name: Verify all i18n files are alphabetized
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- strings/** # Should only check if any strings changed
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update_translations:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# Check out the repository
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# Set up node to run the javascript
|
||||||
|
- name: Set up node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
|
||||||
|
# The only argument is the `directory`, which is where the i18n files are
|
||||||
|
# stored.
|
||||||
|
- name: Run Update JSON Files action
|
||||||
|
uses: audiobookshelf/audiobookshelf-i18n-updater@v1.3.0
|
||||||
|
with:
|
||||||
|
directory: 'strings/' # Adjust the directory path as needed
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"semi": false,
|
||||||
|
"singleQuote": true,
|
||||||
|
"printWidth": 400,
|
||||||
|
"proseWrap": "never",
|
||||||
|
"trailingComma": "none",
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": ["*.html"],
|
||||||
|
"options": {
|
||||||
|
"singleQuote": false,
|
||||||
|
"wrapAttributes": false,
|
||||||
|
"sortAttributes": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"EditorConfig.EditorConfig",
|
||||||
|
"esbenp.prettier-vscode",
|
||||||
|
"octref.vetur"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"vetur.format.defaultFormatterOptions": {
|
||||||
|
"prettier": {
|
||||||
|
"semi": false,
|
||||||
|
"singleQuote": true,
|
||||||
|
"printWidth": 400,
|
||||||
|
"proseWrap": "never",
|
||||||
|
"trailingComma": "none"
|
||||||
|
},
|
||||||
|
"prettyhtml": {
|
||||||
|
"printWidth": 400,
|
||||||
|
"singleQuote": false,
|
||||||
|
"wrapAttributes": false,
|
||||||
|
"sortAttributes": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"editor.detectIndentation": true,
|
||||||
|
"editor.tabSize": 2,
|
||||||
|
"javascript.format.semicolons": "remove",
|
||||||
|
"[javascript][json][jsonc]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[vue]": {
|
||||||
|
"editor.defaultFormatter": "octref.vetur"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,59 +18,62 @@ kotlin {
|
|||||||
"--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
|
"--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
|
||||||
"--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
|
"--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
jvmToolchain(17)
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
||||||
|
|
||||||
namespace 'com.audiobookshelf.app'
|
namespace 'com.audiobookshelf.app'
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
viewBinding true
|
viewBinding true
|
||||||
|
buildConfig true
|
||||||
}
|
}
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
freeCompilerArgs = ['-Xjvm-default=all']
|
freeCompilerArgs = ['-Xjvm-default=all']
|
||||||
|
}
|
||||||
|
compileSdk rootProject.ext.compileSdkVersion
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "com.audiobookshelf.app"
|
||||||
|
minSdkVersion rootProject.ext.minSdkVersion
|
||||||
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
|
versionCode 108
|
||||||
|
versionName "0.9.77-beta"
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
manifestPlaceholders = [
|
||||||
|
"appAuthRedirectScheme": "com.audiobookshelf.app"
|
||||||
|
]
|
||||||
|
aaptOptions {
|
||||||
|
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
||||||
|
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
|
||||||
|
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
|
||||||
}
|
}
|
||||||
compileSdkVersion rootProject.ext.compileSdkVersion
|
}
|
||||||
defaultConfig {
|
buildTypes {
|
||||||
applicationId "com.audiobookshelf.app"
|
debug {
|
||||||
minSdkVersion rootProject.ext.minSdkVersion
|
applicationIdSuffix ".debug"
|
||||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
versionNameSuffix "-debug"
|
||||||
versionCode 95
|
minifyEnabled false
|
||||||
versionName "0.9.64-beta"
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
||||||
aaptOptions {
|
|
||||||
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
|
||||||
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
|
|
||||||
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
buildTypes {
|
release {
|
||||||
debug {
|
minifyEnabled false
|
||||||
applicationIdSuffix ".debug"
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
versionNameSuffix "-debug"
|
|
||||||
minifyEnabled false
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
||||||
}
|
|
||||||
release {
|
|
||||||
minifyEnabled false
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
flatDir{
|
flatDir {
|
||||||
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
|
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
|
||||||
}
|
}
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations.all {
|
configurations.configureEach {
|
||||||
resolutionStrategy {
|
resolutionStrategy {
|
||||||
force("com.google.android.gms:play-services-base:18.0.1")
|
force("com.google.android.gms:play-services-base:18.0.1")
|
||||||
force("androidx.appcompat:appcompat:$androidxAppCompatVersion")
|
force("androidx.appcompat:appcompat:$androidxAppCompatVersion")
|
||||||
force("androidx.core:core-ktx:$androidx_core_ktx_version")
|
force("androidx.core:core-ktx:$androidx_core_ktx_version")
|
||||||
force("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
|
|
||||||
force("androidx.media:media:$androidx_media_version")
|
force("androidx.media:media:$androidx_media_version")
|
||||||
force("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version")
|
force("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version")
|
||||||
force("org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version")
|
force("org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version")
|
||||||
@@ -78,22 +81,18 @@ configurations.all {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
|
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
||||||
implementation project(':capacitor-android')
|
implementation project(':capacitor-android')
|
||||||
|
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
|
||||||
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
|
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
|
||||||
|
|
||||||
// testImplementation "junit:junit:$junitVersion"
|
|
||||||
// androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
||||||
// androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
||||||
implementation project(':capacitor-cordova-android-plugins')
|
implementation project(':capacitor-cordova-android-plugins')
|
||||||
|
|
||||||
implementation "androidx.core:core-ktx:$androidx_core_ktx_version"
|
implementation "androidx.core:core-ktx:$androidx_core_ktx_version"
|
||||||
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
|
||||||
|
|
||||||
@@ -116,22 +115,18 @@ dependencies {
|
|||||||
|
|
||||||
// Glide for images
|
// Glide for images
|
||||||
implementation "com.github.bumptech.glide:glide:$glide_version"
|
implementation "com.github.bumptech.glide:glide:$glide_version"
|
||||||
kapt "com.github.bumptech.glide:compiler:$glide_version"
|
|
||||||
|
|
||||||
// Paper NoSQL Db
|
// Paper NoSQL Db
|
||||||
implementation 'io.github.pilgr:paperdb:2.7.2'
|
implementation 'io.github.pilgr:paperdb:2.7.2'
|
||||||
|
|
||||||
// Simple Storage
|
// Simple Storage
|
||||||
implementation "com.anggrayudi:storage:1.5.4"
|
implementation "com.anggrayudi:storage:1.5.6"
|
||||||
|
|
||||||
// OK HTTP
|
// OK HTTP
|
||||||
implementation 'com.squareup.okhttp3:okhttp:4.9.2'
|
implementation 'com.squareup.okhttp3:okhttp:4.9.2'
|
||||||
|
|
||||||
// Jackson for JSON
|
// Jackson for JSON
|
||||||
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.12.2'
|
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.12.2'
|
||||||
|
|
||||||
// FFMPEG-Kit
|
|
||||||
implementation 'com.arthenica:ffmpeg-kit-min:4.5.1'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: 'capacitor.build.gradle'
|
apply from: 'capacitor.build.gradle'
|
||||||
|
|||||||
@@ -2,14 +2,19 @@
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_11
|
sourceCompatibility JavaVersion.VERSION_17
|
||||||
targetCompatibility JavaVersion.VERSION_11
|
targetCompatibility JavaVersion.VERSION_17
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
|
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation project(':byteowls-capacitor-filesharer')
|
||||||
|
implementation project(':capacitor-community-keep-awake')
|
||||||
|
implementation project(':capacitor-community-volume-buttons')
|
||||||
implementation project(':capacitor-app')
|
implementation project(':capacitor-app')
|
||||||
|
implementation project(':capacitor-browser')
|
||||||
|
implementation project(':capacitor-clipboard')
|
||||||
implementation project(':capacitor-dialog')
|
implementation project(':capacitor-dialog')
|
||||||
implementation project(':capacitor-haptics')
|
implementation project(':capacitor-haptics')
|
||||||
implementation project(':capacitor-network')
|
implementation project(':capacitor-network')
|
||||||
|
|||||||
@@ -2,4 +2,5 @@
|
|||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<background android:drawable="@mipmap/ic_launcher_background"/>
|
<background android:drawable="@mipmap/ic_launcher_background"/>
|
||||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
</adaptive-icon>
|
<monochrome android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
|
</adaptive-icon>
|
||||||
|
|||||||
@@ -2,4 +2,5 @@
|
|||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<background android:drawable="@mipmap/ic_launcher_background"/>
|
<background android:drawable="@mipmap/ic_launcher_background"/>
|
||||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
</adaptive-icon>
|
<monochrome android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
|
</adaptive-icon>
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">Audiobookshelf</string>
|
||||||
|
<string name="title_activity_main">Audiobookshelf</string>
|
||||||
|
<string name="package_name">com.audiobookshelf.app</string>
|
||||||
|
<string name="custom_url_scheme">audiobookshelf</string>
|
||||||
|
<string name="add_widget">Add widget</string>
|
||||||
|
<string name="app_widget_description">Simple widget for audiobookshelf playback</string>
|
||||||
|
<string name="action_jump_forward">Jump Forward</string>
|
||||||
|
<string name="action_jump_backward">Jump Backward</string>
|
||||||
|
<string name="action_skip_forward">Skip Forward</string>
|
||||||
|
<string name="action_skip_backward">Skip Backward</string>
|
||||||
|
<string name="action_change_speed">Change Playback Speed</string>
|
||||||
|
</resources>
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
<!-- Permissions -->
|
<!-- Permissions -->
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||||
@@ -15,10 +16,10 @@
|
|||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:networkSecurityConfig="@xml/network_security_config"
|
android:networkSecurityConfig="@xml/network_security_config"
|
||||||
android:requestLegacyExternalStorage="true"
|
android:requestLegacyExternalStorage="true"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
@@ -92,6 +93,16 @@
|
|||||||
<action android:name="android.media.browse.MediaBrowserService" />
|
<action android:name="android.media.browse.MediaBrowserService" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<provider
|
||||||
|
android:name="androidx.core.content.FileProvider"
|
||||||
|
android:authorities="${applicationId}.fileprovider"
|
||||||
|
android:grantUriPermissions="true"
|
||||||
|
android:exported="false">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
|
android:resource="@xml/file_paths" />
|
||||||
|
</provider>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -2,5 +2,12 @@
|
|||||||
"appId": "com.audiobookshelf.app",
|
"appId": "com.audiobookshelf.app",
|
||||||
"appName": "audiobookshelf-app",
|
"appName": "audiobookshelf-app",
|
||||||
"webDir": "dist",
|
"webDir": "dist",
|
||||||
"bundledWebRuntime": false
|
"plugins": {
|
||||||
|
"CapacitorHttp": {
|
||||||
|
"enabled": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"server": {
|
||||||
|
"androidScheme": "http"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,28 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"pkg": "@byteowls/capacitor-filesharer",
|
||||||
|
"classpath": "com.byteowls.capacitor.filesharer.FileSharerPlugin"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pkg": "@capacitor-community/keep-awake",
|
||||||
|
"classpath": "com.getcapacitor.community.keepawake.KeepAwakePlugin"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pkg": "@capacitor-community/volume-buttons",
|
||||||
|
"classpath": "com.ryltsov.alex.plugins.volume.buttons.VolumeButtonsPlugin"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"pkg": "@capacitor/app",
|
"pkg": "@capacitor/app",
|
||||||
"classpath": "com.capacitorjs.plugins.app.AppPlugin"
|
"classpath": "com.capacitorjs.plugins.app.AppPlugin"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"pkg": "@capacitor/browser",
|
||||||
|
"classpath": "com.capacitorjs.plugins.browser.BrowserPlugin"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pkg": "@capacitor/clipboard",
|
||||||
|
"classpath": "com.capacitorjs.plugins.clipboard.ClipboardPlugin"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"pkg": "@capacitor/dialog",
|
"pkg": "@capacitor/dialog",
|
||||||
"classpath": "com.capacitorjs.plugins.dialog.DialogPlugin"
|
"classpath": "com.capacitorjs.plugins.dialog.DialogPlugin"
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ import android.util.Log
|
|||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import com.anggrayudi.storage.SimpleStorage
|
import com.anggrayudi.storage.SimpleStorage
|
||||||
import com.anggrayudi.storage.SimpleStorageHelper
|
import com.anggrayudi.storage.SimpleStorageHelper
|
||||||
import com.audiobookshelf.app.plugins.AbsDatabase
|
|
||||||
import com.audiobookshelf.app.managers.DbManager
|
import com.audiobookshelf.app.managers.DbManager
|
||||||
import com.audiobookshelf.app.player.PlayerNotificationService
|
import com.audiobookshelf.app.player.PlayerNotificationService
|
||||||
import com.audiobookshelf.app.plugins.AbsAudioPlayer
|
import com.audiobookshelf.app.plugins.AbsAudioPlayer
|
||||||
|
import com.audiobookshelf.app.plugins.AbsDatabase
|
||||||
import com.audiobookshelf.app.plugins.AbsDownloader
|
import com.audiobookshelf.app.plugins.AbsDownloader
|
||||||
import com.audiobookshelf.app.plugins.AbsFileSystem
|
import com.audiobookshelf.app.plugins.AbsFileSystem
|
||||||
import com.getcapacitor.BridgeActivity
|
import com.getcapacitor.BridgeActivity
|
||||||
@@ -103,6 +103,9 @@ class MainActivity : BridgeActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isPlayerNotificationServiceInitialized():Boolean {
|
||||||
|
return ::foregroundService.isInitialized
|
||||||
|
}
|
||||||
|
|
||||||
fun stopMyService() {
|
fun stopMyService() {
|
||||||
if (mBounded) {
|
if (mBounded) {
|
||||||
@@ -116,6 +119,7 @@ class MainActivity : BridgeActivity() {
|
|||||||
override fun onSaveInstanceState(outState: Bundle) {
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
storageHelper.onSaveInstanceState(outState)
|
storageHelper.onSaveInstanceState(outState)
|
||||||
super.onSaveInstanceState(outState)
|
super.onSaveInstanceState(outState)
|
||||||
|
outState.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
||||||
|
|||||||
@@ -15,9 +15,7 @@ import android.widget.RemoteViews
|
|||||||
import androidx.media.session.MediaButtonReceiver
|
import androidx.media.session.MediaButtonReceiver
|
||||||
import com.audiobookshelf.app.data.PlaybackSession
|
import com.audiobookshelf.app.data.PlaybackSession
|
||||||
import com.audiobookshelf.app.device.DeviceManager
|
import com.audiobookshelf.app.device.DeviceManager
|
||||||
import com.audiobookshelf.app.device.WidgetEventEmitter
|
|
||||||
import com.audiobookshelf.app.managers.DbManager
|
import com.audiobookshelf.app.managers.DbManager
|
||||||
import com.audiobookshelf.app.player.PlayerNotificationService
|
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.request.RequestOptions
|
import com.bumptech.glide.request.RequestOptions
|
||||||
import com.bumptech.glide.request.target.AppWidgetTarget
|
import com.bumptech.glide.request.target.AppWidgetTarget
|
||||||
@@ -28,12 +26,9 @@ import com.bumptech.glide.request.transition.Transition
|
|||||||
*/
|
*/
|
||||||
class MediaPlayerWidget : AppWidgetProvider() {
|
class MediaPlayerWidget : AppWidgetProvider() {
|
||||||
val tag = "MediaPlayerWidget"
|
val tag = "MediaPlayerWidget"
|
||||||
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
|
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
|
||||||
// There may be multiple widgets active, so update all of them
|
Log.d(tag, "onUpdate $appWidgetIds")
|
||||||
for (appWidgetId in appWidgetIds) {
|
}
|
||||||
updateAppWidget(context, appWidgetManager, appWidgetId, null, false, PlayerNotificationService.isClosed)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onEnabled(context: Context) {
|
override fun onEnabled(context: Context) {
|
||||||
Log.i(tag, "onEnabled check context ${context.packageName}")
|
Log.i(tag, "onEnabled check context ${context.packageName}")
|
||||||
@@ -51,32 +46,14 @@ class MediaPlayerWidget : AppWidgetProvider() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Enter relevant functionality for when the first widget is created
|
// Enter relevant functionality for when the first widget is created
|
||||||
DeviceManager.widgetUpdater = (object : WidgetEventEmitter {
|
DeviceManager.initializeWidgetUpdater(context)
|
||||||
override fun onPlayerChanged(pns: PlayerNotificationService) {
|
|
||||||
val isPlaying = pns.currentPlayer.isPlaying
|
|
||||||
|
|
||||||
val appWidgetManager = AppWidgetManager.getInstance(context)
|
|
||||||
val componentName = ComponentName(context, MediaPlayerWidget::class.java)
|
|
||||||
val ids = appWidgetManager.getAppWidgetIds(componentName)
|
|
||||||
|
|
||||||
val playbackSession = pns.getCurrentPlaybackSessionCopy()
|
|
||||||
|
|
||||||
for (widgetId in ids) {
|
|
||||||
updateAppWidget(context, appWidgetManager, widgetId, playbackSession, isPlaying, PlayerNotificationService.isClosed)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDisabled(context: Context) {
|
|
||||||
// Enter relevant functionality for when the last widget is disabled
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun updateAppWidget(context: Context, appWidgetManager: AppWidgetManager, appWidgetId: Int, playbackSession: PlaybackSession?, isPlaying:Boolean, isAppClosed:Boolean) {
|
internal fun updateAppWidget(context: Context, appWidgetManager: AppWidgetManager, appWidgetId: Int, playbackSession: PlaybackSession?, isPlaying:Boolean, isAppClosed:Boolean) {
|
||||||
val tag = "MediaPlayerWidget"
|
val tag = "MediaPlayerWidget"
|
||||||
val views = RemoteViews(context.packageName, R.layout.media_player_widget)
|
val views = RemoteViews(context.packageName, R.layout.media_player_widget)
|
||||||
|
Log.i(tag, "updateAppWidget ${playbackSession?.displayTitle ?: "No Title"} isPlaying=$isPlaying isAppClosed=$isAppClosed")
|
||||||
val wholeWidgetClickI = Intent(context, MainActivity::class.java)
|
val wholeWidgetClickI = Intent(context, MainActivity::class.java)
|
||||||
wholeWidgetClickI.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK
|
wholeWidgetClickI.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
val wholeWidgetClickPI = PendingIntent.getActivity(
|
val wholeWidgetClickPI = PendingIntent.getActivity(
|
||||||
@@ -100,7 +77,7 @@ internal fun updateAppWidget(context: Context, appWidgetManager: AppWidgetManage
|
|||||||
|
|
||||||
views.setOnClickPendingIntent(R.id.widgetBackground, wholeWidgetClickPI)
|
views.setOnClickPendingIntent(R.id.widgetBackground, wholeWidgetClickPI)
|
||||||
|
|
||||||
val imageUri = playbackSession?.getCoverUri() ?: Uri.parse("android.resource://${BuildConfig.APPLICATION_ID}/" + R.drawable.icon)
|
val imageUri = playbackSession?.getCoverUri(context) ?: Uri.parse("android.resource://${BuildConfig.APPLICATION_ID}/" + R.drawable.icon)
|
||||||
val awt: AppWidgetTarget = object : AppWidgetTarget(context.applicationContext, R.id.widgetAlbumArt, views, appWidgetId) {
|
val awt: AppWidgetTarget = object : AppWidgetTarget(context.applicationContext, R.id.widgetAlbumArt, views, appWidgetId) {
|
||||||
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
|
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
|
||||||
super.onResourceReady(resource, transition)
|
super.onResourceReady(resource, transition)
|
||||||
@@ -118,7 +95,7 @@ internal fun updateAppWidget(context: Context, appWidgetManager: AppWidgetManage
|
|||||||
|
|
||||||
Log.i(tag, "Update App Widget | Is Playing=$isPlaying | isAppClosed=$isAppClosed")
|
Log.i(tag, "Update App Widget | Is Playing=$isPlaying | isAppClosed=$isAppClosed")
|
||||||
|
|
||||||
val playPauseResource = if (isPlaying) R.drawable.ic_media_pause_dark else R.drawable.ic_media_play_dark
|
val playPauseResource = if (isPlaying) androidx.mediarouter.R.drawable.ic_media_pause_dark else androidx.mediarouter.R.drawable.ic_media_play_dark
|
||||||
views.setImageViewResource(R.id.widgetPlayPauseButton, playPauseResource)
|
views.setImageViewResource(R.id.widgetPlayPauseButton, playPauseResource)
|
||||||
|
|
||||||
// Instruct the widget manager to update the widget
|
// Instruct the widget manager to update the widget
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.audiobookshelf.app.data
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.support.v4.media.MediaDescriptionCompat
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
class CollapsedSeries(
|
||||||
|
id:String,
|
||||||
|
var libraryId:String?,
|
||||||
|
var name:String,
|
||||||
|
//var nameIgnorePrefix:String,
|
||||||
|
var sequence:String?,
|
||||||
|
var libraryItemIds:MutableList<String>
|
||||||
|
) : LibraryItemWrapper(id) {
|
||||||
|
@get:JsonIgnore
|
||||||
|
val title get() = name
|
||||||
|
@get:JsonIgnore
|
||||||
|
val numBooks get() = libraryItemIds.size
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
override fun getMediaDescription(progress:MediaProgressWrapper?, ctx: Context): MediaDescriptionCompat {
|
||||||
|
val extras = Bundle()
|
||||||
|
|
||||||
|
val mediaId = "__LIBRARY__${libraryId}__SERIE__${id}"
|
||||||
|
return MediaDescriptionCompat.Builder()
|
||||||
|
.setMediaId(mediaId)
|
||||||
|
.setTitle(title)
|
||||||
|
//.setIconUri(getCoverUri())
|
||||||
|
.setSubtitle("${numBooks} books")
|
||||||
|
.setExtras(extras)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,15 @@
|
|||||||
package com.audiobookshelf.app.data
|
package com.audiobookshelf.app.data
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.icu.text.DateFormat
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v4.media.MediaDescriptionCompat
|
import android.support.v4.media.MediaDescriptionCompat
|
||||||
import android.support.v4.media.MediaMetadataCompat
|
import android.support.v4.media.MediaMetadataCompat
|
||||||
import androidx.media.utils.MediaConstants
|
import androidx.media.utils.MediaConstants
|
||||||
import com.audiobookshelf.app.media.MediaManager
|
import com.audiobookshelf.app.media.MediaManager
|
||||||
import com.fasterxml.jackson.annotation.*
|
import com.fasterxml.jackson.annotation.*
|
||||||
|
import com.audiobookshelf.app.media.getUriToAbsIconDrawable
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
// This auto-detects whether it is a Book or Podcast
|
// This auto-detects whether it is a Book or Podcast
|
||||||
@JsonTypeInfo(use=JsonTypeInfo.Id.DEDUCTION)
|
@JsonTypeInfo(use=JsonTypeInfo.Id.DEDUCTION)
|
||||||
@@ -24,8 +27,9 @@ open class MediaType(var metadata:MediaTypeMetadata, var coverPath:String?) {
|
|||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
open fun removeAudioTrack(localFileId:String) { }
|
open fun removeAudioTrack(localFileId:String) { }
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
open fun getLocalCopy():MediaType { return MediaType(MediaTypeMetadata(""),null) }
|
open fun getLocalCopy():MediaType { return MediaType(MediaTypeMetadata("", false),null) }
|
||||||
|
@JsonIgnore
|
||||||
|
open fun checkHasTracks():Boolean { return false }
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
@@ -53,7 +57,7 @@ class Podcast(
|
|||||||
audioTracks.forEach { at ->
|
audioTracks.forEach { at ->
|
||||||
if (episodes?.find{ it.audioTrack?.localFileId == at.localFileId } == null) {
|
if (episodes?.find{ it.audioTrack?.localFileId == at.localFileId } == null) {
|
||||||
val localEpisodeId = "local_ep_" + at.localFileId
|
val localEpisodeId = "local_ep_" + at.localFileId
|
||||||
val newEpisode = PodcastEpisode(localEpisodeId,(episodes?.size ?: 0) + 1,null,null,at.title,null,null,null, null, null, at,at.duration,0, null, localEpisodeId)
|
val newEpisode = PodcastEpisode(localEpisodeId,(episodes?.size ?: 0) + 1,null,null,at.title,null,null,null, null, null, at,null,at.duration,0, null, localEpisodeId)
|
||||||
episodes?.add(newEpisode)
|
episodes?.add(newEpisode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,7 +71,7 @@ class Podcast(
|
|||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
override fun addAudioTrack(audioTrack:AudioTrack) {
|
override fun addAudioTrack(audioTrack:AudioTrack) {
|
||||||
val localEpisodeId = "local_ep_" + audioTrack.localFileId
|
val localEpisodeId = "local_ep_" + audioTrack.localFileId
|
||||||
val newEpisode = PodcastEpisode(localEpisodeId,(episodes?.size ?: 0) + 1,null,null,audioTrack.title,null,null,null, null, null,audioTrack,audioTrack.duration,0, null, localEpisodeId)
|
val newEpisode = PodcastEpisode(localEpisodeId,(episodes?.size ?: 0) + 1,null,null,audioTrack.title,null,null,null, null, null,audioTrack,null,audioTrack.duration,0, null, localEpisodeId)
|
||||||
episodes?.add(newEpisode)
|
episodes?.add(newEpisode)
|
||||||
|
|
||||||
var index = 1
|
var index = 1
|
||||||
@@ -93,10 +97,15 @@ class Podcast(
|
|||||||
return Podcast(metadata as PodcastMetadata,coverPath,tags, mutableListOf(),autoDownloadEpisodes, 0)
|
return Podcast(metadata as PodcastMetadata,coverPath,tags, mutableListOf(),autoDownloadEpisodes, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
override fun checkHasTracks():Boolean {
|
||||||
|
return (episodes?.size ?: numEpisodes ?: 0) > 0
|
||||||
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
fun addEpisode(audioTrack:AudioTrack, episode:PodcastEpisode):PodcastEpisode {
|
fun addEpisode(audioTrack:AudioTrack, episode:PodcastEpisode):PodcastEpisode {
|
||||||
val localEpisodeId = "local_ep_" + episode.id
|
val localEpisodeId = "local_ep_" + episode.id
|
||||||
val newEpisode = PodcastEpisode(localEpisodeId,(episodes?.size ?: 0) + 1,episode.episode,episode.episodeType,episode.title,episode.subtitle,episode.description,null,null,null,audioTrack,audioTrack.duration,0, episode.id, localEpisodeId)
|
val newEpisode = PodcastEpisode(localEpisodeId,(episodes?.size ?: 0) + 1,episode.episode,episode.episodeType,episode.title,episode.subtitle,episode.description,null,null,null,audioTrack,episode.chapters,audioTrack.duration,episode.size, episode.id, localEpisodeId)
|
||||||
episodes?.add(newEpisode)
|
episodes?.add(newEpisode)
|
||||||
|
|
||||||
var index = 1
|
var index = 1
|
||||||
@@ -182,6 +191,11 @@ class Book(
|
|||||||
override fun getLocalCopy(): Book {
|
override fun getLocalCopy(): Book {
|
||||||
return Book(metadata as BookMetadata,coverPath,tags, mutableListOf(),chapters,mutableListOf(), ebookFile, null,null, 0)
|
return Book(metadata as BookMetadata,coverPath,tags, mutableListOf(),chapters,mutableListOf(), ebookFile, null,null, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
override fun checkHasTracks():Boolean {
|
||||||
|
return (tracks?.size ?: numTracks ?: 0) > 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This auto-detects whether it is a BookMetadata or PodcastMetadata
|
// This auto-detects whether it is a BookMetadata or PodcastMetadata
|
||||||
@@ -190,7 +204,7 @@ class Book(
|
|||||||
JsonSubTypes.Type(BookMetadata::class),
|
JsonSubTypes.Type(BookMetadata::class),
|
||||||
JsonSubTypes.Type(PodcastMetadata::class)
|
JsonSubTypes.Type(PodcastMetadata::class)
|
||||||
)
|
)
|
||||||
open class MediaTypeMetadata(var title:String) {
|
open class MediaTypeMetadata(var title:String, var explicit:Boolean) {
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
open fun getAuthorDisplayName():String { return "Unknown" }
|
open fun getAuthorDisplayName():String { return "Unknown" }
|
||||||
}
|
}
|
||||||
@@ -209,13 +223,15 @@ class BookMetadata(
|
|||||||
var isbn:String?,
|
var isbn:String?,
|
||||||
var asin:String?,
|
var asin:String?,
|
||||||
var language:String?,
|
var language:String?,
|
||||||
var explicit:Boolean,
|
explicit:Boolean,
|
||||||
// In toJSONExpanded
|
// In toJSONExpanded
|
||||||
var authorName:String?,
|
var authorName:String?,
|
||||||
var authorNameLF:String?,
|
var authorNameLF:String?,
|
||||||
var narratorName:String?,
|
var narratorName:String?,
|
||||||
var seriesName:String?
|
var seriesName:String?,
|
||||||
) : MediaTypeMetadata(title) {
|
@JsonFormat(with=[JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY])
|
||||||
|
var series:List<SeriesType>?
|
||||||
|
) : MediaTypeMetadata(title, explicit) {
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
override fun getAuthorDisplayName():String { return authorName ?: "Unknown" }
|
override fun getAuthorDisplayName():String { return authorName ?: "Unknown" }
|
||||||
}
|
}
|
||||||
@@ -225,8 +241,9 @@ class PodcastMetadata(
|
|||||||
title:String,
|
title:String,
|
||||||
var author:String?,
|
var author:String?,
|
||||||
var feedUrl:String?,
|
var feedUrl:String?,
|
||||||
var genres:MutableList<String>
|
var genres:MutableList<String>,
|
||||||
) : MediaTypeMetadata(title) {
|
explicit:Boolean
|
||||||
|
) : MediaTypeMetadata(title, explicit) {
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
override fun getAuthorDisplayName():String { return author ?: "Unknown" }
|
override fun getAuthorDisplayName():String { return author ?: "Unknown" }
|
||||||
}
|
}
|
||||||
@@ -251,15 +268,16 @@ data class PodcastEpisode(
|
|||||||
var publishedAt:Long?,
|
var publishedAt:Long?,
|
||||||
var audioFile:AudioFile?,
|
var audioFile:AudioFile?,
|
||||||
var audioTrack:AudioTrack?,
|
var audioTrack:AudioTrack?,
|
||||||
|
var chapters:List<BookChapter>?,
|
||||||
var duration:Double?,
|
var duration:Double?,
|
||||||
var size:Long?,
|
var size:Long?,
|
||||||
var serverEpisodeId:String?, // For local podcasts to match with server podcasts
|
var serverEpisodeId:String?, // For local podcasts to match with server podcasts
|
||||||
var localEpisodeId:String? // For Android Auto server episodes with local copy
|
var localEpisodeId:String? // For Android Auto server episodes with local copy
|
||||||
) {
|
) {
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
fun getMediaDescription(libraryItem:LibraryItemWrapper, progress:MediaProgressWrapper?, ctx: Context?): MediaDescriptionCompat {
|
fun getMediaDescription(libraryItem:LibraryItemWrapper, progress:MediaProgressWrapper?, ctx: Context): MediaDescriptionCompat {
|
||||||
val coverUri = if (libraryItem is LocalLibraryItem) {
|
val coverUri = if (libraryItem is LocalLibraryItem) {
|
||||||
libraryItem.getCoverUri()
|
libraryItem.getCoverUri(ctx)
|
||||||
} else {
|
} else {
|
||||||
(libraryItem as LibraryItem).getCoverUri()
|
(libraryItem as LibraryItem).getCoverUri()
|
||||||
}
|
}
|
||||||
@@ -297,11 +315,18 @@ data class PodcastEpisode(
|
|||||||
|
|
||||||
val libraryItemDescription = libraryItem.getMediaDescription(null, ctx)
|
val libraryItemDescription = libraryItem.getMediaDescription(null, ctx)
|
||||||
val mediaId = localEpisodeId ?: id
|
val mediaId = localEpisodeId ?: id
|
||||||
|
var subtitle = libraryItemDescription.title
|
||||||
|
if (publishedAt !== null) {
|
||||||
|
val sdf = DateFormat.getDateInstance()
|
||||||
|
val publishedAtDT = Date(publishedAt!!)
|
||||||
|
subtitle = "${sdf.format(publishedAtDT)} / $subtitle"
|
||||||
|
}
|
||||||
|
|
||||||
val mediaDescriptionBuilder = MediaDescriptionCompat.Builder()
|
val mediaDescriptionBuilder = MediaDescriptionCompat.Builder()
|
||||||
.setMediaId(mediaId)
|
.setMediaId(mediaId)
|
||||||
.setTitle(title)
|
.setTitle(title)
|
||||||
.setIconUri(coverUri)
|
.setIconUri(coverUri)
|
||||||
.setSubtitle(libraryItemDescription.title)
|
.setSubtitle(subtitle)
|
||||||
.setExtras(extras)
|
.setExtras(extras)
|
||||||
|
|
||||||
libraryItemDescription.iconBitmap?.let {
|
libraryItemDescription.iconBitmap?.let {
|
||||||
@@ -340,18 +365,39 @@ data class Library(
|
|||||||
var name:String,
|
var name:String,
|
||||||
var folders:MutableList<Folder>,
|
var folders:MutableList<Folder>,
|
||||||
var icon:String,
|
var icon:String,
|
||||||
var mediaType:String
|
var mediaType:String,
|
||||||
|
var stats: LibraryStats?
|
||||||
) {
|
) {
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
fun getMediaMetadata(): MediaMetadataCompat {
|
fun getMediaMetadata(context: Context, targetType: String? = null): MediaMetadataCompat {
|
||||||
|
var mediaId = id
|
||||||
|
if (targetType !== null) {
|
||||||
|
mediaId = "__RECENTLY__$id"
|
||||||
|
}
|
||||||
return MediaMetadataCompat.Builder().apply {
|
return MediaMetadataCompat.Builder().apply {
|
||||||
putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, id)
|
putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, mediaId)
|
||||||
putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, name)
|
putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, name)
|
||||||
putString(MediaMetadataCompat.METADATA_KEY_TITLE, name)
|
putString(MediaMetadataCompat.METADATA_KEY_TITLE, name)
|
||||||
|
putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI, getUriToAbsIconDrawable(context, icon).toString())
|
||||||
}.build()
|
}.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
data class LibraryStats(
|
||||||
|
var totalItems: Int,
|
||||||
|
var totalSize: Long,
|
||||||
|
var totalDuration: Double,
|
||||||
|
var numAudioFiles: Int
|
||||||
|
)
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
data class SeriesType(
|
||||||
|
var id: String,
|
||||||
|
var name: String,
|
||||||
|
var sequence: String?
|
||||||
|
)
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
data class Folder(
|
data class Folder(
|
||||||
var id:String,
|
var id:String,
|
||||||
@@ -385,3 +431,84 @@ data class LibraryItemWithEpisode(
|
|||||||
var libraryItemWrapper:LibraryItemWrapper,
|
var libraryItemWrapper:LibraryItemWrapper,
|
||||||
var episode:PodcastEpisode
|
var episode:PodcastEpisode
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
data class LibraryItemSearchResultSeriesItemType(
|
||||||
|
var series: LibrarySeriesItem,
|
||||||
|
var books: List<LibraryItem>?
|
||||||
|
)
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
data class LibraryItemSearchResultLibraryItemType(
|
||||||
|
val libraryItem: LibraryItem
|
||||||
|
)
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
data class LibraryItemSearchResultType(
|
||||||
|
var book:List<LibraryItemSearchResultLibraryItemType>?,
|
||||||
|
var podcast:List<LibraryItemSearchResultLibraryItemType>?,
|
||||||
|
var series:List<LibraryItemSearchResultSeriesItemType>?,
|
||||||
|
var authors:List<LibraryAuthorItem>?
|
||||||
|
)
|
||||||
|
|
||||||
|
// For personalized shelves
|
||||||
|
@JsonTypeInfo(
|
||||||
|
use=JsonTypeInfo.Id.NAME,
|
||||||
|
property = "type",
|
||||||
|
include = JsonTypeInfo.As.PROPERTY,
|
||||||
|
visible = true
|
||||||
|
)
|
||||||
|
@JsonSubTypes(
|
||||||
|
JsonSubTypes.Type(LibraryShelfBookEntity::class, name = "book"),
|
||||||
|
JsonSubTypes.Type(LibraryShelfSeriesEntity::class, name = "series"),
|
||||||
|
JsonSubTypes.Type(LibraryShelfAuthorEntity::class, name = "authors"),
|
||||||
|
JsonSubTypes.Type(LibraryShelfEpisodeEntity::class, name = "episode"),
|
||||||
|
JsonSubTypes.Type(LibraryShelfPodcastEntity::class, name = "podcast")
|
||||||
|
)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
sealed class LibraryShelfType(
|
||||||
|
open val id: String,
|
||||||
|
open val label: String,
|
||||||
|
open val total: Int,
|
||||||
|
open val type: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
data class LibraryShelfBookEntity(
|
||||||
|
override val id: String,
|
||||||
|
override val label: String,
|
||||||
|
override val total: Int,
|
||||||
|
override val type: String,
|
||||||
|
val entities: List<LibraryItem>?
|
||||||
|
) : LibraryShelfType(id, label, total, type)
|
||||||
|
|
||||||
|
data class LibraryShelfSeriesEntity(
|
||||||
|
override val id: String,
|
||||||
|
override val label: String,
|
||||||
|
override val total: Int,
|
||||||
|
override val type: String,
|
||||||
|
val entities: List<LibrarySeriesItem>?
|
||||||
|
) : LibraryShelfType(id, label, total, type)
|
||||||
|
|
||||||
|
data class LibraryShelfAuthorEntity(
|
||||||
|
override val id: String,
|
||||||
|
override val label: String,
|
||||||
|
override val total: Int,
|
||||||
|
override val type: String,
|
||||||
|
val entities: List<LibraryAuthorItem>?
|
||||||
|
) : LibraryShelfType(id, label, total, type)
|
||||||
|
|
||||||
|
data class LibraryShelfEpisodeEntity(
|
||||||
|
override val id: String,
|
||||||
|
override val label: String,
|
||||||
|
override val total: Int,
|
||||||
|
override val type: String,
|
||||||
|
val entities: List<LibraryItem>?
|
||||||
|
) : LibraryShelfType(id, label, total, type)
|
||||||
|
|
||||||
|
data class LibraryShelfPodcastEntity(
|
||||||
|
override val id: String,
|
||||||
|
override val label: String,
|
||||||
|
override val total: Int,
|
||||||
|
override val type: String,
|
||||||
|
val entities: List<LibraryItem>?
|
||||||
|
) : LibraryShelfType(id, label, total, type)
|
||||||
|
|||||||
@@ -20,6 +20,18 @@ enum class ShakeSensitivitySetting {
|
|||||||
VERY_LOW, LOW, MEDIUM, HIGH, VERY_HIGH
|
VERY_LOW, LOW, MEDIUM, HIGH, VERY_HIGH
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class DownloadUsingCellularSetting {
|
||||||
|
ASK, ALWAYS, NEVER
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class StreamingUsingCellularSetting {
|
||||||
|
ASK, ALWAYS, NEVER
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class AndroidAutoBrowseSeriesSequenceOrderSetting {
|
||||||
|
ASC, DESC
|
||||||
|
}
|
||||||
|
|
||||||
data class ServerConnectionConfig(
|
data class ServerConnectionConfig(
|
||||||
var id:String,
|
var id:String,
|
||||||
var index:Int,
|
var index:Int,
|
||||||
@@ -83,7 +95,7 @@ data class LocalFolder(
|
|||||||
)
|
)
|
||||||
open class LibraryItemWrapper(var id:String) {
|
open class LibraryItemWrapper(var id:String) {
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
open fun getMediaDescription(progress:MediaProgressWrapper?, ctx: Context?): MediaDescriptionCompat { return MediaDescriptionCompat.Builder().build() }
|
open fun getMediaDescription(progress:MediaProgressWrapper?, ctx: Context): MediaDescriptionCompat { return MediaDescriptionCompat.Builder().build() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
@@ -91,7 +103,6 @@ data class DeviceInfo(
|
|||||||
var deviceId:String,
|
var deviceId:String,
|
||||||
var manufacturer:String,
|
var manufacturer:String,
|
||||||
var model:String,
|
var model:String,
|
||||||
var brand:String,
|
|
||||||
var sdkVersion:Int,
|
var sdkVersion:Int,
|
||||||
var clientVersion: String
|
var clientVersion: String
|
||||||
)
|
)
|
||||||
@@ -108,8 +119,10 @@ data class PlayItemRequestPayload(
|
|||||||
data class DeviceSettings(
|
data class DeviceSettings(
|
||||||
var disableAutoRewind:Boolean,
|
var disableAutoRewind:Boolean,
|
||||||
var enableAltView:Boolean,
|
var enableAltView:Boolean,
|
||||||
|
var allowSeekingOnMediaControls:Boolean,
|
||||||
var jumpBackwardsTime:Int,
|
var jumpBackwardsTime:Int,
|
||||||
var jumpForwardTime:Int,
|
var jumpForwardTime:Int,
|
||||||
|
var enableMp3IndexSeeking:Boolean,
|
||||||
var disableShakeToResetSleepTimer:Boolean,
|
var disableShakeToResetSleepTimer:Boolean,
|
||||||
var shakeSensitivity: ShakeSensitivitySetting,
|
var shakeSensitivity: ShakeSensitivitySetting,
|
||||||
var lockOrientation: LockOrientationSetting,
|
var lockOrientation: LockOrientationSetting,
|
||||||
@@ -121,7 +134,12 @@ data class DeviceSettings(
|
|||||||
var autoSleepTimerAutoRewindTime: Long, //Time in milliseconds
|
var autoSleepTimerAutoRewindTime: Long, //Time in milliseconds
|
||||||
var sleepTimerLength: Long, // Time in milliseconds
|
var sleepTimerLength: Long, // Time in milliseconds
|
||||||
var disableSleepTimerFadeOut: Boolean,
|
var disableSleepTimerFadeOut: Boolean,
|
||||||
var disableSleepTimerResetFeedback: Boolean
|
var disableSleepTimerResetFeedback: Boolean,
|
||||||
|
var languageCode: String,
|
||||||
|
var downloadUsingCellular: DownloadUsingCellularSetting,
|
||||||
|
var streamingUsingCellular: StreamingUsingCellularSetting,
|
||||||
|
var androidAutoBrowseLimitForGrouping: Int,
|
||||||
|
var androidAutoBrowseSeriesSequenceOrder: AndroidAutoBrowseSeriesSequenceOrderSetting
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
// Static method to get default device settings
|
// Static method to get default device settings
|
||||||
@@ -129,8 +147,10 @@ data class DeviceSettings(
|
|||||||
return DeviceSettings(
|
return DeviceSettings(
|
||||||
disableAutoRewind = false,
|
disableAutoRewind = false,
|
||||||
enableAltView = true,
|
enableAltView = true,
|
||||||
|
allowSeekingOnMediaControls = false,
|
||||||
jumpBackwardsTime = 10,
|
jumpBackwardsTime = 10,
|
||||||
jumpForwardTime = 10,
|
jumpForwardTime = 10,
|
||||||
|
enableMp3IndexSeeking = false,
|
||||||
disableShakeToResetSleepTimer = false,
|
disableShakeToResetSleepTimer = false,
|
||||||
shakeSensitivity = ShakeSensitivitySetting.MEDIUM,
|
shakeSensitivity = ShakeSensitivitySetting.MEDIUM,
|
||||||
lockOrientation = LockOrientationSetting.NONE,
|
lockOrientation = LockOrientationSetting.NONE,
|
||||||
@@ -142,7 +162,12 @@ data class DeviceSettings(
|
|||||||
autoSleepTimerAutoRewind = false,
|
autoSleepTimerAutoRewind = false,
|
||||||
autoSleepTimerAutoRewindTime = 300000L, // 5 minutes
|
autoSleepTimerAutoRewindTime = 300000L, // 5 minutes
|
||||||
disableSleepTimerFadeOut = false,
|
disableSleepTimerFadeOut = false,
|
||||||
disableSleepTimerResetFeedback = false
|
disableSleepTimerResetFeedback = false,
|
||||||
|
languageCode = "en-us",
|
||||||
|
downloadUsingCellular = DownloadUsingCellularSetting.ALWAYS,
|
||||||
|
streamingUsingCellular = StreamingUsingCellularSetting.ALWAYS,
|
||||||
|
androidAutoBrowseLimitForGrouping = 100,
|
||||||
|
androidAutoBrowseSeriesSequenceOrder = AndroidAutoBrowseSeriesSequenceOrderSetting.ASC
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package com.audiobookshelf.app.data
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.net.Uri
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.support.v4.media.MediaDescriptionCompat
|
||||||
|
import androidx.media.utils.MediaConstants
|
||||||
|
import com.audiobookshelf.app.BuildConfig
|
||||||
|
import com.audiobookshelf.app.R
|
||||||
|
import com.audiobookshelf.app.device.DeviceManager
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
class LibraryAuthorItem(
|
||||||
|
id:String,
|
||||||
|
var libraryId:String,
|
||||||
|
var name:String,
|
||||||
|
var description:String?,
|
||||||
|
var imagePath:String?,
|
||||||
|
var addedAt:Long,
|
||||||
|
var updatedAt:Long,
|
||||||
|
var numBooks:Int?,
|
||||||
|
var libraryItems:MutableList<LibraryItem>?,
|
||||||
|
var series:MutableList<LibrarySeriesItem>?
|
||||||
|
) : LibraryItemWrapper(id) {
|
||||||
|
@get:JsonIgnore
|
||||||
|
val title get() = name
|
||||||
|
|
||||||
|
@get:JsonIgnore
|
||||||
|
val bookCount get() = if (numBooks != null) numBooks else libraryItems!!.size
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
fun getPortraitUri(): Uri {
|
||||||
|
if (imagePath == null) {
|
||||||
|
return Uri.parse("android.resource://${BuildConfig.APPLICATION_ID}/" + R.drawable.md_account_outline)
|
||||||
|
}
|
||||||
|
|
||||||
|
return Uri.parse("${DeviceManager.serverAddress}/api/authors/$id/image?token=${DeviceManager.token}")
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
fun getMediaDescription(progress:MediaProgressWrapper?, ctx: Context, groupTitle: String?): MediaDescriptionCompat {
|
||||||
|
val extras = Bundle()
|
||||||
|
if (groupTitle !== null) {
|
||||||
|
extras.putString(MediaConstants.DESCRIPTION_EXTRAS_KEY_CONTENT_STYLE_GROUP_TITLE, groupTitle)
|
||||||
|
}
|
||||||
|
|
||||||
|
val mediaId = "__LIBRARY__${libraryId}__AUTHOR__${id}"
|
||||||
|
return MediaDescriptionCompat.Builder()
|
||||||
|
.setMediaId(mediaId)
|
||||||
|
.setTitle(title)
|
||||||
|
.setIconUri(getPortraitUri())
|
||||||
|
.setSubtitle("${bookCount} books")
|
||||||
|
.setExtras(extras)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
override fun getMediaDescription(progress:MediaProgressWrapper?, ctx: Context): MediaDescriptionCompat {
|
||||||
|
return getMediaDescription(progress, ctx, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.audiobookshelf.app.data
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.support.v4.media.MediaDescriptionCompat
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
class LibraryCollection(
|
||||||
|
id:String,
|
||||||
|
var libraryId:String,
|
||||||
|
var name:String,
|
||||||
|
//var userId:String?,
|
||||||
|
var description:String?,
|
||||||
|
var books:MutableList<LibraryItem>?,
|
||||||
|
) : LibraryItemWrapper(id) {
|
||||||
|
@get:JsonIgnore
|
||||||
|
val title get() = name
|
||||||
|
|
||||||
|
@get:JsonIgnore
|
||||||
|
val bookCount get() = if (books != null) books!!.size else 0
|
||||||
|
|
||||||
|
@get:JsonIgnore
|
||||||
|
val audiobookCount get() = books?.filter { book -> (book.media as Book).getAudioTracks().isNotEmpty() }?.size ?: 0
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
override fun getMediaDescription(progress:MediaProgressWrapper?, ctx: Context): MediaDescriptionCompat {
|
||||||
|
val extras = Bundle()
|
||||||
|
|
||||||
|
val mediaId = "__LIBRARY__${libraryId}__COLLECTION__${id}"
|
||||||
|
return MediaDescriptionCompat.Builder()
|
||||||
|
.setMediaId(mediaId)
|
||||||
|
.setTitle(title)
|
||||||
|
//.setIconUri(getCoverUri())
|
||||||
|
.setSubtitle("${bookCount} books")
|
||||||
|
.setExtras(extras)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,10 +32,18 @@ class LibraryItem(
|
|||||||
var media:MediaType,
|
var media:MediaType,
|
||||||
var libraryFiles:MutableList<LibraryFile>?,
|
var libraryFiles:MutableList<LibraryFile>?,
|
||||||
var userMediaProgress:MediaProgress?, // Only included when requesting library item with progress (for downloads)
|
var userMediaProgress:MediaProgress?, // Only included when requesting library item with progress (for downloads)
|
||||||
var localLibraryItemId:String? // For Android Auto
|
var collapsedSeries: CollapsedSeries?,
|
||||||
|
var localLibraryItemId:String?, // For Android Auto
|
||||||
|
val recentEpisode: PodcastEpisode? // Podcast episode shelf uses this
|
||||||
) : LibraryItemWrapper(id) {
|
) : LibraryItemWrapper(id) {
|
||||||
@get:JsonIgnore
|
@get:JsonIgnore
|
||||||
val title get() = media.metadata.title
|
val title: String
|
||||||
|
get() {
|
||||||
|
if (collapsedSeries != null) {
|
||||||
|
return collapsedSeries!!.title
|
||||||
|
}
|
||||||
|
return media.metadata.title
|
||||||
|
}
|
||||||
@get:JsonIgnore
|
@get:JsonIgnore
|
||||||
val authorName get() = media.metadata.getAuthorDisplayName()
|
val authorName get() = media.metadata.getAuthorDisplayName()
|
||||||
|
|
||||||
@@ -50,53 +58,116 @@ class LibraryItem(
|
|||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
fun checkHasTracks():Boolean {
|
fun checkHasTracks():Boolean {
|
||||||
return if (mediaType == "podcast") {
|
return media.checkHasTracks()
|
||||||
((media as Podcast).numEpisodes ?: 0) > 0
|
|
||||||
} else {
|
|
||||||
((media as Book).numTracks ?: 0) > 0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@get:JsonIgnore
|
||||||
|
val seriesSequence: String
|
||||||
|
get() {
|
||||||
|
if (mediaType != "podcast") {
|
||||||
|
return ((media as Book).metadata as BookMetadata).series?.get(0)?.sequence.orEmpty()
|
||||||
|
} else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@get:JsonIgnore
|
||||||
|
val seriesSequenceParts: List<String>
|
||||||
|
get() {
|
||||||
|
if (seriesSequence.isEmpty()) {
|
||||||
|
return listOf("")
|
||||||
|
}
|
||||||
|
return seriesSequence.split(".", limit = 2)
|
||||||
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
override fun getMediaDescription(progress:MediaProgressWrapper?, ctx: Context?): MediaDescriptionCompat {
|
fun getMediaDescription(progress:MediaProgressWrapper?, ctx: Context, authorId: String?, showSeriesNumber: Boolean?, groupTitle: String?): MediaDescriptionCompat {
|
||||||
val extras = Bundle()
|
val extras = Bundle()
|
||||||
|
|
||||||
if (localLibraryItemId != null) {
|
if (collapsedSeries == null) {
|
||||||
extras.putLong(
|
if (localLibraryItemId != null) {
|
||||||
MediaDescriptionCompat.EXTRA_DOWNLOAD_STATUS,
|
extras.putLong(
|
||||||
MediaDescriptionCompat.STATUS_DOWNLOADED
|
MediaDescriptionCompat.EXTRA_DOWNLOAD_STATUS,
|
||||||
)
|
MediaDescriptionCompat.STATUS_DOWNLOADED
|
||||||
}
|
|
||||||
|
|
||||||
if (progress != null) {
|
|
||||||
if (progress.isFinished) {
|
|
||||||
extras.putInt(
|
|
||||||
MediaConstants.DESCRIPTION_EXTRAS_KEY_COMPLETION_STATUS,
|
|
||||||
MediaConstants.DESCRIPTION_EXTRAS_VALUE_COMPLETION_STATUS_FULLY_PLAYED
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
extras.putInt(
|
|
||||||
MediaConstants.DESCRIPTION_EXTRAS_KEY_COMPLETION_STATUS,
|
|
||||||
MediaConstants.DESCRIPTION_EXTRAS_VALUE_COMPLETION_STATUS_PARTIALLY_PLAYED
|
|
||||||
)
|
|
||||||
extras.putDouble(
|
|
||||||
MediaConstants.DESCRIPTION_EXTRAS_KEY_COMPLETION_PERCENTAGE, progress.progress
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else if (mediaType != "podcast") {
|
|
||||||
extras.putInt(
|
if (progress != null) {
|
||||||
MediaConstants.DESCRIPTION_EXTRAS_KEY_COMPLETION_STATUS,
|
if (progress.isFinished) {
|
||||||
MediaConstants.DESCRIPTION_EXTRAS_VALUE_COMPLETION_STATUS_NOT_PLAYED
|
extras.putInt(
|
||||||
)
|
MediaConstants.DESCRIPTION_EXTRAS_KEY_COMPLETION_STATUS,
|
||||||
|
MediaConstants.DESCRIPTION_EXTRAS_VALUE_COMPLETION_STATUS_FULLY_PLAYED
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
extras.putInt(
|
||||||
|
MediaConstants.DESCRIPTION_EXTRAS_KEY_COMPLETION_STATUS,
|
||||||
|
MediaConstants.DESCRIPTION_EXTRAS_VALUE_COMPLETION_STATUS_PARTIALLY_PLAYED
|
||||||
|
)
|
||||||
|
extras.putDouble(
|
||||||
|
MediaConstants.DESCRIPTION_EXTRAS_KEY_COMPLETION_PERCENTAGE, progress.progress
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else if (mediaType != "podcast") {
|
||||||
|
extras.putInt(
|
||||||
|
MediaConstants.DESCRIPTION_EXTRAS_KEY_COMPLETION_STATUS,
|
||||||
|
MediaConstants.DESCRIPTION_EXTRAS_VALUE_COMPLETION_STATUS_NOT_PLAYED
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (media.metadata.explicit) {
|
||||||
|
extras.putLong(
|
||||||
|
MediaConstants.METADATA_KEY_IS_EXPLICIT,
|
||||||
|
MediaConstants.METADATA_VALUE_ATTRIBUTE_PRESENT
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (groupTitle !== null) {
|
||||||
|
extras.putString(MediaConstants.DESCRIPTION_EXTRAS_KEY_CONTENT_STYLE_GROUP_TITLE, groupTitle)
|
||||||
}
|
}
|
||||||
|
|
||||||
val mediaId = localLibraryItemId ?: id
|
val mediaId = if (localLibraryItemId != null) {
|
||||||
|
localLibraryItemId
|
||||||
|
} else if (collapsedSeries != null) {
|
||||||
|
if (authorId != null) {
|
||||||
|
"__LIBRARY__${libraryId}__AUTHOR_SERIES__${authorId}__${collapsedSeries!!.id}"
|
||||||
|
} else {
|
||||||
|
"__LIBRARY__${libraryId}__SERIES__${collapsedSeries!!.id}"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
var subtitle = authorName
|
||||||
|
if (collapsedSeries != null) {
|
||||||
|
subtitle = "${collapsedSeries!!.numBooks} books"
|
||||||
|
}
|
||||||
|
var itemTitle = title
|
||||||
|
if (showSeriesNumber == true && seriesSequence != "") {
|
||||||
|
itemTitle = "$seriesSequence. $itemTitle"
|
||||||
|
}
|
||||||
return MediaDescriptionCompat.Builder()
|
return MediaDescriptionCompat.Builder()
|
||||||
.setMediaId(mediaId)
|
.setMediaId(mediaId)
|
||||||
.setTitle(title)
|
.setTitle(itemTitle)
|
||||||
.setIconUri(getCoverUri())
|
.setIconUri(getCoverUri())
|
||||||
.setSubtitle(authorName)
|
.setSubtitle(subtitle)
|
||||||
.setExtras(extras)
|
.setExtras(extras)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
fun getMediaDescription(progress:MediaProgressWrapper?, ctx: Context, authorId: String?, showSeriesNumber: Boolean?): MediaDescriptionCompat {
|
||||||
|
return getMediaDescription(progress, ctx, authorId, showSeriesNumber, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
fun getMediaDescription(progress:MediaProgressWrapper?, ctx: Context, authorId: String?): MediaDescriptionCompat {
|
||||||
|
return getMediaDescription(progress, ctx, authorId, null, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
override fun getMediaDescription(progress:MediaProgressWrapper?, ctx: Context): MediaDescriptionCompat {
|
||||||
|
/*
|
||||||
|
This is needed so Android auto library hierarchy for author series can be implemented
|
||||||
|
*/
|
||||||
|
return getMediaDescription(progress, ctx, null, null, null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package com.audiobookshelf.app.data
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.support.v4.media.MediaDescriptionCompat
|
||||||
|
import androidx.media.utils.MediaConstants
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
class LibrarySeriesItem(
|
||||||
|
id:String,
|
||||||
|
var libraryId:String,
|
||||||
|
var name:String,
|
||||||
|
var description:String?,
|
||||||
|
var addedAt:Long,
|
||||||
|
var updatedAt:Long,
|
||||||
|
var books:MutableList<LibraryItem>?,
|
||||||
|
var localLibraryItemId:String? // For Android Auto
|
||||||
|
) : LibraryItemWrapper(id) {
|
||||||
|
@get:JsonIgnore
|
||||||
|
val title get() = name
|
||||||
|
|
||||||
|
@get:JsonIgnore
|
||||||
|
val audiobookCount: Int
|
||||||
|
get() {
|
||||||
|
if (books == null) return 0
|
||||||
|
val booksWithAudio = books?.filter { b -> b.media.checkHasTracks() }
|
||||||
|
return booksWithAudio?.size ?: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
fun getMediaDescription(progress:MediaProgressWrapper?, ctx: Context, groupTitle: String?): MediaDescriptionCompat {
|
||||||
|
val extras = Bundle()
|
||||||
|
|
||||||
|
if (localLibraryItemId != null) {
|
||||||
|
extras.putLong(
|
||||||
|
MediaDescriptionCompat.EXTRA_DOWNLOAD_STATUS,
|
||||||
|
MediaDescriptionCompat.STATUS_DOWNLOADED
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (groupTitle !== null) {
|
||||||
|
extras.putString(MediaConstants.DESCRIPTION_EXTRAS_KEY_CONTENT_STYLE_GROUP_TITLE, groupTitle)
|
||||||
|
}
|
||||||
|
|
||||||
|
val mediaId = "__LIBRARY__${libraryId}__SERIES__${id}"
|
||||||
|
return MediaDescriptionCompat.Builder()
|
||||||
|
.setMediaId(mediaId)
|
||||||
|
.setTitle(title)
|
||||||
|
//.setIconUri(getCoverUri())
|
||||||
|
.setSubtitle("$audiobookCount books")
|
||||||
|
.setExtras(extras)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
override fun getMediaDescription(progress:MediaProgressWrapper?, ctx: Context): MediaDescriptionCompat {
|
||||||
|
return getMediaDescription(progress, ctx, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,8 @@ import android.os.Bundle
|
|||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.support.v4.media.MediaDescriptionCompat
|
import android.support.v4.media.MediaDescriptionCompat
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import androidx.core.content.FileProvider
|
||||||
|
import androidx.core.net.toFile
|
||||||
import androidx.media.utils.MediaConstants
|
import androidx.media.utils.MediaConstants
|
||||||
import com.audiobookshelf.app.BuildConfig
|
import com.audiobookshelf.app.BuildConfig
|
||||||
import com.audiobookshelf.app.R
|
import com.audiobookshelf.app.R
|
||||||
@@ -16,6 +18,7 @@ import com.audiobookshelf.app.device.DeviceManager
|
|||||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
import com.audiobookshelf.app.player.PLAYMETHOD_LOCAL
|
import com.audiobookshelf.app.player.PLAYMETHOD_LOCAL
|
||||||
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
@@ -46,7 +49,10 @@ class LocalLibraryItem(
|
|||||||
val isPodcast get() = mediaType == "podcast"
|
val isPodcast get() = mediaType == "podcast"
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
fun getCoverUri(): Uri {
|
fun getCoverUri(ctx:Context): Uri {
|
||||||
|
if (coverContentUrl?.startsWith("file:") == true) {
|
||||||
|
return FileProvider.getUriForFile(ctx, "${BuildConfig.APPLICATION_ID}.fileprovider", Uri.parse(coverContentUrl).toFile())
|
||||||
|
}
|
||||||
return if (coverContentUrl != null) Uri.parse(coverContentUrl) else Uri.parse("android.resource://${BuildConfig.APPLICATION_ID}/" + R.drawable.icon)
|
return if (coverContentUrl != null) Uri.parse(coverContentUrl) else Uri.parse("android.resource://${BuildConfig.APPLICATION_ID}/" + R.drawable.icon)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,9 +80,30 @@ class LocalLibraryItem(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
fun getPlaybackSession(episode:PodcastEpisode?):PlaybackSession {
|
fun hasTracks(episode:PodcastEpisode?): Boolean {
|
||||||
|
var audioTracks = media.getAudioTracks() as MutableList<AudioTrack>
|
||||||
|
if (episode != null) { // Get podcast episode audio track
|
||||||
|
episode.audioTrack?.let { at -> mutableListOf(at) }?.let { tracks -> audioTracks = tracks }
|
||||||
|
}
|
||||||
|
if (audioTracks.size == 0) return false
|
||||||
|
audioTracks.forEach {
|
||||||
|
// Check that metadata is not null
|
||||||
|
if (it.metadata === null) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
// Check that file exists
|
||||||
|
val file = File(it.metadata!!.path)
|
||||||
|
if (!file.exists()) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
fun getPlaybackSession(episode:PodcastEpisode?, deviceInfo:DeviceInfo):PlaybackSession {
|
||||||
val localEpisodeId = episode?.id
|
val localEpisodeId = episode?.id
|
||||||
val sessionId = "play_local_${UUID.randomUUID()}"
|
val sessionId = "${UUID.randomUUID()}"
|
||||||
|
|
||||||
// Get current progress for local media
|
// Get current progress for local media
|
||||||
val mediaProgressId = if (localEpisodeId.isNullOrEmpty()) id else "$id-$localEpisodeId"
|
val mediaProgressId = if (localEpisodeId.isNullOrEmpty()) id else "$id-$localEpisodeId"
|
||||||
@@ -85,19 +112,20 @@ class LocalLibraryItem(
|
|||||||
|
|
||||||
|
|
||||||
val mediaMetadata = media.metadata
|
val mediaMetadata = media.metadata
|
||||||
val chapters = if (mediaType == "book") (media as Book).chapters else mutableListOf()
|
var chapters = if (mediaType == "book") (media as Book).chapters else mutableListOf()
|
||||||
var audioTracks = media.getAudioTracks() as MutableList<AudioTrack>
|
var audioTracks = media.getAudioTracks() as MutableList<AudioTrack>
|
||||||
val authorName = mediaMetadata.getAuthorDisplayName()
|
val authorName = mediaMetadata.getAuthorDisplayName()
|
||||||
val displayTitle = episode?.title ?: mediaMetadata.title
|
val displayTitle = episode?.title ?: mediaMetadata.title
|
||||||
var duration = getDuration()
|
var duration = getDuration()
|
||||||
if (episode != null) { // Get podcast episode audio track
|
if (episode != null) { // Get podcast episode audio track
|
||||||
episode.audioTrack?.let { at -> mutableListOf(at) }?.let { tracks -> audioTracks = tracks }
|
episode.audioTrack?.let { at -> mutableListOf(at) }?.let { tracks -> audioTracks = tracks }
|
||||||
|
chapters = episode.chapters
|
||||||
duration = episode.audioTrack?.duration ?: 0.0
|
duration = episode.audioTrack?.duration ?: 0.0
|
||||||
Log.d("LocalLibraryItem", "getPlaybackSession: Got podcast episode audio track ${audioTracks.size}")
|
Log.d("LocalLibraryItem", "getPlaybackSession: Got podcast episode audio track ${audioTracks.size}")
|
||||||
}
|
}
|
||||||
|
|
||||||
val dateNow = System.currentTimeMillis()
|
val dateNow = System.currentTimeMillis()
|
||||||
return PlaybackSession(sessionId,serverUserId,libraryItemId,episode?.serverEpisodeId, mediaType, mediaMetadata, chapters ?: mutableListOf(), displayTitle, authorName,null,duration,PLAYMETHOD_LOCAL,dateNow,0L,0L, audioTracks,currentTime,null,this,localEpisodeId,serverConnectionConfigId, serverAddress, "exo-player")
|
return PlaybackSession(sessionId,serverUserId,libraryItemId,episode?.serverEpisodeId, mediaType, mediaMetadata, deviceInfo,chapters ?: mutableListOf(), displayTitle, authorName,null,duration,PLAYMETHOD_LOCAL,dateNow,0L,0L, audioTracks,currentTime,null,this,localEpisodeId,serverConnectionConfigId, serverAddress, "exo-player")
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@@ -106,18 +134,16 @@ class LocalLibraryItem(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
override fun getMediaDescription(progress:MediaProgressWrapper?, ctx:Context?): MediaDescriptionCompat {
|
override fun getMediaDescription(progress:MediaProgressWrapper?, ctx:Context): MediaDescriptionCompat {
|
||||||
val coverUri = getCoverUri()
|
val coverUri = getCoverUri(ctx)
|
||||||
|
|
||||||
var bitmap:Bitmap? = null
|
var bitmap:Bitmap? = null
|
||||||
if (coverContentUrl != null) {
|
if (coverContentUrl != null) {
|
||||||
ctx?.let {
|
bitmap = if (Build.VERSION.SDK_INT < 28) {
|
||||||
bitmap = if (Build.VERSION.SDK_INT < 28) {
|
MediaStore.Images.Media.getBitmap(ctx.contentResolver, coverUri)
|
||||||
MediaStore.Images.Media.getBitmap(it.contentResolver, coverUri)
|
} else {
|
||||||
} else {
|
val source: ImageDecoder.Source = ImageDecoder.createSource(ctx.contentResolver, coverUri)
|
||||||
val source: ImageDecoder.Source = ImageDecoder.createSource(it.contentResolver, coverUri)
|
ImageDecoder.decodeBitmap(source)
|
||||||
ImageDecoder.decodeBitmap(source)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,6 +174,10 @@ class LocalLibraryItem(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (media.metadata.explicit) {
|
||||||
|
extras.putLong(MediaConstants.METADATA_KEY_IS_EXPLICIT, MediaConstants.METADATA_VALUE_ATTRIBUTE_PRESENT)
|
||||||
|
}
|
||||||
|
|
||||||
val mediaDescriptionBuilder = MediaDescriptionCompat.Builder()
|
val mediaDescriptionBuilder = MediaDescriptionCompat.Builder()
|
||||||
.setMediaId(id)
|
.setMediaId(id)
|
||||||
.setTitle(title)
|
.setTitle(title)
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ data class LocalMediaItem(
|
|||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
fun getMediaMetadata():MediaTypeMetadata {
|
fun getMediaMetadata():MediaTypeMetadata {
|
||||||
return if (mediaType == "book") {
|
return if (mediaType == "book") {
|
||||||
BookMetadata(name,null, mutableListOf(), mutableListOf(), mutableListOf(),null,null,null,null,null,null,null,false,null,null,null,null)
|
BookMetadata(name,null, mutableListOf(), mutableListOf(), mutableListOf(),null,null,null,null,null,null,null,false,null,null,null, null, null)
|
||||||
} else {
|
} else {
|
||||||
PodcastMetadata(name,null,null, mutableListOf())
|
PodcastMetadata(name,null,null, mutableListOf(), false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import android.net.Uri
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.support.v4.media.MediaMetadataCompat
|
import android.support.v4.media.MediaMetadataCompat
|
||||||
|
import androidx.core.content.FileProvider
|
||||||
|
import androidx.core.net.toFile
|
||||||
import com.audiobookshelf.app.BuildConfig
|
import com.audiobookshelf.app.BuildConfig
|
||||||
import com.audiobookshelf.app.R
|
import com.audiobookshelf.app.R
|
||||||
import com.audiobookshelf.app.device.DeviceManager
|
import com.audiobookshelf.app.device.DeviceManager
|
||||||
@@ -27,6 +29,7 @@ class PlaybackSession(
|
|||||||
var episodeId:String?,
|
var episodeId:String?,
|
||||||
var mediaType:String,
|
var mediaType:String,
|
||||||
var mediaMetadata:MediaTypeMetadata,
|
var mediaMetadata:MediaTypeMetadata,
|
||||||
|
var deviceInfo:DeviceInfo,
|
||||||
var chapters:List<BookChapter>,
|
var chapters:List<BookChapter>,
|
||||||
var displayTitle: String?,
|
var displayTitle: String?,
|
||||||
var displayAuthor: String?,
|
var displayAuthor: String?,
|
||||||
@@ -137,8 +140,15 @@ class PlaybackSession(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
fun getCoverUri(): Uri {
|
fun getCoverUri(ctx:Context): Uri {
|
||||||
if (localLibraryItem?.coverContentUrl != null) return Uri.parse(localLibraryItem?.coverContentUrl) ?: Uri.parse("android.resource://${BuildConfig.APPLICATION_ID}/" + R.drawable.icon)
|
if (localLibraryItem?.coverContentUrl != null) {
|
||||||
|
var coverUri = Uri.parse(localLibraryItem?.coverContentUrl.toString())
|
||||||
|
if (coverUri.toString().startsWith("file:")) {
|
||||||
|
coverUri = FileProvider.getUriForFile(ctx, "${BuildConfig.APPLICATION_ID}.fileprovider", coverUri.toFile())
|
||||||
|
}
|
||||||
|
|
||||||
|
return coverUri ?: Uri.parse("android.resource://${BuildConfig.APPLICATION_ID}/" + R.drawable.icon)
|
||||||
|
}
|
||||||
|
|
||||||
if (coverPath == null) return Uri.parse("android.resource://${BuildConfig.APPLICATION_ID}/" + R.drawable.icon)
|
if (coverPath == null) return Uri.parse("android.resource://${BuildConfig.APPLICATION_ID}/" + R.drawable.icon)
|
||||||
return Uri.parse("$serverAddress/api/items/$libraryItemId/cover?token=${DeviceManager.token}")
|
return Uri.parse("$serverAddress/api/items/$libraryItemId/cover?token=${DeviceManager.token}")
|
||||||
@@ -152,6 +162,8 @@ class PlaybackSession(
|
|||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
fun getMediaMetadataCompat(ctx: Context): MediaMetadataCompat {
|
fun getMediaMetadataCompat(ctx: Context): MediaMetadataCompat {
|
||||||
|
val coverUri = getCoverUri(ctx)
|
||||||
|
|
||||||
val metadataBuilder = MediaMetadataCompat.Builder()
|
val metadataBuilder = MediaMetadataCompat.Builder()
|
||||||
.putString(MediaMetadataCompat.METADATA_KEY_TITLE, displayTitle)
|
.putString(MediaMetadataCompat.METADATA_KEY_TITLE, displayTitle)
|
||||||
.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, displayTitle)
|
.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, displayTitle)
|
||||||
@@ -162,16 +174,16 @@ class PlaybackSession(
|
|||||||
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, displayAuthor)
|
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, displayAuthor)
|
||||||
.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION, displayAuthor)
|
.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION, displayAuthor)
|
||||||
.putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, id)
|
.putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, id)
|
||||||
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI, getCoverUri().toString())
|
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI, coverUri.toString())
|
||||||
.putString(MediaMetadataCompat.METADATA_KEY_ART_URI, getCoverUri().toString())
|
.putString(MediaMetadataCompat.METADATA_KEY_ART_URI, coverUri.toString())
|
||||||
.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON_URI, getCoverUri().toString())
|
.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON_URI, coverUri.toString())
|
||||||
|
|
||||||
// Local covers get bitmap
|
// Local covers get bitmap
|
||||||
if (localLibraryItem?.coverContentUrl != null) {
|
if (localLibraryItem?.coverContentUrl != null) {
|
||||||
val bitmap = if (Build.VERSION.SDK_INT < 28) {
|
val bitmap = if (Build.VERSION.SDK_INT < 28) {
|
||||||
MediaStore.Images.Media.getBitmap(ctx.contentResolver, getCoverUri())
|
MediaStore.Images.Media.getBitmap(ctx.contentResolver, coverUri)
|
||||||
} else {
|
} else {
|
||||||
val source: ImageDecoder.Source = ImageDecoder.createSource(ctx.contentResolver, getCoverUri())
|
val source: ImageDecoder.Source = ImageDecoder.createSource(ctx.contentResolver, coverUri)
|
||||||
ImageDecoder.decodeBitmap(source)
|
ImageDecoder.decodeBitmap(source)
|
||||||
}
|
}
|
||||||
metadataBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, bitmap)
|
metadataBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, bitmap)
|
||||||
@@ -182,7 +194,9 @@ class PlaybackSession(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
fun getExoMediaMetadata(audioTrack:AudioTrack): MediaMetadata {
|
fun getExoMediaMetadata(ctx:Context): MediaMetadata {
|
||||||
|
val coverUri = getCoverUri(ctx)
|
||||||
|
|
||||||
val metadataBuilder = MediaMetadata.Builder()
|
val metadataBuilder = MediaMetadata.Builder()
|
||||||
.setTitle(displayTitle)
|
.setTitle(displayTitle)
|
||||||
.setDisplayTitle(displayTitle)
|
.setDisplayTitle(displayTitle)
|
||||||
@@ -191,20 +205,18 @@ class PlaybackSession(
|
|||||||
.setSubtitle(displayAuthor)
|
.setSubtitle(displayAuthor)
|
||||||
.setAlbumTitle(displayAuthor)
|
.setAlbumTitle(displayAuthor)
|
||||||
.setDescription(displayAuthor)
|
.setDescription(displayAuthor)
|
||||||
.setArtworkUri(getCoverUri())
|
.setArtworkUri(coverUri)
|
||||||
|
.setMediaType(MediaMetadata.MEDIA_TYPE_AUDIO_BOOK)
|
||||||
val contentUri = this.getContentUri(audioTrack)
|
|
||||||
metadataBuilder.setMediaUri(contentUri)
|
|
||||||
|
|
||||||
return metadataBuilder.build()
|
return metadataBuilder.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
fun getMediaItems():List<MediaItem> {
|
fun getMediaItems(ctx:Context):List<MediaItem> {
|
||||||
val mediaItems:MutableList<MediaItem> = mutableListOf()
|
val mediaItems:MutableList<MediaItem> = mutableListOf()
|
||||||
|
|
||||||
for (audioTrack in audioTracks) {
|
for (audioTrack in audioTracks) {
|
||||||
val mediaMetadata = this.getExoMediaMetadata(audioTrack)
|
val mediaMetadata = this.getExoMediaMetadata(ctx)
|
||||||
val mediaUri = this.getContentUri(audioTrack)
|
val mediaUri = this.getContentUri(audioTrack)
|
||||||
val mimeType = audioTrack.mimeType
|
val mimeType = audioTrack.mimeType
|
||||||
|
|
||||||
@@ -252,7 +264,7 @@ class PlaybackSession(
|
|||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
fun clone():PlaybackSession {
|
fun clone():PlaybackSession {
|
||||||
return PlaybackSession(id,userId,libraryItemId,episodeId,mediaType,mediaMetadata,chapters,displayTitle,displayAuthor,coverPath,duration,playMethod,startedAt,updatedAt,timeListening,audioTracks,currentTime,libraryItem,localLibraryItem,localEpisodeId,serverConnectionConfigId,serverAddress, mediaPlayer)
|
return PlaybackSession(id,userId,libraryItemId,episodeId,mediaType,mediaMetadata,deviceInfo,chapters,displayTitle,displayAuthor,coverPath,duration,playMethod,startedAt,updatedAt,timeListening,audioTracks,currentTime,libraryItem,localLibraryItem,localEpisodeId,serverConnectionConfigId,serverAddress, mediaPlayer)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
|
|||||||
@@ -1,15 +1,20 @@
|
|||||||
package com.audiobookshelf.app.device
|
package com.audiobookshelf.app.device
|
||||||
|
|
||||||
|
import android.appwidget.AppWidgetManager
|
||||||
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
import android.net.NetworkCapabilities
|
import android.net.NetworkCapabilities
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import com.audiobookshelf.app.MediaPlayerWidget
|
||||||
import com.audiobookshelf.app.data.*
|
import com.audiobookshelf.app.data.*
|
||||||
import com.audiobookshelf.app.managers.DbManager
|
import com.audiobookshelf.app.managers.DbManager
|
||||||
import com.audiobookshelf.app.player.PlayerNotificationService
|
import com.audiobookshelf.app.player.PlayerNotificationService
|
||||||
|
import com.audiobookshelf.app.updateAppWidget
|
||||||
|
|
||||||
interface WidgetEventEmitter {
|
interface WidgetEventEmitter {
|
||||||
fun onPlayerChanged(pns:PlayerNotificationService)
|
fun onPlayerChanged(pns:PlayerNotificationService)
|
||||||
|
fun onPlayerClosed()
|
||||||
}
|
}
|
||||||
|
|
||||||
object DeviceManager {
|
object DeviceManager {
|
||||||
@@ -43,6 +48,25 @@ object DeviceManager {
|
|||||||
if (deviceData.deviceSettings?.autoSleepTimerAutoRewindTime == null) {
|
if (deviceData.deviceSettings?.autoSleepTimerAutoRewindTime == null) {
|
||||||
deviceData.deviceSettings?.autoSleepTimerAutoRewindTime = 300000L // 5 minutes
|
deviceData.deviceSettings?.autoSleepTimerAutoRewindTime = 300000L // 5 minutes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Language added in v0.9.69
|
||||||
|
if (deviceData.deviceSettings?.languageCode == null) {
|
||||||
|
deviceData.deviceSettings?.languageCode = "en-us"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deviceData.deviceSettings?.downloadUsingCellular == null) {
|
||||||
|
deviceData.deviceSettings?.downloadUsingCellular = DownloadUsingCellularSetting.ALWAYS
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deviceData.deviceSettings?.streamingUsingCellular == null) {
|
||||||
|
deviceData.deviceSettings?.streamingUsingCellular = StreamingUsingCellularSetting.ALWAYS
|
||||||
|
}
|
||||||
|
if (deviceData.deviceSettings?.androidAutoBrowseLimitForGrouping == null) {
|
||||||
|
deviceData.deviceSettings?.androidAutoBrowseLimitForGrouping = 100
|
||||||
|
}
|
||||||
|
if (deviceData.deviceSettings?.androidAutoBrowseSeriesSequenceOrder == null) {
|
||||||
|
deviceData.deviceSettings?.androidAutoBrowseSeriesSequenceOrder = AndroidAutoBrowseSeriesSequenceOrderSetting.ASC
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getBase64Id(id:String):String {
|
fun getBase64Id(id:String):String {
|
||||||
@@ -76,4 +100,31 @@ object DeviceManager {
|
|||||||
deviceData.lastPlaybackSession = playbackSession
|
deviceData.lastPlaybackSession = playbackSession
|
||||||
dbManager.saveDeviceData(deviceData)
|
dbManager.saveDeviceData(deviceData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun initializeWidgetUpdater(context:Context) {
|
||||||
|
Log.d(tag, "Initializing widget updater")
|
||||||
|
widgetUpdater = (object : WidgetEventEmitter {
|
||||||
|
override fun onPlayerChanged(pns: PlayerNotificationService) {
|
||||||
|
|
||||||
|
val isPlaying = pns.currentPlayer.isPlaying
|
||||||
|
|
||||||
|
val appWidgetManager = AppWidgetManager.getInstance(context)
|
||||||
|
val componentName = ComponentName(context, MediaPlayerWidget::class.java)
|
||||||
|
val ids = appWidgetManager.getAppWidgetIds(componentName)
|
||||||
|
val playbackSession = pns.getCurrentPlaybackSessionCopy()
|
||||||
|
|
||||||
|
for (widgetId in ids) {
|
||||||
|
updateAppWidget(context, appWidgetManager, widgetId, playbackSession, isPlaying, PlayerNotificationService.isClosed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
override fun onPlayerClosed() {
|
||||||
|
val appWidgetManager = AppWidgetManager.getInstance(context)
|
||||||
|
val componentName = ComponentName(context, MediaPlayerWidget::class.java)
|
||||||
|
val ids = appWidgetManager.getAppWidgetIds(componentName)
|
||||||
|
for (widgetId in ids) {
|
||||||
|
updateAppWidget(context, appWidgetManager, widgetId, deviceData.lastPlaybackSession, false, PlayerNotificationService.isClosed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,16 +5,11 @@ import android.net.Uri
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.documentfile.provider.DocumentFile
|
import androidx.documentfile.provider.DocumentFile
|
||||||
import com.anggrayudi.storage.file.*
|
import com.anggrayudi.storage.file.*
|
||||||
import com.arthenica.ffmpegkit.FFmpegKitConfig
|
|
||||||
import com.arthenica.ffmpegkit.FFprobeKit
|
|
||||||
import com.arthenica.ffmpegkit.Level
|
|
||||||
import com.audiobookshelf.app.data.*
|
import com.audiobookshelf.app.data.*
|
||||||
import com.audiobookshelf.app.models.DownloadItem
|
import com.audiobookshelf.app.models.DownloadItem
|
||||||
import com.fasterxml.jackson.core.json.JsonReadFeature
|
import com.fasterxml.jackson.core.json.JsonReadFeature
|
||||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
import java.io.File
|
||||||
import com.getcapacitor.JSObject
|
|
||||||
import org.json.JSONException
|
|
||||||
|
|
||||||
class FolderScanner(var ctx: Context) {
|
class FolderScanner(var ctx: Context) {
|
||||||
private val tag = "FolderScanner"
|
private val tag = "FolderScanner"
|
||||||
@@ -26,213 +21,190 @@ class FolderScanner(var ctx: Context) {
|
|||||||
return "local_" + DeviceManager.getBase64Id(mediaItemId)
|
return "local_" + DeviceManager.getBase64Id(mediaItemId)
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class ItemScanResult {
|
private fun scanInternalDownloadItem(downloadItem:DownloadItem, cb: (DownloadItemScanResult?) -> Unit) {
|
||||||
ADDED, REMOVED, UPDATED, UPTODATE
|
val localLibraryItemId = "local_${downloadItem.libraryItemId}"
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: CLEAN this monster! Divide into bite-size methods
|
var localEpisodeId:String? = null
|
||||||
fun scanForMediaItems(localFolder:LocalFolder, forceAudioProbe:Boolean):FolderScanResult? {
|
var localLibraryItem:LocalLibraryItem?
|
||||||
FFmpegKitConfig.enableLogCallback { log ->
|
if (downloadItem.mediaType == "book") {
|
||||||
if (log.level != Level.AV_LOG_STDERR) { // STDERR is filled with junk
|
localLibraryItem = LocalLibraryItem(localLibraryItemId, downloadItem.localFolder.id, downloadItem.itemFolderPath, downloadItem.itemFolderPath, "", false, downloadItem.mediaType, downloadItem.media.getLocalCopy(), mutableListOf(), null, null, true, downloadItem.serverConnectionConfigId, downloadItem.serverAddress, downloadItem.serverUserId, downloadItem.libraryItemId)
|
||||||
Log.d(tag, "FFmpeg-Kit Log: (${log.level}) ${log.message}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val df: DocumentFile? = DocumentFileCompat.fromUri(ctx, Uri.parse(localFolder.contentUrl))
|
|
||||||
|
|
||||||
if (df == null) {
|
|
||||||
Log.e(tag, "Folder Doc File Invalid $localFolder.contentUrl")
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
var mediaItemsUpdated = 0
|
|
||||||
var mediaItemsAdded = 0
|
|
||||||
var mediaItemsRemoved = 0
|
|
||||||
var mediaItemsUpToDate = 0
|
|
||||||
|
|
||||||
// Search for files in media item folder
|
|
||||||
val foldersFound = df.search(true, DocumentFileType.FOLDER)
|
|
||||||
|
|
||||||
// Match folders found with local library items already saved in db
|
|
||||||
var existingLocalLibraryItems = DeviceManager.dbManager.getLocalLibraryItemsInFolder(localFolder.id)
|
|
||||||
|
|
||||||
// Remove existing items no longer there
|
|
||||||
existingLocalLibraryItems = existingLocalLibraryItems.filter { lli ->
|
|
||||||
Log.d(tag, "scanForMediaItems Checking Existing LLI ${lli.id}")
|
|
||||||
val fileFound = foldersFound.find { f -> lli.id == getLocalLibraryItemId(f.id) }
|
|
||||||
if (fileFound == null) {
|
|
||||||
Log.d(tag, "Existing local library item is no longer in file system ${lli.media.metadata.title}")
|
|
||||||
DeviceManager.dbManager.removeLocalLibraryItem(lli.id)
|
|
||||||
mediaItemsRemoved++
|
|
||||||
}
|
|
||||||
fileFound != null
|
|
||||||
}
|
|
||||||
|
|
||||||
foldersFound.forEach { itemFolder ->
|
|
||||||
Log.d(tag, "Iterating over Folder Found ${itemFolder.name} | ${itemFolder.getSimplePath(ctx)} | URI: ${itemFolder.uri}")
|
|
||||||
val existingItem = existingLocalLibraryItems.find { emi -> emi.id == getLocalLibraryItemId(itemFolder.id) }
|
|
||||||
|
|
||||||
val filesInFolder = itemFolder.search(false, DocumentFileType.FILE, arrayOf("audio/*", "image/*", "video/mp4", "application/*"))
|
|
||||||
|
|
||||||
// Do not scan folders that have no media items and not an existing item already
|
|
||||||
if (existingItem != null || filesInFolder.isNotEmpty()) {
|
|
||||||
when (scanLibraryItemFolder(itemFolder, filesInFolder, localFolder, existingItem, forceAudioProbe)) {
|
|
||||||
ItemScanResult.REMOVED -> mediaItemsRemoved++
|
|
||||||
ItemScanResult.UPDATED -> mediaItemsUpdated++
|
|
||||||
ItemScanResult.ADDED -> mediaItemsAdded++
|
|
||||||
else -> mediaItemsUpToDate++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.d(tag, "Folder $${localFolder.name} scan Results: $mediaItemsAdded Added | $mediaItemsUpdated Updated | $mediaItemsRemoved Removed | $mediaItemsUpToDate Up-to-date")
|
|
||||||
|
|
||||||
return if (mediaItemsAdded > 0 || mediaItemsUpdated > 0 || mediaItemsRemoved > 0) {
|
|
||||||
val folderLibraryItems = DeviceManager.dbManager.getLocalLibraryItemsInFolder(localFolder.id) // Get all local media items
|
|
||||||
FolderScanResult(mediaItemsAdded, mediaItemsUpdated, mediaItemsRemoved, mediaItemsUpToDate, localFolder, folderLibraryItems)
|
|
||||||
} else {
|
|
||||||
Log.d(tag, "No Media Items to save")
|
|
||||||
FolderScanResult(mediaItemsAdded, mediaItemsUpdated, mediaItemsRemoved, mediaItemsUpToDate, localFolder, mutableListOf())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun scanLibraryItemFolder(itemFolder:DocumentFile, filesInFolder:List<DocumentFile>, localFolder:LocalFolder, existingItem:LocalLibraryItem?, forceAudioProbe:Boolean):ItemScanResult {
|
|
||||||
val itemFolderName = itemFolder.name ?: ""
|
|
||||||
val itemId = getLocalLibraryItemId(itemFolder.id)
|
|
||||||
|
|
||||||
val existingLocalFiles = existingItem?.localFiles ?: mutableListOf()
|
|
||||||
val existingAudioTracks = existingItem?.media?.getAudioTracks() ?: mutableListOf()
|
|
||||||
var isNewOrUpdated = existingItem == null
|
|
||||||
|
|
||||||
val audioTracks = mutableListOf<AudioTrack>()
|
|
||||||
val localFiles = mutableListOf<LocalFile>()
|
|
||||||
var index = 1
|
|
||||||
var startOffset = 0.0
|
|
||||||
var coverContentUrl:String? = null
|
|
||||||
var coverAbsolutePath:String? = null
|
|
||||||
var hasEBookFile = false
|
|
||||||
var newEBookFile:EBookFile? = null
|
|
||||||
|
|
||||||
val existingLocalFilesRemoved = existingLocalFiles.filter { elf ->
|
|
||||||
filesInFolder.find { fif -> DeviceManager.getBase64Id(fif.id) == elf.id } == null // File was not found in media item folder
|
|
||||||
}
|
|
||||||
if (existingLocalFilesRemoved.isNotEmpty()) {
|
|
||||||
Log.d(tag, "${existingLocalFilesRemoved.size} Local files were removed from local media item ${existingItem?.media?.metadata?.title}")
|
|
||||||
isNewOrUpdated = true
|
|
||||||
}
|
|
||||||
|
|
||||||
filesInFolder.forEach { file ->
|
|
||||||
val mimeType = file.mimeType ?: ""
|
|
||||||
val filename = file.name ?: ""
|
|
||||||
Log.d(tag, "Found $mimeType file $filename in folder $itemFolderName")
|
|
||||||
|
|
||||||
val localFileId = DeviceManager.getBase64Id(file.id)
|
|
||||||
|
|
||||||
val localFile = LocalFile(localFileId,filename,file.uri.toString(),file.getBasePath(ctx), file.getAbsolutePath(ctx),file.getSimplePath(ctx),mimeType,file.length())
|
|
||||||
localFiles.add(localFile)
|
|
||||||
|
|
||||||
Log.d(tag, "File attributes Id:${localFileId}|ContentUrl:${localFile.contentUrl}|isDownloadsDocument:${file.isDownloadsDocument}")
|
|
||||||
|
|
||||||
if (localFile.isAudioFile()) {
|
|
||||||
val audioTrackToAdd:AudioTrack?
|
|
||||||
|
|
||||||
val existingAudioTrack = existingAudioTracks.find { eat -> eat.localFileId == localFileId }
|
|
||||||
if (existingAudioTrack != null) { // Update existing audio track
|
|
||||||
if (existingAudioTrack.index != index) {
|
|
||||||
Log.d(tag, "scanLibraryItemFolder Updating Audio track index from ${existingAudioTrack.index} to $index")
|
|
||||||
existingAudioTrack.index = index
|
|
||||||
isNewOrUpdated = true
|
|
||||||
}
|
|
||||||
if (existingAudioTrack.startOffset != startOffset) {
|
|
||||||
Log.d(tag, "scanLibraryItemFolder Updating Audio track startOffset ${existingAudioTrack.startOffset} to $startOffset")
|
|
||||||
existingAudioTrack.startOffset = startOffset
|
|
||||||
isNewOrUpdated = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (existingAudioTrack == null || forceAudioProbe) {
|
|
||||||
Log.d(tag, "scanLibraryItemFolder Scanning Audio File Path ${localFile.absolutePath} | ForceAudioProbe=${forceAudioProbe}")
|
|
||||||
|
|
||||||
// TODO: Make asynchronous
|
|
||||||
val audioProbeResult = probeAudioFile(localFile.absolutePath)
|
|
||||||
|
|
||||||
if (existingAudioTrack != null) {
|
|
||||||
// Update audio probe data on existing audio track
|
|
||||||
existingAudioTrack.audioProbeResult = audioProbeResult
|
|
||||||
audioTrackToAdd = existingAudioTrack
|
|
||||||
} else {
|
|
||||||
// Create new audio track
|
|
||||||
val track = AudioTrack(index, startOffset, audioProbeResult?.duration ?: 0.0, filename, localFile.contentUrl, mimeType, null, true, localFileId, audioProbeResult, null)
|
|
||||||
audioTrackToAdd = track
|
|
||||||
}
|
|
||||||
|
|
||||||
startOffset += audioProbeResult?.duration ?: 0.0
|
|
||||||
isNewOrUpdated = true
|
|
||||||
} else {
|
|
||||||
audioTrackToAdd = existingAudioTrack
|
|
||||||
}
|
|
||||||
|
|
||||||
startOffset += audioTrackToAdd.duration
|
|
||||||
index++
|
|
||||||
audioTracks.add(audioTrackToAdd)
|
|
||||||
} else if (localFile.isEBookFile()) {
|
|
||||||
val existingLocalFile = existingLocalFiles.find { elf -> elf.id == localFileId }
|
|
||||||
|
|
||||||
if (localFolder.mediaType == "book") {
|
|
||||||
hasEBookFile = true
|
|
||||||
if (existingLocalFile == null) {
|
|
||||||
newEBookFile = EBookFile(localFileId, null, localFile.getEBookFormat() ?: "", true, localFileId, localFile.contentUrl)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
val existingLocalFile = existingLocalFiles.find { elf -> elf.id == localFileId }
|
|
||||||
|
|
||||||
if (existingLocalFile == null) {
|
|
||||||
Log.d(tag, "scanLibraryItemFolder new local file found ${localFile.absolutePath}")
|
|
||||||
isNewOrUpdated = true
|
|
||||||
}
|
|
||||||
if (existingItem != null && existingItem.coverContentUrl == null) {
|
|
||||||
// Existing media item did not have a cover - cover found on scan
|
|
||||||
Log.d(tag, "scanLibraryItemFolder setting cover ${localFile.absolutePath}")
|
|
||||||
isNewOrUpdated = true
|
|
||||||
existingItem.coverAbsolutePath = localFile.absolutePath
|
|
||||||
existingItem.coverContentUrl = localFile.contentUrl
|
|
||||||
existingItem.media.coverPath = localFile.absolutePath
|
|
||||||
}
|
|
||||||
|
|
||||||
// First image file use as cover path
|
|
||||||
if (coverContentUrl == null) {
|
|
||||||
coverContentUrl = localFile.contentUrl
|
|
||||||
coverAbsolutePath = localFile.absolutePath
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (existingItem != null && audioTracks.isEmpty() && !hasEBookFile) {
|
|
||||||
Log.d(tag, "Local library item ${existingItem.media.metadata.title} no longer has audio tracks - removing item")
|
|
||||||
DeviceManager.dbManager.removeLocalLibraryItem(existingItem.id)
|
|
||||||
return ItemScanResult.REMOVED
|
|
||||||
} else if (existingItem != null && !isNewOrUpdated) {
|
|
||||||
Log.d(tag, "Local library item ${existingItem.media.metadata.title} has no updates")
|
|
||||||
return ItemScanResult.UPTODATE
|
|
||||||
} else if (existingItem != null) {
|
|
||||||
Log.d(tag, "Updating local library item ${existingItem.media.metadata.title}")
|
|
||||||
existingItem.updateFromScan(audioTracks,localFiles)
|
|
||||||
DeviceManager.dbManager.saveLocalLibraryItem(existingItem)
|
|
||||||
return ItemScanResult.UPDATED
|
|
||||||
} else if (audioTracks.isNotEmpty() || newEBookFile != null) {
|
|
||||||
Log.d(tag, "Found local media item named $itemFolderName with ${audioTracks.size} tracks and ${localFiles.size} local files")
|
|
||||||
val localMediaItem = LocalMediaItem(itemId, itemFolderName, localFolder.mediaType, localFolder.id, itemFolder.uri.toString(), itemFolder.getSimplePath(ctx), itemFolder.getBasePath(ctx), itemFolder.getAbsolutePath(ctx),audioTracks,newEBookFile,localFiles,coverContentUrl,coverAbsolutePath)
|
|
||||||
val localLibraryItem = localMediaItem.getLocalLibraryItem()
|
|
||||||
DeviceManager.dbManager.saveLocalLibraryItem(localLibraryItem)
|
|
||||||
return ItemScanResult.ADDED
|
|
||||||
} else {
|
} else {
|
||||||
return ItemScanResult.UPTODATE
|
// Lookup or create podcast local library item
|
||||||
|
localLibraryItem = DeviceManager.dbManager.getLocalLibraryItem(localLibraryItemId)
|
||||||
|
if (localLibraryItem == null) {
|
||||||
|
Log.d(tag, "[FolderScanner] Podcast local library item not created yet for ${downloadItem.media.metadata.title}")
|
||||||
|
localLibraryItem = LocalLibraryItem(localLibraryItemId, downloadItem.localFolder.id, downloadItem.itemFolderPath, downloadItem.itemFolderPath, "", false, downloadItem.mediaType, downloadItem.media.getLocalCopy(), mutableListOf(), null, null, true,downloadItem.serverConnectionConfigId,downloadItem.serverAddress,downloadItem.serverUserId,downloadItem.libraryItemId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val audioTracks:MutableList<AudioTrack> = mutableListOf()
|
||||||
|
var foundEBookFile = false
|
||||||
|
|
||||||
|
downloadItem.downloadItemParts.forEach { downloadItemPart ->
|
||||||
|
Log.d(tag, "Scan internal storage item with finalDestinationUri=${downloadItemPart.finalDestinationUri}")
|
||||||
|
|
||||||
|
val file = File(downloadItemPart.finalDestinationPath)
|
||||||
|
Log.d(tag, "Scan internal storage item created file ${file.name}")
|
||||||
|
|
||||||
|
if (file == null) {
|
||||||
|
Log.e(tag, "scanInternalDownloadItem: Null docFile for path ${downloadItemPart.finalDestinationPath}")
|
||||||
|
} else {
|
||||||
|
if (downloadItemPart.audioTrack != null) {
|
||||||
|
val audioTrackFromServer = downloadItemPart.audioTrack
|
||||||
|
Log.d(
|
||||||
|
tag,
|
||||||
|
"scanInternalDownloadItem: Audio Track from Server index = ${audioTrackFromServer.index}"
|
||||||
|
)
|
||||||
|
|
||||||
|
val localFileId = DeviceManager.getBase64Id(file.name)
|
||||||
|
Log.d(tag, "Scan internal file localFileId=$localFileId")
|
||||||
|
val localFile = LocalFile(
|
||||||
|
localFileId,
|
||||||
|
file.name,
|
||||||
|
downloadItemPart.finalDestinationUri.toString(),
|
||||||
|
file.getBasePath(ctx),
|
||||||
|
file.absolutePath,
|
||||||
|
file.getSimplePath(ctx),
|
||||||
|
file.mimeType,
|
||||||
|
file.length()
|
||||||
|
)
|
||||||
|
localLibraryItem.localFiles.add(localFile)
|
||||||
|
|
||||||
|
val trackFileMetadata = FileMetadata(file.name, file.extension, file.absolutePath, file.getBasePath(ctx), file.length())
|
||||||
|
// Create new audio track
|
||||||
|
val track = AudioTrack(
|
||||||
|
audioTrackFromServer.index,
|
||||||
|
audioTrackFromServer.startOffset,
|
||||||
|
audioTrackFromServer.duration,
|
||||||
|
localFile.filename ?: "",
|
||||||
|
localFile.contentUrl,
|
||||||
|
localFile.mimeType ?: "",
|
||||||
|
trackFileMetadata,
|
||||||
|
true,
|
||||||
|
localFileId,
|
||||||
|
null,
|
||||||
|
audioTrackFromServer.index
|
||||||
|
)
|
||||||
|
audioTracks.add(track)
|
||||||
|
|
||||||
|
Log.d(
|
||||||
|
tag,
|
||||||
|
"scanInternalDownloadItem: Created Audio Track with index ${track.index} from local file ${localFile.absolutePath}"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add podcast episodes to library
|
||||||
|
downloadItemPart.episode?.let { podcastEpisode ->
|
||||||
|
val podcast = localLibraryItem.media as Podcast
|
||||||
|
val newEpisode = podcast.addEpisode(track, podcastEpisode)
|
||||||
|
localEpisodeId = newEpisode.id
|
||||||
|
Log.d(
|
||||||
|
tag,
|
||||||
|
"scanInternalDownloadItem: Added episode to podcast ${podcastEpisode.title} ${track.title} | Track index: ${podcastEpisode.audioTrack?.index}"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (downloadItemPart.ebookFile != null) {
|
||||||
|
foundEBookFile = true
|
||||||
|
Log.d(tag, "scanInternalDownloadItem: Ebook file found with mimetype=${file.mimeType}")
|
||||||
|
val localFileId = DeviceManager.getBase64Id(file.name)
|
||||||
|
val localFile = LocalFile(
|
||||||
|
localFileId,
|
||||||
|
file.name,
|
||||||
|
Uri.fromFile(file).toString(),
|
||||||
|
file.getBasePath(ctx),
|
||||||
|
file.absolutePath,
|
||||||
|
file.getSimplePath(ctx),
|
||||||
|
file.mimeType,
|
||||||
|
file.length()
|
||||||
|
)
|
||||||
|
localLibraryItem.localFiles.add(localFile)
|
||||||
|
|
||||||
|
val ebookFile = EBookFile(
|
||||||
|
downloadItemPart.ebookFile.ino,
|
||||||
|
downloadItemPart.ebookFile.metadata,
|
||||||
|
downloadItemPart.ebookFile.ebookFormat,
|
||||||
|
true,
|
||||||
|
localFileId,
|
||||||
|
localFile.contentUrl
|
||||||
|
)
|
||||||
|
(localLibraryItem.media as Book).ebookFile = ebookFile
|
||||||
|
Log.d(tag, "scanInternalDownloadItem: Ebook file added to lli ${localFile.contentUrl}")
|
||||||
|
} else {
|
||||||
|
val localFileId = DeviceManager.getBase64Id(file.name)
|
||||||
|
val localFile = LocalFile(localFileId,file.name,Uri.fromFile(file).toString(),file.getBasePath(ctx),file.absolutePath,file.getSimplePath(ctx),file.mimeType,file.length())
|
||||||
|
|
||||||
|
localLibraryItem.coverAbsolutePath = localFile.absolutePath
|
||||||
|
localLibraryItem.coverContentUrl = localFile.contentUrl
|
||||||
|
localLibraryItem.localFiles.add(localFile)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (audioTracks.isEmpty() && !foundEBookFile) {
|
||||||
|
Log.d(tag, "scanDownloadItem did not find any audio tracks or ebook file in folder for ${downloadItem.itemFolderPath}")
|
||||||
|
return cb(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
// For books sort audio tracks then set
|
||||||
|
if (downloadItem.mediaType == "book") {
|
||||||
|
audioTracks.sortBy { it.index }
|
||||||
|
|
||||||
|
var indexCheck = 1
|
||||||
|
var startOffset = 0.0
|
||||||
|
audioTracks.forEach { audioTrack ->
|
||||||
|
if (audioTrack.index != indexCheck || audioTrack.startOffset != startOffset) {
|
||||||
|
audioTrack.index = indexCheck
|
||||||
|
audioTrack.startOffset = startOffset
|
||||||
|
}
|
||||||
|
indexCheck++
|
||||||
|
startOffset += audioTrack.duration
|
||||||
|
}
|
||||||
|
|
||||||
|
localLibraryItem.media.setAudioTracks(audioTracks)
|
||||||
|
}
|
||||||
|
|
||||||
|
val downloadItemScanResult = DownloadItemScanResult(localLibraryItem,null)
|
||||||
|
|
||||||
|
// If library item had media progress then make local media progress and save
|
||||||
|
downloadItem.userMediaProgress?.let { mediaProgress ->
|
||||||
|
val localMediaProgressId = if (downloadItem.episodeId.isNullOrEmpty()) localLibraryItemId else "$localLibraryItemId-$localEpisodeId"
|
||||||
|
val newLocalMediaProgress = LocalMediaProgress(
|
||||||
|
id = localMediaProgressId,
|
||||||
|
localLibraryItemId = localLibraryItemId,
|
||||||
|
localEpisodeId = localEpisodeId,
|
||||||
|
duration = mediaProgress.duration,
|
||||||
|
progress = mediaProgress.progress,
|
||||||
|
currentTime = mediaProgress.currentTime,
|
||||||
|
isFinished = mediaProgress.isFinished,
|
||||||
|
ebookLocation = mediaProgress.ebookLocation,
|
||||||
|
ebookProgress = mediaProgress.ebookProgress,
|
||||||
|
lastUpdate = mediaProgress.lastUpdate,
|
||||||
|
startedAt = mediaProgress.startedAt,
|
||||||
|
finishedAt = mediaProgress.finishedAt,
|
||||||
|
serverConnectionConfigId = downloadItem.serverConnectionConfigId,
|
||||||
|
serverAddress = downloadItem.serverAddress,
|
||||||
|
serverUserId = downloadItem.serverUserId,
|
||||||
|
libraryItemId = downloadItem.libraryItemId,
|
||||||
|
episodeId = downloadItem.episodeId)
|
||||||
|
Log.d(tag, "scanLibraryItemFolder: Saving local media progress ${newLocalMediaProgress.id} at progress ${newLocalMediaProgress.progress}")
|
||||||
|
DeviceManager.dbManager.saveLocalMediaProgress(newLocalMediaProgress)
|
||||||
|
|
||||||
|
downloadItemScanResult.localMediaProgress = newLocalMediaProgress
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceManager.dbManager.saveLocalLibraryItem(localLibraryItem)
|
||||||
|
|
||||||
|
cb(downloadItemScanResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan item after download and create local library item
|
// Scan item after download and create local library item
|
||||||
fun scanDownloadItem(downloadItem: DownloadItem, cb: (DownloadItemScanResult?) -> Unit) {
|
fun scanDownloadItem(downloadItem: DownloadItem, cb: (DownloadItemScanResult?) -> Unit) {
|
||||||
|
// If downloading to internal storage handle separately
|
||||||
|
if (downloadItem.isInternalStorage) {
|
||||||
|
scanInternalDownloadItem(downloadItem, cb)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
val folderDf = DocumentFileCompat.fromUri(ctx, Uri.parse(downloadItem.localFolder.contentUrl))
|
val folderDf = DocumentFileCompat.fromUri(ctx, Uri.parse(downloadItem.localFolder.contentUrl))
|
||||||
val foldersFound = folderDf?.search(true, DocumentFileType.FOLDER) ?: mutableListOf()
|
val foldersFound = folderDf?.search(true, DocumentFileType.FOLDER) ?: mutableListOf()
|
||||||
|
|
||||||
@@ -303,7 +275,8 @@ class FolderScanner(var ctx: Context) {
|
|||||||
localLibraryItem.localFiles.add(localFile)
|
localLibraryItem.localFiles.add(localFile)
|
||||||
|
|
||||||
// Create new audio track
|
// Create new audio track
|
||||||
val track = AudioTrack(audioTrackFromServer.index, audioTrackFromServer.startOffset, audioTrackFromServer.duration, localFile.filename ?: "", localFile.contentUrl, localFile.mimeType ?: "", null, true, localFileId, null, audioTrackFromServer.index)
|
val trackFileMetadata = FileMetadata(docFile.name ?: "", docFile.extension ?: "", docFile.getAbsolutePath(ctx), docFile.getBasePath(ctx), docFile.length())
|
||||||
|
val track = AudioTrack(audioTrackFromServer.index, audioTrackFromServer.startOffset, audioTrackFromServer.duration, localFile.filename ?: "", localFile.contentUrl, localFile.mimeType ?: "", trackFileMetadata, true, localFileId, null, audioTrackFromServer.index)
|
||||||
audioTracks.add(track)
|
audioTracks.add(track)
|
||||||
|
|
||||||
Log.d(tag, "scanDownloadItem: Created Audio Track with index ${track.index} from local file ${localFile.absolutePath}")
|
Log.d(tag, "scanDownloadItem: Created Audio Track with index ${track.index} from local file ${localFile.absolutePath}")
|
||||||
@@ -370,7 +343,7 @@ class FolderScanner(var ctx: Context) {
|
|||||||
duration = mediaProgress.duration,
|
duration = mediaProgress.duration,
|
||||||
progress = mediaProgress.progress,
|
progress = mediaProgress.progress,
|
||||||
currentTime = mediaProgress.currentTime,
|
currentTime = mediaProgress.currentTime,
|
||||||
isFinished = false,
|
isFinished = mediaProgress.isFinished,
|
||||||
ebookLocation = mediaProgress.ebookLocation,
|
ebookLocation = mediaProgress.ebookLocation,
|
||||||
ebookProgress = mediaProgress.ebookProgress,
|
ebookProgress = mediaProgress.ebookProgress,
|
||||||
lastUpdate = mediaProgress.lastUpdate,
|
lastUpdate = mediaProgress.lastUpdate,
|
||||||
@@ -382,6 +355,7 @@ class FolderScanner(var ctx: Context) {
|
|||||||
libraryItemId = downloadItem.libraryItemId,
|
libraryItemId = downloadItem.libraryItemId,
|
||||||
episodeId = downloadItem.episodeId)
|
episodeId = downloadItem.episodeId)
|
||||||
Log.d(tag, "scanLibraryItemFolder: Saving local media progress ${newLocalMediaProgress.id} at progress ${newLocalMediaProgress.progress}")
|
Log.d(tag, "scanLibraryItemFolder: Saving local media progress ${newLocalMediaProgress.id} at progress ${newLocalMediaProgress.progress}")
|
||||||
|
|
||||||
DeviceManager.dbManager.saveLocalMediaProgress(newLocalMediaProgress)
|
DeviceManager.dbManager.saveLocalMediaProgress(newLocalMediaProgress)
|
||||||
|
|
||||||
downloadItemScanResult.localMediaProgress = newLocalMediaProgress
|
downloadItemScanResult.localMediaProgress = newLocalMediaProgress
|
||||||
@@ -391,132 +365,4 @@ class FolderScanner(var ctx: Context) {
|
|||||||
|
|
||||||
cb(downloadItemScanResult)
|
cb(downloadItemScanResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun scanLocalLibraryItem(localLibraryItem:LocalLibraryItem, forceAudioProbe:Boolean):LocalLibraryItemScanResult? {
|
|
||||||
val df: DocumentFile? = DocumentFileCompat.fromUri(ctx, Uri.parse(localLibraryItem.contentUrl))
|
|
||||||
|
|
||||||
if (df == null) {
|
|
||||||
Log.e(tag, "Item Folder Doc File Invalid ${localLibraryItem.absolutePath}")
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
Log.d(tag, "scanLocalLibraryItem starting for ${localLibraryItem.absolutePath} | ${df.uri}")
|
|
||||||
|
|
||||||
var wasUpdated = false
|
|
||||||
|
|
||||||
// Search for files in media item folder
|
|
||||||
val filesFound = df.search(false, DocumentFileType.FILE, arrayOf("audio/*", "image/*", "video/mp4", "application/*"))
|
|
||||||
Log.d(tag, "scanLocalLibraryItem ${filesFound.size} files found in ${localLibraryItem.absolutePath}")
|
|
||||||
|
|
||||||
filesFound.forEach {
|
|
||||||
try {
|
|
||||||
Log.d(tag, "Checking file found ${it.name} | ${it.id}")
|
|
||||||
}catch(e:Exception) {
|
|
||||||
Log.d(tag, "Check file found exception", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val existingAudioTracks = localLibraryItem.media.getAudioTracks()
|
|
||||||
|
|
||||||
// Remove any files no longer found in library item folder
|
|
||||||
val existingLocalFileIds = localLibraryItem.localFiles.map { it.id }
|
|
||||||
existingLocalFileIds.forEach { localFileId ->
|
|
||||||
Log.d(tag, "Checking local file id is there $localFileId")
|
|
||||||
if (filesFound.find { DeviceManager.getBase64Id(it.id) == localFileId } == null) {
|
|
||||||
Log.d(tag, "scanLocalLibraryItem file $localFileId was removed from ${localLibraryItem.absolutePath}")
|
|
||||||
localLibraryItem.localFiles.removeIf { it.id == localFileId }
|
|
||||||
|
|
||||||
if (existingAudioTracks.find { it.localFileId == localFileId } != null) {
|
|
||||||
Log.d(tag, "scanLocalLibraryItem audio track file $localFileId was removed from ${localLibraryItem.absolutePath}")
|
|
||||||
localLibraryItem.media.removeAudioTrack(localFileId)
|
|
||||||
}
|
|
||||||
wasUpdated = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
filesFound.forEach { docFile ->
|
|
||||||
val localFileId = DeviceManager.getBase64Id(docFile.id)
|
|
||||||
val existingLocalFile = localLibraryItem.localFiles.find { it.id == localFileId }
|
|
||||||
|
|
||||||
if (existingLocalFile == null || (existingLocalFile.isAudioFile() && forceAudioProbe)) {
|
|
||||||
|
|
||||||
val localFile = existingLocalFile ?: LocalFile(localFileId,docFile.name,docFile.uri.toString(),docFile.getBasePath(ctx), docFile.getAbsolutePath(ctx),docFile.getSimplePath(ctx),docFile.mimeType,docFile.length())
|
|
||||||
if (existingLocalFile == null) {
|
|
||||||
localLibraryItem.localFiles.add(localFile)
|
|
||||||
Log.d(tag, "scanLocalLibraryItem new file found ${localFile.filename}")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (localFile.isAudioFile()) {
|
|
||||||
// TODO: Make asynchronous
|
|
||||||
val audioProbeResult = probeAudioFile(localFile.absolutePath)
|
|
||||||
|
|
||||||
val existingTrack = existingAudioTracks.find { audioTrack ->
|
|
||||||
audioTrack.localFileId == localFileId
|
|
||||||
}
|
|
||||||
|
|
||||||
if (existingTrack == null) {
|
|
||||||
// Create new audio track
|
|
||||||
val lastTrack = existingAudioTracks.lastOrNull()
|
|
||||||
val startOffset = (lastTrack?.startOffset ?: 0.0) + (lastTrack?.duration ?: 0.0)
|
|
||||||
val track = AudioTrack(existingAudioTracks.size, startOffset, audioProbeResult?.duration ?: 0.0, localFile.filename ?: "", localFile.contentUrl, localFile.mimeType ?: "", null, true, localFileId, audioProbeResult, null)
|
|
||||||
localLibraryItem.media.addAudioTrack(track)
|
|
||||||
Log.d(tag, "Added New Audio Track ${track.title}")
|
|
||||||
wasUpdated = true
|
|
||||||
} else {
|
|
||||||
existingTrack.audioProbeResult = audioProbeResult
|
|
||||||
// TODO: Update data found from probe
|
|
||||||
|
|
||||||
Log.d(tag, "Updated Audio Track Probe Data ${existingTrack.title}")
|
|
||||||
|
|
||||||
wasUpdated = true
|
|
||||||
}
|
|
||||||
} else if (localFile.isEBookFile()) {
|
|
||||||
if (localLibraryItem.mediaType == "book") {
|
|
||||||
val existingEbookFile = (localLibraryItem.media as Book).ebookFile
|
|
||||||
if (existingEbookFile == null || existingEbookFile.localFileId != localFileId) {
|
|
||||||
val ebookFile = EBookFile(localFileId, null, localFile.getEBookFormat() ?: "", true, localFileId, localFile.contentUrl)
|
|
||||||
(localLibraryItem.media as Book).ebookFile = ebookFile
|
|
||||||
Log.d(tag, "scanLocalLibraryItem: Ebook file added to lli ${localFile.contentUrl}")
|
|
||||||
wasUpdated = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else { // Check if cover is empty
|
|
||||||
if (localLibraryItem.coverContentUrl == null) {
|
|
||||||
Log.d(tag, "scanLocalLibraryItem setting cover for ${localLibraryItem.media.metadata.title}")
|
|
||||||
localLibraryItem.coverContentUrl = localFile.contentUrl
|
|
||||||
localLibraryItem.coverAbsolutePath = localFile.absolutePath
|
|
||||||
wasUpdated = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wasUpdated) {
|
|
||||||
Log.d(tag, "Local library item was updated - saving it")
|
|
||||||
DeviceManager.dbManager.saveLocalLibraryItem(localLibraryItem)
|
|
||||||
} else {
|
|
||||||
Log.d(tag, "Local library item was up-to-date")
|
|
||||||
}
|
|
||||||
return LocalLibraryItemScanResult(wasUpdated, localLibraryItem)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun probeAudioFile(absolutePath:String):AudioProbeResult? {
|
|
||||||
val session = FFprobeKit.execute("-i \"${absolutePath}\" -print_format json -show_format -show_streams -select_streams a -show_chapters -loglevel quiet")
|
|
||||||
|
|
||||||
var probeObject:JSObject? = null
|
|
||||||
try {
|
|
||||||
probeObject = JSObject(session.output)
|
|
||||||
} catch(error:JSONException) {
|
|
||||||
Log.e(tag, "Failed to parse probe result $error")
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.d(tag, "FFprobe output $probeObject")
|
|
||||||
return if (probeObject == null || !probeObject.has("streams")) { // Check if output is empty
|
|
||||||
Log.d(tag, "probeAudioFile Probe audio file $absolutePath failed or invalid")
|
|
||||||
null
|
|
||||||
} else {
|
|
||||||
val audioProbeResult = jacksonMapper.readValue<AudioProbeResult>(session.output)
|
|
||||||
Log.d(tag, "Probe Result DATA ${audioProbeResult.duration} | ${audioProbeResult.size} | ${audioProbeResult.title} | ${audioProbeResult.artist}")
|
|
||||||
audioProbeResult
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import kotlinx.coroutines.Dispatchers
|
|||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import java.io.File
|
||||||
|
import java.io.FileOutputStream
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class DownloadItemManager(var downloadManager:DownloadManager, private var folderScanner: FolderScanner, var mainActivity: MainActivity, private var clientEventEmitter:DownloadEventEmitter) {
|
class DownloadItemManager(var downloadManager:DownloadManager, private var folderScanner: FolderScanner, var mainActivity: MainActivity, private var clientEventEmitter:DownloadEventEmitter) {
|
||||||
@@ -44,6 +46,11 @@ class DownloadItemManager(var downloadManager:DownloadManager, private var folde
|
|||||||
fun onDownloadItemComplete(jsobj:JSObject)
|
fun onDownloadItemComplete(jsobj:JSObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface InternalProgressCallback {
|
||||||
|
fun onProgress(totalBytesWritten:Long, progress: Long)
|
||||||
|
fun onComplete(failed: Boolean)
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
var isDownloading:Boolean = false
|
var isDownloading:Boolean = false
|
||||||
}
|
}
|
||||||
@@ -65,11 +72,33 @@ class DownloadItemManager(var downloadManager:DownloadManager, private var folde
|
|||||||
|
|
||||||
if (nextDownloadItemParts.size > 0) {
|
if (nextDownloadItemParts.size > 0) {
|
||||||
nextDownloadItemParts.forEach {
|
nextDownloadItemParts.forEach {
|
||||||
val dlRequest = it.getDownloadRequest()
|
if (it.isInternalStorage) {
|
||||||
val downloadId = downloadManager.enqueue(dlRequest)
|
val file = File(it.finalDestinationPath)
|
||||||
it.downloadId = downloadId
|
file.parentFile?.mkdirs()
|
||||||
Log.d(tag, "checkUpdateDownloadQueue: Starting download item part, downloadId=$downloadId")
|
|
||||||
currentDownloadItemParts.add(it)
|
val fileOutputStream = FileOutputStream(it.finalDestinationPath)
|
||||||
|
val internalProgressCallback = (object : InternalProgressCallback {
|
||||||
|
override fun onProgress(totalBytesWritten:Long, progress: Long) {
|
||||||
|
it.bytesDownloaded = totalBytesWritten
|
||||||
|
it.progress = progress
|
||||||
|
}
|
||||||
|
override fun onComplete(failed:Boolean) {
|
||||||
|
it.failed = failed
|
||||||
|
it.completed = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
Log.d(tag, "Start internal download to destination path ${it.finalDestinationPath} from ${it.serverUrl}")
|
||||||
|
InternalDownloadManager(fileOutputStream, internalProgressCallback).download(it.serverUrl)
|
||||||
|
it.downloadId = 1
|
||||||
|
currentDownloadItemParts.add(it)
|
||||||
|
} else {
|
||||||
|
val dlRequest = it.getDownloadRequest()
|
||||||
|
val downloadId = downloadManager.enqueue(dlRequest)
|
||||||
|
it.downloadId = downloadId
|
||||||
|
Log.d(tag, "checkUpdateDownloadQueue: Starting download item part, downloadId=$downloadId")
|
||||||
|
currentDownloadItemParts.add(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,14 +118,25 @@ class DownloadItemManager(var downloadManager:DownloadManager, private var folde
|
|||||||
isDownloading = true
|
isDownloading = true
|
||||||
|
|
||||||
while (currentDownloadItemParts.size > 0) {
|
while (currentDownloadItemParts.size > 0) {
|
||||||
|
|
||||||
val itemParts = currentDownloadItemParts.filter { !it.isMoving }.map { it }
|
val itemParts = currentDownloadItemParts.filter { !it.isMoving }.map { it }
|
||||||
for (downloadItemPart in itemParts) {
|
for (downloadItemPart in itemParts) {
|
||||||
val downloadCheckStatus = checkDownloadItemPart(downloadItemPart)
|
if (downloadItemPart.isInternalStorage) {
|
||||||
clientEventEmitter.onDownloadItemPartUpdate(downloadItemPart)
|
clientEventEmitter.onDownloadItemPartUpdate(downloadItemPart)
|
||||||
|
|
||||||
// Will move to final destination, remove current item parts, and check if download item is finished
|
if (downloadItemPart.completed) {
|
||||||
handleDownloadItemPartCheck(downloadCheckStatus, downloadItemPart)
|
val downloadItem = downloadItemQueue.find { it.id == downloadItemPart.downloadItemId }
|
||||||
|
downloadItem?.let {
|
||||||
|
checkDownloadItemFinished(it)
|
||||||
|
}
|
||||||
|
currentDownloadItemParts.remove(downloadItemPart)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val downloadCheckStatus = checkDownloadItemPart(downloadItemPart)
|
||||||
|
clientEventEmitter.onDownloadItemPartUpdate(downloadItemPart)
|
||||||
|
|
||||||
|
// Will move to final destination, remove current item parts, and check if download item is finished
|
||||||
|
handleDownloadItemPartCheck(downloadCheckStatus, downloadItemPart)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay(500)
|
delay(500)
|
||||||
@@ -166,7 +206,6 @@ class DownloadItemManager(var downloadManager:DownloadManager, private var folde
|
|||||||
Log.e(tag, "Download item part finished but download item not found ${downloadItemPart.filename}")
|
Log.e(tag, "Download item part finished but download item not found ${downloadItemPart.filename}")
|
||||||
currentDownloadItemParts.remove(downloadItemPart)
|
currentDownloadItemParts.remove(downloadItemPart)
|
||||||
} else if (downloadCheckStatus == DownloadCheckStatus.Successful) {
|
} else if (downloadCheckStatus == DownloadCheckStatus.Successful) {
|
||||||
|
|
||||||
val file = DocumentFileCompat.fromUri(mainActivity, downloadItemPart.destinationUri)
|
val file = DocumentFileCompat.fromUri(mainActivity, downloadItemPart.destinationUri)
|
||||||
Log.d(tag, "DOWNLOAD: DESTINATION URI ${downloadItemPart.destinationUri}")
|
Log.d(tag, "DOWNLOAD: DESTINATION URI ${downloadItemPart.destinationUri}")
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package com.audiobookshelf.app.managers
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import com.google.common.net.HttpHeaders.CONTENT_LENGTH
|
||||||
|
import okhttp3.*
|
||||||
|
import java.io.*
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class InternalDownloadManager(outputStream:FileOutputStream, private val progressCallback: DownloadItemManager.InternalProgressCallback) : AutoCloseable {
|
||||||
|
private val tag = "InternalDownloadManager"
|
||||||
|
|
||||||
|
private val client: OkHttpClient = OkHttpClient()
|
||||||
|
private val writer = BinaryFileWriter(outputStream, progressCallback)
|
||||||
|
|
||||||
|
@Throws(IOException::class)
|
||||||
|
fun download(url:String) {
|
||||||
|
val request: Request = Request.Builder().url(url).build()
|
||||||
|
client.newCall(request).enqueue(object : Callback {
|
||||||
|
override fun onFailure(call: Call, e: IOException) {
|
||||||
|
Log.e(tag, "download URL $url FAILED")
|
||||||
|
progressCallback.onComplete(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call, response: Response) {
|
||||||
|
val responseBody: ResponseBody = response.body
|
||||||
|
?: throw IllegalStateException("Response doesn't contain a file")
|
||||||
|
|
||||||
|
val length: Long = (response.header(CONTENT_LENGTH, "1") ?: "0").toLong()
|
||||||
|
writer.write(responseBody.byteStream(), length)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
@Throws(Exception::class)
|
||||||
|
override fun close() {
|
||||||
|
writer.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class BinaryFileWriter(outputStream: OutputStream, progressCallback: DownloadItemManager.InternalProgressCallback) :
|
||||||
|
AutoCloseable {
|
||||||
|
private val outputStream: OutputStream
|
||||||
|
private val progressCallback: DownloadItemManager.InternalProgressCallback
|
||||||
|
|
||||||
|
init {
|
||||||
|
this.outputStream = outputStream
|
||||||
|
this.progressCallback = progressCallback
|
||||||
|
}
|
||||||
|
|
||||||
|
@Throws(IOException::class)
|
||||||
|
fun write(inputStream: InputStream?, length: Long): Long {
|
||||||
|
BufferedInputStream(inputStream).use { input ->
|
||||||
|
val dataBuffer = ByteArray(CHUNK_SIZE)
|
||||||
|
var readBytes: Int
|
||||||
|
var totalBytes: Long = 0
|
||||||
|
while (input.read(dataBuffer).also { readBytes = it } != -1) {
|
||||||
|
totalBytes += readBytes.toLong()
|
||||||
|
outputStream.write(dataBuffer, 0, readBytes)
|
||||||
|
progressCallback.onProgress(totalBytes, (totalBytes * 100L) / length)
|
||||||
|
}
|
||||||
|
progressCallback.onComplete(false)
|
||||||
|
return totalBytes
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Throws(IOException::class)
|
||||||
|
override fun close() {
|
||||||
|
outputStream.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val CHUNK_SIZE = 1024
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,13 +20,23 @@ class MediaManager(private var apiHandler: ApiHandler, var ctx: Context) {
|
|||||||
val tag = "MediaManager"
|
val tag = "MediaManager"
|
||||||
|
|
||||||
private var serverLibraryItems = mutableListOf<LibraryItem>() // Store all items here
|
private var serverLibraryItems = mutableListOf<LibraryItem>() // Store all items here
|
||||||
private var selectedLibraryItems = mutableListOf<LibraryItem>()
|
|
||||||
private var selectedLibraryId = ""
|
private var cachedLibraryAuthors : MutableMap<String, MutableMap<String, LibraryAuthorItem>> = hashMapOf()
|
||||||
|
private var cachedLibraryAuthorItems : MutableMap<String, MutableMap<String, List<LibraryItem>>> = hashMapOf()
|
||||||
|
private var cachedLibraryAuthorSeriesItems : MutableMap<String, MutableMap<String, List<LibraryItem>>> = hashMapOf()
|
||||||
|
private var cachedLibrarySeries : MutableMap<String, List<LibrarySeriesItem>> = hashMapOf()
|
||||||
|
private var cachedLibrarySeriesItem : MutableMap<String, MutableMap<String, List<LibraryItem>>> = hashMapOf()
|
||||||
|
private var cachedLibraryCollections : MutableMap<String, MutableMap<String, LibraryCollection>> = hashMapOf()
|
||||||
|
private var cachedLibraryRecentShelves : MutableMap<String, MutableList<LibraryShelfType>> = hashMapOf()
|
||||||
|
private var cachedLibraryDiscovery : MutableMap<String, MutableList<LibraryItem>> = hashMapOf()
|
||||||
|
private var cachedLibraryPodcasts : MutableMap<String, MutableMap<String, LibraryItem>> = hashMapOf()
|
||||||
|
private var isLibraryPodcastsCached : MutableMap<String, Boolean> = hashMapOf()
|
||||||
|
var allLibraryPersonalizationsDone : Boolean = false
|
||||||
|
private var libraryPersonalizationsDone : Int = 0
|
||||||
|
|
||||||
private var selectedPodcast:Podcast? = null
|
private var selectedPodcast:Podcast? = null
|
||||||
private var selectedLibraryItemId:String? = null
|
private var selectedLibraryItemId:String? = null
|
||||||
private var podcastEpisodeLibraryItemMap = mutableMapOf<String, LibraryItemWithEpisode>()
|
private var podcastEpisodeLibraryItemMap = mutableMapOf<String, LibraryItemWithEpisode>()
|
||||||
private var serverLibraryCategories = listOf<LibraryCategory>()
|
|
||||||
private var serverConfigIdUsed:String? = null
|
private var serverConfigIdUsed:String? = null
|
||||||
private var serverConfigLastPing:Long = 0L
|
private var serverConfigLastPing:Long = 0L
|
||||||
var serverUserMediaProgress:MutableList<MediaProgress> = mutableListOf()
|
var serverUserMediaProgress:MutableList<MediaProgress> = mutableListOf()
|
||||||
@@ -39,6 +49,35 @@ class MediaManager(private var apiHandler: ApiHandler, var ctx: Context) {
|
|||||||
return serverLibraries.find { it.id == id } != null
|
return serverLibraries.find { it.id == id } != null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if there is discovery shelf for [libraryId]
|
||||||
|
* If personalized shelves are not yet populated for library then populate
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
fun getHasDiscovery(libraryId: String) : Boolean {
|
||||||
|
if (cachedLibraryDiscovery.containsKey(libraryId)) {
|
||||||
|
if (cachedLibraryDiscovery[libraryId]!!.isNotEmpty()) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
populatePersonalizedDataForLibrary(libraryId){}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getLibrary(id:String) : Library? {
|
||||||
|
return serverLibraries.find { it.id == id }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add [libraryItem] to [serverLibraryItems] if it is not already added
|
||||||
|
*/
|
||||||
|
private fun addServerLibrary(libraryItem: LibraryItem) {
|
||||||
|
if (serverLibraryItems.find { li -> li.id == libraryItem.id } == null) {
|
||||||
|
serverLibraryItems.add(libraryItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun getSavedPlaybackRate():Float {
|
fun getSavedPlaybackRate():Float {
|
||||||
if (userSettingsPlaybackRate != null) {
|
if (userSettingsPlaybackRate != null) {
|
||||||
return userSettingsPlaybackRate ?: 1f
|
return userSettingsPlaybackRate ?: 1f
|
||||||
@@ -91,19 +130,32 @@ class MediaManager(private var apiHandler: ApiHandler, var ctx: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun checkResetServerItems() {
|
fun checkResetServerItems():Boolean {
|
||||||
// When opening android auto need to check if still connected to server
|
// When opening android auto need to check if still connected to server
|
||||||
// and reset any server data already set
|
// and reset any server data already set
|
||||||
val serverConnConfig = if (DeviceManager.isConnectedToServer) DeviceManager.serverConnectionConfig else DeviceManager.deviceData.getLastServerConnectionConfig()
|
val serverConnConfig = if (DeviceManager.isConnectedToServer) DeviceManager.serverConnectionConfig else DeviceManager.deviceData.getLastServerConnectionConfig()
|
||||||
|
|
||||||
if (!DeviceManager.isConnectedToServer || !DeviceManager.checkConnectivity(ctx) || serverConnConfig == null || serverConnConfig.id !== serverConfigIdUsed) {
|
if (!DeviceManager.isConnectedToServer || !DeviceManager.checkConnectivity(ctx) || serverConnConfig == null || serverConnConfig.id !== serverConfigIdUsed) {
|
||||||
|
Log.d(tag, "Reset caches")
|
||||||
podcastEpisodeLibraryItemMap = mutableMapOf()
|
podcastEpisodeLibraryItemMap = mutableMapOf()
|
||||||
serverLibraryCategories = listOf()
|
|
||||||
serverLibraries = listOf()
|
serverLibraries = listOf()
|
||||||
serverLibraryItems = mutableListOf()
|
serverLibraryItems = mutableListOf()
|
||||||
selectedLibraryItems = mutableListOf()
|
cachedLibraryAuthors = hashMapOf()
|
||||||
selectedLibraryId = ""
|
cachedLibraryAuthorItems = hashMapOf()
|
||||||
|
cachedLibraryAuthorSeriesItems = hashMapOf()
|
||||||
|
cachedLibrarySeries = hashMapOf()
|
||||||
|
cachedLibrarySeriesItem = hashMapOf()
|
||||||
|
cachedLibraryCollections = hashMapOf()
|
||||||
|
cachedLibraryRecentShelves = hashMapOf()
|
||||||
|
cachedLibraryDiscovery = hashMapOf()
|
||||||
|
cachedLibraryPodcasts = hashMapOf()
|
||||||
|
isLibraryPodcastsCached = hashMapOf()
|
||||||
|
serverItemsInProgress = listOf()
|
||||||
|
allLibraryPersonalizationsDone = false
|
||||||
|
libraryPersonalizationsDone = 0
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadItemsInProgressForAllLibraries(cb: (List<ItemInProgress>) -> Unit) {
|
private fun loadItemsInProgressForAllLibraries(cb: (List<ItemInProgress>) -> Unit) {
|
||||||
@@ -111,34 +163,467 @@ class MediaManager(private var apiHandler: ApiHandler, var ctx: Context) {
|
|||||||
cb(serverItemsInProgress)
|
cb(serverItemsInProgress)
|
||||||
} else {
|
} else {
|
||||||
apiHandler.getAllItemsInProgress { itemsInProgress ->
|
apiHandler.getAllItemsInProgress { itemsInProgress ->
|
||||||
serverItemsInProgress = itemsInProgress
|
serverItemsInProgress = itemsInProgress.filter {
|
||||||
|
val libraryItem = it.libraryItemWrapper as LibraryItem
|
||||||
|
libraryItem.checkHasTracks()
|
||||||
|
}
|
||||||
cb(serverItemsInProgress)
|
cb(serverItemsInProgress)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadLibraryItemsWithAudio(libraryId:String, cb: (List<LibraryItem>) -> Unit) {
|
/**
|
||||||
if (selectedLibraryItems.isNotEmpty() && selectedLibraryId == libraryId) {
|
* Load personalized shelves from server for all libraries.
|
||||||
cb(selectedLibraryItems)
|
* [cb] resolves when all libraries are processed
|
||||||
|
*/
|
||||||
|
fun populatePersonalizedDataForAllLibraries(cb: () -> Unit ) {
|
||||||
|
serverLibraries.forEach {
|
||||||
|
libraryPersonalizationsDone++
|
||||||
|
Log.d(tag, "Loading personalization for library ${it.name} - ${it.id} - ${it.mediaType}")
|
||||||
|
populatePersonalizedDataForLibrary(it.id) {
|
||||||
|
Log.d(tag, "Loaded personalization for library ${it.name} - ${it.id} - ${it.mediaType}")
|
||||||
|
libraryPersonalizationsDone--
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (libraryPersonalizationsDone > 0) { }
|
||||||
|
|
||||||
|
Log.d(tag, "Finished loading all library personalization data")
|
||||||
|
allLibraryPersonalizationsDone = true
|
||||||
|
cb()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get personalized shelves from server for selected [libraryId].
|
||||||
|
* Populates [cachedLibraryRecentShelves] and [cachedLibraryDiscovery].
|
||||||
|
*/
|
||||||
|
private fun populatePersonalizedDataForLibrary(libraryId: String, cb: () -> Unit) {
|
||||||
|
apiHandler.getLibraryPersonalized(libraryId) { shelves ->
|
||||||
|
Log.d(tag, "populatePersonalizedDataForLibrary $libraryId")
|
||||||
|
if (shelves === null) return@getLibraryPersonalized
|
||||||
|
shelves.map { shelf ->
|
||||||
|
Log.d(tag, "$shelf")
|
||||||
|
if (shelf.type == "book") {
|
||||||
|
if (shelf.id == "continue-listening") return@map
|
||||||
|
else if (shelf.id == "listen-again") return@map
|
||||||
|
else if (shelf.id == "recently-added") {
|
||||||
|
if (!cachedLibraryRecentShelves.containsKey(libraryId)) {
|
||||||
|
cachedLibraryRecentShelves[libraryId] = mutableListOf()
|
||||||
|
}
|
||||||
|
if (cachedLibraryRecentShelves[libraryId]?.find { it.id == shelf.id } == null) {
|
||||||
|
cachedLibraryRecentShelves[libraryId]!!.add(shelf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (shelf.id == "discover") {
|
||||||
|
if (!cachedLibraryDiscovery.containsKey(libraryId)) {
|
||||||
|
cachedLibraryDiscovery[libraryId] = mutableListOf()
|
||||||
|
}
|
||||||
|
(shelf as LibraryShelfBookEntity).entities?.map {
|
||||||
|
cachedLibraryDiscovery[libraryId]!!.add(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (shelf.id == "continue-reading") return@map
|
||||||
|
else if (shelf.id == "continue-series") return@map
|
||||||
|
shelf as LibraryShelfBookEntity
|
||||||
|
} else if (shelf.type == "series") {
|
||||||
|
if (shelf.id == "recent-series") {
|
||||||
|
if (!cachedLibraryRecentShelves.containsKey(libraryId)) {
|
||||||
|
cachedLibraryRecentShelves[libraryId] = mutableListOf()
|
||||||
|
}
|
||||||
|
if (cachedLibraryRecentShelves[libraryId]?.find { it.id == shelf.id } == null) {
|
||||||
|
cachedLibraryRecentShelves[libraryId]!!.add(shelf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (shelf.type == "episode") {
|
||||||
|
if (shelf.id == "continue-listening") return@map
|
||||||
|
else if (shelf.id == "listen-again") return@map
|
||||||
|
else if (shelf.id == "newest-episodes") {
|
||||||
|
if (!cachedLibraryRecentShelves.containsKey(libraryId)) {
|
||||||
|
cachedLibraryRecentShelves[libraryId] = mutableListOf()
|
||||||
|
}
|
||||||
|
if (cachedLibraryRecentShelves[libraryId]?.find { it.id == shelf.id } == null) {
|
||||||
|
cachedLibraryRecentShelves[libraryId]!!.add(shelf)
|
||||||
|
}
|
||||||
|
|
||||||
|
val podcastLibraryItemIds = mutableListOf<String>()
|
||||||
|
(shelf as LibraryShelfEpisodeEntity).entities?.forEach { libraryItem ->
|
||||||
|
if (!podcastLibraryItemIds.contains(libraryItem.id)) {
|
||||||
|
podcastLibraryItemIds.add(libraryItem.id)
|
||||||
|
loadPodcastItem(libraryItem.libraryId, libraryItem.id) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (shelf.type == "podcast") {
|
||||||
|
if (shelf.id == "recently-added"){
|
||||||
|
if (!cachedLibraryRecentShelves.containsKey(libraryId)) {
|
||||||
|
cachedLibraryRecentShelves[libraryId] = mutableListOf()
|
||||||
|
}
|
||||||
|
if (cachedLibraryRecentShelves[libraryId]?.find { it.id == shelf.id } == null) {
|
||||||
|
cachedLibraryRecentShelves[libraryId]!!.add(shelf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (shelf.id == "discover"){
|
||||||
|
return@map
|
||||||
|
}
|
||||||
|
} else if (shelf.type =="authors") {
|
||||||
|
if (shelf.id == "newest-authors") {
|
||||||
|
if (!cachedLibraryRecentShelves.containsKey(libraryId)) {
|
||||||
|
cachedLibraryRecentShelves[libraryId] = mutableListOf()
|
||||||
|
}
|
||||||
|
if (cachedLibraryRecentShelves[libraryId]?.find { it.id == shelf.id } == null) {
|
||||||
|
cachedLibraryRecentShelves[libraryId]!!.add(shelf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Log.d(tag, "populatePersonalizedDataForLibrary $libraryId DONE")
|
||||||
|
cb()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns podcasts for selected library.
|
||||||
|
* If data is not found from local cache it is loaded from server
|
||||||
|
*/
|
||||||
|
fun loadLibraryPodcasts(libraryId:String, cb: (List<LibraryItem>?) -> Unit) {
|
||||||
|
// Without this there is possibility that only recent podcasts get loaded
|
||||||
|
// Loading recent podcasts will also create cachedLibraryPodcasts entry for library
|
||||||
|
if (!isLibraryPodcastsCached.containsKey(libraryId)) {
|
||||||
|
isLibraryPodcastsCached[libraryId] = false
|
||||||
|
}
|
||||||
|
// Ensure that there is map for library
|
||||||
|
if (!cachedLibraryPodcasts.containsKey(libraryId)) {
|
||||||
|
cachedLibraryPodcasts[libraryId] = mutableMapOf()
|
||||||
|
}
|
||||||
|
if (isLibraryPodcastsCached.getOrElse(libraryId) {false}) {
|
||||||
|
Log.d(tag, "loadLibraryPodcasts: Found from cache: $libraryId")
|
||||||
|
cb(cachedLibraryPodcasts[libraryId]?.values?.sortedBy { libraryItem -> (libraryItem.media as Podcast).metadata.title })
|
||||||
} else {
|
} else {
|
||||||
apiHandler.getLibraryItems(libraryId) { libraryItems ->
|
apiHandler.getLibraryItems(libraryId) { libraryItems ->
|
||||||
val libraryItemsWithAudio = libraryItems.filter { li -> li.checkHasTracks() }
|
val libraryItemsWithAudio = libraryItems.filter { li -> li.checkHasTracks() }
|
||||||
if (libraryItemsWithAudio.isNotEmpty()) {
|
|
||||||
selectedLibraryId = libraryId
|
|
||||||
}
|
|
||||||
|
|
||||||
selectedLibraryItems = mutableListOf()
|
|
||||||
libraryItemsWithAudio.forEach { libraryItem ->
|
libraryItemsWithAudio.forEach { libraryItem ->
|
||||||
selectedLibraryItems.add(libraryItem)
|
cachedLibraryPodcasts[libraryId]?.set(libraryItem.id, libraryItem)
|
||||||
if (serverLibraryItems.find { li -> li.id == libraryItem.id } == null) {
|
if (serverLibraryItems.find { li -> li.id == libraryItem.id } == null) {
|
||||||
serverLibraryItems.add(libraryItem)
|
serverLibraryItems.add(libraryItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
isLibraryPodcastsCached[libraryId] = true
|
||||||
|
Log.d(tag, "loadLibraryPodcasts: loaded from server: $libraryId")
|
||||||
|
cb(libraryItemsWithAudio.sortedBy { libraryItem -> (libraryItem.media as Podcast).metadata.title })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns series with audio books from selected library.
|
||||||
|
* If data is not found from local cache then it will be fetched from server
|
||||||
|
*/
|
||||||
|
fun loadLibrarySeriesWithAudio(libraryId:String, cb: (List<LibrarySeriesItem>) -> Unit) {
|
||||||
|
// Check "cache" first
|
||||||
|
if (cachedLibrarySeries.containsKey(libraryId)) {
|
||||||
|
Log.d(tag, "Series with audio found from cache | Library $libraryId ")
|
||||||
|
cb(cachedLibrarySeries[libraryId] as List<LibrarySeriesItem>)
|
||||||
|
} else {
|
||||||
|
apiHandler.getLibrarySeries(libraryId) { seriesItems ->
|
||||||
|
Log.d(tag, "Series with audio loaded from server | Library $libraryId")
|
||||||
|
val seriesItemsWithAudio = seriesItems.filter { si -> si.audiobookCount > 0 }
|
||||||
|
|
||||||
|
cachedLibrarySeries[libraryId] = seriesItemsWithAudio
|
||||||
|
|
||||||
|
cb(seriesItemsWithAudio)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns series with audiobooks from selected library using filter for paging.
|
||||||
|
* If data is not found from local cache then it will be fetched from server
|
||||||
|
*/
|
||||||
|
fun loadLibrarySeriesWithAudio(libraryId:String, seriesFilter:String, cb: (List<LibrarySeriesItem>) -> Unit) {
|
||||||
|
// Check "cache" first
|
||||||
|
if (!cachedLibrarySeries.containsKey(libraryId)) {
|
||||||
|
loadLibrarySeriesWithAudio(libraryId) {}
|
||||||
|
} else {
|
||||||
|
Log.d(tag, "Series with audio found from cache | Library $libraryId ")
|
||||||
|
}
|
||||||
|
val seriesWithBooks = cachedLibrarySeries[libraryId]!!.filter { ls -> ls.title.uppercase().startsWith(seriesFilter) }.toList()
|
||||||
|
cb(seriesWithBooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sorts books in series. Assumes that sequence is main.minor
|
||||||
|
*/
|
||||||
|
private fun sortSeriesBooks(seriesBooks: List<LibraryItem>) : List<LibraryItem> {
|
||||||
|
val sortingLogic = compareBy<LibraryItem> { it.seriesSequenceParts[0].length }
|
||||||
|
.thenBy { it.seriesSequenceParts[0].ifEmpty { "" } }
|
||||||
|
.thenBy { it.seriesSequenceParts.getOrElse(1) { "" }.length }
|
||||||
|
.thenBy { it.seriesSequenceParts.getOrElse(1) { "" } }
|
||||||
|
return seriesBooks.sortedWith(sortingLogic)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns books for series from library.
|
||||||
|
* If data is not found from local cache then it will be fetched from server
|
||||||
|
*/
|
||||||
|
fun loadLibrarySeriesItemsWithAudio(libraryId:String, seriesId:String, cb: (List<LibraryItem>) -> Unit) {
|
||||||
|
// Check "cache" first
|
||||||
|
if (!cachedLibrarySeriesItem.containsKey(libraryId)) {
|
||||||
|
cachedLibrarySeriesItem[libraryId] = hashMapOf()
|
||||||
|
}
|
||||||
|
if (cachedLibrarySeriesItem[libraryId]!!.containsKey(seriesId)) {
|
||||||
|
Log.d(tag, "Items for series $seriesId found from cache | Library $libraryId")
|
||||||
|
cachedLibrarySeriesItem[libraryId]!![seriesId]?.let { cb(it) }
|
||||||
|
} else {
|
||||||
|
apiHandler.getLibrarySeriesItems(libraryId, seriesId) { libraryItems ->
|
||||||
|
Log.d(tag, "Items for series $seriesId loaded from server | Library $libraryId")
|
||||||
|
val libraryItemsWithAudio = libraryItems.filter { li -> li.checkHasTracks() }
|
||||||
|
|
||||||
|
val sortedLibraryItemsWithAudio = sortSeriesBooks(libraryItemsWithAudio)
|
||||||
|
cachedLibrarySeriesItem[libraryId]!![seriesId] = sortedLibraryItemsWithAudio
|
||||||
|
|
||||||
|
sortedLibraryItemsWithAudio.forEach { libraryItem ->
|
||||||
|
if (serverLibraryItems.find { li -> li.id == libraryItem.id } == null) {
|
||||||
|
serverLibraryItems.add(libraryItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cb(sortedLibraryItemsWithAudio)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns authors with books from library.
|
||||||
|
* If data is not found from local cache then it will be fetched from server
|
||||||
|
*/
|
||||||
|
fun loadAuthorsWithBooks(libraryId:String, cb: (List<LibraryAuthorItem>) -> Unit) {
|
||||||
|
// Check "cache" first
|
||||||
|
if (cachedLibraryAuthors.containsKey(libraryId)) {
|
||||||
|
Log.d(tag, "Authors with books found from cache | Library $libraryId ")
|
||||||
|
cb(cachedLibraryAuthors[libraryId]!!.values.toList())
|
||||||
|
} else {
|
||||||
|
// Fetch data from server and add it to local "cache"
|
||||||
|
apiHandler.getLibraryAuthors(libraryId) { authorItems ->
|
||||||
|
Log.d(tag, "Authors with books loaded from server | Library $libraryId ")
|
||||||
|
// TO-DO: This check won't ensure that there is audiobooks. Current API won't offer ability to do so
|
||||||
|
var authorItemsWithBooks = authorItems.filter { li -> li.bookCount != null && li.bookCount!! > 0 }
|
||||||
|
authorItemsWithBooks = authorItemsWithBooks.sortedBy { it.name }
|
||||||
|
// Ensure that there is map for library
|
||||||
|
cachedLibraryAuthors[libraryId] = mutableMapOf()
|
||||||
|
// Cache authors
|
||||||
|
authorItemsWithBooks.forEach {
|
||||||
|
if (!cachedLibraryAuthors[libraryId]!!.containsKey(it.id)) {
|
||||||
|
cachedLibraryAuthors[libraryId]!![it.id] = it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cb(authorItemsWithBooks)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns authors with books from selected library using filter for paging.
|
||||||
|
* If data is not found from local cache then it will be fetched from server
|
||||||
|
*/
|
||||||
|
fun loadAuthorsWithBooks(libraryId:String, authorFilter: String, cb: (List<LibraryAuthorItem>) -> Unit) {
|
||||||
|
// Check "cache" first
|
||||||
|
if (cachedLibraryAuthors.containsKey(libraryId)) {
|
||||||
|
Log.d(tag, "Authors with books found from cache | Library $libraryId ")
|
||||||
|
} else {
|
||||||
|
loadAuthorsWithBooks(libraryId) {}
|
||||||
|
}
|
||||||
|
val authorsWithBooks = cachedLibraryAuthors[libraryId]!!.values.filter { lai -> lai.name.uppercase().startsWith(authorFilter) }.toList()
|
||||||
|
cb(authorsWithBooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns audiobooks for author from library
|
||||||
|
* If data is not found from local cache then it will be fetched from server
|
||||||
|
*/
|
||||||
|
fun loadAuthorBooksWithAudio(libraryId:String, authorId:String, cb: (List<LibraryItem>) -> Unit) {
|
||||||
|
// Ensure that there is map for library
|
||||||
|
if (!cachedLibraryAuthorItems.containsKey(libraryId)) {
|
||||||
|
cachedLibraryAuthorItems[libraryId] = mutableMapOf()
|
||||||
|
}
|
||||||
|
// Check "cache" first
|
||||||
|
if (cachedLibraryAuthorItems[libraryId]!!.containsKey(authorId)) {
|
||||||
|
Log.d(tag, "Items for author $authorId found from cache | Library $libraryId")
|
||||||
|
cachedLibraryAuthorItems[libraryId]!![authorId]?.let { cb(it) }
|
||||||
|
} else {
|
||||||
|
apiHandler.getLibraryItemsFromAuthor(libraryId, authorId) { libraryItems ->
|
||||||
|
Log.d(tag, "Items for author $authorId loaded from server | Library $libraryId")
|
||||||
|
val libraryItemsWithAudio = libraryItems.filter { li -> li.checkHasTracks() }
|
||||||
|
|
||||||
|
cachedLibraryAuthorItems[libraryId]!![authorId] = libraryItemsWithAudio
|
||||||
|
|
||||||
|
libraryItemsWithAudio.forEach { libraryItem ->
|
||||||
|
if (serverLibraryItems.find { li -> li.id == libraryItem.id } == null) {
|
||||||
|
serverLibraryItems.add(libraryItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cb(libraryItemsWithAudio)
|
cb(libraryItemsWithAudio)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns audiobooks for author from specified series within library
|
||||||
|
* If data is not found from local cache then it will be fetched from server
|
||||||
|
*/
|
||||||
|
fun loadAuthorSeriesBooksWithAudio(libraryId:String, authorId:String, seriesId: String, cb: (List<LibraryItem>) -> Unit) {
|
||||||
|
val authorSeriesKey = "$authorId|$seriesId"
|
||||||
|
// Ensure that there is map for library
|
||||||
|
if (!cachedLibraryAuthorSeriesItems.containsKey(libraryId)) {
|
||||||
|
cachedLibraryAuthorSeriesItems[libraryId] = mutableMapOf()
|
||||||
|
}
|
||||||
|
// Check "cache" first
|
||||||
|
if (cachedLibraryAuthorSeriesItems[libraryId]!!.containsKey(authorSeriesKey)) {
|
||||||
|
Log.d(tag, "Items for series $seriesId with author $authorId found from cache | Library $libraryId")
|
||||||
|
cachedLibraryAuthorSeriesItems[libraryId]!![authorSeriesKey]?.let { cb(it) }
|
||||||
|
} else {
|
||||||
|
apiHandler.getLibrarySeriesItems(libraryId, seriesId) { libraryItems ->
|
||||||
|
Log.d(tag, "Items for series $seriesId with author $authorId loaded from server | Library $libraryId")
|
||||||
|
val libraryItemsWithAudio = libraryItems.filter { li -> li.checkHasTracks() }
|
||||||
|
if (!cachedLibraryAuthors[libraryId]!!.containsKey(authorId)) {
|
||||||
|
Log.d(tag, "Author data is missing")
|
||||||
|
}
|
||||||
|
val authorName = cachedLibraryAuthors[libraryId]!![authorId]?.name ?: ""
|
||||||
|
Log.d(tag, "Using author name: $authorName")
|
||||||
|
val libraryItemsFromAuthorWithAudio = libraryItemsWithAudio.filter { li -> li.authorName.indexOf(authorName, ignoreCase = true) >= 0 }
|
||||||
|
|
||||||
|
val sortedLibraryItemsWithAudio = sortSeriesBooks(libraryItemsFromAuthorWithAudio)
|
||||||
|
cachedLibraryAuthorSeriesItems[libraryId]!![authorId] = sortedLibraryItemsWithAudio
|
||||||
|
|
||||||
|
sortedLibraryItemsWithAudio.forEach { libraryItem ->
|
||||||
|
if (serverLibraryItems.find { li -> li.id == libraryItem.id } == null) {
|
||||||
|
serverLibraryItems.add(libraryItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cb(sortedLibraryItemsWithAudio)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns collections with audiobooks from library
|
||||||
|
* If data is not found from local cache then it will be fetched from server
|
||||||
|
*/
|
||||||
|
fun loadLibraryCollectionsWithAudio(libraryId:String, cb: (List<LibraryCollection>) -> Unit) {
|
||||||
|
if (cachedLibraryCollections.containsKey(libraryId)) {
|
||||||
|
Log.d(tag, "Collections with books found from cache | Library $libraryId ")
|
||||||
|
cb(cachedLibraryCollections[libraryId]!!.values.toList())
|
||||||
|
} else {
|
||||||
|
apiHandler.getLibraryCollections(libraryId) { libraryCollections ->
|
||||||
|
Log.d(tag, "Collections with books loaded from server | Library $libraryId ")
|
||||||
|
val libraryCollectionsWithAudio = libraryCollections.filter { lc -> lc.audiobookCount > 0 }
|
||||||
|
|
||||||
|
// Cache collections
|
||||||
|
cachedLibraryCollections[libraryId] = hashMapOf()
|
||||||
|
libraryCollectionsWithAudio.forEach {
|
||||||
|
if (!cachedLibraryCollections[libraryId]!!.containsKey(it.id)) {
|
||||||
|
cachedLibraryCollections[libraryId]!![it.id] = it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cb(libraryCollectionsWithAudio)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns audiobooks for collection from library
|
||||||
|
* If data is not found from local cache then it will be fetched from server
|
||||||
|
*/
|
||||||
|
fun loadLibraryCollectionBooksWithAudio(libraryId: String, collectionId: String, cb: (List<LibraryItem>) -> Unit) {
|
||||||
|
if (!cachedLibraryCollections.containsKey(libraryId)) {
|
||||||
|
loadLibraryCollectionsWithAudio(libraryId) {}
|
||||||
|
}
|
||||||
|
Log.d(tag, "Trying to find collection $collectionId items from from cache | Library $libraryId ")
|
||||||
|
if ( cachedLibraryCollections[libraryId]!!.containsKey(collectionId)) {
|
||||||
|
val libraryCollectionBookswithAudio = cachedLibraryCollections[libraryId]!![collectionId]?.books
|
||||||
|
libraryCollectionBookswithAudio?.forEach { libraryItem ->
|
||||||
|
if (serverLibraryItems.find { li -> li.id == libraryItem.id } == null) {
|
||||||
|
serverLibraryItems.add(libraryItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cb(libraryCollectionBookswithAudio as List<LibraryItem>)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns audiobooks from discovery shelf for [libraryId]
|
||||||
|
* If data is not found from local cache then it will be fetched from server
|
||||||
|
*/
|
||||||
|
fun loadLibraryDiscoveryBooksWithAudio(libraryId: String, cb: (List<LibraryItem>) -> Unit) {
|
||||||
|
if (!cachedLibraryDiscovery.containsKey(libraryId)) {
|
||||||
|
cb(listOf())
|
||||||
|
}
|
||||||
|
val libraryItemsWithAudio = cachedLibraryDiscovery[libraryId]?.filter { li -> li.checkHasTracks() }
|
||||||
|
libraryItemsWithAudio?.forEach { libraryItem -> addServerLibrary(libraryItem) }
|
||||||
|
cb(libraryItemsWithAudio as List<LibraryItem>)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns recent shelves for [libraryId]
|
||||||
|
* If data is not shelves are found returns empty list
|
||||||
|
*/
|
||||||
|
fun getLibraryRecentShelfs(libraryId: String, cb: (List<LibraryShelfType>) -> Unit) {
|
||||||
|
if (!cachedLibraryRecentShelves.containsKey(libraryId)) {
|
||||||
|
Log.d(tag, "getLibraryRecentShelfs: No shelves $libraryId")
|
||||||
|
cb(listOf())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cb(cachedLibraryRecentShelves[libraryId] as List<LibraryShelfType>)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns recent shelf by [type] for [libraryId]
|
||||||
|
* If shelf is not found returns null
|
||||||
|
*/
|
||||||
|
fun getLibraryRecentShelfByType(libraryId: String, type:String, cb: (LibraryShelfType?) -> Unit) {
|
||||||
|
Log.d(tag, "getLibraryRecentShelfByType: $libraryId | $type")
|
||||||
|
if (!cachedLibraryRecentShelves.containsKey(libraryId)) {
|
||||||
|
cb(null)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for (shelf in cachedLibraryRecentShelves[libraryId]!!) {
|
||||||
|
if (shelf.type == type.lowercase()) {
|
||||||
|
cb(shelf)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cb(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads podcasts for newest episodes shelf
|
||||||
|
*/
|
||||||
|
private fun loadPodcastItem(libraryId: String, libraryItemId: String, cb: (LibraryItem?) -> Unit) {
|
||||||
|
// Ensure that there is map for library
|
||||||
|
if (!cachedLibraryPodcasts.containsKey(libraryId)) {
|
||||||
|
cachedLibraryPodcasts[libraryId] = mutableMapOf()
|
||||||
|
}
|
||||||
|
if (cachedLibraryPodcasts[libraryId]!!.containsKey(libraryItemId)) {
|
||||||
|
Log.d(tag, "loadPodcastItem: Podcast found from cache | Library $libraryItemId ")
|
||||||
|
cb(cachedLibraryPodcasts[libraryId]?.get(libraryItemId))
|
||||||
|
} else {
|
||||||
|
Log.d(tag, "loadPodcastItem: Calling getLibraryItem $libraryItemId")
|
||||||
|
apiHandler.getLibraryItem(libraryItemId) { libraryItem ->
|
||||||
|
if (libraryItem !== null) {
|
||||||
|
Log.d(tag, "loadPodcastItem: Got library item ${libraryItem.id} ${libraryItem.media.metadata.title}")
|
||||||
|
val podcast = libraryItem.media as Podcast
|
||||||
|
podcast.episodes?.forEach { podcastEpisode ->
|
||||||
|
podcastEpisodeLibraryItemMap[podcastEpisode.id] = LibraryItemWithEpisode(libraryItem, podcastEpisode)
|
||||||
|
}
|
||||||
|
cachedLibraryPodcasts[libraryId]?.set(libraryItemId, libraryItem)
|
||||||
|
cb(libraryItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun loadLibraryItem(libraryItemId:String, cb: (LibraryItemWrapper?) -> Unit) {
|
private fun loadLibraryItem(libraryItemId:String, cb: (LibraryItemWrapper?) -> Unit) {
|
||||||
if (libraryItemId.startsWith("local")) {
|
if (libraryItemId.startsWith("local")) {
|
||||||
cb(DeviceManager.dbManager.getLocalLibraryItem(libraryItemId))
|
cb(DeviceManager.dbManager.getLocalLibraryItem(libraryItemId))
|
||||||
@@ -184,8 +669,8 @@ class MediaManager(private var apiHandler: ApiHandler, var ctx: Context) {
|
|||||||
}
|
}
|
||||||
selectedLibraryItemId = libraryItemWrapper.id
|
selectedLibraryItemId = libraryItemWrapper.id
|
||||||
selectedPodcast = podcast
|
selectedPodcast = podcast
|
||||||
|
val episodes = podcast.episodes?.sortedByDescending { it.publishedAt }
|
||||||
val children = podcast.episodes?.map { podcastEpisode ->
|
val children = episodes?.map { podcastEpisode ->
|
||||||
|
|
||||||
val progress = serverUserMediaProgress.find { it.libraryItemId == libraryItemWrapper.id && it.episodeId == podcastEpisode.id }
|
val progress = serverUserMediaProgress.find { it.libraryItemId == libraryItemWrapper.id && it.episodeId == podcastEpisode.id }
|
||||||
|
|
||||||
@@ -206,13 +691,16 @@ class MediaManager(private var apiHandler: ApiHandler, var ctx: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads libraries for selected server with stats
|
||||||
|
*/
|
||||||
private fun loadLibraries(cb: (List<Library>) -> Unit) {
|
private fun loadLibraries(cb: (List<Library>) -> Unit) {
|
||||||
if (serverLibraries.isNotEmpty()) {
|
if (serverLibraries.isNotEmpty()) {
|
||||||
cb(serverLibraries)
|
cb(serverLibraries)
|
||||||
} else {
|
} else {
|
||||||
apiHandler.getLibraries {
|
apiHandler.getLibraries { loadedLibraries ->
|
||||||
serverLibraries = it
|
serverLibraries = loadedLibraries
|
||||||
cb(it)
|
cb(serverLibraries)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -244,14 +732,18 @@ class MediaManager(private var apiHandler: ApiHandler, var ctx: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun checkSetValidServerConnectionConfig(cb: (Boolean) -> Unit) = runBlocking {
|
private fun checkSetValidServerConnectionConfig(cb: (Boolean) -> Unit) = runBlocking {
|
||||||
Log.d(tag, "checkSetValidServerConnectionConfig | $serverConfigIdUsed")
|
Log.d(tag, "checkSetValidServerConnectionConfig | serverConfigIdUsed=$serverConfigIdUsed | lastServerConnectionConfigId=${DeviceManager.deviceData.lastServerConnectionConfigId}")
|
||||||
|
|
||||||
coroutineScope {
|
coroutineScope {
|
||||||
if (!DeviceManager.checkConnectivity(ctx)) {
|
if (!DeviceManager.checkConnectivity(ctx)) {
|
||||||
serverUserMediaProgress = mutableListOf()
|
serverUserMediaProgress = mutableListOf()
|
||||||
|
Log.d(tag, "checkSetValidServerConnectionConfig: No connectivity")
|
||||||
|
cb(false)
|
||||||
|
} else if (DeviceManager.deviceData.lastServerConnectionConfigId.isNullOrBlank()) { // If in offline mode last server connection config is unset
|
||||||
|
serverUserMediaProgress = mutableListOf()
|
||||||
|
Log.d(tag, "checkSetValidServerConnectionConfig: No last server connection config")
|
||||||
cb(false)
|
cb(false)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
var hasValidConn = false
|
var hasValidConn = false
|
||||||
var lookupMediaProgress = true
|
var lookupMediaProgress = true
|
||||||
|
|
||||||
@@ -322,6 +814,25 @@ class MediaManager(private var apiHandler: ApiHandler, var ctx: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun initializeInProgressItems(cb: () -> Unit) {
|
||||||
|
Log.d(tag, "Initializing inprogress items")
|
||||||
|
|
||||||
|
loadItemsInProgressForAllLibraries { itemsInProgress ->
|
||||||
|
itemsInProgress.forEach {
|
||||||
|
val libraryItem = it.libraryItemWrapper as LibraryItem
|
||||||
|
if (serverLibraryItems.find { li -> li.id == libraryItem.id } == null) {
|
||||||
|
serverLibraryItems.add(libraryItem)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (it.episode != null) {
|
||||||
|
podcastEpisodeLibraryItemMap[it.episode.id] = LibraryItemWithEpisode(it.libraryItemWrapper, it.episode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Log.d(tag, "Initializing inprogress items done")
|
||||||
|
cb()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun loadAndroidAutoItems(cb: () -> Unit) {
|
fun loadAndroidAutoItems(cb: () -> Unit) {
|
||||||
Log.d(tag, "Load android auto items")
|
Log.d(tag, "Load android auto items")
|
||||||
|
|
||||||
@@ -329,37 +840,82 @@ class MediaManager(private var apiHandler: ApiHandler, var ctx: Context) {
|
|||||||
checkSetValidServerConnectionConfig { isConnected ->
|
checkSetValidServerConnectionConfig { isConnected ->
|
||||||
if (isConnected) {
|
if (isConnected) {
|
||||||
serverConfigIdUsed = DeviceManager.serverConnectionConfigId
|
serverConfigIdUsed = DeviceManager.serverConnectionConfigId
|
||||||
|
Log.d(tag, "loadAndroidAutoItems: Connected to server config id=$serverConfigIdUsed")
|
||||||
|
|
||||||
loadLibraries { libraries ->
|
loadLibraries { libraries ->
|
||||||
if (libraries.isEmpty()) {
|
if (libraries.isEmpty()) {
|
||||||
Log.w(tag, "No libraries returned from server request")
|
Log.w(tag, "No libraries returned from server request")
|
||||||
cb()
|
cb()
|
||||||
} else {
|
} else {
|
||||||
val library = libraries[0]
|
cb() // Fully loaded
|
||||||
Log.d(tag, "Loading categories for library ${library.name} - ${library.id} - ${library.mediaType}")
|
|
||||||
|
|
||||||
loadItemsInProgressForAllLibraries { itemsInProgress ->
|
|
||||||
itemsInProgress.forEach {
|
|
||||||
val libraryItem = it.libraryItemWrapper as LibraryItem
|
|
||||||
if (serverLibraryItems.find { li -> li.id == libraryItem.id } == null) {
|
|
||||||
serverLibraryItems.add(libraryItem)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (it.episode != null) {
|
|
||||||
podcastEpisodeLibraryItemMap[it.episode.id] = LibraryItemWithEpisode(it.libraryItemWrapper, it.episode)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cb() // Fully loaded
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // Not connected to server
|
} else { // Not connected to server
|
||||||
|
Log.d(tag, "loadAndroidAutoItems: Not connected to server")
|
||||||
cb()
|
cb()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles search requests.
|
||||||
|
* Searches from books, series and authors
|
||||||
|
*/
|
||||||
|
suspend fun doSearch(libraryId: String, queryString: String) : Map<String, List<MediaBrowserCompat.MediaItem>> {
|
||||||
|
return suspendCoroutine {
|
||||||
|
apiHandler.getSearchResults(libraryId, queryString) { searchResult ->
|
||||||
|
Log.d(tag, "searchLocalCache: $searchResult")
|
||||||
|
// Nothing found from server
|
||||||
|
if (searchResult === null) {
|
||||||
|
it.resume(mapOf())
|
||||||
|
return@getSearchResults
|
||||||
|
}
|
||||||
|
|
||||||
|
val foundItems: MutableMap<String, List<MediaBrowserCompat.MediaItem>> = mutableMapOf()
|
||||||
|
|
||||||
|
val serverLibrary = serverLibraries.find { sl -> sl.id == libraryId }
|
||||||
|
|
||||||
|
// Books
|
||||||
|
if (searchResult.book !== null && searchResult.book!!.isNotEmpty()) {
|
||||||
|
Log.d(tag, "searchLocalCache: found ${searchResult.book!!.size} books")
|
||||||
|
val children = searchResult.book!!.filter { it.libraryItem.checkHasTracks() }.map { bookResult ->
|
||||||
|
val libraryItem = bookResult.libraryItem
|
||||||
|
|
||||||
|
if (serverLibraryItems.find { li -> li.id == libraryItem.id } == null) {
|
||||||
|
serverLibraryItems.add(libraryItem)
|
||||||
|
}
|
||||||
|
val progress = serverUserMediaProgress.find { it.libraryItemId == libraryItem.id }
|
||||||
|
val localLibraryItem = DeviceManager.dbManager.getLocalLibraryItemByLId(libraryItem.id)
|
||||||
|
libraryItem.localLibraryItemId = localLibraryItem?.id
|
||||||
|
val description = libraryItem.getMediaDescription(progress, ctx, null, null, "Books (${serverLibrary?.name})")
|
||||||
|
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE)
|
||||||
|
}
|
||||||
|
foundItems["book"] = children
|
||||||
|
}
|
||||||
|
if (searchResult.series !== null && searchResult.series!!.isNotEmpty()) {
|
||||||
|
Log.d(tag, "onSearch: found ${searchResult.series!!.size} series")
|
||||||
|
val children = searchResult.series!!.map { seriesResult ->
|
||||||
|
val seriesItem = seriesResult.series
|
||||||
|
seriesItem.books = seriesResult.books as MutableList<LibraryItem>
|
||||||
|
val description = seriesItem.getMediaDescription(null, ctx, "Series (${serverLibrary?.name})")
|
||||||
|
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)
|
||||||
|
}
|
||||||
|
foundItems["series"] = children
|
||||||
|
}
|
||||||
|
if (searchResult.authors !== null && searchResult.authors!!.isNotEmpty()) {
|
||||||
|
Log.d(tag, "onSearch: found ${searchResult.authors!!.size} authors")
|
||||||
|
val children = searchResult.authors!!.map { authorItem ->
|
||||||
|
val description = authorItem.getMediaDescription(null, ctx, "Authors (${serverLibrary?.name})")
|
||||||
|
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)
|
||||||
|
}
|
||||||
|
foundItems["authors"] = children
|
||||||
|
}
|
||||||
|
|
||||||
|
it.resume(foundItems)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun getFirstItem() : LibraryItemWrapper? {
|
fun getFirstItem() : LibraryItemWrapper? {
|
||||||
if (serverLibraryItems.isNotEmpty()) {
|
if (serverLibraryItems.isNotEmpty()) {
|
||||||
return serverLibraryItems[0]
|
return serverLibraryItems[0]
|
||||||
@@ -394,7 +950,7 @@ class MediaManager(private var apiHandler: ApiHandler, var ctx: Context) {
|
|||||||
|
|
||||||
fun play(libraryItemWrapper:LibraryItemWrapper, episode:PodcastEpisode?, playItemRequestPayload:PlayItemRequestPayload, cb: (PlaybackSession?) -> Unit) {
|
fun play(libraryItemWrapper:LibraryItemWrapper, episode:PodcastEpisode?, playItemRequestPayload:PlayItemRequestPayload, cb: (PlaybackSession?) -> Unit) {
|
||||||
if (libraryItemWrapper is LocalLibraryItem) {
|
if (libraryItemWrapper is LocalLibraryItem) {
|
||||||
cb(libraryItemWrapper.getPlaybackSession(episode))
|
cb(libraryItemWrapper.getPlaybackSession(episode, playItemRequestPayload.deviceInfo))
|
||||||
} else {
|
} else {
|
||||||
val libraryItem = libraryItemWrapper as LibraryItem
|
val libraryItem = libraryItemWrapper as LibraryItem
|
||||||
apiHandler.playLibraryItem(libraryItem.id,episode?.id ?: "", playItemRequestPayload) {
|
apiHandler.playLibraryItem(libraryItem.id,episode?.id ?: "", playItemRequestPayload) {
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ class MediaProgressSyncer(val playerNotificationService: PlayerNotificationServi
|
|||||||
var currentLocalMediaProgress: LocalMediaProgress? = null
|
var currentLocalMediaProgress: LocalMediaProgress? = null
|
||||||
|
|
||||||
private val currentDisplayTitle get() = currentPlaybackSession?.displayTitle ?: "Unset"
|
private val currentDisplayTitle get() = currentPlaybackSession?.displayTitle ?: "Unset"
|
||||||
private val currentIsLocal get() = currentPlaybackSession?.isLocal == true
|
val currentIsLocal get() = currentPlaybackSession?.isLocal == true
|
||||||
private val currentSessionId get() = currentPlaybackSession?.id ?: ""
|
val currentSessionId get() = currentPlaybackSession?.id ?: ""
|
||||||
private val currentPlaybackDuration get() = currentPlaybackSession?.duration ?: 0.0
|
private val currentPlaybackDuration get() = currentPlaybackSession?.duration ?: 0.0
|
||||||
|
|
||||||
fun start(playbackSession:PlaybackSession) {
|
fun start(playbackSession:PlaybackSession) {
|
||||||
@@ -215,7 +215,6 @@ class MediaProgressSyncer(val playerNotificationService: PlayerNotificationServi
|
|||||||
val listeningTimeToAdd = diffSinceLastSync / 1000L
|
val listeningTimeToAdd = diffSinceLastSync / 1000L
|
||||||
|
|
||||||
val syncData = MediaProgressSyncData(listeningTimeToAdd,currentPlaybackDuration,currentTime)
|
val syncData = MediaProgressSyncData(listeningTimeToAdd,currentPlaybackDuration,currentTime)
|
||||||
|
|
||||||
currentPlaybackSession?.syncData(syncData)
|
currentPlaybackSession?.syncData(syncData)
|
||||||
|
|
||||||
if (currentPlaybackSession?.progress?.isNaN() == true) {
|
if (currentPlaybackSession?.progress?.isNaN() == true) {
|
||||||
@@ -239,15 +238,12 @@ class MediaProgressSyncer(val playerNotificationService: PlayerNotificationServi
|
|||||||
saveLocalProgress(it)
|
saveLocalProgress(it)
|
||||||
lastSyncTime = System.currentTimeMillis()
|
lastSyncTime = System.currentTimeMillis()
|
||||||
|
|
||||||
|
Log.d(tag, "Sync local device current serverConnectionConfigId=${DeviceManager.serverConnectionConfig?.id}")
|
||||||
|
|
||||||
// Local library item is linked to a server library item
|
// Local library item is linked to a server library item
|
||||||
// Send sync to server also if connected to this server and local item belongs to this server
|
// Send sync to server also if connected to this server and local item belongs to this server
|
||||||
if (hasNetworkConnection && shouldSyncServer && !it.libraryItemId.isNullOrEmpty() && it.serverConnectionConfigId != null && DeviceManager.serverConnectionConfig?.id == it.serverConnectionConfigId) {
|
if (hasNetworkConnection && shouldSyncServer && !it.libraryItemId.isNullOrEmpty() && it.serverConnectionConfigId != null && DeviceManager.serverConnectionConfig?.id == it.serverConnectionConfigId) {
|
||||||
apiHandler.sendLocalProgressSync(it) { syncSuccess, errorMsg ->
|
apiHandler.sendLocalProgressSync(it) { syncSuccess, errorMsg ->
|
||||||
Log.d(
|
|
||||||
tag,
|
|
||||||
"Local progress sync data sent to server $currentDisplayTitle for time $currentTime"
|
|
||||||
)
|
|
||||||
|
|
||||||
if (syncSuccess) {
|
if (syncSuccess) {
|
||||||
failedSyncs = 0
|
failedSyncs = 0
|
||||||
playerNotificationService.alertSyncSuccess()
|
playerNotificationService.alertSyncSuccess()
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.audiobookshelf.app.media
|
||||||
|
|
||||||
|
import android.content.ContentResolver
|
||||||
|
import android.content.Context
|
||||||
|
import android.net.Uri
|
||||||
|
import androidx.annotation.AnyRes
|
||||||
|
import com.audiobookshelf.app.R
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get uri to drawable or any other resource type if u wish
|
||||||
|
* @param drawableId - drawable res id
|
||||||
|
* @return - uri
|
||||||
|
*/
|
||||||
|
fun getUriToDrawable(context: Context, @AnyRes drawableId: Int): Uri {
|
||||||
|
return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE
|
||||||
|
+ "://" + context.resources.getResourcePackageName(drawableId)
|
||||||
|
+ '/' + context.resources.getResourceTypeName(drawableId)
|
||||||
|
+ '/' + context.resources.getResourceEntryName(drawableId))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get uri to drawable or any other resource type if u wish
|
||||||
|
* @param drawableId - drawable res id
|
||||||
|
* @return - uri
|
||||||
|
*/
|
||||||
|
fun getUriToAbsIconDrawable(context: Context, absIconName: String): Uri {
|
||||||
|
val drawableId = when(absIconName) {
|
||||||
|
"audiobookshelf" -> R.drawable.abs_audiobookshelf
|
||||||
|
"authors" -> R.drawable.abs_authors
|
||||||
|
"book-1" -> R.drawable.abs_book_1
|
||||||
|
"books-1" -> R.drawable.abs_books_1
|
||||||
|
"books-2" -> R.drawable.abs_books_2
|
||||||
|
"columns" -> R.drawable.abs_columns
|
||||||
|
"database" -> R.drawable.abs_database
|
||||||
|
"file-picture" -> R.drawable.abs_file_picture
|
||||||
|
"headphones" -> R.drawable.abs_headphones
|
||||||
|
"heart" -> R.drawable.abs_heart
|
||||||
|
"microphone_1" -> R.drawable.abs_microphone_1
|
||||||
|
"microphone_2" -> R.drawable.abs_microphone_2
|
||||||
|
"microphone_3" -> R.drawable.abs_microphone_3
|
||||||
|
"music" -> R.drawable.abs_music
|
||||||
|
"podcast" -> R.drawable.abs_podcast
|
||||||
|
"radio" -> R.drawable.abs_radio
|
||||||
|
"rocket" -> R.drawable.abs_rocket
|
||||||
|
"rss" -> R.drawable.abs_rss
|
||||||
|
"star" -> R.drawable.abs_star
|
||||||
|
else -> R.drawable.icon_library_folder
|
||||||
|
}
|
||||||
|
return Uri.parse(
|
||||||
|
ContentResolver.SCHEME_ANDROID_RESOURCE
|
||||||
|
+ "://" + context.resources.getResourcePackageName(drawableId)
|
||||||
|
+ '/' + context.resources.getResourceTypeName(drawableId)
|
||||||
|
+ '/' + context.resources.getResourceEntryName(drawableId))
|
||||||
|
}
|
||||||
@@ -21,6 +21,9 @@ data class DownloadItem(
|
|||||||
val media: MediaType,
|
val media: MediaType,
|
||||||
val downloadItemParts: MutableList<DownloadItemPart>
|
val downloadItemParts: MutableList<DownloadItemPart>
|
||||||
) {
|
) {
|
||||||
|
@get:JsonIgnore
|
||||||
|
val isInternalStorage get() = localFolder.id.startsWith("internal-")
|
||||||
|
|
||||||
@get:JsonIgnore
|
@get:JsonIgnore
|
||||||
val isDownloadFinished get() = !downloadItemParts.any { !it.completed || it.isMoving }
|
val isDownloadFinished get() = !downloadItemParts.any { !it.completed || it.isMoving }
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,12 @@ data class DownloadItemPart(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@get:JsonIgnore
|
||||||
|
val isInternalStorage get() = localFolderId.startsWith("internal-")
|
||||||
|
|
||||||
|
@get:JsonIgnore
|
||||||
|
val serverUrl get() = "${DeviceManager.serverAddress}${serverPath}?token=${DeviceManager.token}"
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
fun getDownloadRequest(): DownloadManager.Request {
|
fun getDownloadRequest(): DownloadManager.Request {
|
||||||
val dlRequest = DownloadManager.Request(uri)
|
val dlRequest = DownloadManager.Request(uri)
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ import com.google.android.exoplayer2.Player
|
|||||||
import com.google.android.exoplayer2.ui.PlayerNotificationManager
|
import com.google.android.exoplayer2.ui.PlayerNotificationManager
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
|
|
||||||
const val NOTIFICATION_LARGE_ICON_SIZE = 144 // px
|
|
||||||
|
|
||||||
class AbMediaDescriptionAdapter constructor(private val controller: MediaControllerCompat, private val playerNotificationService: PlayerNotificationService) : PlayerNotificationManager.MediaDescriptionAdapter {
|
class AbMediaDescriptionAdapter constructor(private val controller: MediaControllerCompat, private val playerNotificationService: PlayerNotificationService) : PlayerNotificationManager.MediaDescriptionAdapter {
|
||||||
private val tag = "MediaDescriptionAdapter"
|
private val tag = "MediaDescriptionAdapter"
|
||||||
|
|
||||||
@@ -77,7 +75,7 @@ class AbMediaDescriptionAdapter constructor(private val controller: MediaControl
|
|||||||
.load(uri)
|
.load(uri)
|
||||||
.placeholder(R.drawable.icon)
|
.placeholder(R.drawable.icon)
|
||||||
.error(R.drawable.icon)
|
.error(R.drawable.icon)
|
||||||
.submit(NOTIFICATION_LARGE_ICON_SIZE, NOTIFICATION_LARGE_ICON_SIZE)
|
.submit()
|
||||||
.get()
|
.get()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
@@ -85,7 +83,7 @@ class AbMediaDescriptionAdapter constructor(private val controller: MediaControl
|
|||||||
Glide.with(playerNotificationService)
|
Glide.with(playerNotificationService)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.load(Uri.parse("android.resource://${BuildConfig.APPLICATION_ID}/" + R.drawable.icon))
|
.load(Uri.parse("android.resource://${BuildConfig.APPLICATION_ID}/" + R.drawable.icon))
|
||||||
.submit(NOTIFICATION_LARGE_ICON_SIZE, NOTIFICATION_LARGE_ICON_SIZE)
|
.submit()
|
||||||
.get()
|
.get()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +1,45 @@
|
|||||||
package com.audiobookshelf.app.player
|
package com.audiobookshelf.app.player
|
||||||
|
|
||||||
import android.content.ContentResolver
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.Uri
|
|
||||||
import android.support.v4.media.MediaMetadataCompat
|
import android.support.v4.media.MediaMetadataCompat
|
||||||
import androidx.annotation.AnyRes
|
import android.util.Log
|
||||||
import com.audiobookshelf.app.R
|
import com.audiobookshelf.app.R
|
||||||
import com.audiobookshelf.app.data.*
|
import com.audiobookshelf.app.data.*
|
||||||
|
import com.audiobookshelf.app.media.getUriToDrawable
|
||||||
|
|
||||||
class BrowseTree(
|
class BrowseTree(
|
||||||
val context: Context,
|
val context: Context,
|
||||||
itemsInProgress: List<ItemInProgress>,
|
itemsInProgress: List<ItemInProgress>,
|
||||||
libraries: List<Library>
|
libraries: List<Library>,
|
||||||
|
recentsLoaded: Boolean
|
||||||
) {
|
) {
|
||||||
private val mediaIdToChildren = mutableMapOf<String, MutableList<MediaMetadataCompat>>()
|
private val mediaIdToChildren = mutableMapOf<String, MutableList<MediaMetadataCompat>>()
|
||||||
|
|
||||||
/**
|
|
||||||
* get uri to drawable or any other resource type if u wish
|
|
||||||
* @param drawableId - drawable res id
|
|
||||||
* @return - uri
|
|
||||||
*/
|
|
||||||
private fun getUriToDrawable(@AnyRes drawableId: Int): Uri {
|
|
||||||
return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE
|
|
||||||
+ "://" + context.resources.getResourcePackageName(drawableId)
|
|
||||||
+ '/' + context.resources.getResourceTypeName(drawableId)
|
|
||||||
+ '/' + context.resources.getResourceEntryName(drawableId))
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val rootList = mediaIdToChildren[AUTO_BROWSE_ROOT] ?: mutableListOf()
|
val rootList = mediaIdToChildren[AUTO_BROWSE_ROOT] ?: mutableListOf()
|
||||||
|
|
||||||
val continueListeningMetadata = MediaMetadataCompat.Builder().apply {
|
val continueListeningMetadata = MediaMetadataCompat.Builder().apply {
|
||||||
putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, CONTINUE_ROOT)
|
putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, CONTINUE_ROOT)
|
||||||
putString(MediaMetadataCompat.METADATA_KEY_TITLE, "Listening")
|
putString(MediaMetadataCompat.METADATA_KEY_TITLE, "Continue")
|
||||||
putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI, getUriToDrawable(R.drawable.exo_icon_localaudio).toString())
|
putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI, getUriToDrawable(context, R.drawable.exo_icon_localaudio).toString())
|
||||||
|
}.build()
|
||||||
|
|
||||||
|
val recentMetadata = MediaMetadataCompat.Builder().apply {
|
||||||
|
putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, RECENTLY_ROOT)
|
||||||
|
putString(MediaMetadataCompat.METADATA_KEY_TITLE, "Recent")
|
||||||
|
putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI, getUriToDrawable(context, R.drawable.md_clock_outline).toString())
|
||||||
}.build()
|
}.build()
|
||||||
|
|
||||||
val downloadsMetadata = MediaMetadataCompat.Builder().apply {
|
val downloadsMetadata = MediaMetadataCompat.Builder().apply {
|
||||||
putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, DOWNLOADS_ROOT)
|
putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, DOWNLOADS_ROOT)
|
||||||
putString(MediaMetadataCompat.METADATA_KEY_TITLE, "Downloads")
|
putString(MediaMetadataCompat.METADATA_KEY_TITLE, "Downloads")
|
||||||
putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI, getUriToDrawable(R.drawable.exo_icon_downloaddone).toString())
|
putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI, getUriToDrawable(context, R.drawable.exo_icon_downloaddone).toString())
|
||||||
}.build()
|
}.build()
|
||||||
|
|
||||||
val librariesMetadata = MediaMetadataCompat.Builder().apply {
|
val librariesMetadata = MediaMetadataCompat.Builder().apply {
|
||||||
putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, LIBRARIES_ROOT)
|
putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, LIBRARIES_ROOT)
|
||||||
putString(MediaMetadataCompat.METADATA_KEY_TITLE, "Libraries")
|
putString(MediaMetadataCompat.METADATA_KEY_TITLE, "Libraries")
|
||||||
putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI, getUriToDrawable(R.drawable.icon_library_folder).toString())
|
putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI, getUriToDrawable(context, R.drawable.icon_library_folder).toString())
|
||||||
}.build()
|
}.build()
|
||||||
|
|
||||||
if (itemsInProgress.isNotEmpty()) {
|
if (itemsInProgress.isNotEmpty()) {
|
||||||
@@ -53,13 +47,28 @@ class BrowseTree(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (libraries.isNotEmpty()) {
|
if (libraries.isNotEmpty()) {
|
||||||
|
if (recentsLoaded) {
|
||||||
|
rootList += recentMetadata
|
||||||
|
}
|
||||||
rootList += librariesMetadata
|
rootList += librariesMetadata
|
||||||
|
|
||||||
libraries.forEach { library ->
|
libraries.forEach { library ->
|
||||||
val libraryMediaMetadata = library.getMediaMetadata()
|
// Skip libraries without audio content
|
||||||
|
if (library.stats?.numAudioFiles == 0) return@forEach
|
||||||
|
Log.d("BrowseTree", "Library $library | ${library.icon}")
|
||||||
|
// Generate library list items for Libraries menu
|
||||||
|
val libraryMediaMetadata = library.getMediaMetadata(context)
|
||||||
val children = mediaIdToChildren[LIBRARIES_ROOT] ?: mutableListOf()
|
val children = mediaIdToChildren[LIBRARIES_ROOT] ?: mutableListOf()
|
||||||
children += libraryMediaMetadata
|
children += libraryMediaMetadata
|
||||||
mediaIdToChildren[LIBRARIES_ROOT] = children
|
mediaIdToChildren[LIBRARIES_ROOT] = children
|
||||||
|
|
||||||
|
if (recentsLoaded) {
|
||||||
|
// Generate library list items for Recent menu
|
||||||
|
val recentlyMediaMetadata = library.getMediaMetadata(context,"recently")
|
||||||
|
val childrenRecently = mediaIdToChildren[RECENTLY_ROOT] ?: mutableListOf()
|
||||||
|
childrenRecently += recentlyMediaMetadata
|
||||||
|
mediaIdToChildren[RECENTLY_ROOT] = childrenRecently
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,3 +84,4 @@ const val AUTO_BROWSE_ROOT = "/"
|
|||||||
const val CONTINUE_ROOT = "__CONTINUE__"
|
const val CONTINUE_ROOT = "__CONTINUE__"
|
||||||
const val DOWNLOADS_ROOT = "__DOWNLOADS__"
|
const val DOWNLOADS_ROOT = "__DOWNLOADS__"
|
||||||
const val LIBRARIES_ROOT = "__LIBRARIES__"
|
const val LIBRARIES_ROOT = "__LIBRARIES__"
|
||||||
|
const val RECENTLY_ROOT = "__RECENTLY__"
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class CastManager constructor(val mainActivity:Activity) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun startRouteScan(connListener:ChromecastListener) {
|
fun startRouteScan(connListener:ChromecastListener) {
|
||||||
var callback = object : ScanCallback() {
|
val callback = object : ScanCallback() {
|
||||||
override fun onRouteUpdate(routes: List<MediaRouter.RouteInfo>?) {
|
override fun onRouteUpdate(routes: List<MediaRouter.RouteInfo>?) {
|
||||||
Log.d(tag, "CAST On ROUTE UPDATED ${routes?.size} | ${getContext().castState}")
|
Log.d(tag, "CAST On ROUTE UPDATED ${routes?.size} | ${getContext().castState}")
|
||||||
// if the routes have changed, we may have an available device
|
// if the routes have changed, we may have an available device
|
||||||
@@ -136,7 +136,7 @@ class CastManager constructor(val mainActivity:Activity) {
|
|||||||
// Let the client know a receiver is available
|
// Let the client know a receiver is available
|
||||||
connListener.onReceiverAvailableUpdate(true)
|
connListener.onReceiverAvailableUpdate(true)
|
||||||
// Since we have a receiver we may also have an active session
|
// Since we have a receiver we may also have an active session
|
||||||
var session = getSessionManager()?.currentCastSession
|
val session = getSessionManager()?.currentCastSession
|
||||||
// If we do have a session
|
// If we do have a session
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
// Let the client know
|
// Let the client know
|
||||||
@@ -246,15 +246,15 @@ class CastManager constructor(val mainActivity:Activity) {
|
|||||||
onRouteUpdate(outRoutes)
|
onRouteUpdate(outRoutes)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRouteAdded(router: MediaRouter?, route: MediaRouter.RouteInfo?) {
|
override fun onRouteAdded(router: MediaRouter, route: MediaRouter.RouteInfo) {
|
||||||
onFilteredRouteUpdate()
|
onFilteredRouteUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRouteChanged(router: MediaRouter?, route: MediaRouter.RouteInfo?) {
|
override fun onRouteChanged(router: MediaRouter, route: MediaRouter.RouteInfo) {
|
||||||
onFilteredRouteUpdate()
|
onFilteredRouteUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRouteRemoved(router: MediaRouter?, route: MediaRouter.RouteInfo?) {
|
override fun onRouteRemoved(router: MediaRouter, route: MediaRouter.RouteInfo) {
|
||||||
onFilteredRouteUpdate()
|
onFilteredRouteUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ import com.google.android.exoplayer2.*
|
|||||||
import com.google.android.exoplayer2.C.TrackType
|
import com.google.android.exoplayer2.C.TrackType
|
||||||
import com.google.android.exoplayer2.MediaMetadata
|
import com.google.android.exoplayer2.MediaMetadata
|
||||||
import com.google.android.exoplayer2.Player.*
|
import com.google.android.exoplayer2.Player.*
|
||||||
import com.google.android.exoplayer2.TracksInfo.TrackGroupInfo
|
import com.google.android.exoplayer2.Tracks.Group
|
||||||
import com.google.android.exoplayer2.audio.AudioAttributes
|
import com.google.android.exoplayer2.audio.AudioAttributes
|
||||||
import com.google.android.exoplayer2.ext.cast.SessionAvailabilityListener
|
import com.google.android.exoplayer2.ext.cast.SessionAvailabilityListener
|
||||||
import com.google.android.exoplayer2.source.TrackGroup
|
import com.google.android.exoplayer2.source.TrackGroup
|
||||||
import com.google.android.exoplayer2.source.TrackGroupArray
|
import com.google.android.exoplayer2.source.TrackGroupArray
|
||||||
import com.google.android.exoplayer2.text.Cue
|
import com.google.android.exoplayer2.text.CueGroup
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelection
|
import com.google.android.exoplayer2.trackselection.TrackSelection
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionArray
|
import com.google.android.exoplayer2.trackselection.TrackSelectionArray
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters
|
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters
|
||||||
@@ -49,7 +49,7 @@ class CastPlayer(var castContext: CastContext) : BasePlayer() {
|
|||||||
private var myPlayWhenReady:Boolean = false
|
private var myPlayWhenReady:Boolean = false
|
||||||
private var playbackParameters:PlaybackParameters = PlaybackParameters.DEFAULT
|
private var playbackParameters:PlaybackParameters = PlaybackParameters.DEFAULT
|
||||||
private var myAvailableCommands: Commands
|
private var myAvailableCommands: Commands
|
||||||
private var myCurrentTracksInfo: TracksInfo
|
private var myCurrentTracksInfo: Tracks
|
||||||
private var myCurrentTrackGroups: TrackGroupArray
|
private var myCurrentTrackGroups: TrackGroupArray
|
||||||
private var myCurrentTrackSelections: TrackSelectionArray
|
private var myCurrentTrackSelections: TrackSelectionArray
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ class CastPlayer(var castContext: CastContext) : BasePlayer() {
|
|||||||
COMMAND_GET_MEDIA_ITEMS_METADATA,
|
COMMAND_GET_MEDIA_ITEMS_METADATA,
|
||||||
COMMAND_SET_MEDIA_ITEMS_METADATA,
|
COMMAND_SET_MEDIA_ITEMS_METADATA,
|
||||||
COMMAND_CHANGE_MEDIA_ITEMS,
|
COMMAND_CHANGE_MEDIA_ITEMS,
|
||||||
COMMAND_GET_TRACK_INFOS)
|
COMMAND_GET_TRACKS)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
var currentPlaybackState = Player.STATE_IDLE
|
var currentPlaybackState = Player.STATE_IDLE
|
||||||
@@ -95,7 +95,7 @@ class CastPlayer(var castContext: CastContext) : BasePlayer() {
|
|||||||
Log.d(tag, "Init CastPlayer")
|
Log.d(tag, "Init CastPlayer")
|
||||||
myCurrentTrackGroups = TrackGroupArray.EMPTY
|
myCurrentTrackGroups = TrackGroupArray.EMPTY
|
||||||
myCurrentTrackSelections = EMPTY_TRACK_SELECTION_ARRAY
|
myCurrentTrackSelections = EMPTY_TRACK_SELECTION_ARRAY
|
||||||
myCurrentTracksInfo = TracksInfo.EMPTY
|
myCurrentTracksInfo = Tracks.EMPTY
|
||||||
statusListener = StatusListener()
|
statusListener = StatusListener()
|
||||||
timelineTracker = CastTimelineTracker()
|
timelineTracker = CastTimelineTracker()
|
||||||
myCurrentTimeline = CastTimeline.EMPTY_CAST_TIMELINE
|
myCurrentTimeline = CastTimeline.EMPTY_CAST_TIMELINE
|
||||||
@@ -385,7 +385,7 @@ class CastPlayer(var castContext: CastContext) : BasePlayer() {
|
|||||||
}
|
}
|
||||||
if (updateTracksAndSelectionsAndNotifyIfChanged()) {
|
if (updateTracksAndSelectionsAndNotifyIfChanged()) {
|
||||||
listeners.queueEvent(
|
listeners.queueEvent(
|
||||||
EVENT_TRACKS_CHANGED) { listener: Listener -> listener.onTracksInfoChanged(currentTracksInfo) }
|
EVENT_TRACKS_CHANGED) { listener: Listener -> listener.onTracksChanged(currentTracks) }
|
||||||
}
|
}
|
||||||
updateAvailableCommandsAndNotifyIfChanged()
|
updateAvailableCommandsAndNotifyIfChanged()
|
||||||
listeners.flushEvents()
|
listeners.flushEvents()
|
||||||
@@ -405,7 +405,7 @@ class CastPlayer(var castContext: CastContext) : BasePlayer() {
|
|||||||
val hasChanged = !myCurrentTrackGroups.isEmpty
|
val hasChanged = !myCurrentTrackGroups.isEmpty
|
||||||
myCurrentTrackGroups = TrackGroupArray.EMPTY
|
myCurrentTrackGroups = TrackGroupArray.EMPTY
|
||||||
myCurrentTrackSelections = EMPTY_TRACK_SELECTION_ARRAY
|
myCurrentTrackSelections = EMPTY_TRACK_SELECTION_ARRAY
|
||||||
myCurrentTracksInfo = TracksInfo.EMPTY
|
myCurrentTracksInfo = Tracks.EMPTY
|
||||||
return hasChanged
|
return hasChanged
|
||||||
}
|
}
|
||||||
var activeTrackIds = mediaStatus.activeTrackIds
|
var activeTrackIds = mediaStatus.activeTrackIds
|
||||||
@@ -414,7 +414,7 @@ class CastPlayer(var castContext: CastContext) : BasePlayer() {
|
|||||||
}
|
}
|
||||||
val trackGroups = arrayOfNulls<TrackGroup>(castMediaTracks.size)
|
val trackGroups = arrayOfNulls<TrackGroup>(castMediaTracks.size)
|
||||||
val trackSelections = arrayOfNulls<TrackSelection>(RENDERER_COUNT)
|
val trackSelections = arrayOfNulls<TrackSelection>(RENDERER_COUNT)
|
||||||
val trackGroupInfos = arrayOfNulls<TrackGroupInfo>(castMediaTracks.size)
|
val trackGroupInfos = arrayOfNulls<Group>(castMediaTracks.size)
|
||||||
for (i in castMediaTracks.indices) {
|
for (i in castMediaTracks.indices) {
|
||||||
val mediaTrack = castMediaTracks[i]
|
val mediaTrack = castMediaTracks[i]
|
||||||
trackGroups[i] = TrackGroup( /* id= */i.toString(), mediaTrackToFormat(mediaTrack))
|
trackGroups[i] = TrackGroup( /* id= */i.toString(), mediaTrackToFormat(mediaTrack))
|
||||||
@@ -428,18 +428,16 @@ class CastPlayer(var castContext: CastContext) : BasePlayer() {
|
|||||||
}
|
}
|
||||||
val trackSupport = intArrayOf(if (supported) C.FORMAT_HANDLED else C.FORMAT_UNSUPPORTED_TYPE)
|
val trackSupport = intArrayOf(if (supported) C.FORMAT_HANDLED else C.FORMAT_UNSUPPORTED_TYPE)
|
||||||
val trackSelected = booleanArrayOf(selected)
|
val trackSelected = booleanArrayOf(selected)
|
||||||
trackGroupInfos[i] = TrackGroupInfo(trackGroups[i]!!, trackSupport, trackType, trackSelected)
|
trackGroupInfos[i] = Group(trackGroups[i]!!, false, trackSupport, trackSelected)
|
||||||
}
|
}
|
||||||
|
|
||||||
val tg = trackGroups.filterNotNull().toTypedArray()
|
val tg = trackGroups.filterNotNull().toTypedArray()
|
||||||
var ts = trackSelections.filterNotNull().toTypedArray()
|
val ts = trackSelections.filterNotNull().toTypedArray()
|
||||||
var tgi = trackGroupInfos.filterNotNull().toMutableList()
|
val tgi = trackGroupInfos.filterNotNull().toMutableList()
|
||||||
val newTrackGroups = TrackGroupArray(*tg)
|
val newTrackGroups = TrackGroupArray(*tg)
|
||||||
val newTrackSelections = TrackSelectionArray(*ts)
|
val newTrackSelections = TrackSelectionArray(*ts)
|
||||||
val newTracksInfo = TracksInfo(tgi)
|
val newTracksInfo = Tracks(tgi)
|
||||||
if (newTrackGroups != currentTrackGroups
|
if (newTracksInfo != currentTracks) {
|
||||||
|| newTrackSelections != currentTrackSelections
|
|
||||||
|| newTracksInfo != currentTracksInfo) {
|
|
||||||
myCurrentTrackSelections = newTrackSelections
|
myCurrentTrackSelections = newTrackSelections
|
||||||
myCurrentTrackGroups = newTrackGroups
|
myCurrentTrackGroups = newTrackGroups
|
||||||
myCurrentTracksInfo = newTracksInfo
|
myCurrentTracksInfo = newTracksInfo
|
||||||
@@ -593,7 +591,7 @@ class CastPlayer(var castContext: CastContext) : BasePlayer() {
|
|||||||
listeners.flushEvents()
|
listeners.flushEvents()
|
||||||
val pendingResult: PendingResult<RemoteMediaClient.MediaChannelResult> = if (playWhenReady) remoteMediaClient!!.play() else remoteMediaClient!!.pause()
|
val pendingResult: PendingResult<RemoteMediaClient.MediaChannelResult> = if (playWhenReady) remoteMediaClient!!.play() else remoteMediaClient!!.pause()
|
||||||
|
|
||||||
var resultCb = ResultCallback<RemoteMediaClient.MediaChannelResult?> {
|
val resultCb = ResultCallback<RemoteMediaClient.MediaChannelResult?> {
|
||||||
updatePlayerStateAndNotifyIfChanged()
|
updatePlayerStateAndNotifyIfChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -622,10 +620,10 @@ class CastPlayer(var castContext: CastContext) : BasePlayer() {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun seekTo(mediaItemIndex: Int, positionMs: Long) {
|
override fun seekTo(mediaItemIndex: Int, positionMs: Long, seekCommand: Int, isRepeatingCurrentItem: Boolean) {
|
||||||
Log.d(tag, "seekTo $mediaItemIndex position $positionMs")
|
Log.d(tag, "seekTo $mediaItemIndex position $positionMs")
|
||||||
|
|
||||||
var resultCb = ResultCallback<RemoteMediaClient.MediaChannelResult?> {
|
val resultCb = ResultCallback<RemoteMediaClient.MediaChannelResult?> {
|
||||||
val statusCode: Int = it.status.statusCode
|
val statusCode: Int = it.status.statusCode
|
||||||
if (statusCode != CastStatusCodes.SUCCESS && statusCode != CastStatusCodes.REPLACED) {
|
if (statusCode != CastStatusCodes.SUCCESS && statusCode != CastStatusCodes.REPLACED) {
|
||||||
Log.e(tag, "Seek failed. Error code $statusCode")
|
Log.e(tag, "Seek failed. Error code $statusCode")
|
||||||
@@ -645,14 +643,14 @@ class CastPlayer(var castContext: CastContext) : BasePlayer() {
|
|||||||
|
|
||||||
// We assume the default position is 0. There is no support for seeking to the default position
|
// We assume the default position is 0. There is no support for seeking to the default position
|
||||||
// in RemoteMediaClient.
|
// in RemoteMediaClient.
|
||||||
var positionMsFinal = if (positionMs != C.TIME_UNSET) positionMs else 0
|
val positionMsFinal = if (positionMs != C.TIME_UNSET) positionMs else 0
|
||||||
if (mediaStatus != null) {
|
if (mediaStatus != null) {
|
||||||
if (currentMediaItemIndex != mediaItemIndex) {
|
if (currentMediaItemIndex != mediaItemIndex) {
|
||||||
Log.d(tag, "seekTo: Changing media item index from $currentMediaItemIndex to $mediaItemIndex")
|
Log.d(tag, "seekTo: Changing media item index from $currentMediaItemIndex to $mediaItemIndex")
|
||||||
remoteMediaClient?.queueJumpToItem(myCurrentTimeline.getPeriod(mediaItemIndex, period).uid as Int, positionMsFinal, JSONObject())?.setResultCallback(resultCb)
|
remoteMediaClient?.queueJumpToItem(myCurrentTimeline.getPeriod(mediaItemIndex, period).uid as Int, positionMsFinal, JSONObject())?.setResultCallback(resultCb)
|
||||||
} else {
|
} else {
|
||||||
Log.d(tag, "seekTo: Same media index seek to position $positionMsFinal")
|
Log.d(tag, "seekTo: Same media index seek to position $positionMsFinal")
|
||||||
var mediaSeekOptions = MediaSeekOptions.Builder().setPosition(positionMsFinal).build()
|
val mediaSeekOptions = MediaSeekOptions.Builder().setPosition(positionMsFinal).build()
|
||||||
remoteMediaClient?.seek(mediaSeekOptions)?.setResultCallback(resultCb)
|
remoteMediaClient?.seek(mediaSeekOptions)?.setResultCallback(resultCb)
|
||||||
}
|
}
|
||||||
val oldPosition = getCurrentPositionInfo()
|
val oldPosition = getCurrentPositionInfo()
|
||||||
@@ -709,7 +707,7 @@ class CastPlayer(var castContext: CastContext) : BasePlayer() {
|
|||||||
|
|
||||||
val pendingResult: PendingResult<RemoteMediaClient.MediaChannelResult>? = remoteMediaClient?.setPlaybackRate(actualPlaybackParameters.speed.toDouble(), /* customData= */null)
|
val pendingResult: PendingResult<RemoteMediaClient.MediaChannelResult>? = remoteMediaClient?.setPlaybackRate(actualPlaybackParameters.speed.toDouble(), /* customData= */null)
|
||||||
|
|
||||||
var resultCb = ResultCallback<RemoteMediaClient.MediaChannelResult?> {
|
val resultCb = ResultCallback<RemoteMediaClient.MediaChannelResult?> {
|
||||||
updatePlaybackRateAndNotifyIfChanged()
|
updatePlaybackRateAndNotifyIfChanged()
|
||||||
listeners.flushEvents()
|
listeners.flushEvents()
|
||||||
}
|
}
|
||||||
@@ -736,15 +734,7 @@ class CastPlayer(var castContext: CastContext) : BasePlayer() {
|
|||||||
sessionManager.endCurrentSession(false)
|
sessionManager.endCurrentSession(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getCurrentTrackGroups(): TrackGroupArray {
|
override fun getCurrentTracks(): Tracks {
|
||||||
return this.myCurrentTrackGroups
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getCurrentTrackSelections(): TrackSelectionArray {
|
|
||||||
return this.myCurrentTrackSelections
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getCurrentTracksInfo(): TracksInfo {
|
|
||||||
return this.myCurrentTracksInfo
|
return this.myCurrentTracksInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -858,8 +848,12 @@ class CastPlayer(var castContext: CastContext) : BasePlayer() {
|
|||||||
return VideoSize.UNKNOWN
|
return VideoSize.UNKNOWN
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getCurrentCues(): MutableList<Cue> {
|
override fun getSurfaceSize(): Size {
|
||||||
return mutableListOf()
|
return Size.UNKNOWN
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getCurrentCues(): CueGroup {
|
||||||
|
return CueGroup.EMPTY_TIME_ZERO
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getDeviceInfo(): DeviceInfo {
|
override fun getDeviceInfo(): DeviceInfo {
|
||||||
|
|||||||
@@ -86,7 +86,8 @@ class MediaSessionCallback(var playerNotificationService:PlayerNotificationServi
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onSeekTo(pos: Long) {
|
override fun onSeekTo(pos: Long) {
|
||||||
playerNotificationService.seekPlayer(pos)
|
val currentTrackStartOffset = playerNotificationService.getCurrentTrackStartOffsetMs()
|
||||||
|
playerNotificationService.seekPlayer(currentTrackStartOffset + pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onChangeSpeed() {
|
private fun onChangeSpeed() {
|
||||||
@@ -115,15 +116,16 @@ class MediaSessionCallback(var playerNotificationService:PlayerNotificationServi
|
|||||||
|
|
||||||
if (mediaId.isNullOrEmpty()) {
|
if (mediaId.isNullOrEmpty()) {
|
||||||
libraryItemWrapper = playerNotificationService.mediaManager.getFirstItem()
|
libraryItemWrapper = playerNotificationService.mediaManager.getFirstItem()
|
||||||
} else if (mediaId.startsWith("ep_") || mediaId.startsWith("local_ep_")) { // Playing podcast episode
|
|
||||||
val libraryItemWithEpisode = playerNotificationService.mediaManager.getPodcastWithEpisodeByEpisodeId(mediaId)
|
|
||||||
libraryItemWrapper = libraryItemWithEpisode?.libraryItemWrapper
|
|
||||||
podcastEpisode = libraryItemWithEpisode?.episode
|
|
||||||
} else {
|
} else {
|
||||||
libraryItemWrapper = playerNotificationService.mediaManager.getById(mediaId)
|
val libraryItemWithEpisode = playerNotificationService.mediaManager.getPodcastWithEpisodeByEpisodeId(mediaId)
|
||||||
|
if (libraryItemWithEpisode != null) {
|
||||||
if (libraryItemWrapper == null) {
|
libraryItemWrapper = libraryItemWithEpisode.libraryItemWrapper
|
||||||
Log.e(tag, "onPlayFromMediaId: Media item not found $mediaId")
|
podcastEpisode = libraryItemWithEpisode.episode
|
||||||
|
} else {
|
||||||
|
libraryItemWrapper = playerNotificationService.mediaManager.getById(mediaId)
|
||||||
|
if (libraryItemWrapper == null) {
|
||||||
|
Log.e(tag, "onPlayFromMediaId: Media item not found $mediaId")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ class MediaSessionPlaybackPreparer(var playerNotificationService:PlayerNotificat
|
|||||||
val libraryItemWrapper: LibraryItemWrapper?
|
val libraryItemWrapper: LibraryItemWrapper?
|
||||||
var podcastEpisode: PodcastEpisode? = null
|
var podcastEpisode: PodcastEpisode? = null
|
||||||
|
|
||||||
if (mediaId.startsWith("ep_") || mediaId.startsWith("local_ep_")) { // Playing podcast episode
|
val libraryItemWithEpisode = playerNotificationService.mediaManager.getPodcastWithEpisodeByEpisodeId(mediaId)
|
||||||
val libraryItemWithEpisode = playerNotificationService.mediaManager.getPodcastWithEpisodeByEpisodeId(mediaId)
|
if (libraryItemWithEpisode != null) {
|
||||||
libraryItemWrapper = libraryItemWithEpisode?.libraryItemWrapper
|
libraryItemWrapper = libraryItemWithEpisode.libraryItemWrapper
|
||||||
podcastEpisode = libraryItemWithEpisode?.episode
|
podcastEpisode = libraryItemWithEpisode.episode
|
||||||
} else {
|
} else {
|
||||||
libraryItemWrapper = playerNotificationService.mediaManager.getById(mediaId)
|
libraryItemWrapper = playerNotificationService.mediaManager.getById(mediaId)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ class PlayerListener(var playerNotificationService:PlayerNotificationService) :
|
|||||||
|
|
||||||
lazyIsPlaying = isPlaying
|
lazyIsPlaying = isPlaying
|
||||||
|
|
||||||
|
// Update widget
|
||||||
|
DeviceManager.widgetUpdater?.onPlayerChanged(playerNotificationService)
|
||||||
|
|
||||||
if (isPlaying) {
|
if (isPlaying) {
|
||||||
Log.d(tag, "SeekBackTime: Player is playing")
|
Log.d(tag, "SeekBackTime: Player is playing")
|
||||||
if (lastPauseTime > 0 && DeviceManager.deviceData.deviceSettings?.disableAutoRewind != true) {
|
if (lastPauseTime > 0 && DeviceManager.deviceData.deviceSettings?.disableAutoRewind != true) {
|
||||||
@@ -109,8 +112,6 @@ class PlayerListener(var playerNotificationService:PlayerNotificationService) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
playerNotificationService.clientEventEmitter?.onPlayingUpdate(isPlaying)
|
playerNotificationService.clientEventEmitter?.onPlayingUpdate(isPlaying)
|
||||||
|
|
||||||
DeviceManager.widgetUpdater?.onPlayerChanged(playerNotificationService)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onEvents(player: Player, events: Player.Events) {
|
override fun onEvents(player: Player, events: Player.Events) {
|
||||||
|
|||||||
@@ -44,11 +44,7 @@ class PlayerNotificationListener(var playerNotificationService:PlayerNotificatio
|
|||||||
} else {
|
} else {
|
||||||
Log.d(tag, "onNotificationCancelled not dismissed by user")
|
Log.d(tag, "onNotificationCancelled not dismissed by user")
|
||||||
|
|
||||||
// When stop button is pressed on the notification I guess it isn't considered "dismissedByUser" so we need to close playback ourselves
|
if (PlayerNotificationService.isSwitchingPlayer) {
|
||||||
if (!PlayerNotificationService.isClosed && !PlayerNotificationService.isSwitchingPlayer) {
|
|
||||||
Log.d(tag, "PNS is not closed - closing it now")
|
|
||||||
playerNotificationService.closePlayback()
|
|
||||||
} else if (PlayerNotificationService.isSwitchingPlayer) {
|
|
||||||
// When switching from cast player to exo player and vice versa the notification is cancelled and posted again
|
// When switching from cast player to exo player and vice versa the notification is cancelled and posted again
|
||||||
// so we don't want to cancel the playback during this switch
|
// so we don't want to cancel the playback during this switch
|
||||||
Log.d(tag, "PNS is switching player")
|
Log.d(tag, "PNS is switching player")
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package com.audiobookshelf.app.player
|
|||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.*
|
import android.app.*
|
||||||
import android.appwidget.AppWidgetManager
|
|
||||||
import android.content.ComponentName
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
@@ -11,10 +9,7 @@ import android.graphics.Color
|
|||||||
import android.graphics.ImageDecoder
|
import android.graphics.ImageDecoder
|
||||||
import android.hardware.Sensor
|
import android.hardware.Sensor
|
||||||
import android.hardware.SensorManager
|
import android.hardware.SensorManager
|
||||||
import android.net.ConnectivityManager
|
import android.net.*
|
||||||
import android.net.Network
|
|
||||||
import android.net.NetworkCapabilities
|
|
||||||
import android.net.NetworkRequest
|
|
||||||
import android.os.*
|
import android.os.*
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
@@ -25,14 +20,11 @@ import android.support.v4.media.session.MediaControllerCompat
|
|||||||
import android.support.v4.media.session.MediaSessionCompat
|
import android.support.v4.media.session.MediaSessionCompat
|
||||||
import android.support.v4.media.session.PlaybackStateCompat
|
import android.support.v4.media.session.PlaybackStateCompat
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.View
|
|
||||||
import android.widget.RemoteViews
|
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.media.MediaBrowserServiceCompat
|
import androidx.media.MediaBrowserServiceCompat
|
||||||
import androidx.media.utils.MediaConstants
|
import androidx.media.utils.MediaConstants
|
||||||
import com.audiobookshelf.app.BuildConfig
|
|
||||||
import com.audiobookshelf.app.R
|
import com.audiobookshelf.app.R
|
||||||
import com.audiobookshelf.app.data.*
|
import com.audiobookshelf.app.data.*
|
||||||
import com.audiobookshelf.app.data.DeviceInfo
|
import com.audiobookshelf.app.data.DeviceInfo
|
||||||
@@ -42,16 +34,22 @@ import com.audiobookshelf.app.managers.SleepTimerManager
|
|||||||
import com.audiobookshelf.app.media.MediaManager
|
import com.audiobookshelf.app.media.MediaManager
|
||||||
import com.audiobookshelf.app.media.MediaProgressSyncer
|
import com.audiobookshelf.app.media.MediaProgressSyncer
|
||||||
import com.audiobookshelf.app.server.ApiHandler
|
import com.audiobookshelf.app.server.ApiHandler
|
||||||
|
import com.audiobookshelf.app.BuildConfig
|
||||||
|
import com.audiobookshelf.app.media.getUriToAbsIconDrawable
|
||||||
|
import com.audiobookshelf.app.media.getUriToDrawable
|
||||||
import com.google.android.exoplayer2.*
|
import com.google.android.exoplayer2.*
|
||||||
import com.google.android.exoplayer2.audio.AudioAttributes
|
import com.google.android.exoplayer2.audio.AudioAttributes
|
||||||
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector
|
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector
|
||||||
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector.CustomActionProvider
|
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector.CustomActionProvider
|
||||||
import com.google.android.exoplayer2.ext.mediasession.TimelineQueueNavigator
|
import com.google.android.exoplayer2.ext.mediasession.TimelineQueueNavigator
|
||||||
|
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory
|
||||||
|
import com.google.android.exoplayer2.extractor.mp3.Mp3Extractor
|
||||||
import com.google.android.exoplayer2.source.MediaSource
|
import com.google.android.exoplayer2.source.MediaSource
|
||||||
import com.google.android.exoplayer2.source.ProgressiveMediaSource
|
import com.google.android.exoplayer2.source.ProgressiveMediaSource
|
||||||
import com.google.android.exoplayer2.source.hls.HlsMediaSource
|
import com.google.android.exoplayer2.source.hls.HlsMediaSource
|
||||||
import com.google.android.exoplayer2.ui.PlayerNotificationManager
|
import com.google.android.exoplayer2.ui.PlayerNotificationManager
|
||||||
import com.google.android.exoplayer2.upstream.*
|
import com.google.android.exoplayer2.upstream.*
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.concurrent.schedule
|
import kotlin.concurrent.schedule
|
||||||
|
|
||||||
@@ -70,7 +68,7 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
var isSwitchingPlayer = false // Used when switching between cast player and exoplayer
|
var isSwitchingPlayer = false // Used when switching between cast player and exoplayer
|
||||||
}
|
}
|
||||||
|
|
||||||
private val tag = "PlayerNotificationService"
|
private val tag = "PlayerNotificationServ"
|
||||||
|
|
||||||
interface ClientEventEmitter {
|
interface ClientEventEmitter {
|
||||||
fun onPlaybackSession(playbackSession:PlaybackSession)
|
fun onPlaybackSession(playbackSession:PlaybackSession)
|
||||||
@@ -124,6 +122,18 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
private var mShakeDetector: ShakeDetector? = null
|
private var mShakeDetector: ShakeDetector? = null
|
||||||
private var shakeSensorUnregisterTask:TimerTask? = null
|
private var shakeSensorUnregisterTask:TimerTask? = null
|
||||||
|
|
||||||
|
// These are used to trigger reloading if
|
||||||
|
private var forceReloadingAndroidAuto:Boolean = false
|
||||||
|
private var firstLoadDone:Boolean = false
|
||||||
|
|
||||||
|
fun isBrowseTreeInitialized() : Boolean {
|
||||||
|
return this::browseTree.isInitialized
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cache latest search so it wont trigger again when returning from series for example
|
||||||
|
private var cachedSearch : String = ""
|
||||||
|
private var cachedSearchResults : MutableList<MediaBrowserCompat.MediaItem> = mutableListOf()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Service related stuff
|
Service related stuff
|
||||||
*/
|
*/
|
||||||
@@ -203,6 +213,12 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
super.onCreate()
|
super.onCreate()
|
||||||
ctx = this
|
ctx = this
|
||||||
|
|
||||||
|
// Initialize Paper
|
||||||
|
DbManager.initialize(ctx)
|
||||||
|
|
||||||
|
// Initialize widget
|
||||||
|
DeviceManager.initializeWidgetUpdater(ctx)
|
||||||
|
|
||||||
// To listen for network change from metered to unmetered
|
// To listen for network change from metered to unmetered
|
||||||
val networkRequest = NetworkRequest.Builder()
|
val networkRequest = NetworkRequest.Builder()
|
||||||
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
||||||
@@ -264,7 +280,7 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
playerNotificationManager.setUseNextAction(false)
|
playerNotificationManager.setUseNextAction(false)
|
||||||
playerNotificationManager.setUsePreviousAction(false)
|
playerNotificationManager.setUsePreviousAction(false)
|
||||||
playerNotificationManager.setUseChronometer(false)
|
playerNotificationManager.setUseChronometer(false)
|
||||||
playerNotificationManager.setUseStopAction(true)
|
playerNotificationManager.setUseStopAction(false)
|
||||||
playerNotificationManager.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
playerNotificationManager.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||||
playerNotificationManager.setPriority(NotificationCompat.PRIORITY_MAX)
|
playerNotificationManager.setPriority(NotificationCompat.PRIORITY_MAX)
|
||||||
playerNotificationManager.setUseFastForwardActionInCompactView(true)
|
playerNotificationManager.setUseFastForwardActionInCompactView(true)
|
||||||
@@ -288,10 +304,10 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
return MediaDescriptionCompat.Builder().build()
|
return MediaDescriptionCompat.Builder().build()
|
||||||
}
|
}
|
||||||
|
|
||||||
val coverUri = currentPlaybackSession!!.getCoverUri()
|
val coverUri = currentPlaybackSession!!.getCoverUri(ctx)
|
||||||
|
|
||||||
var bitmap:Bitmap? = null
|
var bitmap: Bitmap? = null
|
||||||
// Local covers get bitmap
|
// Local covers get bitmap
|
||||||
if (currentPlaybackSession!!.localLibraryItem?.coverContentUrl != null) {
|
if (currentPlaybackSession!!.localLibraryItem?.coverContentUrl != null) {
|
||||||
bitmap = if (Build.VERSION.SDK_INT < 28) {
|
bitmap = if (Build.VERSION.SDK_INT < 28) {
|
||||||
MediaStore.Images.Media.getBitmap(ctx.contentResolver, coverUri)
|
MediaStore.Images.Media.getBitmap(ctx.contentResolver, coverUri)
|
||||||
@@ -319,25 +335,16 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
val mediaDescriptionBuilder = MediaDescriptionCompat.Builder()
|
val mediaDescriptionBuilder = MediaDescriptionCompat.Builder()
|
||||||
.setExtras(extra)
|
.setExtras(extra)
|
||||||
.setTitle(currentPlaybackSession!!.displayTitle)
|
.setTitle(currentPlaybackSession!!.displayTitle)
|
||||||
.setIconUri(coverUri)
|
|
||||||
|
|
||||||
bitmap?.let {
|
bitmap?.let {
|
||||||
mediaDescriptionBuilder.setIconBitmap(it)
|
mediaDescriptionBuilder.setIconBitmap(it)
|
||||||
}
|
} ?: mediaDescriptionBuilder.setIconUri(coverUri)
|
||||||
|
|
||||||
return mediaDescriptionBuilder.build()
|
return mediaDescriptionBuilder.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mediaSessionConnector.setEnabledPlaybackActions(
|
setMediaSessionConnectorPlaybackActions()
|
||||||
PlaybackStateCompat.ACTION_PLAY_PAUSE
|
|
||||||
or PlaybackStateCompat.ACTION_PLAY
|
|
||||||
or PlaybackStateCompat.ACTION_PAUSE
|
|
||||||
or PlaybackStateCompat.ACTION_SEEK_TO
|
|
||||||
or PlaybackStateCompat.ACTION_FAST_FORWARD
|
|
||||||
or PlaybackStateCompat.ACTION_REWIND
|
|
||||||
or PlaybackStateCompat.ACTION_STOP
|
|
||||||
)
|
|
||||||
mediaSessionConnector.setQueueNavigator(queueNavigator)
|
mediaSessionConnector.setQueueNavigator(queueNavigator)
|
||||||
mediaSessionConnector.setPlaybackPreparer(MediaSessionPlaybackPreparer(this))
|
mediaSessionConnector.setPlaybackPreparer(MediaSessionPlaybackPreparer(this))
|
||||||
|
|
||||||
@@ -362,7 +369,7 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
.build()
|
.build()
|
||||||
mPlayer.setHandleAudioBecomingNoisy(true)
|
mPlayer.setHandleAudioBecomingNoisy(true)
|
||||||
mPlayer.addListener(PlayerListener(this))
|
mPlayer.addListener(PlayerListener(this))
|
||||||
val audioAttributes:AudioAttributes = AudioAttributes.Builder().setUsage(C.USAGE_MEDIA).setContentType(C.CONTENT_TYPE_SPEECH).build()
|
val audioAttributes:AudioAttributes = AudioAttributes.Builder().setUsage(C.USAGE_MEDIA).setContentType(C.AUDIO_CONTENT_TYPE_SPEECH).build()
|
||||||
mPlayer.setAudioAttributes(audioAttributes, true)
|
mPlayer.setAudioAttributes(audioAttributes, true)
|
||||||
|
|
||||||
//attach player to playerNotificationManager
|
//attach player to playerNotificationManager
|
||||||
@@ -394,7 +401,7 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
|
|
||||||
val metadata = playbackSession.getMediaMetadataCompat(ctx)
|
val metadata = playbackSession.getMediaMetadataCompat(ctx)
|
||||||
mediaSession.setMetadata(metadata)
|
mediaSession.setMetadata(metadata)
|
||||||
val mediaItems = playbackSession.getMediaItems()
|
val mediaItems = playbackSession.getMediaItems(ctx)
|
||||||
val playbackRateToUse = playbackRate ?: initialPlaybackRate ?: 1f
|
val playbackRateToUse = playbackRate ?: initialPlaybackRate ?: 1f
|
||||||
initialPlaybackRate = playbackRate
|
initialPlaybackRate = playbackRate
|
||||||
|
|
||||||
@@ -438,12 +445,26 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
if (playbackSession.isLocal) {
|
if (playbackSession.isLocal) {
|
||||||
Log.d(tag, "Playing Local Item")
|
Log.d(tag, "Playing Local Item")
|
||||||
val dataSourceFactory = DefaultDataSource.Factory(ctx)
|
val dataSourceFactory = DefaultDataSource.Factory(ctx)
|
||||||
mediaSource = ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(mediaItems[0])
|
|
||||||
|
val extractorsFactory = DefaultExtractorsFactory()
|
||||||
|
if (DeviceManager.deviceData.deviceSettings?.enableMp3IndexSeeking == true) {
|
||||||
|
// @see https://exoplayer.dev/troubleshooting.html#why-is-seeking-inaccurate-in-some-mp3-files
|
||||||
|
extractorsFactory.setMp3ExtractorFlags(Mp3Extractor.FLAG_ENABLE_INDEX_SEEKING)
|
||||||
|
}
|
||||||
|
|
||||||
|
mediaSource = ProgressiveMediaSource.Factory(dataSourceFactory, extractorsFactory).createMediaSource(mediaItems[0])
|
||||||
} else if (!playbackSession.isHLS) {
|
} else if (!playbackSession.isHLS) {
|
||||||
Log.d(tag, "Direct Playing Item")
|
Log.d(tag, "Direct Playing Item")
|
||||||
val dataSourceFactory = DefaultHttpDataSource.Factory()
|
val dataSourceFactory = DefaultHttpDataSource.Factory()
|
||||||
|
|
||||||
|
val extractorsFactory = DefaultExtractorsFactory()
|
||||||
|
if (DeviceManager.deviceData.deviceSettings?.enableMp3IndexSeeking == true) {
|
||||||
|
// @see https://exoplayer.dev/troubleshooting.html#why-is-seeking-inaccurate-in-some-mp3-files
|
||||||
|
extractorsFactory.setMp3ExtractorFlags(Mp3Extractor.FLAG_ENABLE_INDEX_SEEKING)
|
||||||
|
}
|
||||||
|
|
||||||
dataSourceFactory.setUserAgent(channelId)
|
dataSourceFactory.setUserAgent(channelId)
|
||||||
mediaSource = ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(mediaItems[0])
|
mediaSource = ProgressiveMediaSource.Factory(dataSourceFactory, extractorsFactory).createMediaSource(mediaItems[0])
|
||||||
} else {
|
} else {
|
||||||
Log.d(tag, "Playing HLS Item")
|
Log.d(tag, "Playing HLS Item")
|
||||||
val dataSourceFactory = DefaultHttpDataSource.Factory()
|
val dataSourceFactory = DefaultHttpDataSource.Factory()
|
||||||
@@ -483,7 +504,7 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setMediaSessionConnectorCustomActions(playbackSession:PlaybackSession) {
|
private fun setMediaSessionConnectorCustomActions(playbackSession:PlaybackSession) {
|
||||||
val mediaItems = playbackSession.getMediaItems()
|
val mediaItems = playbackSession.getMediaItems(ctx)
|
||||||
val customActionProviders = mutableListOf(
|
val customActionProviders = mutableListOf(
|
||||||
JumpBackwardCustomActionProvider(),
|
JumpBackwardCustomActionProvider(),
|
||||||
JumpForwardCustomActionProvider(),
|
JumpForwardCustomActionProvider(),
|
||||||
@@ -498,6 +519,20 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
mediaSessionConnector.setCustomActionProviders(*customActionProviders.toTypedArray())
|
mediaSessionConnector.setCustomActionProviders(*customActionProviders.toTypedArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setMediaSessionConnectorPlaybackActions() {
|
||||||
|
var playbackActions = PlaybackStateCompat.ACTION_PLAY_PAUSE or
|
||||||
|
PlaybackStateCompat.ACTION_PLAY or
|
||||||
|
PlaybackStateCompat.ACTION_PAUSE or
|
||||||
|
PlaybackStateCompat.ACTION_FAST_FORWARD or
|
||||||
|
PlaybackStateCompat.ACTION_REWIND or
|
||||||
|
PlaybackStateCompat.ACTION_STOP
|
||||||
|
|
||||||
|
if (deviceSettings.allowSeekingOnMediaControls) {
|
||||||
|
playbackActions = playbackActions or PlaybackStateCompat.ACTION_SEEK_TO
|
||||||
|
}
|
||||||
|
mediaSessionConnector.setEnabledPlaybackActions(playbackActions)
|
||||||
|
}
|
||||||
|
|
||||||
fun handlePlayerPlaybackError(errorMessage:String) {
|
fun handlePlayerPlaybackError(errorMessage:String) {
|
||||||
// On error and was attempting to direct play - fallback to transcode
|
// On error and was attempting to direct play - fallback to transcode
|
||||||
currentPlaybackSession?.let { playbackSession ->
|
currentPlaybackSession?.let { playbackSession ->
|
||||||
@@ -638,16 +673,20 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getCurrentTime() : Long {
|
fun getCurrentTrackStartOffsetMs() : Long {
|
||||||
return if (currentPlayer.mediaItemCount > 1) {
|
return if (currentPlayer.mediaItemCount > 1) {
|
||||||
val windowIndex = currentPlayer.currentMediaItemIndex
|
val windowIndex = currentPlayer.currentMediaItemIndex
|
||||||
val currentTrackStartOffset = currentPlaybackSession?.getTrackStartOffsetMs(windowIndex) ?: 0L
|
val currentTrackStartOffset = currentPlaybackSession?.getTrackStartOffsetMs(windowIndex) ?: 0L
|
||||||
currentPlayer.currentPosition + currentTrackStartOffset
|
currentTrackStartOffset
|
||||||
} else {
|
} else {
|
||||||
currentPlayer.currentPosition
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getCurrentTime() : Long {
|
||||||
|
return currentPlayer.currentPosition + getCurrentTrackStartOffsetMs()
|
||||||
|
}
|
||||||
|
|
||||||
fun getCurrentTimeSeconds() : Double {
|
fun getCurrentTimeSeconds() : Double {
|
||||||
return getCurrentTime() / 1000.0
|
return getCurrentTime() / 1000.0
|
||||||
}
|
}
|
||||||
@@ -863,10 +902,28 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
|
|
||||||
fun closePlayback(calledOnError:Boolean? = false) {
|
fun closePlayback(calledOnError:Boolean? = false) {
|
||||||
Log.d(tag, "closePlayback")
|
Log.d(tag, "closePlayback")
|
||||||
|
val config = DeviceManager.serverConnectionConfig
|
||||||
|
|
||||||
|
val isLocal = mediaProgressSyncer.currentIsLocal
|
||||||
|
val currentSessionId = mediaProgressSyncer.currentSessionId
|
||||||
if (mediaProgressSyncer.listeningTimerRunning) {
|
if (mediaProgressSyncer.listeningTimerRunning) {
|
||||||
Log.i(tag, "About to close playback so stopping media progress syncer first")
|
Log.i(tag, "About to close playback so stopping media progress syncer first")
|
||||||
|
|
||||||
mediaProgressSyncer.stop(calledOnError == false) { // If closing on error then do not sync progress (causes exception)
|
mediaProgressSyncer.stop(calledOnError == false) { // If closing on error then do not sync progress (causes exception)
|
||||||
Log.d(tag, "Media Progress syncer stopped")
|
Log.d(tag, "Media Progress syncer stopped")
|
||||||
|
// If not local session then close on server
|
||||||
|
if (!isLocal && currentSessionId != "") {
|
||||||
|
apiHandler.closePlaybackSession(currentSessionId, config) {
|
||||||
|
Log.d(tag, "Closed playback session $currentSessionId")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// If not local session then close on server
|
||||||
|
if (!isLocal && currentSessionId != "") {
|
||||||
|
apiHandler.closePlaybackSession(currentSessionId, config) {
|
||||||
|
Log.d(tag, "Closed playback session $currentSessionId")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -880,8 +937,10 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
currentPlaybackSession = null
|
currentPlaybackSession = null
|
||||||
mediaProgressSyncer.reset()
|
mediaProgressSyncer.reset()
|
||||||
clientEventEmitter?.onPlaybackClosed()
|
clientEventEmitter?.onPlaybackClosed()
|
||||||
|
|
||||||
PlayerListener.lastPauseTime = 0
|
PlayerListener.lastPauseTime = 0
|
||||||
isClosed = true
|
isClosed = true
|
||||||
|
DeviceManager.widgetUpdater?.onPlayerClosed()
|
||||||
stopForeground(Service.STOP_FOREGROUND_REMOVE)
|
stopForeground(Service.STOP_FOREGROUND_REMOVE)
|
||||||
stopSelf()
|
stopSelf()
|
||||||
}
|
}
|
||||||
@@ -896,7 +955,7 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("HardwareIds")
|
@SuppressLint("HardwareIds")
|
||||||
private fun getDeviceInfo(): DeviceInfo {
|
fun getDeviceInfo(): DeviceInfo {
|
||||||
/* EXAMPLE
|
/* EXAMPLE
|
||||||
manufacturer: Google
|
manufacturer: Google
|
||||||
model: Pixel 6
|
model: Pixel 6
|
||||||
@@ -905,7 +964,7 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
appVersion: 0.9.46-beta
|
appVersion: 0.9.46-beta
|
||||||
*/
|
*/
|
||||||
val deviceId = Settings.Secure.getString(ctx.contentResolver, Settings.Secure.ANDROID_ID)
|
val deviceId = Settings.Secure.getString(ctx.contentResolver, Settings.Secure.ANDROID_ID)
|
||||||
return DeviceInfo(deviceId, Build.MANUFACTURER, Build.MODEL, Build.BRAND, Build.VERSION.SDK_INT, BuildConfig.VERSION_NAME)
|
return DeviceInfo(deviceId, Build.MANUFACTURER, Build.MODEL, Build.VERSION.SDK_INT, BuildConfig.VERSION_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val deviceSettings get() = DeviceManager.deviceData.deviceSettings ?: DeviceSettings.default()
|
private val deviceSettings get() = DeviceManager.deviceData.deviceSettings ?: DeviceSettings.default()
|
||||||
@@ -933,6 +992,7 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
|
|
||||||
private val AUTO_MEDIA_ROOT = "/"
|
private val AUTO_MEDIA_ROOT = "/"
|
||||||
private val LIBRARIES_ROOT = "__LIBRARIES__"
|
private val LIBRARIES_ROOT = "__LIBRARIES__"
|
||||||
|
private val RECENTLY_ROOT = "__RECENTLY__"
|
||||||
private val DOWNLOADS_ROOT = "__DOWNLOADS__"
|
private val DOWNLOADS_ROOT = "__DOWNLOADS__"
|
||||||
private val CONTINUE_ROOT = "__CONTINUE__"
|
private val CONTINUE_ROOT = "__CONTINUE__"
|
||||||
private lateinit var browseTree:BrowseTree
|
private lateinit var browseTree:BrowseTree
|
||||||
@@ -955,20 +1015,28 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
// No further calls will be made to other media browsing methods.
|
// No further calls will be made to other media browsing methods.
|
||||||
null
|
null
|
||||||
} else {
|
} else {
|
||||||
|
Log.d(tag, "Android Auto starting")
|
||||||
isStarted = true
|
isStarted = true
|
||||||
mediaManager.checkResetServerItems() // Reset any server items if no longer connected to server
|
|
||||||
|
// Reset cache if no longer connected to server or server changed
|
||||||
|
if (mediaManager.checkResetServerItems()) {
|
||||||
|
forceReloadingAndroidAuto = true
|
||||||
|
}
|
||||||
|
|
||||||
isAndroidAuto = true
|
isAndroidAuto = true
|
||||||
|
|
||||||
val extras = Bundle()
|
val extras = Bundle()
|
||||||
extras.putBoolean(
|
extras.putBoolean(
|
||||||
MediaConstants.BROWSER_SERVICE_EXTRAS_KEY_SEARCH_SUPPORTED, true)
|
MediaConstants.BROWSER_SERVICE_EXTRAS_KEY_SEARCH_SUPPORTED, true
|
||||||
|
)
|
||||||
extras.putInt(
|
extras.putInt(
|
||||||
MediaConstants.DESCRIPTION_EXTRAS_KEY_CONTENT_STYLE_BROWSABLE,
|
MediaConstants.DESCRIPTION_EXTRAS_KEY_CONTENT_STYLE_BROWSABLE,
|
||||||
MediaConstants.DESCRIPTION_EXTRAS_VALUE_CONTENT_STYLE_LIST_ITEM)
|
MediaConstants.DESCRIPTION_EXTRAS_VALUE_CONTENT_STYLE_LIST_ITEM
|
||||||
|
)
|
||||||
extras.putInt(
|
extras.putInt(
|
||||||
MediaConstants.DESCRIPTION_EXTRAS_KEY_CONTENT_STYLE_PLAYABLE,
|
MediaConstants.DESCRIPTION_EXTRAS_KEY_CONTENT_STYLE_PLAYABLE,
|
||||||
MediaConstants.DESCRIPTION_EXTRAS_VALUE_CONTENT_STYLE_LIST_ITEM)
|
MediaConstants.DESCRIPTION_EXTRAS_VALUE_CONTENT_STYLE_LIST_ITEM
|
||||||
|
)
|
||||||
|
|
||||||
BrowserRoot(AUTO_MEDIA_ROOT, extras)
|
BrowserRoot(AUTO_MEDIA_ROOT, extras)
|
||||||
}
|
}
|
||||||
@@ -979,67 +1047,59 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
|
|
||||||
result.detach()
|
result.detach()
|
||||||
|
|
||||||
if (parentMediaId.startsWith("li_") || parentMediaId.startsWith("local_")) { // Show podcast episodes
|
// Prevent crashing if app is restarted while browsing
|
||||||
Log.d(tag, "Loading podcast episodes")
|
if ((parentMediaId != DOWNLOADS_ROOT && parentMediaId != AUTO_MEDIA_ROOT) && !firstLoadDone){
|
||||||
mediaManager.loadPodcastEpisodeMediaBrowserItems(parentMediaId, ctx) {
|
result.sendResult(null)
|
||||||
result.sendResult(it)
|
return
|
||||||
}
|
}
|
||||||
} else if (::browseTree.isInitialized && browseTree[parentMediaId] == null && mediaManager.getIsLibrary(parentMediaId)) { // Load library items for library
|
|
||||||
|
|
||||||
mediaManager.loadLibraryItemsWithAudio(parentMediaId) { libraryItems ->
|
if (parentMediaId == DOWNLOADS_ROOT) { // Load downloads
|
||||||
val children = libraryItems.map { libraryItem ->
|
|
||||||
if (libraryItem.mediaType == "podcast") { // Podcasts are browseable
|
|
||||||
val mediaDescription = libraryItem.getMediaDescription(null, ctx)
|
|
||||||
MediaBrowserCompat.MediaItem(mediaDescription, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)
|
|
||||||
} else {
|
|
||||||
val progress = mediaManager.serverUserMediaProgress.find { it.libraryItemId == libraryItem.id }
|
|
||||||
val localLibraryItem = DeviceManager.dbManager.getLocalLibraryItemByLId(libraryItem.id)
|
|
||||||
libraryItem.localLibraryItemId = localLibraryItem?.id
|
|
||||||
val description = libraryItem.getMediaDescription(progress, ctx)
|
|
||||||
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
|
||||||
}
|
|
||||||
} else if (parentMediaId == DOWNLOADS_ROOT) { // Load downloads
|
|
||||||
|
|
||||||
val localBooks = DeviceManager.dbManager.getLocalLibraryItems("book")
|
val localBooks = DeviceManager.dbManager.getLocalLibraryItems("book")
|
||||||
val localPodcasts = DeviceManager.dbManager.getLocalLibraryItems("podcast")
|
val localPodcasts = DeviceManager.dbManager.getLocalLibraryItems("podcast")
|
||||||
val localBrowseItems:MutableList<MediaBrowserCompat.MediaItem> = mutableListOf()
|
val localBrowseItems: MutableList<MediaBrowserCompat.MediaItem> = mutableListOf()
|
||||||
|
|
||||||
localBooks.forEach { localLibraryItem ->
|
localBooks.forEach { localLibraryItem ->
|
||||||
val progress = DeviceManager.dbManager.getLocalMediaProgress(localLibraryItem.id)
|
if (localLibraryItem.media.getAudioTracks().isNotEmpty()) {
|
||||||
val description = localLibraryItem.getMediaDescription(progress, ctx)
|
val progress = DeviceManager.dbManager.getLocalMediaProgress(localLibraryItem.id)
|
||||||
|
val description = localLibraryItem.getMediaDescription(progress, ctx)
|
||||||
|
|
||||||
localBrowseItems += MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE)
|
localBrowseItems += MediaBrowserCompat.MediaItem(
|
||||||
|
description,
|
||||||
|
MediaBrowserCompat.MediaItem.FLAG_PLAYABLE
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
localPodcasts.forEach { localLibraryItem ->
|
localPodcasts.forEach { localLibraryItem ->
|
||||||
val mediaDescription = localLibraryItem.getMediaDescription(null, ctx)
|
val mediaDescription = localLibraryItem.getMediaDescription(null, ctx)
|
||||||
localBrowseItems += MediaBrowserCompat.MediaItem(mediaDescription, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)
|
localBrowseItems += MediaBrowserCompat.MediaItem(
|
||||||
|
mediaDescription,
|
||||||
|
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
result.sendResult(localBrowseItems)
|
result.sendResult(localBrowseItems)
|
||||||
|
|
||||||
} else if (parentMediaId == CONTINUE_ROOT) {
|
} else if (parentMediaId == CONTINUE_ROOT) {
|
||||||
val localBrowseItems:MutableList<MediaBrowserCompat.MediaItem> = mutableListOf()
|
val localBrowseItems: MutableList<MediaBrowserCompat.MediaItem> = mutableListOf()
|
||||||
mediaManager.serverItemsInProgress.forEach { itemInProgress ->
|
mediaManager.serverItemsInProgress.forEach { itemInProgress ->
|
||||||
val progress: MediaProgressWrapper?
|
val progress: MediaProgressWrapper?
|
||||||
val mediaDescription:MediaDescriptionCompat
|
val mediaDescription: MediaDescriptionCompat
|
||||||
if (itemInProgress.episode != null) {
|
if (itemInProgress.episode != null) {
|
||||||
if (itemInProgress.isLocal) {
|
if (itemInProgress.isLocal) {
|
||||||
progress = DeviceManager.dbManager.getLocalMediaProgress("${itemInProgress.libraryItemWrapper.id}-${itemInProgress.episode.id}")
|
progress = DeviceManager.dbManager.getLocalMediaProgress("${itemInProgress.libraryItemWrapper.id}-${itemInProgress.episode.id}")
|
||||||
} else {
|
} else {
|
||||||
progress = mediaManager.serverUserMediaProgress.find { it.libraryItemId == itemInProgress.libraryItemWrapper.id && it.episodeId == itemInProgress.episode.id }
|
progress = mediaManager.serverUserMediaProgress.find { it.libraryItemId == itemInProgress.libraryItemWrapper.id && it.episodeId == itemInProgress.episode.id }
|
||||||
|
|
||||||
// to show download icon
|
// to show download icon
|
||||||
val localLibraryItem = DeviceManager.dbManager.getLocalLibraryItemByLId(itemInProgress.libraryItemWrapper.id)
|
val localLibraryItem = DeviceManager.dbManager.getLocalLibraryItemByLId(itemInProgress.libraryItemWrapper.id)
|
||||||
localLibraryItem?.let { lli ->
|
localLibraryItem?.let { lli ->
|
||||||
val localEpisode = (lli.media as Podcast).episodes?.find { it.serverEpisodeId == itemInProgress.episode.id }
|
val localEpisode = (lli.media as Podcast).episodes?.find { it.serverEpisodeId == itemInProgress.episode.id }
|
||||||
itemInProgress.episode.localEpisodeId = localEpisode?.id
|
itemInProgress.episode.localEpisodeId = localEpisode?.id
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
mediaDescription = itemInProgress.episode.getMediaDescription(itemInProgress.libraryItemWrapper, progress, ctx)
|
mediaDescription = itemInProgress.episode.getMediaDescription(itemInProgress.libraryItemWrapper, progress, ctx)
|
||||||
} else {
|
} else {
|
||||||
if (itemInProgress.isLocal) {
|
if (itemInProgress.isLocal) {
|
||||||
@@ -1055,28 +1115,499 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
localBrowseItems += MediaBrowserCompat.MediaItem(mediaDescription, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE)
|
localBrowseItems += MediaBrowserCompat.MediaItem(mediaDescription, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE)
|
||||||
}
|
}
|
||||||
result.sendResult(localBrowseItems)
|
result.sendResult(localBrowseItems)
|
||||||
} else {
|
} else if (parentMediaId == AUTO_MEDIA_ROOT) {
|
||||||
mediaManager.loadAndroidAutoItems {
|
Log.d(tag, "Trying to initialize browseTree.")
|
||||||
browseTree = BrowseTree(this, mediaManager.serverItemsInProgress, mediaManager.serverLibraries)
|
if (!this::browseTree.isInitialized || forceReloadingAndroidAuto) {
|
||||||
|
forceReloadingAndroidAuto = false
|
||||||
val children = browseTree[parentMediaId]?.map { item ->
|
mediaManager.loadAndroidAutoItems {
|
||||||
Log.d(tag, "Loading Browser Media Item ${item.description.title}")
|
Log.d(tag, "android auto loaded. Starting browseTree initialize")
|
||||||
|
browseTree = BrowseTree(this, mediaManager.serverItemsInProgress, mediaManager.serverLibraries, mediaManager.allLibraryPersonalizationsDone)
|
||||||
|
val children = browseTree[parentMediaId]?.map { item ->
|
||||||
|
Log.d(tag, "Found top menu item: ${item.description.title}")
|
||||||
MediaBrowserCompat.MediaItem(item.description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)
|
MediaBrowserCompat.MediaItem(item.description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)
|
||||||
|
}
|
||||||
|
Log.d(tag, "browseTree initialize and android auto loaded")
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
firstLoadDone = true
|
||||||
|
if (mediaManager.serverLibraries.isNotEmpty()) {
|
||||||
|
Log.d(tag, "Starting personalization fetch")
|
||||||
|
mediaManager.populatePersonalizedDataForAllLibraries {
|
||||||
|
notifyChildrenChanged("/")
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.d(tag, "Initialize inprogress items")
|
||||||
|
mediaManager.initializeInProgressItems {
|
||||||
|
notifyChildrenChanged("/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.d(tag, "Starting browseTree refresh")
|
||||||
|
browseTree = BrowseTree(this, mediaManager.serverItemsInProgress, mediaManager.serverLibraries, mediaManager.allLibraryPersonalizationsDone)
|
||||||
|
val children = browseTree[parentMediaId]?.map { item ->
|
||||||
|
Log.d(tag, "Found top menu item: ${item.description.title}")
|
||||||
|
MediaBrowserCompat.MediaItem(item.description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)
|
||||||
|
}
|
||||||
|
Log.d(tag, "browseTree initialize and android auto loaded")
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
}
|
||||||
|
} else if (parentMediaId == LIBRARIES_ROOT || parentMediaId == RECENTLY_ROOT) {
|
||||||
|
Log.d(tag, "First load done: $firstLoadDone")
|
||||||
|
if (!firstLoadDone) {
|
||||||
|
result.sendResult(null)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Wait until top-menu is initialized
|
||||||
|
while (!this::browseTree.isInitialized) {}
|
||||||
|
val children = browseTree[parentMediaId]?.map { item ->
|
||||||
|
Log.d(tag, "[MENU: $parentMediaId] Showing list item ${item.description.title}")
|
||||||
|
MediaBrowserCompat.MediaItem(item.description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
} else if (mediaManager.getIsLibrary(parentMediaId)) { // Load library items for library
|
||||||
|
Log.d(tag, "Loading items for library $parentMediaId")
|
||||||
|
val selectedLibrary = mediaManager.getLibrary(parentMediaId)
|
||||||
|
if (selectedLibrary?.mediaType == "podcast") { // Podcasts are browseable
|
||||||
|
mediaManager.loadLibraryPodcasts(parentMediaId) { libraryItems ->
|
||||||
|
val children = libraryItems?.map { libraryItem ->
|
||||||
|
val mediaDescription = libraryItem.getMediaDescription(null, ctx)
|
||||||
|
MediaBrowserCompat.MediaItem(
|
||||||
|
mediaDescription,
|
||||||
|
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
||||||
|
)
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val children = mutableListOf(
|
||||||
|
MediaBrowserCompat.MediaItem(
|
||||||
|
MediaDescriptionCompat.Builder()
|
||||||
|
.setTitle("Authors")
|
||||||
|
.setMediaId("__LIBRARY__${parentMediaId}__AUTHORS")
|
||||||
|
.setIconUri(getUriToAbsIconDrawable(ctx, "authors"))
|
||||||
|
.build(),
|
||||||
|
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
||||||
|
),
|
||||||
|
MediaBrowserCompat.MediaItem(
|
||||||
|
MediaDescriptionCompat.Builder()
|
||||||
|
.setTitle("Series")
|
||||||
|
.setMediaId("__LIBRARY__${parentMediaId}__SERIES_LIST")
|
||||||
|
.setIconUri(getUriToAbsIconDrawable(ctx, "columns"))
|
||||||
|
.build(),
|
||||||
|
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
||||||
|
),
|
||||||
|
MediaBrowserCompat.MediaItem(
|
||||||
|
MediaDescriptionCompat.Builder()
|
||||||
|
.setTitle("Collections")
|
||||||
|
.setMediaId("__LIBRARY__${parentMediaId}__COLLECTIONS")
|
||||||
|
.setIconUri(getUriToDrawable(ctx, R.drawable.md_book_multiple_outline))
|
||||||
|
.build(),
|
||||||
|
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if (mediaManager.getHasDiscovery(parentMediaId)) {
|
||||||
|
children.add(
|
||||||
|
MediaBrowserCompat.MediaItem(
|
||||||
|
MediaDescriptionCompat.Builder()
|
||||||
|
.setTitle("Discovery")
|
||||||
|
.setMediaId("__LIBRARY__${parentMediaId}__DISCOVERY")
|
||||||
|
.setIconUri(getUriToDrawable(ctx, R.drawable.md_telescope))
|
||||||
|
.build(),
|
||||||
|
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
}
|
}
|
||||||
|
} else if (parentMediaId.startsWith(RECENTLY_ROOT)) {
|
||||||
|
Log.d(tag, "Browsing recently $parentMediaId")
|
||||||
|
val mediaIdParts = parentMediaId.split("__")
|
||||||
|
if (!mediaManager.getIsLibrary(mediaIdParts[2])) {
|
||||||
|
Log.d(tag, "${mediaIdParts[2]} is not library")
|
||||||
|
result.sendResult(null)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Log.d(tag, "Mediaparts: ${mediaIdParts.size} | $mediaIdParts")
|
||||||
|
if (mediaIdParts.size == 3) {
|
||||||
|
mediaManager.getLibraryRecentShelfs(mediaIdParts[2]) { availableShelfs ->
|
||||||
|
Log.d(tag, "Found ${availableShelfs.size} shelfs")
|
||||||
|
val children : MutableList<MediaBrowserCompat.MediaItem> = mutableListOf()
|
||||||
|
for (shelf in availableShelfs) {
|
||||||
|
if (shelf.type == "book") {
|
||||||
|
children.add(
|
||||||
|
MediaBrowserCompat.MediaItem(
|
||||||
|
MediaDescriptionCompat.Builder()
|
||||||
|
.setTitle("Books")
|
||||||
|
.setMediaId("${parentMediaId}__BOOK")
|
||||||
|
.setIconUri(getUriToDrawable(ctx, R.drawable.md_book_open_blank_variant_outline))
|
||||||
|
.build(),
|
||||||
|
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} else if (shelf.type == "series") {
|
||||||
|
children.add(
|
||||||
|
MediaBrowserCompat.MediaItem(
|
||||||
|
MediaDescriptionCompat.Builder()
|
||||||
|
.setTitle("Series")
|
||||||
|
.setMediaId("${parentMediaId}__SERIES")
|
||||||
|
.setIconUri(getUriToAbsIconDrawable(ctx, "columns"))
|
||||||
|
.build(),
|
||||||
|
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} else if (shelf.type == "episode") {
|
||||||
|
children.add(
|
||||||
|
MediaBrowserCompat.MediaItem(
|
||||||
|
MediaDescriptionCompat.Builder()
|
||||||
|
.setTitle("Episodes")
|
||||||
|
.setMediaId("${parentMediaId}__EPISODE")
|
||||||
|
.setIconUri(getUriToAbsIconDrawable(ctx, "microphone_2"))
|
||||||
|
.build(),
|
||||||
|
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} else if (shelf.type == "podcast") {
|
||||||
|
children.add(
|
||||||
|
MediaBrowserCompat.MediaItem(
|
||||||
|
MediaDescriptionCompat.Builder()
|
||||||
|
.setTitle("Podcast")
|
||||||
|
.setMediaId("${parentMediaId}__PODCAST")
|
||||||
|
.setIconUri(getUriToAbsIconDrawable(ctx, "podcast"))
|
||||||
|
.build(),
|
||||||
|
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} else if (shelf.type == "authors") {
|
||||||
|
children.add(
|
||||||
|
MediaBrowserCompat.MediaItem(
|
||||||
|
MediaDescriptionCompat.Builder()
|
||||||
|
.setTitle("Authors")
|
||||||
|
.setMediaId("${parentMediaId}__AUTHORS")
|
||||||
|
.setIconUri(getUriToAbsIconDrawable(ctx, "authors"))
|
||||||
|
.build(),
|
||||||
|
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
}
|
||||||
|
} else if (mediaIdParts.size == 4) {
|
||||||
|
mediaManager.getLibraryRecentShelfByType(mediaIdParts[2], mediaIdParts[3]) { shelf ->
|
||||||
|
if (shelf === null) {
|
||||||
|
result.sendResult(mutableListOf())
|
||||||
|
}else {
|
||||||
|
if (shelf.type == "book") {
|
||||||
|
val children = (shelf as LibraryShelfBookEntity).entities?.map { libraryItem ->
|
||||||
|
val progress = mediaManager.serverUserMediaProgress.find { it.libraryItemId == libraryItem.id }
|
||||||
|
val localLibraryItem = DeviceManager.dbManager.getLocalLibraryItemByLId(libraryItem.id)
|
||||||
|
libraryItem.localLibraryItemId = localLibraryItem?.id
|
||||||
|
val description = libraryItem.getMediaDescription(progress, ctx, null, false)
|
||||||
|
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE)
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
} else if (shelf.type == "episode") {
|
||||||
|
val episodesWithRecentEpisode = (shelf as LibraryShelfEpisodeEntity).entities?.filter { libraryItem -> libraryItem.recentEpisode !== null }
|
||||||
|
val children = episodesWithRecentEpisode?.map { libraryItem ->
|
||||||
|
val podcast = libraryItem.media as Podcast
|
||||||
|
val progress = mediaManager.serverUserMediaProgress.find { it.libraryItemId == libraryItem.libraryId && it.episodeId == libraryItem.recentEpisode?.id }
|
||||||
|
|
||||||
|
// to show download icon
|
||||||
|
val localLibraryItem = DeviceManager.dbManager.getLocalLibraryItemByLId(libraryItem.recentEpisode!!.id)
|
||||||
|
localLibraryItem?.let { lli ->
|
||||||
|
val localEpisode = (lli.media as Podcast).episodes?.find { it.serverEpisodeId == libraryItem.recentEpisode.id }
|
||||||
|
libraryItem.recentEpisode.localEpisodeId = localEpisode?.id
|
||||||
|
}
|
||||||
|
|
||||||
|
val description = libraryItem.recentEpisode.getMediaDescription(libraryItem, progress, ctx)
|
||||||
|
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE)
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
} else if (shelf.type == "podcast") {
|
||||||
|
val children = (shelf as LibraryShelfPodcastEntity).entities?.map { libraryItem ->
|
||||||
|
val mediaDescription = libraryItem.getMediaDescription(null, ctx)
|
||||||
|
MediaBrowserCompat.MediaItem(
|
||||||
|
mediaDescription,
|
||||||
|
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
||||||
|
)
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
} else if (shelf.type == "series") {
|
||||||
|
val children = (shelf as LibraryShelfSeriesEntity).entities?.map { librarySeriesItem ->
|
||||||
|
val description = librarySeriesItem.getMediaDescription(null, ctx)
|
||||||
|
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
} else if (shelf.type == "authors") {
|
||||||
|
val children = (shelf as LibraryShelfAuthorEntity).entities?.map { authorItem ->
|
||||||
|
val description = authorItem.getMediaDescription(null, ctx)
|
||||||
|
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
} else {
|
||||||
|
result.sendResult(mutableListOf())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (parentMediaId.startsWith("__LIBRARY__")) {
|
||||||
|
Log.d(tag, "Browsing library $parentMediaId")
|
||||||
|
val mediaIdParts = parentMediaId.split("__")
|
||||||
|
/*
|
||||||
|
MediaIdParts for Library
|
||||||
|
1: LIBRARY
|
||||||
|
2: mediaId for library
|
||||||
|
3: Browsing style (AUTHORS, AUTHOR, AUTHOR_SERIES, SERIES_LIST, SERIES, COLLECTION, COLLECTIONS, DISCOVERY)
|
||||||
|
4:
|
||||||
|
- Paging: SERIES_LIST, AUTHORS
|
||||||
|
- SeriesId: SERIES
|
||||||
|
- AuthorId: AUTHOR, AUTHOR_SERIES
|
||||||
|
- CollectionId: COLLECTIONS
|
||||||
|
5: SeriesId: AUTHOR_SERIES
|
||||||
|
*/
|
||||||
|
if (!mediaManager.getIsLibrary(mediaIdParts[2])) {
|
||||||
|
Log.d(tag, "${mediaIdParts[2]} is not library")
|
||||||
|
result.sendResult(null)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Log.d(tag, "$mediaIdParts")
|
||||||
|
if (mediaIdParts[3] == "SERIES_LIST" && mediaIdParts.size == 5) {
|
||||||
|
Log.d(tag, "Loading series from library ${mediaIdParts[2]} with paging ${mediaIdParts[4]}")
|
||||||
|
mediaManager.loadLibrarySeriesWithAudio(mediaIdParts[2], mediaIdParts[4]) { seriesItems ->
|
||||||
|
Log.d(tag, "Received ${seriesItems.size} series")
|
||||||
|
|
||||||
|
val seriesLetters = seriesItems.groupingBy { iwb -> iwb.title.substring(0, mediaIdParts[4].length + 1).uppercase() }.eachCount()
|
||||||
|
if (seriesItems.size > DeviceManager.deviceData.deviceSettings!!.androidAutoBrowseLimitForGrouping && seriesItems.size > 1 && seriesLetters.size > 1) {
|
||||||
|
val children = seriesLetters.map { (seriesLetter, seriesCount) ->
|
||||||
|
MediaBrowserCompat.MediaItem(
|
||||||
|
MediaDescriptionCompat.Builder()
|
||||||
|
.setTitle(seriesLetter)
|
||||||
|
.setMediaId("${parentMediaId}${seriesLetter.last()}")
|
||||||
|
.setSubtitle("$seriesCount series")
|
||||||
|
.build(),
|
||||||
|
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
||||||
|
)
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
} else {
|
||||||
|
val children = seriesItems.map { seriesItem ->
|
||||||
|
val description = seriesItem.getMediaDescription(null, ctx)
|
||||||
|
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (mediaIdParts[3] == "SERIES_LIST") {
|
||||||
|
Log.d(tag, "Loading series from library ${mediaIdParts[2]}")
|
||||||
|
mediaManager.loadLibrarySeriesWithAudio(mediaIdParts[2]) { seriesItems ->
|
||||||
|
Log.d(tag, "Received ${seriesItems.size} series")
|
||||||
|
if (seriesItems.size > DeviceManager.deviceData.deviceSettings!!.androidAutoBrowseLimitForGrouping && seriesItems.size > 1) {
|
||||||
|
val seriesLetters = seriesItems.groupingBy { iwb -> iwb.title.first().uppercaseChar() }.eachCount()
|
||||||
|
val children = seriesLetters.map { (seriesLetter, seriesCount) ->
|
||||||
|
MediaBrowserCompat.MediaItem(
|
||||||
|
MediaDescriptionCompat.Builder()
|
||||||
|
.setTitle(seriesLetter.toString())
|
||||||
|
.setSubtitle("$seriesCount series")
|
||||||
|
.setMediaId("${parentMediaId}__${seriesLetter}")
|
||||||
|
.build(),
|
||||||
|
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
||||||
|
)
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
} else {
|
||||||
|
val children = seriesItems.map { seriesItem ->
|
||||||
|
val description = seriesItem.getMediaDescription(null, ctx)
|
||||||
|
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (mediaIdParts[3] == "SERIES") {
|
||||||
|
Log.d(tag, "Loading items for serie ${mediaIdParts[4]} from library ${mediaIdParts[2]}")
|
||||||
|
mediaManager.loadLibrarySeriesItemsWithAudio(
|
||||||
|
mediaIdParts[2],
|
||||||
|
mediaIdParts[4]
|
||||||
|
) { libraryItems ->
|
||||||
|
Log.d(tag, "Received ${libraryItems.size} library items")
|
||||||
|
var items = libraryItems
|
||||||
|
if (DeviceManager.deviceData.deviceSettings!!.androidAutoBrowseSeriesSequenceOrder === AndroidAutoBrowseSeriesSequenceOrderSetting.DESC) {
|
||||||
|
items = libraryItems.reversed()
|
||||||
|
}
|
||||||
|
val children = items.map { libraryItem ->
|
||||||
|
val progress =
|
||||||
|
mediaManager.serverUserMediaProgress.find { it.libraryItemId == libraryItem.id }
|
||||||
|
val localLibraryItem = DeviceManager.dbManager.getLocalLibraryItemByLId(libraryItem.id)
|
||||||
|
libraryItem.localLibraryItemId = localLibraryItem?.id
|
||||||
|
val description = libraryItem.getMediaDescription(progress, ctx, null, true)
|
||||||
|
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE)
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
}
|
||||||
|
} else if (mediaIdParts[3] == "AUTHORS" && mediaIdParts.size == 5) {
|
||||||
|
Log.d(tag, "Loading authors from library ${mediaIdParts[2]} with paging ${mediaIdParts[4]}")
|
||||||
|
mediaManager.loadAuthorsWithBooks(mediaIdParts[2], mediaIdParts[4]) { authorItems ->
|
||||||
|
Log.d(tag, "Received ${authorItems.size} authors")
|
||||||
|
|
||||||
|
val authorLetters = authorItems.groupingBy { iwb -> iwb.name.substring(0, mediaIdParts[4].length + 1).uppercase() }.eachCount()
|
||||||
|
if (authorItems.size > DeviceManager.deviceData.deviceSettings!!.androidAutoBrowseLimitForGrouping && authorItems.size > 1 && authorLetters.size > 1) {
|
||||||
|
val children = authorLetters.map { (authorLetter, authorCount) ->
|
||||||
|
MediaBrowserCompat.MediaItem(
|
||||||
|
MediaDescriptionCompat.Builder()
|
||||||
|
.setTitle(authorLetter)
|
||||||
|
.setMediaId("${parentMediaId}${authorLetter.last()}")
|
||||||
|
.setSubtitle("$authorCount authors")
|
||||||
|
.build(),
|
||||||
|
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
||||||
|
)
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
} else {
|
||||||
|
val children = authorItems.map { authorItem ->
|
||||||
|
val description = authorItem.getMediaDescription(null, ctx)
|
||||||
|
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (mediaIdParts[3] == "AUTHORS") {
|
||||||
|
Log.d(tag, "Loading authors from library ${mediaIdParts[2]}")
|
||||||
|
mediaManager.loadAuthorsWithBooks(mediaIdParts[2]) { authorItems ->
|
||||||
|
Log.d(tag, "Received ${authorItems.size} authors")
|
||||||
|
if (authorItems.size > DeviceManager.deviceData.deviceSettings!!.androidAutoBrowseLimitForGrouping && authorItems.size > 1) {
|
||||||
|
val authorLetters = authorItems.groupingBy { iwb -> iwb.name.first().uppercaseChar() }.eachCount()
|
||||||
|
val children = authorLetters.map { (authorLetter, authorCount) ->
|
||||||
|
MediaBrowserCompat.MediaItem(
|
||||||
|
MediaDescriptionCompat.Builder()
|
||||||
|
.setTitle(authorLetter.toString())
|
||||||
|
.setSubtitle("$authorCount authors")
|
||||||
|
.setMediaId("${parentMediaId}__${authorLetter}")
|
||||||
|
.build(),
|
||||||
|
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
||||||
|
)
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
} else {
|
||||||
|
val children = authorItems.map { authorItem ->
|
||||||
|
val description = authorItem.getMediaDescription(null, ctx)
|
||||||
|
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (mediaIdParts[3] == "AUTHOR") {
|
||||||
|
mediaManager.loadAuthorBooksWithAudio(mediaIdParts[2], mediaIdParts[4]) { libraryItems ->
|
||||||
|
val children = libraryItems.map { libraryItem ->
|
||||||
|
val progress = mediaManager.serverUserMediaProgress.find { it.libraryItemId == libraryItem.id }
|
||||||
|
val localLibraryItem = DeviceManager.dbManager.getLocalLibraryItemByLId(libraryItem.id)
|
||||||
|
libraryItem.localLibraryItemId = localLibraryItem?.id
|
||||||
|
if (libraryItem.collapsedSeries != null) {
|
||||||
|
val description = libraryItem.getMediaDescription(progress, ctx, mediaIdParts[4])
|
||||||
|
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)
|
||||||
|
} else {
|
||||||
|
val description = libraryItem.getMediaDescription(progress, ctx)
|
||||||
|
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
}
|
||||||
|
} else if (mediaIdParts[3] == "AUTHOR_SERIES") {
|
||||||
|
mediaManager.loadAuthorSeriesBooksWithAudio(mediaIdParts[2], mediaIdParts[4], mediaIdParts[5]) { libraryItems ->
|
||||||
|
var items = libraryItems
|
||||||
|
if (DeviceManager.deviceData.deviceSettings!!.androidAutoBrowseSeriesSequenceOrder === AndroidAutoBrowseSeriesSequenceOrderSetting.DESC) {
|
||||||
|
items = libraryItems.reversed()
|
||||||
|
}
|
||||||
|
val children = items.map { libraryItem ->
|
||||||
|
val progress = mediaManager.serverUserMediaProgress.find { it.libraryItemId == libraryItem.id }
|
||||||
|
val localLibraryItem = DeviceManager.dbManager.getLocalLibraryItemByLId(libraryItem.id)
|
||||||
|
libraryItem.localLibraryItemId = localLibraryItem?.id
|
||||||
|
val description = libraryItem.getMediaDescription(progress, ctx, null, true)
|
||||||
|
if (libraryItem.collapsedSeries != null) {
|
||||||
|
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)
|
||||||
|
} else {
|
||||||
|
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
}
|
||||||
|
} else if (mediaIdParts[3] == "COLLECTIONS") {
|
||||||
|
Log.d(tag, "Loading collections from library ${mediaIdParts[2]}")
|
||||||
|
mediaManager.loadLibraryCollectionsWithAudio(mediaIdParts[2]) { collectionItems ->
|
||||||
|
Log.d(tag, "Received ${collectionItems.size} collections")
|
||||||
|
val children = collectionItems.map { collectionItem ->
|
||||||
|
val description = collectionItem.getMediaDescription(null, ctx)
|
||||||
|
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
}
|
||||||
|
} else if (mediaIdParts[3] == "COLLECTION") {
|
||||||
|
Log.d(tag, "Loading collection ${mediaIdParts[4]} books from library ${mediaIdParts[2]}")
|
||||||
|
mediaManager.loadLibraryCollectionBooksWithAudio(mediaIdParts[2], mediaIdParts[4]) { libraryItems ->
|
||||||
|
Log.d(tag, "Received ${libraryItems.size} collections")
|
||||||
|
val children = libraryItems.map { libraryItem ->
|
||||||
|
val progress = mediaManager.serverUserMediaProgress.find { it.libraryItemId == libraryItem.id }
|
||||||
|
val localLibraryItem = DeviceManager.dbManager.getLocalLibraryItemByLId(libraryItem.id)
|
||||||
|
libraryItem.localLibraryItemId = localLibraryItem?.id
|
||||||
|
val description = libraryItem.getMediaDescription(progress, ctx)
|
||||||
|
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE)
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
}
|
||||||
|
} else if (mediaIdParts[3] == "DISCOVERY") {
|
||||||
|
Log.d(tag, "Loading discovery from library ${mediaIdParts[2]}")
|
||||||
|
mediaManager.loadLibraryDiscoveryBooksWithAudio(mediaIdParts[2]) { libraryItems ->
|
||||||
|
Log.d(tag, "Received ${libraryItems.size} libraryItems for discovery")
|
||||||
|
val children = libraryItems.map { libraryItem ->
|
||||||
|
val progress = mediaManager.serverUserMediaProgress.find { it.libraryItemId == libraryItem.id }
|
||||||
|
val localLibraryItem = DeviceManager.dbManager.getLocalLibraryItemByLId(libraryItem.id)
|
||||||
|
libraryItem.localLibraryItemId = localLibraryItem?.id
|
||||||
|
val description = libraryItem.getMediaDescription(progress, ctx)
|
||||||
|
MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE)
|
||||||
|
}
|
||||||
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result.sendResult(null)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.d(tag, "Loading podcast episodes for podcast $parentMediaId")
|
||||||
|
mediaManager.loadPodcastEpisodeMediaBrowserItems(parentMediaId, ctx) {
|
||||||
|
result.sendResult(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSearch(query: String, extras: Bundle?, result: Result<MutableList<MediaBrowserCompat.MediaItem>>) {
|
override fun onSearch(query: String, extras: Bundle?, result: Result<MutableList<MediaBrowserCompat.MediaItem>>) {
|
||||||
result.detach()
|
result.detach()
|
||||||
mediaManager.loadAndroidAutoItems {
|
if (cachedSearch != query) {
|
||||||
browseTree = BrowseTree(this, mediaManager.serverItemsInProgress, mediaManager.serverLibraries)
|
Log.d(tag, "Search bundle: $extras")
|
||||||
val children = browseTree[LIBRARIES_ROOT]?.map { item ->
|
var foundBooks: MutableList<MediaBrowserCompat.MediaItem> = mutableListOf()
|
||||||
MediaBrowserCompat.MediaItem(item.description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)
|
var foundPodcasts: MutableList<MediaBrowserCompat.MediaItem> = mutableListOf()
|
||||||
|
var foundSeries: MutableList<MediaBrowserCompat.MediaItem> = mutableListOf()
|
||||||
|
var foundAuthors: MutableList<MediaBrowserCompat.MediaItem> = mutableListOf()
|
||||||
|
|
||||||
|
mediaManager.serverLibraries.forEach { serverLibrary ->
|
||||||
|
runBlocking {
|
||||||
|
// Skip searching library if it doesn't have any audio files
|
||||||
|
if (serverLibrary.stats?.numAudioFiles == 0) return@runBlocking
|
||||||
|
val searchResult = mediaManager.doSearch(serverLibrary.id, query)
|
||||||
|
for (resultData in searchResult.entries.iterator()) {
|
||||||
|
when (resultData.key) {
|
||||||
|
"book" -> foundBooks.addAll(resultData.value)
|
||||||
|
"series" -> foundSeries.addAll(resultData.value)
|
||||||
|
"authors" -> foundAuthors.addAll(resultData.value)
|
||||||
|
"podcast" -> foundPodcasts.addAll(resultData.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
foundBooks.addAll(foundSeries)
|
||||||
|
foundBooks.addAll(foundAuthors)
|
||||||
|
cachedSearchResults = foundBooks
|
||||||
}
|
}
|
||||||
|
result.sendResult(cachedSearchResults)
|
||||||
|
cachedSearch = query
|
||||||
|
Log.d(tag, "onSearch: Done")
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -1139,6 +1670,14 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
hasNetworkConnectivity = networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED) && networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
hasNetworkConnectivity = networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED) && networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
||||||
Log.i(tag, "Network capabilities changed. hasNetworkConnectivity=$hasNetworkConnectivity | isUnmeteredNetwork=$isUnmeteredNetwork")
|
Log.i(tag, "Network capabilities changed. hasNetworkConnectivity=$hasNetworkConnectivity | isUnmeteredNetwork=$isUnmeteredNetwork")
|
||||||
clientEventEmitter?.onNetworkMeteredChanged(isUnmeteredNetwork)
|
clientEventEmitter?.onNetworkMeteredChanged(isUnmeteredNetwork)
|
||||||
|
if (hasNetworkConnectivity) {
|
||||||
|
// Force android auto loading if libraries are empty.
|
||||||
|
// Lack of network connectivity is most likely reason for libraries being empty
|
||||||
|
if (isBrowseTreeInitialized() && firstLoadDone && mediaManager.serverLibraries.isEmpty()) {
|
||||||
|
forceReloadingAndroidAuto = true
|
||||||
|
notifyChildrenChanged("/")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -198,10 +198,13 @@ class AbsAudioPlayer : Plugin() {
|
|||||||
return call.resolve(JSObject("{\"error\":\"Podcast episode not found\"}"))
|
return call.resolve(JSObject("{\"error\":\"Podcast episode not found\"}"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!it.hasTracks(episode)) {
|
||||||
|
return call.resolve(JSObject("{\"error\":\"No audio files found on device. Download book again to fix.\"}"))
|
||||||
|
}
|
||||||
|
|
||||||
Handler(Looper.getMainLooper()).post {
|
Handler(Looper.getMainLooper()).post {
|
||||||
Log.d(tag, "prepareLibraryItem: Preparing Local Media item ${jacksonMapper.writeValueAsString(it)}")
|
Log.d(tag, "prepareLibraryItem: Preparing Local Media item ${jacksonMapper.writeValueAsString(it)}")
|
||||||
val playbackSession = it.getPlaybackSession(episode)
|
val playbackSession = it.getPlaybackSession(episode, playerNotificationService.getDeviceInfo())
|
||||||
if (startTimeOverride != null) {
|
if (startTimeOverride != null) {
|
||||||
Log.d(tag, "prepareLibraryItem: Using start time override $startTimeOverride")
|
Log.d(tag, "prepareLibraryItem: Using start time override $startTimeOverride")
|
||||||
playbackSession.currentTime = startTimeOverride
|
playbackSession.currentTime = startTimeOverride
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.audiobookshelf.app.plugins
|
package com.audiobookshelf.app.plugins
|
||||||
|
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.audiobookshelf.app.MainActivity
|
import com.audiobookshelf.app.MainActivity
|
||||||
import com.audiobookshelf.app.data.*
|
import com.audiobookshelf.app.data.*
|
||||||
@@ -231,9 +233,15 @@ class AbsDatabase : Plugin() {
|
|||||||
if (!success) {
|
if (!success) {
|
||||||
call.resolve(JSObject("{\"error\":\"$errorMsg\"}"))
|
call.resolve(JSObject("{\"error\":\"$errorMsg\"}"))
|
||||||
} else {
|
} else {
|
||||||
|
// Remove all local sessions
|
||||||
|
savedSessions.forEach {
|
||||||
|
DeviceManager.dbManager.removePlaybackSession(it.id)
|
||||||
|
}
|
||||||
call.resolve()
|
call.resolve()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
call.resolve()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -487,9 +495,16 @@ class AbsDatabase : Plugin() {
|
|||||||
fun updateDeviceSettings(call:PluginCall) { // Returns device data
|
fun updateDeviceSettings(call:PluginCall) { // Returns device data
|
||||||
Log.d(tag, "updateDeviceSettings ${call.data}")
|
Log.d(tag, "updateDeviceSettings ${call.data}")
|
||||||
val newDeviceSettings = jacksonMapper.readValue<DeviceSettings>(call.data.toString())
|
val newDeviceSettings = jacksonMapper.readValue<DeviceSettings>(call.data.toString())
|
||||||
GlobalScope.launch(Dispatchers.IO) {
|
|
||||||
|
Handler(Looper.getMainLooper()).post {
|
||||||
DeviceManager.deviceData.deviceSettings = newDeviceSettings
|
DeviceManager.deviceData.deviceSettings = newDeviceSettings
|
||||||
DeviceManager.dbManager.saveDeviceData(DeviceManager.deviceData)
|
DeviceManager.dbManager.saveDeviceData(DeviceManager.deviceData)
|
||||||
|
|
||||||
|
// Updates playback actions for media notification (handles media control seek locking setting)
|
||||||
|
if (mainActivity.isPlayerNotificationServiceInitialized()) {
|
||||||
|
mainActivity.foregroundService.setMediaSessionConnectorPlaybackActions()
|
||||||
|
}
|
||||||
|
|
||||||
call.resolve(JSObject(jacksonMapper.writeValueAsString(DeviceManager.deviceData)))
|
call.resolve(JSObject(jacksonMapper.writeValueAsString(DeviceManager.deviceData)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class AbsDownloader : Plugin() {
|
|||||||
val libraryItemId = call.data.getString("libraryItemId").toString()
|
val libraryItemId = call.data.getString("libraryItemId").toString()
|
||||||
var episodeId = call.data.getString("episodeId").toString()
|
var episodeId = call.data.getString("episodeId").toString()
|
||||||
if (episodeId == "null") episodeId = ""
|
if (episodeId == "null") episodeId = ""
|
||||||
val localFolderId = call.data.getString("localFolderId").toString()
|
var localFolderId = call.data.getString("localFolderId", "").toString()
|
||||||
Log.d(tag, "Download library item $libraryItemId to folder $localFolderId / episode: $episodeId")
|
Log.d(tag, "Download library item $libraryItemId to folder $localFolderId / episode: $episodeId")
|
||||||
|
|
||||||
val downloadId = if (episodeId.isEmpty()) libraryItemId else "$libraryItemId-$episodeId"
|
val downloadId = if (episodeId.isEmpty()) libraryItemId else "$libraryItemId-$episodeId"
|
||||||
@@ -72,9 +72,18 @@ class AbsDownloader : Plugin() {
|
|||||||
} else {
|
} else {
|
||||||
Log.d(tag, "Got library item from server ${libraryItem.id}")
|
Log.d(tag, "Got library item from server ${libraryItem.id}")
|
||||||
|
|
||||||
val localFolder = DeviceManager.dbManager.getLocalFolder(localFolderId)
|
if (localFolderId == "") {
|
||||||
if (localFolder != null) {
|
localFolderId = "internal-${libraryItem.mediaType}"
|
||||||
|
}
|
||||||
|
var localFolder = DeviceManager.dbManager.getLocalFolder(localFolderId)
|
||||||
|
|
||||||
|
if (localFolder == null && localFolderId.startsWith("internal-")) {
|
||||||
|
Log.d(tag, "Creating new App Storage internal LocalFolder $localFolderId")
|
||||||
|
localFolder = LocalFolder(localFolderId, "Internal App Storage", "", "", "", "", "internal", libraryItem.mediaType)
|
||||||
|
DeviceManager.dbManager.saveLocalFolder(localFolder)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (localFolder != null) {
|
||||||
if (episodeId.isNotEmpty() && libraryItem.mediaType != "podcast") {
|
if (episodeId.isNotEmpty() && libraryItem.mediaType != "podcast") {
|
||||||
Log.e(tag, "Library item is not a podcast but episode was requested")
|
Log.e(tag, "Library item is not a podcast but episode was requested")
|
||||||
call.resolve(JSObject("{\"error\":\"Invalid library item not a podcast\"}"))
|
call.resolve(JSObject("{\"error\":\"Invalid library item not a podcast\"}"))
|
||||||
@@ -100,12 +109,6 @@ class AbsDownloader : Plugin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean folder path so it can be used in URL
|
|
||||||
private fun cleanRelPath(relPath: String): String {
|
|
||||||
val cleanedRelPath = relPath.replace("\\", "/").replace("%", "%25").replace("#", "%23")
|
|
||||||
return if (cleanedRelPath.startsWith("/")) cleanedRelPath.substring(1) else cleanedRelPath
|
|
||||||
}
|
|
||||||
|
|
||||||
// Item filenames could be the same if they are in sub-folders, this will make them unique
|
// Item filenames could be the same if they are in sub-folders, this will make them unique
|
||||||
private fun getFilenameFromRelPath(relPath: String): String {
|
private fun getFilenameFromRelPath(relPath: String): String {
|
||||||
var cleanedRelPath = relPath.replace("\\", "_").replace("/", "_")
|
var cleanedRelPath = relPath.replace("\\", "_").replace("/", "_")
|
||||||
@@ -127,7 +130,9 @@ class AbsDownloader : Plugin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun startLibraryItemDownload(libraryItem: LibraryItem, localFolder: LocalFolder, episode:PodcastEpisode?) {
|
private fun startLibraryItemDownload(libraryItem: LibraryItem, localFolder: LocalFolder, episode:PodcastEpisode?) {
|
||||||
val tempFolderPath = mainActivity.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)
|
val isInternal = localFolder.id.startsWith("internal-")
|
||||||
|
|
||||||
|
val tempFolderPath = if (isInternal) "${mainActivity.filesDir}/downloads/${libraryItem.id}" else mainActivity.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)
|
||||||
|
|
||||||
Log.d(tag, "downloadCacheDirectory=$tempFolderPath")
|
Log.d(tag, "downloadCacheDirectory=$tempFolderPath")
|
||||||
|
|
||||||
@@ -138,13 +143,13 @@ class AbsDownloader : Plugin() {
|
|||||||
val tracks = libraryItem.media.getAudioTracks()
|
val tracks = libraryItem.media.getAudioTracks()
|
||||||
Log.d(tag, "Starting library item download with ${tracks.size} tracks")
|
Log.d(tag, "Starting library item download with ${tracks.size} tracks")
|
||||||
val itemSubfolder = "$bookAuthor/$bookTitle"
|
val itemSubfolder = "$bookAuthor/$bookTitle"
|
||||||
val itemFolderPath = "${localFolder.absolutePath}/$itemSubfolder"
|
val itemFolderPath = if (isInternal) "$tempFolderPath" else "${localFolder.absolutePath}/$itemSubfolder"
|
||||||
val downloadItem = DownloadItem(libraryItem.id, libraryItem.id, null, libraryItem.userMediaProgress,DeviceManager.serverConnectionConfig?.id ?: "", DeviceManager.serverAddress, DeviceManager.serverUserId, libraryItem.mediaType, itemFolderPath, localFolder, bookTitle, itemSubfolder, libraryItem.media, mutableListOf())
|
val downloadItem = DownloadItem(libraryItem.id, libraryItem.id, null, libraryItem.userMediaProgress,DeviceManager.serverConnectionConfig?.id ?: "", DeviceManager.serverAddress, DeviceManager.serverUserId, libraryItem.mediaType, itemFolderPath, localFolder, bookTitle, itemSubfolder, libraryItem.media, mutableListOf())
|
||||||
|
|
||||||
val book = libraryItem.media as Book
|
val book = libraryItem.media as Book
|
||||||
book.ebookFile?.let { ebookFile ->
|
book.ebookFile?.let { ebookFile ->
|
||||||
val fileSize = ebookFile.metadata?.size ?: 0
|
val fileSize = ebookFile.metadata?.size ?: 0
|
||||||
val serverPath = "/s/item/${libraryItem.id}/${cleanRelPath(ebookFile.metadata?.relPath ?: "")}"
|
val serverPath = "/api/items/${libraryItem.id}/file/${ebookFile.ino}/download"
|
||||||
val destinationFilename = getFilenameFromRelPath(ebookFile.metadata?.relPath ?: "")
|
val destinationFilename = getFilenameFromRelPath(ebookFile.metadata?.relPath ?: "")
|
||||||
val finalDestinationFile = File("$itemFolderPath/$destinationFilename")
|
val finalDestinationFile = File("$itemFolderPath/$destinationFilename")
|
||||||
val destinationFile = File("$tempFolderPath/$destinationFilename")
|
val destinationFile = File("$tempFolderPath/$destinationFilename")
|
||||||
@@ -164,9 +169,14 @@ class AbsDownloader : Plugin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create download item part for each audio track
|
// Create download item part for each audio track
|
||||||
|
val audioFiles = (libraryItem.media as Book).audioFiles ?: mutableListOf()
|
||||||
tracks.forEach { audioTrack ->
|
tracks.forEach { audioTrack ->
|
||||||
val fileSize = audioTrack.metadata?.size ?: 0
|
val fileSize = audioTrack.metadata?.size ?: 0
|
||||||
val serverPath = "/s/item/${libraryItem.id}/${cleanRelPath(audioTrack.relPath)}"
|
|
||||||
|
// TODO: Currently file ino is only stored on AudioFile. This should be updated server side to be in FileMetadata or on the AudioTrack
|
||||||
|
val audioFileIno = audioFiles.find { it.metadata.path == audioTrack.metadata?.path }?.ino
|
||||||
|
|
||||||
|
val serverPath = "/api/items/${libraryItem.id}/file/${audioFileIno}/download"
|
||||||
val destinationFilename = getFilenameFromRelPath(audioTrack.relPath)
|
val destinationFilename = getFilenameFromRelPath(audioTrack.relPath)
|
||||||
Log.d(tag, "Audio File Server Path $serverPath | AF RelPath ${audioTrack.relPath} | LocalFolder Path ${localFolder.absolutePath} | DestName $destinationFilename")
|
Log.d(tag, "Audio File Server Path $serverPath | AF RelPath ${audioTrack.relPath} | LocalFolder Path ${localFolder.absolutePath} | DestName $destinationFilename")
|
||||||
|
|
||||||
@@ -219,14 +229,15 @@ class AbsDownloader : Plugin() {
|
|||||||
val podcastTitle = cleanStringForFileSystem(libraryItem.media.metadata.title)
|
val podcastTitle = cleanStringForFileSystem(libraryItem.media.metadata.title)
|
||||||
|
|
||||||
val audioTrack = episode?.audioTrack
|
val audioTrack = episode?.audioTrack
|
||||||
|
val audioFileIno = episode?.audioFile?.ino
|
||||||
val fileSize = audioTrack?.metadata?.size ?: 0
|
val fileSize = audioTrack?.metadata?.size ?: 0
|
||||||
|
|
||||||
Log.d(tag, "Starting podcast episode download")
|
Log.d(tag, "Starting podcast episode download")
|
||||||
val itemFolderPath = localFolder.absolutePath + "/" + podcastTitle
|
val itemFolderPath = if (isInternal) "$tempFolderPath" else "${localFolder.absolutePath}/$podcastTitle"
|
||||||
val downloadItemId = "${libraryItem.id}-${episode?.id}"
|
val downloadItemId = "${libraryItem.id}-${episode?.id}"
|
||||||
val downloadItem = DownloadItem(downloadItemId, libraryItem.id, episode?.id, libraryItem.userMediaProgress, DeviceManager.serverConnectionConfig?.id ?: "", DeviceManager.serverAddress, DeviceManager.serverUserId, libraryItem.mediaType, itemFolderPath, localFolder, podcastTitle, podcastTitle, libraryItem.media, mutableListOf())
|
val downloadItem = DownloadItem(downloadItemId, libraryItem.id, episode?.id, libraryItem.userMediaProgress, DeviceManager.serverConnectionConfig?.id ?: "", DeviceManager.serverAddress, DeviceManager.serverUserId, libraryItem.mediaType, itemFolderPath, localFolder, podcastTitle, podcastTitle, libraryItem.media, mutableListOf())
|
||||||
|
|
||||||
var serverPath = "/s/item/${libraryItem.id}/${cleanRelPath(audioTrack?.relPath ?: "")}"
|
var serverPath = "/api/items/${libraryItem.id}/file/${audioFileIno}/download"
|
||||||
var destinationFilename = getFilenameFromRelPath(audioTrack?.relPath ?: "")
|
var destinationFilename = getFilenameFromRelPath(audioTrack?.relPath ?: "")
|
||||||
Log.d(tag, "Audio File Server Path $serverPath | AF RelPath ${audioTrack?.relPath} | LocalFolder Path ${localFolder.absolutePath} | DestName $destinationFilename")
|
Log.d(tag, "Audio File Server Path $serverPath | AF RelPath ${audioTrack?.relPath} | LocalFolder Path ${localFolder.absolutePath} | DestName $destinationFilename")
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.audiobookshelf.app.plugins
|
package com.audiobookshelf.app.plugins
|
||||||
|
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.database.Cursor
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
@@ -13,16 +12,11 @@ import com.anggrayudi.storage.callback.StorageAccessCallback
|
|||||||
import com.anggrayudi.storage.file.*
|
import com.anggrayudi.storage.file.*
|
||||||
import com.audiobookshelf.app.MainActivity
|
import com.audiobookshelf.app.MainActivity
|
||||||
import com.audiobookshelf.app.data.LocalFolder
|
import com.audiobookshelf.app.data.LocalFolder
|
||||||
import com.audiobookshelf.app.data.LocalLibraryItem
|
|
||||||
import com.audiobookshelf.app.device.DeviceManager
|
import com.audiobookshelf.app.device.DeviceManager
|
||||||
import com.audiobookshelf.app.device.FolderScanner
|
|
||||||
import com.fasterxml.jackson.core.json.JsonReadFeature
|
import com.fasterxml.jackson.core.json.JsonReadFeature
|
||||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||||
import com.getcapacitor.*
|
import com.getcapacitor.*
|
||||||
import com.getcapacitor.annotation.CapacitorPlugin
|
import com.getcapacitor.annotation.CapacitorPlugin
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.GlobalScope
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@CapacitorPlugin(name = "AbsFileSystem")
|
@CapacitorPlugin(name = "AbsFileSystem")
|
||||||
@@ -166,23 +160,10 @@ class AbsFileSystem : Plugin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PluginMethod
|
@PluginMethod
|
||||||
fun scanFolder(call: PluginCall) {
|
fun getSDKVersion(call: PluginCall) {
|
||||||
val folderId = call.data.getString("folderId", "").toString()
|
val jsObject = JSObject()
|
||||||
val forceAudioProbe = call.data.getBoolean("forceAudioProbe")
|
jsObject.put("version", Build.VERSION.SDK_INT)
|
||||||
Log.d(TAG, "Scan Folder $folderId | Force Audio Probe $forceAudioProbe")
|
call.resolve(jsObject)
|
||||||
|
|
||||||
val folder: LocalFolder? = DeviceManager.dbManager.getLocalFolder(folderId)
|
|
||||||
folder?.let {
|
|
||||||
val folderScanner = FolderScanner(context)
|
|
||||||
val folderScanResult = folderScanner.scanForMediaItems(it, forceAudioProbe)
|
|
||||||
if (folderScanResult == null) {
|
|
||||||
Log.d(TAG, "NO Scan DATA")
|
|
||||||
return call.resolve(JSObject())
|
|
||||||
} else {
|
|
||||||
Log.d(TAG, "Scan DATA ${jacksonMapper.writeValueAsString(folderScanResult)}")
|
|
||||||
return call.resolve(JSObject(jacksonMapper.writeValueAsString(folderScanResult)))
|
|
||||||
}
|
|
||||||
} ?: call.resolve(JSObject())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PluginMethod
|
@PluginMethod
|
||||||
@@ -199,27 +180,6 @@ class AbsFileSystem : Plugin() {
|
|||||||
call.resolve()
|
call.resolve()
|
||||||
}
|
}
|
||||||
|
|
||||||
@PluginMethod
|
|
||||||
fun scanLocalLibraryItem(call: PluginCall) {
|
|
||||||
val localLibraryItemId = call.data.getString("localLibraryItemId", "").toString()
|
|
||||||
val forceAudioProbe = call.data.getBoolean("forceAudioProbe")
|
|
||||||
Log.d(TAG, "Scan Local library item $localLibraryItemId | Force Audio Probe $forceAudioProbe")
|
|
||||||
GlobalScope.launch(Dispatchers.IO) {
|
|
||||||
val localLibraryItem: LocalLibraryItem? = DeviceManager.dbManager.getLocalLibraryItem(localLibraryItemId)
|
|
||||||
localLibraryItem?.let {
|
|
||||||
val folderScanner = FolderScanner(context)
|
|
||||||
val scanResult = folderScanner.scanLocalLibraryItem(it, forceAudioProbe)
|
|
||||||
if (scanResult == null) {
|
|
||||||
Log.d(TAG, "NO Scan DATA")
|
|
||||||
call.resolve(JSObject())
|
|
||||||
} else {
|
|
||||||
Log.d(TAG, "Scan DATA ${jacksonMapper.writeValueAsString(scanResult)}")
|
|
||||||
call.resolve(JSObject(jacksonMapper.writeValueAsString(scanResult)))
|
|
||||||
}
|
|
||||||
} ?: call.resolve(JSObject())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@PluginMethod
|
@PluginMethod
|
||||||
fun deleteItem(call: PluginCall) {
|
fun deleteItem(call: PluginCall) {
|
||||||
val localLibraryItemId = call.data.getString("id", "").toString()
|
val localLibraryItemId = call.data.getString("id", "").toString()
|
||||||
@@ -227,35 +187,53 @@ class AbsFileSystem : Plugin() {
|
|||||||
val contentUrl = call.data.getString("contentUrl", "").toString()
|
val contentUrl = call.data.getString("contentUrl", "").toString()
|
||||||
Log.d(tag, "deleteItem $absolutePath | $contentUrl")
|
Log.d(tag, "deleteItem $absolutePath | $contentUrl")
|
||||||
|
|
||||||
var subfolderPathToDelete = ""
|
|
||||||
|
|
||||||
// Check if should delete subfolder
|
// Check if should delete subfolder
|
||||||
val localLibraryItem = DeviceManager.dbManager.getLocalLibraryItem(localLibraryItemId)
|
val localLibraryItem = DeviceManager.dbManager.getLocalLibraryItem(localLibraryItemId)
|
||||||
localLibraryItem?.folderId?.let { folderId ->
|
|
||||||
val folder = DeviceManager.dbManager.getLocalFolder(folderId)
|
val success: Boolean
|
||||||
folder?.absolutePath?.let { folderPath ->
|
|
||||||
val splitAbsolutePath = absolutePath.split("/")
|
// If internal library item use File to delete
|
||||||
val fullSubDir = splitAbsolutePath.subList(0, splitAbsolutePath.size - 1).joinToString("/")
|
if (localLibraryItem?.folderId?.startsWith("internal-") == true) {
|
||||||
if (fullSubDir != folderPath) {
|
Log.d(tag, "Deleting internal library item at absolutePath $absolutePath")
|
||||||
val subdirHasAnItem = DeviceManager.dbManager.getLocalLibraryItems().any { _localLibraryItem ->
|
val file = File(absolutePath)
|
||||||
if (_localLibraryItem.id == localLibraryItemId) {
|
success = if (file.exists()) {
|
||||||
false
|
file.deleteRecursively()
|
||||||
} else {
|
} else {
|
||||||
_localLibraryItem.absolutePath.startsWith(fullSubDir)
|
true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var subfolderPathToDelete = ""
|
||||||
|
localLibraryItem?.folderId?.let { folderId ->
|
||||||
|
val folder = DeviceManager.dbManager.getLocalFolder(folderId)
|
||||||
|
folder?.absolutePath?.let { folderPath ->
|
||||||
|
val splitAbsolutePath = absolutePath.split("/")
|
||||||
|
val fullSubDir = splitAbsolutePath.subList(0, splitAbsolutePath.size - 1).joinToString("/")
|
||||||
|
if (fullSubDir != folderPath) {
|
||||||
|
val subdirHasAnItem = DeviceManager.dbManager.getLocalLibraryItems().any { _localLibraryItem ->
|
||||||
|
if (_localLibraryItem.id == localLibraryItemId) {
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
_localLibraryItem.absolutePath.startsWith(fullSubDir)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
subfolderPathToDelete = if (subdirHasAnItem) "" else fullSubDir
|
||||||
}
|
}
|
||||||
subfolderPathToDelete = if (subdirHasAnItem) "" else fullSubDir
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val docfile = DocumentFileCompat.fromUri(mainActivity, Uri.parse(contentUrl))
|
val docfile = DocumentFileCompat.fromUri(mainActivity, Uri.parse(contentUrl))
|
||||||
val success = docfile?.delete() == true
|
if (docfile?.exists() == true) {
|
||||||
|
success = docfile.delete() == true
|
||||||
|
} else {
|
||||||
|
Log.d(tag, "Folder $contentUrl doesn't exist")
|
||||||
|
success = true
|
||||||
|
}
|
||||||
|
|
||||||
if (subfolderPathToDelete != "") {
|
if (subfolderPathToDelete != "") {
|
||||||
Log.d(tag, "Deleting empty subfolder at $subfolderPathToDelete")
|
Log.d(tag, "Deleting empty subfolder at $subfolderPathToDelete")
|
||||||
val docfilesub = DocumentFileCompat.fromFullPath(mainActivity, subfolderPathToDelete)
|
val docfilesub = DocumentFileCompat.fromFullPath(mainActivity, subfolderPathToDelete)
|
||||||
docfilesub?.delete()
|
docfilesub?.delete()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
package com.audiobookshelf.app.server
|
package com.audiobookshelf.app.server
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.Build
|
||||||
|
import android.provider.Settings
|
||||||
|
import android.util.Base64
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.audiobookshelf.app.data.*
|
import com.audiobookshelf.app.data.*
|
||||||
import com.audiobookshelf.app.device.DeviceManager
|
import com.audiobookshelf.app.device.DeviceManager
|
||||||
@@ -8,6 +12,7 @@ import com.audiobookshelf.app.media.MediaEventManager
|
|||||||
import com.audiobookshelf.app.media.MediaProgressSyncData
|
import com.audiobookshelf.app.media.MediaProgressSyncData
|
||||||
import com.audiobookshelf.app.media.SyncResult
|
import com.audiobookshelf.app.media.SyncResult
|
||||||
import com.audiobookshelf.app.models.User
|
import com.audiobookshelf.app.models.User
|
||||||
|
import com.audiobookshelf.app.BuildConfig
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
import com.fasterxml.jackson.core.json.JsonReadFeature
|
import com.fasterxml.jackson.core.json.JsonReadFeature
|
||||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||||
@@ -17,6 +22,7 @@ import com.getcapacitor.JSObject
|
|||||||
import okhttp3.*
|
import okhttp3.*
|
||||||
import okhttp3.MediaType.Companion.toMediaType
|
import okhttp3.MediaType.Companion.toMediaType
|
||||||
import okhttp3.RequestBody.Companion.toRequestBody
|
import okhttp3.RequestBody.Companion.toRequestBody
|
||||||
|
import okhttp3.internal.EMPTY_REQUEST
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
@@ -30,7 +36,7 @@ class ApiHandler(var ctx:Context) {
|
|||||||
private var pingClient = OkHttpClient.Builder().callTimeout(3, TimeUnit.SECONDS).build()
|
private var pingClient = OkHttpClient.Builder().callTimeout(3, TimeUnit.SECONDS).build()
|
||||||
private var jacksonMapper = jacksonObjectMapper().enable(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature())
|
private var jacksonMapper = jacksonObjectMapper().enable(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature())
|
||||||
|
|
||||||
data class LocalSessionsSyncRequestPayload(val sessions:List<PlaybackSession>)
|
data class LocalSessionsSyncRequestPayload(val sessions:List<PlaybackSession>, val deviceInfo:DeviceInfo)
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
data class LocalSessionSyncResult(val id:String, val success:Boolean, val progressSynced:Boolean?, val error:String?)
|
data class LocalSessionSyncResult(val id:String, val success:Boolean, val progressSynced:Boolean?, val error:String?)
|
||||||
data class LocalSessionsSyncResponsePayload(val results:List<LocalSessionSyncResult>)
|
data class LocalSessionsSyncResponsePayload(val results:List<LocalSessionSyncResult>)
|
||||||
@@ -39,36 +45,58 @@ class ApiHandler(var ctx:Context) {
|
|||||||
val address = config?.address ?: DeviceManager.serverAddress
|
val address = config?.address ?: DeviceManager.serverAddress
|
||||||
val token = config?.token ?: DeviceManager.token
|
val token = config?.token ?: DeviceManager.token
|
||||||
|
|
||||||
val request = Request.Builder()
|
try {
|
||||||
.url("${address}$endpoint").addHeader("Authorization", "Bearer $token")
|
val request = Request.Builder()
|
||||||
.build()
|
.url("${address}$endpoint").addHeader("Authorization", "Bearer $token")
|
||||||
makeRequest(request, httpClient, cb)
|
.build()
|
||||||
|
makeRequest(request, httpClient, cb)
|
||||||
|
} catch(e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
val jsobj = JSObject()
|
||||||
|
jsobj.put("error", "Request failed: ${e.message}")
|
||||||
|
cb(jsobj)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun postRequest(endpoint:String, payload: JSObject, config:ServerConnectionConfig?, cb: (JSObject) -> Unit) {
|
private fun postRequest(endpoint:String, payload: JSObject?, config:ServerConnectionConfig?, cb: (JSObject) -> Unit) {
|
||||||
val address = config?.address ?: DeviceManager.serverAddress
|
val address = config?.address ?: DeviceManager.serverAddress
|
||||||
val token = config?.token ?: DeviceManager.token
|
val token = config?.token ?: DeviceManager.token
|
||||||
val mediaType = "application/json; charset=utf-8".toMediaType()
|
val mediaType = "application/json; charset=utf-8".toMediaType()
|
||||||
val requestBody = payload.toString().toRequestBody(mediaType)
|
val requestBody = payload?.toString()?.toRequestBody(mediaType) ?: EMPTY_REQUEST
|
||||||
val requestUrl = "${address}$endpoint"
|
val requestUrl = "${address}$endpoint"
|
||||||
Log.d(tag, "postRequest to $requestUrl")
|
Log.d(tag, "postRequest to $requestUrl")
|
||||||
val request = Request.Builder().post(requestBody)
|
try {
|
||||||
.url(requestUrl).addHeader("Authorization", "Bearer ${token}")
|
val request = Request.Builder().post(requestBody)
|
||||||
.build()
|
.url(requestUrl).addHeader("Authorization", "Bearer ${token}")
|
||||||
makeRequest(request, null, cb)
|
.build()
|
||||||
|
makeRequest(request, null, cb)
|
||||||
|
} catch(e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
val jsobj = JSObject()
|
||||||
|
jsobj.put("error", "Request failed: ${e.message}")
|
||||||
|
cb(jsobj)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun patchRequest(endpoint:String, payload: JSObject, cb: (JSObject) -> Unit) {
|
private fun patchRequest(endpoint:String, payload: JSObject, cb: (JSObject) -> Unit) {
|
||||||
val mediaType = "application/json; charset=utf-8".toMediaType()
|
val mediaType = "application/json; charset=utf-8".toMediaType()
|
||||||
val requestBody = payload.toString().toRequestBody(mediaType)
|
val requestBody = payload.toString().toRequestBody(mediaType)
|
||||||
val request = Request.Builder().patch(requestBody)
|
try {
|
||||||
.url("${DeviceManager.serverAddress}$endpoint").addHeader("Authorization", "Bearer ${DeviceManager.token}")
|
val request = Request.Builder().patch(requestBody)
|
||||||
.build()
|
.url("${DeviceManager.serverAddress}$endpoint").addHeader("Authorization", "Bearer ${DeviceManager.token}")
|
||||||
makeRequest(request, null, cb)
|
.build()
|
||||||
|
makeRequest(request, null, cb)
|
||||||
|
} catch(e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
val jsobj = JSObject()
|
||||||
|
jsobj.put("error", "Request failed: ${e.message}")
|
||||||
|
cb(jsobj)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun makeRequest(request:Request, httpClient:OkHttpClient?, cb: (JSObject) -> Unit) {
|
private fun makeRequest(request:Request, httpClient:OkHttpClient?, cb: (JSObject) -> Unit) {
|
||||||
val client = httpClient ?: defaultClient
|
val client = httpClient ?: defaultClient
|
||||||
|
|
||||||
client.newCall(request).enqueue(object : Callback {
|
client.newCall(request).enqueue(object : Callback {
|
||||||
override fun onFailure(call: Call, e: IOException) {
|
override fun onFailure(call: Call, e: IOException) {
|
||||||
Log.d(tag, "FAILURE TO CONNECT")
|
Log.d(tag, "FAILURE TO CONNECT")
|
||||||
@@ -127,7 +155,7 @@ class ApiHandler(var ctx:Context) {
|
|||||||
|
|
||||||
fun getLibraries(cb: (List<Library>) -> Unit) {
|
fun getLibraries(cb: (List<Library>) -> Unit) {
|
||||||
val mapper = jacksonMapper
|
val mapper = jacksonMapper
|
||||||
getRequest("/api/libraries", null,null) {
|
getRequest("/api/libraries?include=stats", null,null) {
|
||||||
val libraries = mutableListOf<Library>()
|
val libraries = mutableListOf<Library>()
|
||||||
|
|
||||||
var array = JSONArray()
|
var array = JSONArray()
|
||||||
@@ -144,6 +172,23 @@ class ApiHandler(var ctx:Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getLibraryPersonalized(libraryItemId:String, cb: (List<LibraryShelfType>?) -> Unit) {
|
||||||
|
getRequest("/api/libraries/$libraryItemId/personalized", null, null) {
|
||||||
|
if (it.has("error")) {
|
||||||
|
Log.e(tag, it.getString("error") ?: "getLibraryStats Failed")
|
||||||
|
cb(null)
|
||||||
|
} else {
|
||||||
|
val items = mutableListOf<LibraryShelfType>()
|
||||||
|
val array = it.getJSONArray("value")
|
||||||
|
for (i in 0 until array.length()) {
|
||||||
|
val item = jacksonMapper.readValue<LibraryShelfType>(array.get(i).toString())
|
||||||
|
items.add(item)
|
||||||
|
}
|
||||||
|
cb(items)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun getLibraryItem(libraryItemId:String, cb: (LibraryItem?) -> Unit) {
|
fun getLibraryItem(libraryItemId:String, cb: (LibraryItem?) -> Unit) {
|
||||||
getRequest("/api/items/$libraryItemId?expanded=1", null, null) {
|
getRequest("/api/items/$libraryItemId?expanded=1", null, null) {
|
||||||
if (it.has("error")) {
|
if (it.has("error")) {
|
||||||
@@ -184,6 +229,103 @@ class ApiHandler(var ctx:Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getLibrarySeries(libraryId:String, cb: (List<LibrarySeriesItem>) -> Unit) {
|
||||||
|
Log.d(tag, "Getting series")
|
||||||
|
getRequest("/api/libraries/$libraryId/series?minified=1&sort=name&limit=10000", null, null) {
|
||||||
|
val items = mutableListOf<LibrarySeriesItem>()
|
||||||
|
if (it.has("results")) {
|
||||||
|
val array = it.getJSONArray("results")
|
||||||
|
for (i in 0 until array.length()) {
|
||||||
|
val item = jacksonMapper.readValue<LibrarySeriesItem>(array.get(i).toString())
|
||||||
|
items.add(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cb(items)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getLibrarySeriesItems(libraryId:String, seriesId:String, cb: (List<LibraryItem>) -> Unit) {
|
||||||
|
Log.d(tag, "Getting items for series")
|
||||||
|
val seriesIdBase64 = Base64.encodeToString(seriesId.toByteArray(), Base64.DEFAULT)
|
||||||
|
getRequest("/api/libraries/$libraryId/items?minified=1&sort=media.metadata.title&filter=series.${seriesIdBase64}&limit=1000", null, null) {
|
||||||
|
val items = mutableListOf<LibraryItem>()
|
||||||
|
if (it.has("results")) {
|
||||||
|
val array = it.getJSONArray("results")
|
||||||
|
for (i in 0 until array.length()) {
|
||||||
|
val item = jacksonMapper.readValue<LibraryItem>(array.get(i).toString())
|
||||||
|
items.add(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cb(items)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getLibraryAuthors(libraryId:String, cb: (List<LibraryAuthorItem>) -> Unit) {
|
||||||
|
Log.d(tag, "Getting series")
|
||||||
|
getRequest("/api/libraries/$libraryId/authors", null, null) {
|
||||||
|
val items = mutableListOf<LibraryAuthorItem>()
|
||||||
|
if (it.has("authors")) {
|
||||||
|
val array = it.getJSONArray("authors")
|
||||||
|
for (i in 0 until array.length()) {
|
||||||
|
val item = jacksonMapper.readValue<LibraryAuthorItem>(array.get(i).toString())
|
||||||
|
items.add(item)
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
Log.e(tag, "No results")
|
||||||
|
}
|
||||||
|
cb(items)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getLibraryItemsFromAuthor(libraryId:String, authorId:String, cb: (List<LibraryItem>) -> Unit) {
|
||||||
|
Log.d(tag, "Getting author items")
|
||||||
|
val authorIdBase64 = Base64.encodeToString(authorId.toByteArray(), Base64.DEFAULT)
|
||||||
|
getRequest("/api/libraries/$libraryId/items?limit=1000&minified=1&filter=authors.${authorIdBase64}&sort=media.metadata.title&collapseseries=1", null, null) {
|
||||||
|
val items = mutableListOf<LibraryItem>()
|
||||||
|
if (it.has("results")) {
|
||||||
|
val array = it.getJSONArray("results")
|
||||||
|
for (i in 0 until array.length()) {
|
||||||
|
val item = jacksonMapper.readValue<LibraryItem>(array.get(i).toString())
|
||||||
|
if (item.collapsedSeries != null) {
|
||||||
|
item.collapsedSeries?.libraryId = libraryId
|
||||||
|
}
|
||||||
|
items.add(item)
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
Log.e(tag, "No results")
|
||||||
|
}
|
||||||
|
cb(items)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getLibraryCollections(libraryId:String, cb: (List<LibraryCollection>) -> Unit) {
|
||||||
|
Log.d(tag, "Getting collections")
|
||||||
|
getRequest("/api/libraries/$libraryId/collections?minified=1&sort=name&limit=1000", null, null) {
|
||||||
|
val items = mutableListOf<LibraryCollection>()
|
||||||
|
if (it.has("results")) {
|
||||||
|
val array = it.getJSONArray("results")
|
||||||
|
for (i in 0 until array.length()) {
|
||||||
|
val item = jacksonMapper.readValue<LibraryCollection>(array.get(i).toString())
|
||||||
|
items.add(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cb(items)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSearchResults(libraryId:String, queryString:String, cb: (LibraryItemSearchResultType?) -> Unit) {
|
||||||
|
Log.d(tag, "Doing search for library $libraryId")
|
||||||
|
getRequest("/api/libraries/$libraryId/search?q=$queryString", null, null) {
|
||||||
|
if (it.has("error")) {
|
||||||
|
Log.e(tag, it.getString("error") ?: "getSearchResults Failed")
|
||||||
|
cb(null)
|
||||||
|
} else {
|
||||||
|
val librarySearchResults = jacksonMapper.readValue<LibraryItemSearchResultType>(it.toString())
|
||||||
|
cb(librarySearchResults)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun getAllItemsInProgress(cb: (List<ItemInProgress>) -> Unit) {
|
fun getAllItemsInProgress(cb: (List<ItemInProgress>) -> Unit) {
|
||||||
getRequest("/api/me/items-in-progress", null, null) {
|
getRequest("/api/me/items-in-progress", null, null) {
|
||||||
val items = mutableListOf<ItemInProgress>()
|
val items = mutableListOf<ItemInProgress>()
|
||||||
@@ -292,6 +434,13 @@ class ApiHandler(var ctx:Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun closePlaybackSession(playbackSessionId:String, config:ServerConnectionConfig?, cb: (Boolean) -> Unit) {
|
||||||
|
Log.d(tag, "closePlaybackSession: playbackSessionId=$playbackSessionId")
|
||||||
|
postRequest("/api/session/$playbackSessionId/close", null, config) {
|
||||||
|
cb(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun authorize(config:ServerConnectionConfig, cb: (MutableList<MediaProgress>?) -> Unit) {
|
fun authorize(config:ServerConnectionConfig, cb: (MutableList<MediaProgress>?) -> Unit) {
|
||||||
Log.d(tag, "authorize: Authorizing ${config.address}")
|
Log.d(tag, "authorize: Authorizing ${config.address}")
|
||||||
postRequest("/api/authorize", JSObject(), config) {
|
postRequest("/api/authorize", JSObject(), config) {
|
||||||
@@ -314,19 +463,24 @@ class ApiHandler(var ctx:Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun sendSyncLocalSessions(playbackSessions:List<PlaybackSession>, cb: (Boolean, String?) -> Unit) {
|
fun sendSyncLocalSessions(playbackSessions:List<PlaybackSession>, cb: (Boolean, String?) -> Unit) {
|
||||||
val payload = JSObject(jacksonMapper.writeValueAsString(LocalSessionsSyncRequestPayload(playbackSessions)))
|
@SuppressLint("HardwareIds")
|
||||||
|
val deviceId = Settings.Secure.getString(ctx.contentResolver, Settings.Secure.ANDROID_ID)
|
||||||
|
val deviceInfo = DeviceInfo(deviceId, Build.MANUFACTURER, Build.MODEL, Build.VERSION.SDK_INT, BuildConfig.VERSION_NAME)
|
||||||
|
|
||||||
|
val payload = JSObject(jacksonMapper.writeValueAsString(LocalSessionsSyncRequestPayload(playbackSessions, deviceInfo)))
|
||||||
|
Log.d(tag, "Sending ${playbackSessions.size} saved local playback sessions to server")
|
||||||
postRequest("/api/session/local-all", payload, null) {
|
postRequest("/api/session/local-all", payload, null) {
|
||||||
if (!it.getString("error").isNullOrEmpty()) {
|
if (!it.getString("error").isNullOrEmpty()) {
|
||||||
|
Log.e(tag, "Failed to sync local sessions")
|
||||||
cb(false, it.getString("error"))
|
cb(false, it.getString("error"))
|
||||||
} else {
|
} else {
|
||||||
val response = jacksonMapper.readValue<LocalSessionsSyncResponsePayload>(it.toString())
|
val response = jacksonMapper.readValue<LocalSessionsSyncResponsePayload>(it.toString())
|
||||||
response.results.forEach { localSessionSyncResult ->
|
response.results.forEach { localSessionSyncResult ->
|
||||||
|
Log.d(tag, "Synced session result ${localSessionSyncResult.id}|${localSessionSyncResult.progressSynced}|${localSessionSyncResult.success}")
|
||||||
playbackSessions.find { ps -> ps.id == localSessionSyncResult.id }?.let { session ->
|
playbackSessions.find { ps -> ps.id == localSessionSyncResult.id }?.let { session ->
|
||||||
if (localSessionSyncResult.progressSynced == true) {
|
if (localSessionSyncResult.progressSynced == true) {
|
||||||
val syncResult = SyncResult(true, true, "Progress synced on server")
|
val syncResult = SyncResult(true, true, "Progress synced on server")
|
||||||
MediaEventManager.saveEvent(session, syncResult)
|
MediaEventManager.saveEvent(session, syncResult)
|
||||||
DeviceManager.dbManager.removePlaybackSession(session.id)
|
|
||||||
Log.i(tag, "Successfully synced session ${session.displayTitle} with server")
|
Log.i(tag, "Successfully synced session ${session.displayTitle} with server")
|
||||||
} else if (!localSessionSyncResult.success) {
|
} else if (!localSessionSyncResult.success) {
|
||||||
Log.e(tag, "Failed to sync session ${session.displayTitle} with server. Error: ${localSessionSyncResult.error}")
|
Log.e(tag, "Failed to sync session ${session.displayTitle} with server. Error: ${localSessionSyncResult.error}")
|
||||||
@@ -356,6 +510,7 @@ class ApiHandler(var ctx:Context) {
|
|||||||
Log.d(tag, "Server progress for media item id=\"${mediaProgress.mediaItemId}\" is more recent then local. Updating local current time ${localMediaProgress.currentTime} to ${mediaProgress.currentTime}")
|
Log.d(tag, "Server progress for media item id=\"${mediaProgress.mediaItemId}\" is more recent then local. Updating local current time ${localMediaProgress.currentTime} to ${mediaProgress.currentTime}")
|
||||||
localMediaProgress.updateFromServerMediaProgress(mediaProgress)
|
localMediaProgress.updateFromServerMediaProgress(mediaProgress)
|
||||||
MediaEventManager.syncEvent(mediaProgress, "Sync on server connection")
|
MediaEventManager.syncEvent(mediaProgress, "Sync on server connection")
|
||||||
|
DeviceManager.dbManager.saveLocalMediaProgress(localMediaProgress)
|
||||||
} else if (localMediaProgress.lastUpdate > mediaProgress.lastUpdate && localMediaProgress.ebookLocation != null && localMediaProgress.ebookLocation != mediaProgress.ebookLocation) {
|
} else if (localMediaProgress.lastUpdate > mediaProgress.lastUpdate && localMediaProgress.ebookLocation != null && localMediaProgress.ebookLocation != mediaProgress.ebookLocation) {
|
||||||
// Patch ebook progress to server
|
// Patch ebook progress to server
|
||||||
val endpoint = "/api/me/progress/${localMediaProgress.libraryItemId}"
|
val endpoint = "/api/me/progress/${localMediaProgress.libraryItemId}"
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
<!-- drawable/clock_outline.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#FFFFFF" android:pathData="M12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22C6.47,22 2,17.5 2,12A10,10 0 0,1 12,2M12.5,7V12.25L17,14.92L16.25,16.15L11,13V7H12.5Z" /></vector>
|
||||||
|
After Width: | Height: | Size: 560 B |
|
After Width: | Height: | Size: 798 B |
|
After Width: | Height: | Size: 387 B |
|
After Width: | Height: | Size: 532 B |
|
After Width: | Height: | Size: 707 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="27dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="27"
|
||||||
|
android:viewportHeight="32">
|
||||||
|
<path
|
||||||
|
android:pathData="M26.719,15.761c-0.165,-0.138 -0.422,-0.341 -0.77,-0.581v-2.703c0,-6.891 -5.586,-12.477 -12.478,-12.477v0c-6.891,0 -12.477,5.586 -12.477,12.477v2.703c-0.348,0.241 -0.605,0.443 -0.77,0.581 -0.137,0.114 -0.223,0.285 -0.223,0.476 0,0 0,0 0,0.001v-0,3.238c0,0 0,0.001 0,0.001 0,0.191 0.086,0.361 0.222,0.475l0.001,0.001c0.385,0.321 1.269,0.993 2.645,1.683v0.315c0,0.849 0.548,1.537 1.223,1.537v0c0.675,0 1.223,-0.688 1.223,-1.537v-7.767c0,-0.849 -0.548,-1.537 -1.223,-1.537v0c-0.647,0 -1.177,0.632 -1.22,1.431l-0.003,0.002v-1.601c0,-5.856 4.747,-10.602 10.603,-10.602v0c5.856,0 10.603,4.747 10.603,10.602v1.601l-0.003,-0.002c-0.043,-0.799 -0.573,-1.431 -1.22,-1.431v0c-0.675,0 -1.223,0.688 -1.223,1.537v7.766c0,0.849 0.548,1.537 1.223,1.537v0c0.676,0 1.223,-0.688 1.223,-1.537v-0.315c1.376,-0.69 2.26,-1.362 2.645,-1.683 0.137,-0.114 0.223,-0.285 0.223,-0.476 0,-0 0,-0.001 0,-0.001v0,-3.237c0,-0 0,-0 0,-0 0,-0.191 -0.086,-0.361 -0.222,-0.475l-0.001,-0.001zM9.12,29.262c0.816,0 1.477,-0.661 1.477,-1.477v0,-16.543c0,-0 0,-0 0,-0 0,-0.816 -0.661,-1.477 -1.477,-1.477h-1.526c-0.816,0 -1.478,0.662 -1.478,1.478v0,16.543c0,0.816 0.661,1.477 1.477,1.477 0,0 0,0 0,0v0zM6.673,13.731h3.368v0.352h-3.368zM14.234,29.262c0.816,0 1.477,-0.661 1.477,-1.477v0,-16.543c0,-0 0,-0 0,-0 0,-0.816 -0.661,-1.477 -1.477,-1.477h-1.526c-0.816,0 -1.478,0.662 -1.478,1.478v0,16.543c0,0.816 0.661,1.477 1.477,1.477 0,0 0,0 0,0v0zM11.787,13.731h3.367v0.352h-3.367zM19.348,29.262c0.816,0 1.477,-0.661 1.477,-1.477v0,-16.543c0,-0 0,-0 0,-0 0,-0.816 -0.661,-1.477 -1.477,-1.477h-1.526c-0.816,0 -1.478,0.662 -1.478,1.478v0,16.543c0,0.816 0.661,1.477 1.477,1.477 0,0 0,0 0,0v0zM16.901,13.731h3.367v0.352h-3.367zM3.566,29.773h19.81c0.615,0 1.113,0.498 1.113,1.113v0c0,0.615 -0.498,1.113 -1.113,1.113h-19.81c-0.615,0 -1.113,-0.498 -1.113,-1.113v-0c0,-0.615 0.498,-1.113 1.113,-1.113z"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="32dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="32"
|
||||||
|
android:viewportHeight="32">
|
||||||
|
<path
|
||||||
|
android:pathData="M16,7.333c2.577,0 4.667,2.089 4.667,4.667v0c0,2.577 -2.089,4.667 -4.667,4.667v0c-2.577,0 -4.667,-2.089 -4.667,-4.667v0c0,-2.577 2.089,-4.667 4.667,-4.667v0zM6.667,10.667c0.747,0 1.44,0.2 2.04,0.56 -0.2,1.907 0.36,3.8 1.507,5.28 -0.667,1.28 -2,2.16 -3.547,2.16 -2.209,0 -4,-1.791 -4,-4v0c0,-2.209 1.791,-4 4,-4v0zM25.333,10.667c2.209,0 4,1.791 4,4v0c0,2.209 -1.791,4 -4,4v0c-1.547,0 -2.88,-0.88 -3.547,-2.16 1.147,-1.48 1.707,-3.373 1.507,-5.28 0.6,-0.36 1.293,-0.56 2.04,-0.56zM7.333,24.333c0,-2.76 3.88,-5 8.667,-5s8.667,2.24 8.667,5v2.333h-17.333v-2.333zM0,26.667v-2c0,-1.853 2.52,-3.413 5.933,-3.867 -0.787,0.907 -1.267,2.16 -1.267,3.533v2.333h-4.667zM32,26.667h-4.667v-2.333c0,-1.373 -0.48,-2.627 -1.267,-3.533 3.413,0.453 5.933,2.013 5.933,3.867v2z"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="32dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="32"
|
||||||
|
android:viewportHeight="32">
|
||||||
|
<path
|
||||||
|
android:pathData="M28,4v26h-21c-1.657,0 -3,-1.343 -3,-3s1.343,-3 3,-3h19v-24h-20c-2.2,0 -4,1.8 -4,4v24c0,2.2 1.8,4 4,4h24v-28h-2zM7.002,26v0c-0.001,0 -0.001,0 -0.002,0 -0.552,0 -1,0.448 -1,1s0.448,1 1,1c0.001,0 0.001,-0 0.002,-0v0h18.997v-2h-18.997z"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="32dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="32"
|
||||||
|
android:viewportHeight="32">
|
||||||
|
<path
|
||||||
|
android:pathData="M12,4v20h4v-20h-4zM16,6.667l5.333,17.333 4,-1.333 -5.333,-17.333 -4,1.333zM6.667,6.667v17.333h4v-17.333h-4zM4,25.333v2.667h24v-2.667h-24z"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="36dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="36"
|
||||||
|
android:viewportHeight="32">
|
||||||
|
<path
|
||||||
|
android:pathData="M7,4h-6c-0.55,0 -1,0.45 -1,1v22c0,0.55 0.45,1 1,1h6c0.55,0 1,-0.45 1,-1v-22c0,-0.55 -0.45,-1 -1,-1zM6,10h-4v-2h4v2zM17,4h-6c-0.55,0 -1,0.45 -1,1v22c0,0.55 0.45,1 1,1h6c0.55,0 1,-0.45 1,-1v-22c0,-0.55 -0.45,-1 -1,-1zM16,10h-4v-2h4v2zM23.909,5.546l-5.358,2.7c-0.491,0.247 -0.691,0.852 -0.443,1.343l8.999,17.861c0.247,0.491 0.852,0.691 1.343,0.443l5.358,-2.7c0.491,-0.247 0.691,-0.852 0.443,-1.343l-8.999,-17.861c-0.247,-0.491 -0.852,-0.691 -1.343,-0.443z"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="32dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="32"
|
||||||
|
android:viewportHeight="32">
|
||||||
|
<path
|
||||||
|
android:pathData="M19.2,6h-6.4v19.2h6.4v-19.2zM22.4,6v19.2h6.4v-19.2h-6.4zM9.6,6h-6.4v19.2h6.4v-19.2zM0,2.8h32v25.6h-32v-25.6z"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="27dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="27"
|
||||||
|
android:viewportHeight="32">
|
||||||
|
<path
|
||||||
|
android:pathData="M13.68,0c7.518,0 13.612,2.854 13.612,6.37 0,3.518 -6.096,6.37 -13.612,6.37s-13.612,-2.854 -13.612,-6.37c0,-3.516 6.096,-6.37 13.612,-6.37v0zM0.068,21.31v4.891c2.422,8.602 26.349,6.94 27.227,-0.44v-4.885c-1.195,8.102 -25.313,8.685 -27.227,0.435v0,0zM0,8.578v4.776c2.422,8.401 26.482,7.266 27.362,0.06v-4.773c-1.198,7.914 -25.448,7.995 -27.362,-0.063v0zM0,14.75v4.891c2.422,8.602 26.482,7.44 27.362,0.06v-4.885c-1.198,8.102 -25.448,8.185 -27.362,-0.065v0z"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="32dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="32"
|
||||||
|
android:viewportHeight="32">
|
||||||
|
<path
|
||||||
|
android:pathData="M26,28h-20v-4l6,-10 8.219,10 5.781,-4v8zM26,15c0,1.657 -1.343,3 -3,3s-3,-1.343 -3,-3 1.343,-3 3,-3c1.657,0 3,1.343 3,3zM28.681,7.159c-0.694,-0.947 -1.662,-2.053 -2.724,-3.116s-2.169,-2.03 -3.116,-2.724c-1.612,-1.182 -2.393,-1.319 -2.841,-1.319h-15.5c-1.378,0 -2.5,1.121 -2.5,2.5v27c0,1.378 1.122,2.5 2.5,2.5h23c1.378,0 2.5,-1.122 2.5,-2.5v-19.5c0,-0.448 -0.137,-1.23 -1.319,-2.841zM24.543,5.457c0.959,0.959 1.712,1.825 2.268,2.543h-4.811v-4.811c0.718,0.556 1.584,1.309 2.543,2.268zM28,29.5c0,0.271 -0.229,0.5 -0.5,0.5h-23c-0.271,0 -0.5,-0.229 -0.5,-0.5v-27c0,-0.271 0.229,-0.5 0.5,-0.5 0,0 15.499,-0 15.5,0v7c0,0.552 0.448,1 1,1h7v19.5z"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="32dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="32"
|
||||||
|
android:viewportHeight="32">
|
||||||
|
<path
|
||||||
|
android:pathData="M9,18h-2v14h2c0.55,0 1,-0.45 1,-1v-12c0,-0.55 -0.45,-1 -1,-1zM23,18c-0.55,0 -1,0.45 -1,1v12c0,0.55 0.45,1 1,1h2v-14h-2zM32,16c0,-8.837 -7.163,-16 -16,-16s-16,7.163 -16,16c0,1.919 0.338,3.759 0.958,5.464 -0.609,1.038 -0.958,2.246 -0.958,3.536 0,3.526 2.608,6.443 6,6.929v-13.857c-0.997,0.143 -1.927,0.495 -2.742,1.012 -0.168,-0.835 -0.258,-1.699 -0.258,-2.584 0,-7.18 5.82,-13 13,-13s13,5.82 13,13c0,0.885 -0.088,1.749 -0.257,2.584 -0.816,-0.517 -1.745,-0.87 -2.743,-1.013v13.858c3.392,-0.485 6,-3.402 6,-6.929 0,-1.29 -0.349,-2.498 -0.958,-3.536 0.62,-1.705 0.958,-3.545 0.958,-5.465z"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="32dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="32"
|
||||||
|
android:viewportHeight="32">
|
||||||
|
<path
|
||||||
|
android:pathData="M23.6,2c-3.363,0 -6.258,2.736 -7.599,5.594 -1.342,-2.858 -4.237,-5.594 -7.601,-5.594 -4.637,0 -8.4,3.764 -8.4,8.401 0,9.433 9.516,11.906 16.001,21.232 6.13,-9.268 15.999,-12.1 15.999,-21.232 0,-4.637 -3.763,-8.401 -8.4,-8.401z"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="32">
|
||||||
|
<path
|
||||||
|
android:pathData="M6,6v10c0,3.313 2.688,6 6,6s6,-2.688 6,-6h-5c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1h5v-2h-5c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1h5v-2h-5c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1h5c0,-3.313 -2.688,-6 -6,-6s-6,2.688 -6,6zM20,15v1c0,4.419 -3.581,8 -8,8s-8,-3.581 -8,-8v-2.5c0,-0.831 -0.669,-1.5 -1.5,-1.5s-1.5,0.669 -1.5,1.5v2.5c0,5.569 4.138,10.169 9.5,10.9v2.1h-3c-0.831,0 -1.5,0.669 -1.5,1.5s0.669,1.5 1.5,1.5h9c0.831,0 1.5,-0.669 1.5,-1.5s-0.669,-1.5 -1.5,-1.5h-3v-2.1c5.363,-0.731 9.5,-5.331 9.5,-10.9v-2.5c0,-0.831 -0.669,-1.5 -1.5,-1.5s-1.5,0.669 -1.5,1.5v1.5z"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="22dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="22"
|
||||||
|
android:viewportHeight="32">
|
||||||
|
<path
|
||||||
|
android:pathData="M22.292,14.872c0,-0.836 -0.677,-1.51 -1.51,-1.51 -0.836,0 -1.51,0.677 -1.51,1.51 0,2.977 -0.714,5.435 -2.159,7.076 -1.31,1.484 -3.289,2.341 -5.964,2.341s-4.654,-0.854 -5.964,-2.339c-1.448,-1.641 -2.159,-4.099 -2.159,-7.078 0,-0.836 -0.677,-1.51 -1.51,-1.51 -0.836,0 -1.51,0.677 -1.51,1.51 0,3.711 0.961,6.857 2.914,9.073 1.438,1.63 3.375,2.734 5.815,3.164v2.479h-3.703c-0.661,0 -1.203,0.542 -1.203,1.203v1.206h14.646v-1.206c0,-0.661 -0.542,-1.203 -1.203,-1.203h-3.711v-2.479c2.44,-0.432 4.375,-1.534 5.815,-3.167 1.953,-2.214 2.917,-5.359 2.917,-9.07v0,0zM11.146,0c3.083,0 5.604,2.523 5.604,5.604v0.146h-3.013v3.57h3.016v1.818h-3.016v3.57h3.016v1.284c0,3.083 -2.523,5.604 -5.604,5.604 -3.083,0 -5.604,-2.523 -5.604,-5.604v-1.284h3.016v-3.57h-3.018v-1.818h3.016v-3.57h-3.016v-0.146c0,-3.081 2.521,-5.604 5.604,-5.604v0z"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="32dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="32"
|
||||||
|
android:viewportHeight="32">
|
||||||
|
<path
|
||||||
|
android:pathData="M15,22c2.761,0 5,-2.239 5,-5v-12c0,-2.761 -2.239,-5 -5,-5s-5,2.239 -5,5v12c0,2.761 2.239,5 5,5zM22,14v3c0,3.866 -3.134,7 -7,7s-7,-3.134 -7,-7v-3h-2v3c0,4.632 3.5,8.447 8,8.944v4.056h-4v2h10v-2h-4v-4.056c4.5,-0.497 8,-4.312 8,-8.944v-3h-2z"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="32dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="32"
|
||||||
|
android:viewportHeight="32">
|
||||||
|
<path
|
||||||
|
android:pathData="M30,0h2v23c0,2.761 -3.134,5 -7,5s-7,-2.239 -7,-5c0,-2.761 3.134,-5 7,-5 1.959,0 3.729,0.575 5,1.501v-11.501l-16,3.556v15.444c0,2.761 -3.134,5 -7,5s-7,-2.239 -7,-5c0,-2.761 3.134,-5 7,-5 1.959,0 3.729,0.575 5,1.501v-19.501l18,-4z"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="33dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="33"
|
||||||
|
android:viewportHeight="32">
|
||||||
|
<path
|
||||||
|
android:pathData="M18.289,18.549v13.45h-3.973v-13.45c-1.305,-0.706 -2.191,-2.087 -2.191,-3.676 0,-2.307 1.871,-4.178 4.178,-4.178s4.178,1.871 4.178,4.178c0,1.589 -0.887,2.97 -2.192,3.676v0zM10.434,2.963c0.774,-0.382 1.091,-1.319 0.709,-2.091s-1.318,-1.091 -2.091,-0.71c-3.158,1.558 -5.613,4.134 -7.165,7.169 -1.146,2.241 -1.8,4.734 -1.879,7.251 -0.079,2.538 0.421,5.101 1.585,7.46 1.433,2.906 3.863,5.491 7.44,7.322 0.767,0.392 1.706,0.088 2.098,-0.679s0.088,-1.706 -0.679,-2.097c-2.929,-1.498 -4.905,-3.589 -6.059,-5.926 -0.93,-1.887 -1.33,-3.942 -1.267,-5.981 0.064,-2.058 0.599,-4.098 1.536,-5.93 1.256,-2.455 3.234,-4.536 5.771,-5.786v0zM23.554,0.161c-0.773,-0.382 -1.71,-0.064 -2.091,0.71s-0.064,1.71 0.71,2.091c2.537,1.251 4.515,3.332 5.771,5.787 0.937,1.832 1.472,3.871 1.536,5.93 0.064,2.038 -0.336,4.094 -1.267,5.981 -1.153,2.337 -3.13,4.428 -6.059,5.926 -0.767,0.392 -1.07,1.331 -0.679,2.097s1.331,1.071 2.098,0.679c3.577,-1.83 6.007,-4.415 7.44,-7.322 1.164,-2.359 1.664,-4.922 1.585,-7.46 -0.079,-2.516 -0.732,-5.01 -1.878,-7.251 -1.552,-3.034 -4.008,-5.611 -7.165,-7.169v0zM21.968,7.033c-0.582,-0.42 -1.395,-0.287 -1.814,0.295s-0.287,1.395 0.295,1.814c0.235,0.169 0.465,0.359 0.691,0.566 1.319,1.216 2.101,2.838 2.266,4.553 0.166,1.731 -0.295,3.566 -1.464,5.188 -0.198,0.276 -0.427,0.555 -0.686,0.836 -0.487,0.529 -0.453,1.353 0.076,1.839s1.353,0.452 1.84,-0.076c0.313,-0.339 0.607,-0.701 0.88,-1.081 1.555,-2.16 2.167,-4.617 1.943,-6.951 -0.225,-2.349 -1.293,-4.566 -3.091,-6.224 -0.283,-0.261 -0.595,-0.514 -0.935,-0.76v0zM12.156,9.143c0.582,-0.42 0.715,-1.232 0.295,-1.814s-1.232,-0.715 -1.814,-0.296c-0.341,0.246 -0.652,0.499 -0.935,0.76 -1.799,1.658 -2.866,3.875 -3.091,6.224 -0.224,2.334 0.387,4.792 1.943,6.952 0.274,0.379 0.567,0.741 0.88,1.08 0.487,0.529 1.311,0.563 1.839,0.076s0.563,-1.311 0.076,-1.839c-0.259,-0.281 -0.487,-0.56 -0.686,-0.836 -1.169,-1.623 -1.63,-3.457 -1.464,-5.188 0.164,-1.715 0.947,-3.337 2.266,-4.553 0.226,-0.207 0.456,-0.397 0.691,-0.566v0z"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="32dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="32"
|
||||||
|
android:viewportHeight="32">
|
||||||
|
<path
|
||||||
|
android:pathData="M30.925,2.938c0.794,-0.231 1.25,-1.069 1.019,-1.863s-1.069,-1.25 -1.869,-1.012l-26.844,7.869c-0.587,0.169 -1.119,0.456 -1.569,0.825 -1.006,0.725 -1.663,1.906 -1.663,3.244v16c0,2.206 1.794,4 4,4h24c2.206,0 4,-1.794 4,-4v-16c0,-2.206 -1.794,-4 -4,-4h-14.344l17.269,-5.063zM23,25c-2.762,0 -5,-2.238 -5,-5s2.238,-5 5,-5 5,2.238 5,5 -2.238,5 -5,5zM5,16c0,-0.55 0.45,-1 1,-1h6c0.55,0 1,0.45 1,1s-0.45,1 -1,1h-6c-0.55,0 -1,-0.45 -1,-1zM4,20c0,-0.55 0.45,-1 1,-1h8c0.55,0 1,0.45 1,1s-0.45,1 -1,1h-8c-0.55,0 -1,-0.45 -1,-1zM5,24c0,-0.55 0.45,-1 1,-1h6c0.55,0 1,0.45 1,1s-0.45,1 -1,1h-6c-0.55,0 -1,-0.45 -1,-1z"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="32dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="32"
|
||||||
|
android:viewportHeight="32">
|
||||||
|
<path
|
||||||
|
android:pathData="M22,2l-10,10h-6l-6,8c0,0 6.357,-1.77 10.065,-0.94l-10.065,12.94 13.184,-10.255c1.839,4.208 -1.184,10.255 -1.184,10.255l8,-6v-6l10,-10 2,-10 -10,2z"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="32dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="32"
|
||||||
|
android:viewportHeight="32">
|
||||||
|
<path
|
||||||
|
android:pathData="M4.259,23.467c-2.35,0 -4.259,1.917 -4.259,4.252 0,2.349 1.909,4.244 4.259,4.244 2.358,0 4.265,-1.895 4.265,-4.244 -0,-2.336 -1.907,-4.252 -4.265,-4.252zM0.005,10.873v6.133c3.993,0 7.749,1.562 10.577,4.391 2.825,2.822 4.384,6.595 4.384,10.603h6.16c-0,-11.651 -9.478,-21.127 -21.121,-21.127zM0.012,0v6.136c14.243,0 25.836,11.604 25.836,25.864h6.152c0,-17.64 -14.352,-32 -31.988,-32z"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="32dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="32"
|
||||||
|
android:viewportHeight="32">
|
||||||
|
<path
|
||||||
|
android:pathData="M32,12.408l-11.056,-1.607 -4.944,-10.018 -4.944,10.018 -11.056,1.607 8,7.798 -1.889,11.011 9.889,-5.199 9.889,5.199 -1.889,-11.011 8,-7.798z"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<!-- drawable/account_outline.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#FFFFFF" android:pathData="M12,4A4,4 0 0,1 16,8A4,4 0 0,1 12,12A4,4 0 0,1 8,8A4,4 0 0,1 12,4M12,6A2,2 0 0,0 10,8A2,2 0 0,0 12,10A2,2 0 0,0 14,8A2,2 0 0,0 12,6M12,13C14.67,13 20,14.33 20,17V20H4V17C4,14.33 9.33,13 12,13M12,14.9C9.03,14.9 5.9,16.36 5.9,17V18.1H18.1V17C18.1,16.36 14.97,14.9 12,14.9Z" /></vector>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<!-- drawable/book_multiple_outline.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#FFFFFF" android:pathData="M19 2A2 2 0 0 1 21 4V16A2 2 0 0 1 19 18H9A2 2 0 0 1 7 16V4A2 2 0 0 1 9 2H19M19 4H16V10L13.5 7.75L11 10V4H9V16H19M3 20A2 2 0 0 0 5 22H17V20H5V6H3Z" /></vector>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<!-- drawable/book_open_blank_variant_outline.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#FFFFFF" android:pathData="M12 21.5C10.65 20.65 8.2 20 6.5 20C4.85 20 3.15 20.3 1.75 21.05C1.65 21.1 1.6 21.1 1.5 21.1C1.25 21.1 1 20.85 1 20.6V6C1.6 5.55 2.25 5.25 3 5C4.11 4.65 5.33 4.5 6.5 4.5C8.45 4.5 10.55 4.9 12 6C13.45 4.9 15.55 4.5 17.5 4.5C18.67 4.5 19.89 4.65 21 5C21.75 5.25 22.4 5.55 23 6V20.6C23 20.85 22.75 21.1 22.5 21.1C22.4 21.1 22.35 21.1 22.25 21.05C20.85 20.3 19.15 20 17.5 20C15.8 20 13.35 20.65 12 21.5M11 7.5C9.64 6.9 7.84 6.5 6.5 6.5C5.3 6.5 4.1 6.65 3 7V18.5C4.1 18.15 5.3 18 6.5 18C7.84 18 9.64 18.4 11 19V7.5M13 19C14.36 18.4 16.16 18 17.5 18C18.7 18 19.9 18.15 21 18.5V7C19.9 6.65 18.7 6.5 17.5 6.5C16.16 6.5 14.36 6.9 13 7.5V19Z" /></vector>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<!-- drawable/clock_outline.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#FFFFFF" android:pathData="M12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22C6.47,22 2,17.5 2,12A10,10 0 0,1 12,2M12.5,7V12.25L17,14.92L16.25,16.15L11,13V7H12.5Z" /></vector>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<!-- drawable/telescope.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#FFFFFF" android:pathData="M21.9,8.9L20.2,9.9L16.2,3L17.9,2L21.9,8.9M9.8,7.9L12.8,13.1L18.9,9.6L15.9,4.4L9.8,7.9M11.4,12.7L9.4,9.2L5.1,11.7L7.1,15.2L11.4,12.7M2.1,14.6L3.1,16.3L5.7,14.8L4.7,13.1L2.1,14.6M12.1,14L11.8,13.6L7.5,16.1L7.8,16.5C8,16.8 8.3,17.1 8.6,17.3L7,22H9L10.4,17.7H10.5L12,22H14L12.1,16.4C12.6,15.7 12.6,14.8 12.1,14Z" /></vector>
|
||||||
@@ -2,4 +2,5 @@
|
|||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<background android:drawable="@mipmap/ic_launcher_background"/>
|
<background android:drawable="@mipmap/ic_launcher_background"/>
|
||||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
</adaptive-icon>
|
<monochrome android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
|
</adaptive-icon>
|
||||||
|
|||||||
@@ -2,4 +2,5 @@
|
|||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<background android:drawable="@mipmap/ic_launcher_background"/>
|
<background android:drawable="@mipmap/ic_launcher_background"/>
|
||||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
</adaptive-icon>
|
<monochrome android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
|
</adaptive-icon>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<?xml version='1.0' encoding='utf-8'?>
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">audiobookshelf</string>
|
<string name="app_name">Audiobookshelf</string>
|
||||||
<string name="title_activity_main">audiobookshelf</string>
|
<string name="title_activity_main">Audiobookshelf</string>
|
||||||
<string name="package_name">com.audiobookshelf.app</string>
|
<string name="package_name">com.audiobookshelf.app</string>
|
||||||
<string name="custom_url_scheme">com.audiobookshelf.app</string>
|
<string name="custom_url_scheme">audiobookshelf</string>
|
||||||
<string name="add_widget">Add widget</string>
|
<string name="add_widget">Add widget</string>
|
||||||
<string name="app_widget_description">Simple widget for audiobookshelf playback</string>
|
<string name="app_widget_description">Simple widget for audiobookshelf playback</string>
|
||||||
<string name="action_jump_forward">Jump Forward</string>
|
<string name="action_jump_forward">Jump Forward</string>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
<paths>
|
||||||
<external-path name="my_images" path="." />
|
<files-path name="downloads" path="downloads/" />
|
||||||
<cache-path name="my_cache_images" path="." />
|
</paths>
|
||||||
</paths>
|
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.7.20'
|
ext.kotlin_version = '2.0.0'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.google.gms:google-services:4.3.13'
|
classpath 'com.google.gms:google-services:4.4.2'
|
||||||
classpath 'com.android.tools.build:gradle:7.4.0'
|
classpath 'com.android.tools.build:gradle:8.8.0'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
@@ -26,7 +26,7 @@ allprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task clean(type: Delete) {
|
tasks.register('clean', Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.layout.buildDirectory
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,24 @@
|
|||||||
include ':capacitor-android'
|
include ':capacitor-android'
|
||||||
project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')
|
project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')
|
||||||
|
|
||||||
|
include ':byteowls-capacitor-filesharer'
|
||||||
|
project(':byteowls-capacitor-filesharer').projectDir = new File('../node_modules/@byteowls/capacitor-filesharer/android')
|
||||||
|
|
||||||
|
include ':capacitor-community-keep-awake'
|
||||||
|
project(':capacitor-community-keep-awake').projectDir = new File('../node_modules/@capacitor-community/keep-awake/android')
|
||||||
|
|
||||||
|
include ':capacitor-community-volume-buttons'
|
||||||
|
project(':capacitor-community-volume-buttons').projectDir = new File('../node_modules/@capacitor-community/volume-buttons/android')
|
||||||
|
|
||||||
include ':capacitor-app'
|
include ':capacitor-app'
|
||||||
project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/android')
|
project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/android')
|
||||||
|
|
||||||
|
include ':capacitor-browser'
|
||||||
|
project(':capacitor-browser').projectDir = new File('../node_modules/@capacitor/browser/android')
|
||||||
|
|
||||||
|
include ':capacitor-clipboard'
|
||||||
|
project(':capacitor-clipboard').projectDir = new File('../node_modules/@capacitor/clipboard/android')
|
||||||
|
|
||||||
include ':capacitor-dialog'
|
include ':capacitor-dialog'
|
||||||
project(':capacitor-dialog').projectDir = new File('../node_modules/@capacitor/dialog/android')
|
project(':capacitor-dialog').projectDir = new File('../node_modules/@capacitor/dialog/android')
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ org.gradle.jvmargs=-Dfile.encoding=UTF-8 \
|
|||||||
# Android operating system, and which are packaged with your app's APK
|
# Android operating system, and which are packaged with your app's APK
|
||||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
# Automatically convert third-party libraries to use AndroidX
|
|
||||||
android.enableJetifier=true
|
|
||||||
|
|
||||||
kapt.use.worker.api=false
|
kapt.use.worker.api=false
|
||||||
|
|
||||||
|
android.buildfeatures.buildconfig=true
|
||||||
|
|
||||||
|
org.gradle.warning.mode=all
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#Sun Apr 17 13:28:55 CDT 2022
|
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
|
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStorePath=wrapper/dists
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
|
||||||
|
networkTimeout=10000
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright 2015 the original author or authors.
|
# Copyright © 2015-2021 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -17,67 +17,101 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
#
|
||||||
## Gradle start up script for UN*X
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
##
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
# Resolve links: $0 may be a link
|
|
||||||
PRG="$0"
|
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
|
||||||
ls=`ls -ld "$PRG"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
PRG="$link"
|
|
||||||
else
|
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
# Resolve links: $0 may be a link
|
||||||
APP_BASE_NAME=`basename "$0"`
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD=maximum
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "`uname`" in
|
case "$( uname )" in #(
|
||||||
CYGWIN* )
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
cygwin=true
|
Darwin* ) darwin=true ;; #(
|
||||||
;;
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
Darwin* )
|
NONSTOP* ) nonstop=true ;;
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
NONSTOP* )
|
|
||||||
nonstop=true
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
@@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
else
|
else
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
@@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD="java"
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
@@ -106,80 +140,105 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
case $MAX_FD in #(
|
||||||
if [ $? -eq 0 ] ; then
|
max*)
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
# shellcheck disable=SC3045
|
||||||
fi
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
ulimit -n $MAX_FD
|
warn "Could not query maximum file descriptor limit"
|
||||||
if [ $? -ne 0 ] ; then
|
esac
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
case $MAX_FD in #(
|
||||||
fi
|
'' | soft) :;; #(
|
||||||
else
|
*)
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
fi
|
# shellcheck disable=SC3045
|
||||||
fi
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
# For Darwin, add options to specify how the application appears in the dock
|
|
||||||
if $darwin; then
|
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
||||||
SEP=""
|
|
||||||
for dir in $ROOTDIRSRAW ; do
|
|
||||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
||||||
SEP="|"
|
|
||||||
done
|
|
||||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
||||||
# Add a user-defined pattern to the cygpath arguments
|
|
||||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
||||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
||||||
fi
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
i=0
|
|
||||||
for arg in "$@" ; do
|
|
||||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
|
||||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
|
||||||
|
|
||||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
|
||||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
|
||||||
else
|
|
||||||
eval `echo args$i`="\"$arg\""
|
|
||||||
fi
|
|
||||||
i=`expr $i + 1`
|
|
||||||
done
|
|
||||||
case $i in
|
|
||||||
0) set -- ;;
|
|
||||||
1) set -- "$args0" ;;
|
|
||||||
2) set -- "$args0" "$args1" ;;
|
|
||||||
3) set -- "$args0" "$args1" "$args2" ;;
|
|
||||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
||||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
||||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
||||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
||||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
||||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Escape application args
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
save () {
|
# * args from the command line
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
# * the main class name
|
||||||
echo " "
|
# * -classpath
|
||||||
}
|
# * -D...appname settings
|
||||||
APP_ARGS=`save "$@"`
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command;
|
||||||
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||||
|
# shell script including quotes and variable substitutions, so put them in
|
||||||
|
# double quotes to make sure that they get re-expanded; and
|
||||||
|
# * put everything else in single quotes, so that it's not re-expanded.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@@ -25,7 +25,8 @@
|
|||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
plugins {
|
||||||
|
id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0"
|
||||||
|
}
|
||||||
|
|
||||||
include ':app'
|
include ':app'
|
||||||
include ':capacitor-cordova-android-plugins'
|
include ':capacitor-cordova-android-plugins'
|
||||||
project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/')
|
project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/')
|
||||||
|
|||||||