Compare commits
1330 Commits
v5.29.0-93
...
feat/sync-
| Author | SHA1 | Date | |
|---|---|---|---|
| bd02a0b4be | |||
| 7a498763bb | |||
| 8b839a5b13 | |||
| 7d2ed0eac0 | |||
| 5c70bc2237 | |||
| 03b36096b8 | |||
| 4191dbc4f0 | |||
| cc20b6e38a | |||
| 3ad5890238 | |||
| 6179d7055b | |||
| f18391adc2 | |||
| 3a2f15a436 | |||
| c0e8160955 | |||
| 9038131c96 | |||
| 4430ae1107 | |||
| d6aa2690b2 | |||
| e42fd24b71 | |||
| 452a1ede24 | |||
| ceb227f645 | |||
| 479ea5778b | |||
| 8969d6fd5d | |||
| cc43f2e0fd | |||
| ab12491f2f | |||
| ae24ab0c87 | |||
| 383712900c | |||
| cea62b55e2 | |||
| ff6cdb1ba3 | |||
| b6e531fa96 | |||
| e7a37df690 | |||
| 5308ccfabe | |||
| 2ee49b9a20 | |||
| 3af3d413c0 | |||
| 9bf24977ca | |||
| bf1dd958cd | |||
| 30c34b799b | |||
| b202b580bb | |||
| 239b056abb | |||
| 315be3797c | |||
| 6d29da5172 | |||
| 8aeb0d6f09 | |||
| bdcca58770 | |||
| 4115383b68 | |||
| 9075bfa214 | |||
| 3fa63e331b | |||
| aef19fcd49 | |||
| 15d7252974 | |||
| f6fa060f3a | |||
| 7cfe48b3c8 | |||
| 6bd3c1011d | |||
| 3447ecffd8 | |||
| 644b93ab02 | |||
| 6b44140ff3 | |||
| 78d26b4cc1 | |||
| 5565539445 | |||
| 1ee0f292ba | |||
| f609637f0b | |||
| 9d10add8eb | |||
| f5a39f982e | |||
| 1a063bb0c1 | |||
| 86340d603f | |||
| 0731cc1fde | |||
| 86dfee2ff9 | |||
| edf82952ce | |||
| 062f0149d0 | |||
| a504f00bac | |||
| 4412d159bb | |||
| e119b7fecd | |||
| 72460b88be | |||
| 3fe7c8252e | |||
| 36ebab77ee | |||
| e84db01984 | |||
| ae605d4a55 | |||
| 882bf4b551 | |||
| 968164af55 | |||
| 0119e6f123 | |||
| 30135bdb8f | |||
| f8ac85d29c | |||
| 7093552259 | |||
| 2be52d21ee | |||
| cb093cc3f0 | |||
| 3cbdd94189 | |||
| 11013319bf | |||
| aa954b3af9 | |||
| 93f279a384 | |||
| 4e54833cc9 | |||
| f95862da8b | |||
| 1515df34b5 | |||
| 8a8ef40dc1 | |||
| b6194fed26 | |||
| 02752f6c81 | |||
| b33d367dfd | |||
| d5046ab431 | |||
| a53168c9bc | |||
| 3cbc8c2f74 | |||
| 7398b83004 | |||
| 8013426ded | |||
| b86d85b15f | |||
| 5a73afbab3 | |||
| e19ee25839 | |||
| 61bf39e95f | |||
| ef82ae2378 | |||
| 2dcccc22a8 | |||
| cb0e77d204 | |||
| a6ea178609 | |||
| 6a62f08891 | |||
| ddb48481d2 | |||
| 48a55a6b31 | |||
| 50fcb0c3ea | |||
| e97722b6fb | |||
| 2163b2ff9e | |||
| b9558e2732 | |||
| 39bba71e7a | |||
| 5daddeadda | |||
| 58b1c0295c | |||
| a56082d002 | |||
| 877ab7cf39 | |||
| 428e3496d8 | |||
| b33419ea05 | |||
| e9bcd0a0d6 | |||
| 98b877671a | |||
| 6c61a62799 | |||
| 391e409ee1 | |||
| cfd1ee845a | |||
| 34b123a0a7 | |||
| 51515171a8 | |||
| e9139c66e1 | |||
| 24941a165a | |||
| 9d661eefa7 | |||
| 373fa7fc80 | |||
| d9743a89d6 | |||
| 0f596836dc | |||
| eb08575f3e | |||
| 405268bbce | |||
| 2453e34a74 | |||
| 2830367826 | |||
| 782d94289f | |||
| 3e2c2fe18f | |||
| 1afd154364 | |||
| b24cac0cb1 | |||
| d5db516112 | |||
| b2a7a606e5 | |||
| 219866e195 | |||
| dea7ceb5f6 | |||
| da1da1c1af | |||
| 9b4fa45492 | |||
| 01df42b76b | |||
| cef8aa1968 | |||
| 4147612d9b | |||
| 9b57d10e2d | |||
| 19f4e70ada | |||
| 49b7e4c245 | |||
| 638de59562 | |||
| 69b092be46 | |||
| 27d1d02d58 | |||
| e4bfa5e6bf | |||
| 3ea3238011 | |||
| 2dcae2168b | |||
| 4b1c198818 | |||
| e42e2fbd56 | |||
| 713e4157db | |||
| 76cf7dce1d | |||
| f492d2ea97 | |||
| 37a3689a2c | |||
| 7429f17538 | |||
| 32ba015686 | |||
| e5365fd527 | |||
| 1c873d0194 | |||
| 1424ee2b45 | |||
| 69cb916364 | |||
| 04f1d712cd | |||
| ee14ae51be | |||
| 4683217e44 | |||
| df94d6677a | |||
| 6f85e12edf | |||
| 020c826f1d | |||
| 5640d778a2 | |||
| 2300475a9e | |||
| 612b4061d5 | |||
| 49c7ff8f8e | |||
| 1c408f3966 | |||
| 055f5b23da | |||
| 9810b3e8fe | |||
| dba7042b12 | |||
| 6695dc596e | |||
| 079ba014f8 | |||
| 46955685bb | |||
| 14eeb00539 | |||
| 56843f18d4 | |||
| 53a46892a4 | |||
| a2153761c2 | |||
| 26a8c0abd8 | |||
| 21bf0fd8e9 | |||
| 9787d23ea0 | |||
| 6ae34b81db | |||
| 0b1e770c03 | |||
| f4681dab31 | |||
| 79a7f994eb | |||
| 3276fca27c | |||
| 372db8e52c | |||
| 9b6d986f1c | |||
| 0e88db1600 | |||
| 05b59c8732 | |||
| 28f68cae95 | |||
| 22713db44e | |||
| d9389ac4aa | |||
| 31ec9311fc | |||
| fca62df263 | |||
| 978c01d7dc | |||
| b7a24e331a | |||
| b1eac6a043 | |||
| 9f8a712be6 | |||
| 930ab904ed | |||
| 3c207244e6 | |||
| 0f59e03afa | |||
| c5d99fa304 | |||
| a313cd8050 | |||
| ce477e2bd0 | |||
| 7cf2adaa37 | |||
| 0852497df2 | |||
| 592df6ea44 | |||
| 7b5d1b1bf3 | |||
| 5b1a614eb7 | |||
| ae9fbfb8c4 | |||
| 48b118d342 | |||
| 39625369d7 | |||
| 05b9920f6d | |||
| 8a5fa2c31a | |||
| c2dc6d7dbe | |||
| a027442ae6 | |||
| ba1584f642 | |||
| 4124d571b7 | |||
| a545401ca3 | |||
| 4b7f2401dd | |||
| daa1e4fc64 | |||
| 064135a057 | |||
| b56946d6f0 | |||
| 1a46d371e4 | |||
| d2a062907a | |||
| 56e945eb43 | |||
| 91579194a4 | |||
| c42a7d5963 | |||
| d2293bd881 | |||
| db4eb9f811 | |||
| 24d95b8e95 | |||
| 435dac11a1 | |||
| bffa2dab7f | |||
| 136975c067 | |||
| f389fcc206 | |||
| 9c5ef246a4 | |||
| 5f71f52fe1 | |||
| 2bfa0c1031 | |||
| 97c9dd9923 | |||
| cc3733e6fe | |||
| cacdc13b9a | |||
| ab3ebd7b37 | |||
| 08879b63da | |||
| ca8d41bac2 | |||
| 31c54b8f3b | |||
| 038da5dae2 | |||
| 3bcf332dfa | |||
| ee7723a4d8 | |||
| aed68e3268 | |||
| 6902e748e4 | |||
| fa9186cb54 | |||
| 119a684112 | |||
| 72d8016c4b | |||
| 6569eecbb1 | |||
| 83cb925be2 | |||
| a98b54269a | |||
| 570cf800e5 | |||
| 83ec4414f9 | |||
| 004bd3421a | |||
| f365a80a84 | |||
| ff078ab2a1 | |||
| 0ba49550b3 | |||
| 251e867833 | |||
| ca20d7e2a3 | |||
| 8fb4b373d3 | |||
| 58fa40fe08 | |||
| cd4f2783b5 | |||
| 4ee735b8cd | |||
| 605b886315 | |||
| 54eb44d072 | |||
| 5866b0d28a | |||
| 9f47f30f38 | |||
| dcb3fa3910 | |||
| 12bbd008d8 | |||
| 49b35b2837 | |||
| 1269560541 | |||
| a788b7b485 | |||
| f47a2db92b | |||
| aa41551c4e | |||
| 813634379a | |||
| e884e9b45a | |||
| e86a301d10 | |||
| 89bdafe7ed | |||
| 8dc4b86790 | |||
| 989d1578ef | |||
| ba3b86a00e | |||
| 2a279762e1 | |||
| 574ae0eece | |||
| 9412c255eb | |||
| c2c6901b04 | |||
| e8cca4b491 | |||
| b4e2685f19 | |||
| 8f9c5fac95 | |||
| e28a4a8fed | |||
| 45b4d1214e | |||
| a7dc78b969 | |||
| 11a0d55d12 | |||
| 398ff16f76 | |||
| 5d7056735a | |||
| 3bd0444dde | |||
| 4d2d3d24ee | |||
| 7310056d2e | |||
| 5cf8b80ea4 | |||
| bf5b7ced89 | |||
| b1e44ea89b | |||
| 1f5b9bde3e | |||
| c57063bcfe | |||
| 5fd7d0bb62 | |||
| a45d6ce0b4 | |||
| dcff648d37 | |||
| 513938da99 | |||
| 6490111940 | |||
| 56437855d8 | |||
| 29facb49df | |||
| f023a315b9 | |||
| b9d217d773 | |||
| cbdab7cd50 | |||
| 5b2f710be8 | |||
| b15dafb852 | |||
| 37b36a9632 | |||
| 17495e3699 | |||
| d9ee277e82 | |||
| bb6bdb1351 | |||
| 204300ca98 | |||
| 24815cd398 | |||
| b963281eb6 | |||
| 95721268f7 | |||
| dfd542f5df | |||
| 14522e5d07 | |||
| 71efe3b69a | |||
| b8cbbc0301 | |||
| 2fe8051280 | |||
| 0d4a893552 | |||
| e07216365a | |||
| 1c04e966d9 | |||
| ba0ad10f61 | |||
| 9592731033 | |||
| 0dc9fb1aa3 | |||
| fd450f0d67 | |||
| 57984d160f | |||
| 165ca21926 | |||
| e19c091532 | |||
| 5db6b3511f | |||
| 8557b230ac | |||
| 44a817be12 | |||
| c76e0b8bfa | |||
| bbbd77b8ab | |||
| 08ab5ec727 | |||
| 39afbecce8 | |||
| 4229f0e335 | |||
| efae6cb459 | |||
| 8f8cfb757f | |||
| 1e894e1158 | |||
| 96b479b8f0 | |||
| 342eefe7ba | |||
| e9c9f6f66b | |||
| 7da90ffb0b | |||
| c71f8676dd | |||
| 50555cb217 | |||
| 766e4fc3ab | |||
| c091e496e7 | |||
| ecd81ea353 | |||
| 21e7198589 | |||
| d6c97bc215 | |||
| 321e9b6ee6 | |||
| 7cc3e7ec67 | |||
| 08dac2eb42 | |||
| 85c7746206 | |||
| a35700e2f7 | |||
| 6a44294338 | |||
| b8c275d8fc | |||
| 638bf86d1e | |||
| 158c46f210 | |||
| a28ef7d20b | |||
| bae20a4e7d | |||
| 4a2f0896bb | |||
| 51ccc532d5 | |||
| 1bf977f3e4 | |||
| da2aeeeaf2 | |||
| 52d160a0e0 | |||
| cbba9c09b5 | |||
| 3c877ada98 | |||
| 9b95e01d33 | |||
| 567576fc04 | |||
| 1b7913a00e | |||
| 05e2719e1c | |||
| 8ed10c411a | |||
| f9f4bb84b4 | |||
| 44a2e616ab | |||
| fffd3ef789 | |||
| d53782b8de | |||
| b16c5d723b | |||
| 1dfd636283 | |||
| 65feed01f4 | |||
| 2a596bd2a0 | |||
| 16c4f1016c | |||
| 1ced82c1f6 | |||
| 078c9204af | |||
| 68818b3409 | |||
| 7d4aa34d12 | |||
| 209c3d7d30 | |||
| 2a27e0f467 | |||
| 54ee8a9c69 | |||
| 2b44efd6b3 | |||
| d62c8beb30 | |||
| 155ec08280 | |||
| d46aa81dbe | |||
| 51c0bf27cf | |||
| 43eb4c88c9 | |||
| 06b2d2b416 | |||
| af7580a6a6 | |||
| 1e4375ec8a | |||
| 195247a5c3 | |||
| dd65bc8bc2 | |||
| 196e719358 | |||
| b1c267b179 | |||
| a2679c8dbd | |||
| c9e1816be0 | |||
| a1f0455d5a | |||
| 5b3f4b6104 | |||
| fe4e9d9d3b | |||
| dd051b4d13 | |||
| e7f756555c | |||
| 9488837e9e | |||
| b8c4f1403b | |||
| b88698c2a3 | |||
| c897d5ad0f | |||
| 037f453a75 | |||
| ad3a3c1341 | |||
| ba320f7740 | |||
| f3dbc0b779 | |||
| 0c518ac40e | |||
| ccc0140bba | |||
| bf57118900 | |||
| b80a14f2b1 | |||
| 2c044d0ee4 | |||
| 1450064640 | |||
| 90e19d5099 | |||
| 383124dc36 | |||
| 6d6ce2613a | |||
| 8569264b82 | |||
| 59667abf09 | |||
| 5201637326 | |||
| 417c41c8a0 | |||
| b651ef8617 | |||
| af67894d4e | |||
| 76e17eddd7 | |||
| f8c9c41eb0 | |||
| 40ac173389 | |||
| c6bc7ca6cc | |||
| f01e08aec9 | |||
| faddf5d7b6 | |||
| 81cf2f0ddc | |||
| 198561d15a | |||
| 1e721b699c | |||
| 8f48dfd347 | |||
| bc811a2882 | |||
| bdccbc4c28 | |||
| bfd986fdfd | |||
| a2bd5e01e0 | |||
| 844d227f19 | |||
| 8b1f92e9c4 | |||
| f5834d440b | |||
| f982bf6478 | |||
| 33d7afec71 | |||
| 37ef50f323 | |||
| 4c6acdee3a | |||
| 6beb060e63 | |||
| a552677e41 | |||
| bb148f42b8 | |||
| 065aa96e18 | |||
| d9a90ca80b | |||
| 2aeffb1cc4 | |||
| d3188cc3cd | |||
| 1d7f902a81 | |||
| 13a40806e4 | |||
| b56e5c4022 | |||
| acca1537da | |||
| 6e5b639d58 | |||
| 24000f55af | |||
| d11ccba0b7 | |||
| 3540c4626d | |||
| e6a2758fdb | |||
| a56e2bd16e | |||
| e038c565ff | |||
| ec5905bb11 | |||
| 21f50c4eed | |||
| 5a93f3671b | |||
| 6dcb8b6efe | |||
| d60916b3bc | |||
| 798b19d9d7 | |||
| 5c47d3cda8 | |||
| aea64c0602 | |||
| 4abc0a3edb | |||
| ded940412e | |||
| 9971651fe1 | |||
| 4e00b5db19 | |||
| e6a6bbcf97 | |||
| 0eecc4699f | |||
| c771bad1ea | |||
| e5dbdb154f | |||
| 2b91545d34 | |||
| f8703b9fe1 | |||
| 58cc8c7f3c | |||
| 79cf1566b2 | |||
| 47a98f22b5 | |||
| 71453054d9 | |||
| 61ae86e40a | |||
| 89de5f24bf | |||
| 5c8a275b3e | |||
| 405fd6c698 | |||
| d70c8f2b78 | |||
| 2700b309dd | |||
| 832509a124 | |||
| 36e69ece10 | |||
| 7d56f92535 | |||
| 9fe58a72c7 | |||
| 4c79c49506 | |||
| c4a622a55c | |||
| 3a02823ea9 | |||
| 7d816c00c4 | |||
| 1214a6fb13 | |||
| e90053bdc9 | |||
| de9980af6a | |||
| ec6ad35ade | |||
| c199487c51 | |||
| a1ac427540 | |||
| 1e2755c82c | |||
| a05e31705f | |||
| 62f2bb40df | |||
| eabb277c7b | |||
| fb7cdd5ce7 | |||
| 3bbfd676fb | |||
| 7be6af5f08 | |||
| 982f5faf97 | |||
| 81c8469e7b | |||
| 2e03e9f4f5 | |||
| 6ab10a0eee | |||
| 23f7d1f32c | |||
| 93f5343106 | |||
| 6846a61dd5 | |||
| 1a99fec286 | |||
| 3d77c1ed3a | |||
| c312d616da | |||
| 8f1affeb74 | |||
| fdbfdecb2d | |||
| e84b814d2c | |||
| 14c8591a99 | |||
| 95d073a50d | |||
| edec43aea2 | |||
| 188b5bdd7f | |||
| c454b092b2 | |||
| c70b1c962b | |||
| e71b2b0a56 | |||
| c010b7aba4 | |||
| 2c23c4f0eb | |||
| 2c2031f623 | |||
| 41ddf53e23 | |||
| b911edb83c | |||
| 7524144c3d | |||
| aef5bb0021 | |||
| 1e45790280 | |||
| 6ebae66fc7 | |||
| 907f840537 | |||
| 07dfd58538 | |||
| 4491865aef | |||
| 9dabe9fa03 | |||
| 79349d51ee | |||
| a3319b71d2 | |||
| b06341959d | |||
| 089e552e0f | |||
| 16e0da0c7c | |||
| e1a9879ea4 | |||
| b610e1619d | |||
| 6977e99269 | |||
| 18246edd46 | |||
| b7cadbce50 | |||
| 44569233e9 | |||
| d1962cf363 | |||
| dbf35afa3f | |||
| 1dcdb81529 | |||
| fb9d0d01d8 | |||
| f449a41257 | |||
| ef41245a1a | |||
| c2aae6d5f9 | |||
| 700a56c6f9 | |||
| 6673805ba1 | |||
| 6130fa345b | |||
| 38a9bf0bfa | |||
| bdb2180af6 | |||
| a4b8feb7ef | |||
| 6c58b3b102 | |||
| 28014190f3 | |||
| 76843829aa | |||
| ef3a243bc5 | |||
| 796848a23c | |||
| fc8766f2e7 | |||
| 278423cfad | |||
| 8e2f06c19b | |||
| bf4f270c37 | |||
| d406cba6c2 | |||
| 6c4d17ab9e | |||
| 8fc9134402 | |||
| babb7d3f7b | |||
| 0972e90049 | |||
| df2382609a | |||
| b61fdd0a0e | |||
| 0662ecd86b | |||
| 3c6920520e | |||
| 03bbcc2af3 | |||
| 5efd61d5f6 | |||
| 737e14a6ce | |||
| 68931b5d9c | |||
| dac1f207f2 | |||
| dd48585bca | |||
| b4a8c07d8a | |||
| 7a417bc655 | |||
| 920e7a8038 | |||
| 6efb8ee700 | |||
| 1d58dcc998 | |||
| 5647b9c0b0 | |||
| ba0eb38ee8 | |||
| 3406addd87 | |||
| 52f7120157 | |||
| ee742213e6 | |||
| 3816ce44a5 | |||
| 37c6c7bb26 | |||
| a0bc96fa2b | |||
| 5375901813 | |||
| 816c37ed6f | |||
| a3c603490d | |||
| 2e18460f22 | |||
| 6482bb31e9 | |||
| 1822177e2c | |||
| 3af3d4255f | |||
| a58498741b | |||
| c01c9af191 | |||
| 463ac5fc77 | |||
| 3bd4823463 | |||
| 240666aa5f | |||
| 77bbf5c647 | |||
| 873178c10d | |||
| 478385a5e0 | |||
| d5b2f586fa | |||
| 3e91968c7d | |||
| 868adca99a | |||
| 4703c94f4b | |||
| 9246f46d82 | |||
| 8209c97b6c | |||
| fabd160a72 | |||
| 685102c0da | |||
| e999fd33f7 | |||
| f8f77b1f4d | |||
| 0ca5211caf | |||
| 2e2fe556cd | |||
| 4734bad08a | |||
| bd4eb76ad1 | |||
| c8883bd1cc | |||
| c658df314f | |||
| 97a93dfa36 | |||
| b8fced4237 | |||
| b5d76cafe1 | |||
| 98fb4b381a | |||
| 1afed0d6db | |||
| 5c872b282c | |||
| 12be13d267 | |||
| 83f50bb42c | |||
| 61e73ad932 | |||
| e811538bbd | |||
| 818dec8428 | |||
| b79ada682f | |||
| 78330c1d12 | |||
| ff6e73cdb1 | |||
| 4be928b015 | |||
| 3124082175 | |||
| a28451a976 | |||
| ec70e2c47e | |||
| 68d546c7ca | |||
| 365aa5d8da | |||
| c842a9a184 | |||
| 6093b662a1 | |||
| 85d8638178 | |||
| ff434a0e51 | |||
| 93ec29884b | |||
| f7bb617edb | |||
| 1b5567f470 | |||
| d1628b3377 | |||
| 509d6f4ac6 | |||
| 5f9257a103 | |||
| d50bea5f62 | |||
| e138890f4d | |||
| 96734e3ead | |||
| 7a596f49ca | |||
| 564e5cbb8c | |||
| 25d7f2731a | |||
| 36c164da26 | |||
| 4996d62252 | |||
| 20bab0fc84 | |||
| 74f6f3467b | |||
| af4647dc37 | |||
| e2306124b2 | |||
| 00cd4c1f1f | |||
| 4ace4b8056 | |||
| bffdc42eac | |||
| 0d6aa9f11d | |||
| 357c48ab08 | |||
| f1d3705f80 | |||
| 699679289b | |||
| f8dc122c41 | |||
| 0a56189ae8 | |||
| e079116d80 | |||
| d661a91c2f | |||
| 3ff5b04893 | |||
| 9c8bc7742c | |||
| 4c01859683 | |||
| 794a681f07 | |||
| 9778cf439b | |||
| a66f62bcb7 | |||
| 0935a75ec0 | |||
| 0a221c07bf | |||
| 011ff1e24a | |||
| 9cd8b5d8d5 | |||
| 1eb77e8bd2 | |||
| 650dd2e2ad | |||
| 563955940d | |||
| 376996540d | |||
| 1292446bd0 | |||
| 427ce5bc38 | |||
| e7897f9b18 | |||
| 55ece981b5 | |||
| 7f68b165cb | |||
| bf46229bcd | |||
| ce80f133a0 | |||
| e5ea731946 | |||
| 24d7f60426 | |||
| 3a0205789a | |||
| f86edd196f | |||
| 898278b3d9 | |||
| fd757a346c | |||
| ed32da8882 | |||
| d7e88ba38a | |||
| af0ba215dd | |||
| 8e7a168495 | |||
| 913bf7ad2f | |||
| 4d84af6ff9 | |||
| 1acfe4227f | |||
| 847def3d30 | |||
| f523e984c8 | |||
| 5fe39d69de | |||
| 0c76783397 | |||
| e4b5a6ef5a | |||
| f03a9677cc | |||
| c4b519204b | |||
| 423bcda7ff | |||
| 2bb61e8e4b | |||
| 84d8de881e | |||
| 3809d6d887 | |||
| 96c18ec7a6 | |||
| d052ef5923 | |||
| 993631c853 | |||
| 3a9958fa7d | |||
| bb51391b61 | |||
| 57f1cb7e59 | |||
| b4cd90a7e9 | |||
| 6ec9d2076f | |||
| 22c727cd2f | |||
| 5e5aee539e | |||
| c158225472 | |||
| ac5b7837db | |||
| 05a113de40 | |||
| d45d02bfd2 | |||
| 395433f21f | |||
| ccbd70666a | |||
| aaa8eda004 | |||
| 748497e5b1 | |||
| 1cf49b931e | |||
| e4a9d533d4 | |||
| 36e9bd20ac | |||
| cc4ef16e10 | |||
| 6a446a6f3a | |||
| 233e0ec71d | |||
| d6e1a90472 | |||
| 0911cd146b | |||
| 8e255b1803 | |||
| 14939625dd | |||
| 19afb7221d | |||
| ae0f4c948b | |||
| d650739632 | |||
| 6f6a734cb5 | |||
| e510146775 | |||
| 8b863955a3 | |||
| 37155b96dd | |||
| e55d4d3332 | |||
| 3e38830480 | |||
| dabf532ae7 | |||
| 7aa2b20224 | |||
| 10572e7b0b | |||
| 3912729fff | |||
| 78ff8dcb0a | |||
| 80e7ad9401 | |||
| 0c807922d6 | |||
| d7f5b573c6 | |||
| f9d624b077 | |||
| a22fa59975 | |||
| e68ad6489a | |||
| ccd3a98799 | |||
| 96026ef9fa | |||
| a9ba7d056b | |||
| da4e83d29d | |||
| 777e05733c | |||
| cc9c390bbb | |||
| d96ae0cdbb | |||
| c8a1bd5278 | |||
| aa0d36a3ba | |||
| ffe1c0606a | |||
| 7f73b728a5 | |||
| 5cfb7f5036 | |||
| 399e513174 | |||
| cbf6f34a9c | |||
| 23c0f12ed3 | |||
| da91dcab59 | |||
| ee846bc620 | |||
| aa3db9330e | |||
| 2393dc2291 | |||
| cb94bc9f29 | |||
| a60442db41 | |||
| 1eeb34c93a | |||
| d18f3909ea | |||
| c23118e535 | |||
| 4d4498cdee | |||
| a348b80eaf | |||
| 9691344e67 | |||
| 64bdbbf409 | |||
| 984bb60e6a | |||
| 41ba8c3e5a | |||
| b203d3a756 | |||
| 1461af16b9 | |||
| 14fca95ed6 | |||
| c3926c85d8 | |||
| 9b73272019 | |||
| 28bca22d93 | |||
| 905571a637 | |||
| 5757df01e7 | |||
| 3f60f85992 | |||
| dc9ac67e6e | |||
| 8c1d4a3778 | |||
| 7189261c01 | |||
| 86c1781426 | |||
| 4812e9258b | |||
| b906fe7b47 | |||
| 846fd7222e | |||
| 1afabdfd94 | |||
| 8ed2a13884 | |||
| 52980189ed | |||
| 852f7734ef | |||
| a25503113b | |||
| 0d6b62b361 | |||
| e3b8ea74c1 | |||
| bf10d5aa42 | |||
| cd13c98ac2 | |||
| 2c49b468e6 | |||
| d175e895c3 | |||
| 1c0af1be7d | |||
| 62f5a479c9 | |||
| a87011d5b0 | |||
| c6c2213a88 | |||
| 9ede98deea | |||
| e46ec7c416 | |||
| d49c6bc3ca | |||
| 2bba43cf26 | |||
| 3efcd71046 | |||
| 19f54bb8d2 | |||
| ce99eef958 | |||
| a167e7ff58 | |||
| ddd9032dbf | |||
| 1062522388 | |||
| b631c3437c | |||
| 5de5b005bf | |||
| 7d99db505b | |||
| 3b3e2e572e | |||
| 4f1ccac6fc | |||
| 41c8d4950f | |||
| d633d9b37b | |||
| 23ec072ac5 | |||
| 3f3fd1ad5f | |||
| 3022118445 | |||
| edf56c92d5 | |||
| 56eb40740a | |||
| d697bc7b8a | |||
| 95beddc194 | |||
| 5e3e4a88f5 | |||
| ad6bf59297 | |||
| 42e009b91d | |||
| 75dabfef6b | |||
| e51e976385 | |||
| 28b9e14487 | |||
| 5ee1e823c5 | |||
| 11eee2eb0a | |||
| 42fa273d06 | |||
| 69dcd407b1 | |||
| 66722a313f | |||
| 81b0404999 | |||
| 79dadfeae6 | |||
| 601733f257 | |||
| 48a6bd0d2e | |||
| dfb89980fe | |||
| e7d4c598a3 | |||
| fe2d0e6a34 | |||
| 1cbfbeb118 | |||
| d845ceb31a | |||
| c080049322 | |||
| d6d0bea491 | |||
| 820e29db23 | |||
| 1f05d6e0ba | |||
| c995846db7 | |||
| 964b2afaae | |||
| 7cd4a45915 | |||
| 707361e660 | |||
| be4d464bc0 | |||
| e3c56fa800 | |||
| b427418ec6 | |||
| 580a00e1a9 | |||
| 7e982e30a3 | |||
| 0eae5262af | |||
| 6656cbc635 | |||
| 1e13ae4815 | |||
| e18aeb92dd | |||
| 24aaeeee7f | |||
| a70a397199 | |||
| 7f4d06fbe1 | |||
| 690ca33702 | |||
| cf6a80dd0d | |||
| c409b755cf | |||
| 0399a0cc91 | |||
| c28d6f3080 | |||
| 56501f9f33 | |||
| ebcf2aaa9e | |||
| 0f9f3dc073 | |||
| 8c92da2ceb | |||
| 671c59a9de | |||
| adcb8a4693 | |||
| 95d87858f1 | |||
| 0a463b0ddd | |||
| 2da4230d8c | |||
| b00fda2289 | |||
| 86790e7b69 | |||
| 80ea7303f8 | |||
| 700831ba26 | |||
| e35950ad89 | |||
| 0a6b93a8f8 | |||
| 7be72e76f2 | |||
| 6d5b0eb1e8 | |||
| 0dcf5d2097 | |||
| 32e584c04c | |||
| f726a4629f | |||
| fbe29d82be | |||
| a6c2254db3 | |||
| 3d4977dc87 | |||
| 4d0fda6157 | |||
| 34fb8ccf93 | |||
| 49b9c3a135 | |||
| bc04dcc94b | |||
| eb0bba47f9 | |||
| 9ba4e9c2cf | |||
| 3a69bb4452 | |||
| 0581ebf409 | |||
| 44607a9039 | |||
| 00db8c00c6 | |||
| c64713117e | |||
| 28e28d0775 | |||
| 6f53a67554 | |||
| f2b965b447 | |||
| 0ae4f745ee | |||
| bcfd9cdfef | |||
| 94ffe5a86f | |||
| c3ddd28bad | |||
| eab8bc846c | |||
| 05268442f8 | |||
| 55521e6f29 | |||
| db5b09cc11 | |||
| b0922b4c29 | |||
| 455ed32ac6 | |||
| fd92979481 | |||
| 3d322b29c1 | |||
| dcfc2f44cb | |||
| b809ae6687 | |||
| c575e589ae | |||
| 2af47af681 | |||
| b1228bdd2a | |||
| 4008c7fa4d | |||
| f2d714280b | |||
| 6862609bba | |||
| 3afae78477 | |||
| b03df595bc | |||
| c6f0825fb5 | |||
| cbc2902613 | |||
| db725a417d | |||
| 4270924d0f | |||
| 69fc206377 | |||
| 8468ec45c2 | |||
| 256a4c2b0a | |||
| 7d01e47c26 | |||
| 5814f468b3 | |||
| a5730e0ffd | |||
| 0dfd87db25 | |||
| 31aa16f155 | |||
| b22c6b9a5b | |||
| ffae0d1b1d | |||
| 5d8a31c725 | |||
| 1c35982db0 | |||
| 52f71dc79e | |||
| f1c0155379 | |||
| 19dc23d98a | |||
| 69c82ec0e6 | |||
| b1a9d96c3b | |||
| a88500576f | |||
| 058eaf0a4a | |||
| 1b326a0515 | |||
| 3fc1fd821a | |||
| b3af44cc4c | |||
| 44c1711be7 | |||
| c616df87ea | |||
| dd7072eea4 | |||
| 4ee463f03e | |||
| d3dc31eeaf | |||
| 08b364a626 | |||
| 9e6d1e5fbd | |||
| 75a21ee04e | |||
| 27d13d4ce9 | |||
| 16526ddfbd | |||
| d6e676300e | |||
| 7852972e01 | |||
| 6ff76ea1ed | |||
| 39d51ceeb3 | |||
| 00fc6e447c | |||
| 76fff608ed | |||
| 460409ac30 | |||
| 80403e1684 | |||
| ef32fd946b | |||
| 23d57c8bbd | |||
| c46b93769d | |||
| 2305229919 | |||
| 0e9453b1b2 | |||
| 420290bc87 | |||
| 91be2cea1d | |||
| 4dc3a8edc3 | |||
| 5ba9c74583 | |||
| a694e401d3 | |||
| a6cb0b9fa0 | |||
| 9b599fd28d | |||
| f04fecc11e | |||
| 471e28099b | |||
| 5a3031ae87 | |||
| 1421f27bd3 | |||
| e9e152eeee | |||
| aae6904e4b | |||
| db7fbe057e | |||
| 042508e8e6 | |||
| af5736f54d | |||
| 56816fa682 | |||
| 05e0609f94 | |||
| 7a080851ae | |||
| e1ce989d43 | |||
| 6e00a0c2a6 | |||
| 71318fa9ef | |||
| 05b4896d6e | |||
| 7f40e45ef2 | |||
| 2928c59b87 | |||
| ceb2442f3f | |||
| cec684c325 | |||
| b5e4bf772b | |||
| 9f3fe9e30d | |||
| c7174bbaec | |||
| de013e0129 | |||
| 412ea87668 | |||
| dc40f81ff2 | |||
| 25c849ccad | |||
| 927c846bcb | |||
| fcd13ba8b0 | |||
| bccd161762 | |||
| 776dfddc34 | |||
| b31b529ca7 | |||
| 1cc2f5387a | |||
| 5c79a01cc6 | |||
| 1e3704c1ed | |||
| 41340f7333 | |||
| e73fc09d9b | |||
| d593c54262 | |||
| b1e5d48098 | |||
| f9d652d629 | |||
| 77ee092b5b | |||
| 0a61d29f37 | |||
| c65147e309 | |||
| 1ff2bb0bcc | |||
| f8ce9ffc90 | |||
| 42366a8591 | |||
| 5dbf29a09d | |||
| 9621a62ed6 | |||
| 07f320db27 | |||
| 89ecf09b55 | |||
| 2cfb227c22 | |||
| 285ec88d01 | |||
| 1f86e7b32d | |||
| f34adc8e6d | |||
| 8606c8f87a | |||
| caf2dbacf9 | |||
| df6c87eed2 | |||
| 2894a964ea | |||
| 421baf2889 | |||
| 040901f9df | |||
| 9587336b31 | |||
| e1c2b2027a | |||
| c5ff26c879 | |||
| 9690a695d4 | |||
| 78e9c43f24 | |||
| 2d9af85b62 | |||
| 35c71c70c9 | |||
| 70e63ed8e3 | |||
| b7a36074ed | |||
| 0cb7e4c9a1 | |||
| 152b9add80 | |||
| ab27ca5256 | |||
| 90545415ae | |||
| 8018517207 | |||
| c79128d6f4 | |||
| 141d179a64 | |||
| 0a9471fc2e | |||
| 7cfa26ff02 | |||
| a7335d21c5 | |||
| ce3d594a4e | |||
| 553f84daa1 | |||
| 70f782cb5c | |||
| 28725ae76f | |||
| b0972f1a80 | |||
| 585660e52d | |||
| 0fd84f8b44 | |||
| 43bcf78dea | |||
| fb44391500 | |||
| 4c4de337cd | |||
| 20998852b6 | |||
| 929a2c4d29 | |||
| f0fd323107 | |||
| 00892e831a | |||
| 625e448928 | |||
| 2bfefc5082 | |||
| a55fcdcb28 | |||
| 1538d77960 | |||
| 9f77e70c16 | |||
| 548a34c66d | |||
| 55f51284c8 | |||
| 079dac80f8 | |||
| b33fee6ec0 | |||
| 2c1fdae6c7 | |||
| 6a935b18e8 | |||
| 91c363fb55 | |||
| 630f78e62d | |||
| dc7b103cbc | |||
| d30f51123d | |||
| 00f625c350 | |||
| 95f63bd4f2 | |||
| e1a65c5fce | |||
| 9fd6ce4e74 | |||
| 46df9cdccc | |||
| 339665f90f | |||
| 07a1b2a63b | |||
| 96d9d05eb9 | |||
| b1c848a7a6 | |||
| eb4d84bb48 | |||
| 04f72091e4 | |||
| 5d21d62140 | |||
| 0a7b646779 | |||
| 6a36874ef8 | |||
| 285e0caafe | |||
| 9f9a675f04 | |||
| 0e0c6c48af | |||
| 238220548a | |||
| 38c02380ad | |||
| dfc023a0cd | |||
| cbd9a5708b | |||
| bf5608492d | |||
| 267f03fd42 | |||
| 8b0a639196 | |||
| 75f164249f | |||
| fd72f01b1d | |||
| c17a55e33c | |||
| d39a62d4e0 | |||
| 5d02c40227 | |||
| 910d1eb6b7 | |||
| 1aded5ecf4 | |||
| 755a2a0633 | |||
| d86dc7a03c | |||
| 1a33e24a85 | |||
| 9a9c219082 | |||
| 9741334c2e | |||
| 48f762140b | |||
| 3e9c3027f2 | |||
| c895965822 | |||
| eba7f31b32 | |||
| 8dff7f3e69 | |||
| 5abb229fcc | |||
| d0b6d4ae5c | |||
| 772a21210d | |||
| b81df5b2ad | |||
| 07c44ef6a1 | |||
| 6aa1a0a00e | |||
| c6890cee19 | |||
| 38d91af306 | |||
| f83a4035c3 | |||
| 5fc03780a9 | |||
| ac7828c9f2 | |||
| 270a02366d | |||
| 25d96aba67 | |||
| f6558e1e13 | |||
| 7784cecdbc | |||
| ad3301e0a8 | |||
| 8f2ee5d323 | |||
| 9a999eefb7 | |||
| cdb274229b | |||
| b20a3717e1 | |||
| 3ef8dea4d2 | |||
| 17ee9752d3 | |||
| f2bf3df304 | |||
| c2b46ea5f2 | |||
| a5992750ed | |||
| 8b76b72222 | |||
| f12c0f8066 | |||
| 5f158f74e8 | |||
| ad6b7228cf | |||
| 9a0873cf67 | |||
| 503376edc2 | |||
| 7490617191 | |||
| 6cf461dbf7 | |||
| f33595c4c4 | |||
| f6f2db4b6f | |||
| 68252a4375 | |||
| c57a9f44a2 | |||
| 2fb90cb5d4 | |||
| 9925022660 | |||
| 5972b8b4bf | |||
| 13949e86c4 | |||
| f31507ae9f | |||
| 1207d53314 | |||
| f02b232589 | |||
| ab984d133a | |||
| 7440998d5f | |||
| 1e6351a11c | |||
| 78d9bde4c7 | |||
| dec546238e | |||
| 5715d36ad1 | |||
| 351e1d2eba | |||
| 0a067eb9dd | |||
| c62021ee64 | |||
| 7bab11d2a1 | |||
| 5bb2451750 | |||
| ef0341ad6d | |||
| a97a0d64a4 | |||
| 627190ddb7 | |||
| f1139add2a | |||
| ba59291932 | |||
| d3a8bafe8b | |||
| 4cfc98ec5a | |||
| 86b7924a55 | |||
| f645964bdf | |||
| e420b261bb | |||
| 1781f4c665 | |||
| ee79ed528b | |||
| d61abd1174 | |||
| fc9137a48d | |||
| a460ae0788 | |||
| 37a6dae3b5 | |||
| 4cbd4fe629 | |||
| 44df5dc061 | |||
| 9f144a638b | |||
| 18276c5941 | |||
| 385d197e31 | |||
| 2dceaeec3e | |||
| f59bc42539 | |||
| 5b7c98224c | |||
| 2542311341 | |||
| f4d001a821 | |||
| 2710c03112 | |||
| 3341d55f5a | |||
| bbca9c17e7 | |||
| d84cca5ab9 | |||
| 99d1185333 | |||
| 9f6611f877 | |||
| f81d315800 | |||
| 33f5badfd9 | |||
| 0407244cca | |||
| 64449ec38b | |||
| fb937e8ced | |||
| 96f9e8aceb | |||
| be294fbba5 | |||
| aabc676f94 | |||
| 24e6f93eae | |||
| 9a75e242e6 | |||
| 4c867390c2 | |||
| f9c6bb1e56 | |||
| 33ed2796c8 | |||
| c4fb785e55 | |||
| 8d5e6c8940 | |||
| f258b71648 | |||
| f3679aa041 | |||
| 3b02c9df23 | |||
| 1034254613 | |||
| bc3e92c4a1 | |||
| c7dabaa37b | |||
| 69866eaf91 | |||
| 5a8f1d663d | |||
| 2be72776ce | |||
| d92f6ff164 | |||
| 9aaeee9b3d | |||
| b4e94eeabb | |||
| 6f86dd7eef | |||
| 04d001a055 | |||
| f10b08e152 | |||
| 56c8885030 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -9,4 +9,6 @@ build/
|
||||
release-app/
|
||||
test-app/
|
||||
scripts/apk-channel/
|
||||
app/src/test/java/com/gh/gamecenter
|
||||
app/src/test/java/com/gh/gamecenter
|
||||
app/src/main/assets-debug/
|
||||
app/src/main/assets-release/
|
||||
@ -61,7 +61,7 @@ android_build:
|
||||
script:
|
||||
- export GRADLE_USER_HOME=/home/gitlab-runner/ci-build-cache/$CI_PROJECT_PATH/.gradle
|
||||
- chmod +x ./gradlew
|
||||
- ./scripts/jenkins_build.sh -c
|
||||
- ./scripts/jenkins_build.sh $CI_COMMIT_REF_NAME $BEFORE_COMMIT_SHA $CI_COMMIT_SHA
|
||||
#设置打包后的产物,用于job之间共享
|
||||
artifacts:
|
||||
paths:
|
||||
@ -71,7 +71,8 @@ android_build:
|
||||
exit_codes: 137
|
||||
only:
|
||||
- dev
|
||||
- dev-5.29.0
|
||||
- release
|
||||
- feat/GHZSCY-6578
|
||||
|
||||
# 代码检查
|
||||
sonarqube_analysis:
|
||||
@ -102,7 +103,7 @@ sonarqube_analysis:
|
||||
exit_codes: 137
|
||||
only:
|
||||
- dev
|
||||
- dev-5.29.0
|
||||
- release
|
||||
|
||||
## 发送简易检测结果报告
|
||||
send_sonar_report:
|
||||
@ -120,21 +121,24 @@ send_sonar_report:
|
||||
exit_codes: 137
|
||||
only:
|
||||
- dev
|
||||
- dev-5.29.0
|
||||
- release
|
||||
|
||||
oss-upload&send-email:
|
||||
tags:
|
||||
- rancher-k8s
|
||||
- sysadm-devops
|
||||
stage: oss-upload&send-email
|
||||
image: hub.shanqu.cc/devops/android-apk-oss-upload:latest
|
||||
id_tokens:
|
||||
VAULT_ID_TOKEN:
|
||||
aud: https://vault.shanqu.cc
|
||||
variables:
|
||||
GIT_STRATEGY: none
|
||||
VAULT_ADDR: https://vault.shanqu.cc # 固定值
|
||||
VAULT_SECRET_PATH: prod/devops/android-apk-oss-upload # 固定值
|
||||
VAULT_ROLE: android-apk-oss-upload # 固定值
|
||||
ENDPOINT: "oss-cn-shenzhen-internal.aliyuncs.com" # 固定值
|
||||
BUCKET: "shanqu" # 固定值
|
||||
FILE_PATH: "app/build/tmp/" # APK 存放路径
|
||||
ENDPOINT: "tos-cn-guangzhou.ivolces.com" # 固定值
|
||||
BUCKET: "sysadm-public" # 固定值
|
||||
FILE_PATH: "app/build/tmp/" # APK 存放路径
|
||||
Email_To_List: $EMAIL_TO_LIST # 邮件接受人列表
|
||||
Email_Title: "光环助手 $CI_COMMIT_BRANCH" # 邮件标题
|
||||
PIPELINE_ID: $CI_PIPELINE_ID # 流水线id
|
||||
@ -145,11 +149,13 @@ oss-upload&send-email:
|
||||
artifacts: true
|
||||
script:
|
||||
### 绑定上传参数 ###
|
||||
|
||||
- export OSS_PATH="release/dev/${CI_PROJECT_NAME}/$(date "+%Y/%m/%d")"
|
||||
### 开启上传 ###
|
||||
- /usr/local/bin/python /upload.py
|
||||
### 发送邮件
|
||||
- /usr/local/bin/python /ci-android-mail.py
|
||||
- /usr/local/bin/python /ci-android-mail-jira-comment.py
|
||||
only:
|
||||
- dev
|
||||
- dev-5.29.0
|
||||
- release
|
||||
- feat/GHZSCY-6578
|
||||
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -5,9 +5,9 @@
|
||||
[submodule "vspace-bridge"]
|
||||
path = vspace-bridge
|
||||
url = ../../../cwzs/android/vspace-bridge.git
|
||||
[submodule "module_common/src/debug/assets/assistant-android-mock"]
|
||||
path = module_common/src/debug/assets/assistant-android-mock
|
||||
url = ../../../halo/android/assistant-android-mock.git
|
||||
[submodule "ndownload"]
|
||||
path = ndownload
|
||||
url = ../../../android/ndownload.git
|
||||
[submodule "vasdk"]
|
||||
path = vasdk
|
||||
url = ../../../sdg/android/vasdk.git
|
||||
|
||||
21
README.md
21
README.md
@ -30,14 +30,7 @@
|
||||
|
||||
### git 版本管理
|
||||
|
||||
本项目使用简化版的 git flow 来管理分支,细节请看 [光环安卓简单 git 规范](https://git.ghzs.com/halo/android/assistant-android/-/wikis/%E5%85%89%E7%8E%AF%E5%AE%89%E5%8D%93%E7%AE%80%E5%8D%95-git-%E8%A7%84%E8%8C%83)
|
||||
|
||||
### API 环境配置
|
||||
|
||||
本项目使用 Build Variants 来切换 API 环境
|
||||
|
||||
* internal 为测试环境
|
||||
* publish 为正式环境
|
||||
本项目使用简化版的 git flow 来管理分支,细节请看 [光环安卓简单 git 规范](https://git.shanqu.cc/halo/android/assistant-android/-/wikis/%E5%85%89%E7%8E%AF%E5%AE%89%E5%8D%93%E7%AE%80%E5%8D%95-git-%E8%A7%84%E8%8C%83)
|
||||
|
||||
### 图片资源配置
|
||||
|
||||
@ -51,16 +44,4 @@
|
||||
|
||||
### 混淆配置
|
||||
|
||||
* 本项目使用了微信的 [AndResGuard](https://github.com/shwenzhang/AndResGuard) 作为资源混淆压缩方案,新增需要使用 `getIdentifier` 获取的资源文件时需要添加至白名单
|
||||
* 本项目默认使用 R8 作为混淆工具,往 proguard-rules.txt 添加 proguard 新配置项时请检查可用性(如语法等)
|
||||
|
||||
### APK打包配置
|
||||
|
||||
> 打内部测试包:`./scripts/test_build.sh`
|
||||
> 打邮件测试包:`./scripts/jenkins_build.sh`
|
||||
|
||||
### TODO
|
||||
|
||||
* 把原有 EventBus 的消息 Type 统一到一个文件内
|
||||
* 将实现细节从 View(Fragment、Activity) 剥离并以 MVVM 结构改造
|
||||
* 重构 MainActivity
|
||||
|
||||
305
app/build.gradle
305
app/build.gradle
@ -3,7 +3,6 @@ apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android' // kotlin
|
||||
apply plugin: 'kotlin-parcelize'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'AndResGuard'
|
||||
|
||||
import groovy.xml.XmlUtil
|
||||
|
||||
@ -14,6 +13,7 @@ android {
|
||||
String SDK_VERSION = ""
|
||||
String SDK_APP_ID = ""
|
||||
String SDK_APP_NAME = ""
|
||||
boolean USE_DEFAULT_CHANNEL_SDK = true
|
||||
int ACTIVATE_REPORTING_RATIO = 100
|
||||
|
||||
buildFeatures {
|
||||
@ -22,6 +22,8 @@ android {
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
coreLibraryDesugaringEnabled true
|
||||
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
@ -72,7 +74,7 @@ android {
|
||||
versionName rootProject.ext.versionName
|
||||
applicationId rootProject.ext.applicationId
|
||||
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt', 'proguard-fresco.txt'
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt', 'proguard-fresco.txt', rootProject.ext.va_proguard_rules
|
||||
|
||||
String CORE_EVENT_GAME_CATEGORY = ""
|
||||
|
||||
@ -86,6 +88,7 @@ android {
|
||||
buildConfigField "String", "SDK_VERSION", "\"${SDK_VERSION}\""
|
||||
buildConfigField "String", "SDK_APP_ID", "\"${SDK_APP_ID}\""
|
||||
buildConfigField "String", "SDK_APP_NAME", "\"${SDK_APP_NAME}\""
|
||||
buildConfigField "boolean", "USE_DEFAULT_CHANNEL_SDK", "${USE_DEFAULT_CHANNEL_SDK}"
|
||||
|
||||
// 首次启动的跳转配置
|
||||
buildConfigField "String", "FIRST_LAUNCH", "\"${FIRST_LAUNCH}\""
|
||||
@ -93,13 +96,17 @@ android {
|
||||
buildConfigField "int", "ACTIVATE_REPORTING_RATIO", "${ACTIVATE_REPORTING_RATIO}"
|
||||
|
||||
// All third-party appid/appkey
|
||||
buildConfigField "boolean", "IS_GAT_APP", "false"
|
||||
buildConfigField "String", "API_HOST", "\"${API_HOST}\""
|
||||
buildConfigField "String", "NEW_API_HOST", "\"${NEW_API_HOST}\""
|
||||
buildConfigField "String", "LOG_HUB_PROJECT", "\"${LOG_HUB_PROJECT}\""
|
||||
buildConfigField "String", "VAPI_HOST", "\"${VAPI_HOST}\""
|
||||
buildConfigField "String", "WECHAT_APPID", "\"${WECHAT_APPID}\""
|
||||
buildConfigField "String", "WECHAT_SECRET", "\"${WECHAT_SECRET}\""
|
||||
buildConfigField "String", "TENCENT_APPID", "\"${TENCENT_APPID}\""
|
||||
buildConfigField "String", "WEIBO_APPKEY", "\"${WEIBO_APPKEY}\""
|
||||
// 一体包的32位畅玩游戏助手包名
|
||||
buildConfigField "String", "EXT_PACKAGE_NAME", "\"${rootProject.ext.EXT_PACKAGE_NAME}\""
|
||||
}
|
||||
|
||||
// gradle 2.2以上默认同时启用v1和v2(优先用于Android N)
|
||||
@ -120,6 +127,10 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
exclude 'META-INF/gradle/incremental.annotation.processors'
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
debuggable true
|
||||
@ -155,9 +166,18 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
flavorDimensions("env")
|
||||
flavorDimensions("env", "region")
|
||||
|
||||
sourceSets {
|
||||
|
||||
debug {
|
||||
assets.srcDirs += 'src/main/assets-debug'
|
||||
}
|
||||
|
||||
release {
|
||||
assets.srcDirs += 'src/main/assets-release'
|
||||
}
|
||||
|
||||
publish {
|
||||
java.srcDirs = ['src/main/java', "src/default/java"]
|
||||
}
|
||||
@ -173,6 +193,15 @@ android {
|
||||
gdt {
|
||||
java.srcDirs = ['src/main/java', 'src/gdt/java']
|
||||
}
|
||||
gat {
|
||||
java.srcDirs = ['src/main/java', 'src/gat/java']
|
||||
}
|
||||
cn {
|
||||
java.srcDirs = ['src/main/java', 'src/cn/java']
|
||||
}
|
||||
sm {
|
||||
java.srcDirs = ['src/main/java', 'src/sm/java']
|
||||
}
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
@ -186,6 +215,11 @@ android {
|
||||
buildConfigField "String", "DEV_VAPI_HOST", "\"${DEV_VAPI_HOST}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPID", "\"${DEV_QUICK_LOGIN_APPID}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${DEV_QUICK_LOGIN_APPKEY}\""
|
||||
buildConfigField "String", "DEV_CSJ_APPID", "\"${DEV_CSJ_APPID}\""
|
||||
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
||||
|
||||
buildConfigField "String", "VA_VERSION_NAME", "\"${rootProject.ext.VA_VERSION}-debug\""
|
||||
manifestPlaceholders.put("VA_VERSION_NAME", "${rootProject.ext.VA_VERSION}-debug")
|
||||
}
|
||||
|
||||
// publish, 发布时候使用的 flavor,接口仅包含正式环境
|
||||
@ -197,6 +231,11 @@ android {
|
||||
buildConfigField "String", "DEV_VAPI_HOST", "\"${VAPI_HOST}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPID", "\"${QUICK_LOGIN_APPID}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
||||
buildConfigField "String", "DEV_CSJ_APPID", "\"${CSJ_APPID}\""
|
||||
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
||||
|
||||
buildConfigField "String", "VA_VERSION_NAME", "\"${rootProject.ext.VA_VERSION}\""
|
||||
manifestPlaceholders.put("VA_VERSION_NAME", "${rootProject.ext.VA_VERSION}")
|
||||
}
|
||||
|
||||
tea {
|
||||
@ -207,8 +246,13 @@ android {
|
||||
buildConfigField "String", "DEV_VAPI_HOST", "\"${VAPI_HOST}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPID", "\"${QUICK_LOGIN_APPID}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
||||
buildConfigField "String", "DEV_CSJ_APPID", "\"${CSJ_APPID}\""
|
||||
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
||||
|
||||
buildConfigField "String", "VA_VERSION_NAME", "\"${rootProject.ext.VA_VERSION}\""
|
||||
|
||||
manifestPlaceholders.put("APPLOG_SCHEME", "rangersapplog.byAx6uYt".toLowerCase())
|
||||
manifestPlaceholders.put("VA_VERSION_NAME", "${rootProject.ext.VA_VERSION}")
|
||||
}
|
||||
|
||||
kuaishou {
|
||||
@ -219,6 +263,11 @@ android {
|
||||
buildConfigField "String", "DEV_VAPI_HOST", "\"${VAPI_HOST}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPID", "\"${QUICK_LOGIN_APPID}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
||||
buildConfigField "String", "DEV_CSJ_APPID", "\"${CSJ_APPID}\""
|
||||
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
||||
|
||||
buildConfigField "String", "VA_VERSION_NAME", "\"${rootProject.ext.VA_VERSION}\""
|
||||
manifestPlaceholders.put("VA_VERSION_NAME", "${rootProject.ext.VA_VERSION}")
|
||||
}
|
||||
|
||||
gdt {
|
||||
@ -229,6 +278,45 @@ android {
|
||||
buildConfigField "String", "DEV_VAPI_HOST", "\"${VAPI_HOST}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPID", "\"${QUICK_LOGIN_APPID}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
||||
buildConfigField "String", "DEV_CSJ_APPID", "\"${CSJ_APPID}\""
|
||||
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
||||
|
||||
buildConfigField "String", "VA_VERSION_NAME", "\"${rootProject.ext.VA_VERSION}\""
|
||||
manifestPlaceholders.put("VA_VERSION_NAME", "${rootProject.ext.VA_VERSION}")
|
||||
}
|
||||
|
||||
sm {
|
||||
dimension "env"
|
||||
|
||||
buildConfigField "String", "DEV_API_HOST", "\"${API_HOST}\""
|
||||
buildConfigField "String", "NEW_DEV_API_HOST", "\"${NEW_API_HOST}\""
|
||||
buildConfigField "String", "DEV_VAPI_HOST", "\"${VAPI_HOST}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPID", "\"${QUICK_LOGIN_APPID}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
||||
buildConfigField "String", "DEV_CSJ_APPID", "\"${CSJ_APPID}\""
|
||||
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
||||
|
||||
buildConfigField "String", "VA_VERSION_NAME", "\"${rootProject.ext.VA_VERSION}\""
|
||||
manifestPlaceholders.put("VA_VERSION_NAME", "${rootProject.ext.VA_VERSION}")
|
||||
}
|
||||
|
||||
// 港澳台
|
||||
gat {
|
||||
dimension "region"
|
||||
|
||||
applicationId rootProject.ext.applicationIdGat
|
||||
|
||||
// 支持繁体
|
||||
resConfigs "zh", "zh-rTW"
|
||||
|
||||
buildConfigField "boolean", "IS_GAT_APP", "true"
|
||||
buildConfigField "String", "LOG_HUB_PROJECT", "\"${LOG_HUB_PROJECT_GAT}\""
|
||||
buildConfigField "String", "API_HOST", "\"${API_HOST_GAT}\""
|
||||
buildConfigField "String", "NEW_API_HOST", "\"${NEW_API_HOST_GAT}\""
|
||||
}
|
||||
|
||||
cn {
|
||||
dimension "region"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -246,14 +334,13 @@ dependencies {
|
||||
teaImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/tea/libs')
|
||||
kuaishouImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/kuaishou/libs')
|
||||
gdtImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/gdt/libs')
|
||||
testImplementation 'junit:junit:4.12'
|
||||
smImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/sm/libs')
|
||||
|
||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:${leakcanary}"
|
||||
debugImplementation "com.squareup.leakcanary:leakcanary-android-process:${leakcanary}"
|
||||
|
||||
// debugImplementation "com.gu.android:toolargetool:${toolargetool}" // 需要使用调试时才启用
|
||||
debugImplementation "com.github.nichbar:WhatTheStack:${whatTheStack}"
|
||||
// debugImplementation "io.github.didi.dokit:dokitx:${dokit}"
|
||||
|
||||
implementation "androidx.multidex:multidex:${multiDex}"
|
||||
implementation "androidx.fragment:fragment-ktx:${fragment}"
|
||||
@ -265,7 +352,8 @@ dependencies {
|
||||
|
||||
implementation "com.kyleduo.switchbutton:library:${switchButton}"
|
||||
|
||||
implementation "com.leon.channel:helper:${apkChannelPackage}"
|
||||
implementation "com.tencent.vasdolly:helper:${apkChannelPackage}"
|
||||
implementation "com.tencent.vasdolly:writer:${apkChannelPackage}"
|
||||
|
||||
implementation "com.j256.ormlite:ormlite-android:${ormlite}"
|
||||
implementation "com.j256.ormlite:ormlite-core:${ormlite}"
|
||||
@ -288,12 +376,10 @@ dependencies {
|
||||
})
|
||||
implementation "com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-exo_player2:$gsyVideo"
|
||||
|
||||
// implementation "androidx.work:work-runtime:${workManager}"
|
||||
|
||||
implementation "com.llew.huawei:verifier:${verifier}"
|
||||
|
||||
teaImplementation "com.bytedance.applog:RangersAppLog-Lite-cn:${bytedanceApplog}"
|
||||
teaImplementation "com.bytedance.applog:RangersAppLog-All-convert:${bytedanceApplog}"
|
||||
teaImplementation "com.bytedance.ads:AppConvert:${bytedanceAppConvert}"
|
||||
|
||||
implementation "net.lingala.zip4j:zip4j:${zip4j}"
|
||||
|
||||
@ -302,46 +388,109 @@ dependencies {
|
||||
|
||||
implementation "com.lg:easyfloat:${easyFloat}"
|
||||
|
||||
implementation "io.github.florent37:shapeofview:${shapeOfView}"
|
||||
|
||||
implementation "com.lg:apksig:${apksig}"
|
||||
implementation("com.lg:apksig:${apksig}") {
|
||||
exclude group: 'com.google.protobuf'
|
||||
}
|
||||
|
||||
implementation "com.lg:gid:${gid}"
|
||||
|
||||
implementation "com.lg:shortcut:${shortcut}"
|
||||
|
||||
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:${desugarJdkLibs}"
|
||||
|
||||
kapt "com.alibaba:arouter-compiler:$arouterVersion"
|
||||
|
||||
implementation project(':ndownload')
|
||||
implementation project(':vspace-bridge:vspace')
|
||||
implementation(project(':feature:xapk-installer'))
|
||||
|
||||
implementation (project(':module_common')) {
|
||||
implementation(project(':module_common')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
|
||||
implementation(project(':module_login')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
implementation(project(':module_setting')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
// implementation(project(':module_setting_compose')) {
|
||||
// exclude group: 'androidx.swiperefreshlayout'
|
||||
// }
|
||||
|
||||
implementation(project(':module_core_feature')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
implementation(project(':module_feedback')) {
|
||||
|
||||
implementation(project(':module_setting')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
implementation(project(':module_sensors_data')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
|
||||
// implementation(project(':module_setting_compose')) {
|
||||
// exclude group: 'androidx.swiperefreshlayout'
|
||||
// }
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enablePkg) {
|
||||
implementation(project(':feature:pkg'))
|
||||
}
|
||||
// implementation(project(':feature:vpn'))
|
||||
implementation(project(':feature:pkg'))
|
||||
implementation(project(':feature:oaid'))
|
||||
implementation(project(':feature:floating-window'))
|
||||
implementation(project(':feature:beizi_startup_ad'))
|
||||
implementation(project(':feature:xapk-installer'))
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableFeedback) {
|
||||
implementation(project(':feature:new_feedback')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
}
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableMessage) {
|
||||
implementation(project(':module_message')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
}
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableOaid) {
|
||||
implementation(project(':feature:oaid'))
|
||||
}
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableFloatingWindow) {
|
||||
implementation(project(':feature:floating-window'))
|
||||
}
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableSensorData) {
|
||||
implementation(project(':module_sensors_data')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
}
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableCsjAd) {
|
||||
implementation(project(':feature:csj_ad'))
|
||||
}
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableQQGame) {
|
||||
implementation(project(':feature:qq_game')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
}
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enablePush) {
|
||||
def pushProperty = findProperty('BUILD_PUSH_TYPE')
|
||||
// 根据BUILD_PUSH_TYPE决定使用哪个推送SDK,目前默认使用极光推送
|
||||
def pushProject = (pushProperty == null || pushProperty == 'jg')
|
||||
? project(':feature:jg_push') : project(':feature:acloud_push')
|
||||
|
||||
implementation(pushProject) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
}
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableSentry) {
|
||||
implementation(project(':feature:sentry'))
|
||||
}
|
||||
|
||||
implementation(project(':feature:media_select'))
|
||||
|
||||
implementation(project(":module_va_api"))
|
||||
implementation(project(":va-archive-common"))
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableVa) {
|
||||
implementation(project(":module_va_impl"))
|
||||
}
|
||||
debugImplementation "com.bytedance.tools.codelocator:codelocator-core:2.0.3"
|
||||
internalImplementation(project(':module_internal_test'))
|
||||
|
||||
debugImplementation 'com.bytedance.android:shadowhook:1.0.9'
|
||||
debugImplementation 'io.github.shiqos:wytrace:1.0.1'
|
||||
}
|
||||
|
||||
File propFile = file('sign.properties')
|
||||
@ -401,106 +550,6 @@ if (propFile.exists()) {
|
||||
// }.each { t -> t.dependsOn generateMetaJson }
|
||||
//}
|
||||
|
||||
andResGuard {
|
||||
mappingFile = null
|
||||
use7zip = true
|
||||
useSign = true
|
||||
// 打开这个开关,会keep住所有资源的原始路径,只混淆资源的名字
|
||||
keepRoot = false
|
||||
// 设置这个值,会把arsc name列混淆成相同的名字,减少string常量池的大小
|
||||
fixedResName = "arg"
|
||||
// 打开这个开关会合并所有哈希值相同的资源,但请不要过度依赖这个功能去除去冗余资源
|
||||
mergeDuplicatedRes = true
|
||||
whiteList = [
|
||||
"R.drawable.icon",
|
||||
"R.drawable.ic_bar_back",
|
||||
"R.drawable.toolbar_search_icon",
|
||||
"R.drawable.bg_notification_answer_style_1",
|
||||
"R.drawable.bg_notification_answer_style_2",
|
||||
"R.drawable.bg_notification_article_style_1",
|
||||
"R.drawable.bg_notification_article_style_2",
|
||||
"R.drawable.bg_notification_feedback_style_1",
|
||||
"R.drawable.bg_notification_feedback_style_2",
|
||||
"R.drawable.bg_notification_gift_style_1",
|
||||
"R.drawable.bg_notification_gift_style_2",
|
||||
"R.drawable.bg_notification_login_style_1",
|
||||
"R.drawable.bg_notification_login_style_2",
|
||||
"R.drawable.bg_notification_question_style_1",
|
||||
"R.drawable.bg_notification_question_style_2",
|
||||
"R.drawable.bg_notification_rating_style_1",
|
||||
"R.drawable.bg_notification_rating_style_2",
|
||||
"R.drawable.bg_notification_reserve_game_style_1",
|
||||
"R.drawable.bg_notification_reserve_game_style_2",
|
||||
"R.drawable.bg_notification_video_style_1",
|
||||
"R.drawable.bg_notification_video_style_2",
|
||||
"R.drawable.ic_recommend_activity",
|
||||
"R.drawable.ic_recommend_discount",
|
||||
"R.drawable.ic_recommend_function",
|
||||
"R.drawable.ic_recommend_gift",
|
||||
"R.drawable.ic_recommend_role",
|
||||
"R.drawable.download_button_normal_style",
|
||||
"R.drawable.ic_selector_selected",
|
||||
"R.drawable.ic_selector_default",
|
||||
"R.id.download_speed",
|
||||
"R.id.download_percentage",
|
||||
"R.id.comment",
|
||||
"R.id.vote",
|
||||
"R.id.watermark_hint",
|
||||
"R.id.watermark_sb",
|
||||
"R.id.bottomShareIv",
|
||||
"R.id.bottomShareTv",
|
||||
"R.id.recommendStarPref",
|
||||
"R.id.recommendStar",
|
||||
"R.id.iv_vmode_badge",
|
||||
"R.id.tv_vmode",
|
||||
"R.id.iv_vmode",
|
||||
"R.drawable.help_search_delete",
|
||||
"R.drawable.suggest_type_normal",
|
||||
"R.drawable.suggest_type_crash",
|
||||
"R.drawable.suggest_type_game_question",
|
||||
"R.drawable.suggest_type_game_collect",
|
||||
"R.drawable.suggest_type_function_suggest",
|
||||
"R.drawable.suggest_type_article_collect",
|
||||
"R.drawable.suggest_type_copyright",
|
||||
"R.drawable.news_comment_detail_read",
|
||||
"R.drawable.news_comment_detail_comment",
|
||||
"R.drawable.news_comment_detail_share",
|
||||
"R.drawable.ic_libao",
|
||||
"R.drawable.ic_link",
|
||||
"R.drawable.concern_message_icon",
|
||||
"R.drawable.reuse_blank_hint",
|
||||
"R.drawable.ic_concern",
|
||||
"R.drawable.concern_down",
|
||||
"R.drawable.concern_up",
|
||||
"R.drawable.ic_libao_more",
|
||||
"R.drawable.ic_libao_delete",
|
||||
"R.drawable.ic_dialog_close",
|
||||
"R.drawable.occupy2",
|
||||
"R.drawable.kc_checkbox_unselect",
|
||||
"R.drawable.kc_checkbox_select",
|
||||
"R.drawable.ic_type_unselect",
|
||||
"R.drawable.ic_type_selected",
|
||||
"R.drawable.suggest_add_pic_icon",
|
||||
"R.drawable.icon_pic_add",
|
||||
"R.drawable.ask_search_input_delete",
|
||||
"R.drawable.suggest_pic_delete",
|
||||
"R.id.cardIv",
|
||||
"R.id.cardMask",
|
||||
"R.id.cardGradientMask",
|
||||
"R.id.gameIconIv",
|
||||
"R.id.titleContainer"
|
||||
]
|
||||
compressFilePattern = [
|
||||
"*.png",
|
||||
"*.jpg",
|
||||
"*.jpeg",
|
||||
"*.gif",
|
||||
]
|
||||
sevenzip {
|
||||
artifact = 'io.github.leon406:SevenZip:1.2.22.5'
|
||||
}
|
||||
}
|
||||
|
||||
project.afterEvaluate {
|
||||
def variants = null
|
||||
try {
|
||||
|
||||
@ -80,15 +80,19 @@
|
||||
### EasyFloat
|
||||
-keep class com.lzf.easyfloat.* {*;}
|
||||
|
||||
### dokit
|
||||
-keep class com.didichuxing.** {*;}
|
||||
|
||||
### 广点通SDK
|
||||
-dontwarn com.qq.gdt.action.**
|
||||
-keep class com.qq.gdt.action.** {*;}
|
||||
-keep public class com.tencent.turingfd.sdk.**
|
||||
|
||||
### 神马 SDK
|
||||
-dontwarn com.gism.**
|
||||
|
||||
-keepclasseswithmembers class * {
|
||||
native <methods>;
|
||||
}
|
||||
|
||||
-keepclassmembernames class com.contrarywind.view.WheelView {
|
||||
private int itemsVisible;
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.utils.PackageFlavorHelper
|
||||
import com.gh.gamecenter.core.provider.IFlavorProvider
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.leon.channel.helper.ChannelReaderUtil
|
||||
import com.tencent.vasdolly.helper.ChannelReaderUtil
|
||||
|
||||
class FlavorProviderImp : IFlavorProvider {
|
||||
override fun getChannelStr(application: Application): String {
|
||||
|
||||
@ -5,6 +5,7 @@ import com.lightgame.utils.Utils
|
||||
import com.qq.gdt.action.ActionParam
|
||||
import com.qq.gdt.action.ActionType
|
||||
import com.qq.gdt.action.GDTAction
|
||||
import com.qq.gdt.action.PrivateController
|
||||
import org.json.JSONObject
|
||||
|
||||
object GdtHelper {
|
||||
@ -16,11 +17,20 @@ object GdtHelper {
|
||||
|
||||
@JvmStatic
|
||||
fun init(application: Application, channel: String) {
|
||||
GDTAction.setPrivateController(object : PrivateController() {
|
||||
override fun isCanUsePhoneState(): Boolean {
|
||||
return false
|
||||
}
|
||||
})
|
||||
|
||||
if (channel == "KS_GDT_GHZS_MC01") {
|
||||
GDTAction.init(application, KS_USER_ACTION_SET_ID, KS_APP_SECRET_ID, channel)
|
||||
} else {
|
||||
GDTAction.init(application, USER_ACTION_SET_ID, APP_SECRET_ID, channel)
|
||||
}
|
||||
|
||||
GDTAction.start()
|
||||
|
||||
Utils.log("init GdtHelper")
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ import com.gh.gamecenter.core.provider.IFlavorProvider
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.TimeUtils
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.leon.channel.helper.ChannelReaderUtil
|
||||
import com.tencent.vasdolly.helper.ChannelReaderUtil
|
||||
|
||||
class FlavorProviderImp : IFlavorProvider {
|
||||
|
||||
|
||||
Binary file not shown.
BIN
app/src/gdt/libs/GDTActionSDK.min.1.8.9.aar
Normal file
BIN
app/src/gdt/libs/GDTActionSDK.min.1.8.9.aar
Normal file
Binary file not shown.
42
app/src/internal/java/com/gh/vspace/ExternalGameUsage.kt
Normal file
42
app/src/internal/java/com/gh/vspace/ExternalGameUsage.kt
Normal file
@ -0,0 +1,42 @@
|
||||
package com.gh.vspace
|
||||
|
||||
import android.content.Intent
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.Keep
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.databinding.LayoutPersonalOtherItemBinding
|
||||
import com.gh.vspace.installexternalgames.InstallExternalGameActivity
|
||||
import com.lightgame.utils.Utils
|
||||
import java.io.File
|
||||
|
||||
@Keep
|
||||
class ExternalGameUsage : ITestCase {
|
||||
|
||||
private fun buttonTemplate(viewParent: ViewGroup, id: Int, fn: (LayoutPersonalOtherItemBinding) -> Unit) {
|
||||
val context = viewParent.context
|
||||
viewParent.findViewById<View>(id) ?: run {
|
||||
val binding = LayoutPersonalOtherItemBinding.inflate(LayoutInflater.from(context)).apply {
|
||||
root.id = id
|
||||
fn(this)
|
||||
}
|
||||
viewParent.addView(binding.root, 0)
|
||||
}
|
||||
}
|
||||
|
||||
override fun addInstallExternalGameButton(viewParent: ViewGroup) {
|
||||
val context = viewParent.context
|
||||
buttonTemplate(viewParent, R.id.install_game_from_external) {
|
||||
it.titleTv.text = context.getString(R.string.title_install_external_game)
|
||||
it.iconIv.setImageResource(R.drawable.ic_personal_my_game)
|
||||
it.root.setOnClickListener {
|
||||
context.startActivity(
|
||||
InstallExternalGameActivity.getIntent(context)
|
||||
.apply { flags = flags or Intent.FLAG_ACTIVITY_NEW_TASK })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.gh.vspace.installexternalgames;
|
||||
|
||||
public class Constants {
|
||||
public static final String TAG = "从SD卡安装";
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package com.gh.vspace.installexternalgames
|
||||
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.gamecenter.common.utils.goneIf
|
||||
import com.gh.gamecenter.common.utils.toBinding
|
||||
|
||||
class ExternalGameAdapter(private val games: List<ExternalGameUiState>, private val onItemClickListener: OnItemClickListener) :
|
||||
RecyclerView.Adapter<ExternalGameViewHolder>() {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ExternalGameViewHolder {
|
||||
return ExternalGameViewHolder(parent.toBinding())
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return games.size
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ExternalGameViewHolder, position: Int) {
|
||||
val item = games[position]
|
||||
holder.apkInfo.text = item.externalGameEntity.let { item ->
|
||||
"""
|
||||
应用程序名:${item.appName}
|
||||
版本号:${item.apkVersion}
|
||||
包名: ${item.apkPackageName}
|
||||
路径:${item.apkPath}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
holder.update.setOnClickListener {
|
||||
onItemClickListener.onItemClick(item, OnItemClickListener.ClickType.CLICK_INSTALL)
|
||||
}
|
||||
|
||||
holder.install.goneIf(item.isInstalled) {
|
||||
holder.install.setOnClickListener {
|
||||
onItemClickListener.onItemClick(item, OnItemClickListener.ClickType.CLICK_INSTALL)
|
||||
}
|
||||
}
|
||||
holder.uninstall.goneIf(!item.isInstalled) {
|
||||
holder.uninstall.setOnClickListener {
|
||||
onItemClickListener.onItemClick(
|
||||
item,
|
||||
OnItemClickListener.ClickType.CLICK_UNINSTALL
|
||||
)
|
||||
}
|
||||
}
|
||||
holder.start.goneIf(!item.isInstalled) {
|
||||
holder.start.setOnClickListener {
|
||||
onItemClickListener.onItemClick(item, OnItemClickListener.ClickType.CLICK_START)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.gh.vspace.installexternalgames
|
||||
|
||||
data class ExternalGameEntity(
|
||||
val cpuAbi: Set<String>,
|
||||
val apkPath: String,
|
||||
val apkFileName: String,
|
||||
val appName: String,
|
||||
val apkVersion: String,
|
||||
val apkPackageName: String,
|
||||
val lastModified: Long,
|
||||
)
|
||||
@ -0,0 +1,6 @@
|
||||
package com.gh.vspace.installexternalgames
|
||||
|
||||
data class ExternalGameUiState(
|
||||
val externalGameEntity: ExternalGameEntity,
|
||||
val isInstalled: Boolean
|
||||
)
|
||||
@ -0,0 +1,12 @@
|
||||
package com.gh.vspace.installexternalgames
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.gamecenter.databinding.LayoutExternalGameItemBinding
|
||||
|
||||
class ExternalGameViewHolder(binding: LayoutExternalGameItemBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
val apkInfo = binding.apkFileInfo
|
||||
val install = binding.btnInstall
|
||||
val uninstall = binding.btnUninstall
|
||||
val start = binding.btnStart
|
||||
val update = binding.btnUpdate
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.gh.vspace.installexternalgames
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
|
||||
class InstallExternalGameActivity : ToolBarActivity() {
|
||||
companion object {
|
||||
fun getIntent(context: Context): Intent {
|
||||
return getTargetIntent(context, InstallExternalGameActivity::class.java, InstallExternalGameFragment::class.java, Bundle())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,201 @@
|
||||
package com.gh.vspace.installexternalgames
|
||||
|
||||
import android.Manifest
|
||||
import android.app.Dialog
|
||||
import android.content.ComponentName
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.fragment.ToolbarFragment
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.utils.toColor
|
||||
import com.gh.gamecenter.common.utils.viewModelProvider
|
||||
import com.gh.gamecenter.common.view.divider.HorizontalDividerItemDecoration
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.databinding.FragmentInstallExternalGamesBinding
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lg.vspace.VirtualAppManager
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import io.reactivex.Single
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
|
||||
|
||||
private val mViewModel: InstallExternalGameViewModel by lazy { viewModelProvider() }
|
||||
|
||||
private lateinit var mBinding: FragmentInstallExternalGamesBinding
|
||||
|
||||
private val games = mutableListOf<ExternalGameUiState>()
|
||||
private var adapter = ExternalGameAdapter(games, this)
|
||||
|
||||
private var uninstallDisposable: Disposable? = null
|
||||
|
||||
override fun getLayoutId() = 0
|
||||
|
||||
override fun getInflatedLayout() =
|
||||
FragmentInstallExternalGamesBinding.inflate(layoutInflater).apply { mBinding = this }.root
|
||||
|
||||
private lateinit var dialog: Dialog
|
||||
|
||||
|
||||
private val requestPermissionLauncher = registerForActivityResult<String, Boolean>(
|
||||
ActivityResultContracts.RequestPermission()
|
||||
) { result ->
|
||||
if (result == true) {
|
||||
// grant
|
||||
mViewModel.scanPaths()
|
||||
} else {
|
||||
// not grant
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setNavigationTitle(getString(com.gh.gamecenter.R.string.title_install_external_game))
|
||||
initView()
|
||||
mViewModel.gamesList.observe(this) {
|
||||
if (dialog.isShowing) {
|
||||
dialog.dismiss()
|
||||
}
|
||||
games.clear()
|
||||
games.addAll(
|
||||
it.map {
|
||||
ExternalGameUiState(it, VHelper.isInstalled(it.apkPackageName))
|
||||
}
|
||||
)
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
requestStoragePermission()
|
||||
}
|
||||
|
||||
private fun requestStoragePermission() {
|
||||
when {
|
||||
ContextCompat.checkSelfPermission(
|
||||
requireContext(),
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
) == PackageManager.PERMISSION_GRANTED -> {
|
||||
mViewModel.scanPaths()
|
||||
}
|
||||
|
||||
shouldShowRequestPermissionRationale(Manifest.permission.READ_EXTERNAL_STORAGE) -> {
|
||||
requestPermissionLauncher.launch(Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
}
|
||||
|
||||
else -> {
|
||||
requestPermissionLauncher.launch(Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun initView() {
|
||||
dialog = DialogUtils.showWaitDialog(requireContext(), "")
|
||||
mBinding.externalGamesList.let {
|
||||
it.adapter = adapter
|
||||
it.layoutManager = LinearLayoutManager(requireContext())
|
||||
val itemDecoration = HorizontalDividerItemDecoration.Builder(requireContext())
|
||||
.size(2F.dip2px())
|
||||
.color(R.color.ui_divider.toColor(requireContext()))
|
||||
.build()
|
||||
if (it.itemDecorationCount != 0) {
|
||||
it.removeItemDecorationAt(0)
|
||||
}
|
||||
it.addItemDecoration(itemDecoration)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (dialog.isShowing) {
|
||||
dialog.dismiss()
|
||||
}
|
||||
if (uninstallDisposable?.isDisposed != true) {
|
||||
uninstallDisposable?.dispose()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onItemClick(externalGameUiState: ExternalGameUiState, clickType: OnItemClickListener.ClickType) {
|
||||
when (clickType) {
|
||||
OnItemClickListener.ClickType.CLICK_INSTALL -> {
|
||||
install(externalGameUiState)
|
||||
}
|
||||
|
||||
OnItemClickListener.ClickType.CLICK_UNINSTALL -> {
|
||||
uninstall(externalGameUiState)
|
||||
}
|
||||
|
||||
OnItemClickListener.ClickType.CLICK_START -> {
|
||||
start(externalGameUiState)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun install(externalGameUiState: ExternalGameUiState) {
|
||||
|
||||
VHelper.disableLaunchGameAfterInstallation()
|
||||
VHelper.install(requireContext(), DownloadEntity().apply {
|
||||
externalGameUiState.externalGameEntity.apply {
|
||||
packageName = apkPackageName
|
||||
path = apkPath
|
||||
}
|
||||
}, true)
|
||||
|
||||
VHelper.newCwValidateVspaceBeforeAction(
|
||||
requireContext(),null,
|
||||
) {
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun uninstall(externalGameUiState: ExternalGameUiState) {
|
||||
dialog.show()
|
||||
uninstallDisposable = Single.create<Void> {
|
||||
VHelper.uninstall(externalGameUiState.externalGameEntity.apkPackageName)
|
||||
}.subscribeOn(Schedulers.from(AppExecutor.lightWeightIoExecutor)).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { t1, t2 ->
|
||||
if (dialog.isShowing) {
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun start(externalGameUiState: ExternalGameUiState) {
|
||||
val intent = VirtualAppManager.get().getStartGameIntent(
|
||||
externalGameUiState.externalGameEntity.apkPackageName,
|
||||
"",
|
||||
externalGameUiState.externalGameEntity.appName,
|
||||
"",
|
||||
MetaUtil.getBase64EncodedAndroidId(),
|
||||
HaloApp.getInstance().gid,
|
||||
com.gh.gamecenter.BuildConfig.VERSION_NAME,
|
||||
HaloApp.getInstance().channel,
|
||||
"",
|
||||
"",
|
||||
com.gh.gamecenter.BuildConfig.VA_VERSION_NAME,
|
||||
HaloApp.getInstance().oaid
|
||||
)
|
||||
intent.setComponent(
|
||||
ComponentName(
|
||||
com.gh.gamecenter.BuildConfig.APPLICATION_ID,
|
||||
VirtualAppManager.AIDL_SERVER_REMOTE_GUIDE_ACTIVITY
|
||||
)
|
||||
)
|
||||
requireActivity().startActivity(intent)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package com.gh.vspace.installexternalgames
|
||||
|
||||
import android.app.Application
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Environment
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.vspace.VHelper
|
||||
import com.lg.vspace.helper.compat.NativeLibraryHelperCompat
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
|
||||
class InstallExternalGameViewModel(application: Application) : AndroidViewModel(application) {
|
||||
private val _gamesList = MutableLiveData<List<ExternalGameEntity>>(listOf())
|
||||
val gamesList: LiveData<List<ExternalGameEntity>> = _gamesList
|
||||
private val pkgManger = getApplication<Application>().packageManager
|
||||
private var disposable: Disposable = VHelper.callSite.observeOn(AndroidSchedulers.mainThread()).subscribe {
|
||||
scanPaths()
|
||||
}
|
||||
|
||||
fun scanPaths() {
|
||||
runOnIoThread {
|
||||
_gamesList.postValue(Environment.getExternalStorageDirectory().walk().maxDepth(1)
|
||||
.filter { it.isHidden.not() }
|
||||
.filter { it.isFile }
|
||||
.onEach {
|
||||
Utils.log(Constants.TAG, "获得文件: ${it.name}")
|
||||
}
|
||||
.filter { it.extension == "apk" }
|
||||
.map {
|
||||
val packageInfo = pkgManger.getPackageArchiveInfo(
|
||||
it.absolutePath,
|
||||
PackageManager.GET_META_DATA or PackageManager.GET_ACTIVITIES
|
||||
)
|
||||
packageInfo?.let { packageInfo ->
|
||||
val applicationInfo = packageInfo.applicationInfo
|
||||
applicationInfo.publicSourceDir = it.absolutePath
|
||||
applicationInfo.sourceDir = it.absolutePath
|
||||
ExternalGameEntity(
|
||||
cpuAbi = NativeLibraryHelperCompat.getPackageAbiList(it.absolutePath),
|
||||
apkPath = it.absolutePath,
|
||||
apkFileName = it.name,
|
||||
apkPackageName = packageInfo.packageName,
|
||||
apkVersion = packageInfo.versionName,
|
||||
appName = pkgManger.getApplicationLabel(applicationInfo).toString(),
|
||||
lastModified = it.lastModified()
|
||||
)
|
||||
}
|
||||
}.filterNotNull()
|
||||
.toList().sortedByDescending { it.lastModified }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
disposable.dispose()
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.gh.vspace.installexternalgames
|
||||
|
||||
interface OnItemClickListener {
|
||||
|
||||
enum class ClickType {
|
||||
CLICK_INSTALL, CLICK_UNINSTALL, CLICK_START
|
||||
}
|
||||
|
||||
fun onItemClick(externalGameUiState: ExternalGameUiState, clickType: ClickType)
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/external_games_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
51
app/src/internal/res/layout/layout_external_game_item.xml
Normal file
51
app/src/internal/res/layout/layout_external_game_item.xml
Normal file
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/apk_file_info"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="20sp"
|
||||
tools:text="文件名:\n路径:" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_install"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/text_install"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_update"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/text_update"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_uninstall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/text_uninstall"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_start"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/text_start"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
8
app/src/internal/res/values-zh-rTW/strings.xml
Normal file
8
app/src/internal/res/values-zh-rTW/strings.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="title_install_external_game">從SD卡安裝</string>
|
||||
<string name="text_install">安裝</string>
|
||||
<string name="text_update">更新</string>
|
||||
<string name="text_uninstall">卸載</string>
|
||||
<string name="text_start">啟動</string>
|
||||
</resources>
|
||||
4
app/src/internal/res/values/ids.xml
Normal file
4
app/src/internal/res/values/ids.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<item name="install_game_from_external" type="id" />
|
||||
</resources>
|
||||
8
app/src/internal/res/values/strings.xml
Normal file
8
app/src/internal/res/values/strings.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="title_install_external_game">从SD卡安装</string>
|
||||
<string name="text_install">安装</string>
|
||||
<string name="text_update">更新</string>
|
||||
<string name="text_uninstall">卸载</string>
|
||||
<string name="text_start">启动</string>
|
||||
</resources>
|
||||
@ -12,6 +12,7 @@ import com.gh.gamecenter.core.utils.TimeUtils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.kwai.monitor.payload.TurboHelper
|
||||
import com.tencent.vasdolly.helper.ChannelReaderUtil
|
||||
|
||||
class FlavorProviderImp : IFlavorProvider {
|
||||
|
||||
@ -34,7 +35,11 @@ class FlavorProviderImp : IFlavorProvider {
|
||||
}
|
||||
|
||||
override fun getChannelStr(application: Application): String {
|
||||
var channel = TurboHelper.getChannel(application)
|
||||
var channel = if (BuildConfig.USE_DEFAULT_CHANNEL_SDK) {
|
||||
ChannelReaderUtil.getChannel(application)
|
||||
} else {
|
||||
TurboHelper.getChannel(application)
|
||||
}
|
||||
if (channel == null || TextUtils.isEmpty(channel.trim())) {
|
||||
channel = KUAISHOU_CHANNEL
|
||||
}
|
||||
|
||||
Binary file not shown.
BIN
app/src/kuaishou/libs/channelsdk-0.2.3.aar
Normal file
BIN
app/src/kuaishou/libs/channelsdk-0.2.3.aar
Normal file
Binary file not shown.
Binary file not shown.
BIN
app/src/kuaishou/libs/monitorsdk-1.0.15.aar
Normal file
BIN
app/src/kuaishou/libs/monitorsdk-1.0.15.aar
Normal file
Binary file not shown.
@ -9,8 +9,18 @@
|
||||
|
||||
<queries>
|
||||
<package android:name="com.lg.vspace" />
|
||||
<package android:name="com.gh.gamecenter.addon" />
|
||||
</queries>
|
||||
|
||||
<!-- 华为/荣耀角标 -->
|
||||
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE " />
|
||||
<uses-permission android:name="com.hihonor.android.launcher.permission.CHANGE_BADGE" />
|
||||
<!-- vivo角标 -->
|
||||
<uses-permission android:name="com.vivo.notification.permission.BADGE_ICON" />
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
|
||||
tools:ignore="ScopedStorage" />
|
||||
<!-- 允许应用程序访问网络连接 -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<!-- 允许应用程序写入外部存储,如SD卡上写文件 -->
|
||||
@ -31,7 +41,7 @@
|
||||
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
||||
<!-- 应用安装相关 -->
|
||||
<uses-permission android:name="com.android.permission.GET_INSTALLED_APPS" />
|
||||
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
|
||||
<!-- 前台服务权限-->
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
|
||||
@ -46,6 +56,9 @@
|
||||
<!-- 如果有视频相关的广告且使用textureView播放,请务必添加,否则黑屏 -->
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
<!-- 悬浮窗 -->
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
|
||||
<uses-sdk tools:overrideLibrary="
|
||||
com.shuyu.gsyvideoplayer,
|
||||
com.shuyu.gsyvideoplayer.lib,
|
||||
@ -77,7 +90,40 @@
|
||||
androidx.compose.animation.core,
|
||||
androidx.constraintlayout.compose,
|
||||
androidx.compose.ui.test.manifest,
|
||||
androidx.compose.ui.tooling.preview" />
|
||||
com.bytedance.sdk.openadsdk,
|
||||
com.bykv.vk.openvk,
|
||||
com.bytedance.tools,
|
||||
androidx.compose.ui.tooling.preview,
|
||||
com.tencent.qqmini,
|
||||
com.tencent.qqmini.minigame.external,
|
||||
com.tencent.qqmini.minigame.opensdk,
|
||||
com.tencent.qqmini.union.ad,
|
||||
com.lg.vspace,
|
||||
io.lg.va.common,
|
||||
com.va.floating,
|
||||
com.lg.cloud,
|
||||
com.lg.archive,
|
||||
com.lg.vclient,
|
||||
com.va.realname,
|
||||
com.lg.vspace.flavor,
|
||||
com.lg.update,
|
||||
com.lg.login,
|
||||
com.lg.accelerator,
|
||||
com.lody.virtual,
|
||||
com.lg.core,
|
||||
com.lg.ads,
|
||||
com.lg.common,
|
||||
com.lg.vspace.network,
|
||||
com.lody.virtual.lib.res,
|
||||
com.va.host,
|
||||
com.lg.vspace.plugin.host,
|
||||
com.lg.plugin.constant,
|
||||
com.bytedance.tools.codelocator,
|
||||
org.chickenhook.restrictionbypass,
|
||||
com.lody.virtual.sandhook,
|
||||
com.lg.vspace.common,
|
||||
com.lg.vspace.archive.common,
|
||||
com.wy.lib.wytrace" />
|
||||
|
||||
<!-- 去掉 SDK 一些流氓权限 -->
|
||||
<uses-permission
|
||||
@ -92,6 +138,18 @@
|
||||
android:name="android.permission.GET_TASKS"
|
||||
tools:node="remove" />
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.ACCESS_COARSE_LOCATION"
|
||||
tools:node="remove" />
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.ACCESS_BACKGROUND_LOCATION"
|
||||
tools:node="remove" />
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.ACCESS_FINE_LOCATION"
|
||||
tools:node="remove" />
|
||||
|
||||
<supports-screens
|
||||
android:anyDensity="true"
|
||||
android:largeScreens="true"
|
||||
@ -107,10 +165,12 @@
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:preserveLegacyExternalStorage="true"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:resizeableActivity="true"
|
||||
android:theme="@style/AppCompatTheme.APP"
|
||||
tools:replace="android:name,android:allowBackup"
|
||||
tools:targetApi="n">
|
||||
tools:targetApi="r">
|
||||
|
||||
<meta-data
|
||||
android:name="EasyGoClient"
|
||||
@ -125,6 +185,8 @@
|
||||
android:name="io.sentry.breadcrumbs.system-events"
|
||||
android:value="false" />
|
||||
|
||||
<meta-data android:name="module_version" android:value="${VA_VERSION_NAME}" />
|
||||
|
||||
<service android:name="com.gh.ndownload.NDownloadService" />
|
||||
|
||||
<activity
|
||||
@ -183,7 +245,7 @@
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.NewsDetailActivity"
|
||||
android:name="com.gh.gamecenter.newsdetail.NewsDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
@ -238,7 +300,7 @@
|
||||
android:windowSoftInputMode="stateHidden" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.LibaoDetailActivity"
|
||||
android:name="com.gh.gamecenter.libao.LibaoDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
@ -249,10 +311,6 @@
|
||||
android:name="com.gh.gamecenter.CleanApkActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.SelectUserIconActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.CommentDetailActivity"
|
||||
android:screenOrientation="portrait"
|
||||
@ -270,21 +328,13 @@
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.VoteActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustResize" />
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.WeiBoShareActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden" />
|
||||
|
||||
<activity
|
||||
android:name=".category.CategoryDirectoryActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".category.CategoryListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.UserInfoActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -297,51 +347,19 @@
|
||||
android:name="com.gh.gamecenter.CollectionActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.MessageActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.UserInfoEditActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.qa.answer.detail.AnswerDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.qa.answer.edit.AnswerEditActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.ConcernInfoActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.InfoActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.MessageKeFuActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.MessageInviteActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.MessageVoteActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".qa.questions.invite.QuestionsInviteActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.qa.myqa.MyAskActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.qa.questions.edit.QuestionEditActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -379,10 +397,6 @@
|
||||
android:name="com.gh.gamecenter.qa.article.edit.ArticleEditActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.qa.article.MyArticleActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.qa.article.draft.ArticleDraftActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -421,10 +435,6 @@
|
||||
android:name="com.gh.gamecenter.history.HistoryActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.personalhome.rating.RatingActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.gamedetail.rating.logs.CommentLogsActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -446,9 +456,6 @@
|
||||
android:name="com.gh.gamecenter.video.game.GameVideoActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.qa.editor.LocalMediaActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.servers.GameServersActivity"
|
||||
@ -481,17 +488,19 @@
|
||||
android:configChanges="orientation|screenSize|keyboardHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/TransparentStatusBarAndNavigationBar" />
|
||||
<activity
|
||||
android:name=".gamedetail.myrating.MyRatingActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.gamedetail.fuli.kaifu.ServersCalendarActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".qa.answer.draft.AnswerDraftActivity"
|
||||
android:name=".gamedetail.fuli.kaifu.ServersCalendarManagementActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".gamedetail.fuli.kaifu.ServersSubscribedGameListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".gamedetail.rating.RatingFoldActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -503,10 +512,6 @@
|
||||
android:name=".video.poster.PosterEditActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".video.poster.PosterClipActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".forum.detail.ForumDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -548,14 +553,6 @@
|
||||
android:name=".simulatorgame.SimulatorManagementActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".catalog.CatalogActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".catalog.NewCatalogListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".forum.search.ForumOrUserSearchActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -576,10 +573,6 @@
|
||||
android:name=".personal.DeliveryInfoActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".qa.editor.PreviewVideoActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".qa.video.publish.VideoPublishActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -612,6 +605,10 @@
|
||||
android:name=".game.commoncollection.detail.CommonCollectionDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".game.commoncollection.detail.CustomCommonCollectionDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".gamecollection.detail.GameCollectionDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -703,7 +700,7 @@
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.toolbox.ToolBoxBlockActivity"
|
||||
android:name="com.gh.gamecenter.toolbox.ToolBoxActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
@ -760,6 +757,42 @@
|
||||
android:name="com.gh.gamecenter.gamecollection.hotlist.GameCollectionHotListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.minigame.qq.QGameHomeWrapperActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.minigame.MiniGameSearchActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.gamecollection.hotlist.GameCollectionListDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.UserAuthActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.SplashAdActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.wrapper.ToolbarWrapperActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".forum.home.CommunityActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".forum.home.follow.FollowDynamicActivity"
|
||||
android:theme="@style/Theme.Transparent" />
|
||||
|
||||
<activity
|
||||
android:name=".forum.home.follow.AllFollowedActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppCompatTheme.APP" />
|
||||
|
||||
<!-- <activity-->
|
||||
<!-- android:name="${applicationId}.douyinapi.DouYinEntryActivity"-->
|
||||
@ -771,7 +804,8 @@
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
android:grantUriPermissions="true"
|
||||
tools:replace="android:authorities">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/provider_paths" />
|
||||
@ -815,6 +849,10 @@
|
||||
<!-- tools:node="remove" />-->
|
||||
<!-- </provider>-->
|
||||
|
||||
<service android:name="com.gh.gamecenter.install.InstallService" />
|
||||
|
||||
<service android:name="com.gh.download.suspendwindow.DownloadSuspendWindowService" />
|
||||
|
||||
<receiver
|
||||
android:name="com.gh.gamecenter.receiver.DownloadReceiver"
|
||||
android:exported="false">
|
||||
@ -832,8 +870,8 @@
|
||||
|
||||
<activity
|
||||
android:name="com.gh.common.xapk.XapkInstallReceiver"
|
||||
android:theme="@style/Theme.Transparent"
|
||||
android:exported="false" />
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.Transparent" />
|
||||
|
||||
<receiver
|
||||
android:name="com.gh.gamecenter.receiver.ActivitySkipReceiver"
|
||||
@ -842,40 +880,6 @@
|
||||
<action android:name="com.gh.gamecenter.ACTIVITYSKIP" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- 梦工厂配置 开始 -->
|
||||
<!--<meta-data
|
||||
android:name="MGC_APPID"
|
||||
android:value="1001276" />
|
||||
|
||||
<provider
|
||||
android:name="com.leto.game.base.provider.LetoFileProvider"
|
||||
android:authorities="${applicationId}.leto.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/leto_file_path"
|
||||
tools:replace="android:resource" />
|
||||
</provider>-->
|
||||
<!-- 梦工厂配置 结束 -->
|
||||
|
||||
<!-- 穿山甲配置 开始 -->
|
||||
<!--<provider
|
||||
android:name="com.bytedance.sdk.openadsdk.TTFileProvider"
|
||||
android:authorities="${applicationId}.TTFileProvider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
|
||||
<provider
|
||||
android:name="com.bytedance.sdk.openadsdk.multipro.TTMultiProvider"
|
||||
android:authorities="${applicationId}.TTMultiProvider"
|
||||
android:exported="false" />-->
|
||||
<!-- 穿山甲配置 结束 -->
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@ -6,8 +6,6 @@
|
||||
<link rel="stylesheet" type="text/css" href="normalize.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<link rel="stylesheet" type="text/css" href="video-js.min.css">
|
||||
<!-- <link rel="stylesheet" href="https://static-web.ghzs.com/website-static/lib/video-js.min.css">--> <!--在web页面播放视频-->
|
||||
<!--<link rel="stylesheet" type="text/css" href="https://resource.ghzs.com/css/halo_app.css">-->
|
||||
</head>
|
||||
|
||||
<body style="overflow-x: hidden; word-break: break-all;">
|
||||
@ -15,8 +13,5 @@
|
||||
<script type="text/javascript" src="zepto.min.js"></script>
|
||||
<script type="text/javascript" src="rich_editor.js"></script>
|
||||
<script type="text/javascript" src="video.min.js"></script>
|
||||
<!--<script src="https://static-web.ghzs.com/website-static/lib/video.min.js"></script>--> <!--在web页面播放视频-->
|
||||
<!--<script type="text/javascript" src="content.js"></script>-->
|
||||
<!--<script type="text/javascript" src="https://resource.ghzs.com/js/halo_app.js"></script>-->
|
||||
</body>
|
||||
</html>
|
||||
|
||||
1
app/src/main/assets/lottie/draw_overlay_permission.json
Normal file
1
app/src/main/assets/lottie/draw_overlay_permission.json
Normal file
File diff suppressed because one or more lines are too long
1
app/src/main/assets/lottie/tab_mine.json
Normal file
1
app/src/main/assets/lottie/tab_mine.json
Normal file
@ -0,0 +1 @@
|
||||
{"v":"5.12.2","fr":60,"ip":0,"op":40,"w":66,"h":66,"nm":"icon_tab_my","ddd":0,"assets":[{"id":"comp_0","nm":"icon","fr":60,"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"highlight","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[33.134,34.5,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":1,"k":[{"i":{"x":0.667,"y":0.733},"o":{"x":0.333,"y":0},"t":0,"s":[{"i":[[0,-0.004],[0.493,0],[0,0.004],[-0.493,0]],"o":[[0,0.004],[-0.493,0],[0,-0.004],[0.493,0]],"v":[[0.893,1.488],[0,1.496],[-0.893,1.488],[0,1.483]],"c":true}]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0.267},"t":10,"s":[{"i":[[0,-1.018],[1.793,0],[0,1.018],[-1.793,0]],"o":[[0,1.018],[-1.793,0],[0,-1.018],[1.793,0]],"v":[[2.914,-0.344],[0,1.5],[-2.914,-0.344],[0,-1.5]],"c":true}]},{"i":{"x":0.333,"y":1},"o":{"x":0.667,"y":0},"t":18,"s":[{"i":[[0,-1.181],[1.407,0],[0,1.181],[-1.407,0]],"o":[[0,1.181],[-1.407,0],[0,-1.181],[1.407,0]],"v":[[2.226,-0.341],[0,1.74],[-2.211,-0.341],[0,-1.74]],"c":true}]},{"i":{"x":0.333,"y":1},"o":{"x":0.667,"y":0},"t":26,"s":[{"i":[[0,-0.905],[1.381,0],[0,0.905],[-1.381,0]],"o":[[0,0.905],[-1.381,0],[0,-0.905],[1.381,0]],"v":[[2.5,-0.306],[0,1.333],[-2.5,-0.306],[0,-1.333]],"c":true}]},{"t":32,"s":[{"i":[[0,-1.018],[1.381,0],[0,1.018],[-1.381,0]],"o":[[0,1.018],[-1.381,0],[0,-1.018],[1.381,0]],"v":[[2.5,-0.344],[0,1.5],[-2.5,-0.344],[0,-1.5]],"c":true}]}],"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"color","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"椭圆形","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":60,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"body","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[33,34.204,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-3.866,0],[0,3.866],[3.866,0],[0,-3.866]],"o":[[3.866,0],[0,-3.866],[-3.866,0],[0,3.866]],"v":[[0,4.599],[7,-2.401],[0,-9.401],[-7,-2.401]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0.207,0.359],[2.438,0],[1.189,-2.104],[-0.361,-0.204],[-0.204,0.361],[-1.915,0],[-0.932,-1.613],[-0.359,0.207]],"o":[[-1.198,-2.072],[-2.462,0],[-0.204,0.361],[0.361,0.204],[0.925,-1.638],[1.897,0],[0.207,0.359],[0.359,-0.207]],"v":[[5.848,8.225],[0,4.849],[-5.88,8.282],[-5.596,9.304],[-4.574,9.02],[0,6.349],[4.549,8.976],[5.574,9.25]],"c":true},"ix":2},"nm":"路径 2","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"mm","mm":1,"nm":"合并路径 1","mn":"ADBE Vector Filter - Merge","hd":false},{"ty":"gf","o":{"a":0,"k":100,"ix":10},"r":1,"bm":0,"g":{"p":3,"k":{"a":0,"k":[0,0.267,0.639,1,0.5,0.241,0.596,1,1,0.216,0.553,1],"ix":9}},"s":{"a":0,"k":[-3.812,-4.384],"ix":5},"e":{"a":0,"k":[6.345,8.129],"ix":6},"t":1,"nm":"color","mn":"ADBE Vector Graphic - G-Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"Union","np":4,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":60,"st":0,"ct":1,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"icon","refId":"comp_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[33,33,0],"ix":2,"l":2},"a":{"a":0,"k":[33,33,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":0,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":8,"s":[70,70,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":18,"s":[110,110,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":26,"s":[90,90,100]},{"t":32,"s":[100,100,100]}],"ix":6,"l":2}},"ao":0,"w":66,"h":66,"ip":0,"op":60,"st":0,"bm":0}],"markers":[],"props":{}}
|
||||
1
app/src/main/assets/lottie/video.json
Normal file
1
app/src/main/assets/lottie/video.json
Normal file
File diff suppressed because one or more lines are too long
@ -34,18 +34,18 @@ try {
|
||||
var script = document.createElement("script")
|
||||
document.body.appendChild(script)
|
||||
if (isDebug) {
|
||||
script.src = "https://resource.ghzs.com/js/halo_app_test.js" + "?timestamp=" + Math.round(new Date().getTime() / 1000)
|
||||
script.src = "https://dev-and-static.ghzs66.com/web/js/halo.js" + "?timestamp=" + Math.round(new Date().getTime() / 1000)
|
||||
} else {
|
||||
script.src = "https://resource.ghzs.com/js/halo.js" + "?timestamp=" + Math.round(new Date().getTime() / 1000 / 1000)
|
||||
script.src = "https://and-static.ghzs66.com/web/js/halo.js" + "?timestamp=" + Math.round(new Date().getTime() / 1000 / 1000)
|
||||
}
|
||||
|
||||
var style = document.createElement("link")
|
||||
style.rel = "stylesheet"
|
||||
style.type = "text/css"
|
||||
if (isDebug) {
|
||||
style.href = "https://resource.ghzs.com/css/halo_app_test.css" + "?timestamp=" + Math.round(new Date().getTime() / 1000)
|
||||
style.href = "https://dev-and-static.ghzs66.com/web/css/halo.css" + "?timestamp=" + Math.round(new Date().getTime() / 1000)
|
||||
} else {
|
||||
style.href = "https://resource.ghzs.com/css/halo.css" + "?timestamp=" + Math.round(new Date().getTime() / 1000 / 1000)
|
||||
style.href = "https://and-static.ghzs66.com/web/css/halo.css" + "?timestamp=" + Math.round(new Date().getTime() / 1000 / 1000)
|
||||
}
|
||||
|
||||
document.head.appendChild(style)
|
||||
@ -205,14 +205,17 @@ RE.setOutdent = function() {
|
||||
|
||||
RE.setJustifyLeft = function() {
|
||||
document.execCommand('justifyLeft', false, null);
|
||||
RE.enabledEditingItems()
|
||||
}
|
||||
|
||||
RE.setJustifyCenter = function() {
|
||||
document.execCommand('justifyCenter', false, null);
|
||||
RE.enabledEditingItems()
|
||||
}
|
||||
|
||||
RE.setJustifyRight = function() {
|
||||
document.execCommand('justifyRight', false, null);
|
||||
RE.enabledEditingItems()
|
||||
}
|
||||
|
||||
RE.setBlockquote = function() {
|
||||
@ -227,6 +230,16 @@ RE.insertImage = function(url) {
|
||||
RE.insertHTML(html);
|
||||
}
|
||||
|
||||
// 设置分割线
|
||||
RE.insertHorizontalRule = function() {
|
||||
document.execCommand('insertHorizontalRule', false, null);
|
||||
}
|
||||
|
||||
// 设置编辑器默认换行符
|
||||
RE.setDefaultParagraphSeparator = function(separator) {
|
||||
document.execCommand('defaultParagraphSeparator', false, separator);
|
||||
}
|
||||
|
||||
// 替换成缩略图
|
||||
RE.replaceTbImage = function(imgRuleFlag, gifRuleFlag) {
|
||||
var imgs = document.getElementsByTagName("img");
|
||||
@ -574,6 +587,10 @@ document.addEventListener("selectionchange", function(e) {
|
||||
RE.sendElementNameToNative()
|
||||
});
|
||||
|
||||
document.addEventListener("selectionchange", function(e) {
|
||||
RE.enabledEditingItems(e)
|
||||
});
|
||||
|
||||
RE.recursion = function(dom) {
|
||||
var parenDom = dom.parentElement
|
||||
if (parenDom && parenDom instanceof Element &&
|
||||
@ -616,7 +633,6 @@ RE.sendElementNameToNative = function() {
|
||||
// android function to open link
|
||||
function customLinkgo(self) {
|
||||
var datas = self.dataset.datas
|
||||
// console.log(datas)
|
||||
window.OnLinkClickListener.onClick(datas)
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,6 @@ body {
|
||||
}
|
||||
|
||||
#editor {
|
||||
display: table-cell;
|
||||
outline: 0px solid transparent;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 19 KiB |
731
app/src/main/java/com/gh/ad/AdDelegateHelper.kt
Normal file
731
app/src/main/java/com/gh/ad/AdDelegateHelper.kt
Normal file
@ -0,0 +1,731 @@
|
||||
package com.gh.ad
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Message
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.gh.common.exposure.ExposureManager
|
||||
import com.gh.common.util.DirectUtils.directToLinkPage
|
||||
import com.gh.common.util.LogUtils
|
||||
import com.gh.common.util.NewFlatLogUtils.logOpenScreenAdSkip
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.exposure.ExposureSource
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.provider.ICsjAdProvider
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.TimeUtils.getToday
|
||||
import com.gh.gamecenter.entity.AdConfig
|
||||
import com.gh.gamecenter.entity.StartupAdEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent.Companion.createEvent
|
||||
import com.gh.gamecenter.feature.exposure.ExposureType
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
/**
|
||||
* 广告实现代理类
|
||||
*
|
||||
* 由它来分发功能实现到具体的实现
|
||||
*
|
||||
* 以开屏广告为例,有两种实现(1. 自有的广告实现 2. 穿山甲的开屏广告实现 )
|
||||
*/
|
||||
object AdDelegateHelper {
|
||||
|
||||
private var mCsjAdImpl: ICsjAdProvider? = null
|
||||
|
||||
private val mAdConfigList: ArrayList<AdConfig> by lazy { arrayListOf() }
|
||||
|
||||
private var mSplashAd: AdConfig? = null
|
||||
private var mDownloadManagerAd: AdConfig? = null
|
||||
private val mGameSearchAdList: ArrayList<AdConfig> by lazy { arrayListOf() }
|
||||
private var mVGameLaunchAd: AdConfig? = null
|
||||
|
||||
val vGameLaunchAd: AdConfig?
|
||||
get() = mVGameLaunchAd
|
||||
|
||||
val splashAdDisplayInterval: Int
|
||||
get() = mSplashAd?.ownerAd?.startAd?.displayInterval ?: 3
|
||||
|
||||
private const val AD_SDK_CSJ = "穿山甲"
|
||||
const val AD_TYPE_SDK = "third_party_ads" // 第三方 SDK 广告
|
||||
const val AD_TYPE_OWNER = "owner_ads" // 自有广告
|
||||
|
||||
private const val KEY_CACHE_CONFIG = "cache_config" // 放在 SP 里的广告缓存(避免接口加载问题)
|
||||
|
||||
private val mAdConfigSp: SharedPreferences by lazy {
|
||||
HaloApp.getInstance().getSharedPreferences("AdConfig", Context.MODE_PRIVATE)
|
||||
}
|
||||
|
||||
var isShowingSplashAd = false // 是否正在显示开屏广告
|
||||
var gameSearchKeyword = ""
|
||||
|
||||
fun initAdSdk(context: Context) {
|
||||
// 初始化穿山甲
|
||||
if (mCsjAdImpl == null) {
|
||||
mCsjAdImpl =
|
||||
ARouter.getInstance().build(RouteConsts.provider.csjAd).navigation() as? ICsjAdProvider
|
||||
val csjAppId = if (EnvHelper.isDevEnv) BuildConfig.DEV_CSJ_APPID else BuildConfig.CSJ_APPID
|
||||
mCsjAdImpl?.initSDK(context, csjAppId, HaloApp.getInstance().oaid)
|
||||
// 监听亮色/暗色模式切换
|
||||
DarkModeUtils.registerModeChangeListener {
|
||||
val topActivity = CurrentActivityHolder.getCurrentActivity() ?: return@registerModeChangeListener
|
||||
updateThemeStatus(context, DarkModeUtils.isDarkModeOn(topActivity))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求接口获取广告相关配置
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
fun requestAdConfig(isFromRetry: Boolean, keyword: String = "", callback: (() -> Unit)? = null) {
|
||||
// mAdConfigList 不为空不需要重试
|
||||
if (isFromRetry && mAdConfigList.isNotEmpty()) {
|
||||
return
|
||||
}
|
||||
val paramsMap = if (keyword.isNotEmpty()) mapOf("keyword" to keyword) else mapOf()
|
||||
RetrofitManager.getInstance()
|
||||
.newApi
|
||||
.getAdConfig(paramsMap)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<List<AdConfig>>() {
|
||||
override fun onSuccess(data: List<AdConfig>) {
|
||||
gameSearchKeyword = keyword
|
||||
handleAdConfig(data)
|
||||
callback?.invoke()
|
||||
|
||||
// 缓存数据到 SP 供接口请求失败用
|
||||
SPUtils.setString(mAdConfigSp, KEY_CACHE_CONFIG, data.toJson())
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
|
||||
// 若接口请求失败时,从 SP 里获取上次缓存的数据
|
||||
val cachedConfig: List<AdConfig>? = SPUtils.getString(mAdConfigSp, KEY_CACHE_CONFIG).toObject()
|
||||
if (cachedConfig != null && mAdConfigList.isEmpty()) {
|
||||
handleAdConfig(cachedConfig)
|
||||
}
|
||||
|
||||
callback?.invoke()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取搜索页的广告列表
|
||||
*/
|
||||
fun getGameSearchAdList(): ArrayList<AdConfig> {
|
||||
return mGameSearchAdList
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下载管理页的广告
|
||||
*/
|
||||
fun getDownloadManagerAd(): AdConfig? {
|
||||
return mDownloadManagerAd
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理广告配置
|
||||
*/
|
||||
fun handleAdConfig(configList: List<AdConfig>) {
|
||||
mAdConfigList.clear()
|
||||
mGameSearchAdList.clear()
|
||||
mSplashAd = null
|
||||
mDownloadManagerAd = null
|
||||
mVGameLaunchAd = null
|
||||
for (config in configList) {
|
||||
mAdConfigList.add(config)
|
||||
// 处理返回的数据
|
||||
when (config.location) {
|
||||
"halo_launch" -> {
|
||||
config.ownerAd?.startAd?.let { it.id = config.ownerAd.id }
|
||||
mSplashAd = config
|
||||
}
|
||||
|
||||
"download_manager" -> mDownloadManagerAd = config
|
||||
"game_search" -> config.let { mGameSearchAdList.add(it) }
|
||||
"helper_launch" -> mVGameLaunchAd = config
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否需要显示开屏广告
|
||||
* @param isHotLaunch 是否为热启动
|
||||
*/
|
||||
fun shouldShowStartUpAd(isHotLaunch: Boolean): Boolean {
|
||||
return mSplashAd != null
|
||||
&& !isShowingSplashAd
|
||||
&& (!isHotLaunch || shouldShowStartUpAdWhenHotLaunch())
|
||||
&& !isMatchAdFreeRule(mSplashAd)
|
||||
&& isMatchStartUpAdDisplayRule()
|
||||
}
|
||||
|
||||
/**
|
||||
* 热启动是否需要显示开屏广告(目前只展示第三方广告)
|
||||
*/
|
||||
private fun shouldShowStartUpAdWhenHotLaunch() = (mCsjAdImpl != null)
|
||||
&& mSplashAd?.displayRule?.hotStartSplashAd?.type == AD_TYPE_SDK
|
||||
&& mSplashAd?.hotStartThirdPartyAd != null
|
||||
|
||||
/**
|
||||
* 是否需要显示下载管理广告
|
||||
*/
|
||||
fun shouldShowDownloadManagerAd(): Boolean {
|
||||
return mDownloadManagerAd != null && !isMatchAdFreeRule(mDownloadManagerAd) && isMatchDownloadManagerAdDisplayRule()
|
||||
}
|
||||
|
||||
fun shouldShowHelperLaunchAd(): Boolean {
|
||||
return mVGameLaunchAd != null && !isMatchAdFreeRule(mVGameLaunchAd) && isMatchAdDisplayRule(mVGameLaunchAd, Constants.SP_LAST_HELPER_LAUNCH_AD_SHOW_TIME)
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否需要显示游戏搜索广告
|
||||
*/
|
||||
fun shouldShowGameSearchAd(adConfig: AdConfig): Boolean {
|
||||
return !isMatchAdFreeRule(adConfig) && isMatchGameSearchAdDisplayRule(adConfig)
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否在免广告时长内
|
||||
*/
|
||||
private fun isMatchAdFreeRule(adConfig: AdConfig?): Boolean {
|
||||
adConfig?.displayRule?.run {
|
||||
if (adFreeDuration > 0) {
|
||||
val ghInstalledDurationInHours = (System.currentTimeMillis() - PackageUtils.getInstalledTime(
|
||||
HaloApp.getInstance(),
|
||||
BuildConfig.APPLICATION_ID
|
||||
)).toFloat() / 1000 / 3600
|
||||
return ghInstalledDurationInHours < adFreeDuration
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否大于开屏广告展示间隔时长
|
||||
*/
|
||||
private fun isMatchStartUpAdDisplayRule(): Boolean = isMatchAdDisplayRule(mSplashAd, Constants.SP_LAST_SPLASH_AD_SHOW_TIME)
|
||||
|
||||
/**
|
||||
* 是否大于广告管理展示间隔时长
|
||||
*/
|
||||
private fun isMatchDownloadManagerAdDisplayRule(): Boolean = isMatchAdDisplayRule(mDownloadManagerAd, Constants.SP_LAST_DOWNLOAD_MANAGER_AD_SHOW_TIME)
|
||||
private fun isMatchAdDisplayRule(adConfig: AdConfig?, spKey: String): Boolean {
|
||||
adConfig?.displayRule?.run {
|
||||
if (adDisplayInterval > 0) {
|
||||
val lastShowTime = SPUtils.getLong(spKey, 0L)
|
||||
val durationInMinutes = (System.currentTimeMillis() - lastShowTime).toFloat() / 1000 / 60
|
||||
return durationInMinutes > adDisplayInterval
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否大于游戏搜索展示间隔时长
|
||||
*/
|
||||
private fun isMatchGameSearchAdDisplayRule(adConfig: AdConfig?): Boolean {
|
||||
adConfig?.displayRule?.run {
|
||||
if (adDisplayInterval > 0) {
|
||||
val lastShowTime = SPUtils.getLong(Constants.SP_LAST_GAME_SEARCH_AD_SHOW_TIME + adConfig.position, 0L)
|
||||
val durationInMinutes = (System.currentTimeMillis() - lastShowTime).toFloat() / 1000 / 60
|
||||
return durationInMinutes > adDisplayInterval
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新主题样式
|
||||
*/
|
||||
private fun updateThemeStatus(context: Context, isDarkMode: Boolean) {
|
||||
mCsjAdImpl?.updateThemeStatus(context, isDarkMode)
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求开屏广告
|
||||
*/
|
||||
@JvmStatic
|
||||
fun requestSplashAd(
|
||||
activity: Activity,
|
||||
adViewWidthInPx: Int,
|
||||
adViewHeightInPx: Int,
|
||||
adViewWidthInDp: Float,
|
||||
adViewHeightInDp: Float,
|
||||
startAdContainer: ViewGroup,
|
||||
sdkStartAdContainer: ViewGroup,
|
||||
sdkJumpBtn: TextView,
|
||||
adsViewGroup: FrameLayout,
|
||||
handler: BaseActivity.BaseHandler,
|
||||
isHotLaunch: Boolean,
|
||||
hideAction: () -> Unit
|
||||
) {
|
||||
val hideCallback = {
|
||||
isShowingSplashAd = false
|
||||
hideAction.invoke()
|
||||
}
|
||||
if (mSplashAd != null) {
|
||||
when (if (isHotLaunch) mSplashAd!!.displayRule.hotStartSplashAd?.type else mSplashAd!!.displayRule.adSource) {
|
||||
AD_TYPE_SDK -> {
|
||||
isShowingSplashAd = true
|
||||
requestThirdPartySplashAd(
|
||||
activity,
|
||||
adViewWidthInPx,
|
||||
adViewHeightInPx,
|
||||
adViewWidthInDp,
|
||||
adViewHeightInDp,
|
||||
startAdContainer,
|
||||
sdkStartAdContainer,
|
||||
sdkJumpBtn,
|
||||
adsViewGroup,
|
||||
handler,
|
||||
isHotLaunch,
|
||||
hideCallback
|
||||
)
|
||||
}
|
||||
|
||||
AD_TYPE_OWNER -> {
|
||||
isShowingSplashAd = true
|
||||
requestStandardSplashAd(
|
||||
activity,
|
||||
adViewWidthInPx,
|
||||
adViewHeightInPx,
|
||||
adViewWidthInDp,
|
||||
adViewHeightInDp,
|
||||
startAdContainer,
|
||||
sdkStartAdContainer,
|
||||
sdkJumpBtn,
|
||||
adsViewGroup,
|
||||
handler,
|
||||
isHotLaunch,
|
||||
hideCallback
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
hideCallback.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取第三方开屏广告
|
||||
*/
|
||||
private fun requestThirdPartySplashAd(
|
||||
activity: Activity,
|
||||
adViewWidthInPx: Int,
|
||||
adViewHeightInPx: Int,
|
||||
adViewWidthInDp: Float,
|
||||
adViewHeightInDp: Float,
|
||||
startAdContainer: ViewGroup,
|
||||
sdkStartAdContainer: ViewGroup,
|
||||
sdkJumpBtn: TextView,
|
||||
adsViewGroup: FrameLayout,
|
||||
handler: BaseActivity.BaseHandler,
|
||||
isHotLaunch: Boolean,
|
||||
hideCallback: () -> Unit
|
||||
) {
|
||||
// 第三方开屏广告回调,失败时根据接口配置选项决定是否显示自有开屏广告
|
||||
val sdkSplashCallback: (isSuccess: Boolean) -> Unit = { isSuccess ->
|
||||
if (isSuccess) {
|
||||
hideCallback.invoke()
|
||||
SPUtils.setLong(Constants.SP_LAST_SPLASH_AD_SHOW_TIME, System.currentTimeMillis())
|
||||
} else {
|
||||
if (mSplashAd?.displayRule?.adSource == AD_TYPE_SDK && mSplashAd?.displayRule?.onFailedAction == "show" && !isHotLaunch) {
|
||||
sdkStartAdContainer.visibility = View.GONE
|
||||
requestStandardSplashAd(
|
||||
activity,
|
||||
adViewWidthInPx,
|
||||
adViewHeightInPx,
|
||||
adViewWidthInDp,
|
||||
adViewHeightInDp,
|
||||
startAdContainer,
|
||||
sdkStartAdContainer,
|
||||
sdkJumpBtn,
|
||||
adsViewGroup,
|
||||
handler,
|
||||
isHotLaunch,
|
||||
hideCallback
|
||||
)
|
||||
} else {
|
||||
hideCallback.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val thirdPartyAd = if (isHotLaunch) mSplashAd?.hotStartThirdPartyAd else mSplashAd?.thirdPartyAd
|
||||
|
||||
// 第三方广告的数据为空,按加载失败处理
|
||||
if (mSplashAd == null || thirdPartyAd == null) {
|
||||
sdkSplashCallback.invoke(false)
|
||||
return
|
||||
}
|
||||
|
||||
val timeout = if (isHotLaunch) {
|
||||
((mSplashAd?.displayRule?.hotStartSplashAd?.timeout ?: 3.5F) * 1000).toInt()
|
||||
} else {
|
||||
((mSplashAd?.displayRule?.timeout ?: 3.5F) * 1000).toInt()
|
||||
}
|
||||
|
||||
if (thirdPartyAd.sourceName == AD_SDK_CSJ) {
|
||||
sdkStartAdContainer.visibility = View.VISIBLE
|
||||
requestCsjSplashAd(
|
||||
activity,
|
||||
adViewWidthInPx,
|
||||
adViewHeightInPx,
|
||||
adViewWidthInDp,
|
||||
adViewHeightInDp,
|
||||
sdkStartAdContainer,
|
||||
sdkJumpBtn,
|
||||
timeout,
|
||||
isHotLaunch,
|
||||
sdkSplashCallback
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取穿山甲的开屏广告
|
||||
*/
|
||||
private fun requestCsjSplashAd(
|
||||
activity: Activity,
|
||||
adViewWidthInPx: Int,
|
||||
adViewHeightInPx: Int,
|
||||
adViewWidthInDp: Float,
|
||||
adViewHeightInDp: Float,
|
||||
startAdContainer: ViewGroup,
|
||||
sdkJumpBtn: TextView,
|
||||
timeout: Int,
|
||||
isHotLaunch: Boolean,
|
||||
callback: (isSuccess: Boolean) -> Unit,
|
||||
) {
|
||||
val thirdPartyAd = if (isHotLaunch) mSplashAd?.hotStartThirdPartyAd else mSplashAd?.thirdPartyAd
|
||||
if (mCsjAdImpl == null || thirdPartyAd == null) {
|
||||
callback.invoke(false)
|
||||
} else {
|
||||
sdkJumpBtn.setOnClickListener {
|
||||
callback.invoke(true)
|
||||
if (activity is BaseActivity) {
|
||||
activity.baseHandler.removeMessages(MainActivity.COUNTDOWN_SDK_AD)
|
||||
}
|
||||
}
|
||||
|
||||
val onAdShowAction = {
|
||||
sdkJumpBtn.visibility = View.VISIBLE
|
||||
if (activity is BaseActivity) {
|
||||
activity.baseHandler.sendEmptyMessageDelayed(MainActivity.COUNTDOWN_SDK_AD, 1000)
|
||||
}
|
||||
SensorsBridge.trackEvent("ThirdPartyAdShow",
|
||||
"ad_source", thirdPartyAd.sourceName,
|
||||
"ad_id", thirdPartyAd.slotId,
|
||||
"ad_format", mSplashAd?.typeChinese ?: "",
|
||||
"ad_placement", "光环启动",
|
||||
"launch_type", if (isHotLaunch) "热启动" else "冷启动",
|
||||
"ad_space_id", mSplashAd?.id ?: "",
|
||||
"ad_space_name", mSplashAd?.name ?: ""
|
||||
)
|
||||
}
|
||||
val onAdClickAction = {
|
||||
callback.invoke(true)
|
||||
SensorsBridge.trackEvent("ThirdPartyAdClick",
|
||||
"ad_source", thirdPartyAd.sourceName,
|
||||
"ad_id", thirdPartyAd.slotId,
|
||||
"ad_format", mSplashAd?.typeChinese ?: "",
|
||||
"ad_placement", "光环启动",
|
||||
"launch_type", if (isHotLaunch) "热启动" else "冷启动",
|
||||
"ad_space_id", mSplashAd?.id ?: "",
|
||||
"ad_space_name", mSplashAd?.name ?: ""
|
||||
)
|
||||
}
|
||||
mCsjAdImpl?.requestSplashAd(
|
||||
activity,
|
||||
thirdPartyAd.slotId,
|
||||
adViewWidthInPx,
|
||||
adViewHeightInPx,
|
||||
adViewWidthInDp,
|
||||
adViewHeightInDp,
|
||||
startAdContainer,
|
||||
timeout,
|
||||
onAdShowAction,
|
||||
onAdClickAction,
|
||||
callback,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示自有的开屏广告
|
||||
*/
|
||||
private fun requestStandardSplashAd(
|
||||
activity: Activity,
|
||||
adViewWidthInPx: Int,
|
||||
adViewHeightInPx: Int,
|
||||
adViewWidthInDp: Float,
|
||||
adViewHeightInDp: Float,
|
||||
startAdContainer: ViewGroup,
|
||||
sdkStartAdContainer: ViewGroup,
|
||||
sdkJumpBtn: TextView,
|
||||
adsViewGroup: FrameLayout,
|
||||
handler: BaseActivity.BaseHandler,
|
||||
isHotLaunch: Boolean,
|
||||
hideCallback: () -> Unit
|
||||
) {
|
||||
val splashAd = mSplashAd?.ownerAd?.startAd
|
||||
val onEmptyCallback = {
|
||||
if (mSplashAd?.displayRule?.adSource == AD_TYPE_OWNER && mSplashAd?.displayRule?.onFailedAction == "show" && mSplashAd?.thirdPartyAd != null) {
|
||||
// 自有广告为空时,显示第三方广告
|
||||
requestThirdPartySplashAd(
|
||||
activity,
|
||||
adViewWidthInPx,
|
||||
adViewHeightInPx,
|
||||
adViewWidthInDp,
|
||||
adViewHeightInDp,
|
||||
startAdContainer,
|
||||
sdkStartAdContainer,
|
||||
sdkJumpBtn,
|
||||
adsViewGroup,
|
||||
handler,
|
||||
isHotLaunch,
|
||||
hideCallback
|
||||
)
|
||||
} else {
|
||||
hideCallback.invoke()
|
||||
}
|
||||
}
|
||||
if (splashAd == null) {
|
||||
onEmptyCallback.invoke()
|
||||
return
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(splashAd.img)) {
|
||||
val showedTodayTimestamp = SPUtils.getString(Constants.SP_STARTUP_AD_TIMESTAMP, "") ?: ""
|
||||
when (splashAd.rule) {
|
||||
"each" -> showStandardSplashAd(splashAd, startAdContainer, handler, hideCallback)
|
||||
"once" -> if (TextUtils.isEmpty(showedTodayTimestamp)
|
||||
|| !showedTodayTimestamp.contains(splashAd.id)
|
||||
) {
|
||||
showStandardSplashAd(splashAd, startAdContainer, handler, hideCallback)
|
||||
} else {
|
||||
onEmptyCallback.invoke()
|
||||
}
|
||||
|
||||
"everyday" -> {
|
||||
val today = getToday()
|
||||
if (TextUtils.isEmpty(showedTodayTimestamp)
|
||||
|| !showedTodayTimestamp.contains(today)
|
||||
|| !showedTodayTimestamp.contains(splashAd.id)
|
||||
) {
|
||||
showStandardSplashAd(splashAd, startAdContainer, handler, hideCallback)
|
||||
} else {
|
||||
onEmptyCallback.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
else -> hideCallback.invoke()
|
||||
}
|
||||
SPUtils.setString(Constants.SP_STARTUP_AD_TIMESTAMP, splashAd.id + getToday())
|
||||
} else {
|
||||
hideCallback.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showStandardSplashAd(
|
||||
ad: StartupAdEntity,
|
||||
startAdContainer: ViewGroup,
|
||||
handler: BaseActivity.BaseHandler,
|
||||
hideCallback: () -> Unit
|
||||
) {
|
||||
val jumpBtn = startAdContainer.findViewById<TextView>(R.id.jumpBtn)
|
||||
val jumpDetailBtn: TextView = startAdContainer.findViewById(R.id.jumpDetailBtn)
|
||||
val adImage: SimpleDraweeView = startAdContainer.findViewById(R.id.adImage)
|
||||
val adVideo = startAdContainer.findViewById<SplashAdVideoView>(R.id.ad_video)
|
||||
val icpContainer: View? = startAdContainer.findViewById(R.id.startAdIcpContainer)
|
||||
startAdContainer.visibility = View.VISIBLE
|
||||
icpContainer?.visibility = View.VISIBLE
|
||||
jumpBtn.text = startAdContainer.context.getString(R.string.splash_jump, splashAdDisplayInterval)
|
||||
|
||||
jumpDetailBtn.text = ad.desc
|
||||
jumpDetailBtn.setDrawableEnd(
|
||||
AppCompatResources.getDrawable(
|
||||
startAdContainer.context,
|
||||
R.drawable.ic_startup_ad_arrow
|
||||
), null, null
|
||||
)
|
||||
|
||||
adImage.visibleIf(true)
|
||||
ImageUtils.display(adImage, ad.img)
|
||||
|
||||
if (ad.isImageType) {
|
||||
adVideo.visibleIf(false)
|
||||
} else {
|
||||
adVideo.visibleIf(true)
|
||||
adVideo.startPlay(ad.video.url)
|
||||
}
|
||||
startAdContainer.setOnClickListener {
|
||||
// 拦截点击事件传递
|
||||
}
|
||||
jumpBtn.setOnClickListener {
|
||||
handler.removeMessages(MainActivity.COUNTDOWN_AD)
|
||||
hideCallback.invoke()
|
||||
val linkEntity = ad.jump
|
||||
logOpenScreenAdSkip(
|
||||
ad.id,
|
||||
(if (linkEntity.text != null) linkEntity.text else "")!!,
|
||||
(if (linkEntity.type != null) linkEntity.type else "")!!,
|
||||
(if (linkEntity.link != null) linkEntity.link else "")!!
|
||||
)
|
||||
SensorsBridge.trackEvent(
|
||||
"SplashAdOwnSkip",
|
||||
"splash_ad_id",
|
||||
ad.id,
|
||||
"link_type",
|
||||
linkEntity.type ?: "",
|
||||
"link_id",
|
||||
linkEntity.link ?: "",
|
||||
"link_text",
|
||||
linkEntity.text ?: ""
|
||||
)
|
||||
}
|
||||
val sources: MutableList<ExposureSource> = ArrayList()
|
||||
sources.add(ExposureSource("开屏广告", ad.id))
|
||||
val event = createEvent(null, sources, null, ExposureType.EXPOSURE)
|
||||
ExposureManager.log(event)
|
||||
if (ad.button) {
|
||||
jumpDetailBtn.setOnClickListener { v: View ->
|
||||
val linkEntity = ad.jump
|
||||
directToLinkPage(v.context, linkEntity, "(启动广告)", "", event)
|
||||
SensorsBridge.trackEvent(
|
||||
"SplashAdOwnClick",
|
||||
"splash_ad_id",
|
||||
ad.id,
|
||||
"link_type",
|
||||
linkEntity.type ?: "",
|
||||
"link_id",
|
||||
linkEntity.link ?: "",
|
||||
"link_text",
|
||||
linkEntity.text ?: ""
|
||||
)
|
||||
v.postDelayed({
|
||||
handler.removeMessages(MainActivity.COUNTDOWN_AD)
|
||||
hideCallback.invoke()
|
||||
}, 1000)
|
||||
}
|
||||
jumpDetailBtn.visibility = View.VISIBLE
|
||||
LogUtils.logStartAd("watch_start_ads", ad)
|
||||
} else {
|
||||
LogUtils.logStartAd("start_ads", ad)
|
||||
}
|
||||
SPUtils.setLong(Constants.SP_LAST_SPLASH_AD_SHOW_TIME, System.currentTimeMillis())
|
||||
val msg = Message.obtain()
|
||||
msg.what = MainActivity.COUNTDOWN_AD
|
||||
msg.obj = ad
|
||||
handler.sendMessageDelayed(msg, 1000)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取第三方信息流广告
|
||||
*/
|
||||
fun requestThirdPartyFlowAd(
|
||||
fragment: Fragment,
|
||||
slotId: String,
|
||||
adContainerView: ViewGroup,
|
||||
expressViewWidth: Float,
|
||||
onAdShowAction: () -> Unit,
|
||||
onAdClickAction: () -> Unit,
|
||||
callback: (isSuccess: Boolean) -> Unit,
|
||||
) {
|
||||
mCsjAdImpl?.requestFlowAd(fragment, adContainerView, slotId, expressViewWidth, onAdShowAction, onAdClickAction, callback)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取第三方 Banner 广告
|
||||
*/
|
||||
fun requestThirdPartyBannerAd(
|
||||
fragment: Fragment,
|
||||
containerView: ViewGroup,
|
||||
ad: AdConfig.ThirdPartyAd,
|
||||
expressViewWidthInDp: Float,
|
||||
onAdShowAction: () -> Unit,
|
||||
onAdClickAction: () -> Unit,
|
||||
callback: (isSuccess: Boolean) -> Unit
|
||||
) {
|
||||
|
||||
val slotId = ad.slotId
|
||||
val displayRatio: Float = if (ad.displaySize.isEmpty()) {
|
||||
2F
|
||||
} else {
|
||||
val array = ad.displaySize.split("*")
|
||||
if (array.size == 2) {
|
||||
array[0].toFloat() / array[1].toFloat()
|
||||
} else {
|
||||
2F
|
||||
}
|
||||
}
|
||||
val expressViewHeightInDp = expressViewWidthInDp / displayRatio
|
||||
|
||||
mCsjAdImpl?.requestBannerAd(
|
||||
fragment,
|
||||
containerView,
|
||||
slotId,
|
||||
expressViewWidthInDp,
|
||||
expressViewHeightInDp,
|
||||
onAdShowAction,
|
||||
onAdClickAction,
|
||||
callback
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取第三方 全屏/插屏 广告
|
||||
*/
|
||||
fun requestFullScreenAd(
|
||||
fragment: Fragment,
|
||||
ad: AdConfig.ThirdPartyAd,
|
||||
onAdShowAction: () -> Unit,
|
||||
onAdClickAction: () -> Unit,
|
||||
callback: (isSuccess: Boolean) -> Unit
|
||||
) {
|
||||
val slotId = ad.slotId
|
||||
mCsjAdImpl?.requestFullScreenAd(
|
||||
fragment,
|
||||
slotId,
|
||||
onAdShowAction,
|
||||
onAdClickAction,
|
||||
callback
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消开屏广告
|
||||
*/
|
||||
fun cancelSplashAd(context: Context) {
|
||||
mCsjAdImpl?.cancelSplashAd(context)
|
||||
}
|
||||
|
||||
}
|
||||
107
app/src/main/java/com/gh/ad/LaunchAdImpl.kt
Normal file
107
app/src/main/java/com/gh/ad/LaunchAdImpl.kt
Normal file
@ -0,0 +1,107 @@
|
||||
package com.gh.ad
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewStub
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.provider.ILaunchAd
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge
|
||||
import com.gh.gamecenter.common.utils.goneIf
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.entity.AdConfig
|
||||
|
||||
@Route(path = RouteConsts.provider.vaAd, name = "畅玩启动页广告")
|
||||
class LaunchAdImpl : ILaunchAd {
|
||||
override fun init(context: Context?) {
|
||||
}
|
||||
|
||||
override fun requestAd(fragment: Fragment, container: ViewGroup, maskView: View, topViewStub: ViewStub, bottomViewStub: ViewStub, adClickAction: () -> Unit): View {
|
||||
if (AdDelegateHelper.shouldShowHelperLaunchAd()) {
|
||||
val launchAd = AdDelegateHelper.vGameLaunchAd
|
||||
val showThirdPartyAd = launchAd?.displayRule?.adSource == AdDelegateHelper.AD_TYPE_SDK
|
||||
val thirdPartyAd = launchAd?.thirdPartyAd
|
||||
if (showThirdPartyAd && thirdPartyAd != null) {
|
||||
val onAdShowAction = {
|
||||
SensorsBridge.trackEvent("ThirdPartyAdShow",
|
||||
"ad_source", thirdPartyAd.sourceName,
|
||||
"ad_id", thirdPartyAd.slotId,
|
||||
"ad_format", launchAd.typeChinese,
|
||||
"ad_placement", AD_PLACEMENT,
|
||||
"ad_space_id", launchAd.id,
|
||||
"ad_space_name", launchAd.name
|
||||
)
|
||||
}
|
||||
val onAdClickAction = {
|
||||
SensorsBridge.trackEvent("ThirdPartyAdClick",
|
||||
"ad_source", thirdPartyAd.sourceName,
|
||||
"ad_id", thirdPartyAd.slotId,
|
||||
"ad_format", launchAd.typeChinese,
|
||||
"ad_placement", AD_PLACEMENT,
|
||||
"ad_space_id", launchAd.id,
|
||||
"ad_space_name", launchAd.name
|
||||
)
|
||||
adClickAction.invoke()
|
||||
}
|
||||
|
||||
if (launchAd.type == AdConfig.TYPE_BANNER) {
|
||||
requestBannerAd(fragment, container, maskView, thirdPartyAd, onAdShowAction, onAdClickAction)
|
||||
return topViewStub.inflate()
|
||||
} else if (launchAd.type == AdConfig.TYPE_INTERSTITIAL) {
|
||||
requestFullScreenAd(fragment, thirdPartyAd, onAdShowAction, onAdClickAction)
|
||||
return bottomViewStub.inflate()
|
||||
}
|
||||
}
|
||||
}
|
||||
return bottomViewStub.inflate()
|
||||
}
|
||||
|
||||
private fun requestBannerAd(
|
||||
fragment: Fragment,
|
||||
container: ViewGroup,
|
||||
maskView: View,
|
||||
thirdPartyAd: AdConfig.ThirdPartyAd,
|
||||
onAdShowAction: () -> Unit,
|
||||
onAdClickAction: () -> Unit,
|
||||
) {
|
||||
AdDelegateHelper.requestThirdPartyBannerAd(
|
||||
fragment,
|
||||
container,
|
||||
thirdPartyAd,
|
||||
DisplayUtils.getScreenWidthInDp(fragment.requireActivity()),
|
||||
onAdShowAction,
|
||||
onAdClickAction
|
||||
) { isSuccess ->
|
||||
maskView.goneIf(!isSuccess)
|
||||
if (isSuccess) {
|
||||
SPUtils.setLong(Constants.SP_LAST_HELPER_LAUNCH_AD_SHOW_TIME, System.currentTimeMillis())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestFullScreenAd(
|
||||
fragment: Fragment,
|
||||
thirdPartyAd: AdConfig.ThirdPartyAd,
|
||||
onAdShowAction: () -> Unit,
|
||||
onAdClickAction: () -> Unit
|
||||
) {
|
||||
AdDelegateHelper.requestFullScreenAd(
|
||||
fragment,
|
||||
thirdPartyAd,
|
||||
onAdShowAction,
|
||||
onAdClickAction
|
||||
) { isSuccess ->
|
||||
if (isSuccess) {
|
||||
SPUtils.setLong(Constants.SP_LAST_HELPER_LAUNCH_AD_SHOW_TIME, System.currentTimeMillis())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val AD_PLACEMENT = "畅玩启动"
|
||||
}
|
||||
}
|
||||
78
app/src/main/java/com/gh/ad/SplashAdVideoView.kt
Normal file
78
app/src/main/java/com/gh/ad/SplashAdVideoView.kt
Normal file
@ -0,0 +1,78 @@
|
||||
package com.gh.ad
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.WindowManager
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.video.detail.CustomManager
|
||||
import com.shuyu.gsyvideoplayer.utils.GSYVideoType
|
||||
import com.shuyu.gsyvideoplayer.utils.GSYVideoType.SCREEN_TYPE_FULL
|
||||
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
|
||||
import com.shuyu.gsyvideoplayer.video.base.GSYVideoViewBridge
|
||||
|
||||
class SplashAdVideoView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null
|
||||
) :
|
||||
StandardGSYVideoPlayer(context, attrs) {
|
||||
|
||||
fun startPlay(url: String) {
|
||||
GSYVideoType.setShowType(SCREEN_TYPE_FULL)
|
||||
GSYVideoType.setRenderType(GSYVideoType.SUFRACE)
|
||||
CustomManager.getCustomManager(getKey()).isNeedMute = true
|
||||
|
||||
setUp(url, true, "")
|
||||
|
||||
setNeedAutoAdaptation(false)
|
||||
startPlayLogic()
|
||||
}
|
||||
|
||||
override fun getGSYVideoManager(): GSYVideoViewBridge {
|
||||
CustomManager.getCustomManager(getKey()).initContext(context.applicationContext)
|
||||
return CustomManager.getCustomManager(getKey())
|
||||
}
|
||||
|
||||
private fun getKey() = "splash_ad"
|
||||
|
||||
/**
|
||||
* 覆盖父类方法,防止在是视频 Preparing 阶段封面图被隐藏,导致白屏
|
||||
*/
|
||||
override fun changeUiToPreparingShow() = Unit
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.layout_splash_ad_video
|
||||
}
|
||||
|
||||
override fun onAutoCompletion() {
|
||||
setStateAndUi(CURRENT_STATE_AUTO_COMPLETE);
|
||||
|
||||
mSaveChangeViewTIme = 0
|
||||
mCurrentPosition = 0
|
||||
|
||||
if (!mIfCurrentIsFullscreen) {
|
||||
getGSYVideoManager().setLastListener(null)
|
||||
}
|
||||
mAudioManager.abandonAudioFocus(onAudioFocusChangeListener);
|
||||
if (mContext is Activity) {
|
||||
try {
|
||||
(mContext as Activity).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
releaseNetWorkState()
|
||||
|
||||
if (mVideoAllCallBack != null && isCurrentMediaListener()) {
|
||||
mVideoAllCallBack.onAutoComplete(mOriginUrl, mTitle, this)
|
||||
}
|
||||
mHadPlay = false
|
||||
}
|
||||
|
||||
fun clearAll() {
|
||||
GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_DEFAULT)
|
||||
GSYVideoType.setRenderType(GSYVideoType.TEXTURE)
|
||||
release()
|
||||
CustomManager.removeManager(getKey())
|
||||
}
|
||||
}
|
||||
@ -21,6 +21,8 @@ import com.gh.common.view.RichEditor
|
||||
import com.gh.gamecenter.CropImageActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
import com.gh.gamecenter.common.entity.LocalVideoEntity
|
||||
import com.gh.gamecenter.feature.selector.LocalMediaActivity
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
@ -30,6 +32,7 @@ import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.qa.editor.*
|
||||
import com.gh.gamecenter.feature.entity.AnswerEntity
|
||||
import com.gh.gamecenter.feature.entity.ArticleEntity
|
||||
import com.gh.gamecenter.feature.selector.ChooseType
|
||||
import com.gh.gamecenter.qa.entity.EditorInsertEntity
|
||||
import com.gh.gamecenter.video.poster.PosterEditActivity
|
||||
import com.gh.gamecenter.video.upload.UploadManager
|
||||
@ -44,7 +47,7 @@ import org.json.JSONObject
|
||||
import java.io.File
|
||||
|
||||
// TODO: 移动到module_bbs模块
|
||||
abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarActivity(),
|
||||
abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> constructor() : ToolBarActivity(),
|
||||
KeyboardHeightObserver, UploadVideoListener {
|
||||
|
||||
lateinit var mRichEditor: RichEditor
|
||||
@ -57,11 +60,16 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
private lateinit var mEditorFontItalic: CheckableImageView
|
||||
private lateinit var mEditorFontStrikeThrough: CheckableImageView
|
||||
private lateinit var mEditorFontUnderline: CheckableImageView
|
||||
private lateinit var mEditorParagraphDivider: CheckableImageView
|
||||
private lateinit var mEditorParagraphH1: CheckableImageView
|
||||
private lateinit var mEditorParagraphH2: CheckableImageView
|
||||
private lateinit var mEditorParagraphH3: CheckableImageView
|
||||
private lateinit var mEditorParagraphH4: CheckableImageView
|
||||
private lateinit var mEditorParagraphQuote: CheckableImageView
|
||||
private lateinit var mEditorAlignLeft: CheckableImageView
|
||||
private lateinit var mEditorAlignCenter: CheckableImageView
|
||||
private lateinit var mEditorAlignRight: CheckableImageView
|
||||
private lateinit var mEditorAlignContainer: View
|
||||
private lateinit var mEditorFontContainer: View
|
||||
private lateinit var mEditorParagraphContainer: View
|
||||
private lateinit var mEditorLinkContainer: View
|
||||
@ -97,6 +105,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
mRichEditor.insertCustomStyleLink(insertData)
|
||||
}
|
||||
}
|
||||
|
||||
INSERT_ARTICLE_CODE -> {
|
||||
val article =
|
||||
data?.getParcelableExtra<ArticleEntity>(ArticleEntity::class.java.simpleName)
|
||||
@ -106,6 +115,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
mRichEditor.insertCustomStyleLink(insertData)
|
||||
}
|
||||
}
|
||||
|
||||
INSERT_GAME_CODE -> {
|
||||
val game = data?.getParcelableExtra<GameEntity>(GameEntity::class.java.simpleName)
|
||||
if (game != null) {
|
||||
@ -114,6 +124,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
mRichEditor.insertCustomStyleLink(insertData)
|
||||
}
|
||||
}
|
||||
|
||||
INSERT_GAME_COLLECTION_CODE -> {
|
||||
val gameCollectionEntity =
|
||||
data?.getParcelableExtra<GamesCollectionEntity>(GamesCollectionEntity::class.java.simpleName)
|
||||
@ -123,9 +134,11 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
mRichEditor.insertCustomStyleLink(insertData)
|
||||
}
|
||||
}
|
||||
|
||||
REQUEST_CODE_IMAGE -> {
|
||||
if (data != null) mViewModel.uploadPic(data)
|
||||
}
|
||||
|
||||
INSERT_MEDIA_VIDEO_CODE -> {
|
||||
val localVideoList =
|
||||
data?.getParcelableArrayListExtra<LocalVideoEntity>(LocalVideoEntity::class.java.name)
|
||||
@ -135,12 +148,14 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
uploadVideo(localVideoList)
|
||||
}
|
||||
}
|
||||
|
||||
REQUEST_CODE_IMAGE_CROP -> {
|
||||
val imagePath = data?.getStringExtra(CropImageActivity.RESULT_CLIP_PATH)
|
||||
if (!imagePath.isNullOrEmpty()) {
|
||||
mViewModel.uploadPoster(imagePath)
|
||||
}
|
||||
}
|
||||
|
||||
INSERT_VIDEO_CODE -> {
|
||||
val videoEntity = data?.getParcelableExtra<MyVideoEntity>(MyVideoEntity::class.java.simpleName)
|
||||
if (videoEntity != null) {
|
||||
@ -194,7 +209,12 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
mEditorParagraphH2 = findViewById(R.id.editor_paragraph_h2)
|
||||
mEditorParagraphH3 = findViewById(R.id.editor_paragraph_h3)
|
||||
mEditorParagraphH4 = findViewById(R.id.editor_paragraph_h4)
|
||||
mEditorParagraphDivider = findViewById(R.id.editor_paragraph_divider)
|
||||
mEditorParagraphQuote = findViewById(R.id.editor_paragraph_quote)
|
||||
mEditorAlignLeft = findViewById(R.id.editor_align_left)
|
||||
mEditorAlignCenter = findViewById(R.id.editor_align_center)
|
||||
mEditorAlignRight = findViewById(R.id.editor_align_right)
|
||||
mEditorAlignContainer = findViewById(R.id.editor_align_container)
|
||||
mEditorFontContainer = findViewById(R.id.editor_font_container)
|
||||
mEditorParagraphContainer = findViewById(R.id.editor_paragraph_container)
|
||||
mEditorLinkContainer = findViewById(R.id.editor_link_container)
|
||||
@ -216,7 +236,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
mKeyboardHeightProvider = KeyboardHeightProvider(this)
|
||||
mRichEditor.post { mKeyboardHeightProvider?.start() }
|
||||
mRichEditor.enableForceDark(DarkModeUtils.isDarkModeOn(this))
|
||||
mRichEditor.setEditorBackgroundColor(R.color.background_white.toColor(this))
|
||||
mRichEditor.setEditorBackgroundColor(R.color.ui_surface.toColor(this))
|
||||
mRichEditor.setEditorFontColor(if (mIsDarkModeOn) Color.parseColor("#C2C2C2") else Color.parseColor("#4A4A4A"))
|
||||
// 防止个别手机在Js里无法获取粘贴内容
|
||||
mRichEditor.addJavascriptInterface(OnPasteListener(), "onPasteListener")
|
||||
@ -241,6 +261,13 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
mRichEditor.hasFocus()
|
||||
} else false
|
||||
}
|
||||
|
||||
mRichEditor.setOnDecorationChangeListener { _, types ->
|
||||
mEditorAlignLeft.isChecked = types.contains(RichEditor.Type.JUSTIFYLEFT)
|
||||
mEditorAlignCenter.isChecked = types.contains(RichEditor.Type.JUSTIFYCENTER)
|
||||
mEditorAlignRight.isChecked = types.contains(RichEditor.Type.JUSTIFYRIGHT)
|
||||
}
|
||||
|
||||
mOriginalCb.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (isChecked) {
|
||||
mOriginalTipsContainer.alpha = 0f
|
||||
@ -325,6 +352,9 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
MtaHelper.onEvent(mtaEventName(), "文字样式", "文字样式-下滑线")
|
||||
}
|
||||
}
|
||||
mEditorParagraphDivider.setOnClickListener {
|
||||
mRichEditor.insertDivider()
|
||||
}
|
||||
mEditorParagraphH1.setOnClickListener {
|
||||
if (mEditorParagraphH1.isChecked) {
|
||||
mRichEditor.formatBlock()
|
||||
@ -370,6 +400,27 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
}
|
||||
mEditorParagraphQuote.isChecked = !mEditorParagraphQuote.isChecked
|
||||
}
|
||||
mEditorAlignLeft.setOnClickListener {
|
||||
if (!mEditorAlignLeft.isChecked) {
|
||||
mRichEditor.setAlignLeft()
|
||||
MtaHelper.onEvent(mtaEventName(), "文本对齐选项", "文本对齐选项-靠左")
|
||||
mEditorAlignLeft.isChecked = !mEditorAlignLeft.isChecked
|
||||
}
|
||||
}
|
||||
mEditorAlignCenter.setOnClickListener {
|
||||
if (!mEditorAlignCenter.isChecked) {
|
||||
mRichEditor.setAlignCenter()
|
||||
MtaHelper.onEvent(mtaEventName(), "文本对齐选项", "文本对齐选项-靠中")
|
||||
mEditorAlignCenter.isChecked = !mEditorAlignCenter.isChecked
|
||||
}
|
||||
}
|
||||
mEditorAlignRight.setOnClickListener {
|
||||
if (!mEditorAlignRight.isChecked) {
|
||||
mRichEditor.setAlignRight()
|
||||
MtaHelper.onEvent(mtaEventName(), "文本对齐选项", "文本对齐选项-靠右")
|
||||
mEditorAlignRight.isChecked = !mEditorAlignRight.isChecked
|
||||
}
|
||||
}
|
||||
findViewById<View>(R.id.editor_link_answer).setOnClickListener {
|
||||
MtaHelper.onEvent(mtaEventName(), "插入链接", "插入链接-回答")
|
||||
startActivityForResult(
|
||||
@ -449,25 +500,22 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
return
|
||||
}
|
||||
try {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(this,
|
||||
object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
val maxChooseCount = if (videoCount + 3 <= MAX_MEDIA_COUNT) 3 else MAX_MEDIA_COUNT - videoCount
|
||||
startActivityForResult(
|
||||
LocalMediaActivity.getIntent(
|
||||
this@BaseRichEditorActivity,
|
||||
LocalMediaActivity.ChooseType.VIDEO,
|
||||
maxChooseCount,
|
||||
if (mtaEventName() == "提问帖") "发提问帖" else "发帖子"
|
||||
), INSERT_MEDIA_VIDEO_CODE
|
||||
)
|
||||
NewLogUtils.logChooseMedia(
|
||||
"view_media",
|
||||
if (mtaEventName() == "提问帖") "提问帖" else "帖子",
|
||||
"视频"
|
||||
)
|
||||
}
|
||||
})
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(this) {
|
||||
val maxChooseCount = if (videoCount + 3 <= MAX_MEDIA_COUNT) 3 else MAX_MEDIA_COUNT - videoCount
|
||||
startActivityForResult(
|
||||
LocalMediaActivity.getIntent(
|
||||
this@BaseRichEditorActivity,
|
||||
ChooseType.VIDEO,
|
||||
maxChooseCount,
|
||||
if (mtaEventName() == "提问帖") "发提问帖" else "发帖子"
|
||||
), INSERT_MEDIA_VIDEO_CODE
|
||||
)
|
||||
NewLogUtils.logChooseMedia(
|
||||
"view_media",
|
||||
if (mtaEventName() == "提问帖") "提问帖" else "帖子",
|
||||
"视频"
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
toast(R.string.media_image_hint)
|
||||
e.printStackTrace()
|
||||
@ -482,18 +530,16 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
return
|
||||
}
|
||||
try {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(this, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
val maxChooseCount = if (imageCount + 10 <= MAX_IMAGE_COUNT) 10 else MAX_IMAGE_COUNT - imageCount
|
||||
val intent = LocalMediaActivity.getIntent(
|
||||
this@BaseRichEditorActivity,
|
||||
LocalMediaActivity.ChooseType.IMAGE,
|
||||
maxChooseCount,
|
||||
if (mtaEventName() == "提问帖") "发提问帖" else "发帖子"
|
||||
)
|
||||
startActivityForResult(intent, REQUEST_CODE_IMAGE)
|
||||
}
|
||||
})
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(this) {
|
||||
val maxChooseCount = if (imageCount + 10 <= MAX_IMAGE_COUNT) 10 else MAX_IMAGE_COUNT - imageCount
|
||||
val intent = LocalMediaActivity.getIntent(
|
||||
this@BaseRichEditorActivity,
|
||||
ChooseType.IMAGE,
|
||||
maxChooseCount,
|
||||
if (mtaEventName() == "提问帖") "发提问帖" else "发帖子"
|
||||
)
|
||||
startActivityForResult(intent, REQUEST_CODE_IMAGE)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
toast(R.string.media_image_hint)
|
||||
e.printStackTrace()
|
||||
@ -516,6 +562,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
mEditorFontContainer.visibility = if (mEditorFont.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorParagraphContainer.visibility =
|
||||
if (mEditorFont.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorAlignContainer.visibility = if (mEditorFont.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorLinkContainer.visibility = View.GONE
|
||||
mTagsContainer.visibility = View.GONE
|
||||
mIsExtendedKeyboardShow = mEditorFont.isChecked
|
||||
@ -537,6 +584,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
if (mEditorLink.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorLinkContainer.visibility = if (mEditorLink.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorFontContainer.visibility = View.GONE
|
||||
mEditorAlignContainer.visibility = View.GONE
|
||||
mEditorParagraphContainer.visibility = View.GONE
|
||||
mTagsContainer.visibility = View.GONE
|
||||
mIsExtendedKeyboardShow = mEditorLink.isChecked
|
||||
@ -752,9 +800,9 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
|
||||
override fun onDarkModeChanged() {
|
||||
super.onDarkModeChanged()
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
updateStatusBarColor(R.color.ui_surface, R.color.ui_surface)
|
||||
mRichEditor.enableForceDark(DarkModeUtils.isDarkModeOn(this))
|
||||
mRichEditor.setEditorBackgroundColor(R.color.background_white.toColor(this))
|
||||
mRichEditor.setEditorBackgroundColor(R.color.ui_surface.toColor(this))
|
||||
mRichEditor.setEditorFontColor(if (mIsDarkModeOn) Color.parseColor("#C2C2C2") else Color.parseColor("#4A4A4A"))
|
||||
}
|
||||
|
||||
@ -776,7 +824,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
const val INSERT_VIDEO_CODE = 415
|
||||
const val MAX_INPUT_TEXT_NUM = 10000
|
||||
const val MAX_MEDIA_COUNT = 20
|
||||
const val MAX_IMAGE_COUNT = 35
|
||||
const val MAX_IMAGE_COUNT = 70
|
||||
|
||||
const val REQUEST_CODE_IMAGE = 120
|
||||
const val INSERT_MEDIA_VIDEO_CODE = 121
|
||||
|
||||
@ -12,15 +12,15 @@ import androidx.lifecycle.MediatorLiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.fragment.WaitingDialogFragment
|
||||
import com.gh.gamecenter.common.entity.ErrorEntity
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.gamecenter.core.utils.MD5Utils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.common.entity.ErrorEntity
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.entity.ForumDetailEntity
|
||||
import com.gh.gamecenter.entity.LocalVideoEntity
|
||||
import com.gh.gamecenter.common.entity.LocalVideoEntity
|
||||
import com.gh.gamecenter.entity.QuoteCountEntity
|
||||
import com.gh.gamecenter.qa.BbsType
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
@ -38,6 +38,8 @@ import okhttp3.ResponseBody
|
||||
import retrofit2.HttpException
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.util.*
|
||||
import kotlin.collections.LinkedHashMap
|
||||
import kotlin.collections.set
|
||||
|
||||
// TODO: 移动到module_bbs模块
|
||||
@ -57,7 +59,6 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
|
||||
val TITLE_MIN_LENGTH = 6
|
||||
val MIN_TEXT_LENGTH = 6
|
||||
val MAX_TEXT_LENGTH = 10000
|
||||
val FILE_HOST = "file:///"
|
||||
var id = ""//视频标记
|
||||
var videoId = ""//更改封面视频id
|
||||
val quoteCountEntity = QuoteCountEntity()//数据上报用
|
||||
@ -124,8 +125,15 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
|
||||
}
|
||||
val map = LinkedHashMap<String, String>()
|
||||
for (key in imageUrlMap.keys) {
|
||||
map[MD5Utils.getUrlMD5(key)] = FILE_HOST + key.decodeURI()
|
||||
mapImages[TextUtils.htmlEncode(key).decodeURI()] = imageUrlMap[key] ?: ""
|
||||
// 文件格式为 HEIC 时,使用经 OSS 转码的图片作为预览图片
|
||||
if (FileUtils.getFileMimeType(getApplication(), key.decodeURI())?.lowercase(Locale.CHINA)?.contains("heic") == true) {
|
||||
val transformedImgUrl = ImageUtils.getIdealImageUrl(imageUrlMap[key], 5000) ?: ""
|
||||
map[MD5Utils.getUrlMD5(key)] = transformedImgUrl
|
||||
mapImages[transformedImgUrl.decodeURI()] = imageUrlMap[key] ?: ""
|
||||
} else {
|
||||
map[MD5Utils.getUrlMD5(key)] = imageUrlMap[key] ?: ""
|
||||
mapImages[TextUtils.htmlEncode(key).decodeURI()] = imageUrlMap[key] ?: ""
|
||||
}
|
||||
}
|
||||
chooseImagesUploadSuccess.value = map
|
||||
}
|
||||
|
||||
@ -1,18 +1,20 @@
|
||||
package com.gh.base
|
||||
|
||||
import android.graphics.Typeface
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.DownloadManagerActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.utils.viewModelProvider
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils.getBoolean
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||
@ -44,7 +46,7 @@ abstract class DownloadToolbarActivity : ToolBarActivity() {
|
||||
|
||||
override fun inflateMenu(res: Int) {
|
||||
super.inflateMenu(res)
|
||||
if (showDownloadMenu()) {
|
||||
if (!getBoolean(Constants.SP_TEENAGER_MODE) && showDownloadMenu()) {
|
||||
createDownloadMenu(res)
|
||||
}
|
||||
}
|
||||
@ -58,6 +60,7 @@ abstract class DownloadToolbarActivity : ToolBarActivity() {
|
||||
}
|
||||
val downloadMenuView = mActionMenuView.menu.findItem(R.id.menu_download).actionView
|
||||
mDownloadCountHint = downloadMenuView?.findViewById(R.id.menu_download_count_hint)
|
||||
mDownloadCountHint?.typeface = Typeface.createFromAsset(assets, Constants.DIN_FONT_PATH)
|
||||
}
|
||||
|
||||
override fun onMenuItemClick(item: MenuItem?): Boolean {
|
||||
@ -74,19 +77,27 @@ abstract class DownloadToolbarActivity : ToolBarActivity() {
|
||||
if (mDownloadCountHint == null) return
|
||||
val count = DownloadManager.getInstance().getDownloadOrUpdateCount(updateList)
|
||||
if (count != null) {
|
||||
mDownloadCountHint!!.visibility = View.VISIBLE
|
||||
mDownloadCountHint!!.text = count
|
||||
val params = mDownloadCountHint!!.layoutParams
|
||||
if (TextUtils.isEmpty(count)) {
|
||||
params.width = DisplayUtils.dip2px(6f)
|
||||
params.height = DisplayUtils.dip2px(6f)
|
||||
} else {
|
||||
params.width = DisplayUtils.dip2px(12f)
|
||||
params.height = DisplayUtils.dip2px(12f)
|
||||
}
|
||||
mDownloadCountHint!!.layoutParams = params
|
||||
mDownloadCountHint?.visibility = View.VISIBLE
|
||||
mDownloadCountHint?.text = count
|
||||
val params = mDownloadCountHint?.layoutParams
|
||||
params?.width = if (count.isEmpty()) 6F.dip2px() else ConstraintLayout.LayoutParams.WRAP_CONTENT
|
||||
params?.height = if (count.isEmpty()) 6F.dip2px() else 14F.dip2px()
|
||||
(params as? ViewGroup.MarginLayoutParams)?.setMargins(
|
||||
0,
|
||||
if (count.isEmpty()) 0 else (-4F).dip2px(),
|
||||
if (count.isEmpty()) (-4F).dip2px() else (-8F).dip2px(),
|
||||
0
|
||||
)
|
||||
mDownloadCountHint?.setPadding(
|
||||
if (count.isEmpty()) 0 else 4F.dip2px(),
|
||||
0,
|
||||
if (count.isEmpty()) 0 else 4F.dip2px(),
|
||||
0
|
||||
)
|
||||
mDownloadCountHint?.minWidth = if (count.isEmpty()) 0 else 14F.dip2px()
|
||||
mDownloadCountHint?.layoutParams = params
|
||||
} else {
|
||||
mDownloadCountHint!!.visibility = View.GONE
|
||||
mDownloadCountHint?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4,20 +4,30 @@ import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.gh.ad.AdDelegateHelper
|
||||
import com.gh.common.util.FloatingBackViewManager
|
||||
import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.SingletonWebActivity
|
||||
import com.gh.gamecenter.SkipActivity
|
||||
import com.gh.gamecenter.SplashAdActivity
|
||||
import com.gh.gamecenter.SplashScreenActivity
|
||||
import com.gh.gamecenter.authorization.AuthorizationActivity
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.provider.IHelpAndFeedbackProvider
|
||||
import com.gh.gamecenter.common.utils.PackageFlavorHelper
|
||||
import com.gh.gamecenter.core.provider.IPushProvider
|
||||
import com.gh.gamecenter.login.view.LoginActivity
|
||||
import com.gh.gamecenter.va.VCore
|
||||
import com.gh.gamecenter.login.utils.QuickLoginHelper
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
// TODO:移动到对应的模块
|
||||
class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
private var isFromBackgroundToForeground = false // 是否后台回到前台
|
||||
|
||||
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
|
||||
// do nothing
|
||||
@ -25,6 +35,31 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
|
||||
override fun onActivityStarted(activity: Activity) {
|
||||
GlobalActivityManager.currentActivity = activity
|
||||
GlobalActivityManager.activityCount ++
|
||||
if (GlobalActivityManager.activityCount == 1 && isFromBackgroundToForeground) {
|
||||
if (AdDelegateHelper.shouldShowStartUpAd(true)
|
||||
&& !HaloApp.getInstance().isDisableSplashAdTemporarily
|
||||
&& activity !is SplashScreenActivity
|
||||
&& activity !is SkipActivity
|
||||
&& activity !is AuthorizationActivity
|
||||
&& activity !is SplashAdActivity
|
||||
&& !isSuggestionActivity(activity)
|
||||
) {
|
||||
activity.startActivity(SplashAdActivity.getIntent(activity))
|
||||
}
|
||||
isFromBackgroundToForeground = false
|
||||
}
|
||||
|
||||
if (GlobalActivityManager.activityCount == 1) {
|
||||
// 清除桌面角标
|
||||
if (activity !is SplashScreenActivity && activity !is AuthorizationActivity) {
|
||||
val pushProvider = ARouter.getInstance().build(RouteConsts.provider.push).navigation() as? IPushProvider
|
||||
pushProvider?.cleanBadgeNumber(activity.applicationContext)
|
||||
}
|
||||
}
|
||||
if (QuickLoginHelper.isLoginAuthPage(activity)) {
|
||||
QuickLoginHelper.addCustomViewToLoginAuthPage(activity)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResumed(activity: Activity) {
|
||||
@ -56,6 +91,8 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
}
|
||||
|
||||
if (activity is AppCompatActivity
|
||||
&& !VCore.getInstance().isLaunchActivity(activity)
|
||||
&& activity !is LoginActivity
|
||||
&& activity !is SplashScreenActivity
|
||||
&& activity !is SkipActivity
|
||||
&& activity !is AuthorizationActivity
|
||||
@ -74,7 +111,8 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
}
|
||||
|
||||
override fun onActivityStopped(activity: Activity) {
|
||||
// do nothing
|
||||
GlobalActivityManager.activityCount --
|
||||
isFromBackgroundToForeground = GlobalActivityManager.activityCount <= 0
|
||||
}
|
||||
|
||||
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
|
||||
@ -82,7 +120,16 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
}
|
||||
|
||||
override fun onActivityDestroyed(activity: Activity) {
|
||||
// do nothing
|
||||
if (QuickLoginHelper.isLoginAuthPage(activity)) {
|
||||
QuickLoginHelper.release()
|
||||
}
|
||||
}
|
||||
|
||||
private fun isSuggestionActivity(activity: Activity): Boolean {
|
||||
val helpAndFeedbackProvider =
|
||||
ARouter.getInstance().build(RouteConsts.provider.helpAndFeedback)
|
||||
.navigation() as? IHelpAndFeedbackProvider
|
||||
return helpAndFeedbackProvider?.isSuggestionActivity(activity) ?: false
|
||||
}
|
||||
|
||||
}
|
||||
@ -24,22 +24,27 @@ import com.gh.gamecenter.common.callback.BiCallback
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.entity.NotificationUgc
|
||||
import com.gh.gamecenter.common.exposure.ExposureSource
|
||||
import com.gh.gamecenter.common.loghub.LoghubUtils
|
||||
import com.gh.gamecenter.common.provider.IHelpAndFeedbackProvider
|
||||
import com.gh.gamecenter.common.tracker.Tracker
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.utils.NewFlatLogUtils
|
||||
import com.gh.gamecenter.common.view.dsbridge.CompletionHandler
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.provider.IPushProvider
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.entity.SensorsEvent
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
import com.gh.gamecenter.feature.entity.Badge
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.exposure.ExposureSource
|
||||
import com.gh.gamecenter.login.user.LoginTag
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.login.user.UserRepository
|
||||
@ -68,8 +73,14 @@ class DefaultJsApi(
|
||||
val entrance: String = "",
|
||||
private var mFragment: Fragment? = null,
|
||||
private var mBbsId: String? = "",
|
||||
private var mOriginUrl: String? = "",
|
||||
private val mForumName: String? = "",
|
||||
) {
|
||||
|
||||
companion object {
|
||||
private const val SOURCE_ENTRANCE = "webView"
|
||||
}
|
||||
|
||||
private var mLoginHandler: CompletionHandler<Any>? = null
|
||||
private var mDownloadWatcher: DataWatcher? = null // 下载观察者
|
||||
private var mDownloadUrlSet: HashSet<String>? = null // 下载的 url 集合
|
||||
@ -83,6 +94,11 @@ class DefaultJsApi(
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun isEnableForceDark(msg: Any): Boolean {
|
||||
return DarkModeUtils.isWebViewForceDarkEnabled
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun isGhzs(msg: Any): String {
|
||||
return "true"
|
||||
@ -123,7 +139,7 @@ class DefaultJsApi(
|
||||
|
||||
@JavascriptInterface
|
||||
fun login(msg: Any) {
|
||||
if (SPUtils.getBoolean(Constants.SP_HAS_GET_PHONE_INFO) || NetworkUtils.isOpenMobileData(context)) {
|
||||
if (NetworkUtils.isQuickLoginEnabled(context)) {
|
||||
QuickLoginHelper.startLogin(context, "浏览器")
|
||||
} else {
|
||||
val intent = LoginActivity.getIntent(context, "浏览器")
|
||||
@ -213,7 +229,7 @@ class DefaultJsApi(
|
||||
runOnUiThread {
|
||||
// 若畅玩列表中安装了,优先启动畅玩游戏
|
||||
if (VHelper.isInstalled(packageName)) {
|
||||
if (!VHelper.showDialogIfVSpaceIsNeeded(context, "", "", "", "")) {
|
||||
VHelper.validateVSpaceBeforeAction(context, packageName, null) {
|
||||
VHelper.launch(context, packageName)
|
||||
}
|
||||
} else {
|
||||
@ -228,7 +244,14 @@ class DefaultJsApi(
|
||||
|
||||
val context = CurrentActivityHolder.getCurrentActivity()
|
||||
|
||||
context?.startActivity(ImageViewerActivity.getIntent(context, imageEvent.imageList, imageEvent.position, "浏览器"))
|
||||
context?.startActivity(
|
||||
ImageViewerActivity.getIntent(
|
||||
context,
|
||||
imageEvent.imageList,
|
||||
imageEvent.position,
|
||||
"浏览器"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@ -277,11 +300,18 @@ class DefaultJsApi(
|
||||
|
||||
/**
|
||||
* 打开论坛搜索页
|
||||
* 如果用户是从 webView跳转到论坛搜索页,则sourceEntrance为空
|
||||
*/
|
||||
@JavascriptInterface
|
||||
fun openForumSearch(msg: Any) {
|
||||
runOnUiThread {
|
||||
DirectUtils.directToForumOrUserSearch(context, mBbsId ?: "", entrance.ifBlank { "内部网页" })
|
||||
DirectUtils.directToForumOrUserSearch(
|
||||
context,
|
||||
mBbsId ?: "",
|
||||
entrance.ifBlank { "内部网页" },
|
||||
SOURCE_ENTRANCE,
|
||||
mForumName ?: ""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,6 +338,17 @@ class DefaultJsApi(
|
||||
return HaloApp.getInstance().gid
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun getOaid(msg: Any): String {
|
||||
return HaloApp.getInstance().oaid
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun getPushId(): String {
|
||||
val pushProvider = ARouter.getInstance().build(RouteConsts.provider.push).navigation() as? IPushProvider
|
||||
return pushProvider?.getRegistrationId(HaloApp.getInstance()) ?: "unknown"
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun showIncompatibleVersionDialog(msg: Any) {
|
||||
DialogHelper.showUpgradeDialog(context)
|
||||
@ -383,7 +424,7 @@ class DefaultJsApi(
|
||||
|
||||
@JavascriptInterface
|
||||
fun showQaFeedbackDialog(msg: Any) {
|
||||
val mHelpAndFeedbackHelp =
|
||||
val mHelpAndFeedbackHelp =
|
||||
ARouter.getInstance().build(RouteConsts.provider.helpAndFeedback).navigation() as? IHelpAndFeedbackProvider
|
||||
mHelpAndFeedbackHelp?.showQaFeedbackDialogFragment(context as AppCompatActivity, msg.toString())
|
||||
}
|
||||
@ -529,13 +570,24 @@ class DefaultJsApi(
|
||||
@JavascriptInterface
|
||||
fun installDownloadedGame(event: Any) {
|
||||
val url = event.toString()
|
||||
val vUrl = VHelper.getVUrl(url)
|
||||
|
||||
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(url, null, false)
|
||||
?: DownloadManager.getInstance().getDownloadEntitySnapshot(vUrl, null, false)
|
||||
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(url, null)
|
||||
?: DownloadManager.getInstance().getDownloadEntitySnapshot(url, null)
|
||||
|
||||
NewFlatLogUtils.logGameInstall(
|
||||
gameId = downloadEntity?.gameId ?: "",
|
||||
gameName = downloadEntity?.name ?: "",
|
||||
trigger = "主动安装"
|
||||
)
|
||||
|
||||
SensorsBridge.trackInstallGameClick(
|
||||
gameId = downloadEntity?.gameId ?: "",
|
||||
gameName = downloadEntity?.name ?: "",
|
||||
action = "主动安装"
|
||||
)
|
||||
|
||||
downloadEntity?.let {
|
||||
PackageInstaller.install(context, it, showUnzipToast = false)
|
||||
PackageInstaller.install(context, it, showUnzipToast = false, ignoreAsVGame = false)
|
||||
}
|
||||
}
|
||||
|
||||
@ -632,12 +684,19 @@ class DefaultJsApi(
|
||||
fun logExposure(event: Any) {
|
||||
val simpleExposureEvent = event.toString().toObject() ?: SimpleExposureEvent()
|
||||
if (simpleExposureEvent.id.isNotEmpty()) {
|
||||
val exposureSource = ExposureSource("游戏活动", "${simpleExposureEvent.title}+${simpleExposureEvent.id}")
|
||||
val sourceKey = if (mOriginUrl?.contains(Constants.URL_QUERY_FROM_FLOATING_WINDOW) == true) {
|
||||
"落地页"
|
||||
} else {
|
||||
"游戏活动"
|
||||
}
|
||||
|
||||
val exposureSource = ExposureSource(sourceKey, "${simpleExposureEvent.title}+${simpleExposureEvent.id}")
|
||||
mExposureEvent = ExposureEvent.createEvent(
|
||||
gameEntity = null,
|
||||
source = arrayListOf(exposureSource),
|
||||
)
|
||||
ExposureManager.log(mExposureEvent!!)
|
||||
ExposureManager.commitSavedExposureEvents(true)
|
||||
}
|
||||
}
|
||||
|
||||
@ -729,6 +788,7 @@ class DefaultJsApi(
|
||||
var status: String = "" // DOWNLOADING, PAUSED, DOWNLOADED, ERROR, UNKNOWN
|
||||
) {
|
||||
companion object {
|
||||
|
||||
fun fromDownloadEntity(downloadEntity: DownloadEntity): SimpleDownloadEntity {
|
||||
val status: String = when (downloadEntity.status) {
|
||||
add,
|
||||
|
||||
@ -15,9 +15,6 @@ import com.gh.common.util.DirectUtils.directToLegacyVideoDetail
|
||||
import com.gh.common.util.DirectUtils.directToLinkPage
|
||||
import com.gh.common.util.DirectUtils.directToQa
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.gamecenter.LibaoDetailActivity
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.NewsDetailActivity
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
@ -34,12 +31,12 @@ import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.entity.ActivityLabelEntity
|
||||
import com.gh.gamecenter.entity.SubjectRecommendEntity
|
||||
import com.gh.gamecenter.entity.VideoLinkEntity
|
||||
import com.gh.gamecenter.eventbus.EBSkip
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.utils.PlatformUtils
|
||||
import com.gh.gamecenter.fragment.MainWrapperFragment
|
||||
import com.gh.gamecenter.gamecollection.publish.GameCollectionEditActivity
|
||||
import com.gh.gamecenter.libao.LibaoDetailActivity
|
||||
import com.gh.gamecenter.newsdetail.NewsDetailActivity
|
||||
import com.gh.gamecenter.qa.BbsType
|
||||
import com.gh.gamecenter.qa.video.publish.VideoPublishActivity
|
||||
import com.gh.gamecenter.subject.SubjectActivity
|
||||
@ -51,8 +48,8 @@ import java.nio.charset.Charset
|
||||
object DefaultUrlHandler {
|
||||
|
||||
@JvmStatic
|
||||
fun interceptUrl(context: Context, url: String, entrance: String): Boolean {
|
||||
return interceptUrl(context, url, null, entrance, false)
|
||||
fun interceptUrl(context: Context, url: String, entrance: String, sourceEntrance: String = ""): Boolean {
|
||||
return interceptUrl(context, url, null, entrance, false, sourceEntrance)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,7 +63,8 @@ object DefaultUrlHandler {
|
||||
fun interceptUrl(context: Context, url: String,
|
||||
traceEvent: ExposureEvent? = null,
|
||||
entrance: String,
|
||||
bringAppToFront: Boolean = false): Boolean {
|
||||
bringAppToFront: Boolean = false,
|
||||
sourceEntrance: String = ""): Boolean {
|
||||
val uri = Uri.parse(url)
|
||||
if ("ghzhushou" == uri.scheme) {
|
||||
Utils.log("url = $url")
|
||||
@ -135,7 +133,7 @@ object DefaultUrlHandler {
|
||||
}
|
||||
|
||||
}
|
||||
"question" -> DirectUtils.directToQuestionDetail(context, id, entrance, "文章链接")
|
||||
"question" -> DirectUtils.directToQuestionDetail(context, id, entrance, "文章链接", sourceEntrance)
|
||||
|
||||
"real_name" -> DirectUtils.directToRealName(context)
|
||||
|
||||
@ -178,7 +176,7 @@ object DefaultUrlHandler {
|
||||
if ("articles" == type) {
|
||||
DirectUtils.directToCommunityArticle(
|
||||
context, typeId, communityId,
|
||||
entrance, "文章链接"
|
||||
entrance, "文章链接", sourceEntrance
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -246,24 +244,22 @@ object DefaultUrlHandler {
|
||||
act,
|
||||
paginationType,
|
||||
fieldId,
|
||||
sectionName
|
||||
sectionName,
|
||||
sourceEntrance = sourceEntrance
|
||||
)
|
||||
}
|
||||
EntranceConsts.HOST_VIDEO_DETAIL -> {
|
||||
DirectUtils.directToVideoDetail(context, id, entrance, path)
|
||||
DirectUtils.directToVideoDetail(context, id, entrance, path, sourceEntrance)
|
||||
}
|
||||
EntranceConsts.HOST_VIDEO_SINGLE -> {
|
||||
val referer = uri.getQueryParameter("referer") ?: ""
|
||||
DirectUtils.directToVideoDetail(
|
||||
context, id, VideoDetailContainerViewModel.Location.SINGLE_VIDEO.value,
|
||||
false, "", entrance, "", if (TextUtils.isEmpty(referer)) "" else referer
|
||||
false, "", entrance, "", if (TextUtils.isEmpty(referer)) "" else referer, sourceEntrance
|
||||
)
|
||||
}
|
||||
EntranceConsts.HOST_VIDEO_STREAMING_HOME -> {
|
||||
intent = Intent(context, MainActivity::class.java)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
intent.putExtra(MainActivity.SWITCH_TO_VIDEO, true)
|
||||
context.startActivity(intent)
|
||||
DirectUtils.directToHomeVideoTab(context)
|
||||
}
|
||||
EntranceConsts.HOST_VIDEO_STREAMING_DESC -> {
|
||||
directToGameDetailVideoStreaming(context, id, entrance)
|
||||
@ -272,10 +268,6 @@ object DefaultUrlHandler {
|
||||
directToGameVideo(context, id, entrance, "")
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_CATEGORY -> {
|
||||
val title = uri.getQueryParameter("title")
|
||||
DirectUtils.directCategoryDirectory(context, id, title ?: "", entrance, "")
|
||||
}
|
||||
EntranceConsts.HOST_COLUMN_COLLECTION -> {
|
||||
val name = uri.getQueryParameter("name")
|
||||
DirectUtils.directToColumnCollection(context, id, -1, entrance, name ?: "")
|
||||
@ -325,7 +317,7 @@ object DefaultUrlHandler {
|
||||
val linkData = Base64.decode(dataString, Base64.DEFAULT)
|
||||
val linkDataString = String(linkData, Charset.defaultCharset())
|
||||
val le = gson.fromJson(linkDataString, LinkEntity::class.java)
|
||||
directToLinkPage(context, le, entrance, "")
|
||||
directToLinkPage(context, le, entrance, sourceEntrance, "")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
@ -350,7 +342,8 @@ object DefaultUrlHandler {
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_FORUM_DETAIL -> {
|
||||
DirectUtils.directForumDetail(context, id, entrance)
|
||||
val sectionId = uri.getQueryParameter("section_id") ?: ""
|
||||
DirectUtils.directForumDetailSection(context, id, sectionId, entrance)
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_GAME_RATING_DETAIL -> {
|
||||
@ -363,9 +356,8 @@ object DefaultUrlHandler {
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_FORUM -> {
|
||||
val position = uri.getQueryParameter(EntranceConsts.KEY_POSITION)?.toInt()
|
||||
|
||||
DirectUtils.directToForum(context, position ?: 0)
|
||||
DirectUtils.directToHomeCommunityTab(context)
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_UPLOAD_VIDEO_NEW -> {
|
||||
@ -438,17 +430,17 @@ object DefaultUrlHandler {
|
||||
directToFeedback(
|
||||
context,
|
||||
content,
|
||||
null,
|
||||
isQaFeedback,
|
||||
qaContentId,
|
||||
isPlugin = false,
|
||||
isSmoothGame = false,
|
||||
EntranceConsts.ENTRANCE_BROWSER
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_HELP_AND_FEEDBACK -> {
|
||||
val position = uri.getQueryParameter("position") ?: ""
|
||||
DirectUtils.directToHelpAndFeedback(context, position.toInt())
|
||||
DirectUtils.directToHelpAndFeedback(context)
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_HELP_DETAIL -> {
|
||||
@ -489,25 +481,24 @@ object DefaultUrlHandler {
|
||||
val activityName = uri.getQueryParameter("activity_name") ?: ""
|
||||
val gameId = uri.getQueryParameter("game_id") ?: ""
|
||||
context.startActivity(
|
||||
GameCollectionEditActivity.getIntent(
|
||||
GameCollectionEditActivity.getCreateIntent(
|
||||
context,
|
||||
activityId,
|
||||
activityName,
|
||||
gameId,
|
||||
entrance
|
||||
entrance,
|
||||
"其他"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_GAME_LIBRARY -> {
|
||||
DirectUtils.directToMainActivity(context)
|
||||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_GAME))
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_HOME_GAME_COLLECTION_SQUARE -> {
|
||||
DirectUtils.directToMainActivity(context)
|
||||
EventBus.getDefault()
|
||||
.post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_HOME))
|
||||
DirectUtils.directToHomeDefaultTab(context)
|
||||
EventBus.getDefault().post(EBReuse(host))
|
||||
}
|
||||
|
||||
@ -562,7 +553,7 @@ object DefaultUrlHandler {
|
||||
}
|
||||
|
||||
// 处理内部页面逻辑
|
||||
if (transformNormalScheme(context, url, entrance)) {
|
||||
if (transformNormalScheme(context, url, entrance, sourceEntrance)) {
|
||||
return true
|
||||
}
|
||||
|
||||
@ -571,14 +562,14 @@ object DefaultUrlHandler {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun transformNormalScheme(context: Context, url: String, entrance: String): Boolean {
|
||||
val b = transformNewNormalScheme(context, url, entrance)
|
||||
fun transformNormalScheme(context: Context, url: String, entrance: String, sourceEntrance: String): Boolean {
|
||||
val b = transformNewNormalScheme(context, url, entrance, sourceEntrance)
|
||||
if (b) return b
|
||||
return transformOldNormalScheme(context, url, entrance)
|
||||
return transformOldNormalScheme(context, url, entrance, sourceEntrance)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun transformOldNormalScheme(context: Context, url: String, entrance: String): Boolean {
|
||||
fun transformOldNormalScheme(context: Context, url: String, entrance: String, sourceEntrance: String): Boolean {
|
||||
val uri = Uri.parse(url)
|
||||
if (uri.host == "www.ghzs666.com"
|
||||
|| uri.host == "www.ghzs.com"
|
||||
@ -594,6 +585,7 @@ object DefaultUrlHandler {
|
||||
DirectUtils.directToGameDetail(
|
||||
context,
|
||||
gameId,
|
||||
"",
|
||||
entrance,
|
||||
autoDownload = false,
|
||||
traceEvent = null
|
||||
@ -603,7 +595,7 @@ object DefaultUrlHandler {
|
||||
val questionId = split("/")[2]
|
||||
val answerId = uri.getQueryParameter("answer")
|
||||
if (answerId.isNullOrEmpty()) {
|
||||
DirectUtils.directToQuestionDetail(context, questionId, entrance, "")
|
||||
DirectUtils.directToQuestionDetail(context, questionId, entrance, "", sourceEntrance)
|
||||
} else {
|
||||
DirectUtils.directToAnswerDetail(context, answerId, entrance, "")
|
||||
}
|
||||
@ -633,7 +625,7 @@ object DefaultUrlHandler {
|
||||
if ("articles" == type || "article" == type) {
|
||||
DirectUtils.directToCommunityArticle(
|
||||
context, typeId, communityId,
|
||||
entrance, "文章链接"
|
||||
entrance, "文章链接", sourceEntrance
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -664,7 +656,7 @@ object DefaultUrlHandler {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun transformNewNormalScheme(context: Context, url: String, entrance: String): Boolean {
|
||||
fun transformNewNormalScheme(context: Context, url: String, entrance: String, sourceEntrance: String): Boolean {
|
||||
val uri = Uri.parse(url)
|
||||
if (uri.host == "www.ghzs666.com"
|
||||
|| uri.host == "www.ghzs.com"
|
||||
@ -682,7 +674,7 @@ object DefaultUrlHandler {
|
||||
val articleId = splits[2].substring(7)
|
||||
DirectUtils.directToCommunityArticle(
|
||||
context, articleId, "",
|
||||
entrance, "文章链接"
|
||||
entrance, "文章链接", sourceEntrance
|
||||
)
|
||||
}
|
||||
//https://m.ghzs666.com/article/文章ID
|
||||
@ -702,7 +694,7 @@ object DefaultUrlHandler {
|
||||
//https://m.ghzs666.com/bbs/video-视频ID
|
||||
splits.size >= 3 && splits[1] == "bbs" && splits[2].startsWith("video-") -> {
|
||||
val videoId = splits[2].substring(6)
|
||||
DirectUtils.directToVideoDetail(context, videoId, entrance)
|
||||
DirectUtils.directToVideoDetail(context, videoId, entrance, sourceEntrance)
|
||||
}
|
||||
else -> return false
|
||||
}
|
||||
|
||||
@ -2,17 +2,16 @@ package com.gh.common
|
||||
|
||||
import com.gh.common.exposure.ExposureManager
|
||||
import com.gh.common.filter.RegionSettingHelper
|
||||
import com.gh.common.util.AdHelper
|
||||
import com.gh.common.videolog.VideoRecordUtils
|
||||
import com.gh.download.DownloadDataHelper
|
||||
import com.gh.gamecenter.common.loghub.LoghubUtils
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.doOnMainProcessOnly
|
||||
import com.gh.gamecenter.common.utils.tryCatchInRelease
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.gamecenter.entity.TimeEntity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlin.concurrent.fixedRateTimer
|
||||
|
||||
@ -26,7 +25,6 @@ object FixedRateJobHelper {
|
||||
|
||||
private const val DOWNLOAD_HEARTBEAT_PERIOD: Long = 60 * 1000L
|
||||
private const val DOWNLOAD_HEARTBEAT_SHEET_PERIOD: Long = 15 * 1000L
|
||||
private const val STARTUP_AD: Long = 30 * 60 * 1000L
|
||||
|
||||
private var mExecuteCount: Int = 0
|
||||
|
||||
@ -34,63 +32,56 @@ object FixedRateJobHelper {
|
||||
|
||||
@JvmStatic
|
||||
fun begin() {
|
||||
doOnMainProcessOnly {
|
||||
// 时间检查,每15秒检查一次
|
||||
fixedRateTimer("Global-Fixed-Rate-Timer", initialDelay = 100, period = CHECKER_PERIOD) {
|
||||
val elapsedTime = mExecuteCount * CHECKER_PERIOD
|
||||
// 时间校对,10分钟一次
|
||||
if (elapsedTime % TIME_PERIOD == 0L) {
|
||||
RetrofitManager.getInstance().api.time
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<TimeEntity>() {
|
||||
override fun onResponse(response: TimeEntity?) {
|
||||
val serverTime = response?.time
|
||||
serverTime?.let {
|
||||
timeDeltaBetweenServerAndClient = it * 1000 - System.currentTimeMillis()
|
||||
}
|
||||
// 时间检查,每15秒检查一次
|
||||
fixedRateTimer("Global-Fixed-Rate-Timer", initialDelay = 100, period = CHECKER_PERIOD) {
|
||||
val elapsedTime = mExecuteCount * CHECKER_PERIOD
|
||||
// 时间校对,10分钟一次
|
||||
if (elapsedTime % TIME_PERIOD == 0L) {
|
||||
RetrofitManager.getInstance().api.time
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<TimeEntity>() {
|
||||
override fun onResponse(response: TimeEntity?) {
|
||||
val serverTime = response?.time
|
||||
serverTime?.let {
|
||||
timeDeltaBetweenServerAndClient = it * 1000 - System.currentTimeMillis()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 提交曝光数据
|
||||
if (elapsedTime % EXPOSURE_PERIOD == 0L) {
|
||||
ExposureManager.commitSavedExposureEvents(true)
|
||||
}
|
||||
|
||||
// 分片检测下载进度
|
||||
if (elapsedTime % DOWNLOAD_HEARTBEAT_SHEET_PERIOD == 0L) {
|
||||
tryCatchInRelease {
|
||||
val upload = (mExecuteCount * CHECKER_PERIOD) % DOWNLOAD_HEARTBEAT_PERIOD == 0L
|
||||
DownloadDataHelper.uploadDownloadHeartbeat(upload)
|
||||
}
|
||||
}
|
||||
|
||||
// 提交普通 loghub 数据
|
||||
if (elapsedTime % LOGHUB_PERIOD == 0L) {
|
||||
runOnUiThread {
|
||||
LoghubUtils.commitSavedLoghubEvents(true)
|
||||
}
|
||||
}
|
||||
|
||||
// 更新游戏屏蔽信息
|
||||
if (elapsedTime % REGION_SETTING_PERIOD == 0L) {
|
||||
if (HaloApp.getInstance().isRunningForeground) {
|
||||
RegionSettingHelper.getRegionSetting()
|
||||
}
|
||||
}
|
||||
|
||||
// 提交视频浏览记录数据
|
||||
if (elapsedTime % VIDEO_RECORD_PERIOD == 0L) {
|
||||
VideoRecordUtils.commitVideoRecord()
|
||||
}
|
||||
|
||||
// 获取启动广告 (第一次不需要获取)
|
||||
if (elapsedTime % STARTUP_AD == 0L && mExecuteCount != 0) {
|
||||
AdHelper.getSettingAdCache()
|
||||
}
|
||||
|
||||
mExecuteCount++
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 提交曝光数据
|
||||
if (elapsedTime % EXPOSURE_PERIOD == 0L) {
|
||||
ExposureManager.commitSavedExposureEvents(true)
|
||||
}
|
||||
|
||||
// 分片检测下载进度
|
||||
if (elapsedTime % DOWNLOAD_HEARTBEAT_SHEET_PERIOD == 0L) {
|
||||
tryCatchInRelease {
|
||||
val upload = (mExecuteCount * CHECKER_PERIOD) % DOWNLOAD_HEARTBEAT_PERIOD == 0L
|
||||
DownloadDataHelper.uploadDownloadHeartbeat(upload)
|
||||
}
|
||||
}
|
||||
|
||||
// 提交普通 loghub 数据
|
||||
if (elapsedTime % LOGHUB_PERIOD == 0L) {
|
||||
runOnUiThread {
|
||||
LoghubUtils.commitSavedLoghubEvents(true)
|
||||
}
|
||||
}
|
||||
|
||||
// 更新游戏屏蔽信息
|
||||
if (elapsedTime % REGION_SETTING_PERIOD == 0L) {
|
||||
if (HaloApp.getInstance().isRunningForeground) {
|
||||
RegionSettingHelper.getRegionSetting()
|
||||
}
|
||||
}
|
||||
|
||||
// 提交视频浏览记录数据
|
||||
if (elapsedTime % VIDEO_RECORD_PERIOD == 0L) {
|
||||
VideoRecordUtils.commitVideoRecord()
|
||||
}
|
||||
|
||||
mExecuteCount++
|
||||
}
|
||||
}
|
||||
}
|
||||
351
app/src/main/java/com/gh/common/browse/BrowseTimer.kt
Normal file
351
app/src/main/java/com/gh/common/browse/BrowseTimer.kt
Normal file
@ -0,0 +1,351 @@
|
||||
package com.gh.common.browse
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.Message
|
||||
import androidx.lifecycle.*
|
||||
import androidx.lifecycle.Lifecycle.Event
|
||||
|
||||
/**
|
||||
* 浏览时长计时器核心接口类,用于页面浏览时长相关埋点上报
|
||||
*/
|
||||
interface IBrowseTimerCore {
|
||||
/**
|
||||
* 开始计时
|
||||
*/
|
||||
fun start()
|
||||
|
||||
/**
|
||||
* 结束计时
|
||||
*/
|
||||
fun stop()
|
||||
}
|
||||
|
||||
/**
|
||||
* 浏览时长计时器核心实现类
|
||||
*/
|
||||
class BrowseTimerCore internal constructor() : IBrowseTimerCore {
|
||||
|
||||
/**
|
||||
* 延迟执行的时间
|
||||
*/
|
||||
var delayInMills: Long = 3000L
|
||||
|
||||
/**
|
||||
* 开始计时函数回调
|
||||
*/
|
||||
var onStart: (() -> Unit)? = null
|
||||
|
||||
/**
|
||||
* 结束计时函数回调
|
||||
*/
|
||||
var onResult: ((Long) -> Unit)? = null
|
||||
|
||||
/**
|
||||
* 开始计时的时间点
|
||||
*/
|
||||
private var startTimeInMills: Long = 0L
|
||||
|
||||
/**
|
||||
* Handler操作类
|
||||
*/
|
||||
private val handler = object : Handler(Looper.getMainLooper()) {
|
||||
override fun handleMessage(msg: Message) {
|
||||
if (msg.what == MESSAGE_START) {
|
||||
dispatchOnStart()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 延迟执行开始计时
|
||||
* @see delayInMills
|
||||
* @see onStart
|
||||
*/
|
||||
override fun start() {
|
||||
if (delayInMills <= 0) {
|
||||
dispatchOnStart()
|
||||
} else {
|
||||
handler.sendEmptyMessageDelayed(MESSAGE_START, delayInMills)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束计时,统计浏览时长并回调结束计时函数
|
||||
* @see onResult
|
||||
*/
|
||||
override fun stop() {
|
||||
handler.removeMessages(MESSAGE_START)
|
||||
if (startTimeInMills > 0L) {
|
||||
onResult?.invoke(System.currentTimeMillis() - startTimeInMills)
|
||||
startTimeInMills = 0L
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始计时,回调开始计时函数
|
||||
*/
|
||||
private fun dispatchOnStart() {
|
||||
startTimeInMills = System.currentTimeMillis()
|
||||
onStart?.invoke()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val MESSAGE_START = 1
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 无数据浏览计时器接口类
|
||||
*/
|
||||
interface IBrowseTimer : IBrowseTimerCore {
|
||||
|
||||
fun withDelayInMills(delayInMills: Long): IBrowseTimer
|
||||
|
||||
fun withStart(onStart: () -> Unit): IBrowseTimer
|
||||
|
||||
fun withResult(onResult: (Long) -> Unit): IBrowseTimer
|
||||
}
|
||||
|
||||
/**
|
||||
* 无数据的浏览计时器实现类
|
||||
*/
|
||||
class BrowseTimer : IBrowseTimer {
|
||||
|
||||
private val core = BrowseTimerCore()
|
||||
|
||||
private var isStarted: Boolean = false
|
||||
|
||||
override fun withDelayInMills(delayInMills: Long): IBrowseTimer {
|
||||
core.delayInMills = delayInMills
|
||||
return this
|
||||
}
|
||||
|
||||
override fun withStart(onStart: () -> Unit): IBrowseTimer {
|
||||
core.onStart = onStart
|
||||
return this
|
||||
}
|
||||
|
||||
override fun withResult(onResult: (Long) -> Unit): IBrowseTimer {
|
||||
core.onResult = onResult
|
||||
return this
|
||||
}
|
||||
|
||||
override fun start() {
|
||||
if (isStarted) return
|
||||
|
||||
isStarted = true
|
||||
core.start()
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
if (!isStarted) return
|
||||
|
||||
core.stop()
|
||||
isStarted = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 支持Lifecycle的无数据的浏览计时器
|
||||
*/
|
||||
class LifecycleBoundBrowseTimer internal constructor(
|
||||
private val base: IBrowseTimer,
|
||||
private val onStateChanged: (IBrowseTimer, Event) -> Unit
|
||||
) : IBrowseTimer, LifecycleEventObserver {
|
||||
override fun withDelayInMills(delayInMills: Long): IBrowseTimer {
|
||||
return base.withDelayInMills(delayInMills)
|
||||
}
|
||||
|
||||
override fun withStart(onStart: () -> Unit): IBrowseTimer {
|
||||
return base.withStart(onStart)
|
||||
}
|
||||
|
||||
override fun withResult(onResult: (Long) -> Unit): IBrowseTimer {
|
||||
return base.withResult(onResult)
|
||||
}
|
||||
|
||||
override fun start() {
|
||||
base.start()
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
base.stop()
|
||||
}
|
||||
|
||||
override fun onStateChanged(source: LifecycleOwner, event: Event) {
|
||||
onStateChanged.invoke(this, event)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun IBrowseTimer.withLifecycle(
|
||||
owner: LifecycleOwner,
|
||||
onStateChanged: (IBrowseTimer, Event) -> Unit = { timer, event ->
|
||||
when(event) {
|
||||
Event.ON_START -> timer.start()
|
||||
Event.ON_STOP -> timer.stop()
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
): LifecycleBoundBrowseTimer = LifecycleBoundBrowseTimer(this, onStateChanged).apply {
|
||||
owner.lifecycle.addObserver(this)
|
||||
}
|
||||
|
||||
/**
|
||||
* 带数据的浏览计时器接口类
|
||||
*/
|
||||
interface IValueBrowseTimer<T> : IBrowseTimerCore {
|
||||
|
||||
fun withDelayInMills(delayInMills: Long): IValueBrowseTimer<T>
|
||||
|
||||
fun withStart(onStart: (T?) -> Unit): IValueBrowseTimer<T>
|
||||
|
||||
fun withResult(onResult: (T?, Long) -> Unit): IValueBrowseTimer<T>
|
||||
|
||||
fun dispatchValue(value: T?)
|
||||
}
|
||||
|
||||
/**
|
||||
* 带数据的浏览计时器实现类
|
||||
*/
|
||||
class ValueBrowseTimer<T> : IValueBrowseTimer<T> {
|
||||
|
||||
private val core = BrowseTimerCore()
|
||||
|
||||
private var isDispatchValue: Boolean = false
|
||||
|
||||
private var isStarted: Boolean = false
|
||||
|
||||
private var value: T? = null
|
||||
|
||||
override fun withDelayInMills(delayInMills: Long): IValueBrowseTimer<T> {
|
||||
core.delayInMills = delayInMills
|
||||
return this
|
||||
}
|
||||
|
||||
override fun withStart(onStart: (T?) -> Unit): IValueBrowseTimer<T> {
|
||||
core.onStart = { onStart.invoke(value) }
|
||||
return this
|
||||
}
|
||||
|
||||
override fun withResult(onResult: (T?, Long) -> Unit): IValueBrowseTimer<T> {
|
||||
core.onResult = { onResult.invoke(value, it) }
|
||||
return this
|
||||
}
|
||||
|
||||
override fun start() {
|
||||
if (isStarted) return
|
||||
|
||||
isStarted = true
|
||||
|
||||
if (isDispatchValue) {
|
||||
core.start()
|
||||
}
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
if (!isStarted) return
|
||||
|
||||
core.stop()
|
||||
isStarted = false
|
||||
}
|
||||
|
||||
override fun dispatchValue(value: T?) {
|
||||
this.value = value
|
||||
|
||||
if (isStarted && !isDispatchValue) {
|
||||
core.start()
|
||||
}
|
||||
isDispatchValue = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 支持LiveData的带数据的浏览计时器
|
||||
*/
|
||||
class ObserverBoundValueBrowseTimer<T> internal constructor(private val base: IValueBrowseTimer<T>) : IValueBrowseTimer<T>, Observer<T> {
|
||||
override fun withDelayInMills(delayInMills: Long): IValueBrowseTimer<T> {
|
||||
return base.withDelayInMills(delayInMills)
|
||||
}
|
||||
|
||||
override fun withResult(onResult: (T?, Long) -> Unit): IValueBrowseTimer<T> {
|
||||
return base.withResult(onResult)
|
||||
}
|
||||
|
||||
override fun withStart(onStart: (T?) -> Unit): IValueBrowseTimer<T> {
|
||||
return base.withStart(onStart)
|
||||
}
|
||||
|
||||
override fun start() {
|
||||
base.start()
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
base.stop()
|
||||
}
|
||||
|
||||
override fun dispatchValue(value: T?) {
|
||||
base.dispatchValue(value)
|
||||
}
|
||||
|
||||
override fun onChanged(t: T) {
|
||||
dispatchValue(t)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 支持Lifecycle的带数据的浏览计时器
|
||||
*/
|
||||
class LifecycleBoundValueBrowseTimer<T> internal constructor(
|
||||
private val base: IValueBrowseTimer<T>,
|
||||
private val onStateChanged: (IValueBrowseTimer<T>, Event) -> Unit
|
||||
) : IValueBrowseTimer<T>, LifecycleEventObserver {
|
||||
override fun withDelayInMills(delayInMills: Long): IValueBrowseTimer<T> {
|
||||
return base.withDelayInMills(delayInMills)
|
||||
}
|
||||
|
||||
override fun withResult(onResult: (T?, Long) -> Unit): IValueBrowseTimer<T> {
|
||||
return base.withResult(onResult)
|
||||
}
|
||||
|
||||
override fun withStart(onStart: (T?) -> Unit): IValueBrowseTimer<T> {
|
||||
return base.withStart(onStart)
|
||||
}
|
||||
|
||||
override fun start() {
|
||||
base.start()
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
base.stop()
|
||||
}
|
||||
|
||||
override fun dispatchValue(value: T?) {
|
||||
base.dispatchValue(value)
|
||||
}
|
||||
|
||||
override fun onStateChanged(source: LifecycleOwner, event: Event) {
|
||||
onStateChanged.invoke(this, event)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun <T> IValueBrowseTimer<T>.asObserver(): ObserverBoundValueBrowseTimer<T> = ObserverBoundValueBrowseTimer(this)
|
||||
|
||||
fun <T> IValueBrowseTimer<T>.withLifecycle(
|
||||
owner: LifecycleOwner,
|
||||
onStateChanged: (IValueBrowseTimer<T>, Event) -> Unit = { timer, event ->
|
||||
when(event) {
|
||||
Event.ON_START -> timer.start()
|
||||
Event.ON_STOP -> timer.stop()
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
): LifecycleBoundValueBrowseTimer<T> = LifecycleBoundValueBrowseTimer(this, onStateChanged).apply {
|
||||
owner.lifecycle.addObserver(this)
|
||||
}
|
||||
|
||||
@ -1,22 +1,21 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.download.server.BrowserInstallHelper
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class BrowserInstallHandler : ChainHandler() {
|
||||
class BrowserInstallHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
BrowserInstallHelper.showBrowserInstallHintDialog(
|
||||
context,
|
||||
gameEntity.isVGame() || gameEntity.isSplitXApk()
|
||||
gameEntity,
|
||||
asVGame || gameEntity.isSplitXApk()
|
||||
) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.common.dialog.CertificationDialog
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class CertificationHandler : ChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
class ChainBuilder {
|
||||
|
||||
private val handlers: MutableList<ChainHandler> = ArrayList()
|
||||
|
||||
private var processEndCallback: ((Any?) -> Unit)? = null
|
||||
|
||||
fun setProcessEndCallback(callback: (Any?) -> Unit): ChainBuilder {
|
||||
processEndCallback = callback
|
||||
return this
|
||||
}
|
||||
|
||||
fun addHandler(handler: ChainHandler): ChainBuilder {
|
||||
handlers.add(handler)
|
||||
return this
|
||||
}
|
||||
|
||||
fun buildHandlerChain(): ChainHandler? {
|
||||
for (i in handlers.indices) {
|
||||
handlers[i].processEndCallback = processEndCallback
|
||||
if (i + 1 < handlers.size) {
|
||||
handlers[i].setNext(handlers[i + 1])
|
||||
}
|
||||
}
|
||||
return if (handlers.isEmpty()) null else handlers[0]
|
||||
}
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
abstract class ChainHandler {
|
||||
private var next: ChainHandler? = null
|
||||
var processEndCallback: ((Any?) -> Unit)? = null
|
||||
|
||||
fun setNext(next: ChainHandler?) {
|
||||
this.next = next
|
||||
}
|
||||
|
||||
fun getNext(): ChainHandler? {
|
||||
return next
|
||||
}
|
||||
|
||||
fun hasNext(): Boolean {
|
||||
return next != null
|
||||
}
|
||||
|
||||
abstract fun handleRequest(context: Context, gameEntity: GameEntity)
|
||||
|
||||
}
|
||||
@ -5,15 +5,15 @@ import com.gh.common.util.DialogUtils
|
||||
import com.gh.gamecenter.common.utils.safelyGetInRelease
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class CheckDownloadHandler : ChainHandler() {
|
||||
class CheckDownloadHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
val apk = gameEntity.getApk().safelyGetInRelease(0) ?: return
|
||||
DialogUtils.checkDownload(context, apk.size, gameEntity.id, gameEntity.name) { isSubscribe: Boolean ->
|
||||
DialogUtils.checkDownload(context, apk.size, gameEntity.id, gameEntity.name, gameEntity.categoryChinese) { isSubscribe: Boolean ->
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(isSubscribe)
|
||||
processEndCallback?.invoke(asVGame, isSubscribe)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,20 +2,23 @@ package com.gh.common.chain
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.gamecenter.common.utils.PermissionHelper
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class CheckStoragePermissionHandler : ChainHandler() {
|
||||
class CheckStoragePermissionHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(context, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
}
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(
|
||||
context,
|
||||
gameEntity.id,
|
||||
gameEntity.name ?: "",
|
||||
gameEntity.categoryChinese,
|
||||
gameEntity.getApk().firstOrNull()?.format,
|
||||
) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
class DownloadChainBuilder {
|
||||
|
||||
private val handlers: MutableList<DownloadChainHandler> = ArrayList()
|
||||
|
||||
private var processEndCallback: ((asVGame: Boolean, Any?) -> Unit)? = null
|
||||
|
||||
fun setProcessEndCallback(gameId: String, callback: (asVGame: Boolean, Any?) -> Unit): DownloadChainBuilder {
|
||||
processEndCallback = VaPluginDownloadWrapper(gameId = gameId, callback = callback) // 其他需要添加行为的装饰者可以一直包装A(B(C(callback))), 执行顺序 A->B->C->callback
|
||||
return this
|
||||
}
|
||||
|
||||
fun addHandler(handler: DownloadChainHandler): DownloadChainBuilder {
|
||||
handlers.add(handler)
|
||||
return this
|
||||
}
|
||||
|
||||
fun buildHandlerChain(): DownloadChainHandler? {
|
||||
for (i in handlers.indices) {
|
||||
handlers[i].processEndCallback = processEndCallback
|
||||
if (i + 1 < handlers.size) {
|
||||
handlers[i].setNext(handlers[i + 1])
|
||||
}
|
||||
}
|
||||
return if (handlers.isEmpty()) null else handlers[0]
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
abstract class DownloadChainHandler {
|
||||
private var next: DownloadChainHandler? = null
|
||||
|
||||
// asVGame: 当前下载是否以畅玩游戏来进行
|
||||
var processEndCallback: ((asVGame: Boolean, Any?) -> Unit)? = null
|
||||
|
||||
/**
|
||||
* 设置下一个处理者
|
||||
*/
|
||||
fun setNext(next: DownloadChainHandler?) {
|
||||
this.next = next
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一个处理者
|
||||
*/
|
||||
fun getNext(): DownloadChainHandler? {
|
||||
return next
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否存在下一个处理者
|
||||
*/
|
||||
fun hasNext(): Boolean {
|
||||
return next != null
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理请求
|
||||
* @param gameEntity 游戏实体
|
||||
* @param asVGame 是否作为畅玩游戏进行
|
||||
*/
|
||||
abstract fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean)
|
||||
|
||||
}
|
||||
@ -3,21 +3,18 @@ package com.gh.common.chain
|
||||
import android.content.Context
|
||||
import com.gh.common.util.DownloadDialogHelper
|
||||
import com.gh.gamecenter.common.utils.safelyGetInRelease
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class DownloadDialogHelperHandler : ChainHandler() {
|
||||
class DownloadDialogHelperHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
val apk = gameEntity.getApk().safelyGetInRelease(0) ?: return
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
}
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,14 +5,14 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment
|
||||
|
||||
class GamePermissionHandler : ChainHandler() {
|
||||
class GamePermissionHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
GamePermissionDialogFragment.show((context as AppCompatActivity), gameEntity, gameEntity.info) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.common.util.TempCertificationUtils
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class LandPageAddressHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
if (gameEntity.isLandPageAddressDialog()) {
|
||||
TempCertificationUtils.checkCertificationBeforeAction(gameEntity) {
|
||||
if (context is Activity && context.isFinishing) {
|
||||
// 当前 context 已经无效,不需要再传递执行下去了
|
||||
return@checkCertificationBeforeAction
|
||||
}
|
||||
|
||||
DialogUtils.showLandPageAddressDialog(context, gameEntity) {// 跳转第三方落地页
|
||||
if (gameEntity.isLandPageAddressDialogShowOnly()) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
} else {
|
||||
DirectUtils.directToExternalBrowser(context, gameEntity.landPageAddressDialog!!.link!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,17 +1,34 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.common.util.TempCertificationUtils
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class OverseaDownloadHandler : ChainHandler() {
|
||||
class OverseaDownloadHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
DialogUtils.showOverseaDownloadDialog(context, gameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
if (gameEntity.isOverseaAddressDialog()) {
|
||||
TempCertificationUtils.checkCertificationBeforeAction(gameEntity) {
|
||||
if (context is Activity && context.isFinishing) {
|
||||
// 当前 context 已经无效,不需要再传递执行下去了
|
||||
return@checkCertificationBeforeAction
|
||||
}
|
||||
|
||||
DialogUtils.showOverseaDownloadDialog(context, gameEntity) {// 跳转海外下载地址弹窗
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,14 +5,14 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.common.dialog.PackageCheckDialogFragment
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class PackageCheckHandler : ChainHandler() {
|
||||
class PackageCheckHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
PackageCheckDialogFragment.show((context as AppCompatActivity), gameEntity) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,18 +4,20 @@ import android.content.Context
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class UnsupportedFeatureHandler : ChainHandler() {
|
||||
class UnsupportedFeatureHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(
|
||||
context: Context, gameEntity: GameEntity
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
asVGame: Boolean
|
||||
) {
|
||||
if (shouldShowUnsupportedFeatureDialog()) {
|
||||
DialogHelper.showUnsupportedFeatureDialog(context)
|
||||
} else {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,31 +5,27 @@ import com.gh.common.simulator.NewSimulatorGameManager
|
||||
import com.gh.common.simulator.SimulatorGameManager
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class UpdateNewSimulatorHandler: ChainHandler() {
|
||||
class UpdateNewSimulatorHandler: DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
if (NewSimulatorGameManager.shouldShowUpdateNewSimulatorAlert(context)) {
|
||||
NewSimulatorGameManager.showUpdateNewsSimulator(context) {
|
||||
NewSimulatorGameManager.showUpdateNewsSimulator(context, gameEntity) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
import com.gh.vspace.VHelper
|
||||
|
||||
class VaPluginDownloadWrapper(val gameId: String, val callback: (Boolean, Any?) -> Unit) : (Boolean, Any?) -> Unit {
|
||||
override fun invoke(asVGame: Boolean, any: Any?) {
|
||||
callback.invoke(asVGame, any)
|
||||
if (asVGame) {
|
||||
VHelper.initVaPlugin(gameId)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,15 +4,23 @@ import android.content.Context
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.vspace.VHelper
|
||||
|
||||
class ValidateVSpaceHandler : ChainHandler() {
|
||||
class ValidateVSpaceHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
VHelper.validateVSpaceBeforeAction(context, gameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
val closure = {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
|
||||
if (asVGame) {
|
||||
VHelper.validateVSpaceBeforeAction(context,gameEntity.getUniquePackageName(), gameEntity) {
|
||||
closure.invoke()
|
||||
}
|
||||
} else {
|
||||
closure.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,29 +3,59 @@ package com.gh.common.chain
|
||||
import android.content.Context
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge
|
||||
import com.gh.gamecenter.common.utils.toResString
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class VersionNumberHandler : ChainHandler() {
|
||||
class VersionNumberHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
val confirmCallback = {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
if (!gameEntity.isShowVersionNumber()) {
|
||||
confirmCallback.invoke()
|
||||
} else {
|
||||
SensorsBridge.trackGameDemoDialogShow(
|
||||
gameId = gameEntity.id,
|
||||
gameName = gameEntity.name ?: "",
|
||||
gameType = gameEntity.categoryChinese
|
||||
)
|
||||
DialogHelper.showGuideDialog(
|
||||
context,
|
||||
"温馨提示",
|
||||
gameEntity.getVersionNumberString(),
|
||||
"继续下载",
|
||||
R.string.cancel.toResString(),
|
||||
{ confirmCallback.invoke() },
|
||||
{
|
||||
confirmCallback.invoke()
|
||||
SensorsBridge.trackGameDemoDialogClick(
|
||||
buttonName = "继续下载",
|
||||
gameId = gameEntity.id,
|
||||
gameName = gameEntity.name ?: "",
|
||||
gameType = gameEntity.categoryChinese
|
||||
)
|
||||
},
|
||||
cancelClickCallback = {
|
||||
SensorsBridge.trackGameDemoDialogClick(
|
||||
buttonName = R.string.cancel.toResString(),
|
||||
gameId = gameEntity.id,
|
||||
gameName = gameEntity.name ?: "",
|
||||
gameType = gameEntity.categoryChinese
|
||||
)
|
||||
},
|
||||
touchOutsideCallback = {
|
||||
SensorsBridge.trackGameDemoDialogClick(
|
||||
buttonName = "关闭弹窗",
|
||||
gameId = gameEntity.id,
|
||||
gameName = gameEntity.name ?: "",
|
||||
gameType = gameEntity.categoryChinese
|
||||
)
|
||||
},
|
||||
extraConfig = DialogHelper.Config(titleIcon = R.drawable.ic_dialog_tips)
|
||||
)
|
||||
}
|
||||
|
||||
@ -1,49 +1,58 @@
|
||||
package com.gh.common.constant;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.gh.common.util.AdHelper;
|
||||
import com.gh.common.util.PackageHelper;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.common.constant.CommonConsts;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil;
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse;
|
||||
import com.gh.gamecenter.common.retrofit.Response;
|
||||
import com.gh.gamecenter.common.utils.DarkModeUtils;
|
||||
import com.gh.gamecenter.common.utils.EnvHelper;
|
||||
import com.gh.gamecenter.core.AppExecutor;
|
||||
import com.gh.gamecenter.core.utils.GsonUtils;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
import com.gh.gamecenter.core.utils.UrlFilterUtils;
|
||||
import com.gh.gamecenter.entity.AppEntity;
|
||||
import com.gh.gamecenter.entity.GameGuidePopupEntity;
|
||||
import com.gh.gamecenter.entity.NewApiSettingsEntity;
|
||||
import com.gh.gamecenter.entity.NewSettingsEntity;
|
||||
import com.gh.gamecenter.entity.VNewSetting;
|
||||
import com.gh.gamecenter.entity.VSetting;
|
||||
import com.gh.gamecenter.feature.entity.NewsEntity;
|
||||
import com.gh.gamecenter.feature.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.feature.entity.SimulatorEntity;
|
||||
import com.gh.gamecenter.feature.utils.ContentBlockedHelper;
|
||||
import com.gh.gamecenter.receiver.PackageChangeBroadcastReceiver;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.gh.gamecenter.retrofit.service.VApiService;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleSource;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.reactivex.subjects.BehaviorSubject;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
public class Config {
|
||||
@ -60,8 +69,7 @@ public class Config {
|
||||
public static final String WEIBO_APPKEY = BuildConfig.WEIBO_APPKEY;
|
||||
public static final String QUICK_LOGIN_APPID = BuildConfig.QUICK_LOGIN_APPID;
|
||||
public static final String QUICK_LOGIN_APPKEY = BuildConfig.QUICK_LOGIN_APPKEY;
|
||||
// http://www.ghzs666.com/article/${articleId}.html
|
||||
public static final String URL_ARTICLE = "http://www.ghzs666.com/article/"; // ghzs/ghzs666 统一
|
||||
public static final String URL_ARTICLE = "www.ghzs666.com/article/"; // ghzs/ghzs666 统一
|
||||
|
||||
private static final String SETTINGS_KEY = "settingsKey";
|
||||
|
||||
@ -72,139 +80,24 @@ public class Config {
|
||||
private static NewApiSettingsEntity.NightMode mNightModeSetting;
|
||||
private static SimulatorEntity mNewSimulatorEntity;
|
||||
private static VSetting mVSetting;
|
||||
private volatile static VNewSetting mVNewSetting;
|
||||
|
||||
private static AppEntity mNew32UpdateEntity;
|
||||
private static BehaviorSubject<VNewSetting> vNewSettingSubject = BehaviorSubject.create();
|
||||
private static GameGuidePopupEntity mGameGuidePopupEntity;
|
||||
private static SharedPreferences mDefaultSharedPreferences;
|
||||
|
||||
public static final String FIX_DOWNLOAD_KEY = "isFixDownload";
|
||||
public static final String FIX_PLUGIN_KEY = "isFixPlugin";
|
||||
|
||||
public static final int VIDEO_PAGE_SIZE = 21; // 视频列表大多都是一行3个
|
||||
|
||||
public static boolean isShow() {
|
||||
if (SPUtils.getBoolean(Constants.SP_TEENAGER_MODE)) return false;
|
||||
|
||||
if (getPreferences().getBoolean(FIX_DOWNLOAD_KEY, false)) return true;
|
||||
|
||||
if (!isExistDownloadFilter()) return false;
|
||||
|
||||
for (SettingsEntity.Download entity : getSettings().getDownload()) {
|
||||
if ("all".equals(entity.getGame())) {
|
||||
if (entity.getPluginfy() && "normal".equals(entity.getPolicy()) && filterTime(entity.getTime())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isShowDownload(String gameId) {
|
||||
|
||||
if (getPreferences().getBoolean(FIX_DOWNLOAD_KEY, false)) return true;
|
||||
|
||||
if (TextUtils.isEmpty(gameId) || !isExistDownloadFilter())
|
||||
return false;
|
||||
|
||||
for (SettingsEntity.Download entity : getSettings().getDownload()) {
|
||||
if (gameId.equals(entity.getGame())) {
|
||||
if ("normal".equals(entity.getPolicy()) && filterTime(entity.getTime())) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if ("all".equals(entity.getGame())) {
|
||||
if ("normal".equals(entity.getPolicy()) && filterTime(entity.getTime())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* VPN 开关选项是否开启
|
||||
*/
|
||||
public static boolean isVpnOptionEnabled() {
|
||||
if (mNewApiSettingsEntity == null
|
||||
|| mNewApiSettingsEntity.getInstall() == null
|
||||
|| mNewApiSettingsEntity.getInstall().getVpnRequired() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mNewApiSettingsEntity.getInstall().getVpnRequired().getShouldShowVpnOption();
|
||||
}
|
||||
|
||||
public static boolean isShowPlugin(String gameId) {
|
||||
SharedPreferences preferences = getPreferences();
|
||||
boolean isFixPlugin = preferences.getBoolean(FIX_PLUGIN_KEY, false);
|
||||
if (isFixPlugin) return true;
|
||||
|
||||
if (TextUtils.isEmpty(gameId) || !isExistDownloadFilter())
|
||||
return false;
|
||||
|
||||
for (SettingsEntity.Download entity : getSettings().getDownload()) {
|
||||
if (gameId.equals(entity.getGame())) {
|
||||
if (entity.getPluginfy() && filterTime(entity.getTime())) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ("all".equals(entity.getGame())) {
|
||||
if (entity.getPluginfy() && filterTime(entity.getTime())) {
|
||||
preferences.edit().putBoolean(FIX_PLUGIN_KEY, true).apply();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isShowPlugin() {
|
||||
SharedPreferences preferences = getPreferences();
|
||||
boolean isFixPlugin = preferences.getBoolean(FIX_PLUGIN_KEY, false);
|
||||
if (isFixPlugin) return true;
|
||||
|
||||
if (!isExistDownloadFilter())
|
||||
return false;
|
||||
|
||||
for (SettingsEntity.Download entity : getSettings().getDownload()) {
|
||||
if ("all".equals(entity.getGame())) {
|
||||
if (entity.getPluginfy() && filterTime(entity.getTime())) {
|
||||
preferences.edit().putBoolean(FIX_PLUGIN_KEY, true).apply();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean filterTime(SettingsEntity.Download.TimeEntity timeEntity) {
|
||||
long end = timeEntity.getEnd();
|
||||
long start = timeEntity.getStart();
|
||||
long curTime = Utils.getTime(HaloApp.getInstance().getApplication());
|
||||
|
||||
if ((start == 0 || curTime >= start) && (end == 0 || curTime <= end)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return !SPUtils.getBoolean(Constants.SP_TEENAGER_MODE);
|
||||
}
|
||||
|
||||
public static void setSettings(SettingsEntity settingsEntity) {
|
||||
getPreferences().edit().putString(SETTINGS_KEY, GsonUtils.toJson(settingsEntity)).apply();
|
||||
mSettingsEntity = settingsEntity;
|
||||
|
||||
// 更新设置状态
|
||||
mSettingsEntity.showArticleEntrance();
|
||||
mSettingsEntity.showCommunityEntrance();
|
||||
|
||||
// 加载完设置后刷新下
|
||||
PackageHelper.initList();
|
||||
PackageHelper.refreshPackageNameList();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -305,6 +198,37 @@ public class Config {
|
||||
return mVSetting;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static VNewSetting getVNewSettingEntity() {
|
||||
if (mVNewSetting == null) {
|
||||
try {
|
||||
String json = SPUtils.getString(Constants.SP_V_NEW_SETTINGS);
|
||||
if (!TextUtils.isEmpty(json)) {
|
||||
mVNewSetting = GsonUtils.fromJson(json, VNewSetting.class);
|
||||
vNewSettingSubject.onNext(mVNewSetting);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return mVNewSetting;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static Observable<VNewSetting> getVNewSettingObservable() {
|
||||
if (mVNewSetting != null) {
|
||||
return Observable.just(mVNewSetting);
|
||||
} else {
|
||||
return vNewSettingSubject.hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public static AppEntity getNew32UpdateEntity() {
|
||||
return mNew32UpdateEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求网络数据,尝试刷新畅玩相关配置
|
||||
*/
|
||||
@ -313,7 +237,6 @@ public class Config {
|
||||
RetrofitManager.getInstance()
|
||||
.getVApi().getSettings(BuildConfig.VERSION_NAME, Build.VERSION.SDK_INT)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BiResponse<VSetting>() {
|
||||
@Override
|
||||
public void onSuccess(VSetting data) {
|
||||
@ -325,32 +248,40 @@ public class Config {
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public static void getNewSetting() {
|
||||
VApiService vApi = RetrofitManager.getInstance().getVApi();
|
||||
vApi.getNewSettings(BuildConfig.VERSION_NAME, Build.VERSION.SDK_INT).flatMap(new Function<VNewSetting, SingleSource<AppEntity>>() {
|
||||
@Override
|
||||
public SingleSource<AppEntity> apply(VNewSetting data) throws Exception {
|
||||
mVNewSetting = data;
|
||||
vNewSettingSubject.onNext(mVNewSetting);
|
||||
SPUtils.setString(Constants.SP_V_NEW_SETTINGS, GsonUtils.toJson(data));
|
||||
if (data.getVa() != null && data.getVa().getArch32() != null) {
|
||||
String versionNameByPackageName = PackageUtils.getVersionNameByPackageName(data.getVa().getArch32().getPackageName());
|
||||
return vApi.getNewPackageUpdate(
|
||||
BuildConfig.VERSION_NAME,
|
||||
versionNameByPackageName != null ? versionNameByPackageName : "",
|
||||
HaloApp.getInstance().getChannel()
|
||||
);
|
||||
}
|
||||
return Single.error(new IllegalStateException("VNewSetting entity is not expected"));
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(new BiResponse<AppEntity>() {
|
||||
@Override
|
||||
public void onSuccess(AppEntity data) {
|
||||
mNew32UpdateEntity = data;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static GameGuidePopupEntity getGameGuidePopupEntity() {
|
||||
return mGameGuidePopupEntity;
|
||||
}
|
||||
|
||||
private static boolean isExistDownloadFilter() {
|
||||
if (getSettings() == null || getSettings().getDownload() == null || getSettings().getDownload().size() == 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void filterPluginArticle(List<NewsEntity> list) {
|
||||
if (isShowPlugin() || list == null) return;
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
NewsEntity newsEntity = list.get(i);
|
||||
String title = newsEntity.getTitle();
|
||||
if (!TextUtils.isEmpty(title) && title.contains("插件")) {
|
||||
list.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static SharedPreferences getPreferences() {
|
||||
if (mDefaultSharedPreferences == null) {
|
||||
mDefaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication());
|
||||
@ -369,7 +300,6 @@ public class Config {
|
||||
RetrofitManager.getInstance()
|
||||
.getApi().getSettings(PackageUtils.getGhVersionName(), channel)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<SettingsEntity>() {
|
||||
@Override
|
||||
public void onResponse(SettingsEntity response) {
|
||||
@ -381,11 +311,8 @@ public class Config {
|
||||
GsonUtils.toJson(response.getSuggestion()));
|
||||
edit.apply();
|
||||
|
||||
if (!getPreferences().getBoolean(Config.FIX_DOWNLOAD_KEY, false) && Config.isShow()) {
|
||||
getPreferences().edit().putBoolean(Config.FIX_DOWNLOAD_KEY, true).apply();
|
||||
}
|
||||
if (!SPUtils.getBoolean(Constants.SP_TEENAGER_MODE)) {
|
||||
EventBus.getDefault().post(new EBReuse("Refresh"));
|
||||
AppExecutor.getUiExecutor().execute(() -> EventBus.getDefault().post(new EBReuse("Refresh")));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -393,7 +320,6 @@ public class Config {
|
||||
RetrofitManager.getInstance()
|
||||
.getApi().getNewSettings(Build.MANUFACTURER, Build.MODEL, channel, Build.VERSION.SDK_INT, BuildConfig.VERSION_NAME)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BiResponse<NewSettingsEntity>() {
|
||||
@Override
|
||||
public void onSuccess(NewSettingsEntity data) {
|
||||
@ -403,11 +329,11 @@ public class Config {
|
||||
});
|
||||
|
||||
refreshVSettingEntity();
|
||||
getNewSetting();
|
||||
|
||||
RetrofitManager.getInstance()
|
||||
.getApi().getGameGuidePopup(Build.MANUFACTURER, Build.VERSION.RELEASE, Build.MODEL, channel, BuildConfig.VERSION_NAME)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BiResponse<GameGuidePopupEntity>() {
|
||||
@Override
|
||||
public void onSuccess(GameGuidePopupEntity data) {
|
||||
@ -419,7 +345,6 @@ public class Config {
|
||||
if (manufacturer.equals("OPPO") || manufacturer.equals("VIVO")) {
|
||||
RetrofitManager.getInstance().getNewApi().getBrowserHintUrl(manufacturer)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BiResponse<ResponseBody>() {
|
||||
@Override
|
||||
public void onSuccess(ResponseBody data) {
|
||||
@ -443,12 +368,13 @@ public class Config {
|
||||
String filterString = UrlFilterUtils.getFilterQuery(
|
||||
"manufacturer", Build.MANUFACTURER,
|
||||
"model", Build.MODEL,
|
||||
"android_sdk_version", String.valueOf(Build.VERSION.SDK_INT));
|
||||
"android_sdk_version", String.valueOf(Build.VERSION.SDK_INT),
|
||||
"rom", MetaUtil.INSTANCE.getRom().name() + " " + MetaUtil.INSTANCE.getRom().getVersionName()
|
||||
);
|
||||
|
||||
RetrofitManager.getInstance()
|
||||
.getNewApi().getNewSettings(PackageUtils.getGhVersionName(), channel, filterString)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BiResponse<NewApiSettingsEntity>() {
|
||||
@Override
|
||||
public void onSuccess(NewApiSettingsEntity data) {
|
||||
@ -457,12 +383,39 @@ public class Config {
|
||||
mNewSimulatorEntity = data.getSimulator();
|
||||
if (HaloApp.getInstance().isNewForThisVersion && mNightModeSetting != null && mNightModeSetting.getInstall()) {
|
||||
DarkModeUtils.INSTANCE.updateFollowSystemDarkModeToSp(true);
|
||||
DarkModeUtils.INSTANCE.initDarkMode();
|
||||
AppExecutor.getUiExecutor().execute(DarkModeUtils.INSTANCE::initDarkMode);
|
||||
}
|
||||
AdHelper.prefetchStartUpAd(mNewApiSettingsEntity);
|
||||
SPUtils.setString(Constants.SP_NEW_API_SETTINGS, GsonUtils.toJson(data));
|
||||
|
||||
// 刷新屏蔽字段
|
||||
if (mNewApiSettingsEntity.getGameShieldContents() != null) {
|
||||
ContentBlockedHelper.INSTANCE.init(mNewApiSettingsEntity.getGameShieldContents());
|
||||
}
|
||||
|
||||
// 更新安装列表是否开启的配置
|
||||
if (mNewApiSettingsEntity.getInstalledComplianceSwitch() != null) {
|
||||
PackageHelper.INSTANCE.updateIsGetInstalledPackagesApiAgreedRequired(mNewApiSettingsEntity.getInstalledComplianceSwitch());
|
||||
} else {
|
||||
PackageHelper.INSTANCE.updateIsGetInstalledPackagesApiAgreedRequired(false);
|
||||
}
|
||||
|
||||
// 更新包名监听是否开启
|
||||
if (mNewApiSettingsEntity.isPackageObserveEnable()) {
|
||||
AppExecutor.getUiExecutor().execute(() -> observePackageChange(mNewApiSettingsEntity.getPackageObserveActions()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void observePackageChange(NewApiSettingsEntity.PackageObserveActions packageObserveActions) {
|
||||
PackageChangeBroadcastReceiver receiver = new PackageChangeBroadcastReceiver(packageObserveActions);
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction(packageObserveActions.getAdd());
|
||||
intentFilter.addAction(packageObserveActions.getRem());
|
||||
intentFilter.addAction(packageObserveActions.getRep());
|
||||
intentFilter.addDataScheme("package");
|
||||
HaloApp.getInstance().registerReceiver(receiver, intentFilter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -13,14 +13,14 @@ import android.widget.PopupWindow
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.databinding.BindingAdapter
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.callback.OnViewClickListener
|
||||
import com.gh.gamecenter.common.databinding.LayoutPopupContainerBinding
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.utils.toDrawable
|
||||
import com.gh.gamecenter.common.view.BugFixedPopupWindow
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.KaifuAddItemBinding
|
||||
import com.gh.gamecenter.databinding.LayoutAddKaifuPopupBinding
|
||||
import com.gh.gamecenter.databinding.LayoutPopupContainerBinding
|
||||
import com.gh.gamecenter.feature.entity.ServerCalendarEntity
|
||||
import com.gh.gamecenter.servers.add.AddKaiFuPopupAdapter
|
||||
import java.text.SimpleDateFormat
|
||||
@ -120,13 +120,13 @@ object AddKaiFuBindingAdapter {
|
||||
@BindingAdapter("kaiFuTextColor", "kaiFuTextPosition")
|
||||
fun kaiFuTextColor(view: EditText, dataMark: Int, position: Int) {
|
||||
if (dataMark == 1 && view.id == R.id.kaifu_add_time || dataMark == 2 && view.id == R.id.kaifu_add_first_name || dataMark == 3 && view.id == R.id.kaifu_add_server_name || dataMark == 4) {
|
||||
view.setTextColor(ContextCompat.getColor(view.context, R.color.theme_red))
|
||||
view.setHintTextColor(ContextCompat.getColor(view.context, R.color.theme_red))
|
||||
view.setTextColor(ContextCompat.getColor(view.context, R.color.secondary_red))
|
||||
view.setHintTextColor(ContextCompat.getColor(view.context, R.color.secondary_red))
|
||||
} else if (position == 0) {
|
||||
view.setTextColor(ContextCompat.getColor(view.context, R.color.hint))
|
||||
view.setHintTextColor(ContextCompat.getColor(view.context, R.color.hint))
|
||||
} else {
|
||||
view.setTextColor(ContextCompat.getColor(view.context, R.color.text_title))
|
||||
view.setTextColor(ContextCompat.getColor(view.context, R.color.text_primary))
|
||||
view.setHintTextColor(ContextCompat.getColor(view.context, R.color.hint))
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,31 +3,25 @@ package com.gh.common.databind;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.common.chain.BrowserInstallHandler;
|
||||
import com.gh.common.chain.CertificationHandler;
|
||||
import com.gh.common.chain.ChainBuilder;
|
||||
import com.gh.common.chain.ChainHandler;
|
||||
import com.gh.common.chain.DownloadChainBuilder;
|
||||
import com.gh.common.chain.DownloadChainHandler;
|
||||
import com.gh.common.chain.CheckDownloadHandler;
|
||||
import com.gh.common.chain.CheckStoragePermissionHandler;
|
||||
import com.gh.common.chain.DownloadDialogHelperHandler;
|
||||
import com.gh.common.chain.GamePermissionHandler;
|
||||
import com.gh.common.chain.LandPageAddressHandler;
|
||||
import com.gh.common.chain.OverseaDownloadHandler;
|
||||
import com.gh.common.chain.PackageCheckHandler;
|
||||
import com.gh.common.chain.UnsupportedFeatureHandler;
|
||||
@ -45,7 +39,6 @@ import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.GameUtils;
|
||||
import com.gh.common.util.GameViewUtils;
|
||||
import com.gh.common.util.LogUtils;
|
||||
import com.gh.common.util.NewsUtils;
|
||||
import com.gh.common.util.PackageInstaller;
|
||||
import com.gh.common.util.PackageLauncher;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
@ -56,24 +49,18 @@ import com.gh.download.server.BrowserInstallHelper;
|
||||
import com.gh.gamecenter.DownloadManagerActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.WebActivity;
|
||||
import com.gh.gamecenter.common.baselist.LoadStatus;
|
||||
import com.gh.gamecenter.common.callback.OnViewClickListener;
|
||||
import com.gh.gamecenter.common.entity.LinkEntity;
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.common.utils.DarkModeUtils;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.utils.FileUtils;
|
||||
import com.gh.gamecenter.common.utils.ImageUtils;
|
||||
import com.gh.gamecenter.common.view.DrawableView;
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils;
|
||||
import com.gh.gamecenter.common.utils.NewFlatLogUtils;
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge;
|
||||
import com.gh.gamecenter.core.utils.MtaHelper;
|
||||
import com.gh.gamecenter.core.utils.NumberUtils;
|
||||
import com.gh.gamecenter.core.utils.ToastUtils;
|
||||
import com.gh.gamecenter.databinding.KaifuDetailItemRowBinding;
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity;
|
||||
import com.gh.gamecenter.feature.entity.CommunityVideoEntity;
|
||||
import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.feature.entity.PluginLocation;
|
||||
import com.gh.gamecenter.feature.entity.ServerCalendarEntity;
|
||||
import com.gh.gamecenter.feature.entity.TagStyleEntity;
|
||||
import com.gh.gamecenter.feature.entity.TestEntity;
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent;
|
||||
@ -82,149 +69,21 @@ import com.gh.gamecenter.feature.view.DownloadButton;
|
||||
import com.gh.gamecenter.feature.view.GameIconView;
|
||||
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.gh.vspace.VDownloadManagerActivity;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.download.FileUtils;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import kotlin.collections.CollectionsKt;
|
||||
|
||||
/**
|
||||
* Created by khy on 12/02/18.
|
||||
*/
|
||||
|
||||
public class BindingAdapters {
|
||||
|
||||
public static void loadIcon(SimpleDraweeView view, String imageUrl) {
|
||||
ImageUtils.displayIcon(view, imageUrl);
|
||||
}
|
||||
|
||||
public static void loadImage(SimpleDraweeView view, String imageUrl) {
|
||||
ImageUtils.display(view, imageUrl);
|
||||
}
|
||||
|
||||
public static void setTextSize(TextView view, int number) {
|
||||
view.setTextSize(number);
|
||||
}
|
||||
|
||||
public static void setTypeface(TextView view, String type) {
|
||||
if (type == null) return;
|
||||
|
||||
switch (type) {
|
||||
case "bold":
|
||||
view.setTypeface(null, Typeface.BOLD);
|
||||
break;
|
||||
case "italic":
|
||||
view.setTypeface(null, Typeface.ITALIC);
|
||||
break;
|
||||
case "bold_italic":
|
||||
view.setTypeface(null, Typeface.BOLD_ITALIC);
|
||||
break;
|
||||
default:
|
||||
view.setTypeface(null, Typeface.NORMAL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void addDetailKaiFuView(LinearLayout view, List<ServerCalendarEntity> list
|
||||
, OnViewClickListener listener, Boolean isReadyPatch) {
|
||||
if (list == null) return;
|
||||
view.removeAllViews();
|
||||
for (int i = 0; i < list.size() + 1; i++) { // 1 is Title
|
||||
View inflate = LayoutInflater.from(view.getContext()).inflate(R.layout.kaifu_detail_item_row, null);
|
||||
KaifuDetailItemRowBinding binding = KaifuDetailItemRowBinding.bind(inflate);
|
||||
binding.getRoot().setBackgroundColor(isReadyPatch != null && isReadyPatch ? ExtensionsKt.toColor(R.color.theme) : ExtensionsKt.toColor(R.color.white));
|
||||
binding.getRoot().setPadding(DisplayUtils.dip2px(1), DisplayUtils.dip2px(1), DisplayUtils.dip2px(1), i == list.size() ? DisplayUtils.dip2px(1) : 0);
|
||||
ServerCalendarEntity serverEntity = list.get(i - 1);
|
||||
binding.timeTv.setText(i == 0 ? "时间" : serverEntity.getFormatTime("HH:mm"));
|
||||
binding.remarkTv.setText(i == 0 ? "备注" : serverEntity.getRemark());
|
||||
binding.nameTv.setText(i == 0 ? "名字" : (TextUtils.isEmpty(serverEntity.getNote()) ? "-" : serverEntity.getNote()));
|
||||
if (i != 0) {
|
||||
binding.getRoot().setOnClickListener(v -> {
|
||||
listener.onClick(v, isReadyPatch != null && isReadyPatch ? serverEntity : null);
|
||||
});
|
||||
|
||||
// 滑动冲突处理
|
||||
binding.getRoot().setOnTouchListener((v, event) -> {
|
||||
if (list.size() > 5) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
EventBus.getDefault().post(new EBReuse("CalenderDown"));
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||
EventBus.getDefault().post(new EBReuse("CalenderCancel"));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
view.addView(inflate);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果超过10000,则转换为1.0W
|
||||
public static void transSimpleCount(TextView view, int count) {
|
||||
view.setText(NumberUtils.transSimpleCount(count));
|
||||
}
|
||||
|
||||
public static void textColorFromString(TextView tv, String hexString) {
|
||||
if (TextUtils.isEmpty(hexString)) return;
|
||||
|
||||
try {
|
||||
tv.setTextColor(Color.parseColor(hexString));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void showHide(View view, Boolean show) {
|
||||
if (show != null && show) {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
view.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void goneIf(View view, Boolean gone) {
|
||||
if (gone != null && gone) {
|
||||
view.setVisibility(View.GONE);
|
||||
} else {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* lazy 的 paddingTop
|
||||
*/
|
||||
public static void lazyPaddingLeft(View view, int paddingLeftInDp) {
|
||||
view.setPadding(DisplayUtils.dip2px(paddingLeftInDp), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom());
|
||||
}
|
||||
|
||||
/**
|
||||
* lazy 的 paddingTop
|
||||
*/
|
||||
public static void lazyPaddingTop(View view, int paddingTopInDp) {
|
||||
view.setPadding(view.getPaddingLeft(), DisplayUtils.dip2px(paddingTopInDp), view.getPaddingRight(), view.getPaddingBottom());
|
||||
}
|
||||
|
||||
/**
|
||||
* lazy 的 paddingBottom
|
||||
*/
|
||||
public static void lazyPaddingBottom(View view, int paddingBottomInDp) {
|
||||
view.setPadding(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), DisplayUtils.dip2px(paddingBottomInDp));
|
||||
}
|
||||
|
||||
public static void visibleInvisible(View view, Boolean show) {
|
||||
if (show != null && show) {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
view.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setMessageUnread(TextView view, int unreadCount) {
|
||||
if (unreadCount < 100) {
|
||||
view.setText(String.valueOf(unreadCount));
|
||||
@ -233,117 +92,19 @@ public class BindingAdapters {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setServerTypePadding(TextView view, String serverType) {
|
||||
int paddRight = 0;
|
||||
if (TextUtils.isEmpty(serverType)) {
|
||||
} else {
|
||||
if ("删档内测".equals(serverType) || "不删档内测".equals(serverType)) {
|
||||
if ("删档内测".equals(serverType)) {
|
||||
paddRight = DisplayUtils.dip2px(view.getContext(), 50);
|
||||
} else {
|
||||
paddRight = DisplayUtils.dip2px(view.getContext(), 60);
|
||||
}
|
||||
} else {
|
||||
paddRight = DisplayUtils.dip2px(view.getContext(), 30);
|
||||
}
|
||||
}
|
||||
view.setPadding(0, 0, paddRight, 0);
|
||||
}
|
||||
|
||||
public static void setServerType(TextView view, String serverType) {
|
||||
view.setText(serverType);
|
||||
if ("删档内测".equals(serverType) || "不删档内测".equals(serverType)) {
|
||||
view.setBackgroundResource(R.drawable.textview_server_tag);
|
||||
} else {
|
||||
view.setBackgroundResource(R.drawable.textview_orange_up);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setGame(View view, GameEntity gameEntity) {
|
||||
if (gameEntity != null && view instanceof GameIconView) {
|
||||
((GameIconView) view).displayGameIcon(gameEntity);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setGameIcon(View view, GameEntity gameEntity) {
|
||||
if (gameEntity != null && view instanceof GameIconView) {
|
||||
((GameIconView) view).displayGameIcon(gameEntity.getIcon(), gameEntity.getIconSubscript(), gameEntity.getIconFloat());
|
||||
}
|
||||
}
|
||||
|
||||
public static void setArticleType(TextView view, String articleType) {
|
||||
NewsUtils.setNewsType(view, articleType, 0, 0);
|
||||
}
|
||||
|
||||
public static void setDetailDownloadText(TextView view, GameEntity gameEntity) {
|
||||
if (gameEntity == null || gameEntity.getApk().isEmpty()) {
|
||||
view.setBackgroundResource(R.drawable.game_item_btn_pause_style);
|
||||
view.setTextColor(0xFF999999);
|
||||
view.setClickable(false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setLiBaoBtn(TextView view, String status) {
|
||||
if (TextUtils.isEmpty(status)) return;
|
||||
switch (status) {
|
||||
case "coming":
|
||||
view.setText(R.string.libao_coming);
|
||||
view.setBackgroundResource(R.drawable.textview_blue_style);
|
||||
break;
|
||||
case "ling":
|
||||
view.setText(R.string.libao_ling);
|
||||
view.setBackgroundResource(R.drawable.textview_green_style);
|
||||
break;
|
||||
case "tao":
|
||||
view.setText(R.string.libao_tao);
|
||||
view.setBackgroundResource(R.drawable.textview_orange_style);
|
||||
break;
|
||||
case "used_up":
|
||||
view.setText(R.string.libao_used_up);
|
||||
view.setBackgroundResource(R.drawable.textview_cancel_up);
|
||||
break;
|
||||
case "finish":
|
||||
view.setText(R.string.libao_finish);
|
||||
view.setBackgroundResource(R.drawable.textview_cancel_up);
|
||||
break;
|
||||
case "linged":
|
||||
view.setText(R.string.libao_linged);
|
||||
view.setBackgroundResource(R.drawable.libao_linged_style);
|
||||
view.setTextColor(ContextCompat.getColorStateList(view.getContext(), R.color.libao_linged_selector));
|
||||
break;
|
||||
case "taoed":
|
||||
view.setText(R.string.libao_taoed);
|
||||
view.setBackgroundResource(R.drawable.libao_taoed_style);
|
||||
view.setTextColor(ContextCompat.getColorStateList(view.getContext(), R.color.libao_taoed_selector));
|
||||
break;
|
||||
case "copy":
|
||||
view.setText(R.string.libao_copy);
|
||||
view.setBackgroundResource(R.drawable.textview_blue_style);
|
||||
break;
|
||||
case "repeatLing":
|
||||
view.setText(R.string.libao_repeat_ling);
|
||||
view.setBackgroundResource(R.drawable.textview_cancel_up);
|
||||
break;
|
||||
case "repeatLinged":
|
||||
view.setText(R.string.libao_repeat_ling);
|
||||
view.setBackgroundResource(R.drawable.textview_green_style);
|
||||
break;
|
||||
case "repeatTao":
|
||||
view.setText(R.string.libao_repeat_tao);
|
||||
view.setBackgroundResource(R.drawable.textview_cancel_up);
|
||||
break;
|
||||
case "repeatTaoed":
|
||||
view.setText(R.string.libao_repeat_tao);
|
||||
view.setBackgroundResource(R.drawable.textview_orange_style);
|
||||
break;
|
||||
case "unshelve":
|
||||
view.setBackgroundResource(R.drawable.textview_cancel_style);
|
||||
view.setText(R.string.libao_unshelve);
|
||||
break;
|
||||
default:
|
||||
view.setBackgroundResource(R.drawable.textview_cancel_style);
|
||||
view.setText("异常");
|
||||
}
|
||||
public static void setDownloadButton(DownloadButton progressBar,
|
||||
GameEntity gameEntity,
|
||||
ExposureEvent traceEvent,
|
||||
@Nullable View.OnClickListener clickCallBack,
|
||||
@Nullable String entrance,
|
||||
@Nullable String location) {
|
||||
setDownloadButton(progressBar, gameEntity, traceEvent, clickCallBack, entrance, location, "其他");
|
||||
}
|
||||
|
||||
// 大图下的进度条
|
||||
@ -352,14 +113,14 @@ public class BindingAdapters {
|
||||
ExposureEvent traceEvent,
|
||||
@Nullable View.OnClickListener clickCallBack,
|
||||
@Nullable String entrance,
|
||||
@Nullable String location) {
|
||||
@Nullable String location,
|
||||
String sourceEntrance) {
|
||||
|
||||
// 恢复DialogFragment
|
||||
restoreDialogFragment(progressBar);
|
||||
|
||||
// 判断是否显示按钮
|
||||
if (gameEntity != null
|
||||
&& Config.isShowDownload(gameEntity.getId())
|
||||
&& !"光环助手".equals(gameEntity.getName())) {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
@ -373,13 +134,9 @@ public class BindingAdapters {
|
||||
switch (progressBar.getButtonStyle()) {
|
||||
case DOWNLOADING_PLUGIN:
|
||||
case DOWNLOADING_NORMAL:
|
||||
if (gameEntity.isVGame()) {
|
||||
v.getContext().startActivity(VDownloadManagerActivity.getIntent(v.getContext(), true));
|
||||
} else {
|
||||
Intent intent = DownloadManagerActivity.getDownloadMangerIntent(v.getContext(),
|
||||
gameEntity.getApk().get(0).getUrl(), entrance);
|
||||
v.getContext().startActivity(intent);
|
||||
}
|
||||
Intent intent = DownloadManagerActivity.getDownloadMangerIntent(v.getContext(),
|
||||
gameEntity.getApk().isEmpty() ? "" : gameEntity.getApk().get(0).getUrl(), entrance);
|
||||
v.getContext().startActivity(intent);
|
||||
break;
|
||||
case NONE:
|
||||
Utils.toast(v.getContext(), "该游戏已关闭下载");
|
||||
@ -397,12 +154,12 @@ public class BindingAdapters {
|
||||
boolean isInstalled = PackageUtils.isInstalledFromAllPackage(v.getContext(), gameEntity.getSimulator().getApk().getPackageName());
|
||||
if (downloadEntity != null && SimulatorGameManager.isSimulatorGame(gameEntity) && !isInstalled) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(v.getContext(), gameEntity.getSimulator(),
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.getId(), gameEntity.getName(), null);
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.getId(), gameEntity.getName(), gameEntity.getCategoryChinese(), null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ChainBuilder builder = new ChainBuilder();
|
||||
DownloadChainBuilder builder = new DownloadChainBuilder();
|
||||
builder.addHandler(new UnsupportedFeatureHandler());
|
||||
builder.addHandler(new GamePermissionHandler());
|
||||
builder.addHandler(new CheckStoragePermissionHandler());
|
||||
@ -410,27 +167,37 @@ public class BindingAdapters {
|
||||
builder.addHandler(new BrowserInstallHandler());
|
||||
builder.addHandler(new PackageCheckHandler());
|
||||
builder.addHandler(new DownloadDialogHelperHandler());
|
||||
builder.addHandler(new CertificationHandler());
|
||||
builder.addHandler(new VersionNumberHandler());
|
||||
builder.addHandler(new LandPageAddressHandler());
|
||||
builder.addHandler(new OverseaDownloadHandler());
|
||||
builder.addHandler(new CheckDownloadHandler());
|
||||
|
||||
builder.setProcessEndCallback(o -> {
|
||||
download(v.getContext(), progressBar, gameEntity, traceEvent, (boolean) o, entrance, location);
|
||||
builder.setProcessEndCallback(gameEntity.getId(), (asVGame, isSubscribe) -> {
|
||||
download(v.getContext(),
|
||||
progressBar,
|
||||
gameEntity,
|
||||
traceEvent,
|
||||
asVGame,
|
||||
(boolean) isSubscribe,
|
||||
entrance,
|
||||
location);
|
||||
return null;
|
||||
});
|
||||
final ChainHandler chainHandler = builder.buildHandlerChain();
|
||||
final DownloadChainHandler chainHandler = builder.buildHandlerChain();
|
||||
if (chainHandler != null) {
|
||||
chainHandler.handleRequest(v.getContext(), gameEntity);
|
||||
chainHandler.handleRequest(
|
||||
v.getContext(),
|
||||
gameEntity,
|
||||
GameUtils.shouldPerformAsVGame(gameEntity)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
ChainBuilder builder = new ChainBuilder();
|
||||
DownloadChainBuilder builder = new DownloadChainBuilder();
|
||||
builder.addHandler(new UnsupportedFeatureHandler());
|
||||
builder.addHandler(new GamePermissionHandler());
|
||||
builder.addHandler(new CertificationHandler());
|
||||
builder.addHandler(new VersionNumberHandler());
|
||||
|
||||
builder.setProcessEndCallback(o -> {
|
||||
builder.setProcessEndCallback(gameEntity.getId(), (asVGame, isSubscribe) -> {
|
||||
DownloadDialog.showDownloadDialog(
|
||||
v.getContext(),
|
||||
gameEntity,
|
||||
@ -439,9 +206,13 @@ public class BindingAdapters {
|
||||
location + ":" + gameEntity.getName());
|
||||
return null;
|
||||
});
|
||||
final ChainHandler chainHandler = builder.buildHandlerChain();
|
||||
final DownloadChainHandler chainHandler = builder.buildHandlerChain();
|
||||
if (chainHandler != null) {
|
||||
chainHandler.handleRequest(v.getContext(), gameEntity);
|
||||
chainHandler.handleRequest(
|
||||
v.getContext(),
|
||||
gameEntity,
|
||||
GameUtils.shouldPerformAsVGame(gameEntity)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -450,11 +221,18 @@ public class BindingAdapters {
|
||||
if (gameEntity.getApk().size() == 1) {
|
||||
//启动模拟器游戏
|
||||
if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
DownloadEntity downloadEntity = SimulatorGameManager.findDownloadEntityByUrl(gameEntity.getApk().get(0).getUrl());
|
||||
DownloadEntity downloadEntity = SimulatorGameManager.findDownloadEntityByUrl(gameEntity.getApk().isEmpty() ? "" : gameEntity.getApk().get(0).getUrl());
|
||||
if (downloadEntity != null) {
|
||||
File file = new File(downloadEntity.getPath());
|
||||
if (!file.exists()) {
|
||||
download(v.getContext(), progressBar, gameEntity, traceEvent, false, entrance, location);
|
||||
download(v.getContext(),
|
||||
progressBar,
|
||||
gameEntity,
|
||||
traceEvent,
|
||||
false,
|
||||
false,
|
||||
entrance,
|
||||
location);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -463,12 +241,7 @@ public class BindingAdapters {
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameEntity.isVGame()) {
|
||||
VHelper.installOrLaunch((AppCompatActivity) v.getContext(), gameEntity, null);
|
||||
return;
|
||||
}
|
||||
|
||||
PackageLauncher.launchApp(v.getContext(), gameEntity, gameEntity.getApk().get(0).getPackageName());
|
||||
PackageLauncher.launch(v.getContext(), gameEntity, null);
|
||||
} else {
|
||||
DownloadDialog.showDownloadDialog(
|
||||
v.getContext(),
|
||||
@ -481,22 +254,34 @@ public class BindingAdapters {
|
||||
case INSTALL_PLUGIN:
|
||||
case INSTALL_NORMAL:
|
||||
if (gameEntity.getApk().size() == 1) {
|
||||
|
||||
NewFlatLogUtils.INSTANCE.logGameInstall(
|
||||
gameEntity.getId(),
|
||||
gameEntity.getName() != null ? gameEntity.getName() : "",
|
||||
"主动安装"
|
||||
);
|
||||
|
||||
SensorsBridge.trackInstallGameClick(
|
||||
gameEntity.getId(),
|
||||
gameEntity.getName() != null ? gameEntity.getName() : "",
|
||||
"主动安装"
|
||||
);
|
||||
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity);
|
||||
|
||||
if (gameEntity.isVGame()) {
|
||||
VHelper.installOrLaunch(v.getContext(), gameEntity, null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (downloadEntity != null) {
|
||||
PackageInstaller.install(v.getContext(), downloadEntity);
|
||||
if (ExtensionsKt.isLocalDownloadInDualDownloadMode(downloadEntity)) {
|
||||
PackageInstaller.install(v.getContext(), downloadEntity);
|
||||
} else {
|
||||
VHelper.installOrLaunch(v.getContext(), gameEntity, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RESERVABLE:
|
||||
GamePermissionDialogFragment.show((AppCompatActivity) v.getContext(), gameEntity, gameEntity.getInfo(), () -> {
|
||||
CheckLoginUtils.checkLogin(progressBar.getContext(), "", () -> {
|
||||
ReservationHelper.reserve(v.getContext(), gameEntity.getId(), gameEntity.getName(), () -> {
|
||||
ReservationHelper.reserve(v.getContext(), gameEntity, sourceEntrance, () -> {
|
||||
LogUtils.logReservation(gameEntity, traceEvent);
|
||||
updateReservation(progressBar, gameEntity);
|
||||
});
|
||||
@ -575,7 +360,7 @@ public class BindingAdapters {
|
||||
}
|
||||
|
||||
} else {
|
||||
String status = GameUtils.getDownloadBtnText(progressBar.getContext(), gameEntity, PluginLocation.only_game);
|
||||
String status = GameUtils.getDownloadBtnText(progressBar.getContext(), gameEntity, true, false, PluginLocation.only_game);
|
||||
switch (status) {
|
||||
case "插件化":
|
||||
progressBar.setButtonStyle(DownloadButton.ButtonStyle.PLUGIN);
|
||||
@ -647,24 +432,6 @@ public class BindingAdapters {
|
||||
}
|
||||
}
|
||||
|
||||
/*private static void download(DownloadProgressBar progressBar, GameEntity gameEntity, ExposureEvent traceEvent, @Nullable String entrance, @Nullable String location, View v) {
|
||||
if (gameEntity.getApk().size() == 1) {
|
||||
ApkEntity apk = gameEntity.getApk().get(0);
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(
|
||||
v.getContext(),
|
||||
gameEntity,
|
||||
apk,
|
||||
() -> {
|
||||
DialogUtils.checkDownload(v.getContext(), apk.getSize(),
|
||||
isSubscribe -> download(progressBar, gameEntity, traceEvent, isSubscribe, entrance, location));
|
||||
});
|
||||
} else {
|
||||
DownloadDialog.getInstance(v.getContext()).showPopupWindow(v, gameEntity,
|
||||
entrance, location + gameEntity.getName(), traceEvent);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
private static void updateReservation(DownloadButton progressBar, GameEntity gameEntity) {
|
||||
// 显示预约
|
||||
if (gameEntity.isReservable()) {
|
||||
@ -684,45 +451,35 @@ public class BindingAdapters {
|
||||
DownloadButton progressBar,
|
||||
GameEntity gameEntity,
|
||||
ExposureEvent traceEvent,
|
||||
boolean asVGame,
|
||||
boolean isSubscribe,
|
||||
String entrance,
|
||||
String location) {
|
||||
if (BrowserInstallHelper.shouldAutoSwitchAssistantInstall(gameEntity)) {
|
||||
ToastUtils.toast(context.getString(R.string.unsupported_browser_install_hint));
|
||||
}
|
||||
String str = progressBar.getText().toString();
|
||||
String method;
|
||||
if (str.contains("更新")) {
|
||||
method = "更新";
|
||||
} else if (str.contains("插件化")) {
|
||||
method = "插件化";
|
||||
} else {
|
||||
method = progressBar.getContext().getString(R.string.download);
|
||||
}
|
||||
ApkEntity apkEntity = gameEntity.getApk().get(0);
|
||||
String msg = FileUtils.isCanDownload(progressBar.getContext(), apkEntity.getSize());
|
||||
if (TextUtils.isEmpty(msg)) {
|
||||
String buttonText = progressBar.getText();
|
||||
ApkEntity apkEntity = CollectionsKt.firstOrNull(gameEntity.getApk());
|
||||
String msg = FileUtils.isCanDownload(progressBar.getContext(), apkEntity == null ? "" : apkEntity.getSize());
|
||||
if (apkEntity != null && TextUtils.isEmpty(msg)) {
|
||||
DownloadManager.createDownload(progressBar.getContext(),
|
||||
apkEntity,
|
||||
gameEntity,
|
||||
method,
|
||||
asVGame,
|
||||
gameEntity.isDualBtnModeEnabled(),
|
||||
entrance,
|
||||
location + gameEntity.getName(),
|
||||
isSubscribe,
|
||||
traceEvent);
|
||||
|
||||
progressBar.setProgress(0);
|
||||
progressBar.setButtonStyle("插件化".equals(method) ?
|
||||
progressBar.setButtonStyle(buttonText.contains("插件化") ?
|
||||
DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN : DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
} else {
|
||||
Utils.toast(progressBar.getContext(), msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setGameLabelList(LinearLayout layout, List<TagStyleEntity> tagStyle) {
|
||||
GameViewUtils.setLabelList(layout.getContext(), layout, tagStyle);
|
||||
}
|
||||
|
||||
// 包含测试开服标签
|
||||
public static void setGameTags(LinearLayout layout, GameEntity gameEntity) {
|
||||
try {
|
||||
@ -792,17 +549,10 @@ public class BindingAdapters {
|
||||
}
|
||||
}
|
||||
|
||||
public static void isRefreshing(SwipeRefreshLayout layout, LoadStatus status) {
|
||||
if (status != LoadStatus.INIT_LOADING && status != LoadStatus.LIST_LOADING) {
|
||||
layout.setRefreshing(false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setGameName(TextView view, GameEntity game, boolean isShowPlatform, @Nullable Boolean isShowSuffix) {
|
||||
if (isShowSuffix == null) isShowSuffix = true; // 默认显示
|
||||
public static void setGameName(TextView view, GameEntity game, boolean isShowPlatform) {
|
||||
String gameName;
|
||||
if (isShowPlatform && game.getApk().size() > 0) {
|
||||
gameName = String.format("%s - %s", !isShowSuffix ? game.getNameWithoutSuffix() : game.getName(),
|
||||
gameName = String.format("%s - %s", game.getName(),
|
||||
PlatformUtils.getInstance(view.getContext()).getPlatformName(
|
||||
game.getApk().get(0).getPlatform()));
|
||||
if (!gameName.equals((String) view.getTag(R.string.tag_game_name_id))) {
|
||||
@ -810,7 +560,7 @@ public class BindingAdapters {
|
||||
view.setTag(R.string.tag_game_name_id, gameName);
|
||||
}
|
||||
} else {
|
||||
gameName = !isShowSuffix ? game.getNameWithoutSuffix() : game.getName();
|
||||
gameName = game.getName();
|
||||
if (gameName != null && !gameName.equals((String) view.getTag(R.string.tag_game_name_id))) {
|
||||
view.setText(gameName);
|
||||
view.setTag(R.string.tag_game_name_id, gameName);
|
||||
@ -819,30 +569,6 @@ public class BindingAdapters {
|
||||
|
||||
}
|
||||
|
||||
public static void setCommunityImage(SimpleDraweeView imageView, List<String> images, List<CommunityVideoEntity> videos) {
|
||||
if (videos.size() > 0) {
|
||||
CommunityVideoEntity videoEntity = videos.get(0);
|
||||
ImageUtils.display(imageView, videoEntity.getPoster());
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
} else if (images.size() > 0) {
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
ImageUtils.display(imageView, images.get(0));
|
||||
} else {
|
||||
imageView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setCommunityVideoDuration(TextView mVideoDuration, List<CommunityVideoEntity> videos) {
|
||||
if (videos != null && videos.size() > 0) {
|
||||
CommunityVideoEntity videoEntity = videos.get(0);
|
||||
mVideoDuration.setBackground(DrawableView.getOvalDrawable(R.color.black_alpha_50, 999F));
|
||||
mVideoDuration.setText(videoEntity.getDuration());
|
||||
mVideoDuration.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mVideoDuration.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setGameTags(TextView view, List<TagStyleEntity> tags, int maxTags) {
|
||||
if (tags == null) {
|
||||
view.setText("");
|
||||
@ -870,16 +596,4 @@ public class BindingAdapters {
|
||||
}
|
||||
view.setText(span);
|
||||
}
|
||||
|
||||
public static void setVideoData(TextView view, int count) {
|
||||
if (count > 0) {
|
||||
ExtensionsKt.setDrawableStart(view, ContextCompat.getDrawable(view.getContext(), R.drawable.ic_video_data_up), null, null);
|
||||
view.setTextColor(ContextCompat.getColor(view.getContext(), R.color.text_EA3333));
|
||||
view.setText(count + "");
|
||||
} else {
|
||||
ExtensionsKt.removeDrawable(view);
|
||||
view.setTextColor(ContextCompat.getColor(view.getContext(), R.color.text_subtitleDesc));
|
||||
view.setText("-");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ class ApplyModeratorDialogFragment : BaseDialogFragment() {
|
||||
requireContext(),
|
||||
startText.length,
|
||||
startText.length + mGroupNumber.length,
|
||||
R.color.theme_font,
|
||||
R.color.text_theme,
|
||||
true
|
||||
) {
|
||||
DirectUtils.directToQqGroup(
|
||||
|
||||
@ -1,221 +0,0 @@
|
||||
package com.gh.common.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.CheckBox
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.gamecenter.common.avoidcallback.AvoidOnResultManager
|
||||
import com.gh.gamecenter.common.avoidcallback.Callback
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.ShellActivity
|
||||
import com.gh.gamecenter.common.callback.ConfirmListener
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge
|
||||
import com.gh.gamecenter.core.utils.GsonUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.feature.entity.AuthDialogEntity
|
||||
import com.gh.gamecenter.feature.entity.AuthDialogLevel
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.halo.assistant.fragment.user.UserInfoEditFragment
|
||||
import com.lightgame.utils.AppManager
|
||||
|
||||
class CertificationDialog(
|
||||
context: Context,
|
||||
private val authDialogEntity: AuthDialogEntity,
|
||||
val gameEntity: GameEntity,
|
||||
val listener: ConfirmListener
|
||||
) :
|
||||
Dialog(context, R.style.GhAlertDialog) {
|
||||
|
||||
private lateinit var view: View
|
||||
private lateinit var detailedDesTv: TextView
|
||||
private lateinit var noRemindAgainCb: CheckBox
|
||||
private lateinit var actionLeftTv: TextView
|
||||
private lateinit var actionRightTv: TextView
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||
view = LayoutInflater.from(context).inflate(R.layout.dialog_sertification, null)
|
||||
setContentView(view)
|
||||
detailedDesTv = view.findViewById(R.id.detailedDesTv)
|
||||
noRemindAgainCb = view.findViewById(R.id.noRemindAgainCb)
|
||||
actionLeftTv = view.findViewById(R.id.actionLeftTv)
|
||||
actionRightTv = view.findViewById(R.id.actionRightTv)
|
||||
|
||||
detailedDesTv.paint.flags = Paint.UNDERLINE_TEXT_FLAG
|
||||
detailedDesTv.paint.isAntiAlias = true
|
||||
|
||||
detailedDesTv.setOnClickListener {
|
||||
DirectUtils.directToWebView(context, authDialogEntity.link)
|
||||
}
|
||||
|
||||
when (authDialogEntity.level) {
|
||||
AuthDialogLevel.MUST_PASS.value -> {
|
||||
actionLeftTv.text = "暂不下载"
|
||||
actionRightTv.text = "去实名认证"
|
||||
noRemindAgainCb.visibility = View.GONE
|
||||
actionLeftTv.setOnClickListener {
|
||||
SensorsBridge.trackEvent("VerificationPopupClick", "button_name", actionLeftTv.text.toString())
|
||||
dismiss()
|
||||
}
|
||||
actionRightTv.setOnClickListener {
|
||||
SensorsBridge.trackEvent("VerificationPopupClick", "button_name", actionRightTv.text.toString())
|
||||
if (UserManager.getInstance().isLoggedIn) {
|
||||
gotoAuthPage()
|
||||
} else {
|
||||
gotoLoginPage()
|
||||
}
|
||||
}
|
||||
}
|
||||
AuthDialogLevel.ALWAYS_HINT.value -> {
|
||||
actionLeftTv.text = "去实名认证"
|
||||
actionRightTv.text = "继续下载"
|
||||
noRemindAgainCb.visibility = View.GONE
|
||||
actionLeftTv.setOnClickListener {
|
||||
SensorsBridge.trackEvent("VerificationPopupClick", "button_name", actionLeftTv.text.toString())
|
||||
if (UserManager.getInstance().isLoggedIn) {
|
||||
gotoAuthPage()
|
||||
} else {
|
||||
gotoLoginPage()
|
||||
}
|
||||
}
|
||||
actionRightTv.setOnClickListener {
|
||||
SensorsBridge.trackEvent("VerificationPopupClick", "button_name", actionRightTv.text.toString())
|
||||
listener.onConfirm()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
AuthDialogLevel.OPTIONAL_HINT.value -> {
|
||||
actionLeftTv.text = "去实名认证"
|
||||
actionRightTv.text = "继续下载"
|
||||
noRemindAgainCb.visibility = View.VISIBLE
|
||||
actionLeftTv.setOnClickListener {
|
||||
SensorsBridge.trackEvent("VerificationPopupClick", "button_name", actionLeftTv.text.toString())
|
||||
if (noRemindAgainCb.isChecked) {
|
||||
SPUtils.setBoolean(gameEntity.id, true)
|
||||
}
|
||||
if (UserManager.getInstance().isLoggedIn) {
|
||||
gotoAuthPage()
|
||||
} else {
|
||||
gotoLoginPage()
|
||||
}
|
||||
}
|
||||
actionRightTv.setOnClickListener {
|
||||
SensorsBridge.trackEvent("VerificationPopupClick", "button_name", actionRightTv.text.toString())
|
||||
if (noRemindAgainCb.isChecked) {
|
||||
SPUtils.getBoolean(gameEntity.id, true)
|
||||
}
|
||||
listener.onConfirm()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SensorsBridge.trackEvent(
|
||||
"VerificationDialogShow",
|
||||
"game_id",
|
||||
gameEntity.id,
|
||||
"game_name",
|
||||
gameEntity.name ?: "",
|
||||
"game_type",
|
||||
gameEntity.categoryChinese
|
||||
)
|
||||
}
|
||||
|
||||
//跳转登录页面
|
||||
private fun gotoLoginPage() {
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
CheckLoginUtils.checkLogin(
|
||||
currentActivity as AppCompatActivity,
|
||||
null, true, "实名认证弹窗"
|
||||
) {
|
||||
if (UserManager.getInstance().isAuth) {
|
||||
listener.onConfirm()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//跳转实名认证页面
|
||||
private fun gotoAuthPage() {
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
AvoidOnResultManager.getInstance(currentActivity as AppCompatActivity)
|
||||
.startForResult(
|
||||
ShellActivity.getIntent(
|
||||
context,
|
||||
ShellActivity.Type.REAL_NAME_INFO,
|
||||
).apply {
|
||||
putExtra(EntranceConsts.KEY_GAME_ID, gameEntity.id)
|
||||
}, object : Callback {
|
||||
override fun onActivityResult(resultCode: Int, data: Intent?) {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
val isAuthSuccess =
|
||||
data.getBooleanExtra(UserInfoEditFragment.AUTH_SUCCESS, false)
|
||||
if (isAuthSuccess) {
|
||||
listener.onConfirm()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun showCertificationDialog(context: Context, game: GameEntity, listener: ConfirmListener) {
|
||||
//1.先判断是否登录 是执行2 否执行3
|
||||
//2.判断是否实名认证 是终止 否执行3
|
||||
//3.判断是否需要弹出认证弹窗接口
|
||||
if (UserManager.getInstance().isLoggedIn) {
|
||||
if (UserManager.getInstance().isAuth) {//已实名认证
|
||||
listener.onConfirm()
|
||||
} else {
|
||||
authDialog(context, game, listener)
|
||||
}
|
||||
} else {
|
||||
authDialog(context, game, listener)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun authDialog(context: Context, game: GameEntity, listener: ConfirmListener) {
|
||||
var authDialog: AuthDialogEntity? = null
|
||||
if (game.authDialog != null) {
|
||||
authDialog = game.authDialog
|
||||
}
|
||||
if (authDialog == null) {
|
||||
val datas = SPUtils.getString(Constants.SP_AUTH_DIALOG)
|
||||
val type = object : TypeToken<List<AuthDialogEntity>>() {}.type
|
||||
val authDialogs = GsonUtils.gson.fromJson<List<AuthDialogEntity>>(datas, type)
|
||||
if (!authDialogs.isNullOrEmpty()) {
|
||||
authDialog = authDialogs.find { it.gameCategory == game.category }
|
||||
}
|
||||
}
|
||||
val isCloseAuthDialog = SPUtils.getBoolean(game.id, false)
|
||||
if (authDialog != null && (authDialog.level != AuthDialogLevel.OPTIONAL_HINT.value || !isCloseAuthDialog)) {
|
||||
val dialog = CertificationDialog(context, authDialog, game, listener)
|
||||
dialog.show()
|
||||
} else {
|
||||
listener.onConfirm()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -23,6 +23,7 @@ class GameOffServiceDialogFragment : BaseDialogFragment() {
|
||||
|
||||
private var mDialog: GameEntity.Dialog? = null
|
||||
private var mBinding: DialogGameOffServiceBinding? = null
|
||||
private var mCallback: (() -> Unit)? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -44,6 +45,7 @@ class GameOffServiceDialogFragment : BaseDialogFragment() {
|
||||
titleTv.text = title
|
||||
contentTv.text = HtmlCompat.fromHtml(content, HtmlCompat.FROM_HTML_MODE_LEGACY)
|
||||
okTv.setOnClickListener {
|
||||
mCallback?.invoke()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
@ -60,11 +62,10 @@ class GameOffServiceDialogFragment : BaseDialogFragment() {
|
||||
if (index == notEmptySite.size - 1) bottomMargin = 8F.dip2px()
|
||||
}
|
||||
siteTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14F)
|
||||
siteTv.setTextColor(R.color.theme_font.toColor(requireContext()))
|
||||
siteTv.setTextColor(R.color.text_theme.toColor(requireContext()))
|
||||
siteTv.text = site.text
|
||||
siteTv.paintFlags = siteTv.paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
||||
siteTv.setOnClickListener {
|
||||
// MtaHelper.onEvent("游戏下载状态按钮", getKey(), site.text)
|
||||
DirectUtils.directToWebView(requireContext(), site.url, "(关闭下载弹窗)")
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
@ -83,11 +84,13 @@ class GameOffServiceDialogFragment : BaseDialogFragment() {
|
||||
const val KEY_DIALOG = "dialog"
|
||||
|
||||
@JvmStatic
|
||||
fun getInstance(dialog: GameEntity.Dialog) = GameOffServiceDialogFragment().apply {
|
||||
arguments = Bundle().apply {
|
||||
putParcelable(KEY_DIALOG, dialog)
|
||||
fun getInstance(dialog: GameEntity.Dialog, callback: (() -> Unit)? = null) =
|
||||
GameOffServiceDialogFragment().apply {
|
||||
arguments = Bundle().apply {
|
||||
putParcelable(KEY_DIALOG, dialog)
|
||||
}
|
||||
mCallback = callback
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.common.dialog
|
||||
|
||||
import android.app.Activity.RESULT_OK
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
@ -18,13 +19,10 @@ import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.utils.PermissionHelper
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.utils.PermissionHelper.INSTALL_PERMISSION_CODE
|
||||
import com.gh.gamecenter.common.utils.getExtension
|
||||
import com.gh.gamecenter.common.utils.goneIf
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.utils.Utils
|
||||
import kotlin.random.Random
|
||||
|
||||
class InstallPermissionDialogFragment : BaseDialogFragment() {
|
||||
@ -34,8 +32,11 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
|
||||
var url: String = ""
|
||||
var gameId: String = ""
|
||||
var gameName: String = ""
|
||||
var gameType: String = ""
|
||||
var mCallBack: ((isFromPermissionGrantedCallback: Boolean) -> Unit)? = null
|
||||
|
||||
private var dismissByTouchInside = false
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
mView = inflater.inflate(R.layout.dialog_install_permission, null, false)
|
||||
return mView
|
||||
@ -55,6 +56,12 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
|
||||
|
||||
if (isXapk) NewFlatLogUtils.logXApkInstallPermissionDialogShowed(gameId, gameName)
|
||||
|
||||
SensorsBridge.trackInstallPermissionDialogShow(
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameType
|
||||
)
|
||||
|
||||
val randomNumber = if (isXapk) 1 else Random.nextInt(2)
|
||||
closeTv.goneIf(randomNumber == 0)
|
||||
closeIv.goneIf(randomNumber != 0)
|
||||
@ -64,18 +71,38 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
|
||||
closeTv.setOnClickListener {
|
||||
dismissByTouchInside = true
|
||||
if (isXapk) {
|
||||
NewFlatLogUtils.logXApkInstallPermissionDialogClick("尝试解压", false, gameId, gameName)
|
||||
mCallBack?.invoke(false)
|
||||
}
|
||||
SensorsBridge.trackInstallPermissionDialogClick(
|
||||
buttonName = "尝试解压",
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameType
|
||||
)
|
||||
dismiss()
|
||||
}
|
||||
closeIv.setOnClickListener {
|
||||
dismissByTouchInside = true
|
||||
if (isXapk) NewFlatLogUtils.logXApkInstallPermissionDialogClick("关闭", false, gameId, gameName)
|
||||
SensorsBridge.trackInstallPermissionDialogClick(
|
||||
buttonName = "关闭",
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameType
|
||||
)
|
||||
dismiss()
|
||||
}
|
||||
activateTv.setOnClickListener {
|
||||
NewFlatLogUtils.logXApkInstallPermissionDialogClick("立即开启", false, gameId, gameName)
|
||||
SensorsBridge.trackInstallPermissionDialogClick(
|
||||
buttonName = "立即开启",
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameType
|
||||
)
|
||||
PermissionHelper.toInstallPermissionSetting(requireActivity())
|
||||
if (isXapk) {
|
||||
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, requireActivity().javaClass.name)
|
||||
@ -84,9 +111,23 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
if (!dismissByTouchInside) {
|
||||
SensorsBridge.trackInstallPermissionDialogClick(
|
||||
buttonName = "关闭弹窗",
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameType
|
||||
)
|
||||
}
|
||||
super.onDismiss(dialog)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode == RESULT_OK && requestCode == INSTALL_PERMISSION_CODE) {
|
||||
dismissByTouchInside = true
|
||||
|
||||
NewFlatLogUtils.logXApkInstallPermissionDialogClick("立即开启", true, gameId, gameName)
|
||||
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
|
||||
@ -117,7 +158,7 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
if (isXapk) {
|
||||
val xapkUnzipVersions = Config.getSettings()?.permissionPopupAppliedVersions?.xapkUnzip
|
||||
if (xapkUnzipVersions?.contains(Build.VERSION.SDK_INT.toString()) == false) {
|
||||
if (xapkUnzipVersions?.contains(Build.VERSION.SDK_INT.toString()) == false || XapkInstaller.systemHasFlaw) {
|
||||
callBack?.invoke(false)
|
||||
return
|
||||
}
|
||||
@ -136,6 +177,7 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
|
||||
installPermissionDialogFragment.url = downloadEntity.url
|
||||
installPermissionDialogFragment.gameId = downloadEntity.gameId
|
||||
installPermissionDialogFragment.gameName = downloadEntity.name
|
||||
installPermissionDialogFragment.gameType = downloadEntity.categoryChinese
|
||||
val transaction: FragmentTransaction = activity.supportFragmentManager.beginTransaction()
|
||||
transaction.show(installPermissionDialogFragment)
|
||||
transaction.commit()
|
||||
@ -146,6 +188,7 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
|
||||
this.url = downloadEntity.url
|
||||
this.gameId = downloadEntity.gameId
|
||||
this.gameName = downloadEntity.name
|
||||
this.gameType = downloadEntity.categoryChinese
|
||||
}
|
||||
installPermissionDialogFragment.show(
|
||||
activity.supportFragmentManager,
|
||||
|
||||
@ -76,7 +76,7 @@ class NewPrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
contentText.setSpan(object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.theme_font)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.text_theme)
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package com.gh.common.dialog
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.content.pm.PackageInfo
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
@ -11,12 +12,14 @@ import android.view.animation.LinearInterpolator
|
||||
import android.widget.LinearLayout
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.common.util.LogUtils
|
||||
import com.gh.common.util.PackageHelper
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.R
|
||||
@ -57,10 +60,12 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
private val mDuration = 3000
|
||||
private var mDisposable: Disposable? = null
|
||||
private var mAdapter: PackageCheckAdapter? = null
|
||||
private var mAllInstalledPackages = PackageUtils.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
private var mAllInstalledPackages = PackageHelper.getInstalledPackageNameList(HaloApp.getInstance().application, 0)
|
||||
var gameEntity: GameEntity? = null
|
||||
var callBack: ConfirmListener? = null
|
||||
|
||||
private var mDismissByTouchInside = false
|
||||
|
||||
private val dataWatcher = object : DataWatcher() {
|
||||
override fun onDataChanged(downloadEntity: DownloadEntity) {
|
||||
val packageName = downloadEntity.packageName
|
||||
@ -90,6 +95,11 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
EventBus.getDefault().register(this)
|
||||
gameEntity?.let {
|
||||
LogUtils.uploadPackageCheck("pkg_check_pop_click", "出现弹窗", it, "", "", "", "")
|
||||
SensorsBridge.trackPkgCheckDialogShow(
|
||||
gameId = it.id,
|
||||
gameName = it.name ?: "",
|
||||
gameType = it.categoryChinese
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,7 +126,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
requireContext(),
|
||||
0,
|
||||
(link.title ?: "").length,
|
||||
R.color.theme_font,
|
||||
R.color.text_theme,
|
||||
true
|
||||
) {
|
||||
LogUtils.uploadPackageCheck(
|
||||
@ -128,6 +138,18 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
"",
|
||||
""
|
||||
)
|
||||
SensorsBridge.trackPkgCheckDialogClick(
|
||||
buttonName = "点击链接",
|
||||
gameId = gameEntity?.id ?: "",
|
||||
gameName = gameEntity?.name ?: "",
|
||||
gameType = gameEntity?.categoryChinese ?: "",
|
||||
isNotPrompt = if (binding.noRemindAgainCb.isVisible) {
|
||||
binding.noRemindAgainCb.isChecked
|
||||
} else null,
|
||||
linkId = link.link ?: "",
|
||||
linkType = link.type ?: "",
|
||||
linkText = link.linkText ?: ""
|
||||
)
|
||||
DirectUtils.directToLinkPage(requireContext(), link, "包名检测弹窗", "")
|
||||
}.build()
|
||||
spanBuilder.append(linkSpan)
|
||||
@ -176,6 +198,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
val isAllPackageInstalled = isAllPackageInstalled(mAllInstalledPackages, entity)
|
||||
if (isAllPackageInstalled) {
|
||||
mDismissByTouchInside = true
|
||||
callBack?.onConfirm()
|
||||
dismissAllowingStateLoss()
|
||||
} else {
|
||||
@ -193,6 +216,15 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
"",
|
||||
""
|
||||
)
|
||||
SensorsBridge.trackPkgCheckDialogClick(
|
||||
buttonName = "点击前往下载",
|
||||
gameId = gameEntity?.id ?: "",
|
||||
gameName = gameEntity?.name ?: "",
|
||||
gameType = gameEntity?.categoryChinese ?: "",
|
||||
isNotPrompt = if (binding.noRemindAgainCb.isVisible) {
|
||||
binding.noRemindAgainCb.isChecked
|
||||
} else null
|
||||
)
|
||||
DirectUtils.directToLinkPage(requireContext(), packageLink, "包名检测弹窗", "")
|
||||
}
|
||||
}
|
||||
@ -206,6 +238,19 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
saveRecord(entity)
|
||||
LogUtils.uploadPackageCheck("pkg_check_pop_click", "不再提示", gameEntity, "", "", "", "")
|
||||
}
|
||||
|
||||
mDismissByTouchInside = true
|
||||
|
||||
SensorsBridge.trackPkgCheckDialogClick(
|
||||
buttonName = binding.cancelTv.text.toString(),
|
||||
gameId = gameEntity?.id ?: "",
|
||||
gameName = gameEntity?.name ?: "",
|
||||
gameType = gameEntity?.categoryChinese ?: "",
|
||||
isNotPrompt = if (binding.noRemindAgainCb.isVisible) {
|
||||
binding.noRemindAgainCb.isChecked
|
||||
} else null
|
||||
)
|
||||
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
@ -281,7 +326,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mAllInstalledPackages = PackageUtils.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
mAllInstalledPackages = PackageHelper.getInstalledPackageNameList(HaloApp.getInstance().application, 0)
|
||||
gameEntity?.packageDialog?.let {
|
||||
if (isAllPackageInstalled(mAllInstalledPackages, it)) {
|
||||
callBack?.onConfirm()
|
||||
@ -300,11 +345,26 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
DownloadManager.getInstance().removeObserver(dataWatcher)
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
if (!mDismissByTouchInside) {
|
||||
SensorsBridge.trackPkgCheckDialogClick(
|
||||
buttonName = "关闭弹窗",
|
||||
gameId = gameEntity?.id ?: "",
|
||||
gameName = gameEntity?.name ?: "",
|
||||
gameType = gameEntity?.categoryChinese ?: "",
|
||||
isNotPrompt = if (binding.noRemindAgainCb.isVisible) {
|
||||
binding.noRemindAgainCb.isChecked
|
||||
} else null
|
||||
)
|
||||
}
|
||||
super.onDismiss(dialog)
|
||||
}
|
||||
|
||||
//安装、卸载事件
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(busFour: EBPackage) {
|
||||
if (busFour.isInstalledOrUninstalled()) {
|
||||
mAllInstalledPackages = PackageUtils.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
mAllInstalledPackages = PackageHelper.getInstalledPackageNameList(HaloApp.getInstance().application, 0)
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
@ -332,10 +392,10 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
val isAllInstalled = checkDetectionsInstalled(mAllInstalledPackages, entity.packages)
|
||||
if (isAllInstalled) {
|
||||
holder.binding.statusTv.text = "已安装"
|
||||
holder.binding.statusTv.setTextColor(ContextCompat.getColor(context, R.color.theme_font))
|
||||
holder.binding.statusTv.setTextColor(ContextCompat.getColor(context, R.color.text_theme))
|
||||
} else {
|
||||
holder.binding.statusTv.text = "未安装"
|
||||
holder.binding.statusTv.setTextColor(ContextCompat.getColor(context, R.color.theme_red))
|
||||
holder.binding.statusTv.setTextColor(ContextCompat.getColor(context, R.color.secondary_red))
|
||||
}
|
||||
holder.binding.statusTv.visibility = View.VISIBLE
|
||||
} else {
|
||||
@ -357,7 +417,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
return
|
||||
}
|
||||
|
||||
val allInstalledPackages = PackageUtils.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
val allInstalledPackages = PackageHelper.getInstalledPackageNameList(HaloApp.getInstance().application, 0)
|
||||
if (isAllPackageInstalled(allInstalledPackages, packageDialogEntity)) {
|
||||
callBack.onConfirm()
|
||||
return
|
||||
@ -394,12 +454,12 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
|
||||
private fun checkDetectionsInstalled(
|
||||
allInstalledPackages: List<PackageInfo>,
|
||||
allInstalledPackages: List<String>,
|
||||
packages: ArrayList<String>
|
||||
): Boolean {
|
||||
var isPackagesInstalled = false
|
||||
packages.forEach { packageName ->
|
||||
val isInstalled = allInstalledPackages.find { it.packageName == packageName } != null
|
||||
val isInstalled = allInstalledPackages.find { it == packageName } != null
|
||||
if (isInstalled) {
|
||||
isPackagesInstalled = true
|
||||
return@forEach
|
||||
@ -410,7 +470,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
|
||||
|
||||
fun isAllPackageInstalled(
|
||||
allInstalledPackages: List<PackageInfo>,
|
||||
allInstalledPackages: List<String>,
|
||||
packageDialogEntity: PackageDialogEntity
|
||||
): Boolean {
|
||||
var isAllInstalled = true
|
||||
|
||||
@ -29,6 +29,15 @@ class PrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
private var mCallBack: ((isSuccess: Boolean) -> Unit)? = null
|
||||
private val mBinding by lazy { DialogPrivacyProtocolBinding.inflate(layoutInflater) }
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
dismiss()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
@ -59,7 +68,7 @@ class PrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
skipText.setSpan(object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.theme_font)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.text_theme)
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
|
||||
@ -101,7 +110,7 @@ class PrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
skipText.setSpan(object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.theme_font)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.text_theme)
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
|
||||
@ -115,7 +124,7 @@ class PrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
skipText.setSpan(object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.theme_font)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.text_theme)
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
|
||||
|
||||
@ -6,16 +6,16 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
|
||||
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
||||
import com.gh.gamecenter.common.utils.ImageUtils
|
||||
import com.gh.gamecenter.common.utils.fromHtml
|
||||
import com.gh.gamecenter.GameDetailActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
|
||||
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
||||
import com.gh.gamecenter.common.entity.SimpleGameEntity
|
||||
import com.gh.gamecenter.common.utils.ImageUtils
|
||||
import com.gh.gamecenter.common.utils.fromHtml
|
||||
import com.gh.gamecenter.common.view.FixLinearLayoutManager
|
||||
import com.gh.gamecenter.databinding.DialogReserveBinding
|
||||
import com.gh.gamecenter.databinding.DialogReserveItemBinding
|
||||
import com.gh.gamecenter.common.entity.SimpleGameEntity
|
||||
import com.gh.gamecenter.mygame.MyGameActivity
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter
|
||||
|
||||
@ -24,6 +24,15 @@ class ReserveDialog : BaseDialogFragment() {
|
||||
private lateinit var mReserveList: List<SimpleGameEntity>
|
||||
private var mDismissListener: (() -> Unit)? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
dismiss()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
val binding: DialogReserveBinding = DialogReserveBinding.inflate(layoutInflater, null, false)
|
||||
|
||||
@ -34,7 +43,7 @@ class ReserveDialog : BaseDialogFragment() {
|
||||
View.VISIBLE
|
||||
} else View.GONE
|
||||
binding.more.setOnClickListener {
|
||||
val intent = MyGameActivity.getIntentWithConfig(requireContext(), 2)
|
||||
val intent = MyGameActivity.getIntentWithConfig(requireContext(), MyGameActivity.RESERVATION_INDEX)
|
||||
startActivity(intent)
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import com.aliyun.sls.android.producer.Log
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.common.loghub.LoghubHelper
|
||||
import com.gh.gamecenter.common.loghub.TLogHubHelper
|
||||
import com.gh.gamecenter.common.utils.FixedSizeLinkedHashSet
|
||||
import com.gh.gamecenter.common.utils.toJson
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.lightgame.utils.Utils
|
||||
import com.volcengine.model.tls.LogItem
|
||||
|
||||
/**
|
||||
* A handful tool for committing logs to aliyun loghub.
|
||||
@ -78,19 +78,20 @@ object ExposureManager {
|
||||
|
||||
private fun uploadExposures(eventSet: HashSet<ExposureEvent>, forced: Boolean) {
|
||||
eventSet.forEach {
|
||||
LoghubHelper.uploadLog(buildLog(it), LOG_STORE, forced)
|
||||
TLogHubHelper.sendLog(buildLog(it), LOG_STORE)
|
||||
// LoghubHelper.uploadLog(buildLog(it), LOG_STORE, forced)
|
||||
// it.recycle()
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildLog(event: ExposureEvent) = Log().apply {
|
||||
putContent("id", event.id)
|
||||
putContent("payload", event.payload.toJson())
|
||||
putContent("event", event.event.toString())
|
||||
putContent("source", eliminateMultipleBrackets(event.source.toJson()))
|
||||
putContent("meta", event.meta.toJson())
|
||||
putContent("real_millisecond", event.timeInMillisecond.toString())
|
||||
putContent(
|
||||
private fun buildLog(event: ExposureEvent) = LogItem(System.currentTimeMillis()).apply {
|
||||
addContent("__id", event.id)
|
||||
addContent("payload", event.payload.toJson())
|
||||
addContent("event", event.event.toString())
|
||||
addContent("source", eliminateMultipleBrackets(event.source.toJson()))
|
||||
addContent("meta", event.meta.toJson())
|
||||
addContent("real_millisecond", event.timeInMillisecond.toString())
|
||||
addContent(
|
||||
"e-traces", if (event.eTrace != null) {
|
||||
eliminateMultipleBrackets(event.eTrace?.toJson() ?: "")
|
||||
} else ""
|
||||
|
||||
@ -27,7 +27,7 @@ object ExposureUtils {
|
||||
): ExposureEvent {
|
||||
val gameEntity = entity.copy()
|
||||
gameEntity.id = if (entity.id.contains(DownloadEntity.GAME_ID_DIVIDER)) {
|
||||
entity.id.split(DownloadEntity.GAME_ID_DIVIDER).toTypedArray()[0]
|
||||
entity.id.split(DownloadEntity.GAME_ID_DIVIDER).toTypedArray().firstOrNull() ?: ""
|
||||
} else {
|
||||
entity.id
|
||||
}
|
||||
@ -62,17 +62,17 @@ object ExposureUtils {
|
||||
host: String? = "unknown",
|
||||
path: String? = "unknown",
|
||||
downloadType: DownloadType
|
||||
) {
|
||||
): ExposureEvent? {
|
||||
val gameEntity = entity.copy()
|
||||
gameEntity.platform = platform
|
||||
gameEntity.downloadCompleteType = downloadType.toString()
|
||||
val traceEvent = trace?.toObject<ExposureEvent>()
|
||||
|
||||
if (TextUtils.isEmpty(entity.id)) return
|
||||
if (TextUtils.isEmpty(entity.id)) return null
|
||||
|
||||
// 避免生成 trace 相同的下载完成事件,根据日志看下载完成的同一秒有可能生成两条
|
||||
if (mDownloadCompleteTraceEventIdSet.contains(traceEvent?.id)) {
|
||||
return
|
||||
return null
|
||||
}
|
||||
|
||||
traceEvent?.payload?.gameId?.let { mDownloadCompleteTraceEventIdSet.add(it) }
|
||||
@ -91,12 +91,14 @@ object ExposureUtils {
|
||||
|
||||
ExposureManager.log(exposureEvent)
|
||||
ExposureManager.commitSavedExposureEvents(forcedUpload = true)
|
||||
|
||||
return exposureEvent
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getDownloadType(apkEntity: ApkEntity, gameId: String, isVGame: Boolean): DownloadType {
|
||||
fun getDownloadType(apkEntity: ApkEntity, gameId: String, asVGame: Boolean): DownloadType {
|
||||
return when {
|
||||
isVGame -> getVGameDownloadType(apkEntity, gameId)
|
||||
asVGame -> getVGameDownloadType(apkEntity, gameId)
|
||||
PackageUtils.isInstalled(
|
||||
HaloApp.getInstance().application,
|
||||
apkEntity.packageName
|
||||
@ -107,7 +109,7 @@ object ExposureUtils {
|
||||
|
||||
private fun getVGameDownloadType(apkEntity: ApkEntity, gameId: String): DownloadType {
|
||||
return when {
|
||||
PackagesManager.isCanUpdate(gameId, apkEntity.packageName) -> DownloadType.FUN_UPDATE
|
||||
PackagesManager.isCanUpdate(gameId, apkEntity.packageName, asVGame = true) -> DownloadType.FUN_UPDATE
|
||||
else -> DownloadType.FUN_DOWNLOAD
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ import com.halo.assistant.HaloApp
|
||||
|
||||
@Database(
|
||||
entities = [AnswerEntity::class, ArticleEntity::class, NewsEntity::class, HistoryGameEntity::class, MyVideoEntity::class, GamesCollectionEntity::class],
|
||||
version = 13,
|
||||
version = 14,
|
||||
exportSchema = false
|
||||
)
|
||||
@TypeConverters(
|
||||
@ -41,7 +41,8 @@ import com.halo.assistant.HaloApp
|
||||
SimpleGameListConverter::class,
|
||||
TagInfoListConverter::class,
|
||||
ActivityLabelListConverter::class,
|
||||
IconFloatConverter::class
|
||||
IconFloatConverter::class,
|
||||
SectionConverter::class
|
||||
)
|
||||
|
||||
abstract class HistoryDatabase : RoomDatabase() {
|
||||
@ -143,6 +144,14 @@ abstract class HistoryDatabase : RoomDatabase() {
|
||||
}
|
||||
}
|
||||
|
||||
val MIGRATION_13_14: Migration = object : Migration(13, 14) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("Alter TABLE ArticleEntity add type TEXT NOT NULL DEFAULT 'community_article'")
|
||||
database.execSQL("Alter TABLE ArticleEntity add sections TEXT NOT NULL DEFAULT ''")
|
||||
database.execSQL("Alter TABLE ArticleEntity add tagActivityName TEXT NOT NULL DEFAULT ''")
|
||||
}
|
||||
}
|
||||
|
||||
val instance by lazy {
|
||||
Room.databaseBuilder(
|
||||
HaloApp.getInstance().application,
|
||||
@ -160,6 +169,7 @@ abstract class HistoryDatabase : RoomDatabase() {
|
||||
.addMigrations(MIGRATION_10_11)
|
||||
.addMigrations(MIGRATION_11_12)
|
||||
.addMigrations(MIGRATION_12_13)
|
||||
.addMigrations(MIGRATION_13_14)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,10 +6,7 @@ import com.gh.gamecenter.common.utils.removeVideoContent
|
||||
import com.gh.gamecenter.common.utils.tryCatchInRelease
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.gamecenter.entity.*
|
||||
import com.gh.gamecenter.feature.entity.AnswerEntity
|
||||
import com.gh.gamecenter.feature.entity.ArticleEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.NewsEntity
|
||||
import com.gh.gamecenter.feature.entity.*
|
||||
import com.gh.gamecenter.qa.entity.AnswerDetailEntity
|
||||
import com.gh.gamecenter.qa.entity.ArticleDetailEntity
|
||||
|
||||
@ -74,7 +71,6 @@ object HistoryHelper {
|
||||
historyGame.iconFloat = gameEntity.iconFloat
|
||||
historyGame.name = gameEntity.name
|
||||
historyGame.tagStyle = gameEntity.tagStyle
|
||||
historyGame.tag = gameEntity.getTag()
|
||||
historyGame.subtitle = gameEntity.subtitle
|
||||
historyGame.subtitleStyle = gameEntity.subtitleStyle
|
||||
return historyGame
|
||||
@ -108,7 +104,7 @@ object HistoryHelper {
|
||||
fun deleteArticleEntity(articleId: String) {
|
||||
runOnIoThread {
|
||||
tryCatchInRelease {
|
||||
HistoryDatabase.instance.articleDao().deleteArticle(ArticleEntity(id = articleId))
|
||||
HistoryDatabase.instance.articleDao().deleteArticle(ArticleEntity(_id = articleId))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -169,6 +165,9 @@ object HistoryHelper {
|
||||
articleEntity.images = articleDetailEntity.images
|
||||
articleEntity.imagesInfo = articleDetailEntity.imagesInfo
|
||||
articleEntity.videos = articleDetailEntity.videos
|
||||
articleEntity.tagActivityName = articleDetailEntity.tagActivityName
|
||||
articleEntity.sections = articleDetailEntity.sections ?: emptyList()
|
||||
articleEntity.type = "community_article"
|
||||
|
||||
return articleEntity
|
||||
}
|
||||
|
||||
10
app/src/main/java/com/gh/common/iinterface/IMultiTab.kt
Normal file
10
app/src/main/java/com/gh/common/iinterface/IMultiTab.kt
Normal file
@ -0,0 +1,10 @@
|
||||
package com.gh.common.iinterface
|
||||
|
||||
import com.gh.gamecenter.entity.MultiTabNav
|
||||
|
||||
interface IMultiTab {
|
||||
fun provideMultiTabId(): String
|
||||
fun provideMultiTabName(): String
|
||||
fun provideCurrentTabEntity(): MultiTabNav.LinkMultiTabNav?
|
||||
fun provideLastSelectedPosition(): Int
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package com.gh.common.iinterface
|
||||
|
||||
import com.gh.gamecenter.entity.BottomTab
|
||||
|
||||
interface ISearchToolbarTab {
|
||||
fun onScrollChanged(totalHeight: Int, offset: Int, isDarkModeChanged: Boolean)
|
||||
fun changeAppBarColor(color: Int, pageId: String)
|
||||
fun setSearchStyle(searchStyle: BottomTab.SearchStyle)
|
||||
fun getCurrentTabIndex(): Int?
|
||||
}
|
||||
12
app/src/main/java/com/gh/common/iinterface/ISmartRefresh.kt
Normal file
12
app/src/main/java/com/gh/common/iinterface/ISmartRefresh.kt
Normal file
@ -0,0 +1,12 @@
|
||||
package com.gh.common.iinterface
|
||||
|
||||
import com.gh.common.prioritychain.PullDownPushHandler
|
||||
import com.gh.gamecenter.entity.PullDownPush
|
||||
|
||||
interface ISmartRefresh {
|
||||
fun setSmartRefreshEnabled(isEnable: Boolean)
|
||||
fun finishTwoLevel(action: String)
|
||||
fun finishRefresh()
|
||||
fun popupPullDownPush(finishCallback: () -> Unit)
|
||||
fun setPullDownPush(pullDownPush: PullDownPush?, pullDownPushHandler: PullDownPushHandler?)
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.gh.common.iinterface
|
||||
|
||||
interface ISmartRefreshContent {
|
||||
/**
|
||||
* 启用/关闭 页面滑动
|
||||
* @param isScrollEnabled 是否启用
|
||||
*/
|
||||
fun setScrollEnabled(isScrollEnabled: Boolean)
|
||||
|
||||
fun onRefresh()
|
||||
|
||||
/**
|
||||
* 启用/关闭 SwipeRefreshLayout 的下拉刷新
|
||||
* @param isSwipeRefreshEnabled 是否启用
|
||||
*/
|
||||
fun setSwipeRefreshEnabled(isSwipeRefreshEnabled: Boolean)
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.gh.common.iinterface
|
||||
|
||||
import com.gh.common.prioritychain.PriorityChain
|
||||
|
||||
interface ISuperiorChain {
|
||||
fun registerInferiorChain(chain: PriorityChain)
|
||||
|
||||
fun unregisterInferiorChain(chain: PriorityChain)
|
||||
}
|
||||
@ -0,0 +1,138 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Handler
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.FrameLayout
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.gamecenter.GameDetailActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.view.BugFixedPopupWindow
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.databinding.PopupAccelerateNotificationBinding
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.wrapper.MainWrapperViewModel
|
||||
|
||||
class AccelerateNotificationHandler(priority: Int) : PriorityChainHandler(priority) {
|
||||
|
||||
private var mActivity: Activity? = null
|
||||
private var mHandler: Handler? = null
|
||||
private var mGameList: List<GameEntity>? = null
|
||||
private var mViewModel: MainWrapperViewModel? = null
|
||||
|
||||
/**
|
||||
* 提前预处理显示弹窗的内容
|
||||
*/
|
||||
fun doPreProcess(
|
||||
activity: Activity,
|
||||
handler: Handler,
|
||||
gameEntityList: List<GameEntity>?,
|
||||
viewModel: MainWrapperViewModel
|
||||
) {
|
||||
mActivity = activity
|
||||
mGameList = gameEntityList
|
||||
mHandler = handler
|
||||
mViewModel = viewModel
|
||||
|
||||
if (getStatus() == STATUS_PENDING) {
|
||||
if (gameEntityList == null) {
|
||||
processNext()
|
||||
} else {
|
||||
updateStatus(STATUS_VALID)
|
||||
process()
|
||||
}
|
||||
} else {
|
||||
if (gameEntityList == null) {
|
||||
updateStatus(STATUS_INVALID)
|
||||
} else {
|
||||
updateStatus(STATUS_VALID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onProcess() : Boolean {
|
||||
when (getStatus()) {
|
||||
STATUS_VALID -> {
|
||||
val accelerateSet =
|
||||
HashSet(SPUtils.getStringSet(Constants.SP_ACCELERATE_NOTIFICATION_POP_UP_SET))
|
||||
if (!mGameList.isNullOrEmpty() && !accelerateSet.contains(mGameList!![0].messageId)) {
|
||||
showAccelerateNotificationPopupWindow(mActivity!!, mViewModel, mHandler, mGameList!![0]) {
|
||||
processNext()
|
||||
}
|
||||
accelerateSet.add(mGameList!![0].messageId)
|
||||
SPUtils.setStringSet(Constants.SP_ACCELERATE_NOTIFICATION_POP_UP_SET, accelerateSet)
|
||||
return true
|
||||
} else {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
|
||||
STATUS_INVALID -> {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun showAccelerateNotificationPopupWindow(
|
||||
activity: Activity,
|
||||
viewModel: MainWrapperViewModel?,
|
||||
handler: Handler?,
|
||||
gameEntity: GameEntity?,
|
||||
dismissCallback: (() -> Unit)?
|
||||
) {
|
||||
val binding: PopupAccelerateNotificationBinding =
|
||||
PopupAccelerateNotificationBinding.inflate(LayoutInflater.from(activity))
|
||||
if (gameEntity != null) {
|
||||
binding.gameIconView.displayGameIcon(gameEntity)
|
||||
binding.gameNameTv.text = gameEntity.name
|
||||
binding.root.setOnClickListener {
|
||||
NewFlatLogUtils.logMessageInformClickPluginVersion(
|
||||
gameEntity.id,
|
||||
gameEntity.name!!
|
||||
)
|
||||
if (gameEntity.messageId.isNotEmpty()) {
|
||||
// 把对应系统消息设为已读
|
||||
viewModel?.postMessageRead(gameEntity.messageId)
|
||||
}
|
||||
GameDetailActivity.startGameDetailActivity(
|
||||
context = activity,
|
||||
gameId = gameEntity.id,
|
||||
entrance = "首页插件上架弹窗",
|
||||
defaultTab = -1,
|
||||
isSkipGameComment = false,
|
||||
scrollToLibao = false,
|
||||
openVideoStreaming = false,
|
||||
openPlatformWindow = true,
|
||||
traceEvent = null
|
||||
)
|
||||
}
|
||||
}
|
||||
BugFixedPopupWindow(
|
||||
binding.root,
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT
|
||||
).apply {
|
||||
isTouchable = true
|
||||
isFocusable = true
|
||||
isOutsideTouchable = true
|
||||
animationStyle = R.style.popup_window_ease_in_and_out_anim_style
|
||||
showAtLocation(
|
||||
activity.window.decorView,
|
||||
Gravity.TOP,
|
||||
0,
|
||||
DisplayUtils.getStatusBarHeight(activity.resources) + DisplayUtils.dip2px(42f)
|
||||
)
|
||||
setOnDismissListener {
|
||||
dismissCallback?.invoke()
|
||||
}
|
||||
handler?.postDelayed({ dismiss() }, 5000)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,169 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Handler
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.PopupWindow
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.view.BugFixedPopupWindow
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.databinding.PopupBottomTabGuideBinding
|
||||
import com.gh.gamecenter.entity.BottomTab
|
||||
|
||||
class BottomTabGuideHandler(priority: Int): PriorityChainHandler(priority) {
|
||||
private var mActivity: Activity? = null
|
||||
private var mHandler: Handler? = null
|
||||
private var mViewPager: ViewGroup? = null
|
||||
private var mGuide: BottomTab.Guide? = null
|
||||
private var mTriangleTransX = 0F
|
||||
private var mGuideTransX = 0F
|
||||
private var mRestWidth = 0F
|
||||
private var mIsCenterPosition = false
|
||||
private var mIsRightPosition = false
|
||||
|
||||
private var mPopupWindow: PopupWindow? = null
|
||||
|
||||
fun doPreProcess(
|
||||
shouldShow: Boolean,
|
||||
activity: Activity? = null,
|
||||
handler: Handler? = null,
|
||||
viewPager: ViewGroup? = null,
|
||||
guide: BottomTab.Guide? = null,
|
||||
triangleTransX: Float = 0F,
|
||||
guideTransX: Float = 0F,
|
||||
restWidth: Float = 0F,
|
||||
isCenterPosition: Boolean = false,
|
||||
isRightPosition: Boolean = false
|
||||
) {
|
||||
mActivity = activity
|
||||
mHandler = handler
|
||||
mViewPager = viewPager
|
||||
mGuide = guide
|
||||
mTriangleTransX = triangleTransX
|
||||
mGuideTransX = guideTransX
|
||||
mRestWidth = restWidth
|
||||
mIsCenterPosition = isCenterPosition
|
||||
mIsRightPosition = isRightPosition
|
||||
|
||||
if (getStatus() == STATUS_PENDING) {
|
||||
if (shouldShow) {
|
||||
updateStatus(STATUS_VALID)
|
||||
process()
|
||||
} else {
|
||||
processNext()
|
||||
}
|
||||
} else {
|
||||
if (shouldShow) {
|
||||
updateStatus(STATUS_VALID)
|
||||
} else {
|
||||
updateStatus(STATUS_INVALID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onProcess(): Boolean {
|
||||
when (getStatus()) {
|
||||
STATUS_VALID -> {
|
||||
if (mGuide == null || mActivity == null || mViewPager == null) {
|
||||
processNext()
|
||||
return false
|
||||
}
|
||||
|
||||
val guideSet = HashSet(SPUtils.getStringSet(Constants.SP_BOTTOM_TAB_GUIDE_SET))
|
||||
if (!guideSet.contains(mGuide?.bottomTabId + mGuide?.text)) {
|
||||
mPopupWindow = showBottomTabPopupWindow(
|
||||
mActivity!!,
|
||||
mHandler,
|
||||
mViewPager!!,
|
||||
mGuide!!,
|
||||
mTriangleTransX,
|
||||
mGuideTransX,
|
||||
mRestWidth,
|
||||
mIsCenterPosition,
|
||||
mIsRightPosition
|
||||
) {
|
||||
processNext()
|
||||
}
|
||||
guideSet.add(mGuide?.bottomTabId + mGuide?.text)
|
||||
SPUtils.setStringSet(Constants.SP_BOTTOM_TAB_GUIDE_SET, guideSet)
|
||||
return true
|
||||
} else {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
|
||||
STATUS_INVALID -> {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
fun dismiss() {
|
||||
if (mPopupWindow?.isShowing == true) {
|
||||
mPopupWindow?.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val KEY_BOTTOM_TAB_GUIDE_AUTO_DISMISS = 100
|
||||
private const val AUTO_DISMISS_DELAY_TIME = 5000L
|
||||
|
||||
fun showBottomTabPopupWindow(
|
||||
activity: Activity,
|
||||
handler: Handler?,
|
||||
viewPager: ViewGroup,
|
||||
guide: BottomTab.Guide,
|
||||
triangleTransX: Float,
|
||||
guideTransX: Float,
|
||||
restWidth: Float,
|
||||
isCenterPosition: Boolean,
|
||||
isRightPosition: Boolean,
|
||||
dismissCallback: (() -> Unit)?
|
||||
): PopupWindow {
|
||||
val binding = PopupBottomTabGuideBinding.inflate(LayoutInflater.from(activity))
|
||||
binding.guideTv.text = guide.text
|
||||
binding.guideTriangleIv.translationX = triangleTransX
|
||||
binding.guideTv.translationX = guideTransX
|
||||
binding.guideIconIv.translationX = guideTransX
|
||||
binding.guideTv.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
horizontalBias = if (isCenterPosition) 0.5F else if (isRightPosition) 1F else 0F
|
||||
}
|
||||
|
||||
val popupWindow = BugFixedPopupWindow(
|
||||
binding.root,
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT,
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
popupWindow.contentView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)
|
||||
val measureWidth = popupWindow.contentView.measuredWidth
|
||||
val measureHeight = popupWindow.contentView.measuredHeight
|
||||
if (measureWidth > restWidth) {
|
||||
binding.guideTv.translationX = 0F
|
||||
binding.guideIconIv.translationX = 0F
|
||||
}
|
||||
|
||||
return popupWindow.apply {
|
||||
isFocusable = false
|
||||
isOutsideTouchable = false
|
||||
animationStyle = R.style.popup_window_ease_in_and_out_anim_style
|
||||
setOnDismissListener {
|
||||
dismissCallback?.invoke()
|
||||
}
|
||||
handler?.post {
|
||||
if (!activity.isFinishing) {
|
||||
showAsDropDown(viewPager, 0, 8F.dip2px() - measureHeight)
|
||||
}
|
||||
handler.sendEmptyMessageDelayed(KEY_BOTTOM_TAB_GUIDE_AUTO_DISMISS, AUTO_DISMISS_DELAY_TIME)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.FrameLayout
|
||||
import com.airbnb.lottie.LottieAnimationView
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.databinding.LayoutCommunityHomeVideoGuideBinding
|
||||
|
||||
class CommunityHomeGuideHandler(
|
||||
priority: Int,
|
||||
private val context: Context,
|
||||
private val decorView: FrameLayout?,
|
||||
private val videoLottie: LottieAnimationView?
|
||||
) : PriorityChainHandler(priority) {
|
||||
|
||||
init {
|
||||
updateStatus(STATUS_VALID)
|
||||
}
|
||||
|
||||
override fun onProcess(): Boolean {
|
||||
return if (SPUtils.getBoolean(Constants.SP_SHOW_COMMUNITY_HOME_VIDEO_GUIDE, true)) {
|
||||
showHomeVideoGuide(context, decorView, videoLottie)
|
||||
processNext()
|
||||
true
|
||||
} else {
|
||||
processNext()
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun showHomeVideoGuide(context: Context, decorView: FrameLayout?, videoLottie: LottieAnimationView?) {
|
||||
val guideLayoutBinding = LayoutCommunityHomeVideoGuideBinding.inflate(
|
||||
LayoutInflater.from(context),
|
||||
decorView,
|
||||
true
|
||||
)
|
||||
guideLayoutBinding.root.setOnClickListener { view ->
|
||||
decorView?.removeView(view)
|
||||
SPUtils.setBoolean(Constants.SP_SHOW_COMMUNITY_HOME_VIDEO_GUIDE, false)
|
||||
|
||||
videoLottie?.playAnimation()
|
||||
SPUtils.setLong(
|
||||
Constants.SP_COMMUNITY_HOME_VIDEO_LOTTIE_LAST_PLAY_TIME,
|
||||
System.currentTimeMillis()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.gh.gamecenter.feature.entity.FloatingWindowEntity
|
||||
import com.gh.gamecenter.livedata.Event
|
||||
|
||||
class CustomFloatingWindowHandler(priority: Int) : PriorityChainHandler(priority) {
|
||||
|
||||
private val data = arrayListOf<FloatingWindowEntity>()
|
||||
|
||||
private val _showFloatingAction = MutableLiveData<Event<ArrayList<FloatingWindowEntity>>>()
|
||||
val showFloatingAction: LiveData<Event<ArrayList<FloatingWindowEntity>>> = _showFloatingAction
|
||||
|
||||
fun setData(newData: List<FloatingWindowEntity>) {
|
||||
data.clear()
|
||||
data.addAll(newData)
|
||||
doPreProcess()
|
||||
}
|
||||
|
||||
private fun doPreProcess() {
|
||||
// debugOnly {
|
||||
// data.clear()
|
||||
// data.add(
|
||||
// FloatingWindowEntity(
|
||||
// id = "audire",
|
||||
// image = "https://jira.shanqu.cc/secure/attachment/57822/57822_image-2023-12-01-17-53-04-492.png",
|
||||
// link = WelcomeDialogEntity(
|
||||
// id = null,
|
||||
// time = null,
|
||||
// packages = null,
|
||||
// floatingWindowId = null,
|
||||
// shouldShowExitAnimation = false
|
||||
// ),
|
||||
// pushType = "maiorum",
|
||||
// expandable = false,
|
||||
// expandedImage = "fermentum",
|
||||
// bigPopupNotice = "dignissim"
|
||||
// )
|
||||
// )
|
||||
// }
|
||||
|
||||
if (getStatus() == STATUS_PENDING) {
|
||||
if (data.isNotEmpty()) {
|
||||
updateStatus(STATUS_VALID)
|
||||
process()
|
||||
} else {
|
||||
processNext()
|
||||
}
|
||||
} else {
|
||||
if (data.isNotEmpty()) {
|
||||
updateStatus(STATUS_VALID)
|
||||
} else {
|
||||
updateStatus(STATUS_INVALID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onProcess(): Boolean {
|
||||
when (getStatus()) {
|
||||
STATUS_VALID -> {
|
||||
_showFloatingAction.value = Event(data)
|
||||
return true
|
||||
// floatingWindowProvider.showFloatingWindowOnly(
|
||||
// mFragment!!,
|
||||
// mRecyclerView!!,
|
||||
// mWindowList!!,
|
||||
// ) {
|
||||
// val welcomeDialog = WelcomeDialogFragment.getInstance(it, true, mFragment)
|
||||
// welcomeDialog.show(mFragment!!.childFragmentManager, "WelcomeDialog")
|
||||
// }
|
||||
}
|
||||
|
||||
STATUS_INVALID -> {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
fun dismiss() {
|
||||
if (getStatus() == STATUS_HANDLING || getStatus() == STATUS_VALID) {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,269 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.app.Application.ActivityLifecycleCallbacks
|
||||
import android.os.Bundle
|
||||
import android.preference.PreferenceManager
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import com.gh.common.iinterface.ISuperiorChain
|
||||
import com.gh.common.util.CheckLoginUtils
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.gamecenter.SplashAdActivity
|
||||
import com.gh.gamecenter.SplashScreenActivity
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.entity.SimpleGameEntity
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.entity.DialogEntity
|
||||
import com.gh.gamecenter.feature.entity.WelcomeDialogEntity
|
||||
import com.gh.gamecenter.hud.PendingInstallHUDHandler
|
||||
import com.gh.gamecenter.hud.ResumeDownloadHudHandler
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
/**
|
||||
* 全局的 APP 优先级弹窗链管理器
|
||||
*
|
||||
* 弹窗的优先级为
|
||||
* 启动跳转(-101) > 更新弹窗(-100) > 隐私政策弹窗(-99) > 消息通知权限弹窗(0) > 预约弹窗(1) > 启动弹窗(2)
|
||||
*/
|
||||
object GlobalPriorityChainHelper : ISuperiorChain {
|
||||
|
||||
private val api = RetrofitManager.getInstance().api
|
||||
private var inferiorChain: PriorityChain? = null
|
||||
private val mainChain: PriorityChain by lazy { PriorityChain { inferiorChain?.start() } }
|
||||
|
||||
/**
|
||||
* 当前 activity 是否使用于应用全局弹窗的弹出
|
||||
* 排除启动页和其它非 FragmentActivity
|
||||
*/
|
||||
fun isThisActivityValid(activity: Activity?): Boolean {
|
||||
return activity is FragmentActivity
|
||||
&& !activity.isFinishing
|
||||
&& activity !is SplashScreenActivity
|
||||
&& activity !is SplashAdActivity
|
||||
}
|
||||
|
||||
/**
|
||||
* 预启动所有的优先级弹窗管理链
|
||||
*/
|
||||
fun preStart(withSpecialDelay: Boolean) {
|
||||
val launchRedirectHandler = LaunchRedirectHandler(-101)
|
||||
val updateDialogHandler = UpdateDialogHandler(-100)
|
||||
val privacyPolicyDialogHandler = PrivacyPolicyDialogHandler(-99)
|
||||
val notificationPermissionDialogHandler = NotificationPermissionDialogHandler(0)
|
||||
val reserveDialogHandler = ReserveDialogHandler(1)
|
||||
val welcomeDialogHandler = WelcomeDialogHandler(2)
|
||||
val pendingInstallHandler = PendingInstallHUDHandler(3)
|
||||
val resumeDownloadHandler = ResumeDownloadHudHandler(4)
|
||||
|
||||
mainChain.addHandler(launchRedirectHandler)
|
||||
mainChain.addHandler(updateDialogHandler)
|
||||
mainChain.addHandler(privacyPolicyDialogHandler)
|
||||
mainChain.addHandler(welcomeDialogHandler)
|
||||
mainChain.addHandler(reserveDialogHandler)
|
||||
mainChain.addHandler(notificationPermissionDialogHandler)
|
||||
mainChain.addHandler(pendingInstallHandler)
|
||||
mainChain.addHandler(resumeDownloadHandler)
|
||||
|
||||
launchRedirectHandler.doPreProcess()
|
||||
updateDialogHandler.doPreProcess()
|
||||
|
||||
// 首次启动延迟 300ms,保证请求首次启动时已经获取到了 GID 、 OAID 等标记
|
||||
val requestDelay = if (withSpecialDelay) 300L else 0L
|
||||
AppExecutor.uiExecutor.executeWithDelay({
|
||||
requestOpeningDialogData(welcomeDialogHandler, privacyPolicyDialogHandler)
|
||||
requestReserveDialogData(reserveDialogHandler)
|
||||
}, requestDelay)
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动优先级弹窗管理链的执行
|
||||
*/
|
||||
fun start() {
|
||||
if (mainChain.isHandlerQueueEmpty()) return
|
||||
|
||||
mainChain.start()
|
||||
|
||||
observeLifecycle()
|
||||
}
|
||||
|
||||
private fun observeLifecycle() {
|
||||
HaloApp.getInstance().registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks {
|
||||
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
override fun onActivityStarted(activity: Activity) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
override fun onActivityResumed(activity: Activity) {
|
||||
// 优先级弹窗管理链为空时取消注册,避免无用调用
|
||||
if (mainChain.isHandlerQueueEmpty()) {
|
||||
HaloApp.getInstance().unregisterActivityLifecycleCallbacks(this)
|
||||
} else {
|
||||
resume()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityPaused(activity: Activity) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
override fun onActivityStopped(activity: Activity) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
override fun onActivityDestroyed(activity: Activity) {
|
||||
// do nothing
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复链的处理
|
||||
*/
|
||||
fun resume() {
|
||||
mainChain.resume()
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加新的 handler 到优先级弹窗管理链 (插队!)
|
||||
*/
|
||||
fun queueNewHandler(handler: PriorityChainHandler) {
|
||||
if (mainChain.isHandlerQueueEmpty()) {
|
||||
observeLifecycle()
|
||||
}
|
||||
|
||||
mainChain.addHandler(handler)
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求首页启动弹窗相关的数据并执行相关 handler 的 preProcess
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
private fun requestOpeningDialogData(
|
||||
welcomeDialogHandler: WelcomeDialogHandler,
|
||||
privacyPolicyDialogHandler: PrivacyPolicyDialogHandler
|
||||
) {
|
||||
val sp = PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance())
|
||||
|
||||
val lastId = SPUtils.getString(sp, Constants.SP_LAST_OPENING_ID, "")
|
||||
val lastTime = SPUtils.getLong(sp, Constants.SP_LAST_OPENING_TIME, 0)
|
||||
val openType = if (HaloApp.getInstance().isNewForThisVersion) "first" else "not_first_time"
|
||||
|
||||
api.getOpeningDialog(HaloApp.getInstance().channel, lastId, lastTime, openType)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<DialogEntity>() {
|
||||
override fun onSuccess(data: DialogEntity) {
|
||||
var welcomeDialogEntity: WelcomeDialogEntity? = null
|
||||
var privacyPolicyDialogEntity: DialogEntity.PrivacyPolicyEntity? = null
|
||||
|
||||
// 全新安装忽略隐私弹窗
|
||||
if (data.privacyPolicyDialog != null) {
|
||||
val id = data.privacyPolicyDialog.id
|
||||
val lastAcceptedId = SPUtils.getString(Constants.SP_LAST_ACCEPTED_PRIVACY_DIALOG_ID, "")
|
||||
if (HaloApp.getInstance().isBrandNewInstall) {
|
||||
SPUtils.setString(Constants.SP_LAST_ACCEPTED_PRIVACY_DIALOG_ID, id)
|
||||
} else {
|
||||
if (id != lastAcceptedId) {
|
||||
privacyPolicyDialogEntity = data.privacyPolicyDialog
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// debugOnly {
|
||||
// privacyPolicyDialogEntity = DialogEntity.PrivacyPolicyEntity(
|
||||
// "5f6f5f3d9d9b4e0001c3b3a5",
|
||||
// "privacy_policy",
|
||||
// "ONCE",
|
||||
// "INFORM",
|
||||
// "隐私政策",
|
||||
// 1601116800000)
|
||||
// }
|
||||
|
||||
privacyPolicyDialogHandler.doPreProcess(privacyPolicyDialogEntity)
|
||||
|
||||
// 类型为游戏时判断是否本地已安装该游戏,已安装不弹弹窗
|
||||
if (data.welcomeDialog != null) {
|
||||
welcomeDialogEntity = data.welcomeDialog
|
||||
|
||||
if (data.welcomeDialog.type == "game") {
|
||||
if (data.welcomeDialog.packages != null) {
|
||||
for (packageName in data.welcomeDialog.packages!!) {
|
||||
if (PackageUtils.isInstalled(HaloApp.getInstance(), packageName)) {
|
||||
welcomeDialogEntity = null
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
welcomeDialogHandler.doPreProcess(welcomeDialogEntity)
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
privacyPolicyDialogHandler.doPreProcess(null)
|
||||
welcomeDialogHandler.doPreProcess(null)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求预约弹窗相关的数据
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
private fun requestReserveDialogData(reserveDialogHandler: ReserveDialogHandler) {
|
||||
// debugOnly {
|
||||
// reserveDialogHandler.doPreProcess(arrayListOf(SimpleGameEntity(
|
||||
// "5f6f5f3d9d9b4e0001c3b3a5",
|
||||
// "5f6f5f3d9d9b4e0001c3b3a5",
|
||||
// "https://and-static.ghzs.com/image/game/icon/2022/11/18/63772b0d398daaa7c5067298.png",
|
||||
// "5f6f5f3d9d9b4e0001c3b3a5",
|
||||
// )))
|
||||
// return
|
||||
// }
|
||||
|
||||
if (CheckLoginUtils.isLogin()) {
|
||||
api.getReserveDialog(UserManager.getInstance().userId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<List<SimpleGameEntity>>() {
|
||||
override fun onSuccess(data: List<SimpleGameEntity>) {
|
||||
reserveDialogHandler.doPreProcess(data)
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
reserveDialogHandler.doPreProcess(null)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
reserveDialogHandler.doPreProcess(null)
|
||||
}
|
||||
}
|
||||
|
||||
override fun registerInferiorChain(chain: PriorityChain) {
|
||||
inferiorChain = chain
|
||||
if (mainChain.isHandlerQueueEmpty()) {
|
||||
inferiorChain?.resume()
|
||||
}
|
||||
}
|
||||
|
||||
override fun unregisterInferiorChain(chain: PriorityChain) {
|
||||
if (inferiorChain == chain) {
|
||||
inferiorChain = null
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.common.entity.LaunchRedirect
|
||||
import com.gh.gamecenter.common.entity.LaunchRedirectWrapper
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.common.utils.singleToMain
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.wrapper.MainWrapperRepository
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
/**
|
||||
* 初次启动跳转
|
||||
*/
|
||||
class LaunchRedirectHandler(priority: Int) : PriorityChainHandler(priority) {
|
||||
|
||||
private var launchData: LaunchRedirect? = null
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun doPreProcess() {
|
||||
// if (true) {
|
||||
if (HaloApp.getInstance().isBrandNewInstall) {
|
||||
RetrofitManager.getInstance().newApi
|
||||
.getLaunchRedirect(BuildConfig.VERSION_NAME, HaloApp.getInstance().channel)
|
||||
.compose(singleToMain())
|
||||
.subscribe(object : BiResponse<LaunchRedirectWrapper>() {
|
||||
override fun onSuccess(data: LaunchRedirectWrapper) {
|
||||
launchData = data.launchRedirect
|
||||
|
||||
if (launchData == null) {
|
||||
updateStatus(STATUS_INVALID)
|
||||
processNext()
|
||||
return
|
||||
}
|
||||
|
||||
// 尝试提前设置 tab default 避免首页数据加载完成,tab 选中会闪烁
|
||||
if (launchData?.type == "bottom_tab") {
|
||||
MainWrapperRepository.getInstance().sendSelectTabEvent(launchData!!)
|
||||
}
|
||||
|
||||
if (getStatus() == STATUS_PENDING) {
|
||||
updateStatus(STATUS_VALID)
|
||||
process()
|
||||
} else {
|
||||
updateStatus(STATUS_VALID)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
updateStatus(STATUS_INVALID)
|
||||
processNext()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
updateStatus(STATUS_INVALID)
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onProcess(): Boolean {
|
||||
val currentActivity = CurrentActivityHolder.getCurrentActivity()
|
||||
|
||||
if (GlobalPriorityChainHelper.isThisActivityValid(currentActivity)) {
|
||||
if (getStatus() == STATUS_VALID) {
|
||||
// 当 type 为 "bottom_tab" 时上面 doPreProcess 中已经处理过了,但再选中一次好像也没有什么问题,先不特殊处理这个 case 了
|
||||
DirectUtils.directToLinkPage(currentActivity!!, launchData!!, "首次启动跳转", "")
|
||||
// 跳转页面不管回调,延迟 500ms 后执行下一个 handler
|
||||
AppExecutor.uiExecutor.executeWithDelay({
|
||||
processNext()
|
||||
}, 500L)
|
||||
|
||||
return true
|
||||
} else if (getStatus() == STATUS_INVALID) {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,297 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Handler
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.PopupWindow
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.utils.goneIf
|
||||
import com.gh.gamecenter.common.view.BugFixedPopupWindow
|
||||
import com.gh.gamecenter.common.view.NoDefaultMinWidthTabLayout
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.databinding.PopupMultiTabGuideBinding
|
||||
import com.gh.gamecenter.entity.BottomTab
|
||||
import com.gh.gamecenter.wrapper.BaseTabWrapperFragment
|
||||
import com.gh.gamecenter.wrapper.MainWrapperFragment
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.tabs.TabLayout.TabView
|
||||
|
||||
class MultiTabGuideHandler(priority: Int): PriorityChainHandler(priority) {
|
||||
private var mActivity: Activity? = null
|
||||
private var mHandler: Handler? = null
|
||||
private var mGuide: BottomTab.Guide? = null
|
||||
private var mTabLayout: TabLayout? = null
|
||||
private var mTabView: TabView? = null
|
||||
private var mIsSingleLineTab = false
|
||||
private var mMainWrapperFragment: MainWrapperFragment? = null
|
||||
private var mTabWrapperFragment: BaseTabWrapperFragment? = null
|
||||
|
||||
fun doPreProcess(
|
||||
shouldShow: Boolean,
|
||||
activity: Activity? = null,
|
||||
handler: Handler? = null,
|
||||
guide: BottomTab.Guide? = null,
|
||||
tabLayout: TabLayout? = null,
|
||||
tabView: TabLayout.TabView? = null,
|
||||
isSingleLineTab: Boolean = false,
|
||||
mainWrapperFragment: MainWrapperFragment? = null,
|
||||
tabWrapperFragment: BaseTabWrapperFragment? = null
|
||||
) {
|
||||
mActivity = activity
|
||||
mHandler = handler
|
||||
mGuide = guide
|
||||
mTabLayout = tabLayout
|
||||
mTabView = tabView
|
||||
mIsSingleLineTab = isSingleLineTab
|
||||
mMainWrapperFragment = mainWrapperFragment
|
||||
mTabWrapperFragment = tabWrapperFragment
|
||||
|
||||
if (getStatus() == STATUS_PENDING) {
|
||||
if (shouldShow) {
|
||||
updateStatus(STATUS_VALID)
|
||||
process()
|
||||
} else {
|
||||
processNext()
|
||||
}
|
||||
} else {
|
||||
if (shouldShow) {
|
||||
updateStatus(STATUS_VALID)
|
||||
} else {
|
||||
updateStatus(STATUS_INVALID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onProcess(): Boolean {
|
||||
when (getStatus()) {
|
||||
STATUS_VALID -> {
|
||||
if (mGuide == null || mActivity == null || mTabView == null || mTabLayout == null) {
|
||||
processNext()
|
||||
return false
|
||||
}
|
||||
|
||||
return showMultiTabGuide(
|
||||
true,
|
||||
mActivity!!,
|
||||
mHandler,
|
||||
mGuide!!,
|
||||
mTabLayout!!,
|
||||
mTabView!!,
|
||||
mIsSingleLineTab,
|
||||
mMainWrapperFragment,
|
||||
mTabWrapperFragment
|
||||
) {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
|
||||
STATUS_INVALID -> {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAB_GUIDE_TRIANGLE_OFFSET_DP = 5F
|
||||
private const val TAB_GUIDE_START_TRIANGLE_OFFSET_DP = 12F
|
||||
private const val TAB_GUIDE_RIGHT_SIDE_ICON_RIGHT_RESERVED_OFFSET_DP = 51F + TAB_GUIDE_TRIANGLE_OFFSET_DP // 光宝在文案右侧时预留引导到屏幕右侧的距离
|
||||
private const val TAB_GUIDE_RIGHT_SIDE_ICON_LEFT_RESERVED_OFFSET_DP = TAB_GUIDE_START_TRIANGLE_OFFSET_DP + TAB_GUIDE_TRIANGLE_OFFSET_DP // 光宝在文案作侧时预留引导到屏幕右侧的距离
|
||||
|
||||
fun showMultiTabGuide(
|
||||
isImmediately: Boolean,
|
||||
activity: Activity,
|
||||
handler: Handler?,
|
||||
guide: BottomTab.Guide,
|
||||
tabLayout: TabLayout,
|
||||
tabView: TabView,
|
||||
isSingleLineTab: Boolean = false,
|
||||
mainWrapperFragment: MainWrapperFragment? = null,
|
||||
tabWrapperFragment: BaseTabWrapperFragment? = null,
|
||||
dismissCallback: (() -> Unit)? = null
|
||||
): Boolean {
|
||||
val guideSet = HashSet(SPUtils.getStringSet(Constants.SP_MULTI_TAB_NAV_GUIDE_SET))
|
||||
val hasShownGuide = guideSet.contains(guide.multiTabId + guide.text)
|
||||
val isCurrentBottomTab = mainWrapperFragment == null || guide.bottomTabId == mainWrapperFragment.currentTab?.id
|
||||
if (!hasShownGuide && isCurrentBottomTab) {
|
||||
val screenWidth = DisplayUtils.getScreenWidth(activity)
|
||||
val outLocation = IntArray(2)
|
||||
tabView.getLocationOnScreen(outLocation)
|
||||
val tabViewCenterPosX = outLocation.first() + tabView.width / 2F
|
||||
val iconLeftMaxPosX = if (isSingleLineTab) tabLayout.width else tabLayout.width - TAB_GUIDE_RIGHT_SIDE_ICON_LEFT_RESERVED_OFFSET_DP.dip2px()
|
||||
val iconRightMaxPosX = if (isSingleLineTab) tabLayout.width else tabLayout.width - TAB_GUIDE_RIGHT_SIDE_ICON_RIGHT_RESERVED_OFFSET_DP.dip2px()
|
||||
val isIconLeftValid = tabViewCenterPosX <= iconLeftMaxPosX
|
||||
val isIconRightValid = tabViewCenterPosX <= iconRightMaxPosX
|
||||
val isTabViewShowOnScreen = tabViewCenterPosX > 0 && (isIconLeftValid || isIconRightValid)
|
||||
val isTabLayoutScrollStateIdle = (tabLayout as? NoDefaultMinWidthTabLayout)?.isScrollStateIdle == true
|
||||
if (isTabViewShowOnScreen && isTabLayoutScrollStateIdle) {
|
||||
val trianglePosX = tabViewCenterPosX - TAB_GUIDE_TRIANGLE_OFFSET_DP.dip2px()
|
||||
val guideStartPosX = trianglePosX - TAB_GUIDE_START_TRIANGLE_OFFSET_DP.dip2px()
|
||||
val xoff = tabView.width / 2 - TAB_GUIDE_START_TRIANGLE_OFFSET_DP.dip2px() - TAB_GUIDE_TRIANGLE_OFFSET_DP.dip2px()
|
||||
val restGuideWidth = screenWidth - guideStartPosX
|
||||
|
||||
showMultiTabPopupWindow(
|
||||
activity,
|
||||
handler,
|
||||
guide,
|
||||
tabView,
|
||||
xoff,
|
||||
screenWidth,
|
||||
restGuideWidth,
|
||||
isIconRightValid,
|
||||
dismissCallback
|
||||
)
|
||||
guideSet.add(guide.multiTabId + guide.text)
|
||||
SPUtils.setStringSet(Constants.SP_MULTI_TAB_NAV_GUIDE_SET, guideSet)
|
||||
|
||||
return true
|
||||
} else if (isImmediately) {
|
||||
(tabLayout as? NoDefaultMinWidthTabLayout)?.let {
|
||||
it.onScrollListener = object :
|
||||
NoDefaultMinWidthTabLayout.OnScrollListener() {
|
||||
override fun onScrollStateChanged(view: NoDefaultMinWidthTabLayout, scrollState: Int) {
|
||||
if (scrollState == SCROLL_STATE_IDLE) {
|
||||
showMultiTabGuideIfTabViewShow(
|
||||
activity,
|
||||
handler,
|
||||
guide,
|
||||
it,
|
||||
tabView,
|
||||
isSingleLineTab,
|
||||
mainWrapperFragment
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (isImmediately && !isCurrentBottomTab) {
|
||||
tabWrapperFragment?.setResumeAndPauseListener {
|
||||
if (it) {
|
||||
handler?.post {
|
||||
(tabLayout as? NoDefaultMinWidthTabLayout)?.let { tl ->
|
||||
showMultiTabGuideIfBottomTabShow(
|
||||
activity,
|
||||
handler,
|
||||
guide,
|
||||
tl,
|
||||
tabView,
|
||||
isSingleLineTab,
|
||||
mainWrapperFragment,
|
||||
tabWrapperFragment
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dismissCallback?.invoke()
|
||||
return false
|
||||
}
|
||||
|
||||
fun showMultiTabGuideIfTabViewShow(
|
||||
activity: Activity,
|
||||
handler: Handler?,
|
||||
guide: BottomTab.Guide,
|
||||
tabLayout: NoDefaultMinWidthTabLayout,
|
||||
tabView: TabView,
|
||||
isSingleLineTab: Boolean = false,
|
||||
mainWrapperFragment: MainWrapperFragment?
|
||||
) {
|
||||
if (showMultiTabGuide(
|
||||
false,
|
||||
activity,
|
||||
handler,
|
||||
guide,
|
||||
tabLayout,
|
||||
tabView,
|
||||
isSingleLineTab,
|
||||
mainWrapperFragment
|
||||
)
|
||||
) {
|
||||
tabLayout.onScrollListener = null
|
||||
}
|
||||
}
|
||||
|
||||
fun showMultiTabGuideIfBottomTabShow(
|
||||
activity: Activity,
|
||||
handler: Handler?,
|
||||
guide: BottomTab.Guide,
|
||||
tabLayout: NoDefaultMinWidthTabLayout,
|
||||
tabView: TabView,
|
||||
isSingleLineTab: Boolean = false,
|
||||
mainWrapperFragment: MainWrapperFragment?,
|
||||
tabWrapperFragment: BaseTabWrapperFragment?
|
||||
) {
|
||||
if (showMultiTabGuide(
|
||||
false,
|
||||
activity,
|
||||
handler,
|
||||
guide,
|
||||
tabLayout,
|
||||
tabView,
|
||||
isSingleLineTab,
|
||||
mainWrapperFragment,
|
||||
tabWrapperFragment
|
||||
)
|
||||
) {
|
||||
tabWrapperFragment?.setResumeAndPauseListener(null)
|
||||
}
|
||||
}
|
||||
|
||||
fun showMultiTabPopupWindow(
|
||||
activity: Activity,
|
||||
handler: Handler?,
|
||||
guide: BottomTab.Guide,
|
||||
tabView: TabView,
|
||||
xoff: Int,
|
||||
screenWidth: Int,
|
||||
restGuideWidth: Float,
|
||||
isIconRight: Boolean,
|
||||
dismissCallback: (() -> Unit)?
|
||||
): PopupWindow {
|
||||
val binding = PopupMultiTabGuideBinding.inflate(LayoutInflater.from(activity))
|
||||
binding.guideTv.text = guide.text
|
||||
binding.guideTriangleIv.translationX = 12F.dip2px().toFloat()
|
||||
binding.guideTv.setPadding(if (isIconRight) 8F.dip2px() else 52F.dip2px(), 0, if (isIconRight) 52F.dip2px() else 8F.dip2px(), 0)
|
||||
binding.guideIconIv.goneIf(!isIconRight)
|
||||
binding.guideIconFlipIv.goneIf(isIconRight)
|
||||
|
||||
val popupWindow = BugFixedPopupWindow(
|
||||
binding.root,
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT,
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
popupWindow.contentView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)
|
||||
val measureWidth = popupWindow.contentView.measuredWidth
|
||||
if (measureWidth >= screenWidth) {
|
||||
popupWindow.width = screenWidth
|
||||
binding.guideTriangleIv.translationX += screenWidth - restGuideWidth
|
||||
} else if (measureWidth > restGuideWidth) {
|
||||
binding.guideTriangleIv.translationX += measureWidth - restGuideWidth
|
||||
}
|
||||
|
||||
return popupWindow.apply {
|
||||
isTouchable = false
|
||||
isFocusable = false
|
||||
isOutsideTouchable = true
|
||||
animationStyle = R.style.popup_window_ease_in_and_out_anim_style
|
||||
setOnDismissListener {
|
||||
dismissCallback?.invoke()
|
||||
}
|
||||
handler?.post {
|
||||
if (!activity.isFinishing) {
|
||||
showAsDropDown(tabView, xoff, (-25F).dip2px())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import com.gh.gamecenter.common.entity.NotificationUgc
|
||||
import com.gh.gamecenter.common.utils.NotificationHelper
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
|
||||
class NotificationPermissionDialogHandler(priority: Int) : PriorityChainHandler(priority) {
|
||||
|
||||
override fun onProcess(): Boolean {
|
||||
// 仅登录后再启动光环时请求一次权限
|
||||
if (UserManager.getInstance().isLoggedIn) {
|
||||
NotificationHelper.showNotificationHintDialog(NotificationUgc.LOGIN) {
|
||||
processNext()
|
||||
}
|
||||
return true
|
||||
} else {
|
||||
processNext()
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import com.lightgame.utils.Utils
|
||||
import java.util.*
|
||||
import java.util.concurrent.PriorityBlockingQueue
|
||||
|
||||
class PriorityChain(private val completeCallback: (() -> Unit)? = null) {
|
||||
|
||||
private val handlerQueue: Queue<PriorityChainHandler> = PriorityBlockingQueue()
|
||||
|
||||
/**
|
||||
* 添加 handler 到队列中
|
||||
*/
|
||||
fun addHandler(handler: PriorityChainHandler) {
|
||||
handlerQueue.add(handler.also {
|
||||
it.setPriorityChain(this)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动队列中的 handler
|
||||
*/
|
||||
fun start() {
|
||||
handlerQueue.peek()?.let {
|
||||
it.injectQueue(handlerQueue)
|
||||
it.process()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复队列中的 handler
|
||||
*/
|
||||
fun resume() {
|
||||
val handler = handlerQueue.peek()
|
||||
|
||||
if (handler?.getStatus() == PriorityChainHandler.STATUS_HANDLING) {
|
||||
Utils.log(PriorityChainHandler.TAG, "${handler.javaClass.simpleName} 处于执行中状态,不用恢复")
|
||||
} else {
|
||||
handler?.injectQueue(handlerQueue)
|
||||
handler?.process()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 队列是否为空
|
||||
*/
|
||||
fun isHandlerQueueEmpty() = handlerQueue.isEmpty()
|
||||
|
||||
|
||||
fun onHandleComplete() {
|
||||
completeCallback?.invoke()
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,94 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import com.lightgame.utils.Utils
|
||||
import java.util.*
|
||||
|
||||
abstract class PriorityChainHandler(private val mPriority: Int) : Comparable<PriorityChainHandler> {
|
||||
|
||||
private var status = STATUS_UNKNOWN
|
||||
private var queue: Queue<PriorityChainHandler>? = null
|
||||
|
||||
private var priorityChain: PriorityChain? = null
|
||||
|
||||
/**
|
||||
* 获取当前 handler 的状态
|
||||
* - 等待结果返回 (STATUS_PENDING)
|
||||
* - 无需执行 (STATUS_INVALID)
|
||||
* - 可执行 (STATUS_VALID)
|
||||
* - 执行中 (STATUS_HANDLING)
|
||||
* - 未知 (STATUS_UNKNOWN)
|
||||
*/
|
||||
fun getStatus(): Int = status
|
||||
|
||||
fun updateStatus(status: Int) {
|
||||
Utils.log(TAG, "${javaClass.simpleName} updateStatus ${this.status} $status")
|
||||
|
||||
this.status = status
|
||||
}
|
||||
|
||||
fun setPriorityChain(priorityChain: PriorityChain) {
|
||||
this.priorityChain = priorityChain
|
||||
}
|
||||
|
||||
fun injectQueue(queue: Queue<PriorityChainHandler>) {
|
||||
this.queue = queue
|
||||
}
|
||||
|
||||
fun process() {
|
||||
Utils.log(TAG, "${javaClass.simpleName} process $status")
|
||||
|
||||
// 若当前 handler 未经处理,将其状态改为 pending
|
||||
if (status == STATUS_UNKNOWN) {
|
||||
updateStatus(STATUS_PENDING)
|
||||
}
|
||||
|
||||
if (status == STATUS_HANDLING) {
|
||||
Utils.log(TAG, "${javaClass.simpleName} 已经处于执行中状态,不用再次执行")
|
||||
return
|
||||
}
|
||||
|
||||
val isHandling = onProcess()
|
||||
|
||||
if (isHandling) {
|
||||
updateStatus(STATUS_HANDLING)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行相关功能的地方
|
||||
* @return 是否满足执行条件并处于执行中状态
|
||||
*/
|
||||
abstract fun onProcess(): Boolean
|
||||
|
||||
/**
|
||||
* 分发给下一个 handler 处理
|
||||
*/
|
||||
fun processNext() {
|
||||
Utils.log(TAG, "${javaClass.simpleName} processNext")
|
||||
|
||||
queue?.remove(this)
|
||||
if (queue?.isEmpty() == true) {
|
||||
priorityChain?.onHandleComplete()
|
||||
} else {
|
||||
queue?.peek()?.let {
|
||||
it.injectQueue(queue!!)
|
||||
it.process()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun compareTo(other: PriorityChainHandler): Int {
|
||||
return (mPriority - other.mPriority)
|
||||
}
|
||||
|
||||
companion object {
|
||||
internal const val STATUS_PENDING = 0
|
||||
internal const val STATUS_INVALID = 1
|
||||
internal const val STATUS_VALID = 2
|
||||
internal const val STATUS_UNKNOWN = 3
|
||||
internal const val STATUS_HANDLING = 4
|
||||
|
||||
const val TAG = "PriorityChainHandler"
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import com.gh.common.dialog.PrivacyPolicyDialogFragment
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.entity.DialogEntity
|
||||
|
||||
class PrivacyPolicyDialogHandler(priority: Int) : PriorityChainHandler(priority) {
|
||||
|
||||
private var mPrivacyPolicyEntity: DialogEntity.PrivacyPolicyEntity? = null
|
||||
|
||||
/**
|
||||
* 提前预处理显示弹窗的内容
|
||||
*/
|
||||
fun doPreProcess(privacyPolicyEntity: DialogEntity.PrivacyPolicyEntity?) {
|
||||
mPrivacyPolicyEntity = privacyPolicyEntity
|
||||
|
||||
if (getStatus() == STATUS_PENDING) {
|
||||
if (privacyPolicyEntity == null) {
|
||||
processNext()
|
||||
} else {
|
||||
updateStatus(STATUS_VALID)
|
||||
process()
|
||||
}
|
||||
} else {
|
||||
if (privacyPolicyEntity == null) {
|
||||
updateStatus(STATUS_INVALID)
|
||||
} else {
|
||||
updateStatus(STATUS_VALID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onProcess(): Boolean {
|
||||
val currentActivity = CurrentActivityHolder.getCurrentActivity()
|
||||
|
||||
if (GlobalPriorityChainHelper.isThisActivityValid(currentActivity)) {
|
||||
when (getStatus()) {
|
||||
STATUS_VALID -> {
|
||||
PrivacyPolicyDialogFragment.show(currentActivity as FragmentActivity, mPrivacyPolicyEntity) { _: Boolean? ->
|
||||
processNext()
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
STATUS_INVALID -> {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import com.gh.common.iinterface.ISmartRefresh
|
||||
|
||||
class PullDownPushHandler(priority: Int): PriorityChainHandler(priority) {
|
||||
|
||||
private var mSmartRefreshFragment: ISmartRefresh? = null
|
||||
|
||||
/**
|
||||
* 提前预处理显示弹窗的内容
|
||||
*/
|
||||
fun doPreProcess(smartRefreshFragment: ISmartRefresh?, shouldShow: Boolean) {
|
||||
mSmartRefreshFragment = smartRefreshFragment
|
||||
|
||||
if (getStatus() == STATUS_PENDING) {
|
||||
if (shouldShow && smartRefreshFragment != null) {
|
||||
updateStatus(STATUS_VALID)
|
||||
process()
|
||||
} else {
|
||||
processNext()
|
||||
}
|
||||
} else {
|
||||
if (shouldShow && smartRefreshFragment != null) {
|
||||
updateStatus(STATUS_VALID)
|
||||
} else {
|
||||
updateStatus(STATUS_INVALID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onProcess(): Boolean {
|
||||
when (getStatus()) {
|
||||
STATUS_VALID -> {
|
||||
mSmartRefreshFragment?.popupPullDownPush {
|
||||
processNext()
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
STATUS_INVALID -> {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user