Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9278e74e85 | ||
|
|
cf6f09c60d | ||
|
|
f2cbed48d9 | ||
|
|
f1ead0c247 | ||
|
|
5f2c72ec4d | ||
|
|
a6869eb2e6 | ||
|
|
cbae6c476a | ||
|
|
48d257ceaf | ||
|
|
5355456498 | ||
|
|
1436895ace | ||
|
|
6e32f7724f | ||
|
|
3f5104d60a | ||
|
|
d8fdb3b818 | ||
|
|
5c187e7a8d | ||
|
|
24862550a1 | ||
|
|
146fced44e | ||
|
|
d535ed8c98 | ||
|
|
b675dbad9b | ||
|
|
dabe9fe691 | ||
|
|
9ac216504d | ||
|
|
911ca998e7 | ||
|
|
36c105d3a7 | ||
|
|
a655d0112b | ||
|
|
493c771e94 | ||
|
|
e9d70dbf87 | ||
|
|
0849ce2b66 | ||
|
|
d0a8b3b218 | ||
|
|
a8cdc4a771 | ||
|
|
67b883660f | ||
|
|
f328efb831 | ||
|
|
b2f56364d6 | ||
|
|
2761857fe8 | ||
|
|
d439260d69 | ||
|
|
f0f0a5028b | ||
|
|
13e170cb61 | ||
|
|
127d8052ca | ||
|
|
1b3086572f | ||
|
|
6fa308ef96 | ||
|
|
f3e513fc2d | ||
|
|
d72a8faec4 | ||
|
|
fdb4578349 | ||
|
|
c08237d399 | ||
|
|
bdf8a58818 | ||
|
|
e1d51c881a | ||
|
|
28212808f8 | ||
|
|
74f08f8f98 | ||
|
|
cb5c29fbce | ||
|
|
4d775d3a17 | ||
|
|
fd94ef9fa7 | ||
|
|
2e0331305a | ||
|
|
fb560f8f01 | ||
|
|
ef80c9f7fd | ||
|
|
99a4a0a22f | ||
|
|
136853853a | ||
|
|
ebf3299c30 | ||
|
|
036b49a871 | ||
|
|
67d5f88d34 | ||
|
|
b1e0b9af33 | ||
|
|
c30b012787 | ||
|
|
c8c6305757 | ||
|
|
ee1d090e62 | ||
|
|
9e56a86492 | ||
|
|
e6b83877f1 | ||
|
|
b567e39aef | ||
|
|
ae62dba0a6 | ||
|
|
df1e8abf50 | ||
|
|
31cfb26c3b | ||
|
|
e5f34dc464 | ||
|
|
601031e55d | ||
|
|
a9aadbe6a8 | ||
|
|
f9a4b71037 | ||
|
|
0f10e9dc1f | ||
|
|
0647deb06c | ||
|
|
b2f5fec293 | ||
|
|
daf4e5aca2 | ||
|
|
c1324efb41 | ||
|
|
6221de2d3c | ||
|
|
983bc68af2 | ||
|
|
f1b167693d | ||
|
|
68ac64b534 | ||
|
|
6819ae46f9 | ||
|
|
6c406c5a85 | ||
|
|
c179243d22 | ||
|
|
d0f5504c80 | ||
|
|
896c566a02 | ||
|
|
da9352cc68 | ||
|
|
b8d2375e20 | ||
|
|
dd52ff9d07 | ||
|
|
d9891f8a8a | ||
|
|
ea5fe6842d | ||
|
|
fc649187df | ||
|
|
b0f7c41885 | ||
|
|
45935717c8 | ||
|
|
ac5e666369 | ||
|
|
ffeb72a383 | ||
|
|
0ec09d751c | ||
|
|
b8e4fcff92 | ||
|
|
b79f0f4820 | ||
|
|
a1cd58a214 | ||
|
|
cfca8facbe | ||
|
|
066a0a099c | ||
|
|
afeee2e5df | ||
|
|
76036acfc7 | ||
|
|
897bfdaffd | ||
|
|
7475ae323c | ||
|
|
faf7f3ccbf | ||
|
|
4940d1ca33 | ||
|
|
3d48fa5741 | ||
|
|
f9887cffae | ||
|
|
6644907665 | ||
|
|
5f850685d6 | ||
|
|
5f9674e49c | ||
|
|
0d185c6db3 | ||
|
|
53d22dd22d | ||
|
|
ff8ffda3c6 | ||
|
|
64bd540322 | ||
|
|
919f9a48f3 | ||
|
|
746d442051 | ||
|
|
1877b75188 | ||
|
|
6e8c38cace | ||
|
|
eab7bab267 | ||
|
|
aab648c3cf | ||
|
|
f79ff509bd | ||
|
|
1197e990ca | ||
|
|
dce1c0715e | ||
|
|
6a0263c5bc | ||
|
|
ca64db0499 | ||
|
|
a5d4eda4d1 | ||
|
|
5d210961c1 | ||
|
|
1b88f565af | ||
|
|
991a98b571 | ||
|
|
0073277d6e | ||
|
|
eeca602f7a | ||
|
|
6c171560fd | ||
|
|
66c4c00215 | ||
|
|
9b9ef9ab74 | ||
|
|
39a289e7f1 | ||
|
|
722c829502 | ||
|
|
7ecb80d136 | ||
|
|
ea19af04d4 | ||
|
|
8196b69211 | ||
|
|
dc861caf6c | ||
|
|
adb5ffa8d0 | ||
|
|
d918cb28bd | ||
|
|
7ce7314ab9 | ||
|
|
13e5caa0ef | ||
|
|
ff59a7a89f | ||
|
|
c3efa4d004 | ||
|
|
ed50e1300a | ||
|
|
86dbfd54d1 | ||
|
|
535120eebd | ||
|
|
c1106d7186 | ||
|
|
45be7f2c9b | ||
|
|
d6baf3d1c8 | ||
|
|
08c38c1723 | ||
|
|
af4fa454d3 | ||
|
|
0620582a4e | ||
|
|
b11c07e3d1 | ||
|
|
593b34079c | ||
|
|
becb533624 | ||
|
|
8efc0522f2 | ||
|
|
cead924ca5 | ||
|
|
f83a043664 | ||
|
|
e8a0bca5ea | ||
|
|
1198c2298a | ||
|
|
7205acb9d6 | ||
|
|
d21cfd55ab | ||
|
|
47cbc3624c | ||
|
|
1f9a0886a0 | ||
|
|
dd5ea68915 | ||
|
|
b3bba4d273 | ||
|
|
10c123ba6a | ||
|
|
a8ba45b941 | ||
|
|
3652cdf6bc | ||
|
|
f2a7a8c439 | ||
|
|
78d5a99441 | ||
|
|
6931dbe79c | ||
|
|
4d024c06cc | ||
|
|
ddcb190457 | ||
|
|
dd14b90d7e | ||
|
|
4b86444478 | ||
|
|
feb7f260dc | ||
|
|
74c7a1de4d | ||
|
|
88a43dc679 | ||
|
|
1bb5ce72fa | ||
|
|
b4ce544965 | ||
|
|
1ec6f6173a | ||
|
|
8ee19b3f5c | ||
|
|
1055392b7f | ||
|
|
c772cf2ead | ||
|
|
481c50f465 | ||
|
|
71bc969f2a | ||
|
|
e4edebfed7 | ||
|
|
e8a5ab8307 | ||
|
|
3738f3af21 | ||
|
|
74d10e4199 | ||
|
|
080e00becf | ||
|
|
049d905d7d | ||
|
|
33094f8c88 | ||
|
|
6c44e503db | ||
|
|
fa78c80592 | ||
|
|
07630ca97b | ||
|
|
a2b6d4e570 | ||
|
|
9d6b3ddf81 | ||
|
|
0a2769859a | ||
|
|
c4a1ed801a | ||
|
|
453394bf1b | ||
|
|
4b7dfba5a1 | ||
|
|
e699fcf0b3 | ||
|
|
7e80f707e0 | ||
|
|
467f037170 | ||
|
|
89d5b40e5f | ||
|
|
34fba010e1 | ||
|
|
d7396bb044 | ||
|
|
fda0817ad1 | ||
|
|
895ca75506 | ||
|
|
a04448ebe8 | ||
|
|
26ccbf2709 | ||
|
|
7d6c11a88c | ||
|
|
8742913c33 | ||
|
|
8e6e0f0099 | ||
|
|
a4585de807 | ||
|
|
6c24749ad5 | ||
|
|
c73509a4ca | ||
|
|
673b85b2aa | ||
|
|
fe6e60cd67 | ||
|
|
8bcee90d68 | ||
|
|
084407e129 | ||
|
|
4a3db5ae20 | ||
|
|
b36813ebe6 | ||
|
|
cc1ddfa16e | ||
|
|
5f1775d478 | ||
|
|
288e35dd64 | ||
|
|
d4af28d1c5 | ||
|
|
37cf85a5f6 | ||
|
|
c2cbd76f49 | ||
|
|
3d874435c3 | ||
|
|
9ed8864f23 | ||
|
|
61263dd59d | ||
|
|
2707e135c6 | ||
|
|
f9de0d7937 | ||
|
|
f03d58d648 | ||
|
|
f49a3570e9 | ||
|
|
1d97f9008d | ||
|
|
e85ca9114c | ||
|
|
85ed2da518 | ||
|
|
dcc91f75cc | ||
|
|
a40c160ac6 | ||
|
|
e6861c8436 | ||
|
|
e6a5d97fb8 | ||
|
|
ddeb209d51 | ||
|
|
3283b3a607 | ||
|
|
83a41ca6ce | ||
|
|
6c63eb7d66 | ||
|
|
7cf9de8c2a | ||
|
|
a859682954 | ||
|
|
c844c4f896 | ||
|
|
a49cfe91da | ||
|
|
2bacba2c87 | ||
|
|
e473981063 | ||
|
|
34ea4f216c | ||
|
|
52e34b3027 | ||
|
|
c6a6ea0445 | ||
|
|
59ae6340e1 | ||
|
|
cbf2aa2311 | ||
|
|
94b0c7bc01 | ||
|
|
4c50ffac19 | ||
|
|
551e736651 | ||
|
|
0380e35966 | ||
|
|
5de0906fc1 | ||
|
|
c2f17b6230 | ||
|
|
6a3bbe6c0d | ||
|
|
82307c9f98 | ||
|
|
d2ec0e2aa1 | ||
|
|
3951b1080d | ||
|
|
ef7caeeead | ||
|
|
7ef8e2029e | ||
|
|
aaec6ac6a3 | ||
|
|
731960da7c | ||
|
|
ac282d2667 | ||
|
|
7a79601cfc | ||
|
|
d1167e4d2b | ||
|
|
613634adcf | ||
|
|
acbe33c66d | ||
|
|
053ebbd70b | ||
|
|
f5dc4fa4e7 | ||
|
|
343270b757 | ||
|
|
65f5626aba | ||
|
|
a051a73c2b | ||
|
|
6840997793 | ||
|
|
2c98ed2d8d | ||
|
|
6a083c4152 | ||
|
|
b60b5d16c3 | ||
|
|
52cfe8dc12 | ||
|
|
737afca031 | ||
|
|
456f41d28d | ||
|
|
238f59ad71 | ||
|
|
cf6d567193 | ||
|
|
20f8f3852d | ||
|
|
4bb9f5cb43 | ||
|
|
540a841255 | ||
|
|
3544637405 | ||
|
|
651448dfa1 | ||
|
|
4bac266b8b | ||
|
|
f86b61741d | ||
|
|
6c60d299af | ||
|
|
08582238c3 | ||
|
|
b931d0ce7d | ||
|
|
5e1fc9dbd8 | ||
|
|
de4e6eee25 | ||
|
|
d5b4e6990f | ||
|
|
26703815b2 | ||
|
|
40c36df414 | ||
|
|
6eb20d0e08 | ||
|
|
cc3055f1c9 | ||
|
|
25a1eac43b | ||
|
|
ff30e7f6a4 | ||
|
|
3fcc01597d | ||
|
|
cbc4a662e6 | ||
|
|
5aa0513324 | ||
|
|
4d1f142f9c | ||
|
|
e9c8f9432f | ||
|
|
56c375f344 | ||
|
|
5b165a2339 | ||
|
|
bfd3c711ab | ||
|
|
4627e284fa | ||
|
|
ea8ac783a8 | ||
|
|
966dd2bf2c | ||
|
|
364de592fa | ||
|
|
d38241f0d1 | ||
|
|
e217be6b67 | ||
|
|
37f84f0399 | ||
|
|
b618b9fa2b | ||
|
|
37b893103d | ||
|
|
e2d4852df7 | ||
|
|
1e0298d73a | ||
|
|
64c13295d6 | ||
|
|
0261ece709 | ||
|
|
a5799347ad | ||
|
|
6c7c4d1a88 | ||
|
|
f5390316a7 | ||
|
|
da1ea77aa9 | ||
|
|
8ea48977ae | ||
|
|
6721db54e2 | ||
|
|
6a7079c8b2 | ||
|
|
8cc7e9d6c9 | ||
|
|
d0ac41c242 | ||
|
|
bc8f476ef1 | ||
|
|
2d01b63cfe | ||
|
|
88dc31e9af | ||
|
|
8d1e5eb64d | ||
|
|
8113ef3f8a | ||
|
|
a74ed0e93b | ||
|
|
11f42bf71e | ||
|
|
8eb96025ec | ||
|
|
1ece7ff433 | ||
|
|
e312c451f8 | ||
|
|
bb64e91648 | ||
|
|
69398f6a2c | ||
|
|
bef7aa0ae9 | ||
|
|
2776696501 | ||
|
|
fa075df278 | ||
|
|
05311fd3a1 | ||
|
|
79001239d9 | ||
|
|
e344733bf0 | ||
|
|
282fdbb903 | ||
|
|
ee7c571101 | ||
|
|
87e42d6b7e | ||
|
|
8fcf135280 | ||
|
|
ae9364ad7e | ||
|
|
6aa44d8a9e | ||
|
|
3f013d1272 | ||
|
|
94d1f5a4eb | ||
|
|
1d8a7d838b | ||
|
|
c5d441fa1f | ||
|
|
4276a78a81 | ||
|
|
36c24a448f | ||
|
|
4bf1051549 | ||
|
|
fc4ab3128c | ||
|
|
65d32ea13e | ||
|
|
4cd8c80226 | ||
|
|
7adcdc43cf | ||
|
|
77852dc135 | ||
|
|
746ca62ca7 | ||
|
|
5e993f0fcc | ||
|
|
168dbba62c | ||
|
|
4db7bf814c | ||
|
|
21a3ff318b | ||
|
|
116de67d4c | ||
|
|
c6b8dfd539 | ||
|
|
37f33e9943 | ||
|
|
4bae7fdf94 | ||
|
|
c455bde154 | ||
|
|
5aa4321787 | ||
|
|
27a2100c72 | ||
|
|
4fc82c6527 | ||
|
|
56486ad274 | ||
|
|
99a38e655b | ||
|
|
262050147d | ||
|
|
5ff2e608c2 | ||
|
|
4e305faf5b | ||
|
|
0bdbb843fb | ||
|
|
c8736ad26e | ||
|
|
57d6b72f5a | ||
|
|
d0117b14db | ||
|
|
6729842ed8 | ||
|
|
723ade8ba6 | ||
|
|
83066232b6 | ||
|
|
4dc0b19c5d | ||
|
|
a58cc820ef | ||
|
|
2b3397bc85 | ||
|
|
a519b5c0b1 | ||
|
|
fb3a34c871 | ||
|
|
a1bc3fcd7e | ||
|
|
7daf3c6f55 | ||
|
|
7d032179ef | ||
|
|
156507f8f7 | ||
|
|
032a1927db | ||
|
|
f24bf570ef | ||
|
|
75c2ece016 | ||
|
|
0c1c1a6c79 | ||
|
|
5af25a9d43 | ||
|
|
55fec0f578 | ||
|
|
b61fc3a148 | ||
|
|
e3cd0fc2b1 | ||
|
|
fe01f50c65 | ||
|
|
cd378d16e3 | ||
|
|
e951fabf1c | ||
|
|
48543a48fb | ||
|
|
2699893581 | ||
|
|
21914a0bd7 | ||
|
|
d83667682d | ||
|
|
a5dc01f589 | ||
|
|
fb497cebfe | ||
|
|
9ffaba4358 | ||
|
|
be85307fe8 | ||
|
|
b55961bd83 | ||
|
|
f4911394ba | ||
|
|
42cf11358e | ||
|
|
6e6ed07890 | ||
|
|
22327bf33e | ||
|
|
57d8bc3311 | ||
|
|
6589799a2a | ||
|
|
7d6370163b | ||
|
|
9a5d63b7fc | ||
|
|
2d872a57ee | ||
|
|
f9c0850acd | ||
|
|
994ec732a4 | ||
|
|
b44770c77f | ||
|
|
7ea836e249 | ||
|
|
16d2401e38 | ||
|
|
259dc4c7cc | ||
|
|
3bcd67b8fb | ||
|
|
648d9103b7 | ||
|
|
faac434d33 | ||
|
|
f558cc49f7 | ||
|
|
5add227e55 | ||
|
|
4519a5d174 | ||
|
|
095bed4482 | ||
|
|
07dc95b639 | ||
|
|
edc3ebcff1 | ||
|
|
0f7055ca5b | ||
|
|
f426321e15 | ||
|
|
70d5cb3e2b | ||
|
|
15e4dca984 | ||
|
|
3a7221d71b | ||
|
|
e8cb3afb34 | ||
|
|
2b7a580001 | ||
|
|
b5d327581b | ||
|
|
c0ca45e949 | ||
|
|
4acc107d3a | ||
|
|
1070dba0ae | ||
|
|
7ae5d48767 | ||
|
|
e5c05fac48 | ||
|
|
f7c4b94546 | ||
|
|
a58af97216 | ||
|
|
3759a9703a | ||
|
|
2d3ed191fd | ||
|
|
425817b896 | ||
|
|
aaf3be2f7b | ||
|
|
bc810c80d6 | ||
|
|
e7a6f6f921 | ||
|
|
26542abc4d | ||
|
|
46fd7f40d4 | ||
|
|
40eaa80f4b | ||
|
|
ea8f93061d | ||
|
|
2ec2593704 | ||
|
|
c4949c7794 | ||
|
|
7572a0da5a | ||
|
|
678b9c3184 | ||
|
|
2900b18cce | ||
|
|
580e78afab | ||
|
|
ace430abe6 | ||
|
|
54c6089bdc | ||
|
|
8b308abfb8 | ||
|
|
53696970a7 | ||
|
|
18e2d8ad5e | ||
|
|
46cf9ad4ad | ||
|
|
a11f560183 | ||
|
|
23fbde6df4 | ||
|
|
512e4988d2 | ||
|
|
eb41a5e529 | ||
|
|
cefc126ffe | ||
|
|
29286efbd4 | ||
|
|
ea30ad5974 | ||
|
|
5f30cca79b | ||
|
|
d76cf4457e | ||
|
|
88d58f4344 | ||
|
|
93819b3afd | ||
|
|
7b438db34f | ||
|
|
f526d797f8 | ||
|
|
05f7b07449 | ||
|
|
ddf7c66933 | ||
|
|
715a52b291 | ||
|
|
660adb4a6f | ||
|
|
e47a1e0bf2 | ||
|
|
7b2044d2a4 | ||
|
|
1d3c961c3c | ||
|
|
dc59a1270f | ||
|
|
7452efa047 | ||
|
|
8517f74c6d | ||
|
|
637a62ea21 | ||
|
|
16f270fb9f | ||
|
|
c4f016c912 | ||
|
|
e63bc44055 | ||
|
|
99c8e14773 | ||
|
|
d84fb51f6f | ||
|
|
a8309ffaf5 | ||
|
|
fd97ba3ae9 | ||
|
|
305e62746c | ||
|
|
bf57de9d96 | ||
|
|
07e52d2a83 | ||
|
|
36a0450c1d | ||
|
|
f49e8134dd | ||
|
|
a54037270b | ||
|
|
4a6b091496 | ||
|
|
03addf41c7 | ||
|
|
9440855bf2 | ||
|
|
d53b1b94e5 | ||
|
|
16ebf7bb11 | ||
|
|
c8e7194a94 | ||
|
|
c6527fc57a | ||
|
|
bf906479d8 | ||
|
|
938512f826 | ||
|
|
bbc068b889 | ||
|
|
0ae9fd44d2 | ||
|
|
d266b9f55b | ||
|
|
57691fcd99 | ||
|
|
8cd41aae27 | ||
|
|
8ac3efeedc | ||
|
|
642c80779a | ||
|
|
17d43fcb7e | ||
|
|
6bc67dd303 | ||
|
|
2926225133 | ||
|
|
8fe078cc29 | ||
|
|
b721a52584 | ||
|
|
e7eeb0bacd | ||
|
|
710abb1206 | ||
|
|
82c3efba07 | ||
|
|
12a3b50e35 | ||
|
|
48884bc2de | ||
|
|
d02689fc67 | ||
|
|
9751b18c54 | ||
|
|
f6a4ca42b1 | ||
|
|
0f2d6bfa9b | ||
|
|
84a7b930a8 | ||
|
|
7549ecbf45 | ||
|
|
99f6150bdc | ||
|
|
dab8aec81c | ||
|
|
b0ddacbe89 | ||
|
|
530923640c | ||
|
|
c977d2ed86 | ||
|
|
8459d10dc7 | ||
|
|
60836ec5ec | ||
|
|
20cd4affee | ||
|
|
120c3ca52f | ||
|
|
455dadd30d | ||
|
|
01534caf13 | ||
|
|
4186081fdc | ||
|
|
88a7a9b6b1 | ||
|
|
b4267d8d8b | ||
|
|
fdac63a299 | ||
|
|
0a210b6e09 | ||
|
|
945308dfbc | ||
|
|
aa285f90ae | ||
|
|
64bf12718a | ||
|
|
dd9677ea3b | ||
|
|
ea60df592f | ||
|
|
c140aa32b6 | ||
|
|
9d6cf369d6 | ||
|
|
41c124e042 | ||
|
|
eca962ad68 | ||
|
|
89c653e613 | ||
|
|
964ed2d129 | ||
|
|
6a1287d1b0 | ||
|
|
d3f4abc50e | ||
|
|
20da1b6461 | ||
|
|
044947d4ae | ||
|
|
a2c0851ac7 | ||
|
|
7e136faea5 | ||
|
|
309b1e70e6 | ||
|
|
e2399c257d | ||
|
|
c892b51ff8 | ||
|
|
8b3a0d22be | ||
|
|
f4fe9294f0 | ||
|
|
67a2b76e41 | ||
|
|
499e406c5d | ||
|
|
90ccf18fbf | ||
|
|
7f57447e57 | ||
|
|
10beb9935f | ||
|
|
5fc2e1247b | ||
|
|
67d4e97582 | ||
|
|
abeadd858e | ||
|
|
5a737ce38d | ||
|
|
97f1b530b2 | ||
|
|
f1393ae707 | ||
|
|
0c274617cb | ||
|
|
f33a8c3829 | ||
|
|
c243645124 | ||
|
|
4655678481 | ||
|
|
cec8ddeeee | ||
|
|
8d987a02aa | ||
|
|
a6d87d570f | ||
|
|
f3b07be01f | ||
|
|
07f23ba927 | ||
|
|
7a7e96388b | ||
|
|
73d91f7268 | ||
|
|
6371296b28 | ||
|
|
cdeadf9d6d | ||
|
|
c332acb2c1 | ||
|
|
0d68f1a24b | ||
|
|
1666ea88fc | ||
|
|
ff163a31bf | ||
|
|
73d469dc8d | ||
|
|
d0226ab4cc | ||
|
|
3d1b07f11c | ||
|
|
f98d7c26dc | ||
|
|
c5fca74e39 | ||
|
|
f79ad3dabc | ||
|
|
c5ebfa5021 | ||
|
|
534a966ee8 | ||
|
|
7484596fb4 | ||
|
|
1637752b02 | ||
|
|
4ce424d4db | ||
|
|
916af88c53 | ||
|
|
b21776c517 | ||
|
|
6bb128e38a | ||
|
|
8b2694efb7 | ||
|
|
f853132e9b | ||
|
|
39e8d5513a | ||
|
|
6feadf73dd | ||
|
|
d683c48338 | ||
|
|
4a684b0bec | ||
|
|
6d7768e904 | ||
|
|
a645c4530f | ||
|
|
4d61462290 | ||
|
|
877ce8d008 | ||
|
|
fbff91774e | ||
|
|
53fb072373 | ||
|
|
f30f1f47d5 | ||
|
|
d8b0e89c6c | ||
|
|
a353f13ebb | ||
|
|
0d3415441f | ||
|
|
860d509d0f | ||
|
|
c86fdec8e6 | ||
|
|
ca6fedd05c | ||
|
|
07209a79de | ||
|
|
4132416f0d | ||
|
|
e62d5741c2 | ||
|
|
81dca20b17 | ||
|
|
f203f63c36 | ||
|
|
26cd218ec0 | ||
|
|
e402a0376a | ||
|
|
bac202d4ec | ||
|
|
bb8d856d17 | ||
|
|
42075291ce | ||
|
|
32b128fe40 | ||
|
|
df63ab5f91 | ||
|
|
88e3670493 | ||
|
|
eceeed8290 | ||
|
|
caa9c80d44 | ||
|
|
7e76e47d77 | ||
|
|
ba76c9c17e | ||
|
|
9555c6fa76 | ||
|
|
c37a6f5c27 | ||
|
|
b5af71d798 | ||
|
|
8f609fa900 | ||
|
|
5329154121 | ||
|
|
3a9187d795 | ||
|
|
e4e23e8017 | ||
|
|
9638ad4f06 | ||
|
|
c8de700460 | ||
|
|
e0f746b5ae | ||
|
|
9efcc36e15 | ||
|
|
918a7e64bd | ||
|
|
7f6874b791 | ||
|
|
1731462b41 | ||
|
|
654d50cd1b | ||
|
|
f631dd5c7b | ||
|
|
4c5558fa29 | ||
|
|
2892abc7a8 | ||
|
|
529385bc5b | ||
|
|
e3bb5d0fb5 | ||
|
|
2da930cd41 | ||
|
|
f41983a7b6 | ||
|
|
198791ca27 | ||
|
|
5b02ed9b0b | ||
|
|
760bad821b | ||
|
|
b8b2aab9bb | ||
|
|
a2b08606f1 | ||
|
|
5d40bd6f8e | ||
|
|
91639d887f | ||
|
|
6d234672b8 | ||
|
|
4e22b53907 | ||
|
|
f389e315a6 | ||
|
|
7f54c02a1c | ||
|
|
eaaa2b97b4 | ||
|
|
d1362f2ea3 | ||
|
|
2c56c78467 | ||
|
|
ec928c943d | ||
|
|
53bfba0320 | ||
|
|
847c3e85fa | ||
|
|
c96b4afcc7 | ||
|
|
4c741b9ac9 | ||
|
|
6b184c49ad | ||
|
|
6991b99ea9 | ||
|
|
0cc2b4e368 | ||
|
|
c51f834636 | ||
|
|
9a567ff5d0 | ||
|
|
bb420542ef | ||
|
|
14ec13a2e6 | ||
|
|
bf2b038632 | ||
|
|
b2fa6bb3a9 | ||
|
|
53166d9bba | ||
|
|
1560e44d36 | ||
|
|
1dbc8847b1 | ||
|
|
8bbfd1007d | ||
|
|
851e117381 | ||
|
|
2e31a7fbdb | ||
|
|
f3316160fb | ||
|
|
48b92ed2a6 | ||
|
|
4d075095ad | ||
|
|
9c1985bab3 | ||
|
|
e11e1a0d5b | ||
|
|
f202797954 | ||
|
|
f1ee7586f9 | ||
|
|
6cc74488a3 | ||
|
|
dbf9760780 | ||
|
|
6de1e41628 | ||
|
|
9977aac9f6 | ||
|
|
eb4995da86 | ||
|
|
dffff47a9f | ||
|
|
96cc982e01 | ||
|
|
116ab4fcfb | ||
|
|
c9c0249d4f | ||
|
|
85833f91e3 | ||
|
|
b76498852e | ||
|
|
e75b0e51d9 | ||
|
|
6b746bc0b3 | ||
|
|
dd31a59524 | ||
|
|
ca75b44d3b | ||
|
|
d9a9a310a8 | ||
|
|
8ece8cc14d | ||
|
|
425a83faec | ||
|
|
f034b313b3 | ||
|
|
b600cbdc34 | ||
|
|
ad3fce5b17 | ||
|
|
25604657b6 | ||
|
|
996ff027e5 | ||
|
|
71c595df15 | ||
|
|
70d00b7d62 | ||
|
|
e8828d8658 | ||
|
|
e08f6ee73c | ||
|
|
f12460e83a | ||
|
|
baef12a26d | ||
|
|
79400dd2b1 | ||
|
|
4409849143 | ||
|
|
3d77756da0 | ||
|
|
d45dac4587 | ||
|
|
38292bcbcc | ||
|
|
8b8cf9cd7a | ||
|
|
7c969cbe93 | ||
|
|
3283cc447e | ||
|
|
810ba74e75 | ||
|
|
5e1a20c5de | ||
|
|
975c59a114 | ||
|
|
51fcf04b0b | ||
|
|
d921347d73 | ||
|
|
5e25b542fb | ||
|
|
9b4ef98a3d | ||
|
|
8a862439cc | ||
|
|
6719953cf1 | ||
|
|
2bf73eb961 | ||
|
|
fe5d711fea | ||
|
|
33c8aaf36f | ||
|
|
d5366b10fa | ||
|
|
50d07fd31f | ||
|
|
792d64a33a | ||
|
|
adc9550e58 | ||
|
|
0638b9f133 | ||
|
|
05531e0bc5 | ||
|
|
44ec2270f2 | ||
|
|
ffd4f474ed | ||
|
|
2c22780c91 | ||
|
|
1d03d09119 | ||
|
|
404647c4cb | ||
|
|
c0b464ae36 | ||
|
|
e8185e0f9c | ||
|
|
0592c42df0 | ||
|
|
87a50c494f | ||
|
|
8257d7b41d | ||
|
|
77e471d671 | ||
|
|
92f5e6e77c | ||
|
|
4b7be60c27 | ||
|
|
e9abbf256e | ||
|
|
002d8c7430 | ||
|
|
346c7a027d | ||
|
|
7313e2d1c4 | ||
|
|
a34a8136c2 | ||
|
|
3b76dca8f1 | ||
|
|
30682bf8f5 | ||
|
|
e7b83326d0 | ||
|
|
ef55bd2719 | ||
|
|
0c29785a7e | ||
|
|
a5b67d4923 | ||
|
|
34a4df96fc | ||
|
|
eeacbbb979 | ||
|
|
2a010e2643 | ||
|
|
c25785ccf4 | ||
|
|
050fc2b29e | ||
|
|
e1e8fa410a | ||
|
|
becf21b7ea | ||
|
|
9c3f2f44da | ||
|
|
793541474a | ||
|
|
94f9ad6cc4 | ||
|
|
9a89d4c44c | ||
|
|
b99ffa0395 | ||
|
|
f926dc28be | ||
|
|
5b92d477e2 | ||
|
|
df561cc582 | ||
|
|
da60aeb71b | ||
|
|
684f4867c3 | ||
|
|
82a7846e6d | ||
|
|
a9199661a4 | ||
|
|
d07fc29a96 | ||
|
|
066919259c | ||
|
|
a094ba7d5c | ||
|
|
76a9485f0b | ||
|
|
413ef66701 | ||
|
|
1e91a53a8a | ||
|
|
0db7e51d69 | ||
|
|
cdf7f75058 | ||
|
|
84e4151f42 | ||
|
|
3a9729de06 | ||
|
|
93e8882433 | ||
|
|
56a49e323a | ||
|
|
de97703128 | ||
|
|
f820d19f55 | ||
|
|
a2094e9953 | ||
|
|
e5000f6502 | ||
|
|
9d63c50a2d | ||
|
|
ee90951945 | ||
|
|
8ed87d0739 | ||
|
|
1ebac0df21 | ||
|
|
a4e6025607 | ||
|
|
6ef03b8921 | ||
|
|
fdd6c87a31 | ||
|
|
89bfc845f6 | ||
|
|
9af5c0e0f4 | ||
|
|
8e92b21d60 | ||
|
|
9882d9d1c9 | ||
|
|
55275e48de | ||
|
|
3da896d369 | ||
|
|
745aa61466 | ||
|
|
2672144dbe | ||
|
|
ccbad4be1b | ||
|
|
dad3b86ba7 | ||
|
|
cfb81fc530 | ||
|
|
56afde24db | ||
|
|
88fdc1b503 | ||
|
|
338cd20132 | ||
|
|
ad38a09052 | ||
|
|
078e010c54 | ||
|
|
4ae4a7366a | ||
|
|
bfefc53040 | ||
|
|
f8af04ba4b | ||
|
|
e8a572032a | ||
|
|
5ef300b4a4 | ||
|
|
5e3275e547 | ||
|
|
5a55beee7b | ||
|
|
b8e52e2117 | ||
|
|
541f824909 | ||
|
|
4e763be6ec | ||
|
|
afaa00d635 | ||
|
|
1aa03edf6e | ||
|
|
cafada6ede | ||
|
|
36e0127e2b | ||
|
|
0af369bf23 | ||
|
|
a133f7d82d | ||
|
|
f66b8affb1 | ||
|
|
45ab233d01 | ||
|
|
676617ef19 | ||
|
|
af3baa99b8 | ||
|
|
33abefdd14 | ||
|
|
1cbebd0c9e | ||
|
|
245942ff14 | ||
|
|
608a08d2e8 | ||
|
|
fbb0d7090b | ||
|
|
40c890e644 | ||
|
|
35cf4255a6 | ||
|
|
0da47c409f | ||
|
|
541f582ac1 | ||
|
|
191bc33fa3 | ||
|
|
31168d9ed8 | ||
|
|
468c41c526 | ||
|
|
bc684b6ae3 | ||
|
|
399ec8d108 | ||
|
|
1820710f06 | ||
|
|
51d86148e8 | ||
|
|
e8f973531b | ||
|
|
4a01cf0608 | ||
|
|
929a057e1e | ||
|
|
d24a18023d | ||
|
|
4d8085a0db | ||
|
|
8c3ca2161d | ||
|
|
26720dead0 | ||
|
|
cda7e81485 | ||
|
|
0cffb26dfc | ||
|
|
d21e4aa830 | ||
|
|
a5dfe0c586 | ||
|
|
00f4745d46 | ||
|
|
062e7cef24 | ||
|
|
efc710d796 | ||
|
|
fd2d20af94 | ||
|
|
51065d1b57 | ||
|
|
6a60ce07e9 | ||
|
|
7c8f9a6662 | ||
|
|
ed61f470f7 | ||
|
|
a89d8ac229 | ||
|
|
3c8e7d13e0 | ||
|
|
7d2e4c1e8c | ||
|
|
4fbf90654e | ||
|
|
077af85181 | ||
|
|
1b77a8dd8b | ||
|
|
28071a10b5 | ||
|
|
1a6e3bf214 | ||
|
|
16db19fac7 | ||
|
|
c533e7832b | ||
|
|
0cd33ddada | ||
|
|
140d405aa9 | ||
|
|
ceeef6324e | ||
|
|
f850be1eca | ||
|
|
28c5b01596 | ||
|
|
59f5b5ede3 | ||
|
|
8db8083e32 | ||
|
|
a2c3f36065 | ||
|
|
0483e67026 | ||
|
|
872fafbb50 | ||
|
|
4d57d72980 | ||
|
|
77f5d5cf05 | ||
|
|
5e6dfb18f7 | ||
|
|
fe8b7ec5b3 | ||
|
|
f6503dc367 | ||
|
|
491782a88e | ||
|
|
13fb52478f | ||
|
|
15125159bb | ||
|
|
614069e342 | ||
|
|
48350ff175 | ||
|
|
3d3f1e0ff0 | ||
|
|
6abf511ef4 | ||
|
|
fffa136b3f | ||
|
|
8c4c554a1c | ||
|
|
5c1e542dab | ||
|
|
766290a2a3 | ||
|
|
3706bc5936 | ||
|
|
351e39826b | ||
|
|
808217d41e | ||
|
|
1c8f75ec88 | ||
|
|
296f8b2363 | ||
|
|
4960b9e2ec | ||
|
|
3bba3c5689 | ||
|
|
297b2e0826 | ||
|
|
9ed8a67c5c | ||
|
|
b8ad99b2a1 | ||
|
|
68cec1659a | ||
|
|
a7264e506a | ||
|
|
90d17604fc | ||
|
|
77a86da984 | ||
|
|
41becae272 | ||
|
|
21640e4264 | ||
|
|
1366dc0996 | ||
|
|
c6129ffc31 | ||
|
|
d018e9b577 | ||
|
|
496ec53f8a | ||
|
|
b9e0065aad | ||
|
|
a4798c3cf9 | ||
|
|
7a335515f6 | ||
|
|
a8457a748a | ||
|
|
bb7fa61c33 | ||
|
|
5d8d832e99 | ||
|
|
0bb215a803 | ||
|
|
173920d9eb | ||
|
|
1fb5ce87ea | ||
|
|
43deedd994 | ||
|
|
2d72afe1f0 | ||
|
|
a90c795891 | ||
|
|
1e32b6e875 | ||
|
|
0f454b562d | ||
|
|
db86a723a5 | ||
|
|
c0818b056d |
No files matched your search
@@ -0,0 +1,32 @@
|
||||
## PR Checklist
|
||||
|
||||
<!-- For the checkbox formatting to work properly, make sure there are no spaces on either side of the "x" -->
|
||||
|
||||
Please check all that apply to this PR using "x":
|
||||
|
||||
- [ ] I have checked that this PR is not a duplicate of an existing PR (open, closed or merged)
|
||||
- [ ] I have checked that this PR does not introduce a breaking change
|
||||
- [ ] This PR introduces breaking changes and I have provided a detailed explanation below
|
||||
|
||||
## PR Type
|
||||
|
||||
What kind of change does this PR introduce?
|
||||
|
||||
- [ ] Bugfix
|
||||
- [ ] Feature
|
||||
- [ ] Code style update (formatting)
|
||||
- [ ] Refactoring (no functional changes)
|
||||
- [ ] Documentation changes
|
||||
- [ ] Other - Please describe:
|
||||
|
||||
## Fixes
|
||||
|
||||
Issue Number:
|
||||
|
||||
## What is the current behavior?
|
||||
|
||||
## What is the new behavior?
|
||||
|
||||
## Other information
|
||||
|
||||
<!-- If this PR contains a breaking change, please describe the impact and solution strategy for existing applications below. -->
|
||||
@@ -0,0 +1,55 @@
|
||||
<!--
|
||||
Thanks for reporting an issue to LBRY and helping us improve!
|
||||
|
||||
To make it possible for us to help you, please fill out below information carefully.
|
||||
|
||||
Before reporting any issues, please make sure that you're using the latest version.
|
||||
|
||||
We are also available on live chat at https://chat.lbry.com
|
||||
-->
|
||||
|
||||
|
||||
## The Issue
|
||||
|
||||
### Steps to reproduce
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
### Expected behaviour
|
||||
Tell us what should happen
|
||||
|
||||
### Actual behaviour
|
||||
Tell us what happens instead
|
||||
|
||||
|
||||
## System Configuration
|
||||
- Device:
|
||||
- Android version:
|
||||
|
||||
|
||||
## Anything Else
|
||||
<!-- Include anything else that does not fit into the above sections -->
|
||||
|
||||
|
||||
## Screenshots
|
||||
<!-- If a screenshot would help explain the bug, please include one or two here -->
|
||||
|
||||
## Internal Use
|
||||
|
||||
### Acceptance Criteria
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
### Definition of Done
|
||||
- [ ] Tested against acceptance criteria
|
||||
- [ ] Tested against the assumptions of the user story
|
||||
- [ ] The project builds without errors
|
||||
- [ ] Unit tests are written and passing
|
||||
- [ ] Tests on devices/browsers listed in the issue have passed
|
||||
- [ ] QA performed & issues resolved
|
||||
- [ ] Refactoring completed
|
||||
- [ ] Any configuration or build changes documented
|
||||
- [ ] Documentation updated
|
||||
- [ ] Peer Code Review performed
|
||||
+68
-8
@@ -1,9 +1,69 @@
|
||||
.buildozer
|
||||
app/node_modules/
|
||||
bin
|
||||
buildozer.spec
|
||||
build.log
|
||||
recipes/**/*.pyc
|
||||
src/main/assets/index.android.bundle
|
||||
src/main/assets/index.android.bundle.meta
|
||||
# OSX
|
||||
#
|
||||
.DS_Store
|
||||
|
||||
# Xcode
|
||||
#
|
||||
build/
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
xcuserdata
|
||||
*.xccheckout
|
||||
*.moved-aside
|
||||
DerivedData
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.xcuserstate
|
||||
|
||||
# Android/IntelliJ
|
||||
#
|
||||
build/
|
||||
.idea
|
||||
.gradle
|
||||
local.properties
|
||||
*.iml
|
||||
|
||||
# node.js
|
||||
#
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
|
||||
# BUCK
|
||||
buck-out/
|
||||
\.buckd/
|
||||
*.keystore
|
||||
!debug.keystore
|
||||
|
||||
# fastlane
|
||||
#
|
||||
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
|
||||
# screenshots whenever they are needed.
|
||||
# For more information about the recommended setup visit:
|
||||
# https://docs.fastlane.tools/best-practices/source-control/
|
||||
|
||||
*/fastlane/report.xml
|
||||
*/fastlane/Preview.html
|
||||
*/fastlane/screenshots
|
||||
|
||||
# Bundle artifact
|
||||
*.jsbundle
|
||||
|
||||
# CocoaPods
|
||||
/ios/Pods/
|
||||
|
||||
# Other Files
|
||||
app/google-services.json
|
||||
app/twitter.properties
|
||||
*.log
|
||||
.vagrant
|
||||
*.hprof
|
||||
app/build
|
||||
bin
|
||||
app/debuglib
|
||||
@@ -0,0 +1,75 @@
|
||||
stages:
|
||||
- build
|
||||
- deploy
|
||||
- release
|
||||
|
||||
|
||||
build apk:
|
||||
stage: build
|
||||
image: lbry/android-base:platform-28
|
||||
before_script:
|
||||
- echo "$PGP_PRIVATE_KEY" | gpg --batch --import
|
||||
- echo 'deb https://gitsecret.jfrog.io/artifactory/git-secret-deb git-secret main' >> /etc/apt/sources.list
|
||||
- wget -qO - 'https://gitsecret.jfrog.io/artifactory/api/gpg/key/public' | apt-key add -
|
||||
- apt-get -y update && apt-get -y install build-essential ca-certificates curl git gpg-agent openjdk-8-jdk software-properties-common wget zipalign git-secret
|
||||
- git secret reveal
|
||||
- chmod u+x $CI_PROJECT_DIR/gradlew
|
||||
- export BUILD_VERSION=$($CI_PROJECT_DIR/gradlew -p $CI_PROJECT_DIR -q printVersionName --console=plain | tail -1)
|
||||
artifacts:
|
||||
paths:
|
||||
- bin/browser-*-release__arm.apk
|
||||
- bin/browser-*-release__arm64.apk
|
||||
expire_in: 1 week
|
||||
script:
|
||||
- export PATH=/usr/bin:$PATH
|
||||
- export ANDROID_SDK_ROOT=~/.buildozer/android/platform/android-sdk-23
|
||||
- chmod u+x ./release.sh
|
||||
- ./release.sh
|
||||
- cp bin/browser-$BUILD_VERSION-release__arm.apk /dev/null
|
||||
- cp bin/browser-$BUILD_VERSION-release__arm64.apk /dev/null
|
||||
|
||||
deploy build.lbry.io:
|
||||
image: python:stretch
|
||||
stage: deploy
|
||||
dependencies:
|
||||
- build apk
|
||||
before_script:
|
||||
- apt-get -y update && apt-get -y install apt-transport-https
|
||||
- echo "$PGP_PRIVATE_KEY" | gpg --batch --import
|
||||
- echo 'deb https://gitsecret.jfrog.io/artifactory/git-secret-deb git-secret main' >> /etc/apt/sources.list
|
||||
- wget -qO - 'https://gitsecret.jfrog.io/artifactory/api/gpg/key/public' | apt-key add -
|
||||
- apt-get -y update && apt-get -y install openjdk-8-jdk git git-secret
|
||||
- pip install awscli
|
||||
- chmod u+x $CI_PROJECT_DIR/gradlew
|
||||
- git secret reveal
|
||||
- export BUILD_VERSION=$($CI_PROJECT_DIR/gradlew -p $CI_PROJECT_DIR -q printVersionName --console=plain | tail -1)
|
||||
- export BUILD_APK_FILENAME__32=browser-$BUILD_VERSION-release__arm.apk
|
||||
- export BUILD_APK_FILENAME__64=browser-$BUILD_VERSION-release__arm64.apk
|
||||
script:
|
||||
- aws s3 cp bin/$BUILD_APK_FILENAME__64 s3://build.lbry.io/android/build-${CI_PIPELINE_IID}_commit-${CI_COMMIT_SHA:0:7}/$BUILD_APK_FILENAME__64
|
||||
- aws s3 cp bin/$BUILD_APK_FILENAME__32 s3://build.lbry.io/android/build-${CI_PIPELINE_IID}_commit-${CI_COMMIT_SHA:0:7}/$BUILD_APK_FILENAME__32
|
||||
- aws s3 cp bin/$BUILD_APK_FILENAME__64 s3://build.lbry.io/android/push.apk
|
||||
|
||||
release apk:
|
||||
image: python:stretch
|
||||
stage: release
|
||||
only:
|
||||
- tags
|
||||
dependencies:
|
||||
- build apk
|
||||
before_script:
|
||||
- apt-get -y update && apt-get -y install apt-transport-https
|
||||
- echo "$PGP_PRIVATE_KEY" | gpg --batch --import
|
||||
- echo 'deb https://gitsecret.jfrog.io/artifactory/git-secret-deb git-secret main' >> /etc/apt/sources.list
|
||||
- wget -qO - 'https://gitsecret.jfrog.io/artifactory/api/gpg/key/public' | apt-key add -
|
||||
- apt-get -y update && apt-get -y install openjdk-8-jdk git git-secret
|
||||
- pip install awscli githubrelease
|
||||
- git secret reveal
|
||||
- chmod u+x $CI_PROJECT_DIR/gradlew
|
||||
- export BUILD_VERSION=$($CI_PROJECT_DIR/gradlew -p $CI_PROJECT_DIR -q printVersionName --console=plain | tail -1)
|
||||
- export BUILD_APK_FILENAME__32=browser-$BUILD_VERSION-release__arm.apk
|
||||
- export BUILD_APK_FILENAME__64=browser-$BUILD_VERSION-release__arm64.apk
|
||||
script:
|
||||
- githubrelease release lbryio/lbry-android create $CI_COMMIT_TAG --publish bin/$BUILD_APK_FILENAME__64 bin/$BUILD_APK_FILENAME__32
|
||||
- githubrelease release lbryio/lbry-android edit $CI_COMMIT_TAG --draft
|
||||
- aws s3 cp bin/$BUILD_APK_FILENAME__64 s3://build.lbry.io/android/latest.apk
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
lbry-android.keystore:0d958c531870694624cc877ea98ca1c583485f8ebbb3a5acca58b1930c190d65
|
||||
app/google-services.json:896a0bee8294a36d061f10fa926129d8a780528b34d0a2f03113400c4246d67c
|
||||
app/twitter.properties:01212d70712f2041efb5c814bf30ecbf6f72e1ca5179c7647c4f8cbd995dd033
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
sudo: required
|
||||
dist: trusty
|
||||
language: python
|
||||
python:
|
||||
- "2.7"
|
||||
install:
|
||||
- deactivate
|
||||
- export PATH=/usr/bin:$PATH
|
||||
- sudo dpkg --add-architecture i386
|
||||
- sudo apt-get -qq update
|
||||
- sudo apt-get -qq install build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 m4 libc6-dev-i386 npm nodejs
|
||||
- sudo pip install --upgrade cython==0.25.2 pip setuptools
|
||||
- git clone https://github.com/akinwale/buildozer.git
|
||||
- cd app
|
||||
- npm config set registry="http://registry.npmjs.org/"
|
||||
- npm install --silent --save react@16.2.0 react-native@0.52.0 react-native-video@2.0.0
|
||||
- cd ..
|
||||
- cd buildozer
|
||||
- sudo python setup.py install
|
||||
- cd ..
|
||||
- mv buildozer.spec.travis buildozer.spec
|
||||
- mkdir -p cd ~/.buildozer/android/platform/
|
||||
- wget 'https://dl.google.com/android/repository/android-ndk-r13b-linux-x86_64.zip' -P ~/.buildozer/android/platform/
|
||||
- wget 'https://dl.google.com/android/android-sdk_r23-linux.tgz' -P ~/.buildozer/android/platform/
|
||||
- wget 'https://dl.google.com/android/repository/android-23_r02.zip' -P ~/.buildozer/android/platform/
|
||||
- wget 'https://dl.google.com/android/repository/build-tools_r26.0.1-linux.zip' -P ~/.buildozer/android/platform/
|
||||
- unzip -qq ~/.buildozer/android/platform/android-ndk-r13b-linux-x86_64.zip -d ~/.buildozer/android/platform/
|
||||
- tar -xf ~/.buildozer/android/platform/android-sdk_r23-linux.tgz -C ~/.buildozer/android/platform/
|
||||
- mv ~/.buildozer/android/platform/android-sdk-linux ~/.buildozer/android/platform/android-sdk-23
|
||||
- unzip -qq ~/.buildozer/android/platform/android-23_r02.zip -d ~/.buildozer/android/platform/android-sdk-23/platforms
|
||||
- mv ~/.buildozer/android/platform/android-sdk-23/platforms/android-6.0 ~/.buildozer/android/platform/android-sdk-23/platforms/android-23
|
||||
- mkdir -p ~/.buildozer/android/platform/android-sdk-23/build-tools
|
||||
- unzip -qq ~/.buildozer/android/platform/build-tools_r26.0.1-linux.zip -d ~/.buildozer/android/platform/android-sdk-23/build-tools
|
||||
- mv ~/.buildozer/android/platform/android-sdk-23/build-tools/android-8.0.0 ~/.buildozer/android/platform/android-sdk-23/build-tools/26.0.1
|
||||
- mkdir -p ~/.buildozer/android/platform/android-sdk-23/licenses
|
||||
- echo $'\nd56f5187479451eabf01fb78af6dfcb131a6481e' > ~/.buildozer/android/platform/android-sdk-23/licenses/android-sdk-license
|
||||
script:
|
||||
- ./build.sh | grep -Fv -e 'working:' -e 'copy' --line-buffered
|
||||
- cp bin/*.apk /dev/null
|
||||
@@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017-2018 LBRY Inc
|
||||
Copyright (c) 2017-2020 LBRY Inc
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
||||
@@ -1,75 +1,43 @@
|
||||
[](https://travis-ci.org/lbryio/lbry-android)
|
||||
## 64-bit Ubuntu 16.04 LTS build instructions
|
||||
# LBRY Android
|
||||
[](https://ci.lbry.tech/lbry/lbry-android/commits/master)
|
||||
[](https://github.com/lbryio/lbry-android/blob/master/LICENSE)
|
||||
|
||||
### Install Prerequisites
|
||||
An Android browser and wallet for the [LBRY](https://lbry.com) network.
|
||||
|
||||
#### Requirements
|
||||
* JDK 1.8
|
||||
* Android SDK
|
||||
* Android NDK
|
||||
* Buildozer
|
||||
|
||||
#### Apt Packages
|
||||
Based on the quickstart instructions at http://buildozer.readthedocs.io/en/latest/installation.html
|
||||
<img src="https://spee.ch/@lbry:3f/android-08-homepage.gif" alt="LBRY Android GIF" width="384px" />
|
||||
|
||||
|
||||
## Installation
|
||||
The minimum supported Android version is 5.0 Lollipop. There are two ways to install:
|
||||
|
||||
1. Via the Google Play Store. Anyone can join the [open beta](https://play.google.com/apps/testing/io.lbry.browser) in order to install the app from the Play Store.
|
||||
1. Direct APK install available at [http://build.lbry.io/android/latest.apk](http://build.lbry.io/android/latest.apk). You will need to enable installation from third-party sources on your device in order to install from this source.
|
||||
|
||||
## Usage
|
||||
The app can be launched by opening **LBRY** from the device's app drawer or via the shortcut on the home screen if that was created upon installation.
|
||||
|
||||
## Running from Source
|
||||
Clone the repository and open the project in Android Studio. Android Studio will automatically run the initial build process.
|
||||
|
||||
Create file 'twitter.properties' in app/ folder with the following content:
|
||||
|
||||
```
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update
|
||||
sudo apt-get install build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386
|
||||
```
|
||||
Alternatively, the JDK available from http://www.oracle.com/technetwork/java/javase/downloads/index.html can be installed instead of the `openjdk-8-jdk` package.
|
||||
twitterConsumerKey=XXXXXX
|
||||
|
||||
**Additional package for building libgmp**
|
||||
```
|
||||
sudo apt-get install m4
|
||||
twitterConsumerSecret=XXXXXX
|
||||
```
|
||||
|
||||
**Additional package for the pycrypto recipe**
|
||||
Click the Sync button and when process finishes, the Run button to launch the app on your simulator or connected debugging device after the build process is complete.
|
||||
|
||||
This had to be installed due to an error regarding the `<gnu/stubs.h>` include not found.
|
||||
```
|
||||
sudo apt-get install libc6-dev-i386
|
||||
```
|
||||
## Contributing
|
||||
Contributions to this project are welcome, encouraged, and compensated. For more details, see https://lbry.io/faq/contributing
|
||||
|
||||
## License
|
||||
This project is MIT licensed. For the full license, see [LICENSE](LICENSE).
|
||||
|
||||
#### Install Cython
|
||||
```
|
||||
sudo pip install --upgrade cython==0.25.2
|
||||
```
|
||||
## Security
|
||||
We take security seriously. Please contact security@lbry.com regarding any security issues. Our PGP key is [here](https://keybase.io/lbry/key.asc) if you need it.
|
||||
|
||||
#### Install buildozer
|
||||
```
|
||||
git clone https://github.com/kivy/buildozer.git
|
||||
cd buildozer
|
||||
sudo python2.7 setup.py install
|
||||
```
|
||||
|
||||
#### Create buildozer.spec
|
||||
Assuming `lbrydroid` as the current working folder:
|
||||
* Copy `buildozer.spec.sample` to `buildozer.spec` in the `lbry-android` folder. Running `buildozer init` instead will create a new `buildozer.spec` file.
|
||||
* Update `buildozer.spec` settings to match your environment. Basic recommended settings are outlined below.
|
||||
|
||||
|
||||
| Setting | Description |
|
||||
|:------------------- |:-----------------------------|
|
||||
| title | application title |
|
||||
| package.name | package name (eg. lbrynet) |
|
||||
| package.domain | package domain (eg. io.lbry) |
|
||||
| source.dir | the location of the application main.py |
|
||||
| version | application version |
|
||||
| requirements | the module requirements for building the application |
|
||||
| services | list of Android background services and their corresponding Python entry points |
|
||||
| android.permissions | Android manifest permissions required by the application. This should be set to `INTERNET` at the very least to enable internet connectivity |
|
||||
| android.api | Android API version (21 and 24 have been tested to result in a successful build) |
|
||||
| android.sdk | Android SDK version (21 and 24 have been tested to result in a successful build) |
|
||||
| android.ndk | Android NDK version (13b has been tested to result in a successful build) |
|
||||
| android.ndk_path | Android NDK path. buildozer will automatically download this if not set |
|
||||
| android.sdk_path | Android SDK path. buildozer will automatically download this if not set |
|
||||
| p4a.source_dir | Path to the python-for-android repository folder. Currently set to the included `p4a` folder |
|
||||
| p4a.local_recipes | Path to a folder containing python_for_android recipes to be used in the build. The included `recipes` folder includes recipes for a successful build |
|
||||
|
||||
#### Build and deploy the APK
|
||||
Run `buildozer android debug` to build a debug APK, or `buildozer android release` to build a release APK.
|
||||
|
||||
To deploy and run the APK on a connected Android device, you can run `buildozer android debug deploy run`.
|
||||
|
||||
Run `buildozer android clean` to clean the package if you intend to rebuild.
|
||||
## Contact
|
||||
The primary contact for this project is [@akinwale](https://github.com/akinwale) (akinwale@lbry.com)
|
||||
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -0,0 +1,141 @@
|
||||
import com.google.gms.googleservices.GoogleServicesPlugin
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.2"
|
||||
flavorDimensions "default"
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId "io.lbry.browser"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 29
|
||||
versionCode 1701
|
||||
versionName "0.17.1"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
exclude 'META-INF/DEPENDENCIES'
|
||||
exclude 'lib/x86_64/darwin/libscrypt.dylib'
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
__32bit {
|
||||
versionCode android.defaultConfig.versionCode * 10 + 1
|
||||
ndk {
|
||||
abiFilter "armeabi-v7a"
|
||||
}
|
||||
}
|
||||
__64bit {
|
||||
versionCode android.defaultConfig.versionCode * 10 + 2
|
||||
ndk {
|
||||
abiFilter "arm64-v8a"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
Properties twitterProps = new Properties()
|
||||
twitterProps.load(project.file('twitter.properties').newDataInputStream())
|
||||
resValue "string", "TWITTER_CONSUMER_KEY", "\"${twitterProps.getProperty("twitterConsumerKey")}\""
|
||||
resValue "string", "TWITTER_CONSUMER_SECRET", "\"${twitterProps.getProperty("twitterConsumerSecret")}\""
|
||||
}
|
||||
release {
|
||||
Properties twitterProps = new Properties()
|
||||
twitterProps.load(project.file('twitter.properties').newDataInputStream())
|
||||
resValue "string", "TWITTER_CONSUMER_KEY", "\"${twitterProps.getProperty("twitterConsumerKey")}\""
|
||||
resValue "string", "TWITTER_CONSUMER_SECRET", "\"${twitterProps.getProperty("twitterConsumerSecret")}\""
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task printVersionName {
|
||||
doLast {
|
||||
println android.defaultConfig.versionName
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
all {
|
||||
exclude module: 'httpclient'
|
||||
exclude module: 'commons-logging'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.3.0-alpha01'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.3.0-alpha01'
|
||||
implementation "androidx.cardview:cardview:1.0.0"
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
implementation 'androidx.navigation:navigation-fragment:2.3.1'
|
||||
implementation 'androidx.navigation:navigation-ui:2.3.1'
|
||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
||||
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
|
||||
implementation 'androidx.preference:preference:1.1.1'
|
||||
implementation 'androidx.webkit:webkit:1.4.0-rc01'
|
||||
implementation 'androidx.camera:camera-core:1.0.0-beta03'
|
||||
implementation 'androidx.camera:camera-camera2:1.0.0-beta03'
|
||||
implementation 'androidx.camera:camera-lifecycle:1.0.0-beta03'
|
||||
implementation 'androidx.camera:camera-view:1.0.0-alpha10'
|
||||
implementation 'androidx.browser:browser:1.2.0'
|
||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||
|
||||
implementation 'com.github.bumptech.glide:glide:4.11.0'
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.4.1'
|
||||
implementation 'com.google.firebase:firebase-analytics:18.0.0'
|
||||
implementation 'com.google.android.gms:play-services-base:17.5.0'
|
||||
implementation 'com.google.firebase:firebase-messaging:21.0.0'
|
||||
implementation 'com.google.oauth-client:google-oauth-client:1.30.4'
|
||||
|
||||
implementation 'com.android.billingclient:billing:3.0.2'
|
||||
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
implementation 'com.google.android.exoplayer:exoplayer-core:2.12.2'
|
||||
implementation 'com.google.android.exoplayer:exoplayer-dash:2.12.2'
|
||||
implementation 'com.google.android.exoplayer:exoplayer-ui:2.12.2'
|
||||
implementation 'com.google.android.exoplayer:extension-cast:2.12.2'
|
||||
implementation 'com.google.android.exoplayer:extension-mediasession:2.12.2'
|
||||
|
||||
implementation 'com.google.android:flexbox:2.0.1'
|
||||
|
||||
implementation 'com.hbb20:ccp:2.3.8'
|
||||
|
||||
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
|
||||
implementation 'com.atlassian.commonmark:commonmark:0.14.0'
|
||||
|
||||
implementation 'com.arthenica:mobile-ffmpeg-full-gpl:4.3.1.LTS'
|
||||
|
||||
implementation 'commons-codec:commons-codec:1.15'
|
||||
implementation 'org.bitcoinj:bitcoinj-tools:0.14.7'
|
||||
implementation 'org.java-websocket:Java-WebSocket:1.5.1'
|
||||
|
||||
compileOnly 'org.projectlombok:lombok:1.18.10'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.10'
|
||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test:runner:1.3.0'
|
||||
androidTestImplementation 'androidx.test:rules:1.3.0'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
|
||||
__32bitImplementation 'io.lbry:lbrysdk32:0.100.0'
|
||||
__64bitImplementation 'io.lbry:lbrysdk64:0.100.0'
|
||||
//__64bitImplementation(name: 'lbrysdk', ext: 'aar')
|
||||
}
|
||||
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
GoogleServicesPlugin.config.disableVersionCheck = true
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
react-native bundle --platform android --dev false --entry-file src/index.js --bundle-output ../src/main/assets/index.android.bundle --assets-dest ../src/main/res/
|
||||
Binary file not shown.
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "861521963586",
|
||||
"firebase_url": "https://lbry-mobile-builds-debug.firebaseio.com",
|
||||
"project_id": "lbry-mobile-builds-debug",
|
||||
"storage_bucket": "lbry-mobile-builds-debug.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:861521963586:android:592958d248940ab2",
|
||||
"android_client_info": {
|
||||
"package_name": "io.lbry.browser"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "861521963586-60cmvg5nmnrqkrc11a7bpmpv5ra2d50q.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyC7A3BYcIdZP9-Q-VNHoexYJWgZA7WzsPI"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "861521963586-60cmvg5nmnrqkrc11a7bpmpv5ra2d50q.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
import LBRYApp from './src/index';
|
||||
|
||||
export default LBRYApp;
|
||||
Generated
-10579
File diff suppressed because it is too large.
Load diff
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"name": "LBRYApp",
|
||||
"version": "0.0.1",
|
||||
"private": "true",
|
||||
"scripts": {
|
||||
"start": "node node_modules/react-native/local-cli/cli.js start",
|
||||
"postinstall": "cp ./patch/ReactNativeRenderer-dev.js.patch ./node_modules/react-native/Libraries/Renderer/ReactNativeRenderer-dev.js; rm ./node_modules/react-native/local-cli/core/__fixtures__/files/package.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"lbry-redux": "lbryio/lbry-redux#common-components-refactor",
|
||||
"react": "16.2.0",
|
||||
"react-native": "0.52.0",
|
||||
"react-native-vector-icons": "^4.5.0",
|
||||
"react-native-video": "2.0.0",
|
||||
"react-navigation": "^1.0.3",
|
||||
"react-navigation-redux-helpers": "^1.0.1",
|
||||
"react-redux": "^5.0.3",
|
||||
"redux": "^3.6.0",
|
||||
"redux-logger": "3.0.6",
|
||||
"redux-persist": "^4.8.0",
|
||||
"redux-persist-transform-compress": "^4.2.0",
|
||||
"redux-persist-transform-filter": "0.0.10",
|
||||
"redux-thunk": "^2.2.0"
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,27 @@
|
||||
package io.lbry.browser;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
|
||||
assertEquals("io.lbry.browser", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package io.lbry.browser.utils;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@SmallTest
|
||||
public class HelperTest {
|
||||
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
import React from 'react';
|
||||
import DiscoverPage from '../page/discover';
|
||||
import FilePage from '../page/file';
|
||||
import SettingsPage from '../page/settings';
|
||||
import SplashScreen from '../page/splash';
|
||||
import { addNavigationHelpers, DrawerNavigator, StackNavigator } from 'react-navigation';
|
||||
import { connect } from 'react-redux';
|
||||
import { addListener } from '../utils/redux';
|
||||
import { AppState, BackHandler, NativeModules } from 'react-native';
|
||||
import { SETTINGS } from 'lbry-redux';
|
||||
import Feather from 'react-native-vector-icons/Feather';
|
||||
import discoverStyle from '../styles/discover';
|
||||
import { makeSelectClientSetting } from '../redux/selectors/settings';
|
||||
|
||||
const discoverStack = StackNavigator({
|
||||
Discover: {
|
||||
screen: DiscoverPage,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
title: 'Discover',
|
||||
headerLeft: <Feather name="menu" size={24} style={discoverStyle.drawerHamburger} onPress={() => navigation.navigate('DrawerOpen')} />
|
||||
})
|
||||
},
|
||||
File: {
|
||||
screen: FilePage,
|
||||
navigationOptions: {
|
||||
header: null,
|
||||
drawerLockMode: 'locked-closed'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
headerMode: 'screen',
|
||||
});
|
||||
|
||||
const drawer = DrawerNavigator({
|
||||
Discover: { screen: discoverStack },
|
||||
Settings: {
|
||||
screen: SettingsPage,
|
||||
headerMode: 'screen'
|
||||
}
|
||||
}, {
|
||||
drawerWidth: 300,
|
||||
headerMode: 'none'
|
||||
});
|
||||
|
||||
export const AppNavigator = new StackNavigator({
|
||||
Splash: {
|
||||
screen: SplashScreen
|
||||
},
|
||||
Main: {
|
||||
screen: drawer
|
||||
}
|
||||
}, {
|
||||
headerMode: 'none'
|
||||
});
|
||||
|
||||
class AppWithNavigationState extends React.Component {
|
||||
componentWillMount() {
|
||||
AppState.addEventListener('change', this._handleAppStateChange);
|
||||
BackHandler.addEventListener('hardwareBackPress', function() {
|
||||
const { dispatch, navigation, nav } = this.props;
|
||||
if (nav.routes.length === 2 && nav.routes[1].routeName === 'Main') {
|
||||
if (nav.routes[1].routes[0].routes[0].index > 0) {
|
||||
dispatch({ type: 'Navigation/BACK' });
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
AppState.removeEventListener('change', this._handleAppStateChange);
|
||||
BackHandler.removeEventListener('hardwareBackPress');
|
||||
}
|
||||
|
||||
_handleAppStateChange = (nextAppState) => {
|
||||
const { keepDaemonRunning } = this.props;
|
||||
if (AppState.currentState &&
|
||||
AppState.currentState.match(/inactive|background/) &&
|
||||
NativeModules.DaemonServiceControl) {
|
||||
if (!keepDaemonRunning) {
|
||||
// terminate the daemon background service when is suspended / inactive
|
||||
NativeModules.DaemonServiceControl.stopService();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { dispatch, nav } = this.props;
|
||||
return (
|
||||
<AppNavigator
|
||||
navigation={addNavigationHelpers({
|
||||
dispatch,
|
||||
state: nav,
|
||||
addListener,
|
||||
})}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
nav: state.nav,
|
||||
keepDaemonRunning: makeSelectClientSetting(SETTINGS.KEEP_DAEMON_RUNNING)(state),
|
||||
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_NSFW)(state)
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps)(AppWithNavigationState);
|
||||
@@ -1,7 +0,0 @@
|
||||
import { connect } from 'react-redux';
|
||||
import FeaturedCategory from './view';
|
||||
|
||||
const select = state => ({});
|
||||
const perform = dispatch => ({});
|
||||
|
||||
export default connect(select, perform)(FeaturedCategory);
|
||||
@@ -1,27 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Text, View } from 'react-native';
|
||||
import { normalizeURI } from 'lbry-redux';
|
||||
import FileItem from '../fileItem';
|
||||
import discoverStyle from '../../styles/discover';
|
||||
|
||||
class FeaturedCategory extends React.PureComponent {
|
||||
render() {
|
||||
const { category, names, categoryLink, navigation } = this.props;
|
||||
|
||||
return (
|
||||
<View>
|
||||
<Text style={discoverStyle.categoryName}>{category}</Text>
|
||||
{names &&
|
||||
names.map(name => (
|
||||
<FileItem
|
||||
style={discoverStyle.fileItem}
|
||||
key={name}
|
||||
uri={normalizeURI(name)}
|
||||
navigation={navigation} />
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default FeaturedCategory;
|
||||
@@ -1,23 +0,0 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
makeSelectFileInfoForUri,
|
||||
makeSelectDownloadingForUri,
|
||||
makeSelectLoadingForUri,
|
||||
makeSelectCostInfoForUri
|
||||
} from 'lbry-redux';
|
||||
import { doPurchaseUri, doStartDownload } from '../../redux/actions/file';
|
||||
import FileDownloadButton from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
|
||||
downloading: makeSelectDownloadingForUri(props.uri)(state),
|
||||
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
||||
loading: makeSelectLoadingForUri(props.uri)(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
purchaseUri: uri => dispatch(doPurchaseUri(uri)),
|
||||
restartDownload: (uri, outpoint) => dispatch(doStartDownload(uri, outpoint))
|
||||
});
|
||||
|
||||
export default connect(select, perform)(FileDownloadButton);
|
||||
@@ -1,80 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Text, View, TouchableOpacity } from 'react-native';
|
||||
import fileDownloadButtonStyle from '../../styles/fileDownloadButton';
|
||||
|
||||
class FileDownloadButton extends React.PureComponent {
|
||||
componentWillReceiveProps(nextProps) {
|
||||
//this.checkAvailability(nextProps.uri);
|
||||
this.restartDownload(nextProps);
|
||||
}
|
||||
|
||||
restartDownload(props) {
|
||||
const { downloading, fileInfo, uri, restartDownload } = props;
|
||||
|
||||
if (
|
||||
!downloading &&
|
||||
fileInfo &&
|
||||
!fileInfo.completed &&
|
||||
fileInfo.written_bytes !== false &&
|
||||
fileInfo.written_bytes < fileInfo.total_bytes
|
||||
) {
|
||||
restartDownload(uri, fileInfo.outpoint);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
fileInfo,
|
||||
downloading,
|
||||
uri,
|
||||
purchaseUri,
|
||||
costInfo,
|
||||
loading,
|
||||
doPause,
|
||||
style,
|
||||
} = this.props;
|
||||
|
||||
const openFile = () => {
|
||||
//openInShell(fileInfo.download_path);
|
||||
//doPause();
|
||||
};
|
||||
|
||||
if (loading || downloading) {
|
||||
const progress =
|
||||
fileInfo && fileInfo.written_bytes ? fileInfo.written_bytes / fileInfo.total_bytes * 100 : 0,
|
||||
label = fileInfo ? progress.toFixed(0) + '% complete' : 'Connecting...';
|
||||
|
||||
return (
|
||||
<View style={[style, fileDownloadButtonStyle.container]}>
|
||||
<View style={{ width: `${progress}%`, backgroundColor: '#ff0000', position: 'absolute', left: 0, top: 0 }}></View>
|
||||
<Text style={fileDownloadButtonStyle.text}>{label}</Text>
|
||||
</View>
|
||||
);
|
||||
} else if (fileInfo === null && !downloading) {
|
||||
if (!costInfo) {
|
||||
return (
|
||||
<View style={[style, fileDownloadButtonStyle.container]}>
|
||||
<Text>Fetching cost info...</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<TouchableOpacity style={[style, fileDownloadButtonStyle.container]} onPress={() => {
|
||||
purchaseUri(uri);
|
||||
}}>
|
||||
<Text style={fileDownloadButtonStyle.text}>Download</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
} else if (fileInfo && fileInfo.download_path) {
|
||||
return (
|
||||
<TouchableOpacity style={[style, fileDownloadButtonStyle.container]} onPress={() => openFile()}>
|
||||
<Text style={fileDownloadButtonStyle.text}>Open</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export default FileDownloadButton;
|
||||
@@ -1,26 +0,0 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
doResolveUri,
|
||||
makeSelectClaimForUri,
|
||||
makeSelectMetadataForUri,
|
||||
makeSelectFileInfoForUri,
|
||||
makeSelectIsUriResolving,
|
||||
selectRewardContentClaimIds
|
||||
} from 'lbry-redux';
|
||||
import { selectShowNsfw } from '../../redux/selectors/settings';
|
||||
import FileItem from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
|
||||
metadata: makeSelectMetadataForUri(props.uri)(state),
|
||||
rewardedContentClaimIds: selectRewardContentClaimIds(state, props),
|
||||
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
|
||||
obscureNsfw: !selectShowNsfw(state)
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
resolveUri: uri => dispatch(doResolveUri(uri)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(FileItem);
|
||||
@@ -1,76 +0,0 @@
|
||||
import React from 'react';
|
||||
import { normalizeURI } from 'lbry-redux';
|
||||
import { NavigationActions } from 'react-navigation';
|
||||
import { Text, View, TouchableOpacity } from 'react-native';
|
||||
import FileItemMedia from '../fileItemMedia';
|
||||
import FilePrice from '../filePrice';
|
||||
import NsfwOverlay from '../nsfwOverlay';
|
||||
import discoverStyle from '../../styles/discover';
|
||||
|
||||
class FileItem extends React.PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
this.resolve(this.props);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
this.resolve(nextProps);
|
||||
}
|
||||
|
||||
resolve(props) {
|
||||
const { isResolvingUri, resolveUri, claim, uri } = props;
|
||||
|
||||
if (!isResolvingUri && claim === undefined && uri) {
|
||||
resolveUri(uri);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
claim,
|
||||
fileInfo,
|
||||
metadata,
|
||||
isResolvingUri,
|
||||
rewardedContentClaimIds,
|
||||
style,
|
||||
navigation
|
||||
} = this.props;
|
||||
|
||||
const uri = normalizeURI(this.props.uri);
|
||||
const title = metadata && metadata.title ? metadata.title : uri;
|
||||
const thumbnail = metadata && metadata.thumbnail ? metadata.thumbnail : null;
|
||||
const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw;
|
||||
const isRewardContent = claim && rewardedContentClaimIds.includes(claim.claim_id);
|
||||
const channelName = claim ? claim.channel_name : null;
|
||||
|
||||
let description = '';
|
||||
if (isResolvingUri && !claim) {
|
||||
description = 'Loading...';
|
||||
} else if (metadata && metadata.description) {
|
||||
description = metadata.description;
|
||||
} else if (claim === null) {
|
||||
description = 'This address contains no content.';
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={style}>
|
||||
<TouchableOpacity style={discoverStyle.container} onPress={() => {
|
||||
navigation.navigate('File', { uri: uri });
|
||||
}
|
||||
}>
|
||||
<FileItemMedia title={title} thumbnail={thumbnail} blurRadius={obscureNsfw ? 15 : 0} resizeMode="cover" />
|
||||
<FilePrice uri={uri} style={discoverStyle.filePriceContainer} textStyle={discoverStyle.filePriceText} />
|
||||
<Text style={discoverStyle.fileItemName}>{title}</Text>
|
||||
{channelName &&
|
||||
<Text style={discoverStyle.channelName}>{channelName}</Text>}
|
||||
</TouchableOpacity>
|
||||
{obscureNsfw && <NsfwOverlay onPress={() => navigation.navigate('Settings')} />}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default FileItem;
|
||||
@@ -1,7 +0,0 @@
|
||||
import { connect } from 'react-redux';
|
||||
import FileItemMedia from './view';
|
||||
|
||||
const select = state => ({});
|
||||
const perform = dispatch => ({});
|
||||
|
||||
export default connect(select, perform)(FileItemMedia);
|
||||
@@ -1,59 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Text, Image, View } from 'react-native';
|
||||
import fileItemMediaStyle from '../../styles/fileItemMedia';
|
||||
|
||||
class FileItemMedia extends React.PureComponent {
|
||||
static AUTO_THUMB_STYLES = [
|
||||
fileItemMediaStyle.autothumbPurple,
|
||||
fileItemMediaStyle.autothumbRed,
|
||||
fileItemMediaStyle.autothumbPink,
|
||||
fileItemMediaStyle.autothumbIndigo,
|
||||
fileItemMediaStyle.autothumbBlue,
|
||||
fileItemMediaStyle.autothumbLightBlue,
|
||||
fileItemMediaStyle.autothumbCyan,
|
||||
fileItemMediaStyle.autothumbTeal,
|
||||
fileItemMediaStyle.autothumbGreen,
|
||||
fileItemMediaStyle.autothumbYellow,
|
||||
fileItemMediaStyle.autothumbOrange,
|
||||
];
|
||||
|
||||
componentWillMount() {
|
||||
this.setState({
|
||||
autoThumbStyle:
|
||||
FileItemMedia.AUTO_THUMB_STYLES[
|
||||
Math.floor(Math.random() * FileItemMedia.AUTO_THUMB_STYLES.length)
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
let style = this.props.style;
|
||||
const { title, thumbnail, blurRadius, resizeMode } = this.props;
|
||||
const atStyle = this.state.autoThumbStyle;
|
||||
|
||||
if (thumbnail && ((typeof thumbnail) === 'string')) {
|
||||
if (style == null) {
|
||||
style = fileItemMediaStyle.thumbnail;
|
||||
}
|
||||
|
||||
return (
|
||||
<Image source={{uri: thumbnail}}
|
||||
blurRadius={blurRadius}
|
||||
resizeMode={resizeMode ? resizeMode : "cover"}
|
||||
style={style} />
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={[fileItemMediaStyle.autothumb, atStyle]}>
|
||||
<Text style={fileItemMediaStyle.autothumbText}>{title &&
|
||||
title
|
||||
.replace(/\s+/g, '')
|
||||
.substring(0, Math.min(title.replace(' ', '').length, 5))
|
||||
.toUpperCase()}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default FileItemMedia;
|
||||
@@ -1,20 +0,0 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
doFetchCostInfoForUri,
|
||||
makeSelectCostInfoForUri,
|
||||
makeSelectFetchingCostInfoForUri,
|
||||
makeSelectClaimForUri
|
||||
} from 'lbry-redux';
|
||||
import FilePrice from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
||||
fetching: makeSelectFetchingCostInfoForUri(props.uri)(state),
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(FilePrice);
|
||||
@@ -1,120 +0,0 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Text, View } from 'react-native';
|
||||
import { formatCredits, formatFullPrice } from 'lbry-redux';
|
||||
|
||||
class CreditAmount extends React.PureComponent {
|
||||
static propTypes = {
|
||||
amount: PropTypes.number.isRequired,
|
||||
precision: PropTypes.number,
|
||||
isEstimate: PropTypes.bool,
|
||||
label: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
||||
showFree: PropTypes.bool,
|
||||
showFullPrice: PropTypes.bool,
|
||||
showPlus: PropTypes.bool,
|
||||
look: PropTypes.oneOf(['indicator', 'plain', 'fee']),
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
precision: 2,
|
||||
label: true,
|
||||
showFree: false,
|
||||
look: 'indicator',
|
||||
showFullPrice: false,
|
||||
showPlus: false,
|
||||
};
|
||||
|
||||
render() {
|
||||
const minimumRenderableAmount = Math.pow(10, -1 * this.props.precision);
|
||||
const { amount, precision, showFullPrice, style } = this.props;
|
||||
|
||||
let formattedAmount;
|
||||
const fullPrice = formatFullPrice(amount, 2);
|
||||
|
||||
if (showFullPrice) {
|
||||
formattedAmount = fullPrice;
|
||||
} else {
|
||||
formattedAmount =
|
||||
amount > 0 && amount < minimumRenderableAmount
|
||||
? `<${minimumRenderableAmount}`
|
||||
: formatCredits(amount, precision);
|
||||
}
|
||||
|
||||
let amountText;
|
||||
if (this.props.showFree && parseFloat(this.props.amount) === 0) {
|
||||
amountText = 'FREE';
|
||||
} else {
|
||||
if (this.props.label) {
|
||||
const label =
|
||||
typeof this.props.label === 'string'
|
||||
? this.props.label
|
||||
: parseFloat(amount) == 1 ? 'credit' : 'credits';
|
||||
|
||||
amountText = `${formattedAmount} ${label}`;
|
||||
} else {
|
||||
amountText = formattedAmount;
|
||||
}
|
||||
if (this.props.showPlus && amount > 0) {
|
||||
amountText = `+${amountText}`;
|
||||
}
|
||||
}
|
||||
|
||||
/*{this.props.isEstimate ? (
|
||||
<span
|
||||
className="credit-amount__estimate"
|
||||
title={__('This is an estimate and does not include data fees')}
|
||||
>
|
||||
*
|
||||
</span>
|
||||
) : null}*/
|
||||
return (
|
||||
<Text style={style}>{amountText}</Text>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FilePrice extends React.PureComponent {
|
||||
componentWillMount() {
|
||||
this.fetchCost(this.props);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
this.fetchCost(nextProps);
|
||||
}
|
||||
|
||||
fetchCost(props) {
|
||||
const { costInfo, fetchCostInfo, uri, fetching, claim } = props;
|
||||
|
||||
if (costInfo === undefined && !fetching && claim) {
|
||||
fetchCostInfo(uri);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { costInfo, look = 'indicator', showFullPrice = false, style, textStyle } = this.props;
|
||||
|
||||
const isEstimate = costInfo ? !costInfo.includesData : null;
|
||||
|
||||
if (!costInfo) {
|
||||
return (
|
||||
<View style={style}>
|
||||
<Text style={textStyle}>???</Text>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={style}>
|
||||
<CreditAmount
|
||||
style={textStyle}
|
||||
label={false}
|
||||
amount={costInfo.cost}
|
||||
isEstimate={isEstimate}
|
||||
showFree
|
||||
showFullPrice={showFullPrice}>???</CreditAmount>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default FilePrice;
|
||||
@@ -1,7 +0,0 @@
|
||||
import { connect } from 'react-redux';
|
||||
import MediaPlayer from './view';
|
||||
|
||||
const select = state => ({});
|
||||
const perform = dispatch => ({});
|
||||
|
||||
export default connect(select, perform)(MediaPlayer);
|
||||
@@ -1,274 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Lbry } from 'lbry-redux';
|
||||
import { PanResponder, Text, View, ScrollView, TouchableOpacity } from 'react-native';
|
||||
import Video from 'react-native-video';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome';
|
||||
import FileItemMedia from '../fileItemMedia';
|
||||
import mediaPlayerStyle from '../../styles/mediaPlayer';
|
||||
|
||||
class MediaPlayer extends React.PureComponent {
|
||||
static ControlsTimeout = 3000;
|
||||
|
||||
seekResponder = null;
|
||||
|
||||
seekerWidth = 0;
|
||||
|
||||
video = null;
|
||||
|
||||
state = {
|
||||
rate: 1,
|
||||
volume: 1,
|
||||
muted: false,
|
||||
resizeMode: 'stretch',
|
||||
duration: 0.0,
|
||||
currentTime: 0.0,
|
||||
paused: true,
|
||||
fullscreenMode: false,
|
||||
areControlsVisible: true,
|
||||
controlsTimeout: -1,
|
||||
seekerOffset: 0,
|
||||
seekerPosition: 0,
|
||||
firstPlay: true
|
||||
};
|
||||
|
||||
formatTime(time) {
|
||||
let str = '';
|
||||
let minutes = 0, hours = 0, seconds = parseInt(time, 10);
|
||||
if (seconds > 60) {
|
||||
minutes = parseInt(seconds / 60, 10);
|
||||
seconds = seconds % 60;
|
||||
|
||||
if (minutes > 60) {
|
||||
hours = parseInt(minutes / 60, 10);
|
||||
minutes = minutes % 60;
|
||||
}
|
||||
|
||||
str = (hours > 0 ? this.pad(hours) + ':' : '') + this.pad(minutes) + ':' + this.pad(seconds);
|
||||
} else {
|
||||
str = '00:' + this.pad(seconds);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
pad(value) {
|
||||
if (value < 10) {
|
||||
return '0' + String(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
onLoad = (data) => {
|
||||
this.setState({
|
||||
duration: data.duration
|
||||
});
|
||||
if (this.props.onMediaLoaded) {
|
||||
this.props.onMediaLoaded();
|
||||
}
|
||||
}
|
||||
|
||||
onProgress = (data) => {
|
||||
this.setState({ currentTime: data.currentTime });
|
||||
|
||||
if (!this.state.seeking) {
|
||||
this.setSeekerPosition(this.calculateSeekerPosition());
|
||||
}
|
||||
|
||||
if (this.state.firstPlay) {
|
||||
this.setState({ firstPlay: false });
|
||||
this.hidePlayerControls();
|
||||
}
|
||||
}
|
||||
|
||||
clearControlsTimeout = () => {
|
||||
if (this.state.controlsTimeout > -1) {
|
||||
clearTimeout(this.state.controlsTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
showPlayerControls = () => {
|
||||
this.clearControlsTimeout();
|
||||
if (!this.state.areControlsVisible) {
|
||||
this.setState({ areControlsVisible: true });
|
||||
}
|
||||
this.hidePlayerControls();
|
||||
}
|
||||
|
||||
hidePlayerControls() {
|
||||
const player = this;
|
||||
let timeout = setTimeout(() => {
|
||||
player.setState({ areControlsVisible: false });
|
||||
}, MediaPlayer.ControlsTimeout);
|
||||
player.setState({ controlsTimeout: timeout });
|
||||
}
|
||||
|
||||
togglePlay = () => {
|
||||
this.showPlayerControls();
|
||||
this.setState({ paused: !this.state.paused });
|
||||
}
|
||||
|
||||
toggleFullscreenMode = () => {
|
||||
this.showPlayerControls();
|
||||
const { onFullscreenToggled } = this.props;
|
||||
this.setState({ fullscreenMode: !this.state.fullscreenMode }, () => {
|
||||
this.setState({ resizeMode: this.state.fullscreenMode ? 'contain' : 'stretch' });
|
||||
if (onFullscreenToggled) {
|
||||
onFullscreenToggled(this.state.fullscreenMode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onEnd = () => {
|
||||
this.setState({ paused: true });
|
||||
this.video.seek(0);
|
||||
}
|
||||
|
||||
setSeekerPosition(position = 0) {
|
||||
position = this.checkSeekerPosition(position);
|
||||
this.setState({ seekerPosition: position });
|
||||
if (!this.state.seeking) {
|
||||
this.setState({ seekerOffset: position });
|
||||
}
|
||||
}
|
||||
|
||||
checkSeekerPosition(val = 0) {
|
||||
if (val < 0) {
|
||||
val = 0;
|
||||
} else if (val >= this.seekerWidth) {
|
||||
return this.seekerWidth;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
seekTo(time = 0) {
|
||||
if (time > this.state.duration) {
|
||||
return;
|
||||
}
|
||||
this.video.seek(time);
|
||||
this.setState({ currentTime: time });
|
||||
}
|
||||
|
||||
initSeeker() {
|
||||
this.seekResponder = PanResponder.create({
|
||||
onStartShouldSetPanResponder: (evt, gestureState) => true,
|
||||
onMoveShouldSetPanResponder: (evt, gestureState) => true,
|
||||
|
||||
onPanResponderGrant: (evt, gestureState) => {
|
||||
this.clearControlsTimeout();
|
||||
this.setState({ seeking: true });
|
||||
},
|
||||
|
||||
onPanResponderMove: (evt, gestureState) => {
|
||||
const position = this.state.seekerOffset + gestureState.dx;
|
||||
this.setSeekerPosition(position);
|
||||
},
|
||||
|
||||
onPanResponderRelease: (evt, gestureState) => {
|
||||
const time = this.getCurrentTimeForSeekerPosition();
|
||||
if (time >= this.state.duration) {
|
||||
this.setState({ paused: true });
|
||||
this.onEnd();
|
||||
} else {
|
||||
this.seekTo(time);
|
||||
this.setState({ seeking: false });
|
||||
}
|
||||
this.hidePlayerControls();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getCurrentTimeForSeekerPosition() {
|
||||
return this.state.duration * (this.state.seekerPosition / this.seekerWidth);
|
||||
}
|
||||
|
||||
calculateSeekerPosition() {
|
||||
return this.seekerWidth * this.getCurrentTimePercentage();
|
||||
}
|
||||
|
||||
getCurrentTimePercentage() {
|
||||
if (this.state.currentTime > 0) {
|
||||
return parseFloat(this.state.currentTime) / parseFloat(this.state.duration);
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
this.initSeeker();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.clearControlsTimeout();
|
||||
this.setState({ paused: true, fullscreenMode: false });
|
||||
const { onFullscreenToggled } = this.props;
|
||||
if (onFullscreenToggled) {
|
||||
onFullscreenToggled(false);
|
||||
}
|
||||
}
|
||||
|
||||
renderPlayerControls() {
|
||||
if (this.state.areControlsVisible) {
|
||||
return (
|
||||
<View style={mediaPlayerStyle.playerControlsContainer}>
|
||||
<TouchableOpacity style={mediaPlayerStyle.playPauseButton}
|
||||
onPress={this.togglePlay}>
|
||||
{this.state.paused && <Icon name="play" size={32} color="#ffffff" />}
|
||||
{!this.state.paused && <Icon name="pause" size={32} color="#ffffff" />}
|
||||
</TouchableOpacity>
|
||||
|
||||
<TouchableOpacity style={mediaPlayerStyle.toggleFullscreenButton} onPress={this.toggleFullscreenMode}>
|
||||
{this.state.fullscreenMode && <Icon name="compress" size={16} color="#ffffff" />}
|
||||
{!this.state.fullscreenMode && <Icon name="expand" size={16} color="#ffffff" />}
|
||||
</TouchableOpacity>
|
||||
|
||||
<Text style={mediaPlayerStyle.elapsedDuration}>{this.formatTime(this.state.currentTime)}</Text>
|
||||
<Text style={mediaPlayerStyle.totalDuration}>{this.formatTime(this.state.duration)}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
render() {
|
||||
const { fileInfo, title, thumbnail, style, fullScreenStyle } = this.props;
|
||||
const flexCompleted = this.getCurrentTimePercentage() * 100;
|
||||
const flexRemaining = (1 - this.getCurrentTimePercentage()) * 100;
|
||||
|
||||
return (
|
||||
<View style={[style, mediaPlayerStyle.container]}>
|
||||
<Video source={{ uri: 'file:///' + fileInfo.download_path }}
|
||||
ref={(ref: Video) => { this.video = ref }}
|
||||
resizeMode={this.state.resizeMode}
|
||||
playInBackground={true}
|
||||
style={mediaPlayerStyle.player}
|
||||
rate={this.state.rate}
|
||||
volume={this.state.volume}
|
||||
paused={this.state.paused}
|
||||
onLoad={this.onLoad}
|
||||
onProgress={this.onProgress}
|
||||
onEnd={this.onEnd}
|
||||
/>
|
||||
|
||||
<TouchableOpacity style={mediaPlayerStyle.playerControls} onPress={this.showPlayerControls}>
|
||||
{this.renderPlayerControls()}
|
||||
</TouchableOpacity>
|
||||
|
||||
<View style={mediaPlayerStyle.trackingControls}>
|
||||
<View style={mediaPlayerStyle.progress} onLayout={(evt) => this.seekerWidth = evt.nativeEvent.layout.width}>
|
||||
<View style={[mediaPlayerStyle.innerProgressCompleted, { flex: flexCompleted }]} />
|
||||
<View style={[mediaPlayerStyle.innerProgressRemaining, { flex: flexRemaining }]} />
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{this.state.areControlsVisible &&
|
||||
<View style={[mediaPlayerStyle.seekerHandle, { left: this.state.seekerPosition }]} { ...this.seekResponder.panHandlers }>
|
||||
<View style={this.state.seeking ? mediaPlayerStyle.bigSeekerCircle : mediaPlayerStyle.seekerCircle} />
|
||||
</View>}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default MediaPlayer;
|
||||
@@ -1,6 +0,0 @@
|
||||
import { connect } from 'react-redux';
|
||||
import NsfwOverlay from './view';
|
||||
|
||||
const perform = dispatch => ({});
|
||||
|
||||
export default connect(null, perform)(NsfwOverlay);
|
||||
@@ -1,15 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Text, TouchableOpacity } from 'react-native';
|
||||
import discoverStyle from '../../styles/discover';
|
||||
|
||||
class NsfwOverlay extends React.PureComponent {
|
||||
render() {
|
||||
return (
|
||||
<TouchableOpacity style={discoverStyle.overlay} activeOpacity={0.95} onPress={this.props.onPress}>
|
||||
<Text style={discoverStyle.overlayText}>This content is Not Safe For Work. To view adult content, please change your Settings.</Text>
|
||||
</TouchableOpacity>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default NsfwOverlay;
|
||||
@@ -1,119 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Provider, connect } from 'react-redux';
|
||||
import DiscoverPage from './page/discover';
|
||||
import { AppRegistry, AppState, StyleSheet, Text, View, AsyncStorage, NativeModules } from 'react-native';
|
||||
import { createStore, applyMiddleware, compose, combineReducers } from 'redux';
|
||||
import {
|
||||
StackNavigator, addNavigationHelpers
|
||||
} from 'react-navigation';
|
||||
import { AppNavigator } from './component/AppNavigator';
|
||||
import AppWithNavigationState from './component/AppNavigator';
|
||||
import { persistStore, autoRehydrate } from 'redux-persist';
|
||||
import createCompressor from 'redux-persist-transform-compress';
|
||||
import createFilter from 'redux-persist-transform-filter';
|
||||
import thunk from 'redux-thunk';
|
||||
import {
|
||||
Lbry,
|
||||
claimsReducer,
|
||||
costInfoReducer,
|
||||
fileInfoReducer,
|
||||
searchReducer,
|
||||
walletReducer
|
||||
} from 'lbry-redux';
|
||||
import settingsReducer from './redux/reducers/settings';
|
||||
import { reactNavigationMiddleware } from './utils/redux';
|
||||
|
||||
function isFunction(object) {
|
||||
return typeof object === 'function';
|
||||
}
|
||||
|
||||
function isNotFunction(object) {
|
||||
return !isFunction(object);
|
||||
}
|
||||
|
||||
function createBulkThunkMiddleware() {
|
||||
return ({ dispatch, getState }) => next => action => {
|
||||
if (action.type === 'BATCH_ACTIONS') {
|
||||
action.actions.filter(isFunction).map(actionFn => actionFn(dispatch, getState));
|
||||
}
|
||||
return next(action);
|
||||
};
|
||||
}
|
||||
|
||||
function enableBatching(reducer) {
|
||||
return function batchingReducer(state, action) {
|
||||
switch (action.type) {
|
||||
case 'BATCH_ACTIONS':
|
||||
return action.actions.filter(isNotFunction).reduce(batchingReducer, state);
|
||||
default:
|
||||
return reducer(state, action);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const router = AppNavigator.router;
|
||||
const navAction = router.getActionForPathAndParams('Splash');
|
||||
const initialNavState = router.getStateForAction(navAction);
|
||||
const navigatorReducer = (state = initialNavState, action) => {
|
||||
const nextState = AppNavigator.router.getStateForAction(action, state);
|
||||
return nextState || state;
|
||||
};
|
||||
|
||||
const reducers = combineReducers({
|
||||
claims: claimsReducer,
|
||||
costInfo: costInfoReducer,
|
||||
fileInfo: fileInfoReducer,
|
||||
search: searchReducer,
|
||||
wallet: walletReducer,
|
||||
nav: navigatorReducer,
|
||||
settings: settingsReducer
|
||||
});
|
||||
|
||||
const bulkThunk = createBulkThunkMiddleware();
|
||||
const middleware = [thunk, bulkThunk, reactNavigationMiddleware];
|
||||
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
const composeEnhancers = compose;
|
||||
|
||||
const store = createStore(
|
||||
enableBatching(reducers),
|
||||
{}, // initial state,
|
||||
composeEnhancers(
|
||||
autoRehydrate(),
|
||||
applyMiddleware(...middleware)
|
||||
)
|
||||
);
|
||||
|
||||
const compressor = createCompressor();
|
||||
const saveClaimsFilter = createFilter('claims', ['byId', 'claimsByUri']);
|
||||
const subscriptionsFilter = createFilter('subscriptions', ['subscriptions']);
|
||||
const settingsFilter = createFilter('settings', ['clientSettings']);
|
||||
|
||||
const persistOptions = {
|
||||
whitelist: ['claims', 'subscriptions', 'settings'],
|
||||
// Order is important. Needs to be compressed last or other transforms can't
|
||||
// read the data
|
||||
transforms: [saveClaimsFilter, subscriptionsFilter, settingsFilter, compressor],
|
||||
debounce: 10000,
|
||||
storage: AsyncStorage
|
||||
};
|
||||
|
||||
persistStore(store, persistOptions, err => {
|
||||
if (err) {
|
||||
console.log('Unable to load saved SETTINGS');
|
||||
}
|
||||
});
|
||||
|
||||
class LBRYApp extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<AppWithNavigationState />
|
||||
</Provider>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
AppRegistry.registerComponent('LBRYApp', () => LBRYApp);
|
||||
|
||||
export default LBRYApp;
|
||||
@@ -0,0 +1,119 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="io.lbry.browser"
|
||||
android:installLocation="auto">
|
||||
|
||||
<uses-feature android:name="android.hardware.camera" android:required="false" />
|
||||
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="com.android.vending.BILLING" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:usesCleartextTraffic="true">
|
||||
|
||||
<meta-data android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
|
||||
android:value="com.google.android.exoplayer2.ext.cast.DefaultCastOptionsProvider"/>
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.firebase.messaging.default_notification_icon"
|
||||
android:resource="@drawable/ic_lbry" />
|
||||
<meta-data
|
||||
android:name="com.google.firebase.messaging.default_notification_color"
|
||||
android:resource="@color/lbryGreen" />
|
||||
<meta-data
|
||||
android:name="com.google.firebase.messaging.default_notification_channel_id"
|
||||
android:value="@string/default_notification_channel_id"/>
|
||||
|
||||
<meta-data android:name="wakelock" android:value="0"/>
|
||||
|
||||
<activity
|
||||
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout"
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:supportsPictureInPicture="true"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:launchMode="singleTask"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<data android:mimeType="video/*" />
|
||||
<data android:mimeType="image/*" />
|
||||
<data android:mimeType="text/*" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="lbry" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<data android:scheme="https" android:host="open.lbry.com"/>
|
||||
<data android:scheme="https" android:host="lbry.tv" android:pathPattern="/..*/*" />
|
||||
<data android:scheme="https" android:host="lbry.tv" android:pathPattern="/.*:.*" />
|
||||
<data android:scheme="https" android:host="lbry.tv" android:pathPattern="/.*#.*" />
|
||||
<data android:scheme="https" android:host="lbry.lat" android:pathPattern="/..*/*" />
|
||||
<data android:scheme="https" android:host="lbry.lat" android:pathPattern="/.*:.*" />
|
||||
<data android:scheme="https" android:host="lbry.lat" android:pathPattern="/.*#.*" />
|
||||
<data android:scheme="https" android:host="lbry.fr" android:pathPattern="/..*/*" />
|
||||
<data android:scheme="https" android:host="lbry.fr" android:pathPattern="/.*:.*" />
|
||||
<data android:scheme="https" android:host="lbry.fr" android:pathPattern="/.*#.*" />
|
||||
<data android:scheme="https" android:host="lbry.in" android:pathPattern="/..*/*" />
|
||||
<data android:scheme="https" android:host="lbry.in" android:pathPattern="/.*:.*" />
|
||||
<data android:scheme="https" android:host="lbry.in" android:pathPattern="/.*#.*" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".FirstRunActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:parentActivityName=".MainActivity"
|
||||
android:theme="@style/AppTheme.NoActionBarTranslucent" />
|
||||
<activity
|
||||
android:name=".VerificationActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:parentActivityName=".MainActivity"
|
||||
android:theme="@style/AppTheme.NoActionBarTranslucent"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
|
||||
<service
|
||||
android:name="io.lbry.browser.LbrynetMessagingService"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<provider
|
||||
android:name="io.lbry.browser.LocalFileProvider"
|
||||
android:authorities="io.lbry.browser.fileprovider"
|
||||
android:grantUriPermissions="true"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/filepaths" />
|
||||
</provider>
|
||||
</application>
|
||||
</manifest>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
@@ -0,0 +1,252 @@
|
||||
package io.lbry.browser;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.text.HtmlCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import io.lbry.browser.exceptions.AuthTokenInvalidatedException;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import io.lbry.browser.utils.Lbry;
|
||||
import io.lbry.browser.utils.LbryAnalytics;
|
||||
import io.lbry.browser.utils.Lbryio;
|
||||
import io.lbry.lbrysdk.LbrynetService;
|
||||
import io.lbry.lbrysdk.ServiceHelper;
|
||||
import io.lbry.lbrysdk.Utils;
|
||||
|
||||
public class FirstRunActivity extends AppCompatActivity {
|
||||
|
||||
private BroadcastReceiver sdkReceiver;
|
||||
private BroadcastReceiver authReceiver;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_first_run);
|
||||
|
||||
TextView welcomeTos = findViewById(R.id.welcome_text_view_tos);
|
||||
welcomeTos.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
welcomeTos.setText(HtmlCompat.fromHtml(getString(R.string.welcome_tos), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
|
||||
findViewById(R.id.welcome_link_use_lbry).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finishFirstRun();
|
||||
}
|
||||
});
|
||||
|
||||
registerAuthReceiver();
|
||||
findViewById(R.id.welcome_wait_container).setVisibility(View.VISIBLE);
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(MainActivity.ACTION_SDK_READY);
|
||||
filter.addAction(LbrynetService.ACTION_STOP_SERVICE);
|
||||
sdkReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (MainActivity.ACTION_SDK_READY.equals(action)) {
|
||||
// authenticate after we receive the sdk ready event
|
||||
authenticate();
|
||||
} else if (LbrynetService.ACTION_STOP_SERVICE.equals(action)) {
|
||||
finish();
|
||||
if (MainActivity.instance != null) {
|
||||
MainActivity.instance.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
registerReceiver(sdkReceiver, filter);
|
||||
|
||||
CheckInstallIdTask task = new CheckInstallIdTask(this, new CheckInstallIdTask.InstallIdHandler() {
|
||||
@Override
|
||||
public void onInstallIdChecked(boolean result) {
|
||||
// start the sdk from FirstRun
|
||||
boolean serviceRunning = MainActivity.isServiceRunning(MainActivity.instance, LbrynetService.class);
|
||||
if (!serviceRunning) {
|
||||
Lbry.SDK_READY = false;
|
||||
ServiceHelper.start(MainActivity.instance, "", LbrynetService.class, "lbrynetservice");
|
||||
}
|
||||
|
||||
if (result) {
|
||||
// install_id generated and validated, authenticate now
|
||||
authenticate();
|
||||
return;
|
||||
}
|
||||
|
||||
// we weren't able to generate the install_id ourselves, depend on the sdk for that
|
||||
if (Lbry.SDK_READY) {
|
||||
authenticate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
LbryAnalytics.setCurrentScreen(this, "First Run", "FirstRun");
|
||||
}
|
||||
|
||||
private void registerAuthReceiver() {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(MainActivity.ACTION_USER_AUTHENTICATION_SUCCESS);
|
||||
filter.addAction(MainActivity.ACTION_USER_AUTHENTICATION_FAILED);
|
||||
authReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (MainActivity.ACTION_USER_AUTHENTICATION_SUCCESS.equals(intent.getAction())) {
|
||||
handleAuthenticationSuccess();
|
||||
} else {
|
||||
handleAuthenticationFailed();
|
||||
}
|
||||
}
|
||||
};
|
||||
registerReceiver(authReceiver, filter);
|
||||
}
|
||||
|
||||
private void handleAuthenticationSuccess() {
|
||||
// first_auth completed event
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
boolean firstAuthCompleted = sp.getBoolean(MainActivity.PREFERENCE_KEY_INTERNAL_FIRST_AUTH_COMPLETED, false);
|
||||
if (!firstAuthCompleted) {
|
||||
LbryAnalytics.logEvent(LbryAnalytics.EVENT_FIRST_USER_AUTH);
|
||||
sp.edit().putBoolean(MainActivity.PREFERENCE_KEY_INTERNAL_FIRST_AUTH_COMPLETED, true).apply();
|
||||
}
|
||||
|
||||
findViewById(R.id.welcome_wait_container).setVisibility(View.GONE);
|
||||
findViewById(R.id.welcome_display).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.welcome_link_use_lbry).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void handleAuthenticationFailed() {
|
||||
findViewById(R.id.welcome_progress_bar).setVisibility(View.GONE);
|
||||
((TextView) findViewById(R.id.welcome_wait_text)).setText(R.string.startup_failed);
|
||||
}
|
||||
|
||||
private void authenticate() {
|
||||
new AuthenticateTask(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
private void finishFirstRun() {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
sp.edit().putBoolean(MainActivity.PREFERENCE_KEY_INTERNAL_FIRST_RUN_COMPLETED, true).apply();
|
||||
|
||||
// first_run_completed event
|
||||
LbryAnalytics.logEvent(LbryAnalytics.EVENT_FIRST_RUN_COMPLETED);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
Helper.unregisterReceiver(authReceiver, this);
|
||||
Helper.unregisterReceiver(sdkReceiver, this);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void generateIdAndAuthenticate() {
|
||||
|
||||
}
|
||||
|
||||
private static class CheckInstallIdTask extends AsyncTask<Void, Void, Boolean> {
|
||||
private final Context context;
|
||||
private final InstallIdHandler handler;
|
||||
public CheckInstallIdTask(Context context, InstallIdHandler handler) {
|
||||
this.context = context;
|
||||
this.handler = handler;
|
||||
}
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
// Load the installation id from the file system
|
||||
String lbrynetDir = String.format("%s/%s", Utils.getAppInternalStorageDir(context), "lbrynet");
|
||||
File dir = new File(lbrynetDir);
|
||||
boolean dirExists = dir.isDirectory();
|
||||
if (!dirExists) {
|
||||
dirExists = dir.mkdirs();
|
||||
}
|
||||
|
||||
if (!dirExists) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String installIdPath = String.format("%s/install_id", lbrynetDir);
|
||||
File file = new File(installIdPath);
|
||||
String installId = null;
|
||||
if (!file.exists()) {
|
||||
// generate the install_id
|
||||
installId = Lbry.generateId();
|
||||
BufferedWriter writer = null;
|
||||
try {
|
||||
writer = new BufferedWriter(new FileWriter(file));
|
||||
writer.write(installId);
|
||||
} catch (IOException ex) {
|
||||
return false;
|
||||
} finally {
|
||||
Helper.closeCloseable(writer);
|
||||
}
|
||||
} else {
|
||||
// read the installation id from the file
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
reader = new BufferedReader(new InputStreamReader(new FileInputStream(installIdPath)));
|
||||
installId = reader.readLine();
|
||||
} catch (IOException ex) {
|
||||
return false;
|
||||
} finally {
|
||||
Helper.closeCloseable(reader);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Helper.isNullOrEmpty(installId)) {
|
||||
Lbry.INSTALLATION_ID = installId;
|
||||
}
|
||||
return !Helper.isNullOrEmpty(installId);
|
||||
}
|
||||
protected void onPostExecute(Boolean result) {
|
||||
if (handler != null) {
|
||||
handler.onInstallIdChecked(result);
|
||||
}
|
||||
}
|
||||
|
||||
public interface InstallIdHandler {
|
||||
void onInstallIdChecked(boolean result);
|
||||
}
|
||||
}
|
||||
|
||||
private static class AuthenticateTask extends AsyncTask<Void, Void, Void> {
|
||||
private final Context context;
|
||||
public AuthenticateTask(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
protected Void doInBackground(Void... params) {
|
||||
try {
|
||||
Lbryio.authenticate(context);
|
||||
} catch (AuthTokenInvalidatedException ex) {
|
||||
// pass
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
package io.lbry.browser;
|
||||
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||
import com.google.firebase.messaging.FirebaseMessagingService;
|
||||
import com.google.firebase.messaging.RemoteMessage;
|
||||
|
||||
import io.lbry.browser.data.DatabaseHelper;
|
||||
import io.lbry.browser.model.lbryinc.LbryNotification;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import io.lbry.browser.utils.LbryAnalytics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class LbrynetMessagingService extends FirebaseMessagingService {
|
||||
public static final String ACTION_NOTIFICATION_RECEIVED = "io.lbry.browser.Broadcast.NotificationReceived";
|
||||
|
||||
private static final String TAG = "LbrynetMessagingService";
|
||||
private static final String NOTIFICATION_CHANNEL_ID = "io.lbry.browser.LBRY_ENGAGEMENT_CHANNEL";
|
||||
private static final String TYPE_COMMENT = "comment";
|
||||
private static final String TYPE_SUBSCRIPTION = "subscription";
|
||||
private static final String TYPE_REWARD = "reward";
|
||||
private static final String TYPE_INTERESTS = "interests";
|
||||
private static final String TYPE_CREATOR = "creator";
|
||||
private FirebaseAnalytics firebaseAnalytics;
|
||||
|
||||
@Override
|
||||
public void onMessageReceived(RemoteMessage remoteMessage) {
|
||||
if (firebaseAnalytics == null) {
|
||||
firebaseAnalytics = FirebaseAnalytics.getInstance(this);
|
||||
}
|
||||
|
||||
Map<String, String> payload = remoteMessage.getData();
|
||||
if (payload != null) {
|
||||
String type = payload.get("type");
|
||||
String url = payload.get("target");
|
||||
String title = payload.get("title");
|
||||
String body = payload.get("body");
|
||||
String name = payload.get("name"); // notification name
|
||||
String hash = payload.get("hash"); // comment hash
|
||||
|
||||
if (type != null && getEnabledTypes().contains(type) && body != null && body.trim().length() > 0) {
|
||||
// only log the receive event for valid notifications received
|
||||
if (firebaseAnalytics != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("name", name);
|
||||
firebaseAnalytics.logEvent(LbryAnalytics.EVENT_LBRY_NOTIFICATION_RECEIVE, bundle);
|
||||
}
|
||||
|
||||
if (!Helper.isNullOrEmpty(hash)) {
|
||||
url = String.format("%s?comment_hash=%s", url, hash);
|
||||
}
|
||||
|
||||
sendNotification(title, body, type, url, name);
|
||||
}
|
||||
|
||||
// persist the notification data
|
||||
try {
|
||||
DatabaseHelper helper = DatabaseHelper.getInstance();
|
||||
SQLiteDatabase db = helper.getWritableDatabase();
|
||||
LbryNotification lnotification = new LbryNotification();
|
||||
lnotification.setTitle(title);
|
||||
lnotification.setDescription(body);
|
||||
lnotification.setTargetUrl(url);
|
||||
lnotification.setTimestamp(new Date());
|
||||
DatabaseHelper.createOrUpdateNotification(lnotification, db);
|
||||
|
||||
// send a broadcast
|
||||
Intent intent = new Intent(ACTION_NOTIFICATION_RECEIVED);
|
||||
intent.putExtra("title", title);
|
||||
intent.putExtra("body", body);
|
||||
intent.putExtra("url", url);
|
||||
intent.putExtra("timestamp", lnotification.getTimestamp().getTime());
|
||||
sendBroadcast(intent);
|
||||
} catch (Exception ex) {
|
||||
// don't fail if any error occurs while saving a notification
|
||||
Log.e(TAG, "could not save notification", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewToken(String token) {
|
||||
//Log.d(TAG, "Refreshed token: " + token);
|
||||
|
||||
// If you want to send messages to this application instance or
|
||||
// manage this apps subscriptions on the server side, send the
|
||||
// Instance ID token to your app server.
|
||||
sendRegistrationToServer(token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist token to third-party servers.
|
||||
*
|
||||
* Modify this method to associate the user's FCM InstanceID token with any server-side account
|
||||
* maintained by your application.
|
||||
*
|
||||
* @param token The new token.
|
||||
*/
|
||||
private void sendRegistrationToServer(String token) {
|
||||
// TODO: Implement this method to send token to your app server.
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and show a simple notification containing the received FCM message.
|
||||
*
|
||||
* @param messageBody FCM message body received.
|
||||
*/
|
||||
private void sendNotification(String title, String messageBody, String type, String url, String name) {
|
||||
//Intent intent = new Intent(this, MainActivity.class);
|
||||
//intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
if (url == null) {
|
||||
if (TYPE_REWARD.equals(type)) {
|
||||
url = "lbry://?rewards";
|
||||
} else {
|
||||
// default to home page
|
||||
url = "lbry://?discover";
|
||||
}
|
||||
}
|
||||
|
||||
Intent launchIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
launchIntent.putExtra("notification_name", name);
|
||||
launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, launchIntent, PendingIntent.FLAG_ONE_SHOT);
|
||||
|
||||
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
|
||||
NotificationCompat.Builder notificationBuilder =
|
||||
new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
|
||||
.setColor(ContextCompat.getColor(this, R.color.lbryGreen))
|
||||
.setSmallIcon(R.drawable.ic_lbry)
|
||||
.setContentTitle(title)
|
||||
.setContentText(messageBody)
|
||||
.setAutoCancel(true)
|
||||
.setSound(defaultSoundUri)
|
||||
.setContentIntent(pendingIntent);
|
||||
|
||||
NotificationManager notificationManager =
|
||||
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
// Since android Oreo notification channel is needed.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel channel = new NotificationChannel(
|
||||
NOTIFICATION_CHANNEL_ID, "LBRY Engagement", NotificationManager.IMPORTANCE_DEFAULT);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
notificationManager.notify(3, notificationBuilder.build());
|
||||
}
|
||||
|
||||
public List<String> getEnabledTypes() {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
List<String> enabledTypes = new ArrayList<String>();
|
||||
|
||||
if (sp.getBoolean(MainActivity.PREFERENCE_KEY_NOTIFICATION_COMMENTS, true)) {
|
||||
enabledTypes.add(TYPE_COMMENT);
|
||||
}
|
||||
if (sp.getBoolean(MainActivity.PREFERENCE_KEY_NOTIFICATION_SUBSCRIPTIONS, true)) {
|
||||
enabledTypes.add(TYPE_SUBSCRIPTION);
|
||||
}
|
||||
if (sp.getBoolean(MainActivity.PREFERENCE_KEY_NOTIFICATION_REWARDS, true)) {
|
||||
enabledTypes.add(TYPE_REWARD);
|
||||
}
|
||||
if (sp.getBoolean(MainActivity.PREFERENCE_KEY_NOTIFICATION_CONTENT_INTERESTS, true)) {
|
||||
enabledTypes.add(TYPE_INTERESTS);
|
||||
}
|
||||
if (sp.getBoolean(MainActivity.PREFERENCE_KEY_NOTIFICATION_CREATOR, true)) {
|
||||
enabledTypes.add(TYPE_CREATOR);
|
||||
}
|
||||
|
||||
return enabledTypes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package io.lbry.browser;
|
||||
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
public class LocalFileProvider extends FileProvider {
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,469 @@
|
||||
package io.lbry.browser;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.graphics.Color;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.android.billingclient.api.BillingClient;
|
||||
import com.android.billingclient.api.BillingClientStateListener;
|
||||
import com.android.billingclient.api.BillingFlowParams;
|
||||
import com.android.billingclient.api.BillingResult;
|
||||
import com.android.billingclient.api.Purchase;
|
||||
import com.android.billingclient.api.PurchasesUpdatedListener;
|
||||
import com.android.billingclient.api.SkuDetails;
|
||||
import com.android.billingclient.api.SkuDetailsParams;
|
||||
import com.android.billingclient.api.SkuDetailsResponseListener;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.adapter.VerificationPagerAdapter;
|
||||
import io.lbry.browser.listener.SdkStatusListener;
|
||||
import io.lbry.browser.listener.SignInListener;
|
||||
import io.lbry.browser.listener.WalletSyncListener;
|
||||
import io.lbry.browser.model.lbryinc.RewardVerified;
|
||||
import io.lbry.browser.model.lbryinc.User;
|
||||
import io.lbry.browser.tasks.RewardVerifiedHandler;
|
||||
import io.lbry.browser.tasks.lbryinc.FetchCurrentUserTask;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import io.lbry.browser.utils.LbryAnalytics;
|
||||
import io.lbry.browser.utils.Lbryio;
|
||||
import io.lbry.lbrysdk.LbrynetService;
|
||||
|
||||
public class VerificationActivity extends FragmentActivity implements SignInListener, WalletSyncListener {
|
||||
|
||||
public static final int VERIFICATION_FLOW_SIGN_IN = 1;
|
||||
public static final int VERIFICATION_FLOW_REWARDS = 2;
|
||||
public static final int VERIFICATION_FLOW_WALLET = 3;
|
||||
|
||||
private List<SdkStatusListener> sdkStatusListeners;
|
||||
private BillingClient billingClient;
|
||||
private BroadcastReceiver sdkReceiver;
|
||||
private String email;
|
||||
private boolean signedIn;
|
||||
private int flow;
|
||||
|
||||
private final PurchasesUpdatedListener purchasesUpdatedListener = new PurchasesUpdatedListener() {
|
||||
@Override
|
||||
public void onPurchasesUpdated(@NonNull BillingResult billingResult, @Nullable List<Purchase> purchases) {
|
||||
int responseCode = billingResult.getResponseCode();
|
||||
if (responseCode == BillingClient.BillingResponseCode.OK && purchases != null)
|
||||
{
|
||||
for (Purchase purchase : purchases) {
|
||||
if (MainActivity.SKU_SKIP.equalsIgnoreCase(purchase.getSku())) {
|
||||
showLoading();
|
||||
MainActivity.handleBillingPurchase(
|
||||
purchase,
|
||||
billingClient,
|
||||
VerificationActivity.this, null, new RewardVerifiedHandler() {
|
||||
@Override
|
||||
public void onSuccess(RewardVerified rewardVerified) {
|
||||
if (Lbryio.currentUser != null) {
|
||||
Lbryio.currentUser.setRewardApproved(rewardVerified.isRewardApproved());
|
||||
}
|
||||
|
||||
if (!rewardVerified.isRewardApproved()) {
|
||||
// show pending purchase message (possible slow card tx)
|
||||
Snackbar.make(findViewById(R.id.verification_pager), R.string.purchase_request_pending, Snackbar.LENGTH_LONG).show();
|
||||
} else {
|
||||
Snackbar.make(findViewById(R.id.verification_pager), R.string.reward_verification_successful, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
setResult(RESULT_OK);
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finish();
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
showFetchUserError(getString(R.string.purchase_request_failed_error));
|
||||
hideLoading();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
sdkStatusListeners = new ArrayList<>();
|
||||
|
||||
signedIn = Lbryio.isSignedIn();
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
flow = intent.getIntExtra("flow", -1);
|
||||
if (flow == -1 || (flow == VERIFICATION_FLOW_SIGN_IN && signedIn)) {
|
||||
// no flow specified (or user is already signed in), just exit
|
||||
setResult(signedIn ? RESULT_OK : RESULT_CANCELED);
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Arrays.asList(VERIFICATION_FLOW_SIGN_IN, VERIFICATION_FLOW_REWARDS, VERIFICATION_FLOW_WALLET).contains(flow)) {
|
||||
// invalid flow specified
|
||||
setResult(RESULT_CANCELED);
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(LbrynetService.ACTION_STOP_SERVICE);
|
||||
filter.addAction(MainActivity.ACTION_SDK_READY);
|
||||
sdkReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (MainActivity.ACTION_SDK_READY.equals(action)) {
|
||||
for (SdkStatusListener listener : sdkStatusListeners) {
|
||||
if (listener != null) {
|
||||
listener.onSdkReady();
|
||||
}
|
||||
}
|
||||
} else if (LbrynetService.ACTION_STOP_SERVICE.equals(action)) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
};
|
||||
registerReceiver(sdkReceiver, filter);
|
||||
|
||||
billingClient = BillingClient.newBuilder(this)
|
||||
.setListener(purchasesUpdatedListener)
|
||||
.enablePendingPurchases()
|
||||
.build();
|
||||
establishBillingClientConnection();
|
||||
|
||||
setContentView(R.layout.activity_verification);
|
||||
ViewPager2 viewPager = findViewById(R.id.verification_pager);
|
||||
viewPager.setUserInputEnabled(false);
|
||||
viewPager.setSaveEnabled(false);
|
||||
viewPager.setAdapter(new VerificationPagerAdapter(this));
|
||||
|
||||
findViewById(R.id.verification_close_button).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.verification_close_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
setResult(RESULT_CANCELED);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void establishBillingClientConnection() {
|
||||
if (billingClient != null) {
|
||||
billingClient.startConnection(new BillingClientStateListener() {
|
||||
@Override
|
||||
public void onBillingSetupFinished(@NonNull BillingResult billingResult) {
|
||||
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
|
||||
// no need to do anything here. purchases are always checked server-side
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBillingServiceDisconnected() {
|
||||
establishBillingClientConnection();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
LbryAnalytics.setCurrentScreen(this, "Verification", "Verification");
|
||||
checkFlow();
|
||||
}
|
||||
|
||||
public void checkFlow() {
|
||||
ViewPager2 viewPager = findViewById(R.id.verification_pager);
|
||||
if (Lbryio.isSignedIn()) {
|
||||
boolean flowHandled = false;
|
||||
if (flow == VERIFICATION_FLOW_WALLET) {
|
||||
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_WALLET, false);
|
||||
flowHandled = true;
|
||||
} else if (flow == VERIFICATION_FLOW_REWARDS) {
|
||||
User user = Lbryio.currentUser;
|
||||
// disable phone verification for now
|
||||
if (!user.isIdentityVerified()) {
|
||||
// phone number verification required
|
||||
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_PHONE, false);
|
||||
flowHandled = true;
|
||||
} else {
|
||||
if (!user.isRewardApproved()) {
|
||||
// manual verification required
|
||||
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL, false);
|
||||
flowHandled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flowHandled) {
|
||||
// user has already been verified and or reward approved
|
||||
setResult(RESULT_CANCELED);
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showPhoneVerification() {
|
||||
ViewPager2 viewPager = findViewById(R.id.verification_pager);
|
||||
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_PHONE, false);
|
||||
}
|
||||
|
||||
public void showLoading() {
|
||||
findViewById(R.id.verification_loading_progress).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.verification_pager).setVisibility(View.INVISIBLE);
|
||||
findViewById(R.id.verification_close_button).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void hideLoading() {
|
||||
findViewById(R.id.verification_loading_progress).setVisibility(View.GONE);
|
||||
findViewById(R.id.verification_pager).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
ViewPager2 viewPager = findViewById(R.id.verification_pager);
|
||||
|
||||
if (viewPager.getCurrentItem() != VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL)
|
||||
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL);
|
||||
else
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
public void onEmailAdded(String email) {
|
||||
this.email = email;
|
||||
findViewById(R.id.verification_close_button).setVisibility(View.GONE);
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("email", email);
|
||||
LbryAnalytics.logEvent(LbryAnalytics.EVENT_EMAIL_ADDED, bundle);
|
||||
}
|
||||
public void onEmailEdit() {
|
||||
findViewById(R.id.verification_close_button).setVisibility(View.VISIBLE);
|
||||
}
|
||||
public void onEmailVerified() {
|
||||
Snackbar.make(findViewById(R.id.verification_pager), R.string.sign_in_successful, Snackbar.LENGTH_LONG).show();
|
||||
sendBroadcast(new Intent(MainActivity.ACTION_USER_SIGN_IN_SUCCESS));
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("email", email);
|
||||
LbryAnalytics.logEvent(LbryAnalytics.EVENT_EMAIL_VERIFIED, bundle);
|
||||
|
||||
if (flow == VERIFICATION_FLOW_SIGN_IN) {
|
||||
final Intent resultIntent = new Intent();
|
||||
resultIntent.putExtra("flow", VERIFICATION_FLOW_SIGN_IN);
|
||||
resultIntent.putExtra("email", email);
|
||||
|
||||
// only sign in required, don't do anything else
|
||||
showLoading();
|
||||
FetchCurrentUserTask task = new FetchCurrentUserTask(this, new FetchCurrentUserTask.FetchUserTaskHandler() {
|
||||
@Override
|
||||
public void onSuccess(User user) {
|
||||
Lbryio.currentUser = user;
|
||||
setResult(RESULT_OK, resultIntent);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
showFetchUserError(error != null ? error.getMessage() : getString(R.string.fetch_current_user_error));
|
||||
hideLoading();
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} else {
|
||||
// change pager view depending on flow
|
||||
showLoading();
|
||||
FetchCurrentUserTask task = new FetchCurrentUserTask(this, new FetchCurrentUserTask.FetchUserTaskHandler() {
|
||||
@Override
|
||||
public void onSuccess(User user) {
|
||||
hideLoading();
|
||||
findViewById(R.id.verification_close_button).setVisibility(View.VISIBLE);
|
||||
|
||||
Lbryio.currentUser = user;
|
||||
ViewPager2 viewPager = findViewById(R.id.verification_pager);
|
||||
// for rewards, (show phone verification if not done, or manual verification if required)
|
||||
if (flow == VERIFICATION_FLOW_REWARDS) {
|
||||
if (!user.isIdentityVerified()) {
|
||||
// phone number verification required
|
||||
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_PHONE, false);
|
||||
} else {
|
||||
if (!user.isRewardApproved()) {
|
||||
// manual verification required
|
||||
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL, false);
|
||||
} else {
|
||||
// fully verified
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
} else if (flow == VERIFICATION_FLOW_WALLET) {
|
||||
// for wallet sync, if password unlock is required, show password entry page
|
||||
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_WALLET, false);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
showFetchUserError(error != null ? error.getMessage() : getString(R.string.fetch_current_user_error));
|
||||
hideLoading();
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPhoneAdded(String countryCode, String phoneNumber) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPhoneVerified() {
|
||||
showLoading();
|
||||
FetchCurrentUserTask task = new FetchCurrentUserTask(this, new FetchCurrentUserTask.FetchUserTaskHandler() {
|
||||
@Override
|
||||
public void onSuccess(User user) {
|
||||
Lbryio.currentUser = user;
|
||||
if (user.isIdentityVerified() && user.isRewardApproved()) {
|
||||
// verified for rewards
|
||||
LbryAnalytics.logEvent(LbryAnalytics.EVENT_REWARD_ELIGIBILITY_COMPLETED);
|
||||
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
findViewById(R.id.verification_close_button).setVisibility(View.VISIBLE);
|
||||
// show manual verification page if the user is still not reward approved
|
||||
ViewPager2 viewPager = findViewById(R.id.verification_pager);
|
||||
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL, false);
|
||||
hideLoading();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
showFetchUserError(error != null ? error.getMessage() : getString(R.string.fetch_current_user_error));
|
||||
hideLoading();
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
private void showFetchUserError(String message) {
|
||||
Snackbar.make(findViewById(R.id.verification_pager), message, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onManualVerifyContinue() {
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalletSyncProcessing() {
|
||||
findViewById(R.id.verification_close_button).setVisibility(View.GONE);
|
||||
}
|
||||
@Override
|
||||
public void onWalletSyncWaitingForInput() {
|
||||
findViewById(R.id.verification_close_button).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalletSyncEnabled() {
|
||||
findViewById(R.id.verification_close_button).setVisibility(View.VISIBLE);
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalletSyncFailed(Exception error) {
|
||||
findViewById(R.id.verification_close_button).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSkipQueueAction() {
|
||||
if (billingClient != null) {
|
||||
List<String> skuList = new ArrayList<>();
|
||||
skuList.add(MainActivity.SKU_SKIP);
|
||||
|
||||
SkuDetailsParams detailsParams = SkuDetailsParams.newBuilder().
|
||||
setType(BillingClient.SkuType.INAPP).
|
||||
setSkusList(skuList).build();
|
||||
billingClient.querySkuDetailsAsync(detailsParams, new SkuDetailsResponseListener() {
|
||||
@Override
|
||||
public void onSkuDetailsResponse(@NonNull BillingResult billingResult, @Nullable List<SkuDetails> list) {
|
||||
if (list != null && list.size() > 0) {
|
||||
// we only queried one product, so it should be the first item in the list
|
||||
SkuDetails skuDetails = list.get(0);
|
||||
|
||||
// launch the billing flow for skip queue
|
||||
BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder().
|
||||
setSkuDetails(skuDetails).build();
|
||||
billingClient.launchBillingFlow(VerificationActivity.this, billingFlowParams);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTwitterVerified() {
|
||||
Snackbar.make(findViewById(R.id.verification_pager), R.string.reward_verification_successful, Snackbar.LENGTH_LONG).show();
|
||||
|
||||
setResult(RESULT_OK);
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finish();
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onManualProgress(boolean progress) {
|
||||
if (progress) {
|
||||
findViewById(R.id.verification_close_button).setVisibility(View.GONE);
|
||||
} else {
|
||||
findViewById(R.id.verification_close_button).setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
Helper.unregisterReceiver(sdkReceiver, this);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
public void addSdkStatusListener(SdkStatusListener listener) {
|
||||
if (!sdkStatusListeners.contains(listener)) {
|
||||
sdkStatusListeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeSdkStatusListener(SdkStatusListener listener) {
|
||||
sdkStatusListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package io.lbry.browser.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.model.Claim;
|
||||
import io.lbry.browser.listener.ChannelItemSelectionListener;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class ChannelFilterListAdapter extends RecyclerView.Adapter<ChannelFilterListAdapter.ViewHolder> {
|
||||
private final Context context;
|
||||
private List<Claim> items;
|
||||
@Getter
|
||||
@Setter
|
||||
private Claim selectedItem;
|
||||
@Setter
|
||||
private ChannelItemSelectionListener listener;
|
||||
|
||||
public ChannelFilterListAdapter(Context context) {
|
||||
this.context = context;
|
||||
this.items = new ArrayList<>();
|
||||
|
||||
// Always list the placeholder as the first item
|
||||
Claim claim = new Claim();
|
||||
claim.setPlaceholder(true);
|
||||
items.add(claim);
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
protected final View mediaContainer;
|
||||
protected final View alphaContainer;
|
||||
protected final View allView;
|
||||
protected final ImageView thumbnailView;
|
||||
protected final TextView alphaView;
|
||||
protected final TextView titleView;
|
||||
public ViewHolder(View v) {
|
||||
super(v);
|
||||
mediaContainer = v.findViewById(R.id.channel_filter_media_container);
|
||||
alphaContainer = v.findViewById(R.id.channel_filter_no_thumbnail);
|
||||
alphaView = v.findViewById(R.id.channel_filter_alpha_view);
|
||||
thumbnailView = v.findViewById(R.id.channel_filter_thumbnail);
|
||||
titleView = v.findViewById(R.id.channel_filter_title);
|
||||
allView = v.findViewById(R.id.channel_filter_all_container);
|
||||
}
|
||||
}
|
||||
|
||||
public int getItemCount() {
|
||||
return items != null ? items.size() : 0;
|
||||
}
|
||||
|
||||
public boolean isClaimSelected(Claim claim) {
|
||||
return claim.equals(selectedItem);
|
||||
}
|
||||
|
||||
public void clearClaims() {
|
||||
items = new ArrayList<>(items.subList(0, 1));
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void addClaims(List<Claim> claims) {
|
||||
for (Claim claim : claims) {
|
||||
if (!items.contains(claim)) {
|
||||
items.add(claim);
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFilterListAdapter.ViewHolder onCreateViewHolder(ViewGroup root, int viewType) {
|
||||
View v = LayoutInflater.from(context).inflate(R.layout.list_item_channel_filter, root, false);
|
||||
return new ChannelFilterListAdapter.ViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ChannelFilterListAdapter.ViewHolder vh, int position) {
|
||||
Claim claim = items.get(position);
|
||||
vh.alphaView.setVisibility(claim.isPlaceholder() ? View.GONE : View.VISIBLE);
|
||||
vh.titleView.setVisibility(claim.isPlaceholder() ? View.INVISIBLE : View.VISIBLE);
|
||||
vh.allView.setVisibility(claim.isPlaceholder() ? View.VISIBLE : View.GONE);
|
||||
|
||||
vh.titleView.setText(Helper.isNullOrEmpty(claim.getTitle()) ? claim.getName() : claim.getTitle());
|
||||
String thumbnailUrl = claim.getThumbnailUrl();
|
||||
if (!Helper.isNullOrEmpty(thumbnailUrl) && context != null) {
|
||||
Glide.with(context.getApplicationContext()).load(thumbnailUrl).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView);
|
||||
}
|
||||
vh.alphaContainer.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.VISIBLE : View.GONE);
|
||||
vh.thumbnailView.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.GONE : View.VISIBLE);
|
||||
vh.alphaView.setText(claim.isPlaceholder() ? null : claim.getName() != null ? claim.getName().substring(1, 2).toUpperCase() : "");
|
||||
|
||||
int bgColor = Helper.generateRandomColorForValue(claim.getClaimId());
|
||||
Helper.setIconViewBackgroundColor(vh.alphaContainer, bgColor, claim.isPlaceholder(), context);
|
||||
|
||||
vh.itemView.setSelected(isClaimSelected(claim));
|
||||
vh.itemView.setOnClickListener(view -> {
|
||||
if (claim.isPlaceholder()) {
|
||||
selectedItem = null;
|
||||
if (listener != null) {
|
||||
listener.onChannelSelectionCleared();
|
||||
}
|
||||
} else if (!claim.equals(selectedItem)) {
|
||||
selectedItem = claim;
|
||||
if (listener != null) {
|
||||
listener.onChannelItemSelected(claim);
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,524 @@
|
||||
package io.lbry.browser.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.listener.SelectionModeListener;
|
||||
import io.lbry.browser.model.Claim;
|
||||
import io.lbry.browser.model.LbryFile;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import io.lbry.browser.utils.LbryUri;
|
||||
import io.lbry.browser.utils.Lbryio;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.ViewHolder> {
|
||||
private static final int VIEW_TYPE_STREAM = 1;
|
||||
private static final int VIEW_TYPE_CHANNEL = 2;
|
||||
private static final int VIEW_TYPE_FEATURED = 3; // featured search result
|
||||
|
||||
private final Map<String, Claim> quickClaimIdMap;
|
||||
private final Map<String, Claim> quickClaimUrlMap;
|
||||
private final Map<String, Boolean> notFoundClaimIdMap;
|
||||
private final Map<String, Boolean> notFoundClaimUrlMap;
|
||||
|
||||
@Setter
|
||||
private boolean hideFee;
|
||||
@Setter
|
||||
private boolean canEnterSelectionMode;
|
||||
private final Context context;
|
||||
private List<Claim> items;
|
||||
private final List<Claim> selectedItems;
|
||||
@Setter
|
||||
private ClaimListItemListener listener;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean inSelectionMode;
|
||||
@Setter
|
||||
private SelectionModeListener selectionModeListener;
|
||||
private float scale;
|
||||
|
||||
public ClaimListAdapter(List<Claim> items, Context context) {
|
||||
this.context = context;
|
||||
this.items = new ArrayList<>();
|
||||
for (Claim item : items) {
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
this.selectedItems = new ArrayList<>();
|
||||
quickClaimIdMap = new HashMap<>();
|
||||
quickClaimUrlMap = new HashMap<>();
|
||||
notFoundClaimIdMap = new HashMap<>();
|
||||
notFoundClaimUrlMap = new HashMap<>();
|
||||
if (context != null) {
|
||||
scale = context.getResources().getDisplayMetrics().density;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Claim> getSelectedItems() {
|
||||
return this.selectedItems;
|
||||
}
|
||||
public int getSelectedCount() {
|
||||
return selectedItems != null ? selectedItems.size() : 0;
|
||||
}
|
||||
public void clearSelectedItems() {
|
||||
this.selectedItems.clear();
|
||||
}
|
||||
public boolean isClaimSelected(Claim claim) {
|
||||
return selectedItems.contains(claim);
|
||||
}
|
||||
|
||||
public Claim getFeaturedItem() {
|
||||
for (Claim claim : items) {
|
||||
if (claim.isFeatured()) {
|
||||
return claim;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void removeFeaturedItem() {
|
||||
int featuredIndex = -1;
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
if (items.get(i).isFeatured()) {
|
||||
featuredIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (featuredIndex > -1) {
|
||||
items.remove(featuredIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Claim> getItems() {
|
||||
return new ArrayList<>(this.items);
|
||||
}
|
||||
|
||||
public void updateSigningChannelForClaim(Claim resolvedClaim) {
|
||||
for (Claim claim : items) {
|
||||
if (claim.getClaimId().equalsIgnoreCase(resolvedClaim.getClaimId())) {
|
||||
claim.setSigningChannel(resolvedClaim.getSigningChannel());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clearItems() {
|
||||
clearSelectedItems();
|
||||
this.items.clear();
|
||||
quickClaimIdMap.clear();
|
||||
quickClaimUrlMap.clear();
|
||||
notFoundClaimIdMap.clear();
|
||||
notFoundClaimUrlMap.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public Claim getLastItem() {
|
||||
return items.size() > 0 ? items.get(items.size() - 1) : null;
|
||||
}
|
||||
|
||||
public void addFeaturedItem(Claim claim) {
|
||||
items.add(0, claim);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void addItems(List<Claim> claims) {
|
||||
for (Claim claim : claims) {
|
||||
if (claim != null && !items.contains(claim)) {
|
||||
items.add(claim);
|
||||
}
|
||||
}
|
||||
|
||||
notFoundClaimUrlMap.clear();
|
||||
notFoundClaimIdMap.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
public void setItems(List<Claim> claims) {
|
||||
items = new ArrayList<>();
|
||||
for (Claim claim : claims) {
|
||||
if (claim != null) {
|
||||
items.add(claim);
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void removeItems(List<Claim> claims) {
|
||||
items.removeAll(claims);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void removeItem(Claim claim) {
|
||||
items.remove(claim);
|
||||
selectedItems.remove(claim);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
protected final View feeContainer;
|
||||
protected final TextView feeView;
|
||||
protected final ImageView thumbnailView;
|
||||
protected final View noThumbnailView;
|
||||
protected final TextView alphaView;
|
||||
protected final TextView vanityUrlView;
|
||||
protected final TextView durationView;
|
||||
protected final TextView titleView;
|
||||
protected final TextView publisherView;
|
||||
protected final TextView publishTimeView;
|
||||
protected final TextView pendingTextView;
|
||||
protected final View repostInfoView;
|
||||
protected final TextView repostChannelView;
|
||||
protected final View selectedOverlayView;
|
||||
protected final TextView fileSizeView;
|
||||
protected final ProgressBar downloadProgressView;
|
||||
protected final TextView deviceView;
|
||||
|
||||
protected final View loadingImagePlaceholder;
|
||||
protected final View loadingTextPlaceholder1;
|
||||
protected final View loadingTextPlaceholder2;
|
||||
public ViewHolder(View v) {
|
||||
super(v);
|
||||
feeContainer = v.findViewById(R.id.claim_fee_container);
|
||||
feeView = v.findViewById(R.id.claim_fee);
|
||||
alphaView = v.findViewById(R.id.claim_thumbnail_alpha);
|
||||
noThumbnailView = v.findViewById(R.id.claim_no_thumbnail);
|
||||
thumbnailView = v.findViewById(R.id.claim_thumbnail);
|
||||
vanityUrlView = v.findViewById(R.id.claim_vanity_url);
|
||||
durationView = v.findViewById(R.id.claim_duration);
|
||||
titleView = v.findViewById(R.id.claim_title);
|
||||
publisherView = v.findViewById(R.id.claim_publisher);
|
||||
publishTimeView = v.findViewById(R.id.claim_publish_time);
|
||||
pendingTextView = v.findViewById(R.id.claim_pending_text);
|
||||
repostInfoView = v.findViewById(R.id.claim_repost_info);
|
||||
repostChannelView = v.findViewById(R.id.claim_repost_channel);
|
||||
selectedOverlayView = v.findViewById(R.id.claim_selected_overlay);
|
||||
fileSizeView = v.findViewById(R.id.claim_file_size);
|
||||
downloadProgressView = v.findViewById(R.id.claim_download_progress);
|
||||
deviceView = v.findViewById(R.id.claim_view_device);
|
||||
|
||||
loadingImagePlaceholder = v.findViewById(R.id.claim_thumbnail_placeholder);
|
||||
loadingTextPlaceholder1 = v.findViewById(R.id.claim_text_loading_placeholder_1);
|
||||
loadingTextPlaceholder2 = v.findViewById(R.id.claim_text_loading_placeholder_2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return items != null ? items.size() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (items.get(position).isFeatured()) {
|
||||
return VIEW_TYPE_FEATURED;
|
||||
}
|
||||
|
||||
Claim claim = items.get(position);
|
||||
String valueType = items.get(position).getValueType();
|
||||
Claim actualClaim = Claim.TYPE_REPOST.equalsIgnoreCase(valueType) ? claim.getRepostedClaim() : claim;
|
||||
|
||||
return Claim.TYPE_CHANNEL.equalsIgnoreCase(actualClaim.getValueType()) ? VIEW_TYPE_CHANNEL : VIEW_TYPE_STREAM;
|
||||
}
|
||||
|
||||
public void updateFileForClaimByIdOrUrl(LbryFile file, String claimId, String url) {
|
||||
updateFileForClaimByIdOrUrl(file, claimId, url, false);
|
||||
}
|
||||
public void updateFileForClaimByIdOrUrl(LbryFile file, String claimId, String url, boolean skipNotFound) {
|
||||
if (!skipNotFound) {
|
||||
if (notFoundClaimIdMap.containsKey(claimId) && notFoundClaimUrlMap.containsKey(url)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (quickClaimIdMap.containsKey(claimId)) {
|
||||
quickClaimIdMap.get(claimId).setFile(file);
|
||||
notifyDataSetChanged();
|
||||
return;
|
||||
}
|
||||
if (quickClaimUrlMap.containsKey(claimId)) {
|
||||
quickClaimUrlMap.get(claimId).setFile(file);
|
||||
notifyDataSetChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
boolean claimFound = false;
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
Claim claim = items.get(i);
|
||||
if (claimId.equalsIgnoreCase(claim.getClaimId()) || url.equalsIgnoreCase(claim.getPermanentUrl())) {
|
||||
quickClaimIdMap.put(claimId, claim);
|
||||
quickClaimUrlMap.put(url, claim);
|
||||
claim.setFile(file);
|
||||
notifyDataSetChanged();
|
||||
claimFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!claimFound) {
|
||||
notFoundClaimIdMap.put(claimId, true);
|
||||
notFoundClaimUrlMap.put(url, true);
|
||||
}
|
||||
}
|
||||
public void clearFileForClaimOrUrl(String outpoint, String url) {
|
||||
clearFileForClaimOrUrl(outpoint, url, false);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
public void clearFileForClaimOrUrl(String outpoint, String url, boolean remove) {
|
||||
int claimIndex = -1;
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
Claim claim = items.get(i);
|
||||
if (outpoint.equalsIgnoreCase(claim.getOutpoint()) || url.equalsIgnoreCase(claim.getPermanentUrl())) {
|
||||
claimIndex = i;
|
||||
claim.setFile(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (remove && claimIndex > -1) {
|
||||
Claim removed = items.remove(claimIndex);
|
||||
selectedItems.remove(removed);
|
||||
}
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClaimListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
int viewResourceId = -1;
|
||||
switch (viewType) {
|
||||
case VIEW_TYPE_FEATURED: viewResourceId = R.layout.list_item_featured_search_result; break;
|
||||
case VIEW_TYPE_CHANNEL: viewResourceId = R.layout.list_item_channel; break;
|
||||
case VIEW_TYPE_STREAM: default: viewResourceId = R.layout.list_item_stream; break;
|
||||
}
|
||||
|
||||
View v = LayoutInflater.from(context).inflate(viewResourceId, parent, false);
|
||||
return new ClaimListAdapter.ViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ClaimListAdapter.ViewHolder vh, int position) {
|
||||
int type = getItemViewType(position);
|
||||
int paddingTop = position == 0 ? 16 : 8;
|
||||
int paddingBottom = position == getItemCount() - 1 ? 16 : 8;
|
||||
int paddingTopScaled = Helper.getScaledValue(paddingTop, scale);
|
||||
int paddingBottomScaled = Helper.getScaledValue(paddingBottom, scale);
|
||||
vh.itemView.setPadding(vh.itemView.getPaddingStart(), paddingTopScaled, vh.itemView.getPaddingEnd(), paddingBottomScaled);
|
||||
|
||||
Claim original = items.get(position);
|
||||
boolean isRepost = Claim.TYPE_REPOST.equalsIgnoreCase(original.getValueType());
|
||||
final Claim item = Claim.TYPE_REPOST.equalsIgnoreCase(original.getValueType()) ?
|
||||
(original.getRepostedClaim() != null ? original.getRepostedClaim() : original): original;
|
||||
Claim.GenericMetadata metadata = item.getValue();
|
||||
Claim signingChannel = item.getSigningChannel();
|
||||
Claim.StreamMetadata streamMetadata = null;
|
||||
if (metadata instanceof Claim.StreamMetadata) {
|
||||
streamMetadata = (Claim.StreamMetadata) metadata;
|
||||
}
|
||||
String thumbnailUrl = item.getThumbnailUrl();
|
||||
long publishTime = (streamMetadata != null && streamMetadata.getReleaseTime() > 0) ? streamMetadata.getReleaseTime() * 1000 : item.getTimestamp() * 1000;
|
||||
int bgColor = Helper.generateRandomColorForValue(item.getClaimId());
|
||||
if (bgColor == 0) {
|
||||
bgColor = Helper.generateRandomColorForValue(item.getName());
|
||||
}
|
||||
|
||||
boolean isPending = item.getConfirmations() == 0;
|
||||
boolean isSelected = isClaimSelected(original);
|
||||
vh.itemView.setSelected(isSelected);
|
||||
vh.selectedOverlayView.setVisibility(isSelected ? View.VISIBLE : View.GONE);
|
||||
vh.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (isPending) {
|
||||
Snackbar snackbar = Snackbar.make(vh.itemView, R.string.item_pending_blockchain, Snackbar.LENGTH_LONG);
|
||||
TextView snackbarText = snackbar.getView().findViewById(com.google.android.material.R.id.snackbar_text);
|
||||
snackbarText.setMaxLines(5);
|
||||
snackbar.show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (inSelectionMode) {
|
||||
toggleSelectedClaim(original);
|
||||
} else {
|
||||
if (listener != null) {
|
||||
listener.onClaimClicked(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
vh.itemView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
if (!canEnterSelectionMode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isPending) {
|
||||
Snackbar snackbar = Snackbar.make(vh.itemView, R.string.item_pending_blockchain, Snackbar.LENGTH_LONG);
|
||||
TextView snackbarText = snackbar.getView().findViewById(com.google.android.material.R.id.snackbar_text);
|
||||
snackbarText.setMaxLines(5);
|
||||
snackbar.show();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!inSelectionMode) {
|
||||
inSelectionMode = true;
|
||||
if (selectionModeListener != null) {
|
||||
selectionModeListener.onEnterSelectionMode();
|
||||
}
|
||||
}
|
||||
toggleSelectedClaim(original);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
vh.publisherView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null && signingChannel != null) {
|
||||
listener.onClaimClicked(signingChannel);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
vh.publishTimeView.setVisibility(!isPending ? View.VISIBLE : View.GONE);
|
||||
vh.pendingTextView.setVisibility(isPending && !item.isLoadingPlaceholder() ? View.VISIBLE : View.GONE);
|
||||
vh.repostInfoView.setVisibility(isRepost && type != VIEW_TYPE_FEATURED ? View.VISIBLE : View.GONE);
|
||||
vh.repostChannelView.setText(isRepost && original.getSigningChannel() != null ? original.getSigningChannel().getName() : null);
|
||||
vh.repostChannelView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
listener.onClaimClicked(original.getSigningChannel());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
vh.titleView.setText(Helper.isNullOrEmpty(item.getTitle()) ? item.getName() : item.getTitle());
|
||||
if (type == VIEW_TYPE_FEATURED) {
|
||||
LbryUri vanityUrl = new LbryUri();
|
||||
vanityUrl.setClaimName(item.getName());
|
||||
vh.vanityUrlView.setText(vanityUrl.toString());
|
||||
}
|
||||
|
||||
vh.feeContainer.setVisibility(item.isUnresolved() || !Claim.TYPE_STREAM.equalsIgnoreCase(item.getValueType()) ? View.GONE : View.VISIBLE);
|
||||
vh.noThumbnailView.setVisibility(Helper.isNullOrEmpty(thumbnailUrl) ? View.VISIBLE : View.GONE);
|
||||
Helper.setIconViewBackgroundColor(vh.noThumbnailView, bgColor, false, context);
|
||||
|
||||
Helper.setViewVisibility(vh.loadingImagePlaceholder, item.isLoadingPlaceholder() ? View.VISIBLE : View.GONE);
|
||||
Helper.setViewVisibility(vh.loadingTextPlaceholder1, item.isLoadingPlaceholder() ? View.VISIBLE : View.GONE);
|
||||
Helper.setViewVisibility(vh.loadingTextPlaceholder2, item.isLoadingPlaceholder() ? View.VISIBLE : View.GONE);
|
||||
Helper.setViewVisibility(vh.titleView, !item.isLoadingPlaceholder() ? View.VISIBLE : View.GONE);
|
||||
Helper.setViewVisibility(vh.publisherView, !item.isLoadingPlaceholder() ? View.VISIBLE : View.GONE);
|
||||
Helper.setViewVisibility(vh.publishTimeView, !item.isLoadingPlaceholder() && !isPending ? View.VISIBLE : View.GONE);
|
||||
|
||||
if (type == VIEW_TYPE_FEATURED && item.isUnresolved()) {
|
||||
vh.durationView.setVisibility(View.GONE);
|
||||
vh.titleView.setText("Nothing here. Publish something!");
|
||||
vh.alphaView.setText(item.getName().substring(0, Math.min(5, item.getName().length() - 1)));
|
||||
} else {
|
||||
if (Claim.TYPE_STREAM.equalsIgnoreCase(item.getValueType())) {
|
||||
long duration = item.getDuration();
|
||||
if (!Helper.isNullOrEmpty(thumbnailUrl)) {
|
||||
Glide.with(context.getApplicationContext()).
|
||||
asBitmap().
|
||||
load(thumbnailUrl).
|
||||
centerCrop().
|
||||
placeholder(R.drawable.bg_thumbnail_placeholder).
|
||||
into(vh.thumbnailView);
|
||||
vh.thumbnailView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
vh.thumbnailView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
BigDecimal cost = item.getActualCost(Lbryio.LBCUSDRate);
|
||||
vh.feeContainer.setVisibility(cost.doubleValue() > 0 && !hideFee ? View.VISIBLE : View.GONE);
|
||||
vh.feeView.setText(cost.doubleValue() > 0 ? Helper.shortCurrencyFormat(cost.doubleValue()) : "Paid");
|
||||
vh.alphaView.setText(item.getName().substring(0, Math.min(5, item.getName().length() - 1)));
|
||||
vh.publisherView.setText(signingChannel != null ? signingChannel.getName() : context.getString(R.string.anonymous));
|
||||
vh.publishTimeView.setText(DateUtils.getRelativeTimeSpanString(
|
||||
publishTime, System.currentTimeMillis(), 0, DateUtils.FORMAT_ABBREV_RELATIVE));
|
||||
vh.durationView.setVisibility(duration > 0 ? View.VISIBLE : View.GONE);
|
||||
vh.durationView.setText(Helper.formatDuration(duration));
|
||||
|
||||
LbryFile claimFile = item.getFile();
|
||||
boolean isDownloading = false;
|
||||
int progress = 0;
|
||||
String fileSizeString = claimFile == null ? null : Helper.formatBytes(claimFile.getTotalBytes(), false);
|
||||
if (claimFile != null &&
|
||||
!Helper.isNullOrEmpty(claimFile.getDownloadPath()) &&
|
||||
!claimFile.isCompleted() &&
|
||||
claimFile.getWrittenBytes() < claimFile.getTotalBytes()) {
|
||||
isDownloading = true;
|
||||
progress = claimFile.getTotalBytes() > 0 ?
|
||||
Double.valueOf(((double) claimFile.getWrittenBytes() / (double) claimFile.getTotalBytes()) * 100.0).intValue() : 0;
|
||||
fileSizeString = String.format("%s / %s",
|
||||
Helper.formatBytes(claimFile.getWrittenBytes(), false),
|
||||
Helper.formatBytes(claimFile.getTotalBytes(), false));
|
||||
}
|
||||
|
||||
Helper.setViewText(vh.fileSizeView, claimFile != null && !Helper.isNullOrEmpty(claimFile.getDownloadPath()) ? fileSizeString : null);
|
||||
Helper.setViewVisibility(vh.downloadProgressView, isDownloading ? View.VISIBLE : View.INVISIBLE);
|
||||
Helper.setViewProgress(vh.downloadProgressView, progress);
|
||||
Helper.setViewText(vh.deviceView, item.getDevice());
|
||||
} else if (Claim.TYPE_CHANNEL.equalsIgnoreCase(item.getValueType())) {
|
||||
if (!Helper.isNullOrEmpty(thumbnailUrl)) {
|
||||
Glide.with(context.getApplicationContext()).
|
||||
load(thumbnailUrl).
|
||||
centerCrop().
|
||||
placeholder(R.drawable.bg_thumbnail_placeholder).
|
||||
apply(RequestOptions.circleCropTransform()).
|
||||
into(vh.thumbnailView);
|
||||
}
|
||||
vh.alphaView.setText(item.getName().substring(1, 2).toUpperCase());
|
||||
vh.publisherView.setText(item.getName());
|
||||
vh.publishTimeView.setText(DateUtils.getRelativeTimeSpanString(
|
||||
publishTime, System.currentTimeMillis(), 0, DateUtils.FORMAT_ABBREV_RELATIVE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleSelectedClaim(Claim claim) {
|
||||
if (selectedItems.contains(claim)) {
|
||||
selectedItems.remove(claim);
|
||||
} else {
|
||||
selectedItems.add(claim);
|
||||
}
|
||||
|
||||
if (selectionModeListener != null) {
|
||||
selectionModeListener.onItemSelectionToggled();
|
||||
}
|
||||
|
||||
if (selectedItems.size() == 0) {
|
||||
inSelectionMode = false;
|
||||
if (selectionModeListener != null) {
|
||||
selectionModeListener.onExitSelectionMode();
|
||||
}
|
||||
}
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public interface ClaimListItemListener {
|
||||
void onClaimClicked(Claim claim);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
package io.lbry.browser.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.model.Claim;
|
||||
import io.lbry.browser.model.ClaimCacheKey;
|
||||
import io.lbry.browser.model.Comment;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import io.lbry.browser.utils.Lbry;
|
||||
import io.lbry.browser.utils.LbryUri;
|
||||
import lombok.Setter;
|
||||
|
||||
public class CommentListAdapter extends RecyclerView.Adapter<CommentListAdapter.ViewHolder> {
|
||||
private final List<Comment> items;
|
||||
private final Context context;
|
||||
private final boolean nested;
|
||||
private float scale;
|
||||
@Setter
|
||||
private ClaimListAdapter.ClaimListItemListener listener;
|
||||
@Setter
|
||||
private ReplyClickListener replyListener;
|
||||
|
||||
public CommentListAdapter(List<Comment> items, Context context) {
|
||||
this(items, context, false);
|
||||
}
|
||||
|
||||
public CommentListAdapter(List<Comment> items, Context context, boolean nested) {
|
||||
this.items = new ArrayList<>(items);
|
||||
this.context = context;
|
||||
this.nested = nested;
|
||||
if (context != null) {
|
||||
scale = context.getResources().getDisplayMetrics().density;
|
||||
}
|
||||
for (Comment item : this.items) {
|
||||
ClaimCacheKey key = new ClaimCacheKey();
|
||||
key.setClaimId(item.getChannelId());
|
||||
if (Lbry.claimCache.containsKey(key)) {
|
||||
item.setPoster(Lbry.claimCache.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clearItems() {
|
||||
items.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
public int getPositionForComment(String commentHash) {
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
if (commentHash.equalsIgnoreCase(items.get(i).getId())) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return items != null ? items.size() : 0;
|
||||
}
|
||||
|
||||
public List<String> getClaimUrlsToResolve() {
|
||||
List<String> urls = new ArrayList<>();
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
Comment item = items.get(i);
|
||||
if (item.getPoster() == null) {
|
||||
LbryUri url = LbryUri.tryParse(String.format("%s#%s", item.getChannelName(), item.getChannelId()));
|
||||
if (url != null && !urls.contains(url.toString())) {
|
||||
urls.add(url.toString());
|
||||
}
|
||||
}
|
||||
if (item.getReplies().size() > 0) {
|
||||
for (int j = 0; j < item.getReplies().size(); j++) {
|
||||
Comment reply = item.getReplies().get(j);
|
||||
if (reply.getPoster() == null) {
|
||||
LbryUri url = LbryUri.tryParse(String.format("%s#%s", reply.getChannelName(), reply.getChannelId()));
|
||||
if (url != null && !urls.contains(url.toString())) {
|
||||
urls.add(url.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
protected final TextView channelName;
|
||||
protected final TextView commentText;
|
||||
protected final ImageView thumbnailView;
|
||||
protected final View noThumbnailView;
|
||||
protected final TextView alphaView;
|
||||
protected final TextView commentTimeView;
|
||||
protected final View replyLink;
|
||||
protected final RecyclerView repliesList;
|
||||
|
||||
public ViewHolder (View v) {
|
||||
super(v);
|
||||
channelName = v.findViewById(R.id.comment_channel_name);
|
||||
commentTimeView = v.findViewById(R.id.comment_time);
|
||||
commentText = v.findViewById(R.id.comment_text);
|
||||
replyLink = v.findViewById(R.id.comment_reply_link);
|
||||
thumbnailView = v.findViewById(R.id.comment_thumbnail);
|
||||
noThumbnailView = v.findViewById(R.id.comment_no_thumbnail);
|
||||
alphaView = v.findViewById(R.id.comment_thumbnail_alpha);
|
||||
repliesList = v.findViewById(R.id.comment_replies);
|
||||
}
|
||||
}
|
||||
|
||||
public void insert(int index, Comment comment) {
|
||||
if (!items.contains(comment)) {
|
||||
items.add(index, comment);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void addReply(Comment comment) {
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
Comment parent = items.get(i);
|
||||
if (parent.getId().equalsIgnoreCase(comment.getParentId())) {
|
||||
parent.addReply(comment);
|
||||
notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePosterForComment(String channelId, Claim channel) {
|
||||
for (int i = 0 ; i < items.size(); i++) {
|
||||
Comment item = items.get(i);
|
||||
List<Comment> replies = item.getReplies();
|
||||
if (replies != null && replies.size() > 0) {
|
||||
for (int j = 0; j < replies.size(); j++) {
|
||||
Comment reply = item.getReplies().get(j);
|
||||
if (channelId.equalsIgnoreCase(reply.getChannelId())) {
|
||||
reply.setPoster(channel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (channelId.equalsIgnoreCase(item.getChannelId())) {
|
||||
item.setPoster(channel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(context).inflate(R.layout.list_item_comment, parent, false);
|
||||
return new CommentListAdapter.ViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
Comment comment = items.get(position);
|
||||
holder.itemView.setPadding(
|
||||
nested ? Helper.getScaledValue(56, scale) : holder.itemView.getPaddingStart(),
|
||||
holder.itemView.getPaddingTop(),
|
||||
nested ? 0 : holder.itemView.getPaddingEnd(),
|
||||
holder.itemView.getPaddingBottom());
|
||||
|
||||
holder.channelName.setText(comment.getChannelName());
|
||||
holder.commentTimeView.setText(DateUtils.getRelativeTimeSpanString(
|
||||
(comment.getTimestamp() * 1000), System.currentTimeMillis(), 0, DateUtils.FORMAT_ABBREV_RELATIVE));
|
||||
holder.commentText.setText(comment.getText());
|
||||
holder.replyLink.setVisibility(!nested ? View.VISIBLE : View.GONE);
|
||||
|
||||
boolean hasThumbnail = comment.getPoster() != null && !Helper.isNullOrEmpty(comment.getPoster().getThumbnailUrl());
|
||||
holder.thumbnailView.setVisibility(hasThumbnail ? View.VISIBLE : View.INVISIBLE);
|
||||
holder.noThumbnailView.setVisibility(!hasThumbnail ? View.VISIBLE : View.INVISIBLE);
|
||||
int bgColor = Helper.generateRandomColorForValue(comment.getChannelId());
|
||||
Helper.setIconViewBackgroundColor(holder.noThumbnailView, bgColor, false, context);
|
||||
if (hasThumbnail) {
|
||||
Glide.with(context.getApplicationContext()).asBitmap().load(comment.getPoster().getThumbnailUrl()).
|
||||
apply(RequestOptions.circleCropTransform()).into(holder.thumbnailView);
|
||||
}
|
||||
holder.alphaView.setText(comment.getChannelName() != null ? comment.getChannelName().substring(1, 2).toUpperCase() : null);
|
||||
List<Comment> replies = comment.getReplies();
|
||||
boolean hasReplies = replies != null && replies.size() > 0;
|
||||
if (hasReplies) {
|
||||
holder.repliesList.setLayoutManager(new LinearLayoutManager(context));
|
||||
holder.repliesList.setAdapter(new CommentListAdapter(replies, context, true));
|
||||
} else {
|
||||
holder.repliesList.setAdapter(null);
|
||||
}
|
||||
|
||||
holder.channelName.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null && comment.getPoster() != null) {
|
||||
listener.onClaimClicked(comment.getPoster());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
holder.replyLink.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (replyListener != null) {
|
||||
replyListener.onReplyClicked(comment);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public interface ReplyClickListener {
|
||||
void onReplyClicked(Comment comment);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package io.lbry.browser.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.model.EditorsChoiceItem;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import lombok.Setter;
|
||||
|
||||
public class EditorsChoiceItemAdapter extends RecyclerView.Adapter<EditorsChoiceItemAdapter.ViewHolder> {
|
||||
private static final int VIEW_TYPE_HEADER = 1;
|
||||
private static final int VIEW_TYPE_CONTENT = 2;
|
||||
|
||||
private final Context context;
|
||||
private final List<EditorsChoiceItem> items;
|
||||
@Setter
|
||||
private EditorsChoiceItemListener listener;
|
||||
|
||||
public EditorsChoiceItemAdapter(List<EditorsChoiceItem> items, Context context) {
|
||||
this.context = context;
|
||||
this.items = new ArrayList<>(items);
|
||||
}
|
||||
|
||||
public void addFeaturedItem(EditorsChoiceItem item) {
|
||||
items.add(0, item);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void addItems(List<EditorsChoiceItem> items) {
|
||||
for (EditorsChoiceItem item : items) {
|
||||
if (!this.items.contains(item)) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
protected final ImageView thumbnailView;
|
||||
protected final TextView descriptionView;
|
||||
protected final TextView headerView;
|
||||
protected final TextView titleView;
|
||||
protected final View cardView;
|
||||
|
||||
public ViewHolder(View v) {
|
||||
super(v);
|
||||
|
||||
cardView = v.findViewById(R.id.editors_choice_content_card);
|
||||
descriptionView = v.findViewById(R.id.editors_choice_content_description);
|
||||
titleView = v.findViewById(R.id.editors_choice_content_title);
|
||||
|
||||
thumbnailView = v.findViewById(R.id.editors_choice_content_thumbnail);
|
||||
headerView = v.findViewById(R.id.editors_choice_header_title);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return items != null ? items.size() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return items.get(position).isHeader() ? VIEW_TYPE_HEADER : VIEW_TYPE_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EditorsChoiceItemAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(context).inflate(R.layout.list_item_editors_choice, parent, false);
|
||||
return new EditorsChoiceItemAdapter.ViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(EditorsChoiceItemAdapter.ViewHolder vh, int position) {
|
||||
int type = getItemViewType(position);
|
||||
EditorsChoiceItem item = items.get(position);
|
||||
|
||||
vh.headerView.setVisibility(type == VIEW_TYPE_HEADER ? View.VISIBLE : View.GONE);
|
||||
vh.cardView.setVisibility(type == VIEW_TYPE_CONTENT ? View.VISIBLE : View.GONE);
|
||||
|
||||
vh.headerView.setText(item.getTitle());
|
||||
vh.titleView.setText(item.getTitle());
|
||||
vh.descriptionView.setText(item.getDescription());
|
||||
if (!Helper.isNullOrEmpty(item.getThumbnailUrl())) {
|
||||
Glide.with(context.getApplicationContext()).
|
||||
asBitmap().
|
||||
load(item.getThumbnailUrl()).
|
||||
centerCrop().
|
||||
placeholder(R.drawable.bg_thumbnail_placeholder).
|
||||
into(vh.thumbnailView);
|
||||
}
|
||||
|
||||
vh.cardView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
listener.onEditorsChoiceItemClicked(item);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public interface EditorsChoiceItemListener {
|
||||
void onEditorsChoiceItemClicked(EditorsChoiceItem item);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package io.lbry.browser.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.model.GalleryItem;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import lombok.Setter;
|
||||
|
||||
public class GalleryGridAdapter extends RecyclerView.Adapter<GalleryGridAdapter.ViewHolder> {
|
||||
private final Context context;
|
||||
private final List<GalleryItem> items;
|
||||
@Setter
|
||||
private GalleryItemClickListener listener;
|
||||
|
||||
public GalleryGridAdapter(List<GalleryItem> items, Context context) {
|
||||
this.items = new ArrayList<>(items);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
protected final ImageView thumbnailView;
|
||||
protected final TextView durationView;
|
||||
public ViewHolder(View v) {
|
||||
super(v);
|
||||
thumbnailView = v.findViewById(R.id.gallery_item_thumbnail);
|
||||
durationView = v.findViewById(R.id.gallery_item_duration);
|
||||
}
|
||||
}
|
||||
|
||||
public int getItemCount() {
|
||||
return items != null ? items.size() : 0;
|
||||
}
|
||||
|
||||
public void addItem(GalleryItem item) {
|
||||
if (!items.contains(item)) {
|
||||
items.add(item);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void addItems(List<GalleryItem> items) {
|
||||
for (GalleryItem item : items) {
|
||||
if (!this.items.contains(item)) {
|
||||
this.items.add(item);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clearItems() {
|
||||
items.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GalleryGridAdapter.ViewHolder onCreateViewHolder(ViewGroup root, int viewType) {
|
||||
View v = LayoutInflater.from(context).inflate(R.layout.list_item_gallery, root, false);
|
||||
return new GalleryGridAdapter.ViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(GalleryGridAdapter.ViewHolder vh, int position) {
|
||||
GalleryItem item = items.get(position);
|
||||
String thumbnailUrl = item.getThumbnailPath();
|
||||
Glide.with(context.getApplicationContext()).load(thumbnailUrl).centerCrop().into(vh.thumbnailView);
|
||||
vh.durationView.setVisibility(item.getDuration() > 0 ? View.VISIBLE : View.INVISIBLE);
|
||||
vh.durationView.setText(item.getDuration() > 0 ? Helper.formatDuration(Double.valueOf(item.getDuration() / 1000.0).longValue()) : null);
|
||||
|
||||
vh.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
listener.onGalleryItemClicked(item);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public interface GalleryItemClickListener {
|
||||
void onGalleryItemClicked(GalleryItem item);
|
||||
}
|
||||
|
||||
public static class GalleryGridItemDecoration extends RecyclerView.ItemDecoration {
|
||||
|
||||
private final int spanCount;
|
||||
private final int spacing;
|
||||
|
||||
public GalleryGridItemDecoration(int spanCount, int spacing) {
|
||||
this.spanCount = spanCount;
|
||||
this.spacing = spacing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
|
||||
int position = parent.getChildAdapterPosition(view); // item position
|
||||
int column = position % spanCount; // item column
|
||||
|
||||
outRect.left = column * spacing / spanCount; // column * ((1f / spanCount) * spacing)
|
||||
outRect.right = spacing - (column + 1) * spacing / spanCount; // spacing - (column + 1) * ((1f / spanCount) * spacing)
|
||||
if (position >= spanCount) {
|
||||
outRect.top = spacing; // item top
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package io.lbry.browser.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.model.Claim;
|
||||
|
||||
public class InlineChannelSpinnerAdapter extends ArrayAdapter<Claim> {
|
||||
|
||||
private final List<Claim> channels;
|
||||
private final int layoutResourceId;
|
||||
private final LayoutInflater inflater;
|
||||
|
||||
public InlineChannelSpinnerAdapter(Context context, int resource, List<Claim> channels) {
|
||||
super(context, resource, 0, channels);
|
||||
inflater = LayoutInflater.from(context);
|
||||
layoutResourceId = resource;
|
||||
this.channels = new ArrayList<>(channels);
|
||||
}
|
||||
public void addPlaceholder(boolean includeAnonymous) {
|
||||
Claim placeholder = new Claim();
|
||||
placeholder.setPlaceholder(true);
|
||||
insert(placeholder, 0);
|
||||
channels.add(0, placeholder);
|
||||
|
||||
if (includeAnonymous) {
|
||||
Claim anonymous = new Claim();
|
||||
anonymous.setPlaceholderAnonymous(true);
|
||||
insert(anonymous, 1);
|
||||
channels.add(1, anonymous);
|
||||
}
|
||||
}
|
||||
public void addAnonymousPlaceholder() {
|
||||
Claim anonymous = new Claim();
|
||||
anonymous.setPlaceholderAnonymous(true);
|
||||
insert(anonymous, 0);
|
||||
channels.add(0, anonymous);
|
||||
}
|
||||
|
||||
public void addAll(Collection<? extends Claim> collection) {
|
||||
for (Claim claim : collection) {
|
||||
if (!channels.contains(claim)) {
|
||||
channels.add(claim);
|
||||
}
|
||||
}
|
||||
super.addAll(collection);
|
||||
}
|
||||
public void clear() {
|
||||
channels.clear();
|
||||
super.clear();
|
||||
}
|
||||
|
||||
public int getItemPosition(Claim item) {
|
||||
for (int i = 0; i < channels.size(); i++) {
|
||||
Claim channel = channels.get(i);
|
||||
if (item.getClaimId() != null && item.getClaimId().equalsIgnoreCase(channel.getClaimId())) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View view, ViewGroup parent) {
|
||||
return createView(position, view, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View view, ViewGroup parent) {
|
||||
return createView(position, view, parent);
|
||||
}
|
||||
private View createView(int position, View convertView, ViewGroup parent){
|
||||
View view = inflater.inflate(layoutResourceId, parent, false);
|
||||
|
||||
Context context = getContext();
|
||||
Claim channel = getItem(position);
|
||||
String name = channel.getName();
|
||||
if (channel.isPlaceholder()) {
|
||||
name = context.getString(R.string.create_a_channel);
|
||||
} else if (channel.isPlaceholderAnonymous()) {
|
||||
name = context.getString(R.string.anonymous);
|
||||
}
|
||||
|
||||
TextView label = view.findViewById(R.id.channel_item_name);
|
||||
label.setText(name);
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package io.lbry.browser.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.model.lbryinc.Invitee;
|
||||
|
||||
public class InviteeListAdapter extends RecyclerView.Adapter<InviteeListAdapter.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private final List<Invitee> items;
|
||||
|
||||
public InviteeListAdapter(List<Invitee> invitees, Context context) {
|
||||
this.context = context;
|
||||
this.items = new ArrayList<>(invitees);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
items.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public List<Invitee> getItems() {
|
||||
return new ArrayList<>(items);
|
||||
}
|
||||
|
||||
public void addHeader() {
|
||||
Invitee header = new Invitee();
|
||||
header.setHeader(true);
|
||||
items.add(0, header);
|
||||
}
|
||||
|
||||
public void addInvitees(List<Invitee> Invitees) {
|
||||
for (Invitee tx : Invitees) {
|
||||
if (!items.contains(tx)) {
|
||||
items.add(tx);
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public int getItemCount() {
|
||||
return items != null ? items.size() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InviteeListAdapter.ViewHolder onCreateViewHolder(ViewGroup root, int viewType) {
|
||||
View v = LayoutInflater.from(context).inflate(R.layout.list_item_invitee, root, false);
|
||||
return new InviteeListAdapter.ViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(InviteeListAdapter.ViewHolder vh, int position) {
|
||||
Invitee item = items.get(position);
|
||||
vh.emailView.setText(item.isHeader() ? context.getString(R.string.email) : item.getEmail());
|
||||
vh.emailView.setTypeface(null, item.isHeader() ? Typeface.BOLD : Typeface.NORMAL);
|
||||
|
||||
String rewardText = context.getString(
|
||||
item.isInviteRewardClaimed() ? R.string.claimed :
|
||||
(item.isInviteRewardClaimable() ? R.string.claimable : R.string.unclaimable));
|
||||
vh.rewardView.setText(item.isHeader() ? context.getString(R.string.reward) : rewardText);
|
||||
vh.rewardView.setTypeface(null, item.isHeader() ? Typeface.BOLD : Typeface.NORMAL);
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
protected final TextView emailView;
|
||||
protected final TextView rewardView;
|
||||
|
||||
public ViewHolder(View v) {
|
||||
super(v);
|
||||
emailView = v.findViewById(R.id.invitee_email);
|
||||
rewardView = v.findViewById(R.id.invitee_reward);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package io.lbry.browser.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.model.Language;
|
||||
import io.lbry.browser.utils.Predefined;
|
||||
|
||||
public class LanguageSpinnerAdapter extends ArrayAdapter<Language> {
|
||||
private final int layoutResourceId;
|
||||
private final LayoutInflater inflater;
|
||||
|
||||
public LanguageSpinnerAdapter(Context context, int resource) {
|
||||
super(context, resource, 0, Predefined.PUBLISH_LANGUAGES);
|
||||
inflater = LayoutInflater.from(context);
|
||||
layoutResourceId = resource;
|
||||
}
|
||||
|
||||
public int getItemPosition(String languageCode) {
|
||||
for (int i = 0; i < Predefined.PUBLISH_LANGUAGES.size(); i++) {
|
||||
Language lang = Predefined.PUBLISH_LANGUAGES.get(i);
|
||||
if (lang.getCode().equalsIgnoreCase(languageCode)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View view, @NonNull ViewGroup parent) {
|
||||
return createView(position, view, parent);
|
||||
}
|
||||
@Override
|
||||
public View getView(int position, View view, @NonNull ViewGroup parent) {
|
||||
return createView(position, view, parent);
|
||||
}
|
||||
private View createView(int position, View convertView, ViewGroup parent) {
|
||||
Language item = getItem(position);
|
||||
View view = inflater.inflate(layoutResourceId, parent, false);
|
||||
TextView label = view.findViewById(R.id.item_display_name);
|
||||
label.setText(item != null ? item.getStringResourceId() : 0);
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package io.lbry.browser.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.model.License;
|
||||
import io.lbry.browser.utils.Predefined;
|
||||
|
||||
public class LicenseSpinnerAdapter extends ArrayAdapter<License> {
|
||||
private final int layoutResourceId;
|
||||
private final LayoutInflater inflater;
|
||||
|
||||
public LicenseSpinnerAdapter(Context context, int resource) {
|
||||
super(context, resource, 0, Predefined.LICENSES);
|
||||
inflater = LayoutInflater.from(context);
|
||||
layoutResourceId = resource;
|
||||
}
|
||||
public int getItemPosition(String name) {
|
||||
for (int i = 0; i < Predefined.LICENSES.size(); i++) {
|
||||
License lic = Predefined.LICENSES.get(i);
|
||||
if (lic.getName().equalsIgnoreCase(name)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View view, @NonNull ViewGroup parent) {
|
||||
return createView(position, view, parent);
|
||||
}
|
||||
@Override
|
||||
public View getView(int position, View view, @NonNull ViewGroup parent) {
|
||||
return createView(position, view, parent);
|
||||
}
|
||||
private View createView(int position, View convertView, ViewGroup parent) {
|
||||
License item = getItem(position);
|
||||
View view = inflater.inflate(layoutResourceId, parent, false);
|
||||
TextView label = view.findViewById(R.id.item_display_name);
|
||||
label.setText(item != null ? item.getStringResourceId() : 0);
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package io.lbry.browser.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.model.NavMenuItem;
|
||||
import io.lbry.browser.ui.controls.SolidIconView;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import lombok.Setter;
|
||||
|
||||
public class NavigationMenuAdapter extends RecyclerView.Adapter<NavigationMenuAdapter.ViewHolder> {
|
||||
private static final int TYPE_GROUP = 1;
|
||||
private static final int TYPE_ITEM = 2;
|
||||
|
||||
private final Context context;
|
||||
private final List<NavMenuItem> menuItems;
|
||||
private NavMenuItem currentItem;
|
||||
@Setter
|
||||
private NavigationMenuItemClickListener listener;
|
||||
|
||||
public NavigationMenuAdapter(List<NavMenuItem> menuItems, Context context) {
|
||||
this.menuItems = new ArrayList<>(menuItems);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public void setCurrentItem(int id) {
|
||||
for (NavMenuItem item : menuItems) {
|
||||
if (item.getId() == id) {
|
||||
this.currentItem = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setExtraLabelForItem(int id, String extraLabel) {
|
||||
for (NavMenuItem item : menuItems) {
|
||||
if (item.getId() == id) {
|
||||
item.setExtraLabel(extraLabel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setCurrentItem(NavMenuItem currentItem) {
|
||||
this.currentItem = currentItem;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public int getCurrentItemId() {
|
||||
return currentItem != null ? currentItem.getId() : -1;
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
protected final SolidIconView iconView;
|
||||
protected final TextView titleView;
|
||||
public ViewHolder(View v) {
|
||||
super(v);
|
||||
titleView = v.findViewById(R.id.nav_menu_title);
|
||||
iconView = v.findViewById(R.id.nav_menu_item_icon);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return menuItems != null ? menuItems.size() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return menuItems.get(position).isGroup() ? TYPE_GROUP : TYPE_ITEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NavigationMenuAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(context).inflate(viewType == TYPE_GROUP ?
|
||||
R.layout.list_item_nav_menu_group : R.layout.list_item_nav_menu_item, parent, false);
|
||||
return new NavigationMenuAdapter.ViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder vh, int position) {
|
||||
int type = getItemViewType(position);
|
||||
NavMenuItem item = menuItems.get(position);
|
||||
String displayTitle = !Helper.isNullOrEmpty(item.getExtraLabel()) ? String.format("%s (%s)", item.getTitle(), item.getExtraLabel()) : item.getTitle();
|
||||
vh.titleView.setText(displayTitle);
|
||||
if (type == TYPE_ITEM && vh.iconView != null) {
|
||||
vh.iconView.setText(item.getIcon());
|
||||
}
|
||||
vh.itemView.setSelected(item.equals(currentItem));
|
||||
vh.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
listener.onNavigationMenuItemClicked(item);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public interface NavigationMenuItemClickListener {
|
||||
void onNavigationMenuItemClicked(NavMenuItem menuItem);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
package io.lbry.browser.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.listener.SelectionModeListener;
|
||||
import io.lbry.browser.model.Claim;
|
||||
import io.lbry.browser.model.lbryinc.LbryNotification;
|
||||
import io.lbry.browser.ui.controls.SolidIconView;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class NotificationListAdapter extends RecyclerView.Adapter<NotificationListAdapter.ViewHolder> {
|
||||
|
||||
private static final String RULE_CREATOR_SUBSCRIBER = "creator_subscriber";
|
||||
private static final String RULE_COMMENT = "comment";
|
||||
|
||||
private final Context context;
|
||||
private final List<LbryNotification> items;
|
||||
private final List<LbryNotification> selectedItems;
|
||||
@Setter
|
||||
private NotificationClickListener clickListener;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean inSelectionMode;
|
||||
@Setter
|
||||
private SelectionModeListener selectionModeListener;
|
||||
|
||||
public NotificationListAdapter(List<LbryNotification> notifications, Context context) {
|
||||
this.context = context;
|
||||
this.items = new ArrayList<>(notifications);
|
||||
this.selectedItems = new ArrayList<>();
|
||||
Collections.sort(items, Collections.reverseOrder(new LbryNotification()));
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
protected final View layoutView;
|
||||
protected final TextView titleView;
|
||||
protected final TextView bodyView;
|
||||
protected final TextView timeView;
|
||||
protected final SolidIconView iconView;
|
||||
protected final ImageView thumbnailView;
|
||||
protected final View selectedOverlayView;
|
||||
public ViewHolder(View v) {
|
||||
super(v);
|
||||
layoutView = v.findViewById(R.id.notification_layout);
|
||||
titleView = v.findViewById(R.id.notification_title);
|
||||
bodyView = v.findViewById(R.id.notification_body);
|
||||
timeView = v.findViewById(R.id.notification_time);
|
||||
iconView = v.findViewById(R.id.notification_icon);
|
||||
thumbnailView = v.findViewById(R.id.notification_author_thumbnail);
|
||||
selectedOverlayView = v.findViewById(R.id.notification_selected_overlay);
|
||||
}
|
||||
}
|
||||
|
||||
public int getItemCount() {
|
||||
return items != null ? items.size() : 0;
|
||||
}
|
||||
public List<LbryNotification> getSelectedItems() {
|
||||
return this.selectedItems;
|
||||
}
|
||||
public int getSelectedCount() {
|
||||
return selectedItems != null ? selectedItems.size() : 0;
|
||||
}
|
||||
public void clearSelectedItems() {
|
||||
this.selectedItems.clear();
|
||||
}
|
||||
public boolean isNotificationSelected(LbryNotification notification) {
|
||||
return selectedItems.contains(notification);
|
||||
}
|
||||
|
||||
public void insertNotification(LbryNotification notification, int index) {
|
||||
if (!items.contains(notification)) {
|
||||
items.add(index, notification);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void addNotification(LbryNotification notification) {
|
||||
if (!items.contains(notification)) {
|
||||
items.add(notification);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
public void removeNotifications(List<LbryNotification> notifications) {
|
||||
for (LbryNotification notification : notifications) {
|
||||
items.remove(notification);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public List<String> getAuthorUrls() {
|
||||
List<String> urls = new ArrayList<>();
|
||||
for (LbryNotification item : items) {
|
||||
if (!Helper.isNullOrEmpty(item.getAuthorUrl())) {
|
||||
urls.add(item.getAuthorUrl());
|
||||
}
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
public void updateAuthorClaims(List<Claim> claims) {
|
||||
for (Claim claim : claims) {
|
||||
if (claim != null && claim.getThumbnailUrl() != null) {
|
||||
updateClaimForAuthorUrl(claim);
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void updateClaimForAuthorUrl(Claim claim) {
|
||||
for (LbryNotification item : items) {
|
||||
if (claim.getPermanentUrl().equalsIgnoreCase(item.getAuthorUrl())) {
|
||||
item.setCommentAuthor(claim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addNotifications(List<LbryNotification> notifications) {
|
||||
for (LbryNotification notification : notifications) {
|
||||
if (!items.contains(notification)) {
|
||||
items.add(notification);
|
||||
}
|
||||
}
|
||||
Collections.sort(items, Collections.reverseOrder(new LbryNotification()));
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NotificationListAdapter.ViewHolder onCreateViewHolder(ViewGroup root, int viewType) {
|
||||
View v = LayoutInflater.from(context).inflate(R.layout.list_item_notification, root, false);
|
||||
return new NotificationListAdapter.ViewHolder(v);
|
||||
}
|
||||
|
||||
private int getStringIdForRule(String rule) {
|
||||
if (RULE_CREATOR_SUBSCRIBER.equalsIgnoreCase(rule)) {
|
||||
return R.string.fa_heart;
|
||||
}
|
||||
if (RULE_COMMENT.equalsIgnoreCase(rule)) {
|
||||
return R.string.fa_comment_alt;
|
||||
}
|
||||
return R.string.fa_asterisk;
|
||||
}
|
||||
|
||||
private int getColorForRule(String rule) {
|
||||
if (RULE_CREATOR_SUBSCRIBER.equalsIgnoreCase(rule)) {
|
||||
return Color.RED;
|
||||
}
|
||||
if (RULE_COMMENT.equalsIgnoreCase(rule)) {
|
||||
return ContextCompat.getColor(context, R.color.nextLbryGreen);
|
||||
}
|
||||
|
||||
return ContextCompat.getColor(context, R.color.lbryGreen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(NotificationListAdapter.ViewHolder vh, int position) {
|
||||
LbryNotification notification = items.get(position);
|
||||
vh.layoutView.setBackgroundColor(ContextCompat.getColor(context, notification.isSeen() ? android.R.color.transparent : R.color.nextLbryGreenSemiTransparent));
|
||||
vh.selectedOverlayView.setVisibility(isNotificationSelected(notification) ? View.VISIBLE : View.GONE);
|
||||
|
||||
vh.titleView.setVisibility(!Helper.isNullOrEmpty(notification.getTitle()) ? View.VISIBLE : View.GONE);
|
||||
vh.titleView.setText(notification.getTitle());
|
||||
vh.bodyView.setText(notification.getDescription());
|
||||
vh.timeView.setText(DateUtils.getRelativeTimeSpanString(
|
||||
getLocalNotificationTime(notification), System.currentTimeMillis(), 0, DateUtils.FORMAT_ABBREV_RELATIVE));
|
||||
|
||||
vh.thumbnailView.setVisibility(notification.getCommentAuthor() == null ? View.INVISIBLE : View.VISIBLE);
|
||||
if (notification.getCommentAuthor() != null) {
|
||||
Glide.with(context.getApplicationContext()).load(
|
||||
notification.getCommentAuthor().getThumbnailUrl()).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView);
|
||||
}
|
||||
|
||||
vh.iconView.setVisibility(notification.getCommentAuthor() != null ? View.INVISIBLE : View.VISIBLE);
|
||||
vh.iconView.setText(getStringIdForRule(notification.getRule()));
|
||||
vh.iconView.setTextColor(getColorForRule(notification.getRule()));
|
||||
|
||||
vh.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (inSelectionMode) {
|
||||
toggleSelectedNotification(notification);
|
||||
} else {
|
||||
if (clickListener != null) {
|
||||
clickListener.onNotificationClicked(notification);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
vh.itemView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
if (!inSelectionMode) {
|
||||
inSelectionMode = true;
|
||||
if (selectionModeListener != null) {
|
||||
selectionModeListener.onEnterSelectionMode();
|
||||
}
|
||||
}
|
||||
toggleSelectedNotification(notification);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void toggleSelectedNotification(LbryNotification notification) {
|
||||
if (selectedItems.contains(notification)) {
|
||||
selectedItems.remove(notification);
|
||||
} else {
|
||||
selectedItems.add(notification);
|
||||
}
|
||||
|
||||
if (selectionModeListener != null) {
|
||||
selectionModeListener.onItemSelectionToggled();
|
||||
}
|
||||
|
||||
if (selectedItems.size() == 0) {
|
||||
inSelectionMode = false;
|
||||
if (selectionModeListener != null) {
|
||||
selectionModeListener.onExitSelectionMode();
|
||||
}
|
||||
}
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private long getLocalNotificationTime(LbryNotification notification) {
|
||||
TimeZone utcTZ = TimeZone.getTimeZone("UTC");
|
||||
TimeZone targetTZ = TimeZone.getDefault();
|
||||
Calendar cal = new GregorianCalendar(utcTZ);
|
||||
cal.setTimeInMillis(notification.getTimestamp().getTime());
|
||||
|
||||
cal.add(Calendar.MILLISECOND, utcTZ.getRawOffset() * -1);
|
||||
cal.add(Calendar.MILLISECOND, targetTZ.getRawOffset());
|
||||
return cal.getTimeInMillis();
|
||||
}
|
||||
|
||||
public interface NotificationClickListener {
|
||||
void onNotificationClicked(LbryNotification notification);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
package io.lbry.browser.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.model.lbryinc.Reward;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import io.lbry.browser.utils.Lbryio;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class RewardListAdapter extends RecyclerView.Adapter<RewardListAdapter.ViewHolder> {
|
||||
|
||||
public static final int DISPLAY_MODE_ALL = 1;
|
||||
public static final int DISPLAY_MODE_UNCLAIMED = 2;
|
||||
|
||||
private final Context context;
|
||||
@Setter
|
||||
private List<Reward> all;
|
||||
private List<Reward> items;
|
||||
@Setter
|
||||
private RewardClickListener clickListener;
|
||||
@Getter
|
||||
private int displayMode;
|
||||
|
||||
public RewardListAdapter(List<Reward> all, Context context) {
|
||||
this.all = new ArrayList<>(all);
|
||||
this.items = new ArrayList<>(all);
|
||||
this.context = context;
|
||||
this.displayMode = DISPLAY_MODE_ALL;
|
||||
|
||||
addCustomReward();
|
||||
}
|
||||
|
||||
public void setRewards(List<Reward> rewards) {
|
||||
this.all = new ArrayList<>(rewards);
|
||||
updateItemsForDisplayMode();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setDisplayMode(int displayMode) {
|
||||
this.displayMode = displayMode;
|
||||
updateItemsForDisplayMode();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void updateItemsForDisplayMode() {
|
||||
if (displayMode == DISPLAY_MODE_ALL) {
|
||||
items = new ArrayList<>(all);
|
||||
} else if (displayMode == DISPLAY_MODE_UNCLAIMED) {
|
||||
items = new ArrayList<>();
|
||||
for (Reward reward : all) {
|
||||
if (!reward.isClaimed()) {
|
||||
items.add(reward);
|
||||
}
|
||||
}
|
||||
}
|
||||
addCustomReward();
|
||||
}
|
||||
|
||||
private void addCustomReward() {
|
||||
Reward custom = new Reward();
|
||||
custom.setCustom(true);
|
||||
custom.setRewardTitle(context.getString(R.string.custom_reward_title));
|
||||
custom.setRewardDescription(context.getString(R.string.custom_reward_description));
|
||||
items.add(custom);
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
protected final View iconClaimed;
|
||||
protected final View loading;
|
||||
protected final View upTo;
|
||||
protected final TextView textTitle;
|
||||
protected final TextView textDescription;
|
||||
protected final TextView textLbcValue;
|
||||
protected final TextView textUsdValue;
|
||||
protected final TextView textLinkTransaction;
|
||||
protected final EditText inputCustomCode;
|
||||
protected final MaterialButton buttonClaimCustom;
|
||||
public ViewHolder(View v) {
|
||||
super(v);
|
||||
iconClaimed = v.findViewById(R.id.reward_item_claimed_icon);
|
||||
upTo = v.findViewById(R.id.reward_item_up_to);
|
||||
loading = v.findViewById(R.id.reward_item_loading);
|
||||
textTitle = v.findViewById(R.id.reward_item_title);
|
||||
textDescription = v.findViewById(R.id.reward_item_description);
|
||||
textLbcValue = v.findViewById(R.id.reward_item_lbc_value);
|
||||
textLinkTransaction = v.findViewById(R.id.reward_item_tx_link);
|
||||
textUsdValue = v.findViewById(R.id.reward_item_usd_value);
|
||||
inputCustomCode = v.findViewById(R.id.reward_item_custom_code_input);
|
||||
buttonClaimCustom = v.findViewById(R.id.reward_item_custom_claim_button);
|
||||
}
|
||||
}
|
||||
|
||||
public int getItemCount() {
|
||||
return items != null ? items.size() : 0;
|
||||
}
|
||||
|
||||
public void addReward(Reward reward) {
|
||||
if (!items.contains(reward)) {
|
||||
items.add(reward);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
public List<Reward> getRewards() {
|
||||
return new ArrayList<>(items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RewardListAdapter.ViewHolder onCreateViewHolder(ViewGroup root, int viewType) {
|
||||
View v = LayoutInflater.from(context).inflate(R.layout.list_item_reward, root, false);
|
||||
return new RewardListAdapter.ViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RewardListAdapter.ViewHolder vh, int position) {
|
||||
Reward reward = items.get(position);
|
||||
String displayAmount = reward.getDisplayAmount();
|
||||
double rewardAmount = 0;
|
||||
if (!"?".equals(displayAmount)) {
|
||||
rewardAmount = Double.valueOf(displayAmount);
|
||||
}
|
||||
boolean hasTransaction = !Helper.isNullOrEmpty(reward.getTransactionId()) && reward.getTransactionId().length() > 7;
|
||||
vh.iconClaimed.setVisibility(reward.isClaimed() ? View.VISIBLE : View.INVISIBLE);
|
||||
vh.inputCustomCode.setVisibility(reward.isCustom() ? View.VISIBLE : View.GONE);
|
||||
vh.buttonClaimCustom.setVisibility(reward.isCustom() ? View.VISIBLE : View.GONE);
|
||||
vh.textTitle.setText(reward.getRewardTitle());
|
||||
vh.textDescription.setText(reward.getRewardDescription());
|
||||
vh.upTo.setVisibility(reward.shouldDisplayRange() ? View.VISIBLE : View.GONE);
|
||||
vh.textLbcValue.setText(reward.isCustom() ? "?" : Helper.LBC_CURRENCY_FORMAT.format(Helper.parseDouble(reward.getDisplayAmount(), 0)));
|
||||
vh.textLinkTransaction.setVisibility(hasTransaction ? View.VISIBLE : View.GONE);
|
||||
vh.textLinkTransaction.setText(hasTransaction ? reward.getTransactionId().substring(0, 7) : null);
|
||||
vh.textLinkTransaction.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (context != null) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("%s/%s", Helper.EXPLORER_TX_PREFIX, reward.getTransactionId())));
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
vh.textUsdValue.setText(reward.isCustom() || Lbryio.LBCUSDRate == 0 ? null :
|
||||
String.format("≈$%s", Helper.SIMPLE_CURRENCY_FORMAT.format(rewardAmount * Lbryio.LBCUSDRate)));
|
||||
|
||||
vh.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (reward.isClaimed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (vh.inputCustomCode != null && !vh.inputCustomCode.hasFocus()) {
|
||||
vh.inputCustomCode.requestFocus();
|
||||
}
|
||||
|
||||
if (clickListener != null) {
|
||||
clickListener.onRewardClicked(reward, vh.loading);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
vh.inputCustomCode.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
String value = charSequence.toString().trim();
|
||||
vh.buttonClaimCustom.setEnabled(value.length() > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
vh.buttonClaimCustom.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String claimCode = Helper.getValue(vh.inputCustomCode.getText());
|
||||
if (Helper.isNullOrEmpty(claimCode)) {
|
||||
Snackbar.make(view, R.string.please_enter_claim_code, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (clickListener != null) {
|
||||
clickListener.onCustomClaimButtonClicked(claimCode, vh.inputCustomCode, vh.buttonClaimCustom, vh.loading);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public interface RewardClickListener {
|
||||
void onRewardClicked(Reward reward, View loadingView);
|
||||
void onCustomClaimButtonClicked(String code, EditText inputCustomCode, MaterialButton buttonClaim, View loadingView);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package io.lbry.browser.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.model.StartupStage;
|
||||
|
||||
public class StartupStageAdapter extends BaseAdapter {
|
||||
private final List<StartupStage> list;
|
||||
private final LayoutInflater inflater;
|
||||
private final String[] stagesString;
|
||||
|
||||
public StartupStageAdapter(Context ctx, List<StartupStage> rows) {
|
||||
this.list = rows;
|
||||
this.inflater = LayoutInflater.from(ctx);
|
||||
|
||||
stagesString = new String[9];
|
||||
|
||||
stagesString[0] = ctx.getResources().getString(R.string.installation_id_loaded);
|
||||
stagesString[1] = ctx.getResources().getString(R.string.known_tags_loaded);
|
||||
stagesString[2] = ctx.getResources().getString(R.string.exchange_rate_loaded);
|
||||
stagesString[3] = ctx.getResources().getString(R.string.user_authenticated);
|
||||
stagesString[4] = ctx.getResources().getString(R.string.installation_registered);
|
||||
stagesString[5] = ctx.getResources().getString(R.string.subscriptions_loaded);
|
||||
stagesString[6] = ctx.getResources().getString(R.string.subscriptions_resolved);
|
||||
stagesString[7] = ctx.getResources().getString(R.string.block_list_loaded);
|
||||
stagesString[8] = ctx.getResources().getString(R.string.filter_list_loaded);
|
||||
}
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int i) {
|
||||
return list.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
if (view == null) {
|
||||
view = inflater.inflate(R.layout.list_item_startupstage, viewGroup, false);
|
||||
|
||||
ImageView iconView = view.findViewById(R.id.startup_stage_icon);
|
||||
TextView textView = view.findViewById(R.id.startup_stage_text);
|
||||
|
||||
StartupStage item = (StartupStage) getItem(i);
|
||||
|
||||
iconView.setImageResource(item.stageDone ? R.drawable.ic_check : R.drawable.ic_close);
|
||||
iconView.setColorFilter(item.stageDone ? Color.WHITE : Color.RED);
|
||||
|
||||
textView.setText(stagesString[item.stage - 1]);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package io.lbry.browser.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.model.Claim;
|
||||
import io.lbry.browser.listener.ChannelItemSelectionListener;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import lombok.Setter;
|
||||
|
||||
public class SuggestedChannelGridAdapter extends RecyclerView.Adapter<SuggestedChannelGridAdapter.ViewHolder> {
|
||||
private final Context context;
|
||||
private final List<Claim> items;
|
||||
private final List<Claim> selectedItems;
|
||||
@Setter
|
||||
private ChannelItemSelectionListener listener;
|
||||
|
||||
public SuggestedChannelGridAdapter(List<Claim> items, Context context) {
|
||||
this.items = new ArrayList<>(items);
|
||||
this.selectedItems = new ArrayList<>();
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
protected final View noThumbnailView;
|
||||
protected final ImageView thumbnailView;
|
||||
protected final TextView alphaView;
|
||||
protected final TextView titleView;
|
||||
protected final TextView tagView;
|
||||
public ViewHolder(View v) {
|
||||
super(v);
|
||||
noThumbnailView = v.findViewById(R.id.suggested_channel_no_thumbnail);
|
||||
alphaView = v.findViewById(R.id.suggested_channel_alpha_view);
|
||||
thumbnailView = v.findViewById(R.id.suggested_channel_thumbnail);
|
||||
titleView = v.findViewById(R.id.suggested_channel_title);
|
||||
tagView = v.findViewById(R.id.suggested_channel_tag);
|
||||
}
|
||||
}
|
||||
|
||||
public int getItemCount() {
|
||||
return items != null ? items.size() : 0;
|
||||
}
|
||||
|
||||
public int getSelectedCount() { return selectedItems.size(); }
|
||||
|
||||
public void clearItems() {
|
||||
items.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public List<Claim> getSelectedItems() {
|
||||
return this.selectedItems;
|
||||
}
|
||||
public void clearSelectedItems() {
|
||||
this.selectedItems.clear();
|
||||
}
|
||||
public boolean isClaimSelected(Claim claim) {
|
||||
return selectedItems.contains(claim);
|
||||
}
|
||||
|
||||
public void addClaims(List<Claim> claims) {
|
||||
for (Claim claim : claims) {
|
||||
if (!items.contains(claim)) {
|
||||
items.add(claim);
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuggestedChannelGridAdapter.ViewHolder onCreateViewHolder(ViewGroup root, int viewType) {
|
||||
View v = LayoutInflater.from(context).inflate(R.layout.list_item_suggested_channel, root, false);
|
||||
return new SuggestedChannelGridAdapter.ViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(SuggestedChannelGridAdapter.ViewHolder vh, int position) {
|
||||
Claim claim = items.get(position);
|
||||
String thumbnailUrl = claim.getThumbnailUrl();
|
||||
|
||||
int bgColor = Helper.generateRandomColorForValue(claim.getClaimId());
|
||||
Helper.setIconViewBackgroundColor(vh.noThumbnailView, bgColor, false, context);
|
||||
vh.noThumbnailView.setVisibility(Helper.isNullOrEmpty(thumbnailUrl) ? View.INVISIBLE : View.VISIBLE);
|
||||
vh.alphaView.setText(claim.getName().substring(1, 2));
|
||||
if (!Helper.isNullOrEmpty(thumbnailUrl)) {
|
||||
vh.thumbnailView.setVisibility(View.VISIBLE);
|
||||
Glide.with(context.getApplicationContext()).load(thumbnailUrl).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView);
|
||||
} else {
|
||||
vh.thumbnailView.setVisibility(View.GONE);
|
||||
}
|
||||
vh.titleView.setText(Helper.isNullOrEmpty(claim.getTitle()) ? claim.getName() : claim.getTitle());
|
||||
|
||||
String firstTag = claim.getFirstTag();
|
||||
vh.tagView.setVisibility(Helper.isNullOrEmpty(firstTag) ? View.INVISIBLE : View.VISIBLE);
|
||||
vh.tagView.setBackgroundResource(R.drawable.bg_tag);
|
||||
vh.tagView.setText(firstTag);
|
||||
vh.itemView.setSelected(isClaimSelected(claim));
|
||||
|
||||
vh.itemView.setOnClickListener(view -> {
|
||||
if (selectedItems.contains(claim)) {
|
||||
selectedItems.remove(claim);
|
||||
if (listener != null) {
|
||||
listener.onChannelItemDeselected(claim);
|
||||
}
|
||||
} else {
|
||||
selectedItems.add(claim);
|
||||
if (listener != null) {
|
||||
listener.onChannelItemSelected(claim);
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package io.lbry.browser.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.model.Tag;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class TagListAdapter extends RecyclerView.Adapter<TagListAdapter.ViewHolder> {
|
||||
|
||||
public static final int CUSTOMIZE_MODE_NONE = 0;
|
||||
public static final int CUSTOMIZE_MODE_ADD = 1;
|
||||
public static final int CUSTOMIZE_MODE_REMOVE = 2;
|
||||
|
||||
private final Context context;
|
||||
private List<Tag> items;
|
||||
@Setter
|
||||
private TagClickListener clickListener;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private int customizeMode;
|
||||
|
||||
public TagListAdapter(List<Tag> tags, Context context) {
|
||||
this.context = context;
|
||||
this.items = new ArrayList<>(tags);
|
||||
this.customizeMode = CUSTOMIZE_MODE_NONE;
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
protected final ImageView iconView;
|
||||
protected final TextView nameView;
|
||||
public ViewHolder(View v) {
|
||||
super(v);
|
||||
iconView = v.findViewById(R.id.tag_action);
|
||||
nameView = v.findViewById(R.id.tag_name);
|
||||
}
|
||||
}
|
||||
|
||||
public int getItemCount() {
|
||||
return items != null ? items.size() : 0;
|
||||
}
|
||||
|
||||
public void addTag(Tag tag) {
|
||||
if (!items.contains(tag)) {
|
||||
items.add(tag);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
public List<Tag> getTags() {
|
||||
return new ArrayList<>(items);
|
||||
}
|
||||
|
||||
public void setTags(List<Tag> tags) {
|
||||
items = new ArrayList<>(tags);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void addTags(List<Tag> tags) {
|
||||
for (Tag tag : tags) {
|
||||
if (!items.contains(tag)) {
|
||||
items.add(tag);
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
public void removeTag(Tag tag) {
|
||||
items.remove(tag);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagListAdapter.ViewHolder onCreateViewHolder(ViewGroup root, int viewType) {
|
||||
View v = LayoutInflater.from(context).inflate(R.layout.list_item_tag, root, false);
|
||||
return new TagListAdapter.ViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(TagListAdapter.ViewHolder vh, int position) {
|
||||
Tag tag = items.get(position);
|
||||
vh.nameView.setText(tag.getName().toLowerCase());
|
||||
vh.iconView.setVisibility(customizeMode == CUSTOMIZE_MODE_NONE ? View.GONE : View.VISIBLE);
|
||||
vh.iconView.setImageResource(customizeMode == CUSTOMIZE_MODE_REMOVE ? R.drawable.ic_close : R.drawable.ic_add);
|
||||
vh.itemView.setBackgroundResource(tag.isMature() ? R.drawable.bg_tag_mature : R.drawable.bg_tag);
|
||||
vh.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (clickListener != null) {
|
||||
clickListener.onTagClicked(tag, customizeMode);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public interface TagClickListener {
|
||||
void onTagClicked(Tag tag, int customizeMode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package io.lbry.browser.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.model.Transaction;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import io.lbry.browser.utils.LbryUri;
|
||||
import lombok.Setter;
|
||||
|
||||
public class TransactionListAdapter extends RecyclerView.Adapter<TransactionListAdapter.ViewHolder> {
|
||||
|
||||
private static final DecimalFormat TX_LIST_AMOUNT_FORMAT = new DecimalFormat("#,##0.0000");
|
||||
private static final SimpleDateFormat TX_LIST_DATE_FORMAT = new SimpleDateFormat("MMM d");
|
||||
|
||||
private final Context context;
|
||||
private final List<Transaction> items;
|
||||
@Setter
|
||||
private TransactionClickListener listener;
|
||||
|
||||
public TransactionListAdapter(List<Transaction> transactions, Context context) {
|
||||
this.context = context;
|
||||
this.items = new ArrayList<>(transactions);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
items.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public List<Transaction> getItems() {
|
||||
return new ArrayList<>(items);
|
||||
}
|
||||
|
||||
public void addTransactions(List<Transaction> transactions) {
|
||||
for (Transaction tx : transactions) {
|
||||
if (!items.contains(tx)) {
|
||||
items.add(tx);
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public int getItemCount() {
|
||||
return items != null ? items.size() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransactionListAdapter.ViewHolder onCreateViewHolder(ViewGroup root, int viewType) {
|
||||
View v = LayoutInflater.from(context).inflate(R.layout.list_item_transaction, root, false);
|
||||
return new TransactionListAdapter.ViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(TransactionListAdapter.ViewHolder vh, int position) {
|
||||
Transaction item = items.get(position);
|
||||
vh.descView.setText(item.getDescriptionStringId());
|
||||
vh.amountView.setText(TX_LIST_AMOUNT_FORMAT.format(item.getValue().doubleValue()));
|
||||
vh.claimView.setText(item.getClaim());
|
||||
vh.feeView.setText(context.getString(R.string.tx_list_fee, TX_LIST_AMOUNT_FORMAT.format(item.getFee().doubleValue())));
|
||||
vh.txidLinkView.setText(item.getTxid().substring(0, 7));
|
||||
vh.dateView.setVisibility(item.getConfirmations() > 0 ? View.VISIBLE : View.GONE);
|
||||
vh.dateView.setText(item.getConfirmations() > 0 ? TX_LIST_DATE_FORMAT.format(item.getTxDate()) : null);
|
||||
vh.pendingView.setVisibility(item.getConfirmations() == 0 ? View.VISIBLE : View.GONE);
|
||||
|
||||
vh.infoFeeContainer.setVisibility(!Helper.isNullOrEmpty(item.getClaim()) || Math.abs(item.getFee().doubleValue()) > 0 ?
|
||||
View.VISIBLE : View.GONE);
|
||||
|
||||
vh.claimView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
LbryUri claimUrl = item.getClaimUrl();
|
||||
if (claimUrl != null && listener != null) {
|
||||
listener.onClaimUrlClicked(claimUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
vh.txidLinkView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (context != null) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("%s/%s", Helper.EXPLORER_TX_PREFIX, item.getTxid())));
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
vh.itemView.setOnClickListener(view -> {
|
||||
if (listener != null) {
|
||||
listener.onTransactionClicked(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
protected final TextView descView;
|
||||
protected final TextView amountView;
|
||||
protected final TextView claimView;
|
||||
protected final TextView feeView;
|
||||
protected final TextView txidLinkView;
|
||||
protected final TextView dateView;
|
||||
protected final TextView pendingView;
|
||||
protected final View infoFeeContainer;
|
||||
|
||||
public ViewHolder(View v) {
|
||||
super(v);
|
||||
descView = v.findViewById(R.id.transaction_desc);
|
||||
amountView = v.findViewById(R.id.transaction_amount);
|
||||
claimView = v.findViewById(R.id.transaction_claim);
|
||||
feeView = v.findViewById(R.id.transaction_fee);
|
||||
txidLinkView = v.findViewById(R.id.transaction_id_link);
|
||||
dateView = v.findViewById(R.id.transaction_date);
|
||||
pendingView = v.findViewById(R.id.transaction_pending_text);
|
||||
infoFeeContainer = v.findViewById(R.id.transaction_info_fee_container);
|
||||
}
|
||||
}
|
||||
|
||||
public interface TransactionClickListener {
|
||||
void onTransactionClicked(Transaction transaction);
|
||||
void onClaimUrlClicked(LbryUri uri);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package io.lbry.browser.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.exceptions.LbryUriException;
|
||||
import io.lbry.browser.model.Claim;
|
||||
import io.lbry.browser.model.UrlSuggestion;
|
||||
import io.lbry.browser.ui.controls.SolidIconView;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import io.lbry.browser.utils.LbryUri;
|
||||
import lombok.Setter;
|
||||
|
||||
public class UrlSuggestionListAdapter extends RecyclerView.Adapter<UrlSuggestionListAdapter.ViewHolder> {
|
||||
private final Context context;
|
||||
private final List<UrlSuggestion> items;
|
||||
@Setter
|
||||
private UrlSuggestionClickListener listener;
|
||||
|
||||
public UrlSuggestionListAdapter(Context context) {
|
||||
this.context = context;
|
||||
this.items = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
items.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public List<UrlSuggestion> getItems() {
|
||||
return new ArrayList<>(items);
|
||||
}
|
||||
|
||||
public List<String> getItemUrls() {
|
||||
List<String> uris = new ArrayList<>();
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
LbryUri uri = items.get(i).getUri();
|
||||
if (uri != null) {
|
||||
uris.add(uri.toString());
|
||||
}
|
||||
}
|
||||
return uris;
|
||||
}
|
||||
|
||||
public void setClaimForUrl(LbryUri url, Claim claim) {
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
LbryUri thisUrl = items.get(i).getUri();
|
||||
try {
|
||||
if (thisUrl != null) {
|
||||
LbryUri vanity = LbryUri.parse(thisUrl.toVanityString());
|
||||
if (thisUrl.equals(url) || vanity.equals(url)) {
|
||||
items.get(i).setClaim(claim);
|
||||
}
|
||||
}
|
||||
} catch (LbryUriException ex) {
|
||||
// pass
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addUrlSuggestions(List<UrlSuggestion> urlSuggestions) {
|
||||
for (UrlSuggestion urlSuggestion : urlSuggestions) {
|
||||
if (!items.contains(urlSuggestion)) {
|
||||
items.add(urlSuggestion);
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public int getItemCount() {
|
||||
return items != null ? items.size() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UrlSuggestionListAdapter.ViewHolder onCreateViewHolder(ViewGroup root, int viewType) {
|
||||
View v = LayoutInflater.from(context).inflate(R.layout.list_item_url_suggestion, root, false);
|
||||
return new UrlSuggestionListAdapter.ViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(UrlSuggestionListAdapter.ViewHolder vh, int position) {
|
||||
UrlSuggestion item = items.get(position);
|
||||
|
||||
String fullTitle, desc;
|
||||
int iconStringId;
|
||||
switch (item.getType()) {
|
||||
case UrlSuggestion.TYPE_CHANNEL:
|
||||
iconStringId = R.string.fa_at;
|
||||
fullTitle = item.getTitle();
|
||||
desc = item.getClaim() != null ? item.getClaim().getTitle() :
|
||||
((item.isUseTextAsDescription() && !Helper.isNullOrEmpty(item.getText())) ? item.getText() : String.format(context.getString(R.string.view_channel_url_desc), item.getText()));
|
||||
break;
|
||||
case UrlSuggestion.TYPE_TAG:
|
||||
iconStringId = R.string.fa_hashtag;
|
||||
fullTitle = String.format(context.getString(R.string.tag_url_title), item.getText());
|
||||
desc = String.format(context.getString(R.string.explore_tag_url_desc), item.getText());
|
||||
break;
|
||||
case UrlSuggestion.TYPE_SEARCH:
|
||||
iconStringId = R.string.fa_search;
|
||||
fullTitle = String.format(context.getString(R.string.search_url_title), item.getText());
|
||||
desc = String.format(context.getString(R.string.search_url_desc), item.getText());
|
||||
break;
|
||||
case UrlSuggestion.TYPE_FILE:
|
||||
default:
|
||||
iconStringId = R.string.fa_file;
|
||||
fullTitle = item.getTitle();
|
||||
desc = item.getClaim() != null ? item.getClaim().getTitle() :
|
||||
((item.isUseTextAsDescription() && !Helper.isNullOrEmpty(item.getText())) ? item.getText() : String.format(context.getString(R.string.view_file_url_desc), item.getText()));
|
||||
break;
|
||||
}
|
||||
|
||||
vh.iconView.setText(iconStringId);
|
||||
vh.titleView.setText(fullTitle);
|
||||
vh.descView.setText(desc);
|
||||
|
||||
vh.itemView.setOnClickListener(view -> {
|
||||
if (listener != null) {
|
||||
listener.onUrlSuggestionClicked(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
protected final SolidIconView iconView;
|
||||
protected final TextView titleView;
|
||||
protected final TextView descView;
|
||||
public ViewHolder(View v) {
|
||||
super(v);
|
||||
iconView = v.findViewById(R.id.url_suggestion_icon);
|
||||
titleView = v.findViewById(R.id.url_suggestion_title);
|
||||
descView = v.findViewById(R.id.url_suggestion_description);
|
||||
}
|
||||
}
|
||||
|
||||
public interface UrlSuggestionClickListener {
|
||||
void onUrlSuggestionClicked(UrlSuggestion urlSuggestion);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package io.lbry.browser.adapter;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
|
||||
import io.lbry.browser.listener.SignInListener;
|
||||
import io.lbry.browser.listener.WalletSyncListener;
|
||||
import io.lbry.browser.ui.verification.EmailVerificationFragment;
|
||||
import io.lbry.browser.ui.verification.ManualVerificationFragment;
|
||||
import io.lbry.browser.ui.verification.PhoneVerificationFragment;
|
||||
import io.lbry.browser.ui.verification.WalletVerificationFragment;
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
/**
|
||||
* 4 fragments
|
||||
* - Email collect / verify (sign in)
|
||||
* - Phone number collect / verify (rewards)
|
||||
* - Wallet password
|
||||
* - Manual verification page
|
||||
*/
|
||||
public class VerificationPagerAdapter extends FragmentStateAdapter {
|
||||
public static final int PAGE_VERIFICATION_EMAIL = 0;
|
||||
public static final int PAGE_VERIFICATION_PHONE = 1;
|
||||
public static final int PAGE_VERIFICATION_WALLET = 2;
|
||||
public static final int PAGE_VERIFICATION_MANUAL = 3;
|
||||
|
||||
private final FragmentActivity activity;
|
||||
|
||||
public VerificationPagerAdapter(FragmentActivity activity) {
|
||||
super(activity);
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
default:
|
||||
EmailVerificationFragment evFragment = EmailVerificationFragment.class.newInstance();
|
||||
if (activity instanceof SignInListener) {
|
||||
evFragment.setListener((SignInListener) activity);
|
||||
}
|
||||
return evFragment;
|
||||
case 1:
|
||||
PhoneVerificationFragment pvFragment = PhoneVerificationFragment.class.newInstance();
|
||||
if (activity instanceof SignInListener) {
|
||||
pvFragment.setListener((SignInListener) activity);
|
||||
}
|
||||
return pvFragment;
|
||||
case 2:
|
||||
WalletVerificationFragment wvFragment = WalletVerificationFragment.class.newInstance();
|
||||
if (activity instanceof WalletSyncListener) {
|
||||
wvFragment.setListener((WalletSyncListener) activity);
|
||||
}
|
||||
return wvFragment;
|
||||
case 3:
|
||||
ManualVerificationFragment mvFragment = ManualVerificationFragment.class.newInstance();
|
||||
if (activity instanceof SignInListener) {
|
||||
mvFragment.setListener((SignInListener) activity);
|
||||
}
|
||||
return mvFragment;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package io.lbry.browser.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.MainActivity;
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.model.WalletDetailItem;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import io.lbry.browser.views.CreditsBalanceView;
|
||||
|
||||
public class WalletDetailAdapter extends BaseAdapter {
|
||||
private final List<WalletDetailItem> list;
|
||||
private final LayoutInflater inflater;
|
||||
|
||||
public WalletDetailAdapter(Context ctx, List<WalletDetailItem> rows) {
|
||||
this.list = rows;
|
||||
this.inflater = LayoutInflater.from(ctx);
|
||||
}
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int i) {
|
||||
return list.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
if (view == null) {
|
||||
view = inflater.inflate(R.layout.list_item_boosting_balance, viewGroup, false);
|
||||
|
||||
CreditsBalanceView balanceView = view.findViewById(R.id.wallet_supporting_balance);
|
||||
TextView detailTextView = view.findViewById(R.id.detail);
|
||||
TextView detailExplanationTextView = view.findViewById(R.id.detail_explanation);
|
||||
|
||||
WalletDetailItem item = (WalletDetailItem) getItem(i);
|
||||
|
||||
detailTextView.setText(item.detail);
|
||||
detailExplanationTextView.setText(item.detailDesc);
|
||||
|
||||
Helper.setViewText(balanceView, item.detailAmount);
|
||||
|
||||
ProgressBar progressUnlockTips = view.findViewById(R.id.wallet_unlock_tips_progress);
|
||||
progressUnlockTips.setVisibility(item.isInProgress ? View.VISIBLE : View.GONE);
|
||||
|
||||
ImageButton buttonLock = view.findViewById(R.id.lock_button);
|
||||
buttonLock.setVisibility((item.isUnlockable && !item.isInProgress) ? View.VISIBLE : View.GONE);
|
||||
|
||||
if (item.isUnlockable) {
|
||||
buttonLock.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (view.getContext() != null) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext()).
|
||||
setTitle(R.string.unlock_tips).
|
||||
setMessage(R.string.confirm_unlock_tips)
|
||||
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
unlockTips(view);
|
||||
}
|
||||
}).setNegativeButton(R.string.no, null);
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
private void unlockTips(View v) {
|
||||
Context ctx = v.getContext();
|
||||
if (ctx instanceof MainActivity) {
|
||||
v.setVisibility(View.GONE);
|
||||
View progress = v.getRootView().findViewById(R.id.wallet_unlock_tips_progress);
|
||||
progress.setVisibility(View.VISIBLE);
|
||||
((MainActivity) ctx).unlockTips();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,459 @@
|
||||
package io.lbry.browser.data;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.model.Tag;
|
||||
import io.lbry.browser.model.UrlSuggestion;
|
||||
import io.lbry.browser.model.ViewHistory;
|
||||
import io.lbry.browser.model.lbryinc.LbryNotification;
|
||||
import io.lbry.browser.model.lbryinc.Subscription;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import io.lbry.browser.utils.LbryUri;
|
||||
|
||||
public class DatabaseHelper extends SQLiteOpenHelper {
|
||||
public static final int DATABASE_VERSION = 8;
|
||||
public static final String DATABASE_NAME = "LbryApp.db";
|
||||
private static DatabaseHelper instance;
|
||||
|
||||
private static final String[] SQL_CREATE_TABLES = {
|
||||
// local subscription store
|
||||
"CREATE TABLE subscriptions (url TEXT PRIMARY KEY NOT NULL, channel_name TEXT NOT NULL, is_notifications_disabled INTEGER DEFAULT 0 NOT NULL)",
|
||||
// url entry / suggestion history
|
||||
"CREATE TABLE url_history (id INTEGER PRIMARY KEY NOT NULL, value TEXT NOT NULL, url TEXT, type INTEGER NOT NULL, timestamp TEXT NOT NULL)",
|
||||
// tags (known and followed)
|
||||
"CREATE TABLE tags (id INTEGER PRIMARY KEY NOT NULL, name TEXT NOT NULL, is_followed INTEGER NOT NULL)",
|
||||
// view history (stores only stream claims that have resolved)
|
||||
"CREATE TABLE view_history (" +
|
||||
" id INTEGER PRIMARY KEY NOT NULL" +
|
||||
", url TEXT NOT NULL" +
|
||||
", claim_id TEXT" +
|
||||
", claim_name TEXT" +
|
||||
", cost REAL " +
|
||||
", currency TEXT " +
|
||||
", title TEXT " +
|
||||
", publisher_claim_id TEXT" +
|
||||
", publisher_name TEXT" +
|
||||
", publisher_title TEXT" +
|
||||
", thumbnail_url TEXT" +
|
||||
", release_time INTEGER " +
|
||||
", device TEXT" +
|
||||
", timestamp TEXT NOT NULL)",
|
||||
"CREATE TABLE notifications (" +
|
||||
" id INTEGER PRIMARY KEY NOT NULL" +
|
||||
", remote_id INTEGER NOT NULL" +
|
||||
", author_url TEXT" +
|
||||
", title TEXT" +
|
||||
", description TEXT" +
|
||||
", thumbnail_url TEXT" +
|
||||
", target_url TEXT" +
|
||||
", rule TEXT" +
|
||||
", is_read INTEGER DEFAULT 0 NOT NULL" +
|
||||
", is_seen INTEGER DEFAULT 0 NOT NULL " +
|
||||
", timestamp TEXT NOT NULL)",
|
||||
"CREATE TABLE shuffle_watched (id INTEGER PRIMARY KEY NOT NULL, claim_id TEXT NOT NULL)"
|
||||
};
|
||||
private static final String[] SQL_CREATE_INDEXES = {
|
||||
"CREATE UNIQUE INDEX idx_subscription_url ON subscriptions (url)",
|
||||
"CREATE UNIQUE INDEX idx_url_history_value ON url_history (value)",
|
||||
"CREATE UNIQUE INDEX idx_url_history_url ON url_history (url)",
|
||||
"CREATE UNIQUE INDEX idx_tag_name ON tags (name)",
|
||||
"CREATE UNIQUE INDEX idx_view_history_url_device ON view_history (url, device)",
|
||||
"CREATE INDEX idx_view_history_device ON view_history (device)",
|
||||
"CREATE UNIQUE INDEX idx_notification_remote_id ON notifications (remote_id)",
|
||||
"CREATE INDEX idx_notification_timestamp ON notifications (timestamp)",
|
||||
"CREATE UNIQUE INDEX idx_shuffle_watched_claim ON shuffle_watched (claim_id)",
|
||||
};
|
||||
|
||||
private static final String[] SQL_V1_V2_UPGRADE = {
|
||||
"ALTER TABLE view_history ADD COLUMN currency TEXT"
|
||||
};
|
||||
|
||||
private static final String[] SQL_V2_V3_UPGRADE = {
|
||||
"CREATE TABLE notifications (" +
|
||||
" id INTEGER PRIMARY KEY NOT NULL" +
|
||||
", title TEXT" +
|
||||
", description TEXT" +
|
||||
", thumbnail_url TEXT" +
|
||||
", target_url TEXT" +
|
||||
", is_read INTEGER DEFAULT 0 NOT NULL" +
|
||||
", timestamp TEXT NOT NULL)",
|
||||
"CREATE INDEX idx_notification_timestamp ON notifications (timestamp)"
|
||||
};
|
||||
|
||||
private static final String[] SQL_V3_V4_UPGRADE = {
|
||||
"ALTER TABLE notifications ADD COLUMN remote_id INTEGER",
|
||||
"CREATE UNIQUE INDEX idx_notification_remote_id ON notifications (remote_id)"
|
||||
};
|
||||
private static final String[] SQL_V4_V5_UPGRADE = {
|
||||
"ALTER TABLE notifications ADD COLUMN rule TEXT",
|
||||
"ALTER TABLE notifications ADD COLUMN is_seen TEXT"
|
||||
};
|
||||
private static final String[] SQL_V5_V6_UPGRADE = {
|
||||
"ALTER TABLE notifications ADD COLUMN author_url TEXT"
|
||||
};
|
||||
private static final String[] SQL_V6_V7_UPGRADE = {
|
||||
"CREATE TABLE shuffle_watched (id INTEGER PRIMARY KEY NOT NULL, claim_id TEXT NOT NULL)",
|
||||
"CREATE UNIQUE INDEX idx_shuffle_watched_claim ON shuffle_watched (claim_id)"
|
||||
};
|
||||
private static final String[] SQL_V7_V8_UPGRADE = {
|
||||
"AlTER TABLE subscriptions ADD COLUMN is_notifications_disabled INTEGER DEFAULT 0 NOT NULL"
|
||||
};
|
||||
|
||||
private static final String SQL_INSERT_SUBSCRIPTION = "REPLACE INTO subscriptions (channel_name, url, is_notifications_disabled) VALUES (?, ?, ?)";
|
||||
private static final String SQL_UPDATE_SUBSCRIPTION_NOTIFICATION = "UPDATE subscriptions SET is_notification_disabled = ? WHERE url = ?";
|
||||
private static final String SQL_CLEAR_SUBSCRIPTIONS = "DELETE FROM subscriptions";
|
||||
private static final String SQL_DELETE_SUBSCRIPTION = "DELETE FROM subscriptions WHERE url = ?";
|
||||
private static final String SQL_GET_SUBSCRIPTIONS = "SELECT channel_name, url, is_notifications_disabled FROM subscriptions";
|
||||
|
||||
private static final String SQL_INSERT_URL_HISTORY = "REPLACE INTO url_history (value, url, type, timestamp) VALUES (?, ?, ?, ?)";
|
||||
private static final String SQL_CLEAR_URL_HISTORY = "DELETE FROM url_history";
|
||||
private static final String SQL_CLEAR_URL_HISTORY_BEFORE_TIME = "DELETE FROM url_history WHERE timestamp < ?";
|
||||
private static final String SQL_GET_RECENT_URL_HISTORY = "SELECT value, url, type FROM url_history ORDER BY timestamp DESC LIMIT 10";
|
||||
|
||||
private static final String SQL_INSERT_NOTIFICATION = "REPLACE INTO notifications (remote_id, author_url, title, description, rule, target_url, is_read, is_seen, timestamp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
private static final String SQL_GET_NOTIFICATIONS = "SELECT id, remote_id, author_url, title, description, rule, target_url, is_read, is_seen, timestamp FROM notifications ORDER BY timestamp DESC LIMIT 500";
|
||||
private static final String SQL_GET_UNREAD_NOTIFICATIONS_COUNT = "SELECT COUNT(id) FROM notifications WHERE is_read <> 1";
|
||||
private static final String SQL_GET_UNSEEN_NOTIFICATIONS_COUNT = "SELECT COUNT(id) FROM notifications WHERE is_seen <> 1";
|
||||
private static final String SQL_MARK_NOTIFICATIONS_READ = "UPDATE notifications SET is_read = 1 WHERE is_read = 0";
|
||||
private static final String SQL_MARK_NOTIFICATIONS_SEEN = "UPDATE notifications SET is_seen = 1 WHERE is_seen = 0";
|
||||
private static final String SQL_MARK_NOTIFICATION_READ_AND_SEEN = "UPDATE notifications SET is_read = 1, is_seen = 1 WHERE id = ?";
|
||||
|
||||
private static final String SQL_INSERT_SHUFFLE_WATCHED = "REPLACE INTO shuffle_watched (claim_id) VALUES (?)";
|
||||
private static final String SQL_GET_SHUFFLE_WATCHED_CLAIMS = "SELECT claim_id FROM shuffle_watched";
|
||||
|
||||
private static final String SQL_INSERT_VIEW_HISTORY =
|
||||
"REPLACE INTO view_history (url, claim_id, claim_name, cost, currency, title, publisher_claim_id, publisher_name, publisher_title, thumbnail_url, device, release_time, timestamp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
private static final String SQL_GET_VIEW_HISTORY =
|
||||
"SELECT url, claim_id, claim_name, cost, currency, title, publisher_claim_id, publisher_name, publisher_title, thumbnail_url, device, release_time, timestamp " +
|
||||
"FROM view_history WHERE '' = ? OR timestamp < ? ORDER BY timestamp DESC LIMIT %d";
|
||||
private static final String SQL_CLEAR_VIEW_HISTORY = "DELETE FROM view_history";
|
||||
private static final String SQL_CLEAR_VIEW_HISTORY_BY_DEVICE = "DELETE FROM view_history WHERE device = ?";
|
||||
private static final String SQL_CLEAR_VIEW_HISTORY_BEFORE_TIME = "DELETE FROM view_history WHERE timestamp < ?";
|
||||
private static final String SQL_CLEAR_VIEW_HISTORY_BY_DEVICE_BEFORE_TIME = "DELETE FROM view_history WHERE device = ? AND timestamp < ?";
|
||||
|
||||
private static final String SQL_INSERT_TAG = "REPLACE INTO tags (name, is_followed) VALUES (?, ?)";
|
||||
private static final String SQL_GET_KNOWN_TAGS = "SELECT name, is_followed FROM tags";
|
||||
private static final String SQL_UNFOLLOW_TAGS = "UPDATE tags SET is_followed = 0";
|
||||
private static final String SQL_GET_FOLLOWED_TAGS = "SELECT name FROM tags WHERE is_followed = 1";
|
||||
|
||||
|
||||
|
||||
public DatabaseHelper(Context context) {
|
||||
super(context, String.format("%s/%s", context.getFilesDir().getAbsolutePath(), DATABASE_NAME), null, DATABASE_VERSION);
|
||||
instance = this;
|
||||
}
|
||||
public static DatabaseHelper getInstance() {
|
||||
return instance;
|
||||
}
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
for (String sql : SQL_CREATE_TABLES) {
|
||||
db.execSQL(sql);
|
||||
}
|
||||
for (String sql : SQL_CREATE_INDEXES) {
|
||||
db.execSQL(sql);
|
||||
}
|
||||
}
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
if (oldVersion < 2) {
|
||||
for (String sql : SQL_V1_V2_UPGRADE) {
|
||||
db.execSQL(sql);
|
||||
}
|
||||
}
|
||||
if (oldVersion < 3) {
|
||||
for (String sql : SQL_V2_V3_UPGRADE) {
|
||||
db.execSQL(sql);
|
||||
}
|
||||
}
|
||||
if (oldVersion < 4) {
|
||||
for (String sql : SQL_V3_V4_UPGRADE) {
|
||||
db.execSQL(sql);
|
||||
}
|
||||
}
|
||||
if (oldVersion < 5) {
|
||||
for (String sql : SQL_V4_V5_UPGRADE) {
|
||||
db.execSQL(sql);
|
||||
}
|
||||
}
|
||||
if (oldVersion < 6) {
|
||||
for (String sql : SQL_V5_V6_UPGRADE) {
|
||||
db.execSQL(sql);
|
||||
}
|
||||
}
|
||||
if (oldVersion < 7) {
|
||||
for (String sql : SQL_V6_V7_UPGRADE) {
|
||||
db.execSQL(sql);
|
||||
}
|
||||
}
|
||||
if (oldVersion < 8) {
|
||||
for (String sql : SQL_V7_V8_UPGRADE) {
|
||||
db.execSQL(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
|
||||
}
|
||||
|
||||
public static void createOrUpdateUrlHistoryItem(String text, String url, int type, SQLiteDatabase db) {
|
||||
db.execSQL(SQL_INSERT_URL_HISTORY, new Object[] {
|
||||
text, url, type, new SimpleDateFormat(Helper.ISO_DATE_FORMAT_PATTERN).format(new Date())
|
||||
});
|
||||
}
|
||||
public static void clearUrlHistory(SQLiteDatabase db) {
|
||||
db.execSQL(SQL_CLEAR_URL_HISTORY);
|
||||
}
|
||||
public static void clearUrlHistoryBefore(Date date, SQLiteDatabase db) {
|
||||
db.execSQL(SQL_CLEAR_URL_HISTORY_BEFORE_TIME, new Object[] { new SimpleDateFormat(Helper.ISO_DATE_FORMAT_PATTERN).format(new Date()) });
|
||||
}
|
||||
|
||||
// History items are essentially url suggestions
|
||||
public static List<UrlSuggestion> getRecentHistory(SQLiteDatabase db) {
|
||||
List<UrlSuggestion> suggestions = new ArrayList<>();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = db.rawQuery(SQL_GET_RECENT_URL_HISTORY, null);
|
||||
while (cursor.moveToNext()) {
|
||||
UrlSuggestion suggestion = new UrlSuggestion();
|
||||
suggestion.setText(cursor.getString(0));
|
||||
suggestion.setUri(cursor.isNull(1) ? null : LbryUri.tryParse(cursor.getString(1)));
|
||||
suggestion.setType(cursor.getInt(2));
|
||||
suggestion.setTitleUrlOnly(true);
|
||||
suggestions.add(suggestion);
|
||||
}
|
||||
} finally {
|
||||
Helper.closeCursor(cursor);
|
||||
}
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
// View history items are stream claims
|
||||
public static void createOrUpdateViewHistoryItem(ViewHistory viewHistory, SQLiteDatabase db) {
|
||||
db.execSQL(SQL_INSERT_VIEW_HISTORY, new Object[] {
|
||||
viewHistory.getUri().toString(),
|
||||
viewHistory.getClaimId(),
|
||||
viewHistory.getClaimName(),
|
||||
viewHistory.getCost() != null ? viewHistory.getCost().doubleValue() : 0,
|
||||
viewHistory.getCurrency(),
|
||||
viewHistory.getTitle(),
|
||||
viewHistory.getPublisherClaimId(),
|
||||
viewHistory.getPublisherName(),
|
||||
viewHistory.getPublisherTitle(),
|
||||
viewHistory.getThumbnailUrl(),
|
||||
viewHistory.getDevice(),
|
||||
viewHistory.getReleaseTime(),
|
||||
new SimpleDateFormat(Helper.ISO_DATE_FORMAT_PATTERN).format(new Date())
|
||||
});
|
||||
}
|
||||
|
||||
public static List<ViewHistory> getViewHistory(String lastTimestamp, int pageLimit, SQLiteDatabase db) {
|
||||
List<ViewHistory> history = new ArrayList<>();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
String arg = lastTimestamp == null ? "" : lastTimestamp;
|
||||
cursor = db.rawQuery(String.format(SQL_GET_VIEW_HISTORY, pageLimit), new String[] { arg, arg });
|
||||
while (cursor.moveToNext()) {
|
||||
ViewHistory item = new ViewHistory();
|
||||
int cursorIndex = 0;
|
||||
item.setUri(LbryUri.tryParse(cursor.getString(cursorIndex++)));
|
||||
item.setClaimId(cursor.getString(cursorIndex++));
|
||||
item.setClaimName(cursor.getString(cursorIndex++));
|
||||
item.setCost(new BigDecimal(cursor.getDouble(cursorIndex++)));
|
||||
item.setCurrency(cursor.getString(cursorIndex++));
|
||||
item.setTitle(cursor.getString(cursorIndex++));
|
||||
item.setPublisherClaimId(cursor.getString(cursorIndex++));
|
||||
item.setPublisherName(cursor.getString(cursorIndex++));
|
||||
item.setPublisherTitle(cursor.getString(cursorIndex++));
|
||||
item.setThumbnailUrl(cursor.getString(cursorIndex++));
|
||||
item.setDevice(cursor.getString(cursorIndex++));
|
||||
item.setReleaseTime(cursor.getLong(cursorIndex++));
|
||||
try {
|
||||
item.setTimestamp(new SimpleDateFormat(Helper.ISO_DATE_FORMAT_PATTERN).parse(cursor.getString(cursorIndex)));
|
||||
} catch (ParseException ex) {
|
||||
// invalid timestamp (which shouldn't happen). Skip this item
|
||||
continue;
|
||||
}
|
||||
|
||||
history.add(item);
|
||||
}
|
||||
} finally {
|
||||
Helper.closeCursor(cursor);
|
||||
}
|
||||
return history;
|
||||
}
|
||||
|
||||
public static void createOrUpdateTag(Tag tag, SQLiteDatabase db) {
|
||||
db.execSQL(SQL_INSERT_TAG, new Object[] { tag.getLowercaseName(), tag.isFollowed() ? 1 : 0 });
|
||||
}
|
||||
public static void setAllTagsUnfollowed(SQLiteDatabase db) {
|
||||
db.execSQL(SQL_UNFOLLOW_TAGS);
|
||||
}
|
||||
public static List<Tag> getTags(SQLiteDatabase db) {
|
||||
List<Tag> tags = new ArrayList<>();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = db.rawQuery(SQL_GET_KNOWN_TAGS, null);
|
||||
while (cursor.moveToNext()) {
|
||||
Tag tag = new Tag();
|
||||
tag.setName(cursor.getString(0));
|
||||
tag.setFollowed(cursor.getInt(1) == 1);
|
||||
tags.add(tag);
|
||||
}
|
||||
} finally {
|
||||
Helper.closeCursor(cursor);
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
public static void createOrUpdateSubscription(Subscription subscription, SQLiteDatabase db) {
|
||||
db.execSQL(SQL_INSERT_SUBSCRIPTION, new Object[] {
|
||||
subscription.getChannelName(),
|
||||
subscription.getUrl(),
|
||||
subscription.isNotificationsDisabled() ? 1 : 0
|
||||
});
|
||||
}
|
||||
public static void setSubscriptionNotificationDisabled(boolean flag, String url, SQLiteDatabase db) {
|
||||
db.execSQL(SQL_UPDATE_SUBSCRIPTION_NOTIFICATION, new Object[] { flag ? 1 : 0, url });
|
||||
}
|
||||
public static void deleteSubscription(Subscription subscription, SQLiteDatabase db) {
|
||||
db.execSQL(SQL_DELETE_SUBSCRIPTION, new Object[] { subscription.getUrl() });
|
||||
}
|
||||
public static void clearSubscriptions(SQLiteDatabase db) {
|
||||
db.execSQL(SQL_CLEAR_SUBSCRIPTIONS);
|
||||
}
|
||||
public static List<Subscription> getSubscriptions(SQLiteDatabase db) {
|
||||
List<Subscription> subscriptions = new ArrayList<>();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = db.rawQuery(SQL_GET_SUBSCRIPTIONS, null);
|
||||
while (cursor.moveToNext()) {
|
||||
Subscription subscription = new Subscription();
|
||||
subscription.setChannelName(cursor.getString(0));
|
||||
subscription.setUrl(cursor.getString(1));
|
||||
subscription.setNotificationsDisabled(cursor.getInt(2) == 1);
|
||||
subscriptions.add(subscription);
|
||||
}
|
||||
} finally {
|
||||
Helper.closeCursor(cursor);
|
||||
}
|
||||
return subscriptions;
|
||||
}
|
||||
|
||||
public static void createOrUpdateNotification(LbryNotification notification, SQLiteDatabase db) {
|
||||
db.execSQL(SQL_INSERT_NOTIFICATION, new Object[] {
|
||||
notification.getRemoteId(),
|
||||
notification.getAuthorUrl(),
|
||||
notification.getTitle(),
|
||||
notification.getDescription(),
|
||||
notification.getRule(),
|
||||
notification.getTargetUrl(),
|
||||
notification.isRead() ? 1 : 0,
|
||||
notification.isSeen() ? 1 : 0,
|
||||
new SimpleDateFormat(Helper.ISO_DATE_FORMAT_PATTERN).format(notification.getTimestamp() != null ? notification.getTimestamp() : new Date())
|
||||
});
|
||||
}
|
||||
public static List<LbryNotification> getNotifications(SQLiteDatabase db) {
|
||||
List<LbryNotification> notifications = new ArrayList<>();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = db.rawQuery(SQL_GET_NOTIFICATIONS, null);
|
||||
while (cursor.moveToNext()) {
|
||||
LbryNotification notification = new LbryNotification();
|
||||
int columnIndex = 0;
|
||||
notification.setId(cursor.getLong(columnIndex++));
|
||||
notification.setRemoteId(cursor.getLong(columnIndex++));
|
||||
notification.setAuthorUrl(cursor.getString(columnIndex++));
|
||||
notification.setTitle(cursor.getString(columnIndex++));
|
||||
notification.setDescription(cursor.getString(columnIndex++));
|
||||
notification.setRule(cursor.getString(columnIndex++));
|
||||
notification.setTargetUrl(cursor.getString(columnIndex++));
|
||||
notification.setRead(cursor.getInt(columnIndex++) == 1);
|
||||
notification.setSeen(cursor.getInt(columnIndex++) == 1);
|
||||
try {
|
||||
notification.setTimestamp(new SimpleDateFormat(Helper.ISO_DATE_FORMAT_PATTERN).parse(cursor.getString(columnIndex++)));
|
||||
} catch (ParseException ex) {
|
||||
// invalid timestamp (which shouldn't happen). Skip this item
|
||||
continue;
|
||||
}
|
||||
notifications.add(notification);
|
||||
}
|
||||
} finally {
|
||||
Helper.closeCursor(cursor);
|
||||
}
|
||||
return notifications;
|
||||
}
|
||||
public static void deleteNotifications(List<LbryNotification> notifications, SQLiteDatabase db) {
|
||||
StringBuilder sb = new StringBuilder("DELETE FROM notifications WHERE remote_id IN (");
|
||||
List<Object> remoteIds = new ArrayList<>();
|
||||
String delim = "";
|
||||
for (int i = 0; i < notifications.size(); i++) {
|
||||
remoteIds.add(String.valueOf(notifications.get(i).getRemoteId()));
|
||||
sb.append(delim).append("?");
|
||||
delim = ",";
|
||||
}
|
||||
sb.append(")");
|
||||
|
||||
String sql = sb.toString();
|
||||
db.execSQL(sql, remoteIds.toArray());
|
||||
}
|
||||
public static int getUnreadNotificationsCount(SQLiteDatabase db) {
|
||||
int count = 0;
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = db.rawQuery(SQL_GET_UNREAD_NOTIFICATIONS_COUNT, null);
|
||||
if (cursor.moveToNext()) {
|
||||
count = cursor.getInt(0);
|
||||
}
|
||||
} finally {
|
||||
Helper.closeCursor(cursor);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
public static int getUnseenNotificationsCount(SQLiteDatabase db) {
|
||||
int count = 0;
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = db.rawQuery(SQL_GET_UNSEEN_NOTIFICATIONS_COUNT, null);
|
||||
if (cursor.moveToNext()) {
|
||||
count = cursor.getInt(0);
|
||||
}
|
||||
} finally {
|
||||
Helper.closeCursor(cursor);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
public static void markNotificationsSeen(SQLiteDatabase db) {
|
||||
db.execSQL(SQL_MARK_NOTIFICATIONS_SEEN);
|
||||
}
|
||||
public static void markNotificationsRead(SQLiteDatabase db) {
|
||||
db.execSQL(SQL_MARK_NOTIFICATIONS_READ);
|
||||
}
|
||||
public static void markNotificationReadAndSeen(long notificationId, SQLiteDatabase db) {
|
||||
db.execSQL(SQL_MARK_NOTIFICATION_READ_AND_SEEN, new Object[] { notificationId });
|
||||
}
|
||||
public static void createOrUpdateShuffleWatched(String claimId, SQLiteDatabase db) {
|
||||
db.execSQL(SQL_INSERT_SHUFFLE_WATCHED, new Object[] { claimId });
|
||||
}
|
||||
public static List<String> getShuffleWatchedClaims(SQLiteDatabase db) {
|
||||
List<String> claimIds = new ArrayList<>();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = db.rawQuery(SQL_GET_SHUFFLE_WATCHED_CLAIMS, null);
|
||||
while (cursor.moveToNext()) {
|
||||
claimIds.add(cursor.getString(0));
|
||||
}
|
||||
} finally {
|
||||
Helper.closeCursor(cursor);
|
||||
}
|
||||
return claimIds;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package io.lbry.browser.dialog;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import lombok.Setter;
|
||||
|
||||
public class ContentFromDialogFragment extends BottomSheetDialogFragment {
|
||||
public static final String TAG = "ContentFromDialog";
|
||||
public static final int ITEM_FROM_PAST_24_HOURS = 1;
|
||||
public static final int ITEM_FROM_PAST_WEEK = 2;
|
||||
public static final int ITEM_FROM_PAST_MONTH = 3;
|
||||
public static final int ITEM_FROM_PAST_YEAR = 4;
|
||||
public static final int ITEM_FROM_ALL_TIME = 5;
|
||||
|
||||
@Setter
|
||||
private ContentFromListener contentFromListener;
|
||||
private int currentFromItem;
|
||||
|
||||
public static ContentFromDialogFragment newInstance() {
|
||||
return new ContentFromDialogFragment();
|
||||
}
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.dialog_content_from, container,false);
|
||||
|
||||
ContentFromItemClickListener clickListener = new ContentFromItemClickListener(this, contentFromListener);
|
||||
view.findViewById(R.id.content_from_past_24_hours_item).setOnClickListener(clickListener);
|
||||
view.findViewById(R.id.content_from_past_week_item).setOnClickListener(clickListener);
|
||||
view.findViewById(R.id.content_from_past_month_item).setOnClickListener(clickListener);
|
||||
view.findViewById(R.id.content_from_past_year_item).setOnClickListener(clickListener);
|
||||
view.findViewById(R.id.content_from_all_time_item).setOnClickListener(clickListener);
|
||||
checkSelectedFromItem(currentFromItem, view);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
public static void checkSelectedFromItem(int fromItem, View parent) {
|
||||
int checkViewId = -1;
|
||||
switch (fromItem) {
|
||||
case ITEM_FROM_PAST_24_HOURS: checkViewId = R.id.content_from_past_24_hours_item_selected; break;
|
||||
case ITEM_FROM_PAST_WEEK: checkViewId = R.id.content_from_past_week_item_selected; break;
|
||||
case ITEM_FROM_PAST_MONTH: checkViewId = R.id.content_from_past_month_item_selected; break;
|
||||
case ITEM_FROM_PAST_YEAR: checkViewId = R.id.content_from_past_year_item_selected; break;
|
||||
case ITEM_FROM_ALL_TIME: checkViewId = R.id.content_from_all_time_item_selected; break;
|
||||
}
|
||||
if (parent != null && checkViewId > -1) {
|
||||
parent.findViewById(checkViewId).setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentFromItem(int fromItem) {
|
||||
this.currentFromItem = fromItem;
|
||||
}
|
||||
|
||||
private static class ContentFromItemClickListener implements View.OnClickListener {
|
||||
|
||||
private final int[] checkViewIds = {
|
||||
R.id.content_from_past_24_hours_item,
|
||||
R.id.content_from_past_week_item,
|
||||
R.id.content_from_past_month_item,
|
||||
R.id.content_from_past_year_item,
|
||||
R.id.content_from_all_time_item
|
||||
};
|
||||
private final BottomSheetDialogFragment dialog;
|
||||
private final ContentFromListener listener;
|
||||
|
||||
public ContentFromItemClickListener(BottomSheetDialogFragment dialog, ContentFromListener listener) {
|
||||
this.dialog = dialog;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
int currentFromItem = -1;
|
||||
|
||||
if (dialog != null) {
|
||||
View dialogView = dialog.getView();
|
||||
if (dialogView != null) {
|
||||
for (int id : checkViewIds) {
|
||||
dialogView.findViewById(id).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (view.getId()) {
|
||||
case R.id.content_from_past_24_hours_item: currentFromItem = ITEM_FROM_PAST_24_HOURS; break;
|
||||
case R.id.content_from_past_week_item: currentFromItem = ITEM_FROM_PAST_WEEK; break;
|
||||
case R.id.content_from_past_month_item: currentFromItem = ITEM_FROM_PAST_MONTH; break;
|
||||
case R.id.content_from_past_year_item: currentFromItem = ITEM_FROM_PAST_YEAR; break;
|
||||
case R.id.content_from_all_time_item: currentFromItem = ITEM_FROM_ALL_TIME; break;
|
||||
}
|
||||
|
||||
checkSelectedFromItem(currentFromItem, view);
|
||||
if (listener != null) {
|
||||
listener.onContentFromItemSelected(currentFromItem);
|
||||
}
|
||||
|
||||
if (dialog != null) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface ContentFromListener {
|
||||
void onContentFromItemSelected(int contentFromItem);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package io.lbry.browser.dialog;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import lombok.Setter;
|
||||
|
||||
public class ContentScopeDialogFragment extends BottomSheetDialogFragment {
|
||||
public static final String TAG = "ContentScopeDialog";
|
||||
public static final int ITEM_EVERYONE = 1;
|
||||
public static final int ITEM_TAGS = 2;
|
||||
|
||||
@Setter
|
||||
private ContentScopeListener contentScopeListener;
|
||||
private int currentScopeItem;
|
||||
|
||||
public static ContentScopeDialogFragment newInstance() {
|
||||
return new ContentScopeDialogFragment();
|
||||
}
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.dialog_content_scope, container,false);
|
||||
|
||||
ContentScopeItemClickListener clickListener = new ContentScopeItemClickListener(this, contentScopeListener);
|
||||
view.findViewById(R.id.content_scope_everyone_item).setOnClickListener(clickListener);
|
||||
view.findViewById(R.id.content_scope_tags_item).setOnClickListener(clickListener);
|
||||
checkSelectedScopeItem(currentScopeItem, view);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
public static void checkSelectedScopeItem(int scope, View parent) {
|
||||
int checkViewId = -1;
|
||||
switch (scope) {
|
||||
case ITEM_EVERYONE: checkViewId = R.id.content_scope_everyone_item_selected; break;
|
||||
case ITEM_TAGS: checkViewId = R.id.content_scope_tags_item_selected; break;
|
||||
}
|
||||
if (parent != null && checkViewId > -1) {
|
||||
parent.findViewById(checkViewId).setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentScopeItem(int scopeItem) {
|
||||
this.currentScopeItem = scopeItem;
|
||||
}
|
||||
|
||||
private static class ContentScopeItemClickListener implements View.OnClickListener {
|
||||
|
||||
private final int[] checkViewIds = {
|
||||
R.id.content_scope_everyone_item_selected, R.id.content_scope_tags_item_selected
|
||||
};
|
||||
private final BottomSheetDialogFragment dialog;
|
||||
private final ContentScopeListener listener;
|
||||
|
||||
public ContentScopeItemClickListener(BottomSheetDialogFragment dialog, ContentScopeListener listener) {
|
||||
this.dialog = dialog;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
int scopeItem = -1;
|
||||
|
||||
if (dialog != null) {
|
||||
View dialogView = dialog.getView();
|
||||
if (dialogView != null) {
|
||||
for (int id : checkViewIds) {
|
||||
dialogView.findViewById(id).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (view.getId()) {
|
||||
case R.id.content_scope_everyone_item: scopeItem = ITEM_EVERYONE; break;
|
||||
case R.id.content_scope_tags_item: scopeItem = ITEM_TAGS; break;
|
||||
}
|
||||
|
||||
checkSelectedScopeItem(scopeItem, view);
|
||||
if (listener != null) {
|
||||
listener.onContentScopeItemSelected(scopeItem);
|
||||
}
|
||||
|
||||
if (dialog != null) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface ContentScopeListener {
|
||||
void onContentScopeItemSelected(int scopeItem);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package io.lbry.browser.dialog;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import lombok.Setter;
|
||||
|
||||
public class ContentSortDialogFragment extends BottomSheetDialogFragment {
|
||||
public static final String TAG = "ContentSortDialog";
|
||||
public static final int ITEM_SORT_BY_TRENDING = 1;
|
||||
public static final int ITEM_SORT_BY_NEW = 2;
|
||||
public static final int ITEM_SORT_BY_TOP = 3;
|
||||
|
||||
@Setter
|
||||
private SortByListener sortByListener;
|
||||
private int currentSortByItem;
|
||||
|
||||
public static ContentSortDialogFragment newInstance() {
|
||||
return new ContentSortDialogFragment();
|
||||
}
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.dialog_content_sort, container,false);
|
||||
|
||||
SortByItemClickListener clickListener = new SortByItemClickListener(this, sortByListener);
|
||||
view.findViewById(R.id.sort_by_trending_item).setOnClickListener(clickListener);
|
||||
view.findViewById(R.id.sort_by_new_item).setOnClickListener(clickListener);
|
||||
view.findViewById(R.id.sort_by_top_item).setOnClickListener(clickListener);
|
||||
checkSelectedSortByItem(currentSortByItem, view);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
public static void checkSelectedSortByItem(int sortByItem, View parent) {
|
||||
int checkViewId = -1;
|
||||
switch (sortByItem) {
|
||||
case ITEM_SORT_BY_TRENDING: checkViewId = R.id.sort_by_trending_item_selected; break;
|
||||
case ITEM_SORT_BY_NEW: checkViewId = R.id.sort_by_new_item_selected; break;
|
||||
case ITEM_SORT_BY_TOP: checkViewId = R.id.sort_by_top_item_selected; break;
|
||||
}
|
||||
if (parent != null && checkViewId > -1) {
|
||||
parent.findViewById(checkViewId).setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentSortByItem(int sortByItem) {
|
||||
this.currentSortByItem = sortByItem;
|
||||
}
|
||||
|
||||
private static class SortByItemClickListener implements View.OnClickListener {
|
||||
|
||||
private final int[] checkViewIds = {
|
||||
R.id.sort_by_trending_item_selected, R.id.sort_by_new_item_selected, R.id.sort_by_top_item_selected
|
||||
};
|
||||
private final BottomSheetDialogFragment dialog;
|
||||
private final SortByListener listener;
|
||||
|
||||
public SortByItemClickListener(BottomSheetDialogFragment dialog, SortByListener listener) {
|
||||
this.dialog = dialog;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
int selectedSortByItem = -1;
|
||||
|
||||
if (dialog != null) {
|
||||
View dialogView = dialog.getView();
|
||||
if (dialogView != null) {
|
||||
for (int id : checkViewIds) {
|
||||
dialogView.findViewById(id).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (view.getId()) {
|
||||
case R.id.sort_by_trending_item: selectedSortByItem = ITEM_SORT_BY_TRENDING; break;
|
||||
case R.id.sort_by_new_item: selectedSortByItem = ITEM_SORT_BY_NEW; break;
|
||||
case R.id.sort_by_top_item: selectedSortByItem = ITEM_SORT_BY_TOP; break;
|
||||
}
|
||||
|
||||
checkSelectedSortByItem(selectedSortByItem, view);
|
||||
if (listener != null) {
|
||||
listener.onSortByItemSelected(selectedSortByItem);
|
||||
}
|
||||
|
||||
if (dialog != null) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface SortByListener {
|
||||
void onSortByItemSelected(int sortBy);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
package io.lbry.browser.dialog;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatSpinner;
|
||||
import androidx.core.text.HtmlCompat;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.MainActivity;
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.adapter.InlineChannelSpinnerAdapter;
|
||||
import io.lbry.browser.listener.WalletBalanceListener;
|
||||
import io.lbry.browser.model.Claim;
|
||||
import io.lbry.browser.model.WalletBalance;
|
||||
import io.lbry.browser.tasks.GenericTaskHandler;
|
||||
import io.lbry.browser.tasks.claim.ClaimListResultHandler;
|
||||
import io.lbry.browser.tasks.claim.ClaimListTask;
|
||||
import io.lbry.browser.tasks.wallet.SupportCreateTask;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import io.lbry.browser.utils.Lbry;
|
||||
|
||||
public class CreateSupportDialogFragment extends BottomSheetDialogFragment implements WalletBalanceListener {
|
||||
public static final String TAG = "CreateSupportDialog";
|
||||
|
||||
private MaterialButton sendButton;
|
||||
private View cancelLink;
|
||||
private TextInputEditText inputAmount;
|
||||
private View inlineBalanceContainer;
|
||||
private TextView inlineBalanceValue;
|
||||
private ProgressBar sendProgress;
|
||||
|
||||
private InlineChannelSpinnerAdapter channelSpinnerAdapter;
|
||||
private AppCompatSpinner channelSpinner;
|
||||
private SwitchMaterial switchTip;
|
||||
|
||||
private boolean fetchingChannels;
|
||||
private ProgressBar progressLoadingChannels;
|
||||
|
||||
|
||||
private final CreateSupportListener listener;
|
||||
private final Claim claim;
|
||||
|
||||
private CreateSupportDialogFragment(Claim claim, CreateSupportListener listener) {
|
||||
super();
|
||||
this.claim = claim;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public static CreateSupportDialogFragment newInstance(Claim claim, CreateSupportListener listener) {
|
||||
return new CreateSupportDialogFragment(claim, listener);
|
||||
}
|
||||
|
||||
private void disableControls() {
|
||||
Dialog dialog = getDialog();
|
||||
if (dialog != null) {
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
}
|
||||
channelSpinner.setEnabled(false);
|
||||
switchTip.setEnabled(false);
|
||||
sendButton.setEnabled(false);
|
||||
cancelLink.setEnabled(false);
|
||||
}
|
||||
private void enableControls() {
|
||||
Dialog dialog = getDialog();
|
||||
if (dialog != null) {
|
||||
dialog.setCanceledOnTouchOutside(true);
|
||||
}
|
||||
channelSpinner.setEnabled(true);
|
||||
switchTip.setEnabled(true);
|
||||
sendButton.setEnabled(true);
|
||||
cancelLink.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.dialog_create_support, container, false);
|
||||
|
||||
inputAmount = view.findViewById(R.id.create_support_input_amount);
|
||||
inlineBalanceContainer = view.findViewById(R.id.create_support_inline_balance_container);
|
||||
inlineBalanceValue = view.findViewById(R.id.create_support_inline_balance_value);
|
||||
sendProgress = view.findViewById(R.id.create_support_progress);
|
||||
cancelLink = view.findViewById(R.id.create_support_cancel_link);
|
||||
sendButton = view.findViewById(R.id.create_support_send);
|
||||
|
||||
channelSpinner = view.findViewById(R.id.create_support_channel_spinner);
|
||||
switchTip = view.findViewById(R.id.create_support_make_tip_switch);
|
||||
progressLoadingChannels = view.findViewById(R.id.create_support_channel_progress);
|
||||
|
||||
inputAmount.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View view, boolean hasFocus) {
|
||||
inputAmount.setHint(hasFocus ? getString(R.string.zero) : "");
|
||||
inlineBalanceContainer.setVisibility(hasFocus ? View.VISIBLE : View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
inputAmount.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
updateSendButtonText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
|
||||
}
|
||||
});
|
||||
updateInfoText();
|
||||
updateSendButtonText();
|
||||
|
||||
String channel = null;
|
||||
if (Claim.TYPE_CHANNEL.equalsIgnoreCase(claim.getValueType())) {
|
||||
channel = claim.getTitleOrName();
|
||||
} else if (claim.getSigningChannel() != null) {
|
||||
channel = claim.getPublisherTitle();
|
||||
}
|
||||
TextView titleView = view.findViewById(R.id.create_support_title);
|
||||
String tipTitleText = Helper.isNullOrEmpty(channel) ? getString(R.string.send_a_tip) : getString(R.string.send_a_tip_to, channel);
|
||||
titleView.setText(tipTitleText);
|
||||
|
||||
switchTip.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
if (checked) {
|
||||
// show tip info
|
||||
titleView.setText(tipTitleText);
|
||||
updateSendButtonText();
|
||||
} else {
|
||||
// show support info
|
||||
titleView.setText(R.string.support_this_content);
|
||||
sendButton.setText(R.string.send_revocable_support);
|
||||
}
|
||||
updateInfoText();
|
||||
}
|
||||
});
|
||||
|
||||
sendButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String amountString = Helper.getValue(inputAmount.getText());
|
||||
if (Helper.isNullOrEmpty(amountString)) {
|
||||
showError(getString(R.string.invalid_amount));
|
||||
return;
|
||||
}
|
||||
|
||||
BigDecimal amount = new BigDecimal(amountString);
|
||||
if (amount.doubleValue() > Lbry.walletBalance.getAvailable().doubleValue()) {
|
||||
showError(getString(R.string.insufficient_balance));
|
||||
return;
|
||||
}
|
||||
if (amount.doubleValue() < Helper.MIN_SPEND) {
|
||||
showError(getString(R.string.min_spend_required));
|
||||
return;
|
||||
}
|
||||
|
||||
Claim selectedChannel = (Claim) channelSpinner.getSelectedItem();
|
||||
String channelId = !fetchingChannels && selectedChannel != null ? selectedChannel.getClaimId() : null;
|
||||
boolean isTip = switchTip.isChecked();
|
||||
SupportCreateTask task = new SupportCreateTask(
|
||||
claim.getClaimId(), channelId, amount, isTip, sendProgress, new GenericTaskHandler() {
|
||||
@Override
|
||||
public void beforeStart() {
|
||||
disableControls();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
enableControls();
|
||||
if (listener != null) {
|
||||
listener.onSupportCreated(amount, isTip);
|
||||
}
|
||||
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
showError(error.getMessage());
|
||||
enableControls();
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
});
|
||||
|
||||
cancelLink.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
onWalletBalanceUpdated(Lbry.walletBalance);
|
||||
updateInfoText();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void updateSendButtonText() {
|
||||
boolean isTip = switchTip.isChecked();
|
||||
if (!isTip) {
|
||||
sendButton.setText(R.string.send_revocable_support);
|
||||
} else {
|
||||
String amountString = Helper.getValue(inputAmount.getText(), "0");
|
||||
double parsedAmount = Helper.parseDouble(amountString, 0);
|
||||
String text = getResources().getQuantityString(R.plurals.send_lbc_tip, parsedAmount == 1.0 ? 1 : 2, amountString);
|
||||
sendButton.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateInfoText() {
|
||||
View view = getView();
|
||||
if (view != null && switchTip != null) {
|
||||
TextView infoText = view.findViewById(R.id.create_support_info);
|
||||
boolean isTip = switchTip.isChecked();
|
||||
|
||||
infoText.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
if (!isTip) {
|
||||
infoText.setText(HtmlCompat.fromHtml(getString(R.string.support_info), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
} else if (claim != null) {
|
||||
infoText.setText(HtmlCompat.fromHtml(
|
||||
Claim.TYPE_CHANNEL.equalsIgnoreCase(claim.getValueType()) ?
|
||||
getString(R.string.send_tip_info_channel, claim.getTitleOrName()) :
|
||||
getString(R.string.send_tip_info_content, claim.getTitleOrName()),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchChannels() {
|
||||
if (Lbry.ownChannels != null && Lbry.ownChannels.size() > 0) {
|
||||
updateChannelList(Lbry.ownChannels);
|
||||
return;
|
||||
}
|
||||
|
||||
fetchingChannels = true;
|
||||
disableChannelSpinner();
|
||||
ClaimListTask task = new ClaimListTask(Claim.TYPE_CHANNEL, progressLoadingChannels, new ClaimListResultHandler() {
|
||||
@Override
|
||||
public void onSuccess(List<Claim> claims) {
|
||||
Lbry.ownChannels = new ArrayList<>(claims);
|
||||
updateChannelList(Lbry.ownChannels);
|
||||
enableChannelSpinner();
|
||||
fetchingChannels = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
enableChannelSpinner();
|
||||
fetchingChannels = false;
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
private void disableChannelSpinner() {
|
||||
Helper.setViewEnabled(channelSpinner, false);
|
||||
}
|
||||
private void enableChannelSpinner() {
|
||||
Helper.setViewEnabled(channelSpinner, true);
|
||||
}
|
||||
|
||||
private void updateChannelList(List<Claim> channels) {
|
||||
if (channelSpinnerAdapter == null) {
|
||||
Context context = getContext();
|
||||
if (context != null) {
|
||||
channelSpinnerAdapter = new InlineChannelSpinnerAdapter(context, R.layout.spinner_item_channel, new ArrayList<>(channels));
|
||||
channelSpinnerAdapter.addAnonymousPlaceholder();
|
||||
channelSpinnerAdapter.notifyDataSetChanged();
|
||||
}
|
||||
} else {
|
||||
channelSpinnerAdapter.clear();
|
||||
channelSpinnerAdapter.addAll(channels);
|
||||
channelSpinnerAdapter.addAnonymousPlaceholder();
|
||||
channelSpinnerAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
if (channelSpinner != null) {
|
||||
channelSpinner.setAdapter(channelSpinnerAdapter);
|
||||
}
|
||||
|
||||
if (channelSpinnerAdapter != null && channelSpinner != null) {
|
||||
if (channelSpinnerAdapter.getCount() > 1) {
|
||||
channelSpinner.setSelection(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
Context context = getContext();
|
||||
if (context instanceof MainActivity) {
|
||||
((MainActivity) context).addWalletBalanceListener(this);
|
||||
}
|
||||
updateInfoText();
|
||||
fetchChannels();
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
Context context = getContext();
|
||||
if (context instanceof MainActivity) {
|
||||
((MainActivity) context).removeWalletBalanceListener(this);
|
||||
}
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalletBalanceUpdated(WalletBalance walletBalance) {
|
||||
if (walletBalance != null && inlineBalanceValue != null) {
|
||||
inlineBalanceValue.setText(Helper.shortCurrencyFormat(walletBalance.getAvailable().doubleValue()));
|
||||
}
|
||||
}
|
||||
|
||||
private void showError(String message) {
|
||||
Snackbar.make(getView(), message, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).
|
||||
setTextColor(Color.WHITE).
|
||||
show();
|
||||
}
|
||||
|
||||
public interface CreateSupportListener {
|
||||
void onSupportCreated(BigDecimal amount, boolean isTip);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
package io.lbry.browser.dialog;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.flexbox.FlexboxLayoutManager;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.adapter.TagListAdapter;
|
||||
import io.lbry.browser.listener.TagListener;
|
||||
import io.lbry.browser.model.Tag;
|
||||
import io.lbry.browser.tasks.UpdateSuggestedTagsTask;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import io.lbry.browser.utils.Lbry;
|
||||
import lombok.Setter;
|
||||
|
||||
public class CustomizeTagsDialogFragment extends BottomSheetDialogFragment {
|
||||
public static final String TAG = "CustomizeTagsDialog";
|
||||
private static final int SUGGESTED_LIMIT = 8;
|
||||
private String currentFilter;
|
||||
|
||||
private RecyclerView followedTagsList;
|
||||
private RecyclerView suggestedTagsList;
|
||||
private TagListAdapter followedTagsAdapter;
|
||||
private TagListAdapter suggestedTagsAdapter;
|
||||
private View noTagsView;
|
||||
private View noResultsView;
|
||||
@Setter
|
||||
private TagListener listener;
|
||||
|
||||
private void checkNoTags() {
|
||||
Helper.setViewVisibility(noTagsView, followedTagsAdapter == null || followedTagsAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
private void checkNoResults() {
|
||||
Helper.setViewVisibility(noResultsView, suggestedTagsAdapter == null || suggestedTagsAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
public void addTag(Tag tag) {
|
||||
if (followedTagsAdapter.getTags().contains(tag)) {
|
||||
Snackbar.make(getView(), getString(R.string.tag_already_added, tag.getName()), Snackbar.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
tag.setFollowed(true);
|
||||
followedTagsAdapter.addTag(tag);
|
||||
if (suggestedTagsAdapter != null) {
|
||||
suggestedTagsAdapter.removeTag(tag);
|
||||
}
|
||||
updateKnownTags(currentFilter, SUGGESTED_LIMIT, false);
|
||||
if (listener != null) {
|
||||
listener.onTagAdded(tag);
|
||||
}
|
||||
checkNoTags();
|
||||
checkNoResults();
|
||||
}
|
||||
public void removeTag(Tag tag) {
|
||||
tag.setFollowed(false);
|
||||
followedTagsAdapter.removeTag(tag);
|
||||
updateKnownTags(currentFilter, SUGGESTED_LIMIT, false);
|
||||
if (listener != null) {
|
||||
listener.onTagRemoved(tag);
|
||||
}
|
||||
checkNoTags();
|
||||
checkNoResults();
|
||||
}
|
||||
|
||||
public void setFilter(String filter) {
|
||||
currentFilter = filter;
|
||||
updateKnownTags(currentFilter, SUGGESTED_LIMIT, true);
|
||||
}
|
||||
|
||||
public static CustomizeTagsDialogFragment newInstance() {
|
||||
return new CustomizeTagsDialogFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.dialog_customize_tags, container, false);
|
||||
|
||||
noResultsView = view.findViewById(R.id.customize_no_tag_results);
|
||||
noTagsView = view.findViewById(R.id.customize_no_followed_tags);
|
||||
|
||||
followedTagsAdapter = new TagListAdapter(Lbry.followedTags, getContext());
|
||||
followedTagsAdapter.setCustomizeMode(TagListAdapter.CUSTOMIZE_MODE_REMOVE);
|
||||
followedTagsAdapter.setClickListener(customizeTagClickListener);
|
||||
suggestedTagsAdapter = new TagListAdapter(new ArrayList<>(), getContext());
|
||||
suggestedTagsAdapter.setCustomizeMode(TagListAdapter.CUSTOMIZE_MODE_ADD);
|
||||
suggestedTagsAdapter.setClickListener(customizeTagClickListener);
|
||||
|
||||
FlexboxLayoutManager flm1 = new FlexboxLayoutManager(getContext());
|
||||
followedTagsList = view.findViewById(R.id.customize_tags_followed_list);
|
||||
followedTagsList.setLayoutManager(flm1);
|
||||
followedTagsList.setAdapter(followedTagsAdapter);
|
||||
|
||||
FlexboxLayoutManager flm2 = new FlexboxLayoutManager(getContext());
|
||||
suggestedTagsList = view.findViewById(R.id.customize_tags_suggested_list);
|
||||
suggestedTagsList.setLayoutManager(flm2);
|
||||
suggestedTagsList.setAdapter(suggestedTagsAdapter);
|
||||
|
||||
TextInputEditText filterInput = view.findViewById(R.id.customize_tag_filter_input);
|
||||
filterInput.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
String value = Helper.getValue(charSequence);
|
||||
setFilter(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
MaterialButton doneButton = view.findViewById(R.id.customize_done_button);
|
||||
doneButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
checkNoTags();
|
||||
return view;
|
||||
}
|
||||
|
||||
private final TagListAdapter.TagClickListener customizeTagClickListener = new TagListAdapter.TagClickListener() {
|
||||
@Override
|
||||
public void onTagClicked(Tag tag, int customizeMode) {
|
||||
if (customizeMode == TagListAdapter.CUSTOMIZE_MODE_ADD) {
|
||||
addTag(tag);
|
||||
} else if (customizeMode == TagListAdapter.CUSTOMIZE_MODE_REMOVE) {
|
||||
removeTag(tag);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
updateKnownTags(null, SUGGESTED_LIMIT, true);
|
||||
}
|
||||
|
||||
private void updateKnownTags(String filter, int limit, boolean clearPrevious) {
|
||||
UpdateSuggestedTagsTask task = new UpdateSuggestedTagsTask(
|
||||
filter,
|
||||
SUGGESTED_LIMIT,
|
||||
followedTagsAdapter,
|
||||
suggestedTagsAdapter,
|
||||
clearPrevious,
|
||||
false, new UpdateSuggestedTagsTask.KnownTagsHandler() {
|
||||
@Override
|
||||
public void onSuccess(List<Tag> tags) {
|
||||
if (suggestedTagsAdapter == null) {
|
||||
suggestedTagsAdapter = new TagListAdapter(tags, getContext());
|
||||
suggestedTagsAdapter.setCustomizeMode(TagListAdapter.CUSTOMIZE_MODE_ADD);
|
||||
suggestedTagsAdapter.setClickListener(customizeTagClickListener);
|
||||
if (suggestedTagsList != null) {
|
||||
suggestedTagsList.setAdapter(suggestedTagsAdapter);
|
||||
}
|
||||
} else {
|
||||
suggestedTagsAdapter.setTags(tags);
|
||||
}
|
||||
checkNoResults();
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package io.lbry.browser.dialog;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.adapter.SuggestedChannelGridAdapter;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class DiscoverDialogFragment extends BottomSheetDialogFragment {
|
||||
public static final String TAG = "DiscoverDialog";
|
||||
|
||||
@Getter
|
||||
private SuggestedChannelGridAdapter adapter;
|
||||
@Setter
|
||||
private DiscoverDialogListener dialogActionsListener;
|
||||
|
||||
public static DiscoverDialogFragment newInstance() {
|
||||
return new DiscoverDialogFragment();
|
||||
}
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.dialog_discover, container, false);
|
||||
|
||||
RecyclerView grid = view.findViewById(R.id.discover_channel_grid);
|
||||
GridLayoutManager glm = new GridLayoutManager(getContext(), 3);
|
||||
grid.setLayoutManager(glm);
|
||||
grid.setAdapter(adapter);
|
||||
grid.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
GridLayoutManager lm = (GridLayoutManager) recyclerView.getLayoutManager();
|
||||
if (lm != null) {
|
||||
int visibleItemCount = lm.getChildCount();
|
||||
int totalItemCount = lm.getItemCount();
|
||||
int pastVisibleItems = lm.findFirstVisibleItemPosition();
|
||||
if (pastVisibleItems + visibleItemCount >= totalItemCount) {
|
||||
if (dialogActionsListener != null) {
|
||||
dialogActionsListener.onScrollEndReached();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
MaterialButton doneButton = view.findViewById(R.id.discover_done_button);
|
||||
doneButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
public void setAdapter(SuggestedChannelGridAdapter adapter) {
|
||||
this.adapter = adapter;
|
||||
if (getView() != null) {
|
||||
((RecyclerView) getView().findViewById(R.id.discover_channel_grid)).setAdapter(adapter);
|
||||
}
|
||||
}
|
||||
public void setLoading(boolean loading) {
|
||||
if (getView() != null) {
|
||||
getView().findViewById(R.id.discover_loading).setVisibility(loading ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (dialogActionsListener != null) {
|
||||
dialogActionsListener.onResume();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
super.onDismiss(dialog);
|
||||
if (dialogActionsListener != null) {
|
||||
dialogActionsListener.onCancel();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
super.onDismiss(dialog);
|
||||
if (dialogActionsListener != null) {
|
||||
dialogActionsListener.onCancel();
|
||||
}
|
||||
}
|
||||
|
||||
public interface DiscoverDialogListener {
|
||||
void onResume();
|
||||
void onCancel();
|
||||
void onScrollEndReached();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
package io.lbry.browser.dialog;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatSpinner;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.MainActivity;
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.adapter.InlineChannelSpinnerAdapter;
|
||||
import io.lbry.browser.listener.WalletBalanceListener;
|
||||
import io.lbry.browser.model.Claim;
|
||||
import io.lbry.browser.model.WalletBalance;
|
||||
import io.lbry.browser.tasks.claim.ClaimListResultHandler;
|
||||
import io.lbry.browser.tasks.claim.ClaimListTask;
|
||||
import io.lbry.browser.tasks.claim.ClaimResultHandler;
|
||||
import io.lbry.browser.tasks.claim.StreamRepostTask;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import io.lbry.browser.utils.Lbry;
|
||||
import io.lbry.browser.utils.LbryUri;
|
||||
|
||||
public class RepostClaimDialogFragment extends BottomSheetDialogFragment implements WalletBalanceListener {
|
||||
public static final String TAG = "RepostClaimDialog";
|
||||
|
||||
private MaterialButton buttonRepost;
|
||||
private View linkCancel;
|
||||
private TextInputEditText inputDeposit;
|
||||
private View inlineBalanceContainer;
|
||||
private TextView inlineBalanceValue;
|
||||
private ProgressBar repostProgress;
|
||||
private TextView textTitle;
|
||||
|
||||
private AppCompatSpinner channelSpinner;
|
||||
private InlineChannelSpinnerAdapter channelSpinnerAdapter;
|
||||
private TextView textNamePrefix;
|
||||
private EditText inputName;
|
||||
private TextView linkToggleAdvanced;
|
||||
private View advancedContainer;
|
||||
|
||||
private final RepostClaimListener listener;
|
||||
private final Claim claim;
|
||||
|
||||
private RepostClaimDialogFragment(Claim claim, RepostClaimListener listener) {
|
||||
super();
|
||||
this.listener = listener;
|
||||
this.claim = claim;
|
||||
}
|
||||
|
||||
public static RepostClaimDialogFragment newInstance(Claim claim, RepostClaimListener listener) {
|
||||
return new RepostClaimDialogFragment(claim, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.dialog_repost_claim, container, false);
|
||||
|
||||
buttonRepost = view.findViewById(R.id.repost_button);
|
||||
linkCancel = view.findViewById(R.id.repost_cancel_link);
|
||||
inputDeposit = view.findViewById(R.id.repost_input_deposit);
|
||||
inlineBalanceContainer = view.findViewById(R.id.repost_inline_balance_container);
|
||||
inlineBalanceValue = view.findViewById(R.id.repost_inline_balance_value);
|
||||
repostProgress = view.findViewById(R.id.repost_progress);
|
||||
textTitle = view.findViewById(R.id.repost_title);
|
||||
|
||||
channelSpinner = view.findViewById(R.id.repost_channel_spinner);
|
||||
textNamePrefix = view.findViewById(R.id.repost_name_prefix);
|
||||
inputName = view.findViewById(R.id.repost_name_input);
|
||||
linkToggleAdvanced = view.findViewById(R.id.repost_toggle_advanced);
|
||||
advancedContainer = view.findViewById(R.id.repost_advanced_container);
|
||||
|
||||
textTitle.setText(getString(R.string.repost_title, claim.getTitle()));
|
||||
inputName.setText(claim.getName());
|
||||
inputDeposit.setText(R.string.min_deposit);
|
||||
channelSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
|
||||
Object item = adapterView.getItemAtPosition(position);
|
||||
if (item instanceof Claim) {
|
||||
Claim claim = (Claim) item;
|
||||
textNamePrefix.setText(String.format("%s%s/", LbryUri.PROTO_DEFAULT, claim.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> adapterView) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inputDeposit.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View view, boolean hasFocus) {
|
||||
inputDeposit.setHint(hasFocus ? getString(R.string.zero) : "");
|
||||
inlineBalanceContainer.setVisibility(hasFocus ? View.VISIBLE : View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
linkCancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
linkToggleAdvanced.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (advancedContainer.getVisibility() != View.VISIBLE) {
|
||||
advancedContainer.setVisibility(View.VISIBLE);
|
||||
linkToggleAdvanced.setText(R.string.hide_advanced);
|
||||
} else {
|
||||
advancedContainer.setVisibility(View.GONE);
|
||||
linkToggleAdvanced.setText(R.string.show_advanced);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
buttonRepost.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
validateAndRepostClaim();
|
||||
}
|
||||
});
|
||||
|
||||
onWalletBalanceUpdated(Lbry.walletBalance);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
Context context = getContext();
|
||||
if (context instanceof MainActivity) {
|
||||
((MainActivity) context).addWalletBalanceListener(this);
|
||||
}
|
||||
fetchChannels();
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
Context context = getContext();
|
||||
if (context instanceof MainActivity) {
|
||||
((MainActivity) context).removeWalletBalanceListener(this);
|
||||
}
|
||||
inputDeposit.clearFocus();
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
|
||||
private void fetchChannels() {
|
||||
if (Lbry.ownChannels == null || Lbry.ownChannels.size() == 0) {
|
||||
startLoading();
|
||||
ClaimListTask task = new ClaimListTask(Claim.TYPE_CHANNEL, repostProgress, new ClaimListResultHandler() {
|
||||
@Override
|
||||
public void onSuccess(List<Claim> claims) {
|
||||
Lbry.ownChannels = new ArrayList<>(claims);
|
||||
loadChannels(claims);
|
||||
finishLoading();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
// could not fetch channels
|
||||
Context context = getContext();
|
||||
if (context instanceof MainActivity) {
|
||||
((MainActivity) context).showError(error.getMessage());
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} else {
|
||||
loadChannels(Lbry.ownChannels);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadChannels(List<Claim> channels) {
|
||||
if (channelSpinnerAdapter == null) {
|
||||
Context context = getContext();
|
||||
if (context != null) {
|
||||
channelSpinnerAdapter = new InlineChannelSpinnerAdapter(context, R.layout.spinner_item_channel, channels);
|
||||
channelSpinnerAdapter.notifyDataSetChanged();
|
||||
}
|
||||
} else {
|
||||
channelSpinnerAdapter.clear();
|
||||
channelSpinnerAdapter.addAll(channels);
|
||||
channelSpinnerAdapter.notifyDataSetChanged();
|
||||
}
|
||||
if (channelSpinner != null && channelSpinnerAdapter != null) {
|
||||
channelSpinner.setAdapter(channelSpinnerAdapter);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalletBalanceUpdated(WalletBalance walletBalance) {
|
||||
if (walletBalance != null && inlineBalanceValue != null) {
|
||||
inlineBalanceValue.setText(Helper.shortCurrencyFormat(walletBalance.getAvailable().doubleValue()));
|
||||
}
|
||||
}
|
||||
|
||||
private void validateAndRepostClaim() {
|
||||
String name = Helper.getValue(inputName.getText());
|
||||
if (Helper.isNullOrEmpty(name) || !LbryUri.isNameValid(name)) {
|
||||
showError(getString(R.string.repost_name_invalid_characters));
|
||||
return;
|
||||
}
|
||||
|
||||
String depositString = Helper.getValue(inputDeposit.getText());
|
||||
if (Helper.isNullOrEmpty(depositString)) {
|
||||
showError(getString(R.string.invalid_amount));
|
||||
return;
|
||||
}
|
||||
|
||||
BigDecimal bid = new BigDecimal(depositString);
|
||||
if (bid.doubleValue() > Lbry.walletBalance.getAvailable().doubleValue()) {
|
||||
showError(getString(R.string.insufficient_balance));
|
||||
return;
|
||||
}
|
||||
if (bid.doubleValue() < Helper.MIN_DEPOSIT) {
|
||||
String message = getResources().getQuantityString(R.plurals.min_deposit_required, 2, String.valueOf(Helper.MIN_DEPOSIT));
|
||||
showError(message);
|
||||
return;
|
||||
}
|
||||
|
||||
Claim channel = (Claim) channelSpinner.getSelectedItem();
|
||||
if (channel == null) {
|
||||
showError(getString(R.string.please_select_repost_channel));
|
||||
return;
|
||||
}
|
||||
|
||||
StreamRepostTask task = new StreamRepostTask(name, bid, claim.getClaimId(), channel.getClaimId(), repostProgress, new ClaimResultHandler() {
|
||||
@Override
|
||||
public void beforeStart() {
|
||||
startLoading();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Claim claimResult) {
|
||||
if (listener != null) {
|
||||
listener.onClaimReposted(claimResult);
|
||||
}
|
||||
finishLoading();
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
showError(error.getMessage());
|
||||
finishLoading();
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
private void showError(String message) {
|
||||
View view = getView();
|
||||
if (view != null && !Helper.isNullOrEmpty(message)) {
|
||||
Snackbar.make(view, message, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).
|
||||
setTextColor(Color.WHITE).
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
||||
private void startLoading() {
|
||||
Dialog dialog = getDialog();
|
||||
if (dialog != null) {
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
}
|
||||
linkCancel.setEnabled(false);
|
||||
buttonRepost.setEnabled(false);
|
||||
inputName.setEnabled(false);
|
||||
channelSpinner.setEnabled(false);
|
||||
linkToggleAdvanced.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
private void finishLoading() {
|
||||
Dialog dialog = getDialog();
|
||||
if (dialog != null) {
|
||||
dialog.setCanceledOnTouchOutside(true);
|
||||
}
|
||||
linkCancel.setEnabled(true);
|
||||
buttonRepost.setEnabled(true);
|
||||
inputName.setEnabled(true);
|
||||
channelSpinner.setEnabled(true);
|
||||
linkToggleAdvanced.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public interface RepostClaimListener {
|
||||
void onClaimReposted(Claim claim);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package io.lbry.browser.exceptions;
|
||||
|
||||
public class ApiCallException extends Exception {
|
||||
public ApiCallException() {
|
||||
super();
|
||||
}
|
||||
public ApiCallException(String message) {
|
||||
super(message);
|
||||
}
|
||||
public ApiCallException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package io.lbry.browser.exceptions;
|
||||
|
||||
public class AuthTokenInvalidatedException extends Exception {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package io.lbry.browser.exceptions;
|
||||
|
||||
public class LbryRequestException extends Exception {
|
||||
public LbryRequestException() {
|
||||
super();
|
||||
}
|
||||
public LbryRequestException(String message) {
|
||||
super(message);
|
||||
}
|
||||
public LbryRequestException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package io.lbry.browser.exceptions;
|
||||
|
||||
public class LbryResponseException extends Exception {
|
||||
public LbryResponseException() {
|
||||
super();
|
||||
}
|
||||
public LbryResponseException(String message) {
|
||||
super(message);
|
||||
}
|
||||
public LbryResponseException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package io.lbry.browser.exceptions;
|
||||
|
||||
public class LbryUriException extends Exception {
|
||||
public LbryUriException() {
|
||||
super();
|
||||
}
|
||||
public LbryUriException(String message) {
|
||||
super(message);
|
||||
}
|
||||
public LbryUriException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package io.lbry.browser.exceptions;
|
||||
|
||||
public class LbryioRequestException extends Exception {
|
||||
public LbryioRequestException() {
|
||||
super();
|
||||
}
|
||||
public LbryioRequestException(String message) {
|
||||
super(message);
|
||||
}
|
||||
public LbryioRequestException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package io.lbry.browser.exceptions;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class LbryioResponseException extends Exception {
|
||||
@Getter
|
||||
private int statusCode;
|
||||
public LbryioResponseException() {
|
||||
super();
|
||||
}
|
||||
public LbryioResponseException(String message) {
|
||||
super(message);
|
||||
}
|
||||
public LbryioResponseException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
public LbryioResponseException(String message, int statusCode) {
|
||||
super(message);
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
public LbryioResponseException(String message, Throwable cause, int statusCode) {
|
||||
super(message, cause);
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package io.lbry.browser.exceptions;
|
||||
|
||||
public class WalletException extends Exception {
|
||||
public WalletException() {
|
||||
super();
|
||||
}
|
||||
public WalletException(String message) {
|
||||
super(message);
|
||||
}
|
||||
public WalletException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package io.lbry.browser.listener;
|
||||
|
||||
public interface CameraPermissionListener {
|
||||
void onCameraPermissionGranted();
|
||||
void onCameraPermissionRefused();
|
||||
void onRecordAudioPermissionGranted();
|
||||
void onRecordAudioPermissionRefused();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package io.lbry.browser.listener;
|
||||
|
||||
import io.lbry.browser.model.Claim;
|
||||
|
||||
public interface ChannelItemSelectionListener {
|
||||
void onChannelItemSelected(Claim claim);
|
||||
void onChannelItemDeselected(Claim claim);
|
||||
void onChannelSelectionCleared();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package io.lbry.browser.listener;
|
||||
|
||||
public interface DownloadActionListener {
|
||||
void onDownloadAction(String downloadAction, String uri, String outpoint, String fileInfoJson, double progress);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package io.lbry.browser.listener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.model.Claim;
|
||||
|
||||
public interface FetchChannelsListener {
|
||||
void onChannelsFetched(List<Claim> channels);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package io.lbry.browser.listener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.model.Claim;
|
||||
|
||||
public interface FetchClaimsListener {
|
||||
void onClaimsFetched(List<Claim> claims);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package io.lbry.browser.listener;
|
||||
|
||||
public interface FilePickerListener {
|
||||
void onFilePicked(String filePath);
|
||||
void onFilePickerCancelled();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package io.lbry.browser.listener;
|
||||
|
||||
public interface PIPModeListener {
|
||||
void onEnterPIPMode();
|
||||
void onExitPIPMode();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package io.lbry.browser.listener;
|
||||
|
||||
public interface ScreenOrientationListener {
|
||||
void onPortraitOrientationEntered();
|
||||
void onLandscapeOrientationEntered();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package io.lbry.browser.listener;
|
||||
|
||||
public interface SdkStatusListener {
|
||||
void onSdkReady();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package io.lbry.browser.listener;
|
||||
|
||||
public interface SelectionModeListener {
|
||||
void onEnterSelectionMode();
|
||||
void onExitSelectionMode();
|
||||
void onItemSelectionToggled();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package io.lbry.browser.listener;
|
||||
|
||||
public interface SignInListener {
|
||||
void onEmailAdded(String email);
|
||||
void onEmailEdit();
|
||||
void onEmailVerified();
|
||||
void onPhoneAdded(String countryCode, String phoneNumber);
|
||||
void onPhoneVerified();
|
||||
void onManualVerifyContinue();
|
||||
void onSkipQueueAction();
|
||||
void onTwitterVerified();
|
||||
void onManualProgress(boolean progress);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package io.lbry.browser.listener;
|
||||
|
||||
public interface StoragePermissionListener {
|
||||
void onStoragePermissionGranted();
|
||||
void onStoragePermissionRefused();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package io.lbry.browser.listener;
|
||||
|
||||
import io.lbry.browser.model.Tag;
|
||||
|
||||
public interface TagListener {
|
||||
void onTagAdded(Tag tag);
|
||||
void onTagRemoved(Tag tag);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package io.lbry.browser.listener;
|
||||
|
||||
import io.lbry.browser.model.WalletBalance;
|
||||
|
||||
public interface WalletBalanceListener {
|
||||
void onWalletBalanceUpdated(WalletBalance walletBalance);
|
||||
}
|
||||
Loaded 100 of 1247 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user