Compare commits
1761 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e211ee9a1 | |||
| 8e8883ba37 | |||
| 02c4398e48 | |||
| ad7a8dd7dc | |||
| e3338211d6 | |||
| 7cab4b9229 | |||
| ac5f1a0d93 | |||
| 798b9d0c98 | |||
| 3ff29aa38a | |||
| f8c2b9ffb0 | |||
| 888bb8897a | |||
| 192136e66c | |||
| 5057a57f7f | |||
| d81a4e0b7f | |||
| c63a06730f | |||
| bef326d2d7 | |||
| b8e85422f0 | |||
| d050bfdc68 | |||
| 3bac176bf6 | |||
| 7c506a42ae | |||
| 2c436e2027 | |||
| df0078b725 | |||
| 09c950a890 | |||
| e7e76ed68d | |||
| 06c1eeb995 | |||
| d545d852c5 | |||
| 3486e8dcf3 | |||
| 1956b700fc | |||
| 64ad9af344 | |||
| 55fec0b82c | |||
| 8323ef5f41 | |||
| 8dbab23de7 | |||
| 825d232613 | |||
| d797a03502 | |||
| 0ef6d74514 | |||
| 6234e897a8 | |||
| fe121f59b0 | |||
| 90cf5fcdec | |||
| 8b5782a5b6 | |||
| 68a131dbeb | |||
| 1411c02e18 | |||
| 81fe3f0108 | |||
| c15cf23168 | |||
| a79dc580a5 | |||
| 8a62c6295d | |||
| 88e77e1547 | |||
| 534619bc1a | |||
| ae904753f7 | |||
| 8c4a2cb529 | |||
| 16d4893480 | |||
| a7446e2f4c | |||
| 9dcae193a9 | |||
| 36fac0f3f4 | |||
| 24a4c176c0 | |||
| 9c7f50e91e | |||
| e52bc255f3 | |||
| ae4c9887d8 | |||
| 52201e2488 | |||
| c3e2b0e002 | |||
| 709915bf59 | |||
| 9d7ec6fd60 | |||
| ee9de376a3 | |||
| b54dc6f967 | |||
| abea85d831 | |||
| 972137c035 | |||
| 1cdef5e0ee | |||
| bd7ea64b02 | |||
| 20c850c10b | |||
| 0b021e6c42 | |||
| 0d109cdd4f | |||
| 1dab9e1a7d | |||
| 593b01819d | |||
| 029aa9c01b | |||
| 149b549d8d | |||
| 786635010e | |||
| d7fe170067 | |||
| e3d4be9a5a | |||
| 4086a73727 | |||
| 483e3a760f | |||
| 2757f881dc | |||
| e2aff0ece7 | |||
| 327526330f | |||
| ea976a4d0f | |||
| 728ada5e70 | |||
| c091ac4d67 | |||
| ee4c852f1b | |||
| 1a5d334f6c | |||
| 7d72ff3514 | |||
| e224e91100 | |||
| 7c5edd1b73 | |||
| 2621415f7c | |||
| a3184c46b6 | |||
| 1575ffa6ae | |||
| ee27da3de6 | |||
| 83a7224f2d | |||
| ecea2ecdf5 | |||
| f04060b31b | |||
| d411d1966a | |||
| 507bf07104 | |||
| 09061a38bc | |||
| 611a7db2e1 | |||
| a5cf428ce5 | |||
| 31f06a2d43 | |||
| 1d7a60b630 | |||
| a2fadbe513 | |||
| dee61e191c | |||
| 32b6461c6a | |||
| 93fff42693 | |||
| 61f429896c | |||
| a9e03837a3 | |||
| 89421946af | |||
| 218af8ea54 | |||
| d0f79ca473 | |||
| ec870759cf | |||
| 0405a535c7 | |||
| 814e4ba744 | |||
| 5621c1ab58 | |||
| f1fd8bc446 | |||
| 60fdd6cda9 | |||
| 3332363a10 | |||
| 538bd3f126 | |||
| 336f985894 | |||
| ba6687355e | |||
| 983980d8da | |||
| 82d4a401fd | |||
| 76e9f42734 | |||
| 0c0035370a | |||
| a3ac136b3b | |||
| ed1509b54f | |||
| 1d0dcd097c | |||
| 785c0469ac | |||
| 7594ae5fa5 | |||
| 6b4e08fdd1 | |||
| 65435341f3 | |||
| 9bc9f963b7 | |||
| a27501371f | |||
| 9fafebc8e7 | |||
| 59d2151c92 | |||
| 1cc2a05f90 | |||
| 8aea6f5473 | |||
| 22df7e3074 | |||
| 1d5323a477 | |||
| f8d73819ea | |||
| cbe26b7291 | |||
| 93477f60c2 | |||
| 9feebbfe17 | |||
| 6e365491a9 | |||
| 2e58658129 | |||
| 256c564b91 | |||
| 96b50f52ec | |||
| 3167d8aa15 | |||
| 78fd09c728 | |||
| 4c5598cedf | |||
| c3347d94ab | |||
| 7ca4aa75a8 | |||
| 226fad5594 | |||
| d0ee1ba5af | |||
| 439e0c8284 | |||
| 7d079a8728 | |||
| 945a52653e | |||
| bdafc86990 | |||
| 57d425ab9f | |||
| 395ac8e944 | |||
| 2f801e7571 | |||
| d7636045fe | |||
| b745f10870 | |||
| d76849942c | |||
| b7a8a3ffe8 | |||
| 95d9293fe0 | |||
| 3be165a551 | |||
| cb498e2128 | |||
| 973f4d66e2 | |||
| 2c80672f6e | |||
| 2599813ef1 | |||
| 86f849a185 | |||
| 875f1f1506 | |||
| e418375963 | |||
| d528fc7f9e | |||
| 633ea97848 | |||
| 36cb899b91 | |||
| c4d849d6a3 | |||
| c8bd39b4bf | |||
| 733ba16af2 | |||
| 37f57c0c55 | |||
| 013dbd79b4 | |||
| f76d0b3258 | |||
| c2f7cdd72e | |||
| 01c37cb0ba | |||
| 0dd0af1b84 | |||
| 26aa684300 | |||
| 9669cdfb76 | |||
| 2c5e5e283e | |||
| 303921c6ea | |||
| 593291a60f | |||
| 3af8e395bd | |||
| 0b192cfa52 | |||
| fb8f20f31a | |||
| e53386cf72 | |||
| b0e9b9b307 | |||
| 789678a45d | |||
| 4ad01d3451 | |||
| 6a87daa0b3 | |||
| aebef87076 | |||
| 32ff58598f | |||
| 2d56cbe227 | |||
| fbef5f592b | |||
| 090af36f5e | |||
| 885f27fcf1 | |||
| 8dc4eaf77a | |||
| a55bef08a8 | |||
| 0dc3089739 | |||
| 789ef0d783 | |||
| 092db1106d | |||
| 5f4b5bc570 | |||
| 32581fcd5a | |||
| b14d28c406 | |||
| 1d1535dc55 | |||
| de942440e3 | |||
| b58fc39cf1 | |||
| 2e3af25dd4 | |||
| 1d541a30ae | |||
| f926714544 | |||
| f68849d3a5 | |||
| 2111232f42 | |||
| 088552bf56 | |||
| 3eabbc9770 | |||
| 8e3b8df497 | |||
| 06a5aaaa72 | |||
| 97c4f14094 | |||
| 1fa7f18235 | |||
| b309d2fd4a | |||
| 372b56bb1b | |||
| 3325a36cae | |||
| 38673bbff4 | |||
| fb51834153 | |||
| 3a932a1e8a | |||
| 53c61bcb17 | |||
| 6951b4b20d | |||
| 746f9f1a11 | |||
| 9a7344ccbe | |||
| ab2fb8747f | |||
| 9cd8cb3d54 | |||
| ba1c2845b6 | |||
| 065aa19e9e | |||
| 4c2a05c3a6 | |||
| fd45c0740c | |||
| e44bf920fa | |||
| 8a327b2dff | |||
| 6ece7e2596 | |||
| 2e2ce98be3 | |||
| fe4c2392db | |||
| 320a0971b4 | |||
| bfb70b6a05 | |||
| a68af62748 | |||
| 52bd5ce5cc | |||
| b93d486348 | |||
| d193c58e5f | |||
| 6ac2a61793 | |||
| a45c6f2197 | |||
| 71d639bf19 | |||
| 9a51472726 | |||
| 0670f298cd | |||
| aa1e98544b | |||
| fa4607e232 | |||
| cb46420c09 | |||
| d88014fa90 | |||
| 168b76cb0c | |||
| f5680c6d69 | |||
| 654a3cc7ed | |||
| 841cdc474f | |||
| 0adbea3a43 | |||
| e12bada052 | |||
| 68dbefc46f | |||
| 9d71e9b177 | |||
| 5b5801c2cf | |||
| df1cc2b8e9 | |||
| 18d399b3f7 | |||
| e9687fd182 | |||
| 79137a074c | |||
| dae55ca386 | |||
| b7f040d89a | |||
| dc69df9f4f | |||
| 6c1fbfa63b | |||
| e968a2195a | |||
| 000bcea181 | |||
| 8edf508453 | |||
| bc9cc50130 | |||
| 71091d88fc | |||
| 70c1d7e21f | |||
| c07920978e | |||
| 954b2919ac | |||
| c630f731ed | |||
| aaefa7f74e | |||
| 2ec6b471f1 | |||
| a5c5ab68d2 | |||
| fb045c501a | |||
| 6a6e411492 | |||
| 76aac330fc | |||
| 07bdf31f66 | |||
| fe14928af6 | |||
| ad0c1033a4 | |||
| 0c2448fb99 | |||
| cedda145a5 | |||
| ee73187f1a | |||
| 89f91d6800 | |||
| 6714827694 | |||
| aad73f7d19 | |||
| c5985de1c3 | |||
| 86a5b0879a | |||
| 414972d545 | |||
| 9a74ae5844 | |||
| 301980ab14 | |||
| 5dced82e5a | |||
| 9a1e4df408 | |||
| 5b08b81239 | |||
| 7fac538ba3 | |||
| ef6be74ec2 | |||
| 9f49587245 | |||
| b7b733f351 | |||
| 06bfc33e72 | |||
| fbcd55d6c5 | |||
| 2484b5f14b | |||
| 6982659658 | |||
| 9e006166a8 | |||
| 25a62e33a1 | |||
| d05ed0a56c | |||
| eaffb2755c | |||
| e0fcae2ae3 | |||
| af9ad61174 | |||
| 7c54ad54fc | |||
| aee9f1032c | |||
| f7d0605e0a | |||
| f40dcafb43 | |||
| d9cb54b285 | |||
| f738a162d3 | |||
| fda4cd6783 | |||
| ecd1604e25 | |||
| 0f061900af | |||
| c47f5ea85e | |||
| 306eb0e3c7 | |||
| e64025ded8 | |||
| c1fe2da636 | |||
| ff23f58a4f | |||
| fc2f5ffdf9 | |||
| 6dd9ed7fb0 | |||
| 2f362abb91 | |||
| 96807a64cf | |||
| 7df5f1c4c4 | |||
| cf1ede9cf7 | |||
| 729385588a | |||
| 668d5cf8f0 | |||
| 72b1b5b0f9 | |||
| fbf726c174 | |||
| c441eed847 | |||
| e8e83ed49c | |||
| cdc21b067c | |||
| 48e19f7914 | |||
| 89dd570b30 | |||
| 16474d4328 | |||
| 9db612bf03 | |||
| 7d92dbc5c0 | |||
| a9efca8687 | |||
| dbfea5d02b | |||
| a6b05c4a27 | |||
| 6d539d3404 | |||
| b2aff1efc9 | |||
| 8a20a1ef50 | |||
| 33cbfa9751 | |||
| b95a8d44d4 | |||
| 54df9d634a | |||
| 4eb9a696ff | |||
| 7b4fb4682b | |||
| da4275530d | |||
| 1c417e909a | |||
| fc53d69f82 | |||
| dda86cdb93 | |||
| 525a974e3a | |||
| b18c155e22 | |||
| 07e011092a | |||
| 6803ac0611 | |||
| af0dde5ae8 | |||
| ea6edaecc4 | |||
| eb2054bd5e | |||
| b277b3e3af | |||
| 9dc3a4e6ee | |||
| 6fbd2f1079 | |||
| 9edbc7f1d7 | |||
| 8aa75be0d3 | |||
| dc124fb15c | |||
| 9109d1ca3e | |||
| 02296f1d1c | |||
| 63e1082b97 | |||
| 285f228660 | |||
| c18cf069b1 | |||
| fc64f47589 | |||
| 562b940d91 | |||
| d658e07583 | |||
| 9121a6341c | |||
| 4bec027f11 | |||
| b9053e3057 | |||
| 0621138478 | |||
| ce42e89e25 | |||
| 46e1e4c043 | |||
| 621468a183 | |||
| d8876cf96a | |||
| 57d5bc6480 | |||
| f224918f33 | |||
| 7b290dc465 | |||
| b1412dda34 | |||
| 28e4ac8dcb | |||
| 79eeb6d703 | |||
| 0d0e735d0e | |||
| d994502d06 | |||
| dfbd7a65ae | |||
| f99f94c8d7 | |||
| 41c643496a | |||
| e5476f8a01 | |||
| 188fb188ce | |||
| c852592b34 | |||
| 3a1e0c5a63 | |||
| 6376972130 | |||
| c70c860a82 | |||
| 5a178ada74 | |||
| 230427e758 | |||
| abf1af41a3 | |||
| 61e2548bb7 | |||
| f739c54292 | |||
| 3ed84de320 | |||
| 621b4c0946 | |||
| 11be969101 | |||
| ea958cd8f7 | |||
| 56048dcdb0 | |||
| fb545947ec | |||
| df57070b70 | |||
| 9b27d7ee23 | |||
| a2d3fa6e1d | |||
| 94b670eb81 | |||
| d65ed6ced7 | |||
| db50eb7526 | |||
| d21b2018cb | |||
| 9110c07ed9 | |||
| 2298e71279 | |||
| 909bd76e08 | |||
| 50cd0c4e10 | |||
| 460fc235e3 | |||
| c38a3d9eba | |||
| b303291e94 | |||
| 7993da038e | |||
| 05bf4f5525 | |||
| db36896f92 | |||
| 16dbad8bdf | |||
| 8a4c717d24 | |||
| 442a290966 | |||
| 0785f4d0f5 | |||
| 21e325af9c | |||
| 3e9d29ea7f | |||
| 4324373e61 | |||
| 673053d291 | |||
| 5b3975f886 | |||
| 7ed8f43859 | |||
| dcbb1c0dd1 | |||
| 5d4d417f3e | |||
| 5943c6a2c6 | |||
| 6d33d72663 | |||
| 9d2b098837 | |||
| 17bc2d2331 | |||
| 1c192b8db6 | |||
| 76595233fc | |||
| 6531b80998 | |||
| 05707e29d7 | |||
| 616ed4637d | |||
| 912c340a01 | |||
| 583a2f0fad | |||
| 60015bc041 | |||
| 029f445d0a | |||
| 150416b578 | |||
| 6684576de1 | |||
| 289acc9296 | |||
| 2cf9a407e8 | |||
| 682c364647 | |||
| e70730e9a8 | |||
| 0ba6c88d69 | |||
| c56bdea1e2 | |||
| a449a01a24 | |||
| 849acfca3d | |||
| 3cd3cb0186 | |||
| feead100f2 | |||
| a9987e6ab0 | |||
| ef0a6f54b8 | |||
| c8865ad185 | |||
| 354968fba7 | |||
| f985ed2131 | |||
| be2628875f | |||
| 9430c8c580 | |||
| ea2cf5d4ff | |||
| 3b36974d84 | |||
| 41fea1d2a0 | |||
| d81fafc9f6 | |||
| 0a73177996 | |||
| c9423ef425 | |||
| 7086055ec3 | |||
| 553b35d218 | |||
| c910026308 | |||
| 35be9f14e4 | |||
| abcbec9c2a | |||
| ff6f5d7e89 | |||
| 56deea9fb3 | |||
| 1c9a139006 | |||
| 4d89c324b9 | |||
| a76ce03911 | |||
| 9ee3f46ff0 | |||
| 3343007cf8 | |||
| c42d314b76 | |||
| 8db6c2153e | |||
| 5baf54335b | |||
| d9019b8f46 | |||
| a31446557d | |||
| 321fbe22dd | |||
| 01ab912bd9 | |||
| 557bad60bc | |||
| f2dd67d87f | |||
| b8b92c8d69 | |||
| 74ff112e7a | |||
| 684bb1875c | |||
| f6fec2424c | |||
| 2889029b70 | |||
| b56b4fa813 | |||
| 00bc055d69 | |||
| 6fd291c7e3 | |||
| dbdb787076 | |||
| fc788a718d | |||
| e093fe6a06 | |||
| cdce368042 | |||
| 689847d864 | |||
| 3675580d87 | |||
| 92f494d0fe | |||
| 06d7a6d892 | |||
| e2754200af | |||
| cdb083ff48 | |||
| c3fb08d634 | |||
| 78a167aacf | |||
| 5a913fdfbb | |||
| f0a190e8d2 | |||
| a2715fb851 | |||
| 47e5b03f45 | |||
| 251141a5c3 | |||
| 6ac8f4c45d | |||
| 7ebefa7c42 | |||
| 9e4c90f220 | |||
| 50f988641b | |||
| e53b9d4790 | |||
| 027805c4d5 | |||
| c02496c4f0 | |||
| 2a83f290a5 | |||
| d4f9b0b1bc | |||
| 2452b03a49 | |||
| 2ce423b6cb | |||
| e9206158b8 | |||
| 8690e918dd | |||
| c1d702a51c | |||
| 0338ac3810 | |||
| 526fef85e4 | |||
| 49f2d8588a | |||
| 9a80992aec | |||
| 32d0890dba | |||
| b4d37f9ba2 | |||
| 5372ef8f0c | |||
| a11b654c3d | |||
| 1a9a0b3394 | |||
| 890920a57b | |||
| 7fe7de5fdf | |||
| b9b115d0ea | |||
| 08af195f11 | |||
| 71cde729fc | |||
| 077f0a03f6 | |||
| 812eb8001b | |||
| b59af683ac | |||
| 561d680e78 | |||
| 7c3eff2ba7 | |||
| 300c0a8f35 | |||
| 51bfdc0947 | |||
| a64566c0f3 | |||
| dbb9a80ea6 | |||
| e930c54246 | |||
| dfff047cbf | |||
| 44fb2b02bc | |||
| 6a7efafd9f | |||
| 241abc3956 | |||
| 1e82c879bf | |||
| a81d01d2e3 | |||
| 2230796504 | |||
| 458ca7c7cf | |||
| 3f91663ecf | |||
| 04a671382a | |||
| 945ec818e5 | |||
| ff7ac8a785 | |||
| 603105e2ea | |||
| 5475567b48 | |||
| 2aec0adb08 | |||
| 54fc3761bf | |||
| 99e1912bfe | |||
| ecc1cabafd | |||
| 1a5b847b23 | |||
| d3409e7133 | |||
| 4e553e3eb3 | |||
| 4577bbc572 | |||
| da8ca23496 | |||
| 988853be63 | |||
| cde5dc5bfa | |||
| b617250eff | |||
| 313da99536 | |||
| 442e245216 | |||
| 050ab17019 | |||
| c80f488a13 | |||
| cf73804c71 | |||
| a90e5d13ea | |||
| 891fb0b479 | |||
| 58a623d44d | |||
| 0e84b8a154 | |||
| a4dfcf80e4 | |||
| d8567eadb2 | |||
| 0b88207ad5 | |||
| 671466a737 | |||
| 84881a0d52 | |||
| a589049cc7 | |||
| 17877e0f17 | |||
| 1ed9bef2a1 | |||
| a6dddf311c | |||
| e8c2bad187 | |||
| 52bda2c080 | |||
| 607919f40f | |||
| d830638ee6 | |||
| 106bda2097 | |||
| 7debb27374 | |||
| 05b5a7f598 | |||
| 3bbda7ba54 | |||
| 9312f5fd14 | |||
| 399eb07e35 | |||
| eb197ebcee | |||
| 4c30d8ab05 | |||
| 3a67ddf0f6 | |||
| 6541c7b5b7 | |||
| 37f41ade43 | |||
| 007d20d417 | |||
| 00370a81fa | |||
| d4599c3331 | |||
| bce76bbcf3 | |||
| 847a5fe71b | |||
| e2fa003239 | |||
| 0c555e88d3 | |||
| bf7f1a04b3 | |||
| 623172af6d | |||
| 4fb689d9e4 | |||
| 6054c489c6 | |||
| 21719f4408 | |||
| f2a650ba02 | |||
| 871c28b1ea | |||
| d3aa32147a | |||
| 9a50f2e408 | |||
| dcde4947e8 | |||
| 5b61bdc3a8 | |||
| ec1d65f4c3 | |||
| a0081dec07 | |||
| 783787e514 | |||
| ac99dd55a2 | |||
| c56f984952 | |||
| 9269ca726e | |||
| eca3205dcf | |||
| 13f5486d0b | |||
| d4e71274f9 | |||
| 4cc96de806 | |||
| d27ef12039 | |||
| f3c2ee4c40 | |||
| 555f73b478 | |||
| 544bf2ea21 | |||
| 54bbb5e384 | |||
| b10062c73d | |||
| a027d6df1b | |||
| 926a53a4b0 | |||
| 406cb46170 | |||
| acc58dc892 | |||
| 55894c22a4 | |||
| 476b10b862 | |||
| 3cbbe446ab | |||
| 4cf7512ee0 | |||
| ee8ec460a1 | |||
| deecab3cca | |||
| d2f5c1a195 | |||
| dba77e26a3 | |||
| fa48bafbc6 | |||
| 73c48694c7 | |||
| 0ff89d039b | |||
| 7a7081ee13 | |||
| 874aaf4e93 | |||
| ebf076d9f6 | |||
| 073a041d4c | |||
| 96a9b4dabd | |||
| 8e4cdf2386 | |||
| ab4d925a5a | |||
| d9c6f52e21 | |||
| 0a748cd53b | |||
| 07314ef018 | |||
| 5eaebf678f | |||
| 80fbfa60de | |||
| fbbcc9e9b6 | |||
| f47dc6b9de | |||
| 5f8e74f017 | |||
| 8c1ca0ac7e | |||
| 9018de3c4c | |||
| e7cb88c757 | |||
| d6127d6811 | |||
| 67e09e2e1d | |||
| 8fbc24c751 | |||
| c0948209be | |||
| 7237161d52 | |||
| 94c2e21e2b | |||
| 65067e6e01 | |||
| 39490ce7ba | |||
| 2f3f47c745 | |||
| 2195c3df76 | |||
| 119b9db6b4 | |||
| fcbc598732 | |||
| e850049e8e | |||
| 907adea73f | |||
| 2ac5c1362c | |||
| 8b20e2b48f | |||
| c2a9820fc1 | |||
| a9e5bc0c95 | |||
| 0fa2834d25 | |||
| 23f0876c00 | |||
| 6d88d90659 | |||
| a3c366c360 | |||
| 3bef07eeab | |||
| d029e65b8e | |||
| f305ac6905 | |||
| 4d4a46d2a5 | |||
| 8218f2f830 | |||
| b1bf901eac | |||
| 06eff55210 | |||
| 71730fddad | |||
| f2d1c6e3cb | |||
| 7ae837ca3c | |||
| b10908df5e | |||
| 4dd4d38d5b | |||
| 447c286b56 | |||
| c71898ece9 | |||
| 9473e88ea9 | |||
| d7663ed56e | |||
| da7569e2f5 | |||
| d989940a4d | |||
| bd6a86b135 | |||
| b38eb11503 | |||
| 7aef32c13d | |||
| fab64b147c | |||
| cc5a63205c | |||
| 814166a884 | |||
| 55240d9e9b | |||
| 9dc598150f | |||
| 21c087e273 | |||
| bdf3a7014f | |||
| dfea6e9b1b | |||
| 50eef1190e | |||
| ed180121ff | |||
| bdb0ad89d4 | |||
| 7195a30d55 | |||
| 5b0426a94c | |||
| a6d012abd9 | |||
| 86f0b3f29f | |||
| 85e3aa34ac | |||
| 5bbc1dedef | |||
| 39b468ef06 | |||
| fe17176b31 | |||
| 84f701c4ab | |||
| 047f8c176f | |||
| d82e79b680 | |||
| 320d1ae9d8 | |||
| a8892143a2 | |||
| 50f4532406 | |||
| 844454053d | |||
| db5c5ed534 | |||
| a26b8ecca0 | |||
| 5a32ccfa7a | |||
| f51818b157 | |||
| 31a624db51 | |||
| f045b18762 | |||
| f5006cac7d | |||
| 152b193ad5 | |||
| a27af0b642 | |||
| 44ffed3f7c | |||
| fa035ad9be | |||
| 186ace4343 | |||
| 8fb1a0bb1f | |||
| 05513bf8b9 | |||
| 858784857e | |||
| 291a23949a | |||
| 454de23844 | |||
| 1176092fc6 | |||
| 0fc2c57395 | |||
| 0b292f8d74 | |||
| 4bbe51331f | |||
| c289786dfa | |||
| 9a9752a6a1 | |||
| c43b688f8e | |||
| a6272d5221 | |||
| b440a58d95 | |||
| ec1589aa2d | |||
| 8d48e56fa0 | |||
| df7938037e | |||
| c908ee2d49 | |||
| b714abddae | |||
| 63ca189907 | |||
| 6130fb9ba2 | |||
| f0edc676fc | |||
| b68fdb0772 | |||
| 76c7bdd604 | |||
| 205101568e | |||
| efff68c49b | |||
| f74f60bb1d | |||
| 63ea28a620 | |||
| 2c6d043277 | |||
| 9a226f7b64 | |||
| 3b73a0fd72 | |||
| 2478aa77cd | |||
| a41068dbc9 | |||
| 5e47b7ae6b | |||
| debf45a7d5 | |||
| e7041e8c8c | |||
| bd960992bc | |||
| 0c5f6b432c | |||
| 49232edbd5 | |||
| b02884f58d | |||
| 845b588426 | |||
| 3a97d7c8be | |||
| 2cb2ded2d9 | |||
| 14e02bee6c | |||
| 30f7cdc1ba | |||
| 420d14fc37 | |||
| 3d7953d977 | |||
| 35238b3da1 | |||
| 446f4283e0 | |||
| 8062dd3709 | |||
| 41c8fde8c5 | |||
| d90b986d19 | |||
| 64ea8416b2 | |||
| 100a4c9d35 | |||
| 4ef6dec89a | |||
| a14cdc48bd | |||
| 8a4ddbc6df | |||
| ee33acc561 | |||
| 5fe69becf3 | |||
| d460d3ccdf | |||
| 0ee74943e8 | |||
| 82837e38d2 | |||
| 91df90d760 | |||
| 1ee37da720 | |||
| 6f8fc5b69d | |||
| be1918c769 | |||
| 0057b35a0a | |||
| d12974702a | |||
| 921c41689d | |||
| 6389899507 | |||
| 92ede2a2b3 | |||
| 826a63ed71 | |||
| d1576a2a72 | |||
| 95f218d704 | |||
| 315d3a0ac0 | |||
| 954818cef2 | |||
| 5a95ca9b1b | |||
| c1e6f4c26e | |||
| 7c603258fb | |||
| fcbc582686 | |||
| 9c4906b90b | |||
| d35e31e02d | |||
| 6c4ca36c09 | |||
| 70355dc505 | |||
| 20aeaf2a05 | |||
| 1f13e1d08b | |||
| eb9d35c123 | |||
| 45808cd530 | |||
| fd715a3f92 | |||
| e3b32367a7 | |||
| bf9554a746 | |||
| b9f8ca1488 | |||
| e8c4159678 | |||
| e57e71629e | |||
| 2bfd9d24a4 | |||
| b18b8fe22f | |||
| b154ff2f9d | |||
| e9b764b63c | |||
| 7216b97d92 | |||
| 0e9d93b194 | |||
| 2cbee62f0a | |||
| 379e9da5fe | |||
| ae7caa4901 | |||
| cd8b4c9dd7 | |||
| 60cd61dfd2 | |||
| 5a6637d9fc | |||
| dca7ed23f5 | |||
| 8cb5791f3b | |||
| 9b67f2c58f | |||
| 3815810d4f | |||
| 819ceba17d | |||
| 0aa0d62e03 | |||
| b3e2a35880 | |||
| 15ec20c65d | |||
| d4d6d7e12f | |||
| 2e7a4f1421 | |||
| ab8a52faf3 | |||
| bd465559fb | |||
| 13ec45a95c | |||
| 13b034875b | |||
| bb701fb088 | |||
| b367414865 | |||
| 4b00eec608 | |||
| 5e11b51152 | |||
| 9fb43b996e | |||
| bc2072e81f | |||
| f36bc3f643 | |||
| f7901ad843 | |||
| 3771030ed6 | |||
| 57197e58b5 | |||
| ac601399ac | |||
| 6a0e221153 | |||
| 6a949fc851 | |||
| f1a077dc2f | |||
| f20962b02b | |||
| 77e057f244 | |||
| 2c5114c770 | |||
| a30895a199 | |||
| 6d46d4b3da | |||
| 006efbbb77 | |||
| 52334087ad | |||
| ea8fb2c70a | |||
| 531d148718 | |||
| d83ddea323 | |||
| b5dea34090 | |||
| 7d8e3202b5 | |||
| d956e0af4b | |||
| 9ad70990b5 | |||
| 82d711f077 | |||
| 5fc28ef711 | |||
| 1f3dc682e2 | |||
| cce7768246 | |||
| 01172b0664 | |||
| 1ca11fdd34 | |||
| 52a064ae45 | |||
| 6c62ddf927 | |||
| 47e04c08d0 | |||
| d1601874b4 | |||
| 6bc19af041 | |||
| 4e72a3886f | |||
| 8e6b219eea | |||
| bd638251e4 | |||
| 0173d5e4b3 | |||
| 4f364e134b | |||
| 94d2519717 | |||
| 6a11d2e357 | |||
| 0a9e0bc9e4 | |||
| 5914e367d1 | |||
| aeaed888d4 | |||
| a0f054b005 | |||
| 4498e9d444 | |||
| 43e0763fef | |||
| a519c8a482 | |||
| 19bc595a2a | |||
| db07825c58 | |||
| b199e3bf0e | |||
| 1f9ea0891e | |||
| 0a7aa48f1e | |||
| 4b65b7da6c | |||
| 183a7dac4b | |||
| 6726f008c1 | |||
| 89cf0c140f | |||
| 504025ce80 | |||
| fee9e914f1 | |||
| 76efa71c68 | |||
| 26e61959ae | |||
| 9a8956ef9d | |||
| 10d3ffc2f6 | |||
| 090399f61d | |||
| ae7d975a92 | |||
| 55ec6bcafe | |||
| f0566d15af | |||
| a730b692bc | |||
| 826d767423 | |||
| 6d227c7fcd | |||
| 7d9d97840e | |||
| 110ded45a0 | |||
| 7872b593c7 | |||
| 90be30bddb | |||
| a298c61dab | |||
| eb416c45bd | |||
| b05b817aeb | |||
| 666602283a | |||
| ac040a4bae | |||
| b4982c8f22 | |||
| ce3ad92095 | |||
| 8e1ac8698c | |||
| b60a39c7cb | |||
| 3b3e8ba4c8 | |||
| e387f6d3be | |||
| 799d469cb6 | |||
| a54a596fa7 | |||
| 92d73d0285 | |||
| acb752e4e8 | |||
| 9e377abba6 | |||
| 04552c0923 | |||
| 2e1fb85b73 | |||
| 50db32d9b4 | |||
| 28743d953e | |||
| b109d26aa7 | |||
| 7fd21bd06d | |||
| 12e0ffb466 | |||
| 9259341df8 | |||
| 8e8aca7e7b | |||
| 7f0bcd987b | |||
| ef21de95cb | |||
| ca3246de02 | |||
| f0940b7926 | |||
| 0066e0b901 | |||
| 9771f566b0 | |||
| 38ad4c6dec | |||
| 37cf80a188 | |||
| c86ee53f66 | |||
| c2cea7e797 | |||
| a8ef6cdd4f | |||
| 53d157fee8 | |||
| c2e07b13f6 | |||
| 2e8cc48311 | |||
| f6f811eb77 | |||
| ac5528fb15 | |||
| 940d2b7862 | |||
| 835fe3dad3 | |||
| dfaecc08c5 | |||
| 87f5e9b847 | |||
| 3d3939e808 | |||
| 90822e3858 | |||
| 14eec47e9c | |||
| 15ed3fcc69 | |||
| fd8fa9f3ef | |||
| b81075f4a7 | |||
| f11a52e8e1 | |||
| 9c007483d4 | |||
| ff4e818e4c | |||
| 45a50ca0c1 | |||
| 65d9021c37 | |||
| 66481a0391 | |||
| a14a82bc9a | |||
| 756c57a16e | |||
| 8b19e34dc5 | |||
| 50083019ee | |||
| 155272e638 | |||
| 08443ceb3d | |||
| c215696f04 | |||
| 5ca42bf9b6 | |||
| 3272b9dec5 | |||
| 2ebd5da4aa | |||
| 34f024ace2 | |||
| b31f2d50f6 | |||
| da44d3b2b4 | |||
| 99ec2aca6a | |||
| 6c278604ec | |||
| 1e094a467a | |||
| 978ccfeeba | |||
| e93d66d8a1 | |||
| c29a749833 | |||
| b08d5d1261 | |||
| 9b129789e9 | |||
| a76a6d2798 | |||
| 086a760378 | |||
| f78c8d4fd8 | |||
| 7b91489997 | |||
| 36a8980c95 | |||
| 7c65640cb7 | |||
| d70e68495a | |||
| 2586202772 | |||
| b5f771368a | |||
| 0c28320ce3 | |||
| c8b4fbc36b | |||
| e9b07849fe | |||
| 409260af6f | |||
| d3d53d1a4e | |||
| e2db191f70 | |||
| d61816734d | |||
| f4dad8058f | |||
| 70bdb375c3 | |||
| e724ab0a29 | |||
| 7d0ee2ac11 | |||
| 59b7e852e2 | |||
| b2eb1a391d | |||
| 9b3aee98d3 | |||
| 0476f4144c | |||
| ed77f45fae | |||
| 0cd529e746 | |||
| 5969048318 | |||
| d1a7f8baa0 | |||
| 18dc936002 | |||
| b4b7b5d572 | |||
| 291c2e692d | |||
| 8a9a4f21b1 | |||
| cd31332b39 | |||
| cc8d2162a0 | |||
| e6313cdc67 | |||
| 5af64892e7 | |||
| a5578a7ac7 | |||
| fcdda6406e | |||
| 9bdd9f8aa6 | |||
| f3856f051b | |||
| d3a6662c60 | |||
| 5474eddf84 | |||
| b666cd47d4 | |||
| 8a986383fe | |||
| 9fa17f617e | |||
| e46e165704 | |||
| a6af423fb4 | |||
| 3397e694c0 | |||
| 77ff82505e | |||
| c3f2838270 | |||
| aed7f205b6 | |||
| 95b3587f7a | |||
| a4baeb995a | |||
| 032ab54206 | |||
| 1f9c1eb1c0 | |||
| a213e568ba | |||
| 7aeaeb4b86 | |||
| 81aef4b8fa | |||
| 31f0b6a16c | |||
| 44e3a682fd | |||
| 70402a6d3a | |||
| 5c4143224a | |||
| f943e924f7 | |||
| 7d2f542f8a | |||
| fb1f88e971 | |||
| f566f13423 | |||
| 0f88baf1c1 | |||
| a04cbcd814 | |||
| a17d6a2ea4 | |||
| 08f49e0ac4 | |||
| 7787dd1ecc | |||
| 3d0765d4ab | |||
| b51651ace4 | |||
| 568fa56d59 | |||
| 50dee9251c | |||
| e575aaf4fb | |||
| bdd5caae1a | |||
| 3af7de3460 | |||
| caa219f8d6 | |||
| afabaccf1d | |||
| 53cc73701c | |||
| c69b954ffd | |||
| d05c447fe4 | |||
| 5810a24cb0 | |||
| e04c6a9f4d | |||
| e3a9f7af42 | |||
| 5eb58a73ee | |||
| 68ad1f72ce | |||
| 704a52d943 | |||
| 67ec9ccc4e | |||
| c7112ec67f | |||
| 1e1e2034eb | |||
| 5f316c6f44 | |||
| 0c39718f82 | |||
| 8a5ac4a0af | |||
| 492d5f5e84 | |||
| 5a3621fe39 | |||
| fb862e23e5 | |||
| 3d69348301 | |||
| 30787846a2 | |||
| 345ca27f85 | |||
| b7a6d6cae8 | |||
| dadb686514 | |||
| 75f635a28b | |||
| f2bd5b8149 | |||
| 6ed4c79ca4 | |||
| 333f954919 | |||
| 2494d0821d | |||
| e349d0cef3 | |||
| eddad2ba89 | |||
| bfaf88afd6 | |||
| cd59aed8c7 | |||
| f18ca5811f | |||
| 1ed9bcf7c8 | |||
| 29a79ab079 | |||
| 7c03c73419 | |||
| 74f3b9b609 | |||
| a3953d530e | |||
| 2280e8c725 | |||
| b327df732c | |||
| 21d7cf5d6a | |||
| 5b64bdc5b7 | |||
| a3a25b6263 | |||
| c7611c8024 | |||
| f08170504c | |||
| 863dccb5ea | |||
| fc8bb10ca3 | |||
| d06c3586fd | |||
| 395989b528 | |||
| a325440f24 | |||
| 14072bb5a0 | |||
| 7fc33ba8db | |||
| 47e51b6615 | |||
| 857562eaff | |||
| bace854b50 | |||
| e4a404472d | |||
| 7bfa215b4c | |||
| ab7af4b80b | |||
| 2c7ebd8ece | |||
| c96da79058 | |||
| 8f09ebacf5 | |||
| e21f3b9c75 | |||
| 37eeef06e2 | |||
| b7fe56687c | |||
| 60565729ca | |||
| 36f4e1c340 | |||
| abc2a5214b | |||
| a29010e0d7 | |||
| db99ab66ae | |||
| 84cc73c149 | |||
| 10a29cab33 | |||
| 849e2f103a | |||
| 6c22fe193a | |||
| e69dbbf418 | |||
| dfa59a1691 | |||
| 5023e96301 | |||
| 224c24ee9f | |||
| e3b154cf9e | |||
| d249867c4c | |||
| b56045e984 | |||
| 3777cc646e | |||
| aa5a1083d0 | |||
| 2ae5e0742e | |||
| e5e875c54a | |||
| 1a99ec76e4 | |||
| 1b122d1157 | |||
| 77f2f8cc18 | |||
| f0a99980b6 | |||
| b0d43ffe69 | |||
| 16cb0184a4 | |||
| f211a33ea3 | |||
| 440c815189 | |||
| 25829aacfd | |||
| 700a739f95 | |||
| d9620bec05 | |||
| 4b6c51b1f8 | |||
| bd02edf0b1 | |||
| 5c7123a997 | |||
| c17e3bd04f | |||
| 994ae97256 | |||
| 781428a690 | |||
| c23ac5faa8 | |||
| e8d41f83c2 | |||
| 921a0a3361 | |||
| dda5a2df93 | |||
| 155f9f107d | |||
| 24f68b8f1a | |||
| 0ffbe194fa | |||
| 0b41e2b72b | |||
| ef07b9b4ce | |||
| f3999cf2d9 | |||
| 1729847937 | |||
| 37bff6c76c | |||
| 4ef32d8037 | |||
| d2f6a33f0a | |||
| 31d9903251 | |||
| e97642d92a | |||
| c49fc0ff5f | |||
| deb2ab1ff4 | |||
| 23466cf853 | |||
| 16b34f874d | |||
| 0e0d08ae5a | |||
| 986b4c2c27 | |||
| 0bf9ccfcbd | |||
| 5e8c47928d | |||
| ffae7f911f | |||
| e37fdf6d79 | |||
| b359116745 | |||
| 60073aace3 | |||
| 874b13fa14 | |||
| b146d1024b | |||
| 332e95c021 | |||
| 1f68141df5 | |||
| dd731cd306 | |||
| 38d8d03cae | |||
| ec7d840f37 | |||
| 2813dbb897 | |||
| 77d1402b8a | |||
| 08e8a9d105 | |||
| 71661f70b6 | |||
| ac1e79ba83 | |||
| d082809776 | |||
| a458a696db | |||
| 75786a91b0 | |||
| 6ddb5db57b | |||
| 4f70cc9283 | |||
| 23b643d637 | |||
| fdfc256c4d | |||
| fba56c1b75 | |||
| 4743bfacf7 | |||
| 2356537f7c | |||
| fa071aee84 | |||
| c00ca23a8b | |||
| 733b017936 | |||
| 4147f2e368 | |||
| 154b9992eb | |||
| 88b881b043 | |||
| 5d1491fb8c | |||
| 3a33196cf1 | |||
| fa8e0478da | |||
| 7e7e069244 | |||
| 18e0d34af0 | |||
| 3fe3f35483 | |||
| cf8e274883 | |||
| 10dee8b345 | |||
| ae8d30593f | |||
| 9cde46b5da | |||
| 8e61632155 | |||
| e2c4b4cb57 | |||
| 326da504ea | |||
| c5874a3f10 | |||
| 02802fab97 | |||
| 29dea10be2 | |||
| 6bc36193dc | |||
| 81e123388e | |||
| 8ebd7869a5 | |||
| 7a2f5f13f1 | |||
| 25d7dad39f | |||
| c8f8795920 | |||
| 84206a7074 | |||
| 6fd8b36dca | |||
| d1500baae1 | |||
| 045801dd1a | |||
| 14a2cbc793 | |||
| fd385017df | |||
| 9b05954cf2 | |||
| 6aaf636069 | |||
| d30e89e5ec | |||
| 7acc745478 | |||
| 5a9a2d816e | |||
| 105f11ed02 | |||
| 3021437a05 | |||
| 439602fc03 | |||
| 34e13b9589 | |||
| 2aab4ae918 | |||
| 7ef67671a4 | |||
| e8df84416c | |||
| be930bb68b | |||
| db52948865 | |||
| d2a72526f6 | |||
| 0a9f57b32b | |||
| 180f210536 | |||
| c1baa31eed | |||
| cacc97cec7 | |||
| d5691fd81c | |||
| 49dc9fe5f6 | |||
| c0b49c7428 | |||
| fa345af42d | |||
| db3cc786a1 | |||
| fe879ae51d | |||
| 2f55460ffb | |||
| fbc5bd4642 | |||
| 5e0c7d3c9d | |||
| 083996a48d | |||
| 9d38f478e3 | |||
| 57274a0a01 | |||
| b3b56b7fc8 | |||
| 0b690577da | |||
| e9683a3a37 | |||
| f8f67b3eba | |||
| 7b16b082d8 | |||
| 2a783f0d8e | |||
| 42ae32de33 | |||
| cec7ddc486 | |||
| 9c55fc3868 | |||
| 104c5a8d83 | |||
| 7450b16742 | |||
| 3ecd0931a1 | |||
| 2f2a52ae2f | |||
| f464087c30 | |||
| 2364960388 | |||
| 76be4d64cd | |||
| 7d98e8ce47 | |||
| 40831fc681 | |||
| e38e7ccf26 | |||
| 98b9e2f2cf | |||
| 4bf3c12f76 | |||
| bab25f9ad9 | |||
| a62ee8f8c3 | |||
| 5f23691e20 | |||
| 3de9ccc62f | |||
| 1896f7f37b | |||
| 490643dc02 | |||
| 9808976088 | |||
| 5a73068a10 | |||
| 01d5c2540d | |||
| 866b01f865 | |||
| da6a953099 | |||
| bce8d58845 | |||
| 3cfce2db04 | |||
| 327aae5dd9 | |||
| 1bdfde7032 | |||
| 295a0817b0 | |||
| a02dc02d52 | |||
| dc012edf7d | |||
| 1e2eb11c13 | |||
| 3a825f4f25 | |||
| b9ea8c5f74 | |||
| 320d7e2536 | |||
| c200785479 | |||
| 8abb132ad6 | |||
| 8bb2269f36 | |||
| 9d17b26283 | |||
| 5909f15db7 | |||
| 11672ca576 | |||
| e09773def3 | |||
| f6d4432e6f | |||
| 45a6abc5c2 | |||
| dc5e677a38 | |||
| a82549dc17 | |||
| a002e19d9d | |||
| cdf1f98d28 | |||
| 0ff1ebdeb7 | |||
| 17f4a396f8 | |||
| 8aa3cf4368 | |||
| 0136c5e493 | |||
| 8b94b9ee80 | |||
| bed63f19f2 | |||
| e2a6545a84 | |||
| e3d3ec6895 | |||
| 7ba476bd79 | |||
| 2dd41ebd27 | |||
| 038df78171 | |||
| 6e5ff2b508 | |||
| ec8d1e8680 | |||
| 1f0f0c33b7 | |||
| 825940fcac | |||
| 4618834af2 | |||
| 55d968df5e | |||
| 63a078cf7d | |||
| 5304917e53 | |||
| 831b74d2ec | |||
| 1bad9dcd69 | |||
| dd43716851 | |||
| f2e55e95a2 | |||
| 14658a0c4d | |||
| 4195e7056b | |||
| 1d29e8b248 | |||
| b718c718df | |||
| a3601cf1b5 | |||
| 0236a9639b | |||
| 5f4c7454ee | |||
| 773120c96a | |||
| 4b273c6bf9 | |||
| b626aa66ba | |||
| 1dd029559e | |||
| 59cbe5d5bc | |||
| 40d1173653 | |||
| bf6a0aba5d | |||
| 34d8feacdd | |||
| 1ea821584c | |||
| 3d2fee19bb | |||
| 449d12779a | |||
| 6fb6a251e7 | |||
| 4d6220f894 | |||
| fe747bfc52 | |||
| 0c2d038870 | |||
| 4e3f73af75 | |||
| 63e5e1b45f | |||
| 2e1558bd96 | |||
| 0671dee8b2 | |||
| 8f91b8089a | |||
| 009b45f676 | |||
| 8f7d5eb311 | |||
| f3de835ef3 | |||
| fd6662f428 | |||
| fde137b3ed | |||
| a1349aa0e3 | |||
| c9ef5f9b9d | |||
| 8fbf564177 | |||
| ae0b1a818c | |||
| c04cc780b7 | |||
| 71ad1bb6e3 | |||
| c1be77ee9b | |||
| d1fa857ffb | |||
| 93fd81b38b | |||
| 2f116b40b2 | |||
| b884d34bdf | |||
| 309803368b | |||
| 19fc5be8f3 | |||
| c28fac14c0 | |||
| 66e38de29f | |||
| 282cb1d3be | |||
| b741ded595 | |||
| 6b290695fc | |||
| 4e43c554c0 | |||
| 090a72b35f | |||
| 3fcc269df3 | |||
| 9958e0eb34 | |||
| c5269002a2 | |||
| 455a35f8ae | |||
| 0c79f207c3 | |||
| cd16d32a35 | |||
| 1989c1eb48 | |||
| f56856529f | |||
| 52e27a3e39 | |||
| 177c971b52 | |||
| 7a52e19235 | |||
| 5171e509a5 | |||
| 975a3b1828 | |||
| c11887fada | |||
| e043cb5690 | |||
| b2d5354798 | |||
| a211a4143b | |||
| c0df7d314b | |||
| c8a8ce07e2 | |||
| e0e474dfce | |||
| 7591748811 | |||
| 884308690f | |||
| 15bd5b4b7a | |||
| abc3a16ee3 | |||
| bb09ccf3c0 | |||
| ad2ea8095b | |||
| 760d1116a1 | |||
| 47fcf7eb97 | |||
| b0e90c2f63 | |||
| f502884fdd | |||
| 5ed79523d2 | |||
| da5dd70969 | |||
| 68e69085df | |||
| 640ce8f5d7 | |||
| c960cc1ee5 | |||
| 2b2601aa4a | |||
| 99a10ec7db | |||
| 035105adf0 | |||
| f983f0e359 | |||
| 769472b24c | |||
| 8c80ad7575 | |||
| 63db2e6695 | |||
| d6d5e97fbd | |||
| 1ae0a8326e | |||
| 57693fef7b | |||
| 5656016700 | |||
| 90ae180b3e | |||
| 2a3c78d43e | |||
| 11000af718 | |||
| b808121f1d | |||
| addadefeb1 | |||
| 838cd20e57 | |||
| 5b9219522d | |||
| caeb4d273d | |||
| 77cf87c989 | |||
| 50c2dbed5d | |||
| 71a9396952 | |||
| bc3ad75328 | |||
| 077bbc3c38 | |||
| b1b1abad1d | |||
| e6ba2a0066 | |||
| 9b56ef7d82 | |||
| dd442c6653 | |||
| 3044317b09 | |||
| 3a1e1e01dc | |||
| a567701639 | |||
| 1802271358 | |||
| 9e649eef79 | |||
| 1eb4a9c216 | |||
| e3f65d2192 | |||
| bb09cfddb3 | |||
| d383939c9f | |||
| 32dd543562 | |||
| 5a75f26791 | |||
| 95c437efd5 | |||
| ec877f632f | |||
| 8666cbf8bc | |||
| 84b0c26450 | |||
| 64e5bbabb3 | |||
| cc1a15e5ba | |||
| d29e942a72 | |||
| 8d86c88c38 | |||
| c7dc7421aa | |||
| 34ed3e5c68 | |||
| 1a4a8af384 | |||
| 62b1e99bbf | |||
| 1aa3b76934 | |||
| 3e53c50f64 | |||
| 430386bc84 | |||
| 30049e8152 | |||
| 34d9a7a233 | |||
| 183972475b | |||
| fd46727f8e | |||
| f6ce010aa2 | |||
| d0ff30df9f | |||
| 8e449abd67 | |||
| 2986130268 | |||
| 1c0c09f2f2 | |||
| 44100cb5b6 | |||
| cfc6e5cd2a | |||
| c067d14c2c | |||
| aded854a2b | |||
| e79d0b9dd2 | |||
| a0115d88b0 | |||
| 85ec2ed367 | |||
| bf908c4d17 | |||
| f41c5c9428 | |||
| 04837983fa | |||
| 5d484b012c | |||
| 436a8d0585 | |||
| 28cc0a6f84 | |||
| 26cc2f2c96 | |||
| 149107e749 | |||
| a74936c5f5 | |||
| ff8c8913d4 | |||
| 83426e1302 | |||
| 9cd93d467c | |||
| 257f8a5a27 | |||
| 79bab08cae | |||
| 4e699e4f5a | |||
| 1128f40bac | |||
| 53ef836326 | |||
| b8df0e89e5 | |||
| 472bfec6bf | |||
| c1b86cedd2 | |||
| 428c65f075 | |||
| 92ed48f7f6 | |||
| 13e84bc492 | |||
| 0ef86c34b7 | |||
| 7e1a4259d7 | |||
| c842c51fb6 | |||
| 6f2f228e08 | |||
| c78eaa8b96 | |||
| f9606526d2 | |||
| fe4cc9ea2c | |||
| 54d0c05fcc | |||
| 2f7df73a37 | |||
| cf19f3626b | |||
| ff2da5e59b | |||
| e03922e518 | |||
| 893fba5b8c | |||
| c1786f8e24 | |||
| a59f974537 | |||
| 7157e07328 | |||
| 954084bd82 | |||
| 0915ba40f6 | |||
| de30d55bcf | |||
| af1c34fba5 | |||
| 7b7d93786f | |||
| 7c1c504482 | |||
| 33b22fcab6 | |||
| ab0566dcba | |||
| c4f2cc7189 | |||
| 4626d99590 | |||
| 6465ca8a19 | |||
| 15b9d151df | |||
| dd1b6c86cd | |||
| 9613cda79a | |||
| 648b8e5960 | |||
| ce545b1fd5 | |||
| 9151034fbc | |||
| 312a8baa13 | |||
| 18b6168cd1 | |||
| 9a282c3bf4 | |||
| 2bbebe4c30 | |||
| 162961b560 | |||
| f1cc37d0db | |||
| 5a9d216fb7 | |||
| bf37d3be7c | |||
| 7fd57aaed8 | |||
| d996c44b24 | |||
| 6f3052dd1b | |||
| d2b1bfdcdd | |||
| 945fb99594 | |||
| 09d624a4e2 | |||
| eb90db7ce6 | |||
| b56f9391b8 | |||
| c181478909 | |||
| 76b31e734c | |||
| ed8bd76d95 | |||
| 3051a72d7f | |||
| 3a33bf3a5d | |||
| 7959ba2664 | |||
| fe6568b82c | |||
| c228648bb6 | |||
| fdaeb6d1fa | |||
| ba45e18399 | |||
| 3e2bf877d4 | |||
| c80d344046 | |||
| 2364f10d8d | |||
| 2602275c20 | |||
| d113311f4e | |||
| 8d95701e8e | |||
| 0d2c54a5ed | |||
| 6506c84b85 | |||
| 69bb38b487 | |||
| 95e17f2b50 | |||
| 9625da9221 | |||
| c1659f1cf2 | |||
| c46ee764ac | |||
| 7aada85f76 | |||
| 145cbe3e4f | |||
| cb8dd8259d | |||
| b8e721fd27 | |||
| 7917b5384c | |||
| 087b7554bf | |||
| fb5f851a2a | |||
| 7ac51f8c2a | |||
| e5e40a986c | |||
| 7a27436868 | |||
| a5bab7425d | |||
| 93d5ab3739 | |||
| 3146fefb55 | |||
| 1ea51bb9df | |||
| 98bd664ab6 | |||
| 61aee2e784 | |||
| 22bf49078f | |||
| 7284e0d4ae | |||
| d39d075b1a | |||
| 0f6749b0c1 | |||
| 771030b911 | |||
| 8d5744a2cf | |||
| a58aab9004 | |||
| 61bd32f7f0 | |||
| 63a444bd81 | |||
| 8f28c3b74b | |||
| d766206343 | |||
| 172f83f5b3 | |||
| 9e308025c3 | |||
| aaa6a16778 | |||
| 2a21da2210 | |||
| d1cd2cfc8c | |||
| 832c224ed4 | |||
| 99316f4bd5 | |||
| 9caae5f1e5 | |||
| 345be95ce9 | |||
| 6fe68841b7 | |||
| eaff2c15a9 | |||
| 5eb8dc66a8 | |||
| 49715c81e4 | |||
| 3398409555 | |||
| f05aa0589a | |||
| fbc71ce781 | |||
| ca9c671886 | |||
| bd109ba11f | |||
| 0ff770a98b | |||
| ed7bb408a3 | |||
| 84676b9156 | |||
| dcdd50ffe1 | |||
| afb21c59f0 | |||
| e219179519 | |||
| 15a2115c5a | |||
| 94c6f33925 | |||
| 202e38871d | |||
| 3f75b84651 | |||
| f171b785a0 | |||
| 088dd6a856 | |||
| 6318628ea2 | |||
| 0757ea5d0d | |||
| 2c76ad9b74 | |||
| 7d1c63e181 | |||
| 6401b946b6 | |||
| 9a61f58043 | |||
| b854fdeadb | |||
| 6eb4f1ba88 | |||
| ded5e3a73a |
@@ -0,0 +1,11 @@
|
|||||||
|
[*.{kt,kts}]
|
||||||
|
indent_size=4
|
||||||
|
insert_final_newline=true
|
||||||
|
ij_kotlin_allow_trailing_comma=true
|
||||||
|
ij_kotlin_allow_trailing_comma_on_call_site=true
|
||||||
|
ij_kotlin_name_count_to_use_star_import=2147483647
|
||||||
|
ij_kotlin_name_count_to_use_star_import_for_members=2147483647
|
||||||
|
|
||||||
|
ktlint_standard_discouraged-comment-location=disabled
|
||||||
|
ktlint_standard_if-else-wrapping=disabled
|
||||||
|
ktlint_standard_no-consecutive-comments=disabled
|
||||||
+30
-5
@@ -1,6 +1,31 @@
|
|||||||
#
|
* text=auto
|
||||||
# https://help.github.com/articles/dealing-with-line-endings/
|
* text eol=lf
|
||||||
#
|
|
||||||
# These are explicitly windows files and should use crlf
|
|
||||||
*.bat text eol=crlf
|
|
||||||
|
|
||||||
|
# Windows forced line-endings
|
||||||
|
/.idea/* text eol=crlf
|
||||||
|
*.bat text eol=crlf
|
||||||
|
*.ps1 text eol=crlf
|
||||||
|
|
||||||
|
# Gradle wrapper
|
||||||
|
*.jar binary
|
||||||
|
|
||||||
|
# Binary files types
|
||||||
|
*.webp binary
|
||||||
|
*.png binary
|
||||||
|
*.jpg binary
|
||||||
|
*.jpeg binary
|
||||||
|
*.gif binary
|
||||||
|
*.ico binary
|
||||||
|
*.gz binary
|
||||||
|
*.zip binary
|
||||||
|
*.7z binary
|
||||||
|
*.ttf binary
|
||||||
|
*.eot binary
|
||||||
|
*.woff binary
|
||||||
|
*.pyc binary
|
||||||
|
*.swp binary
|
||||||
|
*.pdf binary
|
||||||
|
*.exe binary
|
||||||
|
*.avif binary
|
||||||
|
*.heif binary
|
||||||
|
*.jxl binary
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
name: 🐞 Bug report
|
||||||
|
description: Report a bug in Suwayomi-Server
|
||||||
|
labels: [bug]
|
||||||
|
body:
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: reproduce-steps
|
||||||
|
attributes:
|
||||||
|
label: Steps to reproduce
|
||||||
|
description: Provide an example of the issue.
|
||||||
|
placeholder: |
|
||||||
|
Example:
|
||||||
|
1. First step
|
||||||
|
2. Second step
|
||||||
|
3. Issue here
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: expected-behavior
|
||||||
|
attributes:
|
||||||
|
label: Expected behavior
|
||||||
|
description: Explain what you should expect to happen.
|
||||||
|
placeholder: |
|
||||||
|
Example: "This should happen..."
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: actual-behavior
|
||||||
|
attributes:
|
||||||
|
label: Actual behavior
|
||||||
|
description: Explain what actually happens.
|
||||||
|
placeholder: |
|
||||||
|
Example: "This happened instead..."
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: suwayomi-server-version
|
||||||
|
attributes:
|
||||||
|
label: Suwayomi-Server version
|
||||||
|
description: You can find your Suwayomi-Server version in **More → About**.
|
||||||
|
placeholder: |
|
||||||
|
Example: "v2.1.1867"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: server-os
|
||||||
|
attributes:
|
||||||
|
label: Server operating system
|
||||||
|
description: The operating system on which Suwayomi-Server is running on
|
||||||
|
placeholder: |
|
||||||
|
Example: "Windows 11 Pro 24H2 | Ubuntu 24.04.2 LTS"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: server-desktop-environment
|
||||||
|
attributes:
|
||||||
|
label: Server Desktop Environment
|
||||||
|
description:
|
||||||
|
placeholder: |
|
||||||
|
Example: "Gnome 40"
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: server-jvm-version
|
||||||
|
attributes:
|
||||||
|
label: Server JVM version
|
||||||
|
description: The java version used to run Suwayomi-Server
|
||||||
|
placeholder: |
|
||||||
|
Example: "openjdk 21.0.5 2024-10-15 LTS"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: client-name
|
||||||
|
attributes:
|
||||||
|
label: Used client name
|
||||||
|
description:
|
||||||
|
placeholder: |
|
||||||
|
Example: "Suwayomi-WebUI"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: client-version
|
||||||
|
attributes:
|
||||||
|
label: Client version
|
||||||
|
description:
|
||||||
|
placeholder: |
|
||||||
|
Example: "v1.2.3"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: client-browser
|
||||||
|
attributes:
|
||||||
|
label: Used web browser
|
||||||
|
description: The browser which is used to open Suwayomi-WebUI
|
||||||
|
placeholder: |
|
||||||
|
Example: "Chrome 134.0.6998.118 (64-Bit) | FireFox 136.0.2 (64-Bit) | Electron v35.0.2"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: client-os
|
||||||
|
attributes:
|
||||||
|
label: Client operating system
|
||||||
|
description: The system on which the Suwayomi-WebUI is running on
|
||||||
|
placeholder: |
|
||||||
|
Example: "Windows 11 Pro 24H2 | Ubuntu 24.04.2 LTS"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: other-details
|
||||||
|
attributes:
|
||||||
|
label: Other details
|
||||||
|
description: The more information that gets provided the better, especially via videos and images
|
||||||
|
placeholder: |
|
||||||
|
Additional details and attachments.
|
||||||
|
|
||||||
|
- type: checkboxes
|
||||||
|
id: acknowledgements
|
||||||
|
attributes:
|
||||||
|
label: Acknowledgements
|
||||||
|
description: Read this carefully, we will close and ignore your issue if you skimmed through this.
|
||||||
|
options:
|
||||||
|
- label: I have searched the existing issues and this is a new ticket, **NOT** a duplicate or related to another open or closed issue.
|
||||||
|
required: true
|
||||||
|
- label: I have written a short but informative title (ideally less than ~100 characters).
|
||||||
|
required: true
|
||||||
|
- label: I have tried the troubleshooting guide described in [README.md](https://github.com/Suwayomi/Suwayomi-Server?tab=readme-ov-file#troubleshooting-and-support)
|
||||||
|
required: true
|
||||||
|
- label: I have updated to the **[latest version](https://github.com/suwayomi/suwayomi-server/releases/latest)**.
|
||||||
|
required: true
|
||||||
|
- label: I have filled out all of the requested information in this form, including specific version numbers.
|
||||||
|
required: true
|
||||||
|
- label: I understand that **Suwayomi does not have or fix any extensions**, and I **will not receive help** for any issues related to sources or extensions.
|
||||||
|
required: true
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: ☎️ Support
|
||||||
|
url: https://discord.gg/DDZdqZWaHA
|
||||||
|
about: Join our discord to get help for anything that is not a bug or a feature request
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
name: 🌟 Feature request
|
||||||
|
description: Suggest a feature to improve Suwayomi-Server
|
||||||
|
labels: [enhancement]
|
||||||
|
body:
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: feature-description
|
||||||
|
attributes:
|
||||||
|
label: Describe your suggested feature
|
||||||
|
description: How can Suwayomi-Server be improved?
|
||||||
|
placeholder: |
|
||||||
|
Example:
|
||||||
|
"It should work like this..."
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: other-details
|
||||||
|
attributes:
|
||||||
|
label: Other details
|
||||||
|
placeholder: |
|
||||||
|
Additional details and attachments.
|
||||||
|
|
||||||
|
- type: checkboxes
|
||||||
|
id: acknowledgements
|
||||||
|
attributes:
|
||||||
|
label: Acknowledgements
|
||||||
|
description: Read this carefully, we will close and ignore your issue if you skimmed through this.
|
||||||
|
options:
|
||||||
|
- label: I have searched the existing issues and this is a new ticket, **NOT** a duplicate or related to another open or closed issue.
|
||||||
|
required: true
|
||||||
|
- label: I have written a short but informative title (ideally less than ~100 characters).
|
||||||
|
required: true
|
||||||
|
- label: I have updated to the **[latest version](https://github.com/suwayomi/suwayomi-server/releases/latest)**.
|
||||||
|
required: true
|
||||||
|
- label: I have filled out all of the requested information in this form, including specific version numbers.
|
||||||
|
required: true
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
cp ../master/repo/* .
|
|
||||||
new_build=$(ls | tail -1)
|
|
||||||
echo "New build file name: $new_build"
|
|
||||||
|
|
||||||
cp -f $new_build Tachidesk-latest.jar
|
|
||||||
|
|
||||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
||||||
git config --global user.name "github-actions[bot]"
|
|
||||||
git status
|
|
||||||
if [ -n "$(git status --porcelain)" ]; then
|
|
||||||
git add .
|
|
||||||
git commit -m "Update repo"
|
|
||||||
git push
|
|
||||||
else
|
|
||||||
echo "No changes to commit"
|
|
||||||
fi
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
|
|
||||||
mkdir -p repo/
|
|
||||||
|
|
||||||
# Get last commit message
|
|
||||||
last_commit_log=$(git log -1 --pretty=format:"%s")
|
|
||||||
echo "last commit log: $last_commit_log"
|
|
||||||
|
|
||||||
filter_count=$(echo "$last_commit_log" | grep -c "[RELEASE CI]" )
|
|
||||||
|
|
||||||
if [ "$filter_count" -gt 0 ]; then
|
|
||||||
cp server/build/Tachidesk-*.jar repo/
|
|
||||||
fi
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
name: CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check_wrapper:
|
|
||||||
name: Validate Gradle Wrapper
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Clone repo
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Validate Gradle Wrapper
|
|
||||||
uses: gradle/wrapper-validation-action@v1
|
|
||||||
|
|
||||||
build:
|
|
||||||
name: Build FatJar
|
|
||||||
needs: check_wrapper
|
|
||||||
if: "!startsWith(github.event.head_commit.message, '[SKIP CI]')"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Cancel previous runs
|
|
||||||
uses: styfle/cancel-workflow-action@0.5.0
|
|
||||||
with:
|
|
||||||
access_token: ${{ github.token }}
|
|
||||||
|
|
||||||
- name: Checkout master branch
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
ref: master
|
|
||||||
path: master
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up JDK 1.8
|
|
||||||
uses: actions/setup-java@v1
|
|
||||||
with:
|
|
||||||
java-version: 1.8
|
|
||||||
|
|
||||||
- name: Copy CI gradle.properties
|
|
||||||
run: |
|
|
||||||
cd master
|
|
||||||
mkdir -p ~/.gradle
|
|
||||||
cp .github/runner-files/ci-gradle.properties ~/.gradle/gradle.properties
|
|
||||||
|
|
||||||
- name: Download and process android.jar
|
|
||||||
if: github.event_name == 'push' && github.repository == 'AriaMoradi/Tachidesk'
|
|
||||||
run: |
|
|
||||||
cd master
|
|
||||||
./scripts/getAndroid.sh
|
|
||||||
|
|
||||||
- name: Build the Jar
|
|
||||||
uses: eskatos/gradle-command-action@v1
|
|
||||||
with:
|
|
||||||
build-root-directory: master
|
|
||||||
wrapper-directory: master
|
|
||||||
arguments: :server:shadowJar --stacktrace
|
|
||||||
wrapper-cache-enabled: true
|
|
||||||
dependencies-cache-enabled: true
|
|
||||||
configuration-cache-enabled: true
|
|
||||||
|
|
||||||
- name: Create repo artifacts
|
|
||||||
if: github.event_name == 'push' && github.repository == 'AriaMoradi/Tachidesk'
|
|
||||||
run: |
|
|
||||||
cd master
|
|
||||||
./.github/scripts/create-repo.sh
|
|
||||||
|
|
||||||
- name: Checkout repo branch
|
|
||||||
if: github.event_name == 'push' && github.repository == 'AriaMoradi/Tachidesk'
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
ref: repo
|
|
||||||
path: repo
|
|
||||||
|
|
||||||
- name: Deploy repo
|
|
||||||
if: github.event_name == 'push' && github.repository == 'AriaMoradi/Tachidesk'
|
|
||||||
run: |
|
|
||||||
cd repo
|
|
||||||
../master/.github/scripts/commit-repo.sh
|
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
name: CI Pull Request
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check_wrapper:
|
||||||
|
name: Validate Gradle Wrapper
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Clone repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Validate Gradle Wrapper
|
||||||
|
uses: gradle/actions/wrapper-validation@v4
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Build pull request
|
||||||
|
needs: check_wrapper
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout pull request
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
path: master
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set up JDK
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: 21
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: gradle/actions/setup-gradle@v4
|
||||||
|
|
||||||
|
- name: Copy CI gradle.properties
|
||||||
|
run: |
|
||||||
|
cd master
|
||||||
|
mkdir -p ~/.gradle
|
||||||
|
cp .github/runner-files/ci-gradle.properties ~/.gradle/gradle.properties
|
||||||
|
|
||||||
|
- name: Build Jar
|
||||||
|
working-directory: master
|
||||||
|
run: ./gradlew ktlintCheck :server:shadowJar --stacktrace
|
||||||
|
|
||||||
@@ -0,0 +1,249 @@
|
|||||||
|
name: CI build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check_wrapper:
|
||||||
|
name: Validate Gradle Wrapper
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Clone repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Validate Gradle Wrapper
|
||||||
|
uses: gradle/actions/wrapper-validation@v4
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Build Jar
|
||||||
|
needs: check_wrapper
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout master branch
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: master
|
||||||
|
path: master
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set up JDK
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: 21
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: gradle/actions/setup-gradle@v4
|
||||||
|
|
||||||
|
- name: Copy CI gradle.properties
|
||||||
|
run: |
|
||||||
|
cd master
|
||||||
|
mkdir -p ~/.gradle
|
||||||
|
cp .github/runner-files/ci-gradle.properties ~/.gradle/gradle.properties
|
||||||
|
|
||||||
|
- name: Build Jar
|
||||||
|
env:
|
||||||
|
ProductBuildType: "Preview"
|
||||||
|
working-directory: master
|
||||||
|
run: ./gradlew :server:shadowJar --stacktrace
|
||||||
|
|
||||||
|
- name: Upload Jar
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: jar
|
||||||
|
path: master/server/build/*.jar
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
- name: Upload icons
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: icon
|
||||||
|
path: master/server/src/main/resources/icon
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
- name: Tar scripts dir to maintain file permissions
|
||||||
|
run: tar -cvzf scripts.tar.gz -C master/ scripts/
|
||||||
|
|
||||||
|
- name: Upload scripts.tar.gz
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: scripts
|
||||||
|
path: scripts.tar.gz
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
jlink:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
name: linux-x64
|
||||||
|
- os: windows-latest
|
||||||
|
name: windows-x64
|
||||||
|
- os: macos-14
|
||||||
|
name: macOS-arm64
|
||||||
|
- os: macos-13
|
||||||
|
name: macOS-x64
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-14, macos-13]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Set up JDK
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: 21
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: Package JDK
|
||||||
|
run: jlink --add-modules java.base,java.compiler,java.datatransfer,java.desktop,java.instrument,java.logging,java.management,java.naming,java.prefs,java.scripting,java.se,java.security.jgss,java.security.sasl,java.sql,java.transaction.xa,java.xml,jdk.attach,jdk.crypto.ec,jdk.jdi,jdk.management,jdk.net,jdk.random,jdk.unsupported,jdk.unsupported.desktop,jdk.zipfs --output suwa --strip-debug --no-man-pages --no-header-files --compress=2
|
||||||
|
|
||||||
|
- name: Upload JRE package
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ matrix.name }}-jre
|
||||||
|
path: suwa
|
||||||
|
|
||||||
|
bundle:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- name: debian-all
|
||||||
|
jre: linux-x64
|
||||||
|
- name: appimage
|
||||||
|
jre: linux-x64
|
||||||
|
- name: linux-assets
|
||||||
|
jre: linux-assets
|
||||||
|
- name: linux-x64
|
||||||
|
jre: linux-x64
|
||||||
|
- name: macOS-x64
|
||||||
|
jre: macOS-x64
|
||||||
|
- name: macOS-arm64
|
||||||
|
jre: macOS-arm64
|
||||||
|
- name: windows-x64
|
||||||
|
jre: windows-x64
|
||||||
|
name: [debian-all, appimage, linux-assets, linux-x64, macOS-x64, macOS-arm64, windows-x64]
|
||||||
|
|
||||||
|
name: Make ${{ matrix.name }} release
|
||||||
|
needs: [build, jlink]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Download Jar
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: jar
|
||||||
|
path: server/build
|
||||||
|
|
||||||
|
- name: Download JRE
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
if: matrix.name != 'linux-assets' && matrix.name != 'debian-all'
|
||||||
|
with:
|
||||||
|
name: ${{ matrix.jre }}-jre
|
||||||
|
path: jre
|
||||||
|
|
||||||
|
- name: Download icons
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: icon
|
||||||
|
path: server/src/main/resources/icon
|
||||||
|
|
||||||
|
- name: Download scripts.tar.gz
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: scripts
|
||||||
|
|
||||||
|
- name: Make ${{ matrix.name }} release
|
||||||
|
run: |
|
||||||
|
mkdir upload
|
||||||
|
tar -xvpf scripts.tar.gz
|
||||||
|
scripts/bundler.sh -o upload/ ${{ matrix.name }}
|
||||||
|
|
||||||
|
- name: Upload ${{ matrix.name }} release
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ matrix.name }}
|
||||||
|
path: upload/*
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: bundle
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: jar
|
||||||
|
path: release
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: debian-all
|
||||||
|
path: release
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: appimage
|
||||||
|
path: release
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: linux-assets
|
||||||
|
path: release
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: linux-x64
|
||||||
|
path: release
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: macOS-x64
|
||||||
|
path: release
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: macOS-arm64
|
||||||
|
path: release
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: windows-x64
|
||||||
|
path: release
|
||||||
|
|
||||||
|
- name: Checkout Preview branch
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: "Suwayomi/Suwayomi-Server-preview"
|
||||||
|
ref: main
|
||||||
|
path: preview
|
||||||
|
token: ${{ secrets.DEPLOY_PREVIEW_TOKEN }}
|
||||||
|
|
||||||
|
- name: Generate Tag Name
|
||||||
|
id: GenTagName
|
||||||
|
run: |
|
||||||
|
cd release
|
||||||
|
genTag=$(ls *.jar | sed -e's/Suwayomi-Server-\|.jar//g')
|
||||||
|
echo "$genTag"
|
||||||
|
echo "value=$genTag" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Create Tag
|
||||||
|
run: |
|
||||||
|
TAG="${{ steps.GenTagName.outputs.value }}"
|
||||||
|
echo "tag: $TAG"
|
||||||
|
cd preview
|
||||||
|
echo "{ \"latest\": \"$TAG\" }" > index.json
|
||||||
|
git add index.json
|
||||||
|
git config --global user.email \
|
||||||
|
"github-actions[bot]@users.noreply.github.com"
|
||||||
|
git config --global user.name "github-actions[bot]"
|
||||||
|
git commit -m "Updated to $TAG"
|
||||||
|
git push origin main
|
||||||
|
|
||||||
|
git tag $TAG
|
||||||
|
git push origin $TAG
|
||||||
|
|
||||||
|
- name: Upload Preview Release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.DEPLOY_PREVIEW_TOKEN }}
|
||||||
|
repository: "Suwayomi/Suwayomi-Server-preview"
|
||||||
|
tag_name: ${{ steps.GenTagName.outputs.value }}
|
||||||
|
files: release/*
|
||||||
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
name: Docker Build Stable
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_publish_docker_container:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: run docker build and publish script
|
||||||
|
run: |
|
||||||
|
curl -X POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ secrets.DEPLOY_PREVIEW_TOKEN }}" -d '{"ref":"main", "inputs":{"tachidesk_release_type": "stable"}}' https://api.github.com/repos/suwayomi/docker-tachidesk/actions/workflows/build_container_images.yml/dispatches
|
||||||
|
|
||||||
@@ -0,0 +1,221 @@
|
|||||||
|
name: CI Publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check_wrapper:
|
||||||
|
name: Validate Gradle Wrapper
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Clone repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Validate Gradle Wrapper
|
||||||
|
uses: gradle/actions/wrapper-validation@v4
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Build Jar
|
||||||
|
needs: check_wrapper
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout ${{ github.ref }}
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ github.ref }}
|
||||||
|
path: master
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set up JDK
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: 21
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: gradle/actions/setup-gradle@v4
|
||||||
|
|
||||||
|
- name: Copy CI gradle.properties
|
||||||
|
run: |
|
||||||
|
cd master
|
||||||
|
mkdir -p ~/.gradle
|
||||||
|
cp .github/runner-files/ci-gradle.properties \
|
||||||
|
~/.gradle/gradle.properties
|
||||||
|
|
||||||
|
- name: Build and copy webUI, Build Jar
|
||||||
|
env:
|
||||||
|
ProductBuildType: "Stable"
|
||||||
|
working-directory: master
|
||||||
|
run: ./gradlew :server:downloadWebUI :server:shadowJar --stacktrace
|
||||||
|
|
||||||
|
- name: Upload Jar
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: jar
|
||||||
|
path: master/server/build/*.jar
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
- name: Upload icons
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: icon
|
||||||
|
path: master/server/src/main/resources/icon
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
- name: Tar scripts dir to maintain file permissions
|
||||||
|
run: tar -cvzf scripts.tar.gz -C master/ scripts/
|
||||||
|
|
||||||
|
- name: Upload scripts.tar.gz
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: scripts
|
||||||
|
path: scripts.tar.gz
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
jlink:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
name: linux-x64
|
||||||
|
- os: windows-latest
|
||||||
|
name: windows-x64
|
||||||
|
- os: macos-14
|
||||||
|
name: macOS-arm64
|
||||||
|
- os: macos-13
|
||||||
|
name: macOS-x64
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-14, macos-13]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Set up JDK
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: 21
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: Package JDK
|
||||||
|
run: jlink --add-modules java.base,java.compiler,java.datatransfer,java.desktop,java.instrument,java.logging,java.management,java.naming,java.prefs,java.scripting,java.se,java.security.jgss,java.security.sasl,java.sql,java.transaction.xa,java.xml,jdk.attach,jdk.crypto.ec,jdk.jdi,jdk.management,jdk.net,jdk.random,jdk.unsupported,jdk.unsupported.desktop,jdk.zipfs --output suwa --strip-debug --no-man-pages --no-header-files --compress=2
|
||||||
|
|
||||||
|
- name: Upload JDK package
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ matrix.name }}-jre
|
||||||
|
path: suwa
|
||||||
|
|
||||||
|
bundle:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- name: debian-all
|
||||||
|
jre: linux-x64
|
||||||
|
- name: appimage
|
||||||
|
jre: linux-x64
|
||||||
|
- name: linux-assets
|
||||||
|
jre: linux-assets
|
||||||
|
- name: linux-x64
|
||||||
|
jre: linux-x64
|
||||||
|
- name: macOS-x64
|
||||||
|
jre: macOS-x64
|
||||||
|
- name: macOS-arm64
|
||||||
|
jre: macOS-arm64
|
||||||
|
- name: windows-x64
|
||||||
|
jre: windows-x64
|
||||||
|
name: [debian-all, appimage, linux-assets, linux-x64, macOS-x64, macOS-arm64, windows-x64]
|
||||||
|
|
||||||
|
name: Make ${{ matrix.name }} release
|
||||||
|
needs: [build, jlink]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Download Jar
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: jar
|
||||||
|
path: server/build
|
||||||
|
|
||||||
|
- name: Download JRE
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
if: matrix.name != 'linux-assets' && matrix.name != 'debian-all'
|
||||||
|
with:
|
||||||
|
name: ${{ matrix.jre }}-jre
|
||||||
|
path: jre
|
||||||
|
|
||||||
|
- name: Download icons
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: icon
|
||||||
|
path: server/src/main/resources/icon
|
||||||
|
|
||||||
|
- name: Download scripts.tar.gz
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: scripts
|
||||||
|
|
||||||
|
- name: Make ${{ matrix.name }} release
|
||||||
|
run: |
|
||||||
|
mkdir upload/
|
||||||
|
tar -xvpf scripts.tar.gz
|
||||||
|
scripts/bundler.sh -o upload/ ${{ matrix.name }}
|
||||||
|
|
||||||
|
- name: Upload ${{ matrix.name }} files
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ matrix.name }}
|
||||||
|
path: upload/*
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
release:
|
||||||
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
|
needs: bundle
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: jar
|
||||||
|
path: release
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: debian-all
|
||||||
|
path: release
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: appimage
|
||||||
|
path: release
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: linux-assets
|
||||||
|
path: release
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: linux-x64
|
||||||
|
path: release
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: macOS-x64
|
||||||
|
path: release
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: macOS-arm64
|
||||||
|
path: release
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: windows-x64
|
||||||
|
path: release
|
||||||
|
|
||||||
|
- name: Generate checksums
|
||||||
|
run: cd release && sha256sum * > Checksums.sha256
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.DEPLOY_RELEASE_TOKEN }}
|
||||||
|
draft: true
|
||||||
|
files: release/*
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
name: Publish to WinGet
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: Version
|
||||||
|
required: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: windows-latest # action can only be run on windows
|
||||||
|
steps:
|
||||||
|
- uses: vedantmgoyal2009/winget-releaser@v2
|
||||||
|
with:
|
||||||
|
identifier: Suwayomi.Suwayomi-Server
|
||||||
|
installers-regex: '.*x64.msi$'
|
||||||
|
token: ${{ secrets.WINGET_PUBLISH_PAT }}
|
||||||
|
version: ${{ inputs.version || github.ref_name }}
|
||||||
|
release-tag: ${{ inputs.version || github.ref_name }}
|
||||||
+17
-2
@@ -1,8 +1,23 @@
|
|||||||
# Ignore Gradle project-specific cache directory
|
# Ignore project-specific local files and dirs
|
||||||
.gradle
|
.gradle
|
||||||
.idea
|
.idea
|
||||||
|
gradle.properties
|
||||||
|
.fleet
|
||||||
|
# But we need these
|
||||||
|
!.idea/runConfigurations
|
||||||
|
.kotlin
|
||||||
|
|
||||||
# Ignore Gradle build output directory
|
# Ignore Gradle build output directory
|
||||||
build
|
build
|
||||||
|
server/out
|
||||||
|
AndroidCompat/out
|
||||||
|
|
||||||
server/src/main/resources/react
|
# WebUI is either to be downloaded on-demand or is a dynamic build asset
|
||||||
|
server/src/main/resources/WebUI.zip
|
||||||
|
|
||||||
|
# bundling stage downlaoded assets
|
||||||
|
scripts/OpenJDK*
|
||||||
|
scripts/zulu*
|
||||||
|
scripts/electron-*
|
||||||
|
scripts/rcedit-*
|
||||||
|
scripts/resources/*.so
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
dependencies {
|
|
||||||
// Config API
|
|
||||||
// implementation("com.typesafe:config:1.4.0")
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
plugins {
|
||||||
|
id(
|
||||||
|
libs.plugins.kotlin.jvm
|
||||||
|
.get()
|
||||||
|
.pluginId,
|
||||||
|
)
|
||||||
|
id(
|
||||||
|
libs.plugins.kotlin.serialization
|
||||||
|
.get()
|
||||||
|
.pluginId,
|
||||||
|
)
|
||||||
|
id(
|
||||||
|
libs.plugins.ktlint
|
||||||
|
.get()
|
||||||
|
.pluginId,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// Shared
|
||||||
|
implementation(libs.bundles.shared)
|
||||||
|
testImplementation(libs.bundles.sharedTest)
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package xyz.nulldev.ts.config
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import ca.gosyer.appdirs.AppDirs
|
||||||
|
|
||||||
|
const val CONFIG_PREFIX = "suwayomi.tachidesk.config"
|
||||||
|
|
||||||
|
val ApplicationRootDir: String
|
||||||
|
get(): String {
|
||||||
|
return System.getProperty(
|
||||||
|
"$CONFIG_PREFIX.server.rootDir",
|
||||||
|
AppDirs { appName = "Tachidesk" }.getUserDataDir(),
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package xyz.nulldev.ts.config
|
|
||||||
|
|
||||||
import org.kodein.di.DI
|
|
||||||
import org.kodein.di.bind
|
|
||||||
import org.kodein.di.singleton
|
|
||||||
|
|
||||||
class ConfigKodeinModule {
|
|
||||||
fun create() = DI.Module("ConfigManager") {
|
|
||||||
//Config module
|
|
||||||
bind<ConfigManager>() with singleton { GlobalConfigManager }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,67 +1,95 @@
|
|||||||
package xyz.nulldev.ts.config
|
package xyz.nulldev.ts.config
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import ch.qos.logback.classic.Level
|
||||||
import com.typesafe.config.Config
|
import com.typesafe.config.Config
|
||||||
import com.typesafe.config.ConfigFactory
|
import com.typesafe.config.ConfigFactory
|
||||||
import com.typesafe.config.ConfigRenderOptions
|
import com.typesafe.config.ConfigObject
|
||||||
import mu.KotlinLogging
|
import com.typesafe.config.ConfigValue
|
||||||
|
import com.typesafe.config.parser.ConfigDocument
|
||||||
|
import com.typesafe.config.parser.ConfigDocumentFactory
|
||||||
|
import io.github.config4k.toConfig
|
||||||
|
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||||
|
import kotlinx.coroutines.sync.Mutex
|
||||||
|
import kotlinx.coroutines.sync.withLock
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages app config.
|
* Manages app config.
|
||||||
*/
|
*/
|
||||||
open class ConfigManager {
|
open class ConfigManager {
|
||||||
private val generatedModules
|
val logger = KotlinLogging.logger {}
|
||||||
= mutableMapOf<Class<out ConfigModule>, ConfigModule>()
|
private val generatedModules = mutableMapOf<Class<out ConfigModule>, ConfigModule>()
|
||||||
val config by lazy { loadConfigs() }
|
private val userConfigFile = File(ApplicationRootDir, "server.conf")
|
||||||
|
private var internalConfig = loadConfigs()
|
||||||
|
val config: Config
|
||||||
|
get() = internalConfig
|
||||||
|
|
||||||
//Public read-only view of modules
|
// Public read-only view of modules
|
||||||
val loadedModules: Map<Class<out ConfigModule>, ConfigModule>
|
val loadedModules: Map<Class<out ConfigModule>, ConfigModule>
|
||||||
get() = generatedModules
|
get() = generatedModules
|
||||||
|
|
||||||
open val configFolder: String
|
private val mutex = Mutex()
|
||||||
get() = System.getProperty("compat-configdirs") ?: "tachiserver-data/config"
|
|
||||||
|
|
||||||
val logger = KotlinLogging.logger {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a config module
|
* Get a config module
|
||||||
*/
|
*/
|
||||||
inline fun <reified T : ConfigModule> module(): T
|
inline fun <reified T : ConfigModule> module(): T = loadedModules[T::class.java] as T
|
||||||
= loadedModules[T::class.java] as T
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a config module (Java API)
|
* Get a config module (Java API)
|
||||||
*/
|
*/
|
||||||
fun <T : ConfigModule> module(type: Class<T>): T
|
@Suppress("UNCHECKED_CAST")
|
||||||
= loadedModules[type] as T
|
fun <T : ConfigModule> module(type: Class<T>): T = loadedModules[type] as T
|
||||||
|
|
||||||
|
private fun getUserConfig(): Config =
|
||||||
|
userConfigFile.let {
|
||||||
|
ConfigFactory.parseFile(it)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load configs
|
* Load configs
|
||||||
*/
|
*/
|
||||||
fun loadConfigs(): Config {
|
fun loadConfigs(): Config {
|
||||||
val configs = mutableListOf<Config>()
|
// Load reference configs
|
||||||
|
val compatConfig = ConfigFactory.parseResources("compat-reference.conf")
|
||||||
|
val serverConfig = ConfigFactory.parseResources("server-reference.conf")
|
||||||
|
val baseConfig =
|
||||||
|
ConfigFactory.parseMap(
|
||||||
|
mapOf(
|
||||||
|
// override AndroidCompat's rootDir
|
||||||
|
"androidcompat.rootDir" to "$ApplicationRootDir/android-compat",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
//Load reference config
|
// Load user config
|
||||||
configs += ConfigFactory.parseResources("reference.conf")
|
val userConfig = getUserConfig()
|
||||||
|
|
||||||
//Load custom configs from dir
|
val config =
|
||||||
File(configFolder).listFiles()?.map {
|
ConfigFactory
|
||||||
ConfigFactory.parseFile(it)
|
.empty()
|
||||||
}?.filterNotNull()?.forEach {
|
.withFallback(baseConfig)
|
||||||
configs += it.withFallback(configs.last())
|
.withFallback(userConfig)
|
||||||
}
|
.withFallback(compatConfig)
|
||||||
|
.withFallback(serverConfig)
|
||||||
|
.resolve()
|
||||||
|
|
||||||
val config = configs.last().resolve()
|
// set log level early
|
||||||
|
if (debugLogsEnabled(config)) {
|
||||||
logger.debug {
|
setLogLevelFor(BASE_LOGGER_NAME, Level.DEBUG)
|
||||||
"Loaded config:\n" + config.root().render(ConfigRenderOptions.concise().setFormatted(true))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
fun registerModule(module: ConfigModule) {
|
fun registerModule(module: ConfigModule) {
|
||||||
generatedModules.put(module.javaClass, module)
|
generatedModules[module.javaClass] = module
|
||||||
}
|
}
|
||||||
|
|
||||||
fun registerModules(vararg modules: ConfigModule) {
|
fun registerModules(vararg modules: ConfigModule) {
|
||||||
@@ -69,6 +97,84 @@ open class ConfigManager {
|
|||||||
registerModule(it)
|
registerModule(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateUserConfigFile(
|
||||||
|
path: String,
|
||||||
|
value: ConfigValue,
|
||||||
|
) {
|
||||||
|
val userConfigDoc = ConfigDocumentFactory.parseFile(userConfigFile)
|
||||||
|
val updatedConfigDoc = userConfigDoc.withValue(path, value)
|
||||||
|
val newFileContent = updatedConfigDoc.render()
|
||||||
|
userConfigFile.writeText(newFileContent)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun updateValue(
|
||||||
|
path: String,
|
||||||
|
value: Any,
|
||||||
|
) {
|
||||||
|
mutex.withLock {
|
||||||
|
val actualValue = if (value is Enum<*>) value.name else value
|
||||||
|
val configValue = actualValue.toConfig("internal").getValue("internal")
|
||||||
|
|
||||||
|
updateUserConfigFile(path, configValue)
|
||||||
|
internalConfig = internalConfig.withValue(path, configValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun resetUserConfig(updateInternalConfig: Boolean = true): ConfigDocument {
|
||||||
|
val serverConfigFileContent = this::class.java.getResource("/server-reference.conf")?.readText()
|
||||||
|
val serverConfigDoc = ConfigDocumentFactory.parseString(serverConfigFileContent)
|
||||||
|
userConfigFile.writeText(serverConfigDoc.render())
|
||||||
|
|
||||||
|
if (updateInternalConfig) {
|
||||||
|
getUserConfig().entrySet().forEach { internalConfig = internalConfig.withValue(it.key, it.value) }
|
||||||
|
}
|
||||||
|
|
||||||
|
return serverConfigDoc
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes sure the "UserConfig" is up-to-date.
|
||||||
|
*
|
||||||
|
* - adds missing settings
|
||||||
|
* - removes outdated settings
|
||||||
|
*/
|
||||||
|
fun updateUserConfig(migrate: ConfigDocument.(Config) -> ConfigDocument) {
|
||||||
|
val serverConfig = ConfigFactory.parseResources("server-reference.conf")
|
||||||
|
val userConfig = getUserConfig()
|
||||||
|
|
||||||
|
// NOTE: if more than 1 dot is included, that's a nested setting, which we need to filter out here
|
||||||
|
val refKeys =
|
||||||
|
serverConfig.root().entries.flatMap {
|
||||||
|
(it.value as? ConfigObject)?.entries?.map { e -> "${it.key}.${e.key}" }.orEmpty()
|
||||||
|
}
|
||||||
|
val hasMissingSettings = refKeys.any { !userConfig.hasPath(it) }
|
||||||
|
val hasOutdatedSettings = userConfig.entrySet().any { !refKeys.contains(it.key) && it.key.count { c -> c == '.' } <= 1 }
|
||||||
|
val isUserConfigOutdated = hasMissingSettings || hasOutdatedSettings
|
||||||
|
if (!isUserConfigOutdated) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug {
|
||||||
|
"user config is out of date, updating... (missingSettings= $hasMissingSettings, outdatedSettings= $hasOutdatedSettings"
|
||||||
|
}
|
||||||
|
|
||||||
|
var newUserConfigDoc: ConfigDocument = resetUserConfig(false)
|
||||||
|
userConfig
|
||||||
|
.entrySet()
|
||||||
|
.filter {
|
||||||
|
serverConfig.hasPath(
|
||||||
|
it.key,
|
||||||
|
) ||
|
||||||
|
it.key.count { c -> c == '.' } > 1
|
||||||
|
}.forEach { newUserConfigDoc = newUserConfigDoc.withValue(it.key, it.value) }
|
||||||
|
|
||||||
|
newUserConfigDoc =
|
||||||
|
migrate(newUserConfigDoc, internalConfig)
|
||||||
|
|
||||||
|
userConfigFile.writeText(newUserConfigDoc.render())
|
||||||
|
getUserConfig().entrySet().forEach { internalConfig = internalConfig.withValue(it.key, it.value) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object GlobalConfigManager : ConfigManager()
|
object GlobalConfigManager : ConfigManager()
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package xyz.nulldev.ts.config
|
||||||
|
|
||||||
|
import org.koin.core.module.Module
|
||||||
|
import org.koin.dsl.module
|
||||||
|
|
||||||
|
fun configManagerModule(): Module =
|
||||||
|
module {
|
||||||
|
single<ConfigManager> { GlobalConfigManager }
|
||||||
|
}
|
||||||
@@ -1,8 +1,76 @@
|
|||||||
package xyz.nulldev.ts.config
|
package xyz.nulldev.ts.config
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
import com.typesafe.config.Config
|
import com.typesafe.config.Config
|
||||||
|
import com.typesafe.config.ConfigException
|
||||||
|
import com.typesafe.config.ConfigFactory
|
||||||
|
import io.github.config4k.ClassContainer
|
||||||
|
import io.github.config4k.TypeReference
|
||||||
|
import io.github.config4k.getValue
|
||||||
|
import io.github.config4k.readers.SelectReader
|
||||||
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract config module.
|
* Abstract config module.
|
||||||
*/
|
*/
|
||||||
abstract class ConfigModule(config: Config)
|
@Suppress("UNUSED_PARAMETER")
|
||||||
|
abstract class ConfigModule(
|
||||||
|
getConfig: () -> Config,
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract jvm-commandline-argument-overridable config module.
|
||||||
|
*/
|
||||||
|
abstract class SystemPropertyOverridableConfigModule(
|
||||||
|
getConfig: () -> Config,
|
||||||
|
val moduleName: String,
|
||||||
|
) : ConfigModule(getConfig) {
|
||||||
|
val overridableConfig = SystemPropertyOverrideDelegate(getConfig, moduleName)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Defines a config property that is overridable with jvm `-D` commandline arguments prefixed with [CONFIG_PREFIX] */
|
||||||
|
class SystemPropertyOverrideDelegate(
|
||||||
|
val getConfig: () -> Config,
|
||||||
|
val moduleName: String,
|
||||||
|
) {
|
||||||
|
inline operator fun <R, reified T> getValue(
|
||||||
|
thisRef: R,
|
||||||
|
property: KProperty<*>,
|
||||||
|
): T {
|
||||||
|
val config = getConfig()
|
||||||
|
|
||||||
|
val systemProperty =
|
||||||
|
System.getProperty("$CONFIG_PREFIX.$moduleName.${property.name}")
|
||||||
|
if (systemProperty == null) {
|
||||||
|
val configValue: T = config.getValue(thisRef, property)
|
||||||
|
return configValue
|
||||||
|
}
|
||||||
|
|
||||||
|
val systemPropertyConfig =
|
||||||
|
try {
|
||||||
|
ConfigFactory.parseString("internal=$systemProperty")
|
||||||
|
} catch (_: ConfigException) {
|
||||||
|
ConfigFactory.parseMap(mapOf("internal" to systemProperty))
|
||||||
|
}
|
||||||
|
|
||||||
|
val genericType = object : TypeReference<T>() {}.genericType()
|
||||||
|
val clazz = ClassContainer(T::class, genericType)
|
||||||
|
val reader = SelectReader.getReader(clazz)
|
||||||
|
val path = property.name
|
||||||
|
|
||||||
|
val result = reader(systemPropertyConfig, "internal")
|
||||||
|
return try {
|
||||||
|
result as T
|
||||||
|
} catch (e: Exception) {
|
||||||
|
throw result
|
||||||
|
?.let { e }
|
||||||
|
?: ConfigException.BadPath(path, "take a look at your config")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,139 @@
|
|||||||
|
package xyz.nulldev.ts.config
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import ch.qos.logback.classic.Level
|
||||||
|
import ch.qos.logback.classic.LoggerContext
|
||||||
|
import ch.qos.logback.classic.encoder.PatternLayoutEncoder
|
||||||
|
import ch.qos.logback.classic.spi.ILoggingEvent
|
||||||
|
import ch.qos.logback.core.rolling.RollingFileAppender
|
||||||
|
import ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy
|
||||||
|
import ch.qos.logback.core.util.FileSize
|
||||||
|
import com.typesafe.config.Config
|
||||||
|
import io.github.oshai.kotlinlogging.DelegatingKLogger
|
||||||
|
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||||
|
import org.slf4j.Logger
|
||||||
|
import org.slf4j.LoggerFactory
|
||||||
|
|
||||||
|
private fun fileSizeValueOfOrDefault(
|
||||||
|
fileSizeStr: String,
|
||||||
|
default: String,
|
||||||
|
): FileSize =
|
||||||
|
try {
|
||||||
|
FileSize.valueOf(fileSizeStr)
|
||||||
|
} catch (e: IllegalArgumentException) {
|
||||||
|
FileSize.valueOf(default)
|
||||||
|
}
|
||||||
|
|
||||||
|
private const val FILE_APPENDER_NAME = "SuwayomiDefaultAppender"
|
||||||
|
|
||||||
|
private fun createRollingFileAppender(
|
||||||
|
logContext: LoggerContext,
|
||||||
|
logDirPath: String,
|
||||||
|
maxFiles: Int,
|
||||||
|
maxFileSize: String,
|
||||||
|
maxTotalSize: String,
|
||||||
|
): RollingFileAppender<ILoggingEvent> {
|
||||||
|
val logFilename = "application"
|
||||||
|
|
||||||
|
val logEncoder =
|
||||||
|
PatternLayoutEncoder().apply {
|
||||||
|
pattern = "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n"
|
||||||
|
context = logContext
|
||||||
|
start()
|
||||||
|
}
|
||||||
|
|
||||||
|
val appender =
|
||||||
|
RollingFileAppender<ILoggingEvent>().apply {
|
||||||
|
name = FILE_APPENDER_NAME
|
||||||
|
context = logContext
|
||||||
|
encoder = logEncoder
|
||||||
|
file = "$logDirPath/$logFilename.log"
|
||||||
|
}
|
||||||
|
|
||||||
|
val rollingPolicy =
|
||||||
|
SizeAndTimeBasedRollingPolicy<ILoggingEvent>().apply {
|
||||||
|
context = logContext
|
||||||
|
setParent(appender)
|
||||||
|
fileNamePattern = "$logDirPath/${logFilename}_%d{yyyy-MM-dd}_%i.log.gz"
|
||||||
|
maxHistory = maxFiles.coerceAtLeast(0)
|
||||||
|
setMaxFileSize(fileSizeValueOfOrDefault(maxFileSize, "10mb"))
|
||||||
|
setTotalSizeCap(fileSizeValueOfOrDefault(maxTotalSize, "100mb"))
|
||||||
|
start()
|
||||||
|
}
|
||||||
|
|
||||||
|
appender.rollingPolicy = rollingPolicy
|
||||||
|
appender.start()
|
||||||
|
|
||||||
|
return appender
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getBaseLogger(): ch.qos.logback.classic.Logger =
|
||||||
|
((KotlinLogging.logger(Logger.ROOT_LOGGER_NAME) as DelegatingKLogger<*>).underlyingLogger as ch.qos.logback.classic.Logger)
|
||||||
|
|
||||||
|
private fun getLogger(name: String): ch.qos.logback.classic.Logger {
|
||||||
|
val context = LoggerFactory.getILoggerFactory() as LoggerContext
|
||||||
|
return context.getLogger(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun initLoggerConfig(
|
||||||
|
appRootPath: String,
|
||||||
|
maxFiles: Int,
|
||||||
|
maxFileSize: String,
|
||||||
|
maxTotalSize: String,
|
||||||
|
) {
|
||||||
|
val context = LoggerFactory.getILoggerFactory() as LoggerContext
|
||||||
|
val logger = getBaseLogger()
|
||||||
|
|
||||||
|
// logback logs to the console by default (at least when adding a console appender logs in the console are duplicated)
|
||||||
|
logger.addAppender(createRollingFileAppender(context, "$appRootPath/logs", maxFiles, maxFileSize, maxTotalSize))
|
||||||
|
|
||||||
|
// set "kotlin exposed" log level
|
||||||
|
setLogLevelFor("Exposed", Level.ERROR)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateFileAppender(
|
||||||
|
maxFiles: Int,
|
||||||
|
maxFileSize: String,
|
||||||
|
maxTotalSize: String,
|
||||||
|
) {
|
||||||
|
val logger = getBaseLogger()
|
||||||
|
|
||||||
|
val appender = logger.getAppender(FILE_APPENDER_NAME) as RollingFileAppender<*>? ?: return
|
||||||
|
val rollingPolicy = appender.rollingPolicy as SizeAndTimeBasedRollingPolicy<*>
|
||||||
|
rollingPolicy.apply {
|
||||||
|
maxHistory = maxFiles
|
||||||
|
setMaxFileSize(FileSize.valueOf(maxFileSize))
|
||||||
|
setTotalSizeCap(FileSize.valueOf(maxTotalSize))
|
||||||
|
|
||||||
|
rollingPolicy.stop()
|
||||||
|
appender.stop()
|
||||||
|
|
||||||
|
rollingPolicy.start()
|
||||||
|
appender.start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const val BASE_LOGGER_NAME = "_BaseLogger"
|
||||||
|
|
||||||
|
fun setLogLevelFor(
|
||||||
|
name: String,
|
||||||
|
level: Level,
|
||||||
|
) {
|
||||||
|
val logger =
|
||||||
|
if (name == BASE_LOGGER_NAME) {
|
||||||
|
getBaseLogger()
|
||||||
|
} else {
|
||||||
|
getLogger(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.level = level
|
||||||
|
}
|
||||||
|
|
||||||
|
fun debugLogsEnabled(config: Config) =
|
||||||
|
System.getProperty("suwayomi.tachidesk.config.server.debugLogsEnabled", config.getString("server.debugLogsEnabled")).toBoolean()
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package xyz.nulldev.ts.config
|
|
||||||
|
|
||||||
import com.typesafe.config.Config
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
class ServerConfig(config: Config) : ConfigModule(config) {
|
|
||||||
val ip = config.getString("ip")
|
|
||||||
val port = config.getInt("port")
|
|
||||||
|
|
||||||
val allowConfigChanges = config.getBoolean("allowConfigChanges")
|
|
||||||
val enableWebUi = config.getBoolean("enableWebUi")
|
|
||||||
val useOldWebUi = config.getBoolean("useOldWebUi")
|
|
||||||
val prettyPrintApi = config.getBoolean("prettyPrintApi")
|
|
||||||
// TODO Apply to operation IDs
|
|
||||||
val disabledApiEndpoints = config.getStringList("disabledApiEndpoints").map(String::toLowerCase)
|
|
||||||
val enabledApiEndpoints = config.getStringList("enabledApiEndpoints").map(String::toLowerCase)
|
|
||||||
val httpInitializedPrintMessage = config.getString("httpInitializedPrintMessage")
|
|
||||||
|
|
||||||
val useExternalStaticFiles = config.getBoolean("useExternalStaticFiles")
|
|
||||||
val externalStaticFilesFolder = config.getString("externalStaticFilesFolder")
|
|
||||||
|
|
||||||
val rootDir = registerFile(config.getString("rootDir"))
|
|
||||||
val patchesDir = registerFile(config.getString("patchesDir"))
|
|
||||||
|
|
||||||
fun registerFile(file: String): File {
|
|
||||||
return File(file).apply {
|
|
||||||
mkdirs()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
fun register(config: Config)
|
|
||||||
= ServerConfig(config.getConfig("ts.server"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,5 +2,6 @@ package xyz.nulldev.ts.config.util
|
|||||||
|
|
||||||
import com.typesafe.config.Config
|
import com.typesafe.config.Config
|
||||||
|
|
||||||
operator fun Config.get(key: String) = getString(key)
|
operator fun Config.get(key: String) =
|
||||||
|
getString(key)
|
||||||
?: throw IllegalStateException("Could not find value for config entry: $key!")
|
?: throw IllegalStateException("Could not find value for config entry: $key!")
|
||||||
|
|||||||
-1
@@ -1 +0,0 @@
|
|||||||
xyz.nulldev.ts.api.v2.java.impl.ServerAPIImpl
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.9 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB |
File diff suppressed because one or more lines are too long
@@ -1,22 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"label": "Sync",
|
|
||||||
"icon": "import_export",
|
|
||||||
"type": "nested",
|
|
||||||
"prefs": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Server",
|
|
||||||
"icon": "dns",
|
|
||||||
"type": "nested",
|
|
||||||
"prefs": [
|
|
||||||
{
|
|
||||||
"label": "Password authentication",
|
|
||||||
"type": "text-password",
|
|
||||||
"default": "",
|
|
||||||
"key": "pref_ts_server_password",
|
|
||||||
"hint": "Enter a password"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
# Server ip and port bindings
|
|
||||||
ts.server.ip = 0.0.0.0
|
|
||||||
ts.server.port = 4567
|
|
||||||
|
|
||||||
# Allow/disallow preference changes (useful for demos)
|
|
||||||
ts.server.allowConfigChanges = true
|
|
||||||
|
|
||||||
# Enable the WebUI? Note: The API and multi-user sync server ui will remain available even if the WebUI is disabled
|
|
||||||
ts.server.enableWebUi = true
|
|
||||||
|
|
||||||
# 'true' to use the old, buggy/memory-leaking WebUI
|
|
||||||
ts.server.useOldWebUi = false
|
|
||||||
|
|
||||||
# 'true' to pretty print all JSON API responses
|
|
||||||
ts.server.prettyPrintApi = false
|
|
||||||
|
|
||||||
# List of blacklisted/whitelisted API endpoints/operation IDs
|
|
||||||
ts.server.disabledApiEndpoints = []
|
|
||||||
ts.server.enabledApiEndpoints = []
|
|
||||||
|
|
||||||
# Message to print in the console when the API has finished booting
|
|
||||||
ts.server.httpInitializedPrintMessage = ""
|
|
||||||
|
|
||||||
# Use external folder for static files
|
|
||||||
ts.server.useExternalStaticFiles = false
|
|
||||||
ts.server.externalStaticFilesFolder = ""
|
|
||||||
|
|
||||||
# Root storage dir
|
|
||||||
ts.server.rootDir = tachiserver-data
|
|
||||||
# Dir to store JVM patches
|
|
||||||
ts.server.patchesDir = ${ts.server.rootDir}/patches
|
|
||||||
|
|
||||||
# Storage dir for the emulated Android app
|
|
||||||
android.files.rootDir = ${ts.server.rootDir}/android-compat/appdata
|
|
||||||
# External storage dir for the emulated Android app's
|
|
||||||
android.files.externalStorageDir = ${ts.server.rootDir}/android-compat/extappdata
|
|
||||||
|
|
||||||
# Internal Android directories
|
|
||||||
android.files.dataDir = ${android.files.rootDir}/data
|
|
||||||
android.files.filesDir = ${android.files.rootDir}/files
|
|
||||||
android.files.cacheDir = ${android.files.rootDir}/cache
|
|
||||||
android.files.codeCacheDir = ${android.files.rootDir}/code_cache
|
|
||||||
android.files.noBackupFilesDir = ${android.files.rootDir}/no_backup
|
|
||||||
android.files.databasesDir = ${android.files.rootDir}/databases
|
|
||||||
android.files.prefsDir = ${android.files.rootDir}/shared_prefs
|
|
||||||
|
|
||||||
# External Android directories
|
|
||||||
android.files.externalFilesDirs = [${android.files.externalStorageDir}/files]
|
|
||||||
android.files.obbDirs = [${android.files.externalStorageDir}/obb]
|
|
||||||
android.files.externalCacheDirs = [${android.files.externalStorageDir}/cache]
|
|
||||||
android.files.externalMediaDirs = [${android.files.externalStorageDir}/media]
|
|
||||||
android.files.downloadCacheDir = ${android.files.externalStorageDir}/downloadCache
|
|
||||||
|
|
||||||
android.files.packageDir = ${ts.server.rootDir}/android-compat/packages
|
|
||||||
|
|
||||||
# Emulated Android app package name
|
|
||||||
android.app.packageName = eu.kanade.tachiyomi
|
|
||||||
# Debug mode for the emulated Android app
|
|
||||||
android.app.debug = true
|
|
||||||
|
|
||||||
# Whether or not the emulated Android system is debuggable
|
|
||||||
android.system.isDebuggable = true
|
|
||||||
|
|
||||||
# Is the multi-user sync server enabled? Does not affect the single-user sync server included in the API.
|
|
||||||
ts.syncd.enable = false
|
|
||||||
|
|
||||||
# The URL of this server (displayed in the sync server web ui)
|
|
||||||
ts.syncd.baseUrl = "http://example.com"
|
|
||||||
|
|
||||||
# 'true' to disable the API and only enable the multi-user sync server
|
|
||||||
ts.syncd.syncOnlyMode = false
|
|
||||||
|
|
||||||
# The root directory to store synchronized data
|
|
||||||
ts.syncd.rootDir = ${ts.server.rootDir}/sync/accounts
|
|
||||||
|
|
||||||
# Location to store config files for the sandbox
|
|
||||||
ts.syncd.sandboxedConfig = ${ts.server.rootDir}/sync/sandboxed_config.config
|
|
||||||
|
|
||||||
# Recaptcha stuff for signup/login
|
|
||||||
ts.syncd.recaptcha.siteKey = ""
|
|
||||||
ts.syncd.recaptcha.secret = ""
|
|
||||||
|
|
||||||
# Sync server display name
|
|
||||||
ts.syncd.name = "Tachiyomi sync server"
|
|
||||||
|
|
||||||
# Header used to forward the IP to the multi-user sync server if the server is behind a reverse proxy
|
|
||||||
ts.syncd.ipHeader = ""
|
|
||||||
@@ -1,72 +1,51 @@
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
application
|
id(
|
||||||
}
|
libs.plugins.kotlin.jvm
|
||||||
|
.get()
|
||||||
|
.pluginId,
|
||||||
repositories {
|
)
|
||||||
mavenCentral()
|
id(
|
||||||
jcenter()
|
libs.plugins.kotlin.serialization
|
||||||
maven {
|
.get()
|
||||||
url = uri("https://jitpack.io")
|
.pluginId,
|
||||||
}
|
)
|
||||||
|
id(
|
||||||
maven {
|
libs.plugins.ktlint
|
||||||
url = uri("https://maven.google.com")
|
.get()
|
||||||
}
|
.pluginId,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
// Shared
|
||||||
|
implementation(libs.bundles.shared)
|
||||||
|
testImplementation(libs.bundles.sharedTest)
|
||||||
|
|
||||||
// Android stub library
|
// Android stub library
|
||||||
// compileOnly( fileTree(File(rootProject.rootDir, "libs/android"), include: "*.jar")
|
implementation(libs.android.stubs)
|
||||||
implementation(fileTree("lib/"))
|
|
||||||
implementation(fileTree("${rootProject.rootDir}/server/lib/dex2jar/"))
|
|
||||||
|
|
||||||
|
|
||||||
// Android JAR libs
|
|
||||||
// compileOnly( fileTree(dir: new File(rootProject.rootDir, "libs/other"), include: "*.jar")
|
|
||||||
|
|
||||||
// JSON
|
|
||||||
compileOnly( "com.google.code.gson:gson:2.8.6")
|
|
||||||
|
|
||||||
// Javassist
|
|
||||||
compileOnly( "org.javassist:javassist:3.27.0-GA")
|
|
||||||
|
|
||||||
// Coroutines
|
|
||||||
val kotlinx_coroutines_version = "1.4.2"
|
|
||||||
compileOnly( "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinx_coroutines_version")
|
|
||||||
compileOnly( "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$kotlinx_coroutines_version")
|
|
||||||
|
|
||||||
// XML
|
// XML
|
||||||
compileOnly( group= "xmlpull", name= "xmlpull", version= "1.1.3.1")
|
compileOnly(libs.xmlpull)
|
||||||
|
|
||||||
// Config API
|
// Config API
|
||||||
implementation( project(":AndroidCompat:Config"))
|
implementation(projects.androidCompat.config)
|
||||||
|
|
||||||
// dex2jar
|
|
||||||
// compileOnly( "dex2jar:dex-translator")
|
|
||||||
|
|
||||||
// APK parser
|
|
||||||
compileOnly("net.dongliu:apk-parser:2.6.10")
|
|
||||||
|
|
||||||
// APK sig verifier
|
// APK sig verifier
|
||||||
compileOnly("com.android.tools.build:apksig:4.2.0-alpha13")
|
compileOnly(libs.apksig)
|
||||||
|
|
||||||
// AndroidX annotations
|
// AndroidX annotations
|
||||||
compileOnly( "androidx.annotation:annotation:1.2.0-alpha01")
|
compileOnly(libs.android.annotations)
|
||||||
|
|
||||||
// compileOnly("io.reactivex:rxjava:1.3.8")
|
// substitute for duktape-android/quickjs
|
||||||
|
implementation(libs.bundles.polyglot)
|
||||||
|
|
||||||
|
// Kotlin wrapper around Java Preferences, makes certain things easier
|
||||||
|
implementation(libs.bundles.settings)
|
||||||
|
|
||||||
|
// Android version of SimpleDateFormat
|
||||||
|
implementation(libs.icu4j)
|
||||||
|
|
||||||
|
// OpenJDK lacks native JPEG encoder and native WEBP decoder
|
||||||
|
implementation(libs.bundles.twelvemonkeys)
|
||||||
|
implementation(libs.imageio.webp)
|
||||||
}
|
}
|
||||||
|
|
||||||
//def fatJarTask = tasks.getByPath(':AndroidCompat:JVMPatch:fatJar')
|
|
||||||
//
|
|
||||||
//// Copy JVM core patches
|
|
||||||
//task copyJVMPatches(type: Copy) {
|
|
||||||
// from fatJarTask.outputs.files
|
|
||||||
// into 'src/main/resources/patches'
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//compileOnly(Java.dependsOn gradle.includedBuild('dex2jar').task(':dex-translator:assemble')
|
|
||||||
//compileOnly(Java.dependsOn copyJVMPatches
|
|
||||||
//copyJVMPatches.dependsOn fatJarTask
|
|
||||||
//
|
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
# Copyright (C) Contributors to the Suwayomi project
|
||||||
|
#
|
||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
# This is a windows only PowerShell script to create android.jar stubs
|
||||||
|
|
||||||
|
# foolproof against running from AndroidCompat dir instead of running from project root
|
||||||
|
if ($(Split-Path -Path (Get-Location) -Leaf) -eq "AndroidCompat" ) {
|
||||||
|
Set-Location ..
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Output "Getting required Android.jar..."
|
||||||
|
Remove-Item -Recurse -Force "tmp" -ErrorAction SilentlyContinue | Out-Null
|
||||||
|
New-Item -ItemType Directory -Force -Path "tmp" | Out-Null
|
||||||
|
|
||||||
|
$androidEncoded = (Invoke-WebRequest -Uri "https://android.googlesource.com/platform/prebuilts/sdk/+/6cd31be5e4e25901aadf838120d71a79b46d9add/30/public/android.jar?format=TEXT" -UseBasicParsing).content
|
||||||
|
|
||||||
|
$android_jar = (Get-Location).Path + "\tmp\android.jar"
|
||||||
|
|
||||||
|
[IO.File]::WriteAllBytes($android_jar, [Convert]::FromBase64String($androidEncoded))
|
||||||
|
|
||||||
|
# We need to remove any stub classes that we have implementations for
|
||||||
|
Write-Output "Patching JAR..."
|
||||||
|
|
||||||
|
function Remove-Files-Zip($zipfile, $paths)
|
||||||
|
{
|
||||||
|
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression') | Out-Null
|
||||||
|
|
||||||
|
$stream = New-Object IO.FileStream($zipfile, [IO.FileMode]::Open)
|
||||||
|
$mode = [IO.Compression.ZipArchiveMode]::Update
|
||||||
|
$zip = New-Object IO.Compression.ZipArchive($stream, $mode)
|
||||||
|
|
||||||
|
if ($paths.getType().Name -eq "Object[]")
|
||||||
|
{
|
||||||
|
$paths | ForEach-Object {
|
||||||
|
$path = $_
|
||||||
|
($zip.Entries | Where-Object { $_.FullName -like $path }) | ForEach-Object { Write-Output "Deleting: $($_.FullName)"; $_.Delete() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
($zip.Entries | Where-Object { $_.FullName -like $paths }) | ForEach-Object { Write-Output "Deleting: $($_.FullName)"; $_.Delete() }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$zip.Dispose()
|
||||||
|
$stream.Close()
|
||||||
|
$stream.Dispose()
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Output "Removing org.json..."
|
||||||
|
Remove-Files-Zip $android_jar 'org/json/*'
|
||||||
|
|
||||||
|
Write-Output "Removing org.apache..."
|
||||||
|
Remove-Files-Zip $android_jar 'org/apache/*'
|
||||||
|
|
||||||
|
Write-Output "Removing org.w3c..."
|
||||||
|
Remove-Files-Zip $android_jar 'org/w3c/*'
|
||||||
|
|
||||||
|
Write-Output "Removing org.xml..."
|
||||||
|
Remove-Files-Zip $android_jar 'org/xml/*'
|
||||||
|
|
||||||
|
Write-Output "Removing org.xmlpull..."
|
||||||
|
Remove-Files-Zip $android_jar 'org/xmlpull/*'
|
||||||
|
|
||||||
|
Write-Output "Removing junit..."
|
||||||
|
Remove-Files-Zip $android_jar 'junit/*'
|
||||||
|
|
||||||
|
Write-Output "Removing javax..."
|
||||||
|
Remove-Files-Zip $android_jar 'javax/*'
|
||||||
|
|
||||||
|
Write-Output "Removing java..."
|
||||||
|
Remove-Files-Zip $android_jar 'java/*'
|
||||||
|
|
||||||
|
Write-Output "Removing overriden classes..."
|
||||||
|
Remove-Files-Zip $android_jar 'android/app/Application.class'
|
||||||
|
Remove-Files-Zip $android_jar 'android/app/Service.class'
|
||||||
|
Remove-Files-Zip $android_jar 'android/net/Uri.class'
|
||||||
|
Remove-Files-Zip $android_jar 'android/net/Uri$Builder.class'
|
||||||
|
Remove-Files-Zip $android_jar 'android/os/Environment.class'
|
||||||
|
Remove-Files-Zip $android_jar 'android/text/format/Formatter.class'
|
||||||
|
Remove-Files-Zip $android_jar 'android/text/Html.class'
|
||||||
|
|
||||||
|
function Dedupe($path)
|
||||||
|
{
|
||||||
|
Push-Location $path
|
||||||
|
$classes = Get-ChildItem . *.* -Recurse | Where-Object { !$_.PSIsContainer }
|
||||||
|
$classes | ForEach-Object {
|
||||||
|
"Processing class: $($_.FullName)"
|
||||||
|
Remove-Files-Zip $android_jar ("$($_.Name).class","$($_.Name)$*.class","$($_.Name)Kt.class","$($_.Name)Kt$*.class") | Out-Null
|
||||||
|
}
|
||||||
|
Pop-Location
|
||||||
|
}
|
||||||
|
|
||||||
|
Dedupe "AndroidCompat/src/main/java"
|
||||||
|
Dedupe "server/src/main/kotlin"
|
||||||
|
|
||||||
|
Write-Output "Copying Android.jar to library folder..."
|
||||||
|
Move-Item -Force $android_jar "AndroidCompat/lib/android.jar"
|
||||||
|
|
||||||
|
Write-Output "Cleaning up..."
|
||||||
|
Remove-Item -Recurse -Force "tmp"
|
||||||
|
|
||||||
|
Write-Output "Done!"
|
||||||
@@ -1,12 +1,38 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright (C) Contributors to the Suwayomi project
|
||||||
|
#
|
||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
# This is a bash script to create android.jar stubs
|
||||||
|
|
||||||
|
for dep in "curl" "base64" "zip"
|
||||||
|
do
|
||||||
|
which $dep >/dev/null 2>&1 || { echo >&2 "Error: This script needs $dep installed."; abort=yes; }
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$abort" = yes ]; then
|
||||||
|
echo "Some of the dependencies didn't exist. Aborting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# foolproof against running from AndroidCompat dir instead of running from project root
|
||||||
|
if [ "$(basename "$(pwd)")" = "AndroidCompat" ]; then
|
||||||
|
cd ..
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo "Getting required Android.jar..."
|
echo "Getting required Android.jar..."
|
||||||
rm -rf "tmp"
|
rm -rf "tmp"
|
||||||
mkdir -p "tmp"
|
mkdir -p "tmp"
|
||||||
pushd "tmp"
|
pushd "tmp"
|
||||||
|
|
||||||
curl "https://android.googlesource.com/platform/prebuilts/sdk/+/3b8a524d25fa6c3d795afb1eece3f24870c60988/27/public/android.jar?format=TEXT" | base64 --decode > android.jar
|
curl "https://android.googlesource.com/platform/prebuilts/sdk/+/6cd31be5e4e25901aadf838120d71a79b46d9add/30/public/android.jar?format=TEXT" | base64 --decode > android.jar
|
||||||
|
|
||||||
# We need to remove any stub classes that we might use
|
# We need to remove any stub classes that we have implementations for
|
||||||
echo "Patching JAR..."
|
echo "Patching JAR..."
|
||||||
|
|
||||||
echo "Removing org.json..."
|
echo "Removing org.json..."
|
||||||
@@ -33,7 +59,7 @@ zip --delete android.jar javax/*
|
|||||||
echo "Removing java..."
|
echo "Removing java..."
|
||||||
zip --delete android.jar java/*
|
zip --delete android.jar java/*
|
||||||
|
|
||||||
echo "Removing overriden classes..."
|
echo "Removing overridden classes..."
|
||||||
zip --delete android.jar android/app/Application.class
|
zip --delete android.jar android/app/Application.class
|
||||||
zip --delete android.jar android/app/Service.class
|
zip --delete android.jar android/app/Service.class
|
||||||
zip --delete android.jar android/net/Uri.class
|
zip --delete android.jar android/net/Uri.class
|
||||||
@@ -42,12 +68,12 @@ zip --delete android.jar android/os/Environment.class
|
|||||||
zip --delete android.jar android/text/format/Formatter.class
|
zip --delete android.jar android/text/format/Formatter.class
|
||||||
zip --delete android.jar android/text/Html.class
|
zip --delete android.jar android/text/Html.class
|
||||||
|
|
||||||
# Dedup overriden Android classes
|
# Dedup overridden Android classes
|
||||||
ABS_JAR="$(realpath android.jar)"
|
ABS_JAR="$(realpath android.jar)"
|
||||||
function dedup() {
|
function dedup() {
|
||||||
pushd "$1"
|
pushd "$1"
|
||||||
CLASSES="$(find * -type f)"
|
CLASSES="$(find ./* -type f)"
|
||||||
echo "$CLASSES" | while read class
|
echo "$CLASSES" | while read -r class
|
||||||
do
|
do
|
||||||
NAME="${class%.*}"
|
NAME="${class%.*}"
|
||||||
echo "Processing class: $NAME"
|
echo "Processing class: $NAME"
|
||||||
@@ -56,13 +82,10 @@ function dedup() {
|
|||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
pushd ..
|
popd
|
||||||
dedup AndroidCompat/src/main/java
|
dedup AndroidCompat/src/main/java
|
||||||
dedup server/src/main/java
|
|
||||||
dedup server/src/main/kotlin
|
dedup server/src/main/kotlin
|
||||||
popd
|
|
||||||
|
|
||||||
popd
|
|
||||||
echo "Copying Android.jar to library folder..."
|
echo "Copying Android.jar to library folder..."
|
||||||
mv tmp/android.jar AndroidCompat/lib
|
mv tmp/android.jar AndroidCompat/lib
|
||||||
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
android.jar
|
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package android.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import static java.lang.annotation.ElementType.FIELD;
|
||||||
|
import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
|
||||||
|
import static java.lang.annotation.ElementType.METHOD;
|
||||||
|
import static java.lang.annotation.ElementType.PARAMETER;
|
||||||
|
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Denotes that the annotated element represents a packed color
|
||||||
|
* long. If applied to a long array, every element in the array
|
||||||
|
* represents a color long. For more information on how colors
|
||||||
|
* are packed in a long, please refer to the documentation of
|
||||||
|
* the {@link android.graphics.Color} class.</p>
|
||||||
|
*
|
||||||
|
* <p>Example:</p>
|
||||||
|
*
|
||||||
|
* <pre>{@code
|
||||||
|
* public void setFillColor(@ColorLong long color);
|
||||||
|
* }</pre>
|
||||||
|
*
|
||||||
|
* @see android.graphics.Color
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@Retention(SOURCE)
|
||||||
|
@Target({PARAMETER,METHOD,LOCAL_VARIABLE,FIELD})
|
||||||
|
public @interface ColorLong {
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package android.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import static java.lang.annotation.ElementType.FIELD;
|
||||||
|
import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
|
||||||
|
import static java.lang.annotation.ElementType.METHOD;
|
||||||
|
import static java.lang.annotation.ElementType.PARAMETER;
|
||||||
|
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Denotes that the annotated element represents a half-precision floating point
|
||||||
|
* value. Such values are stored in short data types and can be manipulated with
|
||||||
|
* the {@link android.util.Half} class. If applied to an array of short, every
|
||||||
|
* element in the array represents a half-precision float.</p>
|
||||||
|
*
|
||||||
|
* <p>Example:</p>
|
||||||
|
*
|
||||||
|
* <pre>{@code
|
||||||
|
* public abstract void setPosition(@HalfFloat short x, @HalfFloat short y, @HalfFloat short z);
|
||||||
|
* }</pre>
|
||||||
|
*
|
||||||
|
* @see android.util.Half
|
||||||
|
* @see android.util.Half#toHalf(float)
|
||||||
|
* @see android.util.Half#toFloat(short)
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@Retention(SOURCE)
|
||||||
|
@Target({PARAMETER, METHOD, LOCAL_VARIABLE, FIELD})
|
||||||
|
public @interface HalfFloat {
|
||||||
|
}
|
||||||
@@ -25,7 +25,7 @@ import android.os.IBinder;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import kotlin.NotImplementedError;
|
import kotlin.NotImplementedError;
|
||||||
import xyz.nulldev.androidcompat.service.ServiceSupport;
|
import xyz.nulldev.androidcompat.service.ServiceSupport;
|
||||||
import xyz.nulldev.androidcompat.util.KodeinGlobalHelper;
|
import xyz.nulldev.androidcompat.util.KoinGlobalHelper;
|
||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
@@ -299,7 +299,7 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
*/
|
*/
|
||||||
public abstract class Service extends ContextWrapper implements ComponentCallbacks2 {
|
public abstract class Service extends ContextWrapper implements ComponentCallbacks2 {
|
||||||
|
|
||||||
private static final ServiceSupport serviceSupport = KodeinGlobalHelper.instance(ServiceSupport.class);
|
private static final ServiceSupport serviceSupport = KoinGlobalHelper.instance(ServiceSupport.class);
|
||||||
|
|
||||||
private static final String TAG = "Service";
|
private static final String TAG = "Service";
|
||||||
/**
|
/**
|
||||||
@@ -328,7 +328,7 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac
|
|||||||
public Service() {
|
public Service() {
|
||||||
//==================[THIS LINE MODIFIED FROM ANDROID SOURCE!]==================
|
//==================[THIS LINE MODIFIED FROM ANDROID SOURCE!]==================
|
||||||
//Service must be initialized with a base context!
|
//Service must be initialized with a base context!
|
||||||
super(KodeinGlobalHelper.instance(Context.class));
|
super(KoinGlobalHelper.instance(Context.class));
|
||||||
}
|
}
|
||||||
/** Return the application that owns this service. */
|
/** Return the application that owns this service. */
|
||||||
public final Application getApplication() {
|
public final Application getApplication() {
|
||||||
|
|||||||
@@ -0,0 +1,267 @@
|
|||||||
|
package android.graphics;
|
||||||
|
|
||||||
|
import android.annotation.ColorInt;
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import javax.imageio.IIOImage;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.imageio.ImageWriteParam;
|
||||||
|
import javax.imageio.ImageWriter;
|
||||||
|
import javax.imageio.stream.ImageOutputStream;
|
||||||
|
|
||||||
|
|
||||||
|
public final class Bitmap {
|
||||||
|
private final int width;
|
||||||
|
private final int height;
|
||||||
|
private final BufferedImage image;
|
||||||
|
|
||||||
|
public Bitmap(BufferedImage image) {
|
||||||
|
this.image = image;
|
||||||
|
this.width = image.getWidth();
|
||||||
|
this.height = image.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BufferedImage getImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeight() {
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWidth() {
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CompressFormat {
|
||||||
|
JPEG (0),
|
||||||
|
PNG (1),
|
||||||
|
WEBP (2),
|
||||||
|
WEBP_LOSSY (3),
|
||||||
|
WEBP_LOSSLESS (4);
|
||||||
|
|
||||||
|
CompressFormat(int nativeInt) {
|
||||||
|
this.nativeInt = nativeInt;
|
||||||
|
}
|
||||||
|
|
||||||
|
final int nativeInt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Config {
|
||||||
|
ALPHA_8(1),
|
||||||
|
RGB_565(3),
|
||||||
|
ARGB_4444(4),
|
||||||
|
ARGB_8888(5),
|
||||||
|
RGBA_F16(6),
|
||||||
|
HARDWARE(7),
|
||||||
|
RGBA_1010102(8);
|
||||||
|
|
||||||
|
final int nativeInt;
|
||||||
|
|
||||||
|
private static final Config[] sConfigs = {
|
||||||
|
null, ALPHA_8, null, RGB_565, ARGB_4444, ARGB_8888, RGBA_F16, HARDWARE, RGBA_1010102
|
||||||
|
};
|
||||||
|
|
||||||
|
Config(int ni) {
|
||||||
|
this.nativeInt = ni;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Config nativeToConfig(int ni) {
|
||||||
|
return sConfigs[ni];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int configToBufferedImageType(Config config) {
|
||||||
|
switch (config) {
|
||||||
|
case ALPHA_8:
|
||||||
|
return BufferedImage.TYPE_BYTE_GRAY;
|
||||||
|
case RGB_565:
|
||||||
|
return BufferedImage.TYPE_USHORT_565_RGB;
|
||||||
|
case ARGB_8888:
|
||||||
|
return BufferedImage.TYPE_INT_ARGB;
|
||||||
|
default:
|
||||||
|
throw new UnsupportedOperationException("Bitmap.Config(" + config + ") not supported");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common code for checking that x and y are >= 0
|
||||||
|
*
|
||||||
|
* @param x x coordinate to ensure is >= 0
|
||||||
|
* @param y y coordinate to ensure is >= 0
|
||||||
|
*/
|
||||||
|
private static void checkXYSign(int x, int y) {
|
||||||
|
if (x < 0) {
|
||||||
|
throw new IllegalArgumentException("x must be >= 0");
|
||||||
|
}
|
||||||
|
if (y < 0) {
|
||||||
|
throw new IllegalArgumentException("y must be >= 0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common code for checking that width and height are > 0
|
||||||
|
*
|
||||||
|
* @param width width to ensure is > 0
|
||||||
|
* @param height height to ensure is > 0
|
||||||
|
*/
|
||||||
|
private static void checkWidthHeight(int width, int height) {
|
||||||
|
if (width <= 0) {
|
||||||
|
throw new IllegalArgumentException("width must be > 0");
|
||||||
|
}
|
||||||
|
if (height <= 0) {
|
||||||
|
throw new IllegalArgumentException("height must be > 0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Bitmap createBitmap(int width, int height, Config config) {
|
||||||
|
BufferedImage image = new BufferedImage(width, height, configToBufferedImageType(config));
|
||||||
|
return new Bitmap(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Bitmap createBitmap(@NonNull Bitmap source, int x, int y, int width, int height) {
|
||||||
|
checkXYSign(x, y);
|
||||||
|
checkWidthHeight(width, height);
|
||||||
|
if (x + width > source.getWidth()) {
|
||||||
|
throw new IllegalArgumentException("x + width must be <= bitmap.width()");
|
||||||
|
}
|
||||||
|
if (y + height > source.getHeight()) {
|
||||||
|
throw new IllegalArgumentException("y + height must be <= bitmap.height()");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Android will make a copy when creating a sub image,
|
||||||
|
// so we do the same here
|
||||||
|
BufferedImage subImage = source.image.getSubimage(x, y, width, height);
|
||||||
|
BufferedImage newImage = new BufferedImage(subImage.getWidth(), subImage.getHeight(), subImage.getType());
|
||||||
|
newImage.setData(subImage.getData());
|
||||||
|
|
||||||
|
return new Bitmap(newImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean compress(CompressFormat format, int quality, OutputStream stream) {
|
||||||
|
if (stream == null) {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quality < 0 || quality > 100) {
|
||||||
|
throw new IllegalArgumentException("quality must be 0..100");
|
||||||
|
}
|
||||||
|
float qualityFloat = ((float) quality) / 100;
|
||||||
|
|
||||||
|
String formatString;
|
||||||
|
if (format == Bitmap.CompressFormat.PNG) {
|
||||||
|
formatString = "png";
|
||||||
|
} else if (format == Bitmap.CompressFormat.JPEG) {
|
||||||
|
formatString = "jpg";
|
||||||
|
} else if (format == Bitmap.CompressFormat.WEBP || format == Bitmap.CompressFormat.WEBP_LOSSY) {
|
||||||
|
formatString = "webp";
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("unsupported compression format! " + format);
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName(formatString);
|
||||||
|
if (!writers.hasNext()) {
|
||||||
|
throw new IllegalStateException("no image writers found for this format!");
|
||||||
|
}
|
||||||
|
ImageWriter writer = writers.next();
|
||||||
|
|
||||||
|
ImageOutputStream ios;
|
||||||
|
try {
|
||||||
|
ios = ImageIO.createImageOutputStream(stream);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
writer.setOutput(ios);
|
||||||
|
|
||||||
|
BufferedImage img = image;
|
||||||
|
|
||||||
|
ImageWriteParam param = writer.getDefaultWriteParam();
|
||||||
|
if ("jpg".equals(formatString)) {
|
||||||
|
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
|
||||||
|
param.setCompressionQuality(qualityFloat);
|
||||||
|
|
||||||
|
img = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB);
|
||||||
|
img.getGraphics().drawImage(image, 0, 0, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
writer.write(null, new IIOImage(img, null, null), param);
|
||||||
|
ios.close();
|
||||||
|
writer.dispose();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bitmap copy(Config config, boolean isMutable) {
|
||||||
|
Bitmap ret = createBitmap(width, height, config);
|
||||||
|
ret.image.getGraphics().drawImage(image, 0, 0, null);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shared code to check for illegal arguments passed to getPixels()
|
||||||
|
* or setPixels()
|
||||||
|
*
|
||||||
|
* @param x left edge of the area of pixels to access
|
||||||
|
* @param y top edge of the area of pixels to access
|
||||||
|
* @param width width of the area of pixels to access
|
||||||
|
* @param height height of the area of pixels to access
|
||||||
|
* @param offset offset into pixels[] array
|
||||||
|
* @param stride number of elements in pixels[] between each logical row
|
||||||
|
* @param pixels array to hold the area of pixels being accessed
|
||||||
|
*/
|
||||||
|
private void checkPixelsAccess(int x, int y, int width, int height,
|
||||||
|
int offset, int stride, int[] pixels) {
|
||||||
|
checkXYSign(x, y);
|
||||||
|
if (width < 0) {
|
||||||
|
throw new IllegalArgumentException("width must be >= 0");
|
||||||
|
}
|
||||||
|
if (height < 0) {
|
||||||
|
throw new IllegalArgumentException("height must be >= 0");
|
||||||
|
}
|
||||||
|
if (x + width > getWidth()) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"x + width must be <= bitmap.width()");
|
||||||
|
}
|
||||||
|
if (y + height > getHeight()) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"y + height must be <= bitmap.height()");
|
||||||
|
}
|
||||||
|
if (Math.abs(stride) < width) {
|
||||||
|
throw new IllegalArgumentException("abs(stride) must be >= width");
|
||||||
|
}
|
||||||
|
int lastScanline = offset + (height - 1) * stride;
|
||||||
|
int length = pixels.length;
|
||||||
|
if (offset < 0 || (offset + width > length)
|
||||||
|
|| lastScanline < 0
|
||||||
|
|| (lastScanline + width > length)) {
|
||||||
|
throw new ArrayIndexOutOfBoundsException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getPixels(@ColorInt int[] pixels, int offset, int stride,
|
||||||
|
int x, int y, int width, int height) {
|
||||||
|
checkPixelsAccess(x, y, width, height, offset, stride, pixels);
|
||||||
|
|
||||||
|
image.getRGB(x, y, width, height, pixels, offset, stride);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void eraseColor(int c) {
|
||||||
|
java.awt.Color color = Color.valueOf(c).toJavaColor();
|
||||||
|
Graphics2D graphics = image.createGraphics();
|
||||||
|
graphics.setColor(color);
|
||||||
|
graphics.fillRect(0, 0, width, height);
|
||||||
|
graphics.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void recycle() {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package android.graphics;
|
||||||
|
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.imageio.ImageReader;
|
||||||
|
import javax.imageio.stream.ImageInputStream;
|
||||||
|
|
||||||
|
public class BitmapFactory {
|
||||||
|
public static Bitmap decodeStream(InputStream inputStream) {
|
||||||
|
Bitmap bitmap = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
ImageInputStream imageInputStream = ImageIO.createImageInputStream(inputStream);
|
||||||
|
Iterator<ImageReader> imageReaders = ImageIO.getImageReaders(imageInputStream);
|
||||||
|
|
||||||
|
if (!imageReaders.hasNext()) {
|
||||||
|
throw new IllegalArgumentException("no reader for image");
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageReader imageReader = imageReaders.next();
|
||||||
|
imageReader.setInput(imageInputStream);
|
||||||
|
|
||||||
|
BufferedImage image = imageReader.read(0, imageReader.getDefaultReadParam());
|
||||||
|
bitmap = new Bitmap(image);
|
||||||
|
|
||||||
|
imageReader.dispose();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Bitmap decodeByteArray(byte[] data, int offset, int length) {
|
||||||
|
Bitmap bitmap = null;
|
||||||
|
|
||||||
|
ByteArrayInputStream byteArrayStream = new ByteArrayInputStream(data);
|
||||||
|
try {
|
||||||
|
BufferedImage image = ImageIO.read(byteArrayStream);
|
||||||
|
bitmap = new Bitmap(image);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,184 @@
|
|||||||
|
package android.graphics;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.util.Log;
|
||||||
|
import java.awt.BasicStroke;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
|
import java.awt.Shape;
|
||||||
|
import java.awt.font.GlyphVector;
|
||||||
|
import java.awt.geom.AffineTransform;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
|
public final class Canvas {
|
||||||
|
private BufferedImage canvasImage;
|
||||||
|
private Graphics2D canvas;
|
||||||
|
private List<AffineTransform> transformStack = new ArrayList<AffineTransform>();
|
||||||
|
|
||||||
|
private static final String TAG = "Canvas";
|
||||||
|
|
||||||
|
public Canvas(Bitmap bitmap) {
|
||||||
|
canvasImage = bitmap.getImage();
|
||||||
|
canvas = canvasImage.createGraphics();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawBitmap(Bitmap sourceBitmap, Rect src, Rect dst, Paint paint) {
|
||||||
|
BufferedImage sourceImage = sourceBitmap.getImage();
|
||||||
|
BufferedImage sourceImageCropped = sourceImage.getSubimage(src.left, src.top, src.getWidth(), src.getHeight());
|
||||||
|
canvas.drawImage(sourceImageCropped, dst.left, dst.top, dst.getWidth(), dst.getHeight(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawBitmap(Bitmap sourceBitmap, float left, float top, Paint paint) {
|
||||||
|
BufferedImage sourceImage = sourceBitmap.getImage();
|
||||||
|
canvas.drawImage(sourceImage, null, (int) left, (int) top);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawText(@NonNull char[] text, int index, int count, float x, float y,
|
||||||
|
@NonNull Paint paint) {
|
||||||
|
drawText(new String(text, index, count), x, y, paint);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawText(@NonNull String text, float x, float y, @NonNull Paint paint) {
|
||||||
|
applyPaint(paint);
|
||||||
|
GlyphVector glyphVector = paint.getFont().createGlyphVector(canvas.getFontRenderContext(), text);
|
||||||
|
Shape textShape = glyphVector.getOutline();
|
||||||
|
switch (paint.getStyle()) {
|
||||||
|
case Paint.Style.FILL:
|
||||||
|
canvas.drawString(text, x, y);
|
||||||
|
break;
|
||||||
|
case Paint.Style.STROKE:
|
||||||
|
save();
|
||||||
|
translate(x, y);
|
||||||
|
canvas.draw(textShape);
|
||||||
|
restore();
|
||||||
|
break;
|
||||||
|
case Paint.Style.FILL_AND_STROKE:
|
||||||
|
save();
|
||||||
|
translate(x, y);
|
||||||
|
canvas.draw(textShape);
|
||||||
|
canvas.fill(textShape);
|
||||||
|
restore();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawText(@NonNull String text, int start, int end, float x, float y,
|
||||||
|
@NonNull Paint paint) {
|
||||||
|
drawText(text.substring(start, end), x, y, paint);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawText(@NonNull CharSequence text, int start, int end, float x, float y,
|
||||||
|
@NonNull Paint paint) {
|
||||||
|
String str = text.subSequence(start, end).toString();
|
||||||
|
drawText(str, x, y, paint);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawRoundRect(@NonNull RectF rect, float rx, float ry, @NonNull Paint paint) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawRoundRect(float left, float top, float right, float bottom, float rx, float ry,
|
||||||
|
@NonNull Paint paint) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawPath(@NonNull Path path, @NonNull Paint paint) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void translate(float dx, float dy) {
|
||||||
|
if (dx == 0.0f && dy == 0.0f) return;
|
||||||
|
// TODO: check this, should translations stack?
|
||||||
|
canvas.translate(dx, dy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void scale(float sx, float sy) {
|
||||||
|
if (sx == 1.0f && sy == 1.0f) return;
|
||||||
|
canvas.scale(sx, sy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void scale(float sx, float sy, float px, float py) {
|
||||||
|
if (sx == 1.0f && sy == 1.0f) return;
|
||||||
|
translate(px, py);
|
||||||
|
scale(sx, sy);
|
||||||
|
translate(-px, -py);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rotate(float degrees) {
|
||||||
|
if (degrees == 0.0f) return;
|
||||||
|
canvas.rotate(degrees);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void rotate(float degrees, float px, float py) {
|
||||||
|
if (degrees == 0.0f) return;
|
||||||
|
canvas.rotate(degrees, px, py);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSaveCount() {
|
||||||
|
return transformStack.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int save() {
|
||||||
|
transformStack.add(canvas.getTransform());
|
||||||
|
return getSaveCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restoreToCount(int saveCount) {
|
||||||
|
if (saveCount < 1) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"Underflow in restoreToCount - more restores than saves");
|
||||||
|
}
|
||||||
|
if (saveCount > getSaveCount()) {
|
||||||
|
throw new IllegalArgumentException("Overflow in restoreToCount");
|
||||||
|
|
||||||
|
}
|
||||||
|
AffineTransform ts = transformStack.get(saveCount - 1);
|
||||||
|
canvas.setTransform(ts);
|
||||||
|
while (transformStack.size() >= saveCount) {
|
||||||
|
transformStack.remove(transformStack.size() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restore() {
|
||||||
|
restoreToCount(getSaveCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getClipBounds(@NonNull Rect bounds) {
|
||||||
|
Rectangle r = canvas.getClipBounds();
|
||||||
|
if (r == null) {
|
||||||
|
bounds.left = 0;
|
||||||
|
bounds.top = 0;
|
||||||
|
bounds.right = canvasImage.getWidth();
|
||||||
|
bounds.bottom = canvasImage.getHeight();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bounds.left = r.x;
|
||||||
|
bounds.top = r.y;
|
||||||
|
bounds.right = r.x + r.width;
|
||||||
|
bounds.bottom = r.y + r.height;
|
||||||
|
return r.width != 0 && r.height != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyPaint(Paint paint) {
|
||||||
|
canvas.setFont(paint.getFont());
|
||||||
|
java.awt.Color color = Color.valueOf(paint.getColorLong()).toJavaColor();
|
||||||
|
canvas.setColor(color);
|
||||||
|
canvas.setStroke(new BasicStroke(paint.getStrokeWidth(), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
|
||||||
|
if (paint.isAntiAlias()) {
|
||||||
|
canvas.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
} else {
|
||||||
|
canvas.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||||
|
}
|
||||||
|
if (paint.isDither()) {
|
||||||
|
canvas.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
|
||||||
|
} else {
|
||||||
|
canvas.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
|
||||||
|
}
|
||||||
|
// TODO: use more from paint?
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,578 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.graphics;
|
||||||
|
|
||||||
|
import android.annotation.ColorInt;
|
||||||
|
import android.annotation.ColorLong;
|
||||||
|
import android.annotation.HalfFloat;
|
||||||
|
import android.annotation.IntRange;
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
import android.annotation.Size;
|
||||||
|
import android.util.Half;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.function.DoubleUnaryOperator;
|
||||||
|
|
||||||
|
public class Color {
|
||||||
|
@ColorInt public static final int BLACK = 0xFF000000;
|
||||||
|
@ColorInt public static final int DKGRAY = 0xFF444444;
|
||||||
|
@ColorInt public static final int GRAY = 0xFF888888;
|
||||||
|
@ColorInt public static final int LTGRAY = 0xFFCCCCCC;
|
||||||
|
@ColorInt public static final int WHITE = 0xFFFFFFFF;
|
||||||
|
@ColorInt public static final int RED = 0xFFFF0000;
|
||||||
|
@ColorInt public static final int GREEN = 0xFF00FF00;
|
||||||
|
@ColorInt public static final int BLUE = 0xFF0000FF;
|
||||||
|
@ColorInt public static final int YELLOW = 0xFFFFFF00;
|
||||||
|
@ColorInt public static final int CYAN = 0xFF00FFFF;
|
||||||
|
@ColorInt public static final int MAGENTA = 0xFFFF00FF;
|
||||||
|
@ColorInt public static final int TRANSPARENT = 0;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Size(min = 4, max = 5)
|
||||||
|
private final float[] mComponents;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private final ColorSpace mColorSpace;
|
||||||
|
|
||||||
|
public Color() {
|
||||||
|
// This constructor is required for compatibility with previous APIs
|
||||||
|
mComponents = new float[] { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||||
|
mColorSpace = ColorSpace.get(ColorSpace.Named.SRGB);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Color(float r, float g, float b, float a) {
|
||||||
|
this(r, g, b, a, ColorSpace.get(ColorSpace.Named.SRGB));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Color(float r, float g, float b, float a, @NonNull ColorSpace colorSpace) {
|
||||||
|
mComponents = new float[] { r, g, b, a };
|
||||||
|
mColorSpace = colorSpace;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Color(@Size(min = 4, max = 5) float[] components, @NonNull ColorSpace colorSpace) {
|
||||||
|
mComponents = components;
|
||||||
|
mColorSpace = colorSpace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.awt.Color toJavaColor() {
|
||||||
|
return new java.awt.Color(red(), green(), blue(), alpha());
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public ColorSpace getColorSpace() {
|
||||||
|
return mColorSpace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ColorSpace.Model getModel() {
|
||||||
|
return mColorSpace.getModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWideGamut() {
|
||||||
|
return getColorSpace().isWideGamut();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSrgb() {
|
||||||
|
return getColorSpace().isSrgb();
|
||||||
|
}
|
||||||
|
|
||||||
|
@IntRange(from = 4, to = 5)
|
||||||
|
public int getComponentCount() {
|
||||||
|
return mColorSpace.getComponentCount() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorLong
|
||||||
|
public long pack() {
|
||||||
|
return pack(mComponents[0], mComponents[1], mComponents[2], mComponents[3], mColorSpace);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Color convert(@NonNull ColorSpace colorSpace) {
|
||||||
|
ColorSpace.Connector connector = ColorSpace.connect(mColorSpace, colorSpace);
|
||||||
|
float[] color = new float[] {
|
||||||
|
mComponents[0], mComponents[1], mComponents[2], mComponents[3]
|
||||||
|
};
|
||||||
|
connector.transform(color);
|
||||||
|
return new Color(color, colorSpace);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorInt
|
||||||
|
public int toArgb() {
|
||||||
|
if (mColorSpace.isSrgb()) {
|
||||||
|
return ((int) (mComponents[3] * 255.0f + 0.5f) << 24) |
|
||||||
|
((int) (mComponents[0] * 255.0f + 0.5f) << 16) |
|
||||||
|
((int) (mComponents[1] * 255.0f + 0.5f) << 8) |
|
||||||
|
(int) (mComponents[2] * 255.0f + 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
float[] color = new float[] {
|
||||||
|
mComponents[0], mComponents[1], mComponents[2], mComponents[3]
|
||||||
|
};
|
||||||
|
// The transformation saturates the output
|
||||||
|
ColorSpace.connect(mColorSpace).transform(color);
|
||||||
|
|
||||||
|
return ((int) (color[3] * 255.0f + 0.5f) << 24) |
|
||||||
|
((int) (color[0] * 255.0f + 0.5f) << 16) |
|
||||||
|
((int) (color[1] * 255.0f + 0.5f) << 8) |
|
||||||
|
(int) (color[2] * 255.0f + 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float red() {
|
||||||
|
return mComponents[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public float green() {
|
||||||
|
return mComponents[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
public float blue() {
|
||||||
|
return mComponents[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
public float alpha() {
|
||||||
|
return mComponents[mComponents.length - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Size(min = 4, max = 5)
|
||||||
|
public float[] getComponents() {
|
||||||
|
return Arrays.copyOf(mComponents, mComponents.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Size(min = 4)
|
||||||
|
public float[] getComponents(@Nullable @Size(min = 4) float[] components) {
|
||||||
|
if (components == null) {
|
||||||
|
return Arrays.copyOf(mComponents, mComponents.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (components.length < mComponents.length) {
|
||||||
|
throw new IllegalArgumentException("The specified array's length must be at "
|
||||||
|
+ "least " + mComponents.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.arraycopy(mComponents, 0, components, 0, mComponents.length);
|
||||||
|
return components;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getComponent(@IntRange(from = 0, to = 4) int component) {
|
||||||
|
return mComponents[component];
|
||||||
|
}
|
||||||
|
|
||||||
|
public float luminance() {
|
||||||
|
if (mColorSpace.getModel() != ColorSpace.Model.RGB) {
|
||||||
|
throw new IllegalArgumentException("The specified color must be encoded in an RGB " +
|
||||||
|
"color space. The supplied color space is " + mColorSpace.getModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
DoubleUnaryOperator eotf = ((ColorSpace.Rgb) mColorSpace).getEotf();
|
||||||
|
double r = eotf.applyAsDouble(mComponents[0]);
|
||||||
|
double g = eotf.applyAsDouble(mComponents[1]);
|
||||||
|
double b = eotf.applyAsDouble(mComponents[2]);
|
||||||
|
|
||||||
|
return saturate((float) ((0.2126 * r) + (0.7152 * g) + (0.0722 * b)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
Color color = (Color) o;
|
||||||
|
|
||||||
|
//noinspection SimplifiableIfStatement
|
||||||
|
if (!Arrays.equals(mComponents, color.mComponents)) return false;
|
||||||
|
return mColorSpace.equals(color.mColorSpace);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = Arrays.hashCode(mComponents);
|
||||||
|
result = 31 * result + mColorSpace.hashCode();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder b = new StringBuilder("Color(");
|
||||||
|
for (float c : mComponents) {
|
||||||
|
b.append(c).append(", ");
|
||||||
|
}
|
||||||
|
b.append(mColorSpace.getName());
|
||||||
|
b.append(')');
|
||||||
|
return b.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public static ColorSpace colorSpace(@ColorLong long color) {
|
||||||
|
return ColorSpace.get((int) (color & 0x3fL));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float red(@ColorLong long color) {
|
||||||
|
if ((color & 0x3fL) == 0L) return ((color >> 48) & 0xff) / 255.0f;
|
||||||
|
return Half.toFloat((short) ((color >> 48) & 0xffff));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float green(@ColorLong long color) {
|
||||||
|
if ((color & 0x3fL) == 0L) return ((color >> 40) & 0xff) / 255.0f;
|
||||||
|
return Half.toFloat((short) ((color >> 32) & 0xffff));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float blue(@ColorLong long color) {
|
||||||
|
if ((color & 0x3fL) == 0L) return ((color >> 32) & 0xff) / 255.0f;
|
||||||
|
return Half.toFloat((short) ((color >> 16) & 0xffff));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float alpha(@ColorLong long color) {
|
||||||
|
if ((color & 0x3fL) == 0L) return ((color >> 56) & 0xff) / 255.0f;
|
||||||
|
return ((color >> 6) & 0x3ff) / 1023.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSrgb(@ColorLong long color) {
|
||||||
|
return colorSpace(color).isSrgb();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isWideGamut(@ColorLong long color) {
|
||||||
|
return colorSpace(color).isWideGamut();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isInColorSpace(@ColorLong long color, @NonNull ColorSpace colorSpace) {
|
||||||
|
return (int) (color & 0x3fL) == colorSpace.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorInt
|
||||||
|
public static int toArgb(@ColorLong long color) {
|
||||||
|
if ((color & 0x3fL) == 0L) return (int) (color >> 32);
|
||||||
|
|
||||||
|
float r = red(color);
|
||||||
|
float g = green(color);
|
||||||
|
float b = blue(color);
|
||||||
|
float a = alpha(color);
|
||||||
|
|
||||||
|
// The transformation saturates the output
|
||||||
|
float[] c = ColorSpace.connect(colorSpace(color)).transform(r, g, b);
|
||||||
|
|
||||||
|
return ((int) (a * 255.0f + 0.5f) << 24) |
|
||||||
|
((int) (c[0] * 255.0f + 0.5f) << 16) |
|
||||||
|
((int) (c[1] * 255.0f + 0.5f) << 8) |
|
||||||
|
(int) (c[2] * 255.0f + 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public static Color valueOf(@ColorInt int color) {
|
||||||
|
float r = ((color >> 16) & 0xff) / 255.0f;
|
||||||
|
float g = ((color >> 8) & 0xff) / 255.0f;
|
||||||
|
float b = ((color ) & 0xff) / 255.0f;
|
||||||
|
float a = ((color >> 24) & 0xff) / 255.0f;
|
||||||
|
return new Color(r, g, b, a, ColorSpace.get(ColorSpace.Named.SRGB));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public static Color valueOf(@ColorLong long color) {
|
||||||
|
return new Color(red(color), green(color), blue(color), alpha(color), colorSpace(color));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public static Color valueOf(float r, float g, float b) {
|
||||||
|
return new Color(r, g, b, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public static Color valueOf(float r, float g, float b, float a) {
|
||||||
|
return new Color(saturate(r), saturate(g), saturate(b), saturate(a));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public static Color valueOf(float r, float g, float b, float a, @NonNull ColorSpace colorSpace) {
|
||||||
|
if (colorSpace.getComponentCount() > 3) {
|
||||||
|
throw new IllegalArgumentException("The specified color space must use a color model " +
|
||||||
|
"with at most 3 color components");
|
||||||
|
}
|
||||||
|
return new Color(r, g, b, a, colorSpace);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public static Color valueOf(@NonNull @Size(min = 4, max = 5) float[] components,
|
||||||
|
@NonNull ColorSpace colorSpace) {
|
||||||
|
if (components.length < colorSpace.getComponentCount() + 1) {
|
||||||
|
throw new IllegalArgumentException("Received a component array of length " +
|
||||||
|
components.length + " but the color model requires " +
|
||||||
|
(colorSpace.getComponentCount() + 1) + " (including alpha)");
|
||||||
|
}
|
||||||
|
return new Color(Arrays.copyOf(components, colorSpace.getComponentCount() + 1), colorSpace);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorLong
|
||||||
|
public static long pack(@ColorInt int color) {
|
||||||
|
return (color & 0xffffffffL) << 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorLong
|
||||||
|
public static long pack(float red, float green, float blue) {
|
||||||
|
return pack(red, green, blue, 1.0f, ColorSpace.get(ColorSpace.Named.SRGB));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorLong
|
||||||
|
public static long pack(float red, float green, float blue, float alpha) {
|
||||||
|
return pack(red, green, blue, alpha, ColorSpace.get(ColorSpace.Named.SRGB));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorLong
|
||||||
|
public static long pack(float red, float green, float blue, float alpha,
|
||||||
|
@NonNull ColorSpace colorSpace) {
|
||||||
|
if (colorSpace.isSrgb()) {
|
||||||
|
int argb =
|
||||||
|
((int) (alpha * 255.0f + 0.5f) << 24) |
|
||||||
|
((int) (red * 255.0f + 0.5f) << 16) |
|
||||||
|
((int) (green * 255.0f + 0.5f) << 8) |
|
||||||
|
(int) (blue * 255.0f + 0.5f);
|
||||||
|
return (argb & 0xffffffffL) << 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
int id = colorSpace.getId();
|
||||||
|
if (id == ColorSpace.MIN_ID) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"Unknown color space, please use a color space returned by ColorSpace.get()");
|
||||||
|
}
|
||||||
|
if (colorSpace.getComponentCount() > 3) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"The color space must use a color model with at most 3 components");
|
||||||
|
}
|
||||||
|
|
||||||
|
@HalfFloat short r = Half.toHalf(red);
|
||||||
|
@HalfFloat short g = Half.toHalf(green);
|
||||||
|
@HalfFloat short b = Half.toHalf(blue);
|
||||||
|
|
||||||
|
int a = (int) (Math.max(0.0f, Math.min(alpha, 1.0f)) * 1023.0f + 0.5f);
|
||||||
|
|
||||||
|
// Suppress sign extension
|
||||||
|
return (r & 0xffffL) << 48 |
|
||||||
|
(g & 0xffffL) << 32 |
|
||||||
|
(b & 0xffffL) << 16 |
|
||||||
|
(a & 0x3ffL ) << 6 |
|
||||||
|
id & 0x3fL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorLong
|
||||||
|
public static long convert(@ColorInt int color, @NonNull ColorSpace colorSpace) {
|
||||||
|
float r = ((color >> 16) & 0xff) / 255.0f;
|
||||||
|
float g = ((color >> 8) & 0xff) / 255.0f;
|
||||||
|
float b = ((color ) & 0xff) / 255.0f;
|
||||||
|
float a = ((color >> 24) & 0xff) / 255.0f;
|
||||||
|
ColorSpace source = ColorSpace.get(ColorSpace.Named.SRGB);
|
||||||
|
return convert(r, g, b, a, source, colorSpace);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorLong
|
||||||
|
public static long convert(@ColorLong long color, @NonNull ColorSpace colorSpace) {
|
||||||
|
float r = red(color);
|
||||||
|
float g = green(color);
|
||||||
|
float b = blue(color);
|
||||||
|
float a = alpha(color);
|
||||||
|
ColorSpace source = colorSpace(color);
|
||||||
|
return convert(r, g, b, a, source, colorSpace);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorLong
|
||||||
|
public static long convert(float r, float g, float b, float a,
|
||||||
|
@NonNull ColorSpace source, @NonNull ColorSpace destination) {
|
||||||
|
float[] c = ColorSpace.connect(source, destination).transform(r, g, b);
|
||||||
|
return pack(c[0], c[1], c[2], a, destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorLong
|
||||||
|
public static long convert(@ColorLong long color, @NonNull ColorSpace.Connector connector) {
|
||||||
|
float r = red(color);
|
||||||
|
float g = green(color);
|
||||||
|
float b = blue(color);
|
||||||
|
float a = alpha(color);
|
||||||
|
return convert(r, g, b, a, connector);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorLong
|
||||||
|
public static long convert(float r, float g, float b, float a,
|
||||||
|
@NonNull ColorSpace.Connector connector) {
|
||||||
|
float[] c = connector.transform(r, g, b);
|
||||||
|
return pack(c[0], c[1], c[2], a, connector.getDestination());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float luminance(@ColorLong long color) {
|
||||||
|
ColorSpace colorSpace = colorSpace(color);
|
||||||
|
if (colorSpace.getModel() != ColorSpace.Model.RGB) {
|
||||||
|
throw new IllegalArgumentException("The specified color must be encoded in an RGB " +
|
||||||
|
"color space. The supplied color space is " + colorSpace.getModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
DoubleUnaryOperator eotf = ((ColorSpace.Rgb) colorSpace).getEotf();
|
||||||
|
double r = eotf.applyAsDouble(red(color));
|
||||||
|
double g = eotf.applyAsDouble(green(color));
|
||||||
|
double b = eotf.applyAsDouble(blue(color));
|
||||||
|
|
||||||
|
return saturate((float) ((0.2126 * r) + (0.7152 * g) + (0.0722 * b)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static float saturate(float v) {
|
||||||
|
return v <= 0.0f ? 0.0f : (v >= 1.0f ? 1.0f : v);
|
||||||
|
}
|
||||||
|
|
||||||
|
@IntRange(from = 0, to = 255)
|
||||||
|
public static int alpha(int color) {
|
||||||
|
return color >>> 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
@IntRange(from = 0, to = 255)
|
||||||
|
public static int red(int color) {
|
||||||
|
return (color >> 16) & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
@IntRange(from = 0, to = 255)
|
||||||
|
public static int green(int color) {
|
||||||
|
return (color >> 8) & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
@IntRange(from = 0, to = 255)
|
||||||
|
public static int blue(int color) {
|
||||||
|
return color & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorInt
|
||||||
|
public static int rgb(
|
||||||
|
@IntRange(from = 0, to = 255) int red,
|
||||||
|
@IntRange(from = 0, to = 255) int green,
|
||||||
|
@IntRange(from = 0, to = 255) int blue) {
|
||||||
|
return 0xff000000 | (red << 16) | (green << 8) | blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorInt
|
||||||
|
public static int rgb(float red, float green, float blue) {
|
||||||
|
return 0xff000000 |
|
||||||
|
((int) (red * 255.0f + 0.5f) << 16) |
|
||||||
|
((int) (green * 255.0f + 0.5f) << 8) |
|
||||||
|
(int) (blue * 255.0f + 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorInt
|
||||||
|
public static int argb(
|
||||||
|
@IntRange(from = 0, to = 255) int alpha,
|
||||||
|
@IntRange(from = 0, to = 255) int red,
|
||||||
|
@IntRange(from = 0, to = 255) int green,
|
||||||
|
@IntRange(from = 0, to = 255) int blue) {
|
||||||
|
return (alpha << 24) | (red << 16) | (green << 8) | blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorInt
|
||||||
|
public static int argb(float alpha, float red, float green, float blue) {
|
||||||
|
return ((int) (alpha * 255.0f + 0.5f) << 24) |
|
||||||
|
((int) (red * 255.0f + 0.5f) << 16) |
|
||||||
|
((int) (green * 255.0f + 0.5f) << 8) |
|
||||||
|
(int) (blue * 255.0f + 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float luminance(@ColorInt int color) {
|
||||||
|
ColorSpace.Rgb cs = (ColorSpace.Rgb) ColorSpace.get(ColorSpace.Named.SRGB);
|
||||||
|
DoubleUnaryOperator eotf = cs.getEotf();
|
||||||
|
|
||||||
|
double r = eotf.applyAsDouble(red(color) / 255.0);
|
||||||
|
double g = eotf.applyAsDouble(green(color) / 255.0);
|
||||||
|
double b = eotf.applyAsDouble(blue(color) / 255.0);
|
||||||
|
|
||||||
|
return (float) ((0.2126 * r) + (0.7152 * g) + (0.0722 * b));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorInt
|
||||||
|
public static int parseColor(@Size(min=1) String colorString) {
|
||||||
|
if (colorString.charAt(0) == '#') {
|
||||||
|
// Use a long to avoid rollovers on #ffXXXXXX
|
||||||
|
long color = Long.parseLong(colorString.substring(1), 16);
|
||||||
|
if (colorString.length() == 7) {
|
||||||
|
// Set the alpha value
|
||||||
|
color |= 0x00000000ff000000;
|
||||||
|
} else if (colorString.length() != 9) {
|
||||||
|
throw new IllegalArgumentException("Unknown color");
|
||||||
|
}
|
||||||
|
return (int)color;
|
||||||
|
} else {
|
||||||
|
Integer color = sColorNameMap.get(colorString.toLowerCase(Locale.ROOT));
|
||||||
|
if (color != null) {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Unknown color");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RGBToHSV(
|
||||||
|
@IntRange(from = 0, to = 255) int red,
|
||||||
|
@IntRange(from = 0, to = 255) int green,
|
||||||
|
@IntRange(from = 0, to = 255) int blue, @Size(3) float hsv[]) {
|
||||||
|
if (hsv.length < 3) {
|
||||||
|
throw new RuntimeException("3 components required for hsv");
|
||||||
|
}
|
||||||
|
nativeRGBToHSV(red, green, blue, hsv);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void colorToHSV(@ColorInt int color, @Size(3) float hsv[]) {
|
||||||
|
RGBToHSV((color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF, hsv);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorInt
|
||||||
|
public static int HSVToColor(@Size(3) float hsv[]) {
|
||||||
|
return HSVToColor(0xFF, hsv);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorInt
|
||||||
|
public static int HSVToColor(@IntRange(from = 0, to = 255) int alpha, @Size(3) float hsv[]) {
|
||||||
|
if (hsv.length < 3) {
|
||||||
|
throw new RuntimeException("3 components required for hsv");
|
||||||
|
}
|
||||||
|
return nativeHSVToColor(alpha, hsv);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static native void nativeRGBToHSV(int red, int greed, int blue, float hsv[]);
|
||||||
|
private static native int nativeHSVToColor(int alpha, float hsv[]);
|
||||||
|
|
||||||
|
private static final HashMap<String, Integer> sColorNameMap;
|
||||||
|
static {
|
||||||
|
sColorNameMap = new HashMap<>();
|
||||||
|
sColorNameMap.put("black", BLACK);
|
||||||
|
sColorNameMap.put("darkgray", DKGRAY);
|
||||||
|
sColorNameMap.put("gray", GRAY);
|
||||||
|
sColorNameMap.put("lightgray", LTGRAY);
|
||||||
|
sColorNameMap.put("white", WHITE);
|
||||||
|
sColorNameMap.put("red", RED);
|
||||||
|
sColorNameMap.put("green", GREEN);
|
||||||
|
sColorNameMap.put("blue", BLUE);
|
||||||
|
sColorNameMap.put("yellow", YELLOW);
|
||||||
|
sColorNameMap.put("cyan", CYAN);
|
||||||
|
sColorNameMap.put("magenta", MAGENTA);
|
||||||
|
sColorNameMap.put("aqua", 0xFF00FFFF);
|
||||||
|
sColorNameMap.put("fuchsia", 0xFFFF00FF);
|
||||||
|
sColorNameMap.put("darkgrey", DKGRAY);
|
||||||
|
sColorNameMap.put("grey", GRAY);
|
||||||
|
sColorNameMap.put("lightgrey", LTGRAY);
|
||||||
|
sColorNameMap.put("lime", 0xFF00FF00);
|
||||||
|
sColorNameMap.put("maroon", 0xFF800000);
|
||||||
|
sColorNameMap.put("navy", 0xFF000080);
|
||||||
|
sColorNameMap.put("olive", 0xFF808000);
|
||||||
|
sColorNameMap.put("purple", 0xFF800080);
|
||||||
|
sColorNameMap.put("silver", 0xFFC0C0C0);
|
||||||
|
sColorNameMap.put("teal", 0xFF008080);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,122 @@
|
|||||||
|
package android.graphics;
|
||||||
|
|
||||||
|
import android.os.Parcelable;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import android.os.Parcel;
|
||||||
|
|
||||||
|
public final class Rect {
|
||||||
|
public int left;
|
||||||
|
public int top;
|
||||||
|
public int right;
|
||||||
|
public int bottom;
|
||||||
|
|
||||||
|
private static final class UnflattenHelper {
|
||||||
|
private static final Pattern FLATTENED_PATTERN = Pattern.compile(
|
||||||
|
"(-?\\d+) (-?\\d+) (-?\\d+) (-?\\d+)");
|
||||||
|
|
||||||
|
static Matcher getMatcher(String str) {
|
||||||
|
return FLATTENED_PATTERN.matcher(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Rect() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Rect(int left, int top, int right, int bottom) {
|
||||||
|
this.left = left;
|
||||||
|
this.top = top;
|
||||||
|
this.right = right;
|
||||||
|
this.bottom = bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Rect(Rect r) {
|
||||||
|
if (r == null) {
|
||||||
|
this.left = 0;
|
||||||
|
this.top = 0;
|
||||||
|
this.right = 0;
|
||||||
|
this.bottom = 0;
|
||||||
|
} else {
|
||||||
|
this.left = left;
|
||||||
|
this.top = top;
|
||||||
|
this.right = right;
|
||||||
|
this.bottom = bottom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getWidth() {
|
||||||
|
return right - left;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getHeight() {
|
||||||
|
return bottom - top;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Rect unflattenFromString(String str) {
|
||||||
|
if (str.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Matcher matcher = UnflattenHelper.getMatcher(str);
|
||||||
|
if (!matcher.matches()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Rect(Integer.parseInt(matcher.group(1)),
|
||||||
|
Integer.parseInt(matcher.group(2)),
|
||||||
|
Integer.parseInt(matcher.group(3)),
|
||||||
|
Integer.parseInt(matcher.group(4)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toShortString() {
|
||||||
|
return toShortString(new StringBuilder(32));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toShortString(StringBuilder sb) {
|
||||||
|
sb.setLength(0);
|
||||||
|
sb.append('['); sb.append(left); sb.append(',');
|
||||||
|
sb.append(top); sb.append("]["); sb.append(right);
|
||||||
|
sb.append(','); sb.append(bottom); sb.append(']');
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String flattenToString() {
|
||||||
|
StringBuilder sb = new StringBuilder(32);
|
||||||
|
sb.append(left);
|
||||||
|
sb.append(' ');
|
||||||
|
sb.append(top);
|
||||||
|
sb.append(' ');
|
||||||
|
sb.append(right);
|
||||||
|
sb.append(' ');
|
||||||
|
sb.append(bottom);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeToParcel(Parcel out, int flags) {
|
||||||
|
out.writeInt(left);
|
||||||
|
out.writeInt(top);
|
||||||
|
out.writeInt(right);
|
||||||
|
out.writeInt(bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Parcelable.Creator<Rect> CREATOR = new Parcelable.Creator<Rect>() {
|
||||||
|
@Override
|
||||||
|
public Rect createFromParcel(Parcel in) {
|
||||||
|
Rect r = new Rect();
|
||||||
|
r.readFromParcel(in);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Rect[] newArray(int size) {
|
||||||
|
return new Rect[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public void readFromParcel(Parcel in) {
|
||||||
|
left = in.readInt();
|
||||||
|
top = in.readInt();
|
||||||
|
right = in.readInt();
|
||||||
|
bottom = in.readInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.graphics;
|
||||||
|
|
||||||
|
import com.android.internal.util.ArrayUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public class TemporaryBuffer {
|
||||||
|
public static char[] obtain(int len) {
|
||||||
|
char[] buf;
|
||||||
|
|
||||||
|
synchronized (TemporaryBuffer.class) {
|
||||||
|
buf = sTemp;
|
||||||
|
sTemp = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buf == null || buf.length < len) {
|
||||||
|
buf = ArrayUtils.newUnpaddedCharArray(len);
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void recycle(char[] temp) {
|
||||||
|
if (temp.length > 1000) return;
|
||||||
|
|
||||||
|
synchronized (TemporaryBuffer.class) {
|
||||||
|
sTemp = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static char[] sTemp = null;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,327 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.graphics;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
import android.annotation.TestApi;
|
||||||
|
import android.content.res.AssetManager;
|
||||||
|
import android.util.Log;
|
||||||
|
import com.android.internal.util.Preconditions;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.FontFormatException;
|
||||||
|
import java.awt.font.TextAttribute;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileDescriptor;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
|
||||||
|
|
||||||
|
public class Typeface {
|
||||||
|
|
||||||
|
private static String TAG = "Typeface";
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public static final boolean ENABLE_LAZY_TYPEFACE_INITIALIZATION = true;
|
||||||
|
|
||||||
|
/** The default NORMAL typeface object */
|
||||||
|
public static final Typeface DEFAULT;
|
||||||
|
public static final Typeface DEFAULT_BOLD;
|
||||||
|
/** The NORMAL style of the default sans serif typeface. */
|
||||||
|
public static final Typeface SANS_SERIF;
|
||||||
|
/** The NORMAL style of the default serif typeface. */
|
||||||
|
public static final Typeface SERIF;
|
||||||
|
/** The NORMAL style of the default monospace typeface. */
|
||||||
|
public static final Typeface MONOSPACE;
|
||||||
|
|
||||||
|
public @interface Style {}
|
||||||
|
|
||||||
|
// Style
|
||||||
|
public static final int NORMAL = 0;
|
||||||
|
public static final int BOLD = 1;
|
||||||
|
public static final int ITALIC = 2;
|
||||||
|
public static final int BOLD_ITALIC = 3;
|
||||||
|
/** @hide */ public static final int STYLE_MASK = 0x03;
|
||||||
|
|
||||||
|
public static final String DEFAULT_FAMILY = "sans-serif";
|
||||||
|
|
||||||
|
private final Font mFont;
|
||||||
|
|
||||||
|
/** Returns the typeface's weight value */
|
||||||
|
public int getWeight() {
|
||||||
|
Map<TextAttribute, Object> atts = (Map<TextAttribute, Object>) mFont.getAttributes();
|
||||||
|
Object weight = atts.getOrDefault(TextAttribute.WEIGHT, TextAttribute.WEIGHT_REGULAR);
|
||||||
|
if (weight instanceof Float) {
|
||||||
|
float w = ((Float) weight).floatValue();
|
||||||
|
// undo the transformation
|
||||||
|
return (int) ((w - TextAttribute.WEIGHT_REGULAR) / (TextAttribute.WEIGHT_BOLD - TextAttribute.WEIGHT_REGULAR) * (Builder.BOLD_WEIGHT - Builder.NORMAL_WEIGHT) + Builder.NORMAL_WEIGHT);
|
||||||
|
}
|
||||||
|
return Builder.NORMAL_WEIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getJavaWeight() {
|
||||||
|
Map<TextAttribute, Object> atts = (Map<TextAttribute, Object>) mFont.getAttributes();
|
||||||
|
Object weight = atts.getOrDefault(TextAttribute.WEIGHT, TextAttribute.WEIGHT_REGULAR);
|
||||||
|
if (weight instanceof Float) {
|
||||||
|
return ((Float) weight).floatValue();
|
||||||
|
}
|
||||||
|
return TextAttribute.WEIGHT_REGULAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns the typeface's intrinsic style attributes */
|
||||||
|
public @Style int getStyle() {
|
||||||
|
if (isBold() && isItalic()) return BOLD_ITALIC;
|
||||||
|
if (isBold()) return BOLD;
|
||||||
|
if (isItalic()) return ITALIC;
|
||||||
|
return NORMAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns true if getStyle() has the BOLD bit set. */
|
||||||
|
public final boolean isBold() {
|
||||||
|
return mFont.isBold();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns true if getStyle() has the ITALIC bit set. */
|
||||||
|
public final boolean isItalic() {
|
||||||
|
return mFont.isItalic();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final @Nullable String getSystemFontFamilyName() {
|
||||||
|
return mFont.getFamily();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Typeface findFromCache(AssetManager mgr, String path) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
/** @hide */
|
||||||
|
public static final int NORMAL_WEIGHT = 400;
|
||||||
|
/** @hide */
|
||||||
|
public static final int BOLD_WEIGHT = 700;
|
||||||
|
|
||||||
|
private final String mPath;
|
||||||
|
|
||||||
|
private Font mFont;
|
||||||
|
private int mStyle;
|
||||||
|
private Map<TextAttribute, Object> mAttributes;
|
||||||
|
|
||||||
|
private String mFallbackFamilyName;
|
||||||
|
|
||||||
|
public Builder(@NonNull File path) {
|
||||||
|
mFont = loadFont(path);
|
||||||
|
Log.v(TAG, "Font loaded from " + path.toURI());
|
||||||
|
mPath = null;
|
||||||
|
mStyle = 0;
|
||||||
|
mAttributes = new HashMap<TextAttribute, Object>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder(@NonNull FileDescriptor fd) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder(@NonNull String path) {
|
||||||
|
mFont = loadFont(new File(path));
|
||||||
|
mPath = path;
|
||||||
|
mStyle = 0;
|
||||||
|
mAttributes = new HashMap<TextAttribute, Object>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder(@NonNull AssetManager assetManager, @NonNull String path) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder(@NonNull AssetManager assetManager, @NonNull String path, boolean isAsset,
|
||||||
|
int cookie) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setWeight(int weight) {
|
||||||
|
// java font weight does not follow typical weight distribution
|
||||||
|
// In Java, regular weight is at 1.0 and bold at 2.0, compared to 400 and 700 in TTF
|
||||||
|
// Typical range is 0 to 1000
|
||||||
|
|
||||||
|
float jWeight = (weight - NORMAL_WEIGHT) / (BOLD_WEIGHT - NORMAL_WEIGHT) * (TextAttribute.WEIGHT_BOLD - TextAttribute.WEIGHT_REGULAR) + TextAttribute.WEIGHT_REGULAR;
|
||||||
|
mAttributes.put(TextAttribute.WEIGHT, jWeight);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setItalic(boolean italic) {
|
||||||
|
if (italic) {
|
||||||
|
mStyle |= Font.ITALIC;
|
||||||
|
} else {
|
||||||
|
mStyle &= ~Font.ITALIC;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setTtcIndex(int ttcIndex) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setFontVariationSettings(@Nullable String variationSettings) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setFallback(@Nullable String familyName) {
|
||||||
|
mFallbackFamilyName = familyName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Typeface resolveFallbackTypeface() {
|
||||||
|
if (mFallbackFamilyName == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Typeface(new Font(mFallbackFamilyName, mStyle, 12).deriveFont(mAttributes));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Typeface build() {
|
||||||
|
if (mFont == null) return resolveFallbackTypeface();
|
||||||
|
return new Typeface(mFont.deriveFont(mStyle).deriveFont(mAttributes));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Font loadFont(File fontFile) {
|
||||||
|
try {
|
||||||
|
return Font.createFont(Font.TRUETYPE_FONT, fontFile);
|
||||||
|
} catch (FontFormatException ex) {
|
||||||
|
Log.v(TAG, "Failed to create font as TTF", ex);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
Log.v(TAG, "Failed to create font as TTF", ex);
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return Font.createFont(Font.TYPE1_FONT, fontFile);
|
||||||
|
} catch (FontFormatException ex) {
|
||||||
|
Log.v(TAG, "Failed to create font as T1", ex);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
Log.v(TAG, "Failed to create font as T1", ex);
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Typeface create(String familyName, @Style int style) {
|
||||||
|
return create(getSystemDefaultTypeface(familyName), style);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Typeface create(Typeface family, @Style int style) {
|
||||||
|
if ((style & ~STYLE_MASK) != 0) {
|
||||||
|
style = NORMAL;
|
||||||
|
}
|
||||||
|
if (family == null) {
|
||||||
|
family = getSystemDefaultTypeface(DEFAULT_FAMILY);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @NonNull Typeface create(@Nullable Typeface family,
|
||||||
|
int weight, boolean italic) {
|
||||||
|
Preconditions.checkArgumentInRange(weight, 0, 1000, "weight");
|
||||||
|
if (family == null) {
|
||||||
|
family = getSystemDefaultTypeface(DEFAULT_FAMILY);
|
||||||
|
}
|
||||||
|
return createWeightStyle(family, weight, italic);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static @NonNull Typeface createWeightStyle(@NonNull Typeface base,
|
||||||
|
int weight, boolean italic) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Typeface defaultFromStyle(@Style int style) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Typeface createFromAsset(AssetManager mgr, String path) {
|
||||||
|
Preconditions.checkNotNull(path); // for backward compatibility
|
||||||
|
Preconditions.checkNotNull(mgr);
|
||||||
|
|
||||||
|
Typeface typeface = new Builder(mgr, path).build();
|
||||||
|
if (typeface != null) return typeface;
|
||||||
|
// check if the file exists, and throw an exception for backward compatibility
|
||||||
|
try (InputStream inputStream = mgr.open(path)) {
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("Font asset not found " + path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Typeface.DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Typeface(Font fnt) {
|
||||||
|
mFont = fnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Typeface createFromFile(@Nullable File file) {
|
||||||
|
// For the compatibility reasons, leaving possible NPE here.
|
||||||
|
// See android.graphics.cts.TypefaceTest#testCreateFromFileByFileReferenceNull
|
||||||
|
|
||||||
|
Typeface typeface = new Builder(file).build();
|
||||||
|
if (typeface != null) return typeface;
|
||||||
|
|
||||||
|
// check if the file exists, and throw an exception for backward compatibility
|
||||||
|
if (!file.exists()) {
|
||||||
|
throw new RuntimeException("Font asset not found " + file.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
return Typeface.DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Typeface createFromFile(@Nullable String path) {
|
||||||
|
Preconditions.checkNotNull(path); // for backward compatibility
|
||||||
|
return createFromFile(new File(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Typeface getSystemDefaultTypeface(@NonNull String familyName) {
|
||||||
|
return new Typeface(new Font(familyName, 0, 12));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Font getFont() {
|
||||||
|
return mFont;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
Typeface typeface = (Typeface) o;
|
||||||
|
|
||||||
|
return typeface.mFont.equals(mFont);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return mFont.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
DEFAULT = new Typeface(new Font(null, 0, 12));
|
||||||
|
DEFAULT_BOLD = new Typeface(new Font(null, Font.BOLD, 12));
|
||||||
|
SANS_SERIF = new Typeface(new Font(Font.SANS_SERIF, 0, 12));
|
||||||
|
SERIF = new Typeface(new Font(Font.SERIF, 0, 12));
|
||||||
|
MONOSPACE = new Typeface(new Font(Font.MONOSPACED, 0, 12));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package android.os;
|
package android.os;
|
||||||
|
|
||||||
import xyz.nulldev.androidcompat.io.AndroidFiles;
|
import xyz.nulldev.androidcompat.io.AndroidFiles;
|
||||||
import xyz.nulldev.androidcompat.util.KodeinGlobalHelper;
|
import xyz.nulldev.androidcompat.util.KoinGlobalHelper;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ import java.io.File;
|
|||||||
* Android compatibility layer for files
|
* Android compatibility layer for files
|
||||||
*/
|
*/
|
||||||
public class Environment {
|
public class Environment {
|
||||||
private static AndroidFiles androidFiles = KodeinGlobalHelper.instance(AndroidFiles.class);
|
private static AndroidFiles androidFiles = KoinGlobalHelper.instance(AndroidFiles.class);
|
||||||
|
|
||||||
public static String DIRECTORY_ALARMS = getHomeDirectory("Alarms").getAbsolutePath();
|
public static String DIRECTORY_ALARMS = getHomeDirectory("Alarms").getAbsolutePath();
|
||||||
public static String DIRECTORY_DCIM = getHomeDirectory("DCIM").getAbsolutePath();
|
public static String DIRECTORY_DCIM = getHomeDirectory("DCIM").getAbsolutePath();
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,25 @@
|
|||||||
|
/* //device/java/android/android/app/IActivityPendingResult.aidl
|
||||||
|
**
|
||||||
|
** Copyright 2007, The Android Open Source Project
|
||||||
|
**
|
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
** you may not use this file except in compliance with the License.
|
||||||
|
** You may obtain a copy of the License at
|
||||||
|
**
|
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
**
|
||||||
|
** Unless required by applicable law or agreed to in writing, software
|
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
** See the License for the specific language governing permissions and
|
||||||
|
** limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.os;
|
||||||
|
|
||||||
|
import android.os.Message;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
/* oneway */ interface IMessenger {
|
||||||
|
void send(/* in */ Message msg);
|
||||||
|
}
|
||||||
@@ -0,0 +1,575 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.os;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.util.Printer;
|
||||||
|
import android.util.Slog;
|
||||||
|
import android.util.proto.ProtoOutputStream;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class used to run a message loop for a thread. Threads by default do
|
||||||
|
* not have a message loop associated with them; to create one, call
|
||||||
|
* {@link #prepare} in the thread that is to run the loop, and then
|
||||||
|
* {@link #loop} to have it process messages until the loop is stopped.
|
||||||
|
*
|
||||||
|
* <p>Most interaction with a message loop is through the
|
||||||
|
* {@link Handler} class.
|
||||||
|
*
|
||||||
|
* <p>This is a typical example of the implementation of a Looper thread,
|
||||||
|
* using the separation of {@link #prepare} and {@link #loop} to create an
|
||||||
|
* initial Handler to communicate with the Looper.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* class LooperThread extends Thread {
|
||||||
|
* public Handler mHandler;
|
||||||
|
*
|
||||||
|
* public void run() {
|
||||||
|
* Looper.prepare();
|
||||||
|
*
|
||||||
|
* mHandler = new Handler(Looper.myLooper()) {
|
||||||
|
* public void handleMessage(Message msg) {
|
||||||
|
* // process incoming messages here
|
||||||
|
* }
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* Looper.loop();
|
||||||
|
* }
|
||||||
|
* }</pre>
|
||||||
|
*/
|
||||||
|
public final class Looper {
|
||||||
|
/*
|
||||||
|
* API Implementation Note:
|
||||||
|
*
|
||||||
|
* This class contains the code required to set up and manage an event loop
|
||||||
|
* based on MessageQueue. APIs that affect the state of the queue should be
|
||||||
|
* defined on MessageQueue or Handler rather than on Looper itself. For example,
|
||||||
|
* idle handlers and sync barriers are defined on the queue whereas preparing the
|
||||||
|
* thread, looping, and quitting are defined on the looper.
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static final String TAG = "Looper";
|
||||||
|
|
||||||
|
private static class NoImagePreloadHolder {
|
||||||
|
// Enable/Disable verbose logging with a system prop. e.g.
|
||||||
|
// adb shell 'setprop log.looper.slow.verbose false && stop && start'
|
||||||
|
private static final boolean sVerboseLogging =
|
||||||
|
SystemProperties.getBoolean("log.looper.slow.verbose", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// sThreadLocal.get() will return null unless you've called prepare().
|
||||||
|
static final ThreadLocal<Looper> sThreadLocal = new ThreadLocal<Looper>();
|
||||||
|
private static Looper sMainLooper; // guarded by Looper.class
|
||||||
|
private static Observer sObserver;
|
||||||
|
|
||||||
|
final MessageQueue mQueue;
|
||||||
|
final Thread mThread;
|
||||||
|
private boolean mInLoop;
|
||||||
|
|
||||||
|
private Printer mLogging;
|
||||||
|
private long mTraceTag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If set, the looper will show a warning log if a message dispatch takes longer than this.
|
||||||
|
*/
|
||||||
|
private long mSlowDispatchThresholdMs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If set, the looper will show a warning log if a message delivery (actual delivery time -
|
||||||
|
* post time) takes longer than this.
|
||||||
|
*/
|
||||||
|
private long mSlowDeliveryThresholdMs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if a message delivery takes longer than {@link #mSlowDeliveryThresholdMs}.
|
||||||
|
*/
|
||||||
|
private boolean mSlowDeliveryDetected;
|
||||||
|
|
||||||
|
/** Initialize the current thread as a looper.
|
||||||
|
* This gives you a chance to create handlers that then reference
|
||||||
|
* this looper, before actually starting the loop. Be sure to call
|
||||||
|
* {@link #loop()} after calling this method, and end it by calling
|
||||||
|
* {@link #quit()}.
|
||||||
|
*/
|
||||||
|
public static void prepare() {
|
||||||
|
prepare(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void prepare(boolean quitAllowed) {
|
||||||
|
if (sThreadLocal.get() != null) {
|
||||||
|
throw new RuntimeException("Only one Looper may be created per thread");
|
||||||
|
}
|
||||||
|
sThreadLocal.set(new Looper(quitAllowed));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the current thread as a looper, marking it as an
|
||||||
|
* application's main looper. See also: {@link #prepare()}
|
||||||
|
*
|
||||||
|
* @deprecated The main looper for your application is created by the Android environment,
|
||||||
|
* so you should never need to call this function yourself.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static void prepareMainLooper() {
|
||||||
|
prepare(false);
|
||||||
|
synchronized (Looper.class) {
|
||||||
|
if (sMainLooper != null) {
|
||||||
|
throw new IllegalStateException("The main Looper has already been prepared.");
|
||||||
|
}
|
||||||
|
sMainLooper = myLooper();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the application's main looper, which lives in the main thread of the application.
|
||||||
|
*/
|
||||||
|
public static Looper getMainLooper() {
|
||||||
|
synchronized (Looper.class) {
|
||||||
|
return sMainLooper;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force the application's main looper to the given value. The main looper is typically
|
||||||
|
* configured automatically by the OS, so this capability is only intended to enable testing.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static void setMainLooperForTest(@NonNull Looper looper) {
|
||||||
|
synchronized (Looper.class) {
|
||||||
|
sMainLooper = Objects.requireNonNull(looper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the application's main looper to be undefined. The main looper is typically
|
||||||
|
* configured automatically by the OS, so this capability is only intended to enable testing.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static void clearMainLooperForTest() {
|
||||||
|
synchronized (Looper.class) {
|
||||||
|
sMainLooper = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the transaction observer for all Loopers in this process.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static void setObserver(@Nullable Observer observer) {
|
||||||
|
sObserver = observer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Poll and deliver single message, return true if the outer loop should continue.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({"UnusedTokenOfOriginalCallingIdentity",
|
||||||
|
"ClearIdentityCallNotFollowedByTryFinally"})
|
||||||
|
private static boolean loopOnce(final Looper me,
|
||||||
|
final long ident, final int thresholdOverride) {
|
||||||
|
Message msg = me.mQueue.next(); // might block
|
||||||
|
if (msg == null) {
|
||||||
|
// No message indicates that the message queue is quitting.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This must be in a local variable, in case a UI event sets the logger
|
||||||
|
final Printer logging = me.mLogging;
|
||||||
|
if (logging != null) {
|
||||||
|
logging.println(">>>>> Dispatching to " + msg.target + " "
|
||||||
|
+ msg.callback + ": " + msg.what);
|
||||||
|
}
|
||||||
|
// Make sure the observer won't change while processing a transaction.
|
||||||
|
final Observer observer = sObserver;
|
||||||
|
|
||||||
|
final long traceTag = me.mTraceTag;
|
||||||
|
long slowDispatchThresholdMs = me.mSlowDispatchThresholdMs;
|
||||||
|
long slowDeliveryThresholdMs = me.mSlowDeliveryThresholdMs;
|
||||||
|
|
||||||
|
final boolean hasOverride = thresholdOverride >= 0;
|
||||||
|
if (hasOverride) {
|
||||||
|
slowDispatchThresholdMs = thresholdOverride;
|
||||||
|
slowDeliveryThresholdMs = thresholdOverride;
|
||||||
|
}
|
||||||
|
final boolean logSlowDelivery = (slowDeliveryThresholdMs > 0 || hasOverride)
|
||||||
|
&& (msg.when > 0);
|
||||||
|
final boolean logSlowDispatch = (slowDispatchThresholdMs > 0 || hasOverride);
|
||||||
|
|
||||||
|
final boolean needStartTime = logSlowDelivery || logSlowDispatch;
|
||||||
|
final boolean needEndTime = logSlowDispatch;
|
||||||
|
|
||||||
|
final long dispatchStart = needStartTime ? SystemClock.uptimeMillis() : 0;
|
||||||
|
final long dispatchEnd;
|
||||||
|
Object token = null;
|
||||||
|
if (observer != null) {
|
||||||
|
token = observer.messageDispatchStarting();
|
||||||
|
}
|
||||||
|
long origWorkSource = ThreadLocalWorkSource.setUid(msg.workSourceUid);
|
||||||
|
try {
|
||||||
|
msg.target.dispatchMessage(msg);
|
||||||
|
if (observer != null) {
|
||||||
|
observer.messageDispatched(token, msg);
|
||||||
|
}
|
||||||
|
} catch (Exception exception) {
|
||||||
|
if (observer != null) {
|
||||||
|
observer.dispatchingThrewException(token, msg, exception);
|
||||||
|
}
|
||||||
|
Log.e(TAG, "Loop handler threw", exception);
|
||||||
|
// throw exception;
|
||||||
|
} finally {
|
||||||
|
dispatchEnd = needEndTime ? SystemClock.uptimeMillis() : 0;
|
||||||
|
ThreadLocalWorkSource.restore(origWorkSource);
|
||||||
|
}
|
||||||
|
if (logSlowDelivery) {
|
||||||
|
boolean slow = false;
|
||||||
|
|
||||||
|
if (!me.mSlowDeliveryDetected || NoImagePreloadHolder.sVerboseLogging) {
|
||||||
|
slow = showSlowLog(slowDeliveryThresholdMs, msg.when, dispatchStart,
|
||||||
|
"delivery", msg);
|
||||||
|
}
|
||||||
|
if (me.mSlowDeliveryDetected) {
|
||||||
|
if (!slow && (dispatchStart - msg.when) <= 10) {
|
||||||
|
Slog.w(TAG, "Drained");
|
||||||
|
me.mSlowDeliveryDetected = false;
|
||||||
|
}
|
||||||
|
} else if (slow) {
|
||||||
|
// A slow delivery is detected, suppressing further logs unless verbose logging
|
||||||
|
// is enabled.
|
||||||
|
me.mSlowDeliveryDetected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (logSlowDispatch) {
|
||||||
|
showSlowLog(slowDispatchThresholdMs, dispatchStart, dispatchEnd, "dispatch", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (logging != null) {
|
||||||
|
logging.println("<<<<< Finished to " + msg.target + " " + msg.callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure that during the course of dispatching the
|
||||||
|
// identity of the thread wasn't corrupted.
|
||||||
|
// final long newIdent = Binder.clearCallingIdentity();
|
||||||
|
// if (ident != newIdent) {
|
||||||
|
// Log.wtf(TAG, "Thread identity changed from 0x"
|
||||||
|
// + Long.toHexString(ident) + " to 0x"
|
||||||
|
// + Long.toHexString(newIdent) + " while dispatching to "
|
||||||
|
// + msg.target.getClass().getName() + " "
|
||||||
|
// + msg.callback + " what=" + msg.what);
|
||||||
|
// }
|
||||||
|
|
||||||
|
msg.recycleUnchecked();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the message queue in this thread. Be sure to call
|
||||||
|
* {@link #quit()} to end the loop.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({"UnusedTokenOfOriginalCallingIdentity",
|
||||||
|
"ClearIdentityCallNotFollowedByTryFinally",
|
||||||
|
"ResultOfClearIdentityCallNotStoredInVariable"})
|
||||||
|
public static void loop() {
|
||||||
|
final Looper me = myLooper();
|
||||||
|
if (me == null) {
|
||||||
|
throw new RuntimeException("No Looper; Looper.prepare() wasn't called on this thread.");
|
||||||
|
}
|
||||||
|
if (me.mInLoop) {
|
||||||
|
Slog.w(TAG, "Loop again would have the queued messages be executed"
|
||||||
|
+ " before this one completed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
me.mInLoop = true;
|
||||||
|
|
||||||
|
// Make sure the identity of this thread is that of the local process,
|
||||||
|
// and keep track of what that identity token actually is.
|
||||||
|
// Binder.clearCallingIdentity();
|
||||||
|
// final long ident = Binder.clearCallingIdentity();
|
||||||
|
final long ident = 0;
|
||||||
|
|
||||||
|
// Allow overriding a threshold with a system prop. e.g.
|
||||||
|
// adb shell 'setprop log.looper.1000.main.slow 1 && stop && start'
|
||||||
|
final int thresholdOverride = getThresholdOverride();
|
||||||
|
|
||||||
|
me.mSlowDeliveryDetected = false;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
if (!loopOnce(me, ident, thresholdOverride)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getThresholdOverride() {
|
||||||
|
return -1;
|
||||||
|
// // Allow overriding the threshold for all processes' main looper with a system prop.
|
||||||
|
// // e.g. adb shell 'setprop log.looper.any.main.slow 1 && stop && start'
|
||||||
|
// if (myLooper() == getMainLooper()) {
|
||||||
|
// final int globalOverride = SystemProperties.getInt("log.looper.any.main.slow", -1);
|
||||||
|
// if (globalOverride >= 0) {
|
||||||
|
// return globalOverride;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Allow overriding the threshold for all threads within a process with a system prop.
|
||||||
|
// // e.g. adb shell 'setprop log.looper.1000.any.slow 1 && stop && start'
|
||||||
|
// final int processOverride = SystemProperties.getInt("log.looper."
|
||||||
|
// + Process.myUid() + ".any.slow", -1);
|
||||||
|
// if (processOverride >= 0) {
|
||||||
|
// return processOverride;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return SystemProperties.getInt("log.looper."
|
||||||
|
// + Process.myUid() + "."
|
||||||
|
// + Thread.currentThread().getName()
|
||||||
|
// + ".slow", -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getThresholdOverride$ravenwood() {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getThreadGroup() {
|
||||||
|
int threadGroup = Process.THREAD_GROUP_DEFAULT;
|
||||||
|
|
||||||
|
if (!Process.isIsolated()) {
|
||||||
|
threadGroup = Process.getProcessGroup(Process.myTid());
|
||||||
|
}
|
||||||
|
return threadGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String threadGroupToString(int threadGroup) {
|
||||||
|
switch (threadGroup) {
|
||||||
|
case Process.THREAD_GROUP_SYSTEM:
|
||||||
|
return "SYSTEM";
|
||||||
|
case Process.THREAD_GROUP_AUDIO_APP:
|
||||||
|
return "AUDIO_APP";
|
||||||
|
case Process.THREAD_GROUP_AUDIO_SYS:
|
||||||
|
return "AUDIO_SYS";
|
||||||
|
case Process.THREAD_GROUP_TOP_APP:
|
||||||
|
return "TOP_APP";
|
||||||
|
case Process.THREAD_GROUP_RT_APP:
|
||||||
|
return "RT_APP";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean showSlowLog(long threshold, long measureStart, long measureEnd,
|
||||||
|
String what, Message msg) {
|
||||||
|
final long actualTime = measureEnd - measureStart;
|
||||||
|
if (actualTime < threshold) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String name = /* Process.myProcessName() */ "Stub!";
|
||||||
|
String threadGroup = threadGroupToString(getThreadGroup());
|
||||||
|
boolean isMain = myLooper() == getMainLooper();
|
||||||
|
|
||||||
|
// For slow delivery, the current message isn't really important, but log it anyway.
|
||||||
|
Slog.w(TAG, "Slow " + what + " took " + actualTime + "ms "
|
||||||
|
+ Thread.currentThread().getName() + " app=" + name
|
||||||
|
+ " main=" + isMain + " group=" + threadGroup
|
||||||
|
+ " h=" + msg.target.getClass().getName() + " c=" + msg.callback
|
||||||
|
+ " m=" + msg.what);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the Looper object associated with the current thread. Returns
|
||||||
|
* null if the calling thread is not associated with a Looper.
|
||||||
|
*/
|
||||||
|
public static @Nullable Looper myLooper() {
|
||||||
|
return sThreadLocal.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the {@link MessageQueue} object associated with the current
|
||||||
|
* thread. This must be called from a thread running a Looper, or a
|
||||||
|
* NullPointerException will be thrown.
|
||||||
|
*/
|
||||||
|
public static @NonNull MessageQueue myQueue() {
|
||||||
|
return myLooper().mQueue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Looper(boolean quitAllowed) {
|
||||||
|
mQueue = new MessageQueue(quitAllowed);
|
||||||
|
mThread = Thread.currentThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the current thread is this looper's thread.
|
||||||
|
*/
|
||||||
|
public boolean isCurrentThread() {
|
||||||
|
return Thread.currentThread() == mThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Control logging of messages as they are processed by this Looper. If
|
||||||
|
* enabled, a log message will be written to <var>printer</var>
|
||||||
|
* at the beginning and ending of each message dispatch, identifying the
|
||||||
|
* target Handler and message contents.
|
||||||
|
*
|
||||||
|
* @param printer A Printer object that will receive log messages, or
|
||||||
|
* null to disable message logging.
|
||||||
|
*/
|
||||||
|
public void setMessageLogging(@Nullable Printer printer) {
|
||||||
|
mLogging = printer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@hide} */
|
||||||
|
public void setTraceTag(long traceTag) {
|
||||||
|
mTraceTag = traceTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a thresholds for slow dispatch/delivery log.
|
||||||
|
* {@hide}
|
||||||
|
*/
|
||||||
|
public void setSlowLogThresholdMs(long slowDispatchThresholdMs, long slowDeliveryThresholdMs) {
|
||||||
|
mSlowDispatchThresholdMs = slowDispatchThresholdMs;
|
||||||
|
mSlowDeliveryThresholdMs = slowDeliveryThresholdMs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quits the looper.
|
||||||
|
* <p>
|
||||||
|
* Causes the {@link #loop} method to terminate without processing any
|
||||||
|
* more messages in the message queue.
|
||||||
|
* </p><p>
|
||||||
|
* Any attempt to post messages to the queue after the looper is asked to quit will fail.
|
||||||
|
* For example, the {@link Handler#sendMessage(Message)} method will return false.
|
||||||
|
* </p><p class="note">
|
||||||
|
* Using this method may be unsafe because some messages may not be delivered
|
||||||
|
* before the looper terminates. Consider using {@link #quitSafely} instead to ensure
|
||||||
|
* that all pending work is completed in an orderly manner.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @see #quitSafely
|
||||||
|
*/
|
||||||
|
public void quit() {
|
||||||
|
mQueue.quit(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quits the looper safely.
|
||||||
|
* <p>
|
||||||
|
* Causes the {@link #loop} method to terminate as soon as all remaining messages
|
||||||
|
* in the message queue that are already due to be delivered have been handled.
|
||||||
|
* However pending delayed messages with due times in the future will not be
|
||||||
|
* delivered before the loop terminates.
|
||||||
|
* </p><p>
|
||||||
|
* Any attempt to post messages to the queue after the looper is asked to quit will fail.
|
||||||
|
* For example, the {@link Handler#sendMessage(Message)} method will return false.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public void quitSafely() {
|
||||||
|
mQueue.quit(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the Thread associated with this Looper.
|
||||||
|
*
|
||||||
|
* @return The looper's thread.
|
||||||
|
*/
|
||||||
|
public @NonNull Thread getThread() {
|
||||||
|
return mThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets this looper's message queue.
|
||||||
|
*
|
||||||
|
* @return The looper's message queue.
|
||||||
|
*/
|
||||||
|
public @NonNull MessageQueue getQueue() {
|
||||||
|
return mQueue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dumps the state of the looper for debugging purposes.
|
||||||
|
*
|
||||||
|
* @param pw A printer to receive the contents of the dump.
|
||||||
|
* @param prefix A prefix to prepend to each line which is printed.
|
||||||
|
*/
|
||||||
|
public void dump(@NonNull Printer pw, @NonNull String prefix) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dumps the state of the looper for debugging purposes.
|
||||||
|
*
|
||||||
|
* @param pw A printer to receive the contents of the dump.
|
||||||
|
* @param prefix A prefix to prepend to each line which is printed.
|
||||||
|
* @param handler Only dump messages for this Handler.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public void dump(@NonNull Printer pw, @NonNull String prefix, Handler handler) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public void dumpDebug(ProtoOutputStream proto, long fieldId) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Looper (" + mThread.getName() + ", tid " + mThread.getId()
|
||||||
|
+ ") {" + Integer.toHexString(System.identityHashCode(this)) + "}";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@hide} */
|
||||||
|
public interface Observer {
|
||||||
|
/**
|
||||||
|
* Called right before a message is dispatched.
|
||||||
|
*
|
||||||
|
* <p> The token type is not specified to allow the implementation to specify its own type.
|
||||||
|
*
|
||||||
|
* @return a token used for collecting telemetry when dispatching a single message.
|
||||||
|
* The token token must be passed back exactly once to either
|
||||||
|
* {@link Observer#messageDispatched} or {@link Observer#dispatchingThrewException}
|
||||||
|
* and must not be reused again.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Object messageDispatchStarting();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a message was processed by a Handler.
|
||||||
|
*
|
||||||
|
* @param token Token obtained by previously calling
|
||||||
|
* {@link Observer#messageDispatchStarting} on the same Observer instance.
|
||||||
|
* @param msg The message that was dispatched.
|
||||||
|
*/
|
||||||
|
void messageDispatched(Object token, Message msg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an exception was thrown while processing a message.
|
||||||
|
*
|
||||||
|
* @param token Token obtained by previously calling
|
||||||
|
* {@link Observer#messageDispatchStarting} on the same Observer instance.
|
||||||
|
* @param msg The message that was dispatched and caused an exception.
|
||||||
|
* @param exception The exception that was thrown.
|
||||||
|
*/
|
||||||
|
void dispatchingThrewException(Object token, Message msg, Exception exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,630 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.os;
|
||||||
|
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
import android.util.TimeUtils;
|
||||||
|
import android.util.proto.ProtoOutputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Defines a message containing a description and arbitrary data object that can be
|
||||||
|
* sent to a {@link Handler}. This object contains two extra int fields and an
|
||||||
|
* extra object field that allow you to not do allocations in many cases.
|
||||||
|
*
|
||||||
|
* <p class="note">While the constructor of Message is public, the best way to get
|
||||||
|
* one of these is to call {@link #obtain Message.obtain()} or one of the
|
||||||
|
* {@link Handler#obtainMessage Handler.obtainMessage()} methods, which will pull
|
||||||
|
* them from a pool of recycled objects.</p>
|
||||||
|
*/
|
||||||
|
public final class Message implements Parcelable {
|
||||||
|
/**
|
||||||
|
* User-defined message code so that the recipient can identify
|
||||||
|
* what this message is about. Each {@link Handler} has its own name-space
|
||||||
|
* for message codes, so you do not need to worry about yours conflicting
|
||||||
|
* with other handlers.
|
||||||
|
*
|
||||||
|
* If not specified, this value is 0.
|
||||||
|
* Use values other than 0 to indicate custom message codes.
|
||||||
|
*/
|
||||||
|
public int what;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* arg1 and arg2 are lower-cost alternatives to using
|
||||||
|
* {@link #setData(Bundle) setData()} if you only need to store a
|
||||||
|
* few integer values.
|
||||||
|
*/
|
||||||
|
public int arg1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* arg1 and arg2 are lower-cost alternatives to using
|
||||||
|
* {@link #setData(Bundle) setData()} if you only need to store a
|
||||||
|
* few integer values.
|
||||||
|
*/
|
||||||
|
public int arg2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An arbitrary object to send to the recipient. When using
|
||||||
|
* {@link Messenger} to send the message across processes this can only
|
||||||
|
* be non-null if it contains a Parcelable of a framework class (not one
|
||||||
|
* implemented by the application). For other data transfer use
|
||||||
|
* {@link #setData}.
|
||||||
|
*
|
||||||
|
* <p>Note that Parcelable objects here are not supported prior to
|
||||||
|
* the {@link android.os.Build.VERSION_CODES#FROYO} release.
|
||||||
|
*/
|
||||||
|
public Object obj;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional Messenger where replies to this message can be sent. The
|
||||||
|
* semantics of exactly how this is used are up to the sender and
|
||||||
|
* receiver.
|
||||||
|
*/
|
||||||
|
public Messenger replyTo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates that the uid is not set;
|
||||||
|
*
|
||||||
|
* @hide Only for use within the system server.
|
||||||
|
*/
|
||||||
|
public static final int UID_NONE = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional field indicating the uid that sent the message. This is
|
||||||
|
* only valid for messages posted by a {@link Messenger}; otherwise,
|
||||||
|
* it will be -1.
|
||||||
|
*/
|
||||||
|
public int sendingUid = UID_NONE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional field indicating the uid that caused this message to be enqueued.
|
||||||
|
*
|
||||||
|
* @hide Only for use within the system server.
|
||||||
|
*/
|
||||||
|
public int workSourceUid = UID_NONE;
|
||||||
|
|
||||||
|
/** If set message is in use.
|
||||||
|
* This flag is set when the message is enqueued and remains set while it
|
||||||
|
* is delivered and afterwards when it is recycled. The flag is only cleared
|
||||||
|
* when a new message is created or obtained since that is the only time that
|
||||||
|
* applications are allowed to modify the contents of the message.
|
||||||
|
*
|
||||||
|
* It is an error to attempt to enqueue or recycle a message that is already in use.
|
||||||
|
*/
|
||||||
|
/*package*/ static final int FLAG_IN_USE = 1 << 0;
|
||||||
|
|
||||||
|
/** If set message is asynchronous */
|
||||||
|
/*package*/ static final int FLAG_ASYNCHRONOUS = 1 << 1;
|
||||||
|
|
||||||
|
/** Flags to clear in the copyFrom method */
|
||||||
|
/*package*/ static final int FLAGS_TO_CLEAR_ON_COPY_FROM = FLAG_IN_USE;
|
||||||
|
|
||||||
|
/*package*/ int flags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The targeted delivery time of this message. The time-base is
|
||||||
|
* {@link SystemClock#uptimeMillis}.
|
||||||
|
* @hide Only for use within the tests.
|
||||||
|
*/
|
||||||
|
public long when;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public long mInsertSeq;
|
||||||
|
|
||||||
|
/*package*/ Bundle data;
|
||||||
|
|
||||||
|
/*package*/ Handler target;
|
||||||
|
|
||||||
|
/*package*/ Runnable callback;
|
||||||
|
|
||||||
|
// sometimes we store linked lists of these things
|
||||||
|
/*package*/ Message next;
|
||||||
|
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public static final Object sPoolSync = new Object();
|
||||||
|
private static Message sPool;
|
||||||
|
private static int sPoolSize = 0;
|
||||||
|
|
||||||
|
private static final int MAX_POOL_SIZE = 50;
|
||||||
|
|
||||||
|
private static boolean gCheckRecycle = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a new Message instance from the global pool. Allows us to
|
||||||
|
* avoid allocating new objects in many cases.
|
||||||
|
*/
|
||||||
|
public static Message obtain() {
|
||||||
|
synchronized (sPoolSync) {
|
||||||
|
if (sPool != null) {
|
||||||
|
Message m = sPool;
|
||||||
|
sPool = m.next;
|
||||||
|
m.next = null;
|
||||||
|
m.flags = 0; // clear in-use flag
|
||||||
|
sPoolSize--;
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Message();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as {@link #obtain()}, but copies the values of an existing
|
||||||
|
* message (including its target) into the new one.
|
||||||
|
* @param orig Original message to copy.
|
||||||
|
* @return A Message object from the global pool.
|
||||||
|
*/
|
||||||
|
public static Message obtain(Message orig) {
|
||||||
|
Message m = obtain();
|
||||||
|
m.what = orig.what;
|
||||||
|
m.arg1 = orig.arg1;
|
||||||
|
m.arg2 = orig.arg2;
|
||||||
|
m.obj = orig.obj;
|
||||||
|
m.replyTo = orig.replyTo;
|
||||||
|
m.sendingUid = orig.sendingUid;
|
||||||
|
m.workSourceUid = orig.workSourceUid;
|
||||||
|
if (orig.data != null) {
|
||||||
|
m.data = new Bundle(orig.data);
|
||||||
|
}
|
||||||
|
m.target = orig.target;
|
||||||
|
m.callback = orig.callback;
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as {@link #obtain()}, but sets the value for the <em>target</em> member on the Message returned.
|
||||||
|
* @param h Handler to assign to the returned Message object's <em>target</em> member.
|
||||||
|
* @return A Message object from the global pool.
|
||||||
|
*/
|
||||||
|
public static Message obtain(Handler h) {
|
||||||
|
Message m = obtain();
|
||||||
|
m.target = h;
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as {@link #obtain(Handler)}, but assigns a callback Runnable on
|
||||||
|
* the Message that is returned.
|
||||||
|
* @param h Handler to assign to the returned Message object's <em>target</em> member.
|
||||||
|
* @param callback Runnable that will execute when the message is handled.
|
||||||
|
* @return A Message object from the global pool.
|
||||||
|
*/
|
||||||
|
public static Message obtain(Handler h, Runnable callback) {
|
||||||
|
Message m = obtain();
|
||||||
|
m.target = h;
|
||||||
|
m.callback = callback;
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as {@link #obtain()}, but sets the values for both <em>target</em> and
|
||||||
|
* <em>what</em> members on the Message.
|
||||||
|
* @param h Value to assign to the <em>target</em> member.
|
||||||
|
* @param what Value to assign to the <em>what</em> member.
|
||||||
|
* @return A Message object from the global pool.
|
||||||
|
*/
|
||||||
|
public static Message obtain(Handler h, int what) {
|
||||||
|
Message m = obtain();
|
||||||
|
m.target = h;
|
||||||
|
m.what = what;
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as {@link #obtain()}, but sets the values of the <em>target</em>, <em>what</em>, and <em>obj</em>
|
||||||
|
* members.
|
||||||
|
* @param h The <em>target</em> value to set.
|
||||||
|
* @param what The <em>what</em> value to set.
|
||||||
|
* @param obj The <em>object</em> method to set.
|
||||||
|
* @return A Message object from the global pool.
|
||||||
|
*/
|
||||||
|
public static Message obtain(Handler h, int what, Object obj) {
|
||||||
|
Message m = obtain();
|
||||||
|
m.target = h;
|
||||||
|
m.what = what;
|
||||||
|
m.obj = obj;
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as {@link #obtain()}, but sets the values of the <em>target</em>, <em>what</em>,
|
||||||
|
* <em>arg1</em>, and <em>arg2</em> members.
|
||||||
|
*
|
||||||
|
* @param h The <em>target</em> value to set.
|
||||||
|
* @param what The <em>what</em> value to set.
|
||||||
|
* @param arg1 The <em>arg1</em> value to set.
|
||||||
|
* @param arg2 The <em>arg2</em> value to set.
|
||||||
|
* @return A Message object from the global pool.
|
||||||
|
*/
|
||||||
|
public static Message obtain(Handler h, int what, int arg1, int arg2) {
|
||||||
|
Message m = obtain();
|
||||||
|
m.target = h;
|
||||||
|
m.what = what;
|
||||||
|
m.arg1 = arg1;
|
||||||
|
m.arg2 = arg2;
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as {@link #obtain()}, but sets the values of the <em>target</em>, <em>what</em>,
|
||||||
|
* <em>arg1</em>, <em>arg2</em>, and <em>obj</em> members.
|
||||||
|
*
|
||||||
|
* @param h The <em>target</em> value to set.
|
||||||
|
* @param what The <em>what</em> value to set.
|
||||||
|
* @param arg1 The <em>arg1</em> value to set.
|
||||||
|
* @param arg2 The <em>arg2</em> value to set.
|
||||||
|
* @param obj The <em>obj</em> value to set.
|
||||||
|
* @return A Message object from the global pool.
|
||||||
|
*/
|
||||||
|
public static Message obtain(Handler h, int what,
|
||||||
|
int arg1, int arg2, Object obj) {
|
||||||
|
Message m = obtain();
|
||||||
|
m.target = h;
|
||||||
|
m.what = what;
|
||||||
|
m.arg1 = arg1;
|
||||||
|
m.arg2 = arg2;
|
||||||
|
m.obj = obj;
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public static void updateCheckRecycle(int targetSdkVersion) {
|
||||||
|
if (targetSdkVersion < Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
gCheckRecycle = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a Message instance to the global pool.
|
||||||
|
* <p>
|
||||||
|
* You MUST NOT touch the Message after calling this function because it has
|
||||||
|
* effectively been freed. It is an error to recycle a message that is currently
|
||||||
|
* enqueued or that is in the process of being delivered to a Handler.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public void recycle() {
|
||||||
|
if (isInUse()) {
|
||||||
|
if (gCheckRecycle) {
|
||||||
|
throw new IllegalStateException("This message cannot be recycled because it "
|
||||||
|
+ "is still in use.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
recycleUnchecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recycles a Message that may be in-use.
|
||||||
|
* Used internally by the MessageQueue and Looper when disposing of queued Messages.
|
||||||
|
*/
|
||||||
|
void recycleUnchecked() {
|
||||||
|
// Mark the message as in use while it remains in the recycled object pool.
|
||||||
|
// Clear out all other details.
|
||||||
|
flags = FLAG_IN_USE;
|
||||||
|
what = 0;
|
||||||
|
arg1 = 0;
|
||||||
|
arg2 = 0;
|
||||||
|
obj = null;
|
||||||
|
replyTo = null;
|
||||||
|
sendingUid = UID_NONE;
|
||||||
|
workSourceUid = UID_NONE;
|
||||||
|
when = 0;
|
||||||
|
target = null;
|
||||||
|
callback = null;
|
||||||
|
data = null;
|
||||||
|
|
||||||
|
synchronized (sPoolSync) {
|
||||||
|
if (sPoolSize < MAX_POOL_SIZE) {
|
||||||
|
next = sPool;
|
||||||
|
sPool = this;
|
||||||
|
sPoolSize++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make this message like o. Performs a shallow copy of the data field.
|
||||||
|
* Does not copy the linked list fields, nor the timestamp or
|
||||||
|
* target/callback of the original message.
|
||||||
|
*/
|
||||||
|
public void copyFrom(Message o) {
|
||||||
|
this.flags = o.flags & ~FLAGS_TO_CLEAR_ON_COPY_FROM;
|
||||||
|
this.what = o.what;
|
||||||
|
this.arg1 = o.arg1;
|
||||||
|
this.arg2 = o.arg2;
|
||||||
|
this.obj = o.obj;
|
||||||
|
this.replyTo = o.replyTo;
|
||||||
|
this.sendingUid = o.sendingUid;
|
||||||
|
this.workSourceUid = o.workSourceUid;
|
||||||
|
|
||||||
|
if (o.data != null) {
|
||||||
|
this.data = (Bundle) o.data.clone();
|
||||||
|
} else {
|
||||||
|
this.data = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the targeted delivery time of this message, in milliseconds.
|
||||||
|
*/
|
||||||
|
public long getWhen() {
|
||||||
|
return when;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTarget(Handler target) {
|
||||||
|
this.target = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the {@link android.os.Handler Handler} implementation that
|
||||||
|
* will receive this message. The object must implement
|
||||||
|
* {@link android.os.Handler#handleMessage(android.os.Message)
|
||||||
|
* Handler.handleMessage()}. Each Handler has its own name-space for
|
||||||
|
* message codes, so you do not need to
|
||||||
|
* worry about yours conflicting with other handlers.
|
||||||
|
*/
|
||||||
|
public Handler getTarget() {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve callback object that will execute when this message is handled.
|
||||||
|
* This object must implement Runnable. This is called by
|
||||||
|
* the <em>target</em> {@link Handler} that is receiving this Message to
|
||||||
|
* dispatch it. If
|
||||||
|
* not set, the message will be dispatched to the receiving Handler's
|
||||||
|
* {@link Handler#handleMessage(Message)}.
|
||||||
|
*/
|
||||||
|
public Runnable getCallback() {
|
||||||
|
return callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public Message setCallback(Runnable r) {
|
||||||
|
callback = r;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains a Bundle of arbitrary data associated with this
|
||||||
|
* event, lazily creating it if necessary. Set this value by calling
|
||||||
|
* {@link #setData(Bundle)}. Note that when transferring data across
|
||||||
|
* processes via {@link Messenger}, you will need to set your ClassLoader
|
||||||
|
* on the Bundle via {@link Bundle#setClassLoader(ClassLoader)
|
||||||
|
* Bundle.setClassLoader()} so that it can instantiate your objects when
|
||||||
|
* you retrieve them.
|
||||||
|
* @see #peekData()
|
||||||
|
* @see #setData(Bundle)
|
||||||
|
*/
|
||||||
|
public Bundle getData() {
|
||||||
|
if (data == null) {
|
||||||
|
data = new Bundle();
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Like getData(), but does not lazily create the Bundle. A null
|
||||||
|
* is returned if the Bundle does not already exist. See
|
||||||
|
* {@link #getData} for further information on this.
|
||||||
|
* @see #getData()
|
||||||
|
* @see #setData(Bundle)
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Bundle peekData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a Bundle of arbitrary data values. Use arg1 and arg2 members
|
||||||
|
* as a lower cost way to send a few simple integer values, if you can.
|
||||||
|
* @see #getData()
|
||||||
|
* @see #peekData()
|
||||||
|
*/
|
||||||
|
public void setData(Bundle data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Chainable setter for {@link #what}
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public Message setWhat(int what) {
|
||||||
|
this.what = what;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends this Message to the Handler specified by {@link #getTarget}.
|
||||||
|
* Throws a null pointer exception if this field has not been set.
|
||||||
|
*/
|
||||||
|
public void sendToTarget() {
|
||||||
|
target.sendMessage(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the message is asynchronous, meaning that it is not
|
||||||
|
* subject to {@link Looper} synchronization barriers.
|
||||||
|
*
|
||||||
|
* @return True if the message is asynchronous.
|
||||||
|
*
|
||||||
|
* @see #setAsynchronous(boolean)
|
||||||
|
*/
|
||||||
|
public boolean isAsynchronous() {
|
||||||
|
return (flags & FLAG_ASYNCHRONOUS) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether the message is asynchronous, meaning that it is not
|
||||||
|
* subject to {@link Looper} synchronization barriers.
|
||||||
|
* <p>
|
||||||
|
* Certain operations, such as view invalidation, may introduce synchronization
|
||||||
|
* barriers into the {@link Looper}'s message queue to prevent subsequent messages
|
||||||
|
* from being delivered until some condition is met. In the case of view invalidation,
|
||||||
|
* messages which are posted after a call to {@link android.view.View#invalidate}
|
||||||
|
* are suspended by means of a synchronization barrier until the next frame is
|
||||||
|
* ready to be drawn. The synchronization barrier ensures that the invalidation
|
||||||
|
* request is completely handled before resuming.
|
||||||
|
* </p><p>
|
||||||
|
* Asynchronous messages are exempt from synchronization barriers. They typically
|
||||||
|
* represent interrupts, input events, and other signals that must be handled independently
|
||||||
|
* even while other work has been suspended.
|
||||||
|
* </p><p>
|
||||||
|
* Note that asynchronous messages may be delivered out of order with respect to
|
||||||
|
* synchronous messages although they are always delivered in order among themselves.
|
||||||
|
* If the relative order of these messages matters then they probably should not be
|
||||||
|
* asynchronous in the first place. Use with caution.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param async True if the message is asynchronous.
|
||||||
|
*
|
||||||
|
* @see #isAsynchronous()
|
||||||
|
*/
|
||||||
|
public void setAsynchronous(boolean async) {
|
||||||
|
if (async) {
|
||||||
|
flags |= FLAG_ASYNCHRONOUS;
|
||||||
|
} else {
|
||||||
|
flags &= ~FLAG_ASYNCHRONOUS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*package*/ boolean isInUse() {
|
||||||
|
return ((flags & FLAG_IN_USE) == FLAG_IN_USE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*package*/ void markInUse() {
|
||||||
|
flags |= FLAG_IN_USE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Constructor (but the preferred way to get a Message is to call {@link #obtain() Message.obtain()}).
|
||||||
|
*/
|
||||||
|
public Message() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return toString(SystemClock.uptimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
String toString(long now) {
|
||||||
|
StringBuilder b = new StringBuilder();
|
||||||
|
b.append("{ when=");
|
||||||
|
TimeUtils.formatDuration(when - now, b);
|
||||||
|
|
||||||
|
if (target != null) {
|
||||||
|
if (callback != null) {
|
||||||
|
b.append(" callback=");
|
||||||
|
b.append(callback.getClass().getName());
|
||||||
|
} else {
|
||||||
|
b.append(" what=");
|
||||||
|
b.append(what);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg1 != 0) {
|
||||||
|
b.append(" arg1=");
|
||||||
|
b.append(arg1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg2 != 0) {
|
||||||
|
b.append(" arg2=");
|
||||||
|
b.append(arg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj != null) {
|
||||||
|
b.append(" obj=");
|
||||||
|
b.append(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
b.append(" target=");
|
||||||
|
b.append(target.getClass().getName());
|
||||||
|
} else {
|
||||||
|
b.append(" barrier=");
|
||||||
|
b.append(arg1);
|
||||||
|
}
|
||||||
|
|
||||||
|
b.append(" }");
|
||||||
|
return b.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final @android.annotation.NonNull Parcelable.Creator<Message> CREATOR
|
||||||
|
= new Parcelable.Creator<Message>() {
|
||||||
|
public Message createFromParcel(Parcel source) {
|
||||||
|
Message msg = Message.obtain();
|
||||||
|
msg.readFromParcel(source);
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Message[] newArray(int size) {
|
||||||
|
return new Message[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
if (callback != null) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"Can't marshal callbacks across processes.");
|
||||||
|
}
|
||||||
|
dest.writeInt(what);
|
||||||
|
dest.writeInt(arg1);
|
||||||
|
dest.writeInt(arg2);
|
||||||
|
if (obj != null) {
|
||||||
|
try {
|
||||||
|
Parcelable p = (Parcelable)obj;
|
||||||
|
dest.writeInt(1);
|
||||||
|
dest.writeParcelable(p, flags);
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"Can't marshal non-Parcelable objects across processes.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dest.writeInt(0);
|
||||||
|
}
|
||||||
|
dest.writeLong(when);
|
||||||
|
dest.writeBundle(data);
|
||||||
|
Messenger.writeMessengerOrNullToParcel(replyTo, dest);
|
||||||
|
dest.writeInt(sendingUid);
|
||||||
|
dest.writeInt(workSourceUid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readFromParcel(Parcel source) {
|
||||||
|
what = source.readInt();
|
||||||
|
arg1 = source.readInt();
|
||||||
|
arg2 = source.readInt();
|
||||||
|
if (source.readInt() != 0) {
|
||||||
|
obj = source.readParcelable(getClass().getClassLoader());
|
||||||
|
}
|
||||||
|
when = source.readLong();
|
||||||
|
data = source.readBundle();
|
||||||
|
replyTo = Messenger.readMessengerOrNullFromParcel(source);
|
||||||
|
sendingUid = source.readInt();
|
||||||
|
workSourceUid = source.readInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -42,19 +42,19 @@ public class SystemProperties {
|
|||||||
return native_get(key);
|
return native_get(key);
|
||||||
}
|
}
|
||||||
private static int native_get_int(String key, int def) {
|
private static int native_get_int(String key, int def) {
|
||||||
if(configModule.hasProperty(key))
|
if(!configModule.hasProperty(key))
|
||||||
return def;
|
return def;
|
||||||
else
|
else
|
||||||
return configModule.getIntProperty(key);
|
return configModule.getIntProperty(key);
|
||||||
}
|
}
|
||||||
private static long native_get_long(String key, long def) {
|
private static long native_get_long(String key, long def) {
|
||||||
if(configModule.hasProperty(key))
|
if(!configModule.hasProperty(key))
|
||||||
return def;
|
return def;
|
||||||
else
|
else
|
||||||
return configModule.getLongProperty(key);
|
return configModule.getLongProperty(key);
|
||||||
}
|
}
|
||||||
private static boolean native_get_boolean(String key, boolean def) {
|
private static boolean native_get_boolean(String key, boolean def) {
|
||||||
if(configModule.hasProperty(key))
|
if(!configModule.hasProperty(key))
|
||||||
return def;
|
return def;
|
||||||
else
|
else
|
||||||
return configModule.getBooleanProperty(key);
|
return configModule.getBooleanProperty(key);
|
||||||
@@ -123,4 +123,4 @@ public class SystemProperties {
|
|||||||
}
|
}
|
||||||
native_set(key, val);
|
native_set(key, val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.os;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tracks who triggered the work currently executed on this thread.
|
||||||
|
*
|
||||||
|
* <p>ThreadLocalWorkSource is automatically updated inside system server for incoming/outgoing
|
||||||
|
* binder calls and messages posted to handler threads.
|
||||||
|
*
|
||||||
|
* <p>ThreadLocalWorkSource can also be set manually if needed to refine the WorkSource.
|
||||||
|
*
|
||||||
|
* <p>Example:
|
||||||
|
* <ul>
|
||||||
|
* <li>Bluetooth process calls {@link PowerManager#isInteractive()} API on behalf of app foo.
|
||||||
|
* <li>ThreadLocalWorkSource will be automatically set to the UID of foo.
|
||||||
|
* <li>Any code on the thread handling {@link PowerManagerService#isInteractive()} can call
|
||||||
|
* {@link ThreadLocalWorkSource#getUid()} to blame any resource used to handle this call.
|
||||||
|
* <li>If a message is posted from the binder thread, the code handling the message can also call
|
||||||
|
* {@link ThreadLocalWorkSource#getUid()} and it will return the UID of foo since the work source is
|
||||||
|
* automatically propagated.
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @hide Only for use within system server.
|
||||||
|
*/
|
||||||
|
public final class ThreadLocalWorkSource {
|
||||||
|
public static final int UID_NONE = Message.UID_NONE;
|
||||||
|
private static final ThreadLocal<int []> sWorkSourceUid =
|
||||||
|
ThreadLocal.withInitial(() -> new int[] {UID_NONE});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the UID to blame for the code currently executed on this thread.
|
||||||
|
*
|
||||||
|
* <p>This UID is set automatically by common frameworks (e.g. Binder and Handler frameworks)
|
||||||
|
* and automatically propagated inside system server.
|
||||||
|
* <p>It can also be set manually using {@link #setUid(int)}.
|
||||||
|
*/
|
||||||
|
public static int getUid() {
|
||||||
|
return sWorkSourceUid.get()[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the UID to blame for the code currently executed on this thread.
|
||||||
|
*
|
||||||
|
* <p>Inside system server, this UID will be automatically propagated.
|
||||||
|
* <p>It will be used to attribute future resources used on this thread (e.g. binder
|
||||||
|
* transactions or processing handler messages) and on any other threads the UID is propagated
|
||||||
|
* to.
|
||||||
|
*
|
||||||
|
* @return a token that can be used to restore the state.
|
||||||
|
*/
|
||||||
|
public static long setUid(int uid) {
|
||||||
|
final long token = getToken();
|
||||||
|
sWorkSourceUid.get()[0] = uid;
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restores the state using the provided token.
|
||||||
|
*/
|
||||||
|
public static void restore(long token) {
|
||||||
|
sWorkSourceUid.get()[0] = parseUidFromToken(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the stored work source uid.
|
||||||
|
*
|
||||||
|
* <p>This method should be used when we do not know who to blame. If the UID to blame is the
|
||||||
|
* UID of the current process, it is better to attribute the work to the current process
|
||||||
|
* explicitly instead of clearing the work source:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* ThreadLocalWorkSource.setUid(Process.myUid());
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @return a token that can be used to restore the state.
|
||||||
|
*/
|
||||||
|
public static long clear() {
|
||||||
|
return setUid(UID_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int parseUidFromToken(long token) {
|
||||||
|
return (int) token;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static long getToken() {
|
||||||
|
return sWorkSourceUid.get()[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
private ThreadLocalWorkSource() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
package android.os.shadows;
|
||||||
|
// package org.robolectric.res.android;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A unique id per object registry. Used to emulate android platform behavior of storing a long
|
||||||
|
* which represents a pointer to an object.
|
||||||
|
*/
|
||||||
|
public class NativeObjRegistry<T> {
|
||||||
|
|
||||||
|
private static final int INITIAL_ID = 1;
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final boolean debug;
|
||||||
|
private final HashMap<Long, T> nativeObjToIdMap = new HashMap<Long, T>();
|
||||||
|
private final Map<Long, DebugInfo> idToDebugInfoMap;
|
||||||
|
|
||||||
|
private long nextId = INITIAL_ID;
|
||||||
|
|
||||||
|
public NativeObjRegistry(Class<T> theClass) {
|
||||||
|
this(theClass, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NativeObjRegistry(Class<T> theClass, boolean debug) {
|
||||||
|
this(theClass.getSimpleName(), debug);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NativeObjRegistry(String name) {
|
||||||
|
this(name, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NativeObjRegistry(String name, boolean debug) {
|
||||||
|
this.name = name;
|
||||||
|
this.debug = debug;
|
||||||
|
this.idToDebugInfoMap = debug ? new HashMap<>() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long getNativeObjectId(T o) {
|
||||||
|
for(Map.Entry<Long, T> entry : nativeObjToIdMap.entrySet()) {
|
||||||
|
if (o == entry.getValue())
|
||||||
|
return entry.getKey();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register and assign a new unique native id for given object (representing a C memory pointer).
|
||||||
|
*
|
||||||
|
* @throws IllegalStateException if the object was previously registered
|
||||||
|
*/
|
||||||
|
public synchronized long register(T o) {
|
||||||
|
if (o == null)
|
||||||
|
throw new IllegalStateException("Object must not be null");
|
||||||
|
Long nativeId = getNativeObjectId(o);
|
||||||
|
if (nativeId != null) {
|
||||||
|
if (debug) {
|
||||||
|
DebugInfo debugInfo = idToDebugInfoMap.get(nativeId);
|
||||||
|
if (debugInfo != null) {
|
||||||
|
System.out.printf(
|
||||||
|
"NativeObjRegistry %s: register %d -> %s already registered:%n", name, nativeId, o);
|
||||||
|
debugInfo.registrationTrace.printStackTrace(System.out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalStateException("Object was previously registered with id " + nativeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
nativeId = nextId;
|
||||||
|
if (debug) {
|
||||||
|
System.out.printf("NativeObjRegistry %s: register %d -> %s%n", name, nativeId, o);
|
||||||
|
idToDebugInfoMap.put(nativeId, new DebugInfo(new Trace()));
|
||||||
|
}
|
||||||
|
nativeObjToIdMap.put(nativeId, o);
|
||||||
|
nextId++;
|
||||||
|
return nativeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregister an object previously registered with {@link #register(Object)}.
|
||||||
|
*
|
||||||
|
* @param nativeId the unique id (representing a C memory pointer) of the object to unregister.
|
||||||
|
* @throws IllegalStateException if the object was never registered, or was previously
|
||||||
|
* unregistered.
|
||||||
|
*/
|
||||||
|
public synchronized T unregister(long nativeId) {
|
||||||
|
T o = nativeObjToIdMap.remove(nativeId);
|
||||||
|
if (debug) {
|
||||||
|
System.out.printf("NativeObjRegistry %s: unregister %d -> %s%n", name, nativeId, o);
|
||||||
|
new RuntimeException("unregister debug").printStackTrace(System.out);
|
||||||
|
}
|
||||||
|
if (o == null) {
|
||||||
|
if (debug) {
|
||||||
|
DebugInfo debugInfo = idToDebugInfoMap.get(nativeId);
|
||||||
|
debugInfo.unregistrationTraces.add(new Trace());
|
||||||
|
if (debugInfo.unregistrationTraces.size() > 1) {
|
||||||
|
System.out.format("NativeObjRegistry %s: Too many unregistrations:%n", name);
|
||||||
|
for (Trace unregistration : debugInfo.unregistrationTraces) {
|
||||||
|
unregistration.printStackTrace(System.out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalStateException(
|
||||||
|
nativeId + " has already been removed (or was never registered)");
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Retrieve the native object for given id. Throws if object with that id cannot be found */
|
||||||
|
public synchronized T getNativeObject(long nativeId) {
|
||||||
|
T object = nativeObjToIdMap.get(nativeId);
|
||||||
|
if (object != null) {
|
||||||
|
return object;
|
||||||
|
} else {
|
||||||
|
throw new NullPointerException(
|
||||||
|
String.format(
|
||||||
|
"Could not find object with nativeId: %d. Currently registered ids: %s",
|
||||||
|
nativeId, nativeObjToIdMap.keySet()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the native object for the given id.
|
||||||
|
*
|
||||||
|
* @throws IllegalStateException if no object was registered with the given id before
|
||||||
|
*/
|
||||||
|
public synchronized void update(long nativeId, T o) {
|
||||||
|
T previous = nativeObjToIdMap.get(nativeId);
|
||||||
|
if (previous == null) {
|
||||||
|
throw new IllegalStateException("Native id " + nativeId + " was never registered");
|
||||||
|
}
|
||||||
|
if (debug) {
|
||||||
|
System.out.printf("NativeObjRegistry %s: update %d -> %s%n", name, nativeId, o);
|
||||||
|
idToDebugInfoMap.put(nativeId, new DebugInfo(new Trace()));
|
||||||
|
}
|
||||||
|
nativeObjToIdMap.put(nativeId, o);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similar to {@link #getNativeObject(long)} but returns null if object with given id cannot be
|
||||||
|
* found.
|
||||||
|
*/
|
||||||
|
public synchronized T peekNativeObject(long nativeId) {
|
||||||
|
return nativeObjToIdMap.get(nativeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** WARNING -- dangerous! Call {@link #unregister(long)} instead! */
|
||||||
|
public synchronized void clear() {
|
||||||
|
nextId = INITIAL_ID;
|
||||||
|
nativeObjToIdMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class DebugInfo {
|
||||||
|
final Trace registrationTrace;
|
||||||
|
final List<Trace> unregistrationTraces = new ArrayList<>();
|
||||||
|
|
||||||
|
public DebugInfo(Trace trace) {
|
||||||
|
registrationTrace = trace;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Trace extends Throwable {
|
||||||
|
|
||||||
|
private Trace() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package android.os.shadows;
|
||||||
|
// package org.robolectric.shadows;
|
||||||
|
// and badly gutted
|
||||||
|
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.os.MessageQueue;
|
||||||
|
import android.os.MessageQueue.IdleHandler;
|
||||||
|
import android.os.SystemClock;
|
||||||
|
import android.util.Log;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The shadow {@link} MessageQueue} for {@link LooperMode.Mode.PAUSED}
|
||||||
|
*
|
||||||
|
* <p>This class should not be referenced directly. Use {@link ShadowMessageQueue} instead.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("SynchronizeOnNonFinalField")
|
||||||
|
public class ShadowPausedMessageQueue {
|
||||||
|
|
||||||
|
// just use this class as the native object
|
||||||
|
private static NativeObjRegistry<ShadowPausedMessageQueue> nativeQueueRegistry =
|
||||||
|
new NativeObjRegistry<ShadowPausedMessageQueue>(ShadowPausedMessageQueue.class);
|
||||||
|
private boolean isPolling = false;
|
||||||
|
private Exception uncaughtException = null;
|
||||||
|
|
||||||
|
// shadow constructor instead of nativeInit because nativeInit signature has changed across SDK
|
||||||
|
// versions
|
||||||
|
public static long nativeInit() {
|
||||||
|
return nativeQueueRegistry.register(new ShadowPausedMessageQueue());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void nativeDestroy(long ptr) {
|
||||||
|
nativeQueueRegistry.unregister(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void nativePollOnce(long ptr, int timeoutMillis) {
|
||||||
|
ShadowPausedMessageQueue obj = nativeQueueRegistry.getNativeObject(ptr);
|
||||||
|
obj.nativePollOnce(timeoutMillis);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void nativePollOnce(int timeoutMillis) {
|
||||||
|
if (timeoutMillis == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
synchronized (this) {
|
||||||
|
isPolling = true;
|
||||||
|
try {
|
||||||
|
if (timeoutMillis < 0) {
|
||||||
|
this.wait();
|
||||||
|
} else {
|
||||||
|
this.wait(timeoutMillis);
|
||||||
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
isPolling = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void nativeWake(long ptr) {
|
||||||
|
ShadowPausedMessageQueue obj = nativeQueueRegistry.getNativeObject(ptr);
|
||||||
|
synchronized (obj) {
|
||||||
|
obj.notifyAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean nativeIsPolling(long ptr) {
|
||||||
|
return nativeQueueRegistry.getNativeObject(ptr).isPolling;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -9,8 +9,10 @@ import android.content.Context
|
|||||||
class PreferenceManager {
|
class PreferenceManager {
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getDefaultSharedPreferences(context: Context)
|
fun getDefaultSharedPreferences(context: Context) =
|
||||||
= context.getSharedPreferences(context.applicationInfo.packageName,
|
context.getSharedPreferences(
|
||||||
Context.MODE_PRIVATE)!!
|
context.applicationInfo.packageName,
|
||||||
|
Context.MODE_PRIVATE,
|
||||||
|
)!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,291 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2012 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package android.support.v4.content;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.StatFs;
|
|
||||||
import android.support.v4.os.EnvironmentCompat;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper for accessing features in {@link android.content.Context}
|
|
||||||
* introduced after API level 4 in a backwards compatible fashion.
|
|
||||||
*/
|
|
||||||
public class ContextCompat {
|
|
||||||
/**
|
|
||||||
* Start a set of activities as a synthesized task stack, if able.
|
|
||||||
*
|
|
||||||
* <p>In API level 11 (Android 3.0/Honeycomb) the recommended conventions for
|
|
||||||
* app navigation using the back key changed. The back key's behavior is local
|
|
||||||
* to the current task and does not capture navigation across different tasks.
|
|
||||||
* Navigating across tasks and easily reaching the previous task is accomplished
|
|
||||||
* through the "recents" UI, accessible through the software-provided Recents key
|
|
||||||
* on the navigation or system bar. On devices with the older hardware button configuration
|
|
||||||
* the recents UI can be accessed with a long press on the Home key.</p>
|
|
||||||
*
|
|
||||||
* <p>When crossing from one task stack to another post-Android 3.0,
|
|
||||||
* the application should synthesize a back stack/history for the new task so that
|
|
||||||
* the user may navigate out of the new task and back to the Launcher by repeated
|
|
||||||
* presses of the back key. Back key presses should not navigate across task stacks.</p>
|
|
||||||
*
|
|
||||||
* <p>startActivities provides a mechanism for constructing a synthetic task stack of
|
|
||||||
* multiple activities. If the underlying API is not available on the system this method
|
|
||||||
* will return false.</p>
|
|
||||||
*
|
|
||||||
* @param context Start activities using this activity as the starting context
|
|
||||||
* @param intents Array of intents defining the activities that will be started. The element
|
|
||||||
* length-1 will correspond to the top activity on the resulting task stack.
|
|
||||||
* @return true if the underlying API was available and the call was successful, false otherwise
|
|
||||||
*/
|
|
||||||
public static boolean startActivities(Context context, Intent[] intents) {
|
|
||||||
return startActivities(context, intents, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Start a set of activities as a synthesized task stack, if able.
|
|
||||||
*
|
|
||||||
* <p>In API level 11 (Android 3.0/Honeycomb) the recommended conventions for
|
|
||||||
* app navigation using the back key changed. The back key's behavior is local
|
|
||||||
* to the current task and does not capture navigation across different tasks.
|
|
||||||
* Navigating across tasks and easily reaching the previous task is accomplished
|
|
||||||
* through the "recents" UI, accessible through the software-provided Recents key
|
|
||||||
* on the navigation or system bar. On devices with the older hardware button configuration
|
|
||||||
* the recents UI can be accessed with a long press on the Home key.</p>
|
|
||||||
*
|
|
||||||
* <p>When crossing from one task stack to another post-Android 3.0,
|
|
||||||
* the application should synthesize a back stack/history for the new task so that
|
|
||||||
* the user may navigate out of the new task and back to the Launcher by repeated
|
|
||||||
* presses of the back key. Back key presses should not navigate across task stacks.</p>
|
|
||||||
*
|
|
||||||
* <p>startActivities provides a mechanism for constructing a synthetic task stack of
|
|
||||||
* multiple activities. If the underlying API is not available on the system this method
|
|
||||||
* will return false.</p>
|
|
||||||
*
|
|
||||||
* @param context Start activities using this activity as the starting context
|
|
||||||
* @param intents Array of intents defining the activities that will be started. The element
|
|
||||||
* length-1 will correspond to the top activity on the resulting task stack.
|
|
||||||
* @param options Additional options for how the Activity should be started.
|
|
||||||
* See {@link android.content.Context#startActivity(Intent, Bundle)
|
|
||||||
* @return true if the underlying API was available and the call was successful, false otherwise
|
|
||||||
*/
|
|
||||||
public static boolean startActivities(Context context, Intent[] intents,
|
|
||||||
Bundle options) {
|
|
||||||
context.startActivities(intents, options);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns absolute paths to application-specific directories on all
|
|
||||||
* external storage devices where the application's OBB files (if there are
|
|
||||||
* any) can be found. Note if the application does not have any OBB files,
|
|
||||||
* these directories may not exist.
|
|
||||||
* <p>
|
|
||||||
* This is like {@link Context#getFilesDir()} in that these files will be
|
|
||||||
* deleted when the application is uninstalled, however there are some
|
|
||||||
* important differences:
|
|
||||||
* <ul>
|
|
||||||
* <li>External files are not always available: they will disappear if the
|
|
||||||
* user mounts the external storage on a computer or removes it.
|
|
||||||
* <li>There is no security enforced with these files.
|
|
||||||
* </ul>
|
|
||||||
* <p>
|
|
||||||
* External storage devices returned here are considered a permanent part of
|
|
||||||
* the device, including both emulated external storage and physical media
|
|
||||||
* slots, such as SD cards in a battery compartment. The returned paths do
|
|
||||||
* not include transient devices, such as USB flash drives.
|
|
||||||
* <p>
|
|
||||||
* An application may store data on any or all of the returned devices. For
|
|
||||||
* example, an app may choose to store large files on the device with the
|
|
||||||
* most available space, as measured by {@link StatFs}.
|
|
||||||
* <p>
|
|
||||||
* Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions
|
|
||||||
* are required to write to the returned paths; they're always accessible to
|
|
||||||
* the calling app. Before then,
|
|
||||||
* {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} is required to
|
|
||||||
* write. Write access outside of these paths on secondary external storage
|
|
||||||
* devices is not available. To request external storage access in a
|
|
||||||
* backwards compatible way, consider using {@code android:maxSdkVersion}
|
|
||||||
* like this:
|
|
||||||
*
|
|
||||||
* <pre class="prettyprint"><uses-permission
|
|
||||||
* android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
|
||||||
* android:maxSdkVersion="18" /></pre>
|
|
||||||
* <p>
|
|
||||||
* The first path returned is the same as {@link Context#getObbDir()}.
|
|
||||||
* Returned paths may be {@code null} if a storage device is unavailable.
|
|
||||||
*
|
|
||||||
* @see Context#getObbDir()
|
|
||||||
* @see EnvironmentCompat#getStorageState(File)
|
|
||||||
*/
|
|
||||||
public static File[] getObbDirs(Context context) {
|
|
||||||
return context.getObbDirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns absolute paths to application-specific directories on all
|
|
||||||
* external storage devices where the application can place persistent files
|
|
||||||
* it owns. These files are internal to the application, and not typically
|
|
||||||
* visible to the user as media.
|
|
||||||
* <p>
|
|
||||||
* This is like {@link Context#getFilesDir()} in that these files will be
|
|
||||||
* deleted when the application is uninstalled, however there are some
|
|
||||||
* important differences:
|
|
||||||
* <ul>
|
|
||||||
* <li>External files are not always available: they will disappear if the
|
|
||||||
* user mounts the external storage on a computer or removes it.
|
|
||||||
* <li>There is no security enforced with these files.
|
|
||||||
* </ul>
|
|
||||||
* <p>
|
|
||||||
* External storage devices returned here are considered a permanent part of
|
|
||||||
* the device, including both emulated external storage and physical media
|
|
||||||
* slots, such as SD cards in a battery compartment. The returned paths do
|
|
||||||
* not include transient devices, such as USB flash drives.
|
|
||||||
* <p>
|
|
||||||
* An application may store data on any or all of the returned devices. For
|
|
||||||
* example, an app may choose to store large files on the device with the
|
|
||||||
* most available space, as measured by {@link StatFs}.
|
|
||||||
* <p>
|
|
||||||
* Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions
|
|
||||||
* are required to write to the returned paths; they're always accessible to
|
|
||||||
* the calling app. Before then,
|
|
||||||
* {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} is required to
|
|
||||||
* write. Write access outside of these paths on secondary external storage
|
|
||||||
* devices is not available. To request external storage access in a
|
|
||||||
* backwards compatible way, consider using {@code android:maxSdkVersion}
|
|
||||||
* like this:
|
|
||||||
*
|
|
||||||
* <pre class="prettyprint"><uses-permission
|
|
||||||
* android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
|
||||||
* android:maxSdkVersion="18" /></pre>
|
|
||||||
* <p>
|
|
||||||
* The first path returned is the same as
|
|
||||||
* {@link Context#getExternalFilesDir(String)}. Returned paths may be
|
|
||||||
* {@code null} if a storage device is unavailable.
|
|
||||||
*
|
|
||||||
* @see Context#getExternalFilesDir(String)
|
|
||||||
* @see EnvironmentCompat#getStorageState(File)
|
|
||||||
*/
|
|
||||||
public static File[] getExternalFilesDirs(Context context, String type) {
|
|
||||||
return context.getExternalFilesDirs(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns absolute paths to application-specific directories on all
|
|
||||||
* external storage devices where the application can place cache files it
|
|
||||||
* owns. These files are internal to the application, and not typically
|
|
||||||
* visible to the user as media.
|
|
||||||
* <p>
|
|
||||||
* This is like {@link Context#getCacheDir()} in that these files will be
|
|
||||||
* deleted when the application is uninstalled, however there are some
|
|
||||||
* important differences:
|
|
||||||
* <ul>
|
|
||||||
* <li>External files are not always available: they will disappear if the
|
|
||||||
* user mounts the external storage on a computer or removes it.
|
|
||||||
* <li>There is no security enforced with these files.
|
|
||||||
* </ul>
|
|
||||||
* <p>
|
|
||||||
* External storage devices returned here are considered a permanent part of
|
|
||||||
* the device, including both emulated external storage and physical media
|
|
||||||
* slots, such as SD cards in a battery compartment. The returned paths do
|
|
||||||
* not include transient devices, such as USB flash drives.
|
|
||||||
* <p>
|
|
||||||
* An application may store data on any or all of the returned devices. For
|
|
||||||
* example, an app may choose to store large files on the device with the
|
|
||||||
* most available space, as measured by {@link StatFs}.
|
|
||||||
* <p>
|
|
||||||
* Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions
|
|
||||||
* are required to write to the returned paths; they're always accessible to
|
|
||||||
* the calling app. Before then,
|
|
||||||
* {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} is required to
|
|
||||||
* write. Write access outside of these paths on secondary external storage
|
|
||||||
* devices is not available. To request external storage access in a
|
|
||||||
* backwards compatible way, consider using {@code android:maxSdkVersion}
|
|
||||||
* like this:
|
|
||||||
*
|
|
||||||
* <pre class="prettyprint"><uses-permission
|
|
||||||
* android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
|
||||||
* android:maxSdkVersion="18" /></pre>
|
|
||||||
* <p>
|
|
||||||
* The first path returned is the same as
|
|
||||||
* {@link Context#getExternalCacheDir()}. Returned paths may be {@code null}
|
|
||||||
* if a storage device is unavailable.
|
|
||||||
*
|
|
||||||
* @see Context#getExternalCacheDir()
|
|
||||||
* @see EnvironmentCompat#getStorageState(File)
|
|
||||||
*/
|
|
||||||
public static File[] getExternalCacheDirs(Context context) {
|
|
||||||
return context.getExternalCacheDirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a drawable object associated with a particular resource ID.
|
|
||||||
* <p>
|
|
||||||
* Starting in {@link android.os.Build.VERSION_CODES#LOLLIPOP}, the returned
|
|
||||||
* drawable will be styled for the specified Context's theme.
|
|
||||||
*
|
|
||||||
* @param id The desired resource identifier, as generated by the aapt tool.
|
|
||||||
* This integer encodes the package, type, and resource entry.
|
|
||||||
* The value 0 is an invalid identifier.
|
|
||||||
* @return Drawable An object that can be used to draw this resource.
|
|
||||||
*/
|
|
||||||
public static final Drawable getDrawable(Context context, int id) {
|
|
||||||
return context.getDrawable(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the absolute path to the directory on the filesystem similar to
|
|
||||||
* {@link Context#getFilesDir()}. The difference is that files placed under this
|
|
||||||
* directory will be excluded from automatic backup to remote storage on
|
|
||||||
* devices running {@link android.os.Build.VERSION_CODES#LOLLIPOP} or later. See
|
|
||||||
* {@link android.app.backup.BackupAgent BackupAgent} for a full discussion
|
|
||||||
* of the automatic backup mechanism in Android.
|
|
||||||
*
|
|
||||||
* <p>No permissions are required to read or write to the returned path, since this
|
|
||||||
* path is internal storage.
|
|
||||||
*
|
|
||||||
* @return The path of the directory holding application files that will not be
|
|
||||||
* automatically backed up to remote storage.
|
|
||||||
*
|
|
||||||
* @see android.content.Context.getFilesDir
|
|
||||||
*/
|
|
||||||
public final File getNoBackupFilesDir(Context context) {
|
|
||||||
return context.getNoBackupFilesDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the absolute path to the application specific cache directory on
|
|
||||||
* the filesystem designed for storing cached code. On devices running
|
|
||||||
* {@link android.os.Build.VERSION_CODES#LOLLIPOP} or later, the system will delete
|
|
||||||
* any files stored in this location both when your specific application is
|
|
||||||
* upgraded, and when the entire platform is upgraded.
|
|
||||||
* <p>
|
|
||||||
* This location is optimal for storing compiled or optimized code generated
|
|
||||||
* by your application at runtime.
|
|
||||||
* <p>
|
|
||||||
* Apps require no extra permissions to read or write to the returned path,
|
|
||||||
* since this path lives in their private storage.
|
|
||||||
*
|
|
||||||
* @return The path of the directory holding application code cache files.
|
|
||||||
*/
|
|
||||||
public final File getCodeCacheDir(Context context) {
|
|
||||||
return context.getCodeCacheDir();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package android.support.v4.os;
|
|
||||||
|
|
||||||
import android.os.Environment;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper for accessing features in {@link Environment} introduced after API
|
|
||||||
* level 4 in a backwards compatible fashion.
|
|
||||||
*/
|
|
||||||
public class EnvironmentCompat {
|
|
||||||
/**
|
|
||||||
* Unknown storage state, such as when a path isn't backed by known storage
|
|
||||||
* media.
|
|
||||||
*
|
|
||||||
* @see #getStorageState(File)
|
|
||||||
*/
|
|
||||||
public static final String MEDIA_UNKNOWN = "unknown";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the current state of the storage device that provides the given
|
|
||||||
* path.
|
|
||||||
*
|
|
||||||
* @return one of {@link #MEDIA_UNKNOWN}, {@link Environment#MEDIA_REMOVED},
|
|
||||||
* {@link Environment#MEDIA_UNMOUNTED},
|
|
||||||
* {@link Environment#MEDIA_CHECKING},
|
|
||||||
* {@link Environment#MEDIA_NOFS},
|
|
||||||
* {@link Environment#MEDIA_MOUNTED},
|
|
||||||
* {@link Environment#MEDIA_MOUNTED_READ_ONLY},
|
|
||||||
* {@link Environment#MEDIA_SHARED},
|
|
||||||
* {@link Environment#MEDIA_BAD_REMOVAL}, or
|
|
||||||
* {@link Environment#MEDIA_UNMOUNTABLE}.
|
|
||||||
*/
|
|
||||||
public static String getStorageState(File path) {
|
|
||||||
return Environment.getStorageState(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,193 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2017 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package android.support.v7.preference;
|
|
||||||
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A data store interface to be implemented and provided to the Preferences framework. This can be
|
|
||||||
* used to replace the default {@link android.content.SharedPreferences}, if needed.
|
|
||||||
*
|
|
||||||
* <p>In most cases you want to use {@link android.content.SharedPreferences} as it is automatically
|
|
||||||
* backed up and migrated to new devices. However, providing custom data store to preferences can be
|
|
||||||
* useful if your app stores its preferences in a local db, cloud or they are device specific like
|
|
||||||
* "Developer settings". It might be also useful when you want to use the preferences UI but
|
|
||||||
* the data are not supposed to be stored at all because they are valid per session only.
|
|
||||||
*
|
|
||||||
* <p>Once a put method is called it is full responsibility of the data store implementation to
|
|
||||||
* safely store the given values. Time expensive operations need to be done in the background to
|
|
||||||
* prevent from blocking the UI. You also need to have a plan on how to serialize the data in case
|
|
||||||
* the activity holding this object gets destroyed.
|
|
||||||
*
|
|
||||||
* <p>By default, all "put" methods throw {@link UnsupportedOperationException}.
|
|
||||||
*/
|
|
||||||
public abstract class PreferenceDataStore {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a {@link String} value to the data store.
|
|
||||||
*
|
|
||||||
* <p>Once the value is set the data store is responsible for holding it.
|
|
||||||
*
|
|
||||||
* @param key the name of the preference to modify
|
|
||||||
* @param value the new value for the preference
|
|
||||||
* @see #getString(String, String)
|
|
||||||
*/
|
|
||||||
public void putString(String key, @Nullable String value) {
|
|
||||||
throw new UnsupportedOperationException("Not implemented on this data store");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a set of Strings to the data store.
|
|
||||||
*
|
|
||||||
* <p>Once the value is set the data store is responsible for holding it.
|
|
||||||
*
|
|
||||||
* @param key the name of the preference to modify
|
|
||||||
* @param values the set of new values for the preference
|
|
||||||
* @see #getStringSet(String, Set<String>)
|
|
||||||
*/
|
|
||||||
public void putStringSet(String key, @Nullable Set<String> values) {
|
|
||||||
throw new UnsupportedOperationException("Not implemented on this data store");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets an {@link Integer} value to the data store.
|
|
||||||
*
|
|
||||||
* <p>Once the value is set the data store is responsible for holding it.
|
|
||||||
*
|
|
||||||
* @param key the name of the preference to modify
|
|
||||||
* @param value the new value for the preference
|
|
||||||
* @see #getInt(String, int)
|
|
||||||
*/
|
|
||||||
public void putInt(String key, int value) {
|
|
||||||
throw new UnsupportedOperationException("Not implemented on this data store");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a {@link Long} value to the data store.
|
|
||||||
*
|
|
||||||
* <p>Once the value is set the data store is responsible for holding it.
|
|
||||||
*
|
|
||||||
* @param key the name of the preference to modify
|
|
||||||
* @param value the new value for the preference
|
|
||||||
* @see #getLong(String, long)
|
|
||||||
*/
|
|
||||||
public void putLong(String key, long value) {
|
|
||||||
throw new UnsupportedOperationException("Not implemented on this data store");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a {@link Float} value to the data store.
|
|
||||||
*
|
|
||||||
* <p>Once the value is set the data store is responsible for holding it.
|
|
||||||
*
|
|
||||||
* @param key the name of the preference to modify
|
|
||||||
* @param value the new value for the preference
|
|
||||||
* @see #getFloat(String, float)
|
|
||||||
*/
|
|
||||||
public void putFloat(String key, float value) {
|
|
||||||
throw new UnsupportedOperationException("Not implemented on this data store");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a {@link Boolean} value to the data store.
|
|
||||||
*
|
|
||||||
* <p>Once the value is set the data store is responsible for holding it.
|
|
||||||
*
|
|
||||||
* @param key the name of the preference to modify
|
|
||||||
* @param value the new value for the preference
|
|
||||||
* @see #getBoolean(String, boolean)
|
|
||||||
*/
|
|
||||||
public void putBoolean(String key, boolean value) {
|
|
||||||
throw new UnsupportedOperationException("Not implemented on this data store");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a {@link String} value from the data store.
|
|
||||||
*
|
|
||||||
* @param key the name of the preference to retrieve
|
|
||||||
* @param defValue value to return if this preference does not exist in the storage
|
|
||||||
* @return the value from the data store or the default return value
|
|
||||||
* @see #putString(String, String)
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
public String getString(String key, @Nullable String defValue) {
|
|
||||||
return defValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a set of Strings from the data store.
|
|
||||||
*
|
|
||||||
* @param key the name of the preference to retrieve
|
|
||||||
* @param defValues values to return if this preference does not exist in the storage
|
|
||||||
* @return the values from the data store or the default return values
|
|
||||||
* @see #putStringSet(String, Set<String>)
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
public Set<String> getStringSet(String key, @Nullable Set<String> defValues) {
|
|
||||||
return defValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves an {@link Integer} value from the data store.
|
|
||||||
*
|
|
||||||
* @param key the name of the preference to retrieve
|
|
||||||
* @param defValue value to return if this preference does not exist in the storage
|
|
||||||
* @return the value from the data store or the default return value
|
|
||||||
* @see #putInt(String, int)
|
|
||||||
*/
|
|
||||||
public int getInt(String key, int defValue) {
|
|
||||||
return defValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a {@link Long} value from the data store.
|
|
||||||
*
|
|
||||||
* @param key the name of the preference to retrieve
|
|
||||||
* @param defValue value to return if this preference does not exist in the storage
|
|
||||||
* @return the value from the data store or the default return value
|
|
||||||
* @see #putLong(String, long)
|
|
||||||
*/
|
|
||||||
public long getLong(String key, long defValue) {
|
|
||||||
return defValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a {@link Float} value from the data store.
|
|
||||||
*
|
|
||||||
* @param key the name of the preference to retrieve
|
|
||||||
* @param defValue value to return if this preference does not exist in the storage
|
|
||||||
* @return the value from the data store or the default return value
|
|
||||||
* @see #putFloat(String, float)
|
|
||||||
*/
|
|
||||||
public float getFloat(String key, float defValue) {
|
|
||||||
return defValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a {@link Boolean} value from the data store.
|
|
||||||
*
|
|
||||||
* @param key the name of the preference to retrieve
|
|
||||||
* @param defValue value to return if this preference does not exist in the storage
|
|
||||||
* @return the value from the data store or the default return value
|
|
||||||
* @see #getBoolean(String, boolean)
|
|
||||||
*/
|
|
||||||
public boolean getBoolean(String key, boolean defValue) {
|
|
||||||
return defValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package android.support.v7.preference;
|
|
||||||
|
|
||||||
public class PreferenceScreen {
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,7 @@ package android.text;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.safety.Whitelist;
|
import org.jsoup.safety.Safelist;
|
||||||
import org.xml.sax.XMLReader;
|
import org.xml.sax.XMLReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,7 +18,7 @@ import org.xml.sax.XMLReader;
|
|||||||
public class Html {
|
public class Html {
|
||||||
|
|
||||||
public static Spanned fromHtml(String source) {
|
public static Spanned fromHtml(String source) {
|
||||||
return new FakeSpanned(Jsoup.clean(source, Whitelist.none()));
|
return new FakeSpanned(Jsoup.clean(source, Safelist.none()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Spanned fromHtml(String source, Html.ImageGetter imageGetter, Html.TagHandler tagHandler) {
|
public static Spanned fromHtml(String source, Html.ImageGetter imageGetter, Html.TagHandler tagHandler) {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,631 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.text;
|
||||||
|
|
||||||
|
import android.annotation.ColorInt;
|
||||||
|
import android.annotation.IntRange;
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.RectF;
|
||||||
|
import android.util.Log;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
|
import java.awt.font.LineBreakMeasurer;
|
||||||
|
import java.awt.font.FontRenderContext;
|
||||||
|
import java.awt.font.TextAttribute;
|
||||||
|
import java.awt.font.TextLayout;
|
||||||
|
import java.text.AttributedString;
|
||||||
|
|
||||||
|
import com.android.internal.util.ArrayUtils;
|
||||||
|
import com.android.internal.util.GrowingArrayUtils;
|
||||||
|
|
||||||
|
|
||||||
|
public class StaticLayout extends Layout {
|
||||||
|
/*
|
||||||
|
* The break iteration is done in native code. The protocol for using the native code is as
|
||||||
|
* follows.
|
||||||
|
*
|
||||||
|
* First, call nInit to setup native line breaker object. Then, for each paragraph, do the
|
||||||
|
* following:
|
||||||
|
*
|
||||||
|
* - Create MeasuredParagraph by MeasuredParagraph.buildForStaticLayout which measures in
|
||||||
|
* native.
|
||||||
|
* - Run LineBreaker.computeLineBreaks() to obtain line breaks for the paragraph.
|
||||||
|
*
|
||||||
|
* After all paragraphs, call finish() to release expensive buffers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static final String TAG = "StaticLayout";
|
||||||
|
|
||||||
|
public final static class Builder {
|
||||||
|
private Builder() {}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public static Builder obtain(@NonNull CharSequence source, @IntRange(from = 0) int start,
|
||||||
|
@IntRange(from = 0) int end, @NonNull TextPaint paint,
|
||||||
|
@IntRange(from = 0) int width) {
|
||||||
|
Builder b = new Builder();
|
||||||
|
|
||||||
|
// set default initial values
|
||||||
|
b.mText = source;
|
||||||
|
b.mStart = start;
|
||||||
|
b.mEnd = end;
|
||||||
|
b.mPaint = paint;
|
||||||
|
b.mWidth = width;
|
||||||
|
b.mAlignment = Alignment.ALIGN_NORMAL;
|
||||||
|
b.mTextDir = TextDirectionHeuristics.FIRSTSTRONG_LTR;
|
||||||
|
b.mSpacingMult = DEFAULT_LINESPACING_MULTIPLIER;
|
||||||
|
b.mSpacingAdd = DEFAULT_LINESPACING_ADDITION;
|
||||||
|
b.mIncludePad = true;
|
||||||
|
b.mFallbackLineSpacing = false;
|
||||||
|
b.mEllipsizedWidth = width;
|
||||||
|
b.mEllipsize = null;
|
||||||
|
b.mMaxLines = Integer.MAX_VALUE;
|
||||||
|
b.mBreakStrategy = Layout.BREAK_STRATEGY_SIMPLE;
|
||||||
|
b.mHyphenationFrequency = Layout.HYPHENATION_FREQUENCY_NONE;
|
||||||
|
b.mJustificationMode = Layout.JUSTIFICATION_MODE_NONE;
|
||||||
|
b.mMinimumFontMetrics = null;
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
// release any expensive state
|
||||||
|
/* package */ void finish() {
|
||||||
|
mText = null;
|
||||||
|
mPaint = null;
|
||||||
|
mLeftIndents = null;
|
||||||
|
mRightIndents = null;
|
||||||
|
mMinimumFontMetrics = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setText(CharSequence source) {
|
||||||
|
return setText(source, 0, source.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Builder setText(@NonNull CharSequence source, int start, int end) {
|
||||||
|
mText = source;
|
||||||
|
mStart = start;
|
||||||
|
mEnd = end;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Builder setPaint(@NonNull TextPaint paint) {
|
||||||
|
mPaint = paint;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Builder setWidth(@IntRange(from = 0) int width) {
|
||||||
|
mWidth = width;
|
||||||
|
if (mEllipsize == null) {
|
||||||
|
mEllipsizedWidth = width;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Builder setAlignment(@NonNull Alignment alignment) {
|
||||||
|
mAlignment = alignment;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Builder setTextDirection(@NonNull TextDirectionHeuristic textDir) {
|
||||||
|
mTextDir = textDir;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Builder setLineSpacing(float spacingAdd, float spacingMult) {
|
||||||
|
mSpacingAdd = spacingAdd;
|
||||||
|
mSpacingMult = spacingMult;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Builder setIncludePad(boolean includePad) {
|
||||||
|
mIncludePad = includePad;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Builder setUseLineSpacingFromFallbacks(boolean useLineSpacingFromFallbacks) {
|
||||||
|
mFallbackLineSpacing = useLineSpacingFromFallbacks;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Builder setEllipsizedWidth(@IntRange(from = 0) int ellipsizedWidth) {
|
||||||
|
mEllipsizedWidth = ellipsizedWidth;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Builder setEllipsize(@Nullable TextUtils.TruncateAt ellipsize) {
|
||||||
|
mEllipsize = ellipsize;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Builder setMaxLines(@IntRange(from = 0) int maxLines) {
|
||||||
|
mMaxLines = maxLines;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Builder setBreakStrategy(@BreakStrategy int breakStrategy) {
|
||||||
|
mBreakStrategy = breakStrategy;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Builder setHyphenationFrequency(@HyphenationFrequency int hyphenationFrequency) {
|
||||||
|
mHyphenationFrequency = hyphenationFrequency;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Builder setIndents(@Nullable int[] leftIndents, @Nullable int[] rightIndents) {
|
||||||
|
mLeftIndents = leftIndents;
|
||||||
|
mRightIndents = rightIndents;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Builder setJustificationMode(@JustificationMode int justificationMode) {
|
||||||
|
mJustificationMode = justificationMode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
/* package */ Builder setAddLastLineLineSpacing(boolean value) {
|
||||||
|
mAddLastLineLineSpacing = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("MissingGetterMatchingBuilder") // The base class `Layout` has a getter.
|
||||||
|
@NonNull
|
||||||
|
public Builder setUseBoundsForWidth(boolean useBoundsForWidth) {
|
||||||
|
mUseBoundsForWidth = useBoundsForWidth;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
// The corresponding getter is getShiftDrawingOffsetForStartOverhang()
|
||||||
|
@SuppressLint("MissingGetterMatchingBuilder")
|
||||||
|
public Builder setShiftDrawingOffsetForStartOverhang(
|
||||||
|
boolean shiftDrawingOffsetForStartOverhang) {
|
||||||
|
mShiftDrawingOffsetForStartOverhang = shiftDrawingOffsetForStartOverhang;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setCalculateBounds(boolean value) {
|
||||||
|
mCalculateBounds = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Builder setMinimumFontMetrics(@Nullable Paint.FontMetrics minimumFontMetrics) {
|
||||||
|
mMinimumFontMetrics = minimumFontMetrics;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public StaticLayout build() {
|
||||||
|
StaticLayout result = new StaticLayout(this, mIncludePad, mEllipsize != null
|
||||||
|
? COLUMNS_ELLIPSIZE : COLUMNS_NORMAL);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private CharSequence mText;
|
||||||
|
private int mStart;
|
||||||
|
private int mEnd;
|
||||||
|
private TextPaint mPaint;
|
||||||
|
private int mWidth;
|
||||||
|
private Alignment mAlignment;
|
||||||
|
private TextDirectionHeuristic mTextDir;
|
||||||
|
private float mSpacingMult;
|
||||||
|
private float mSpacingAdd;
|
||||||
|
private boolean mIncludePad;
|
||||||
|
private boolean mFallbackLineSpacing;
|
||||||
|
private int mEllipsizedWidth;
|
||||||
|
private TextUtils.TruncateAt mEllipsize;
|
||||||
|
private int mMaxLines;
|
||||||
|
private int mBreakStrategy;
|
||||||
|
private int mHyphenationFrequency;
|
||||||
|
@Nullable private int[] mLeftIndents;
|
||||||
|
@Nullable private int[] mRightIndents;
|
||||||
|
private int mJustificationMode;
|
||||||
|
private boolean mAddLastLineLineSpacing;
|
||||||
|
private boolean mUseBoundsForWidth;
|
||||||
|
private boolean mShiftDrawingOffsetForStartOverhang;
|
||||||
|
private boolean mCalculateBounds;
|
||||||
|
@Nullable private Paint.FontMetrics mMinimumFontMetrics;
|
||||||
|
|
||||||
|
private final Paint.FontMetricsInt mFontMetricsInt = new Paint.FontMetricsInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
private StaticLayout() {
|
||||||
|
super(
|
||||||
|
null, // text
|
||||||
|
null, // paint
|
||||||
|
0, // width
|
||||||
|
null, // alignment
|
||||||
|
null, // textDir
|
||||||
|
1, // spacing multiplier
|
||||||
|
0, // spacing amount
|
||||||
|
false, // include font padding
|
||||||
|
false, // fallback line spacing
|
||||||
|
0, // ellipsized width
|
||||||
|
null, // ellipsize
|
||||||
|
1, // maxLines
|
||||||
|
BREAK_STRATEGY_SIMPLE,
|
||||||
|
HYPHENATION_FREQUENCY_NONE,
|
||||||
|
null, // leftIndents
|
||||||
|
null, // rightIndents
|
||||||
|
JUSTIFICATION_MODE_NONE,
|
||||||
|
false, // useBoundsForWidth
|
||||||
|
false, // shiftDrawingOffsetForStartOverhang
|
||||||
|
null // minimumFontMetrics
|
||||||
|
);
|
||||||
|
|
||||||
|
mColumns = COLUMNS_ELLIPSIZE;
|
||||||
|
mLineDirections = new Directions[2];
|
||||||
|
mLines = new int[2 * mColumns];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public StaticLayout(CharSequence source, TextPaint paint,
|
||||||
|
int width,
|
||||||
|
Alignment align, float spacingmult, float spacingadd,
|
||||||
|
boolean includepad) {
|
||||||
|
this(source, 0, source.length(), paint, width, align,
|
||||||
|
spacingmult, spacingadd, includepad);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public StaticLayout(CharSequence source, int bufstart, int bufend,
|
||||||
|
TextPaint paint, int outerwidth,
|
||||||
|
Alignment align,
|
||||||
|
float spacingmult, float spacingadd,
|
||||||
|
boolean includepad) {
|
||||||
|
this(source, bufstart, bufend, paint, outerwidth, align,
|
||||||
|
spacingmult, spacingadd, includepad, null, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public StaticLayout(CharSequence source, int bufstart, int bufend,
|
||||||
|
TextPaint paint, int outerwidth,
|
||||||
|
Alignment align,
|
||||||
|
float spacingmult, float spacingadd,
|
||||||
|
boolean includepad,
|
||||||
|
TextUtils.TruncateAt ellipsize, int ellipsizedWidth) {
|
||||||
|
this(source, bufstart, bufend, paint, outerwidth, align,
|
||||||
|
TextDirectionHeuristics.FIRSTSTRONG_LTR,
|
||||||
|
spacingmult, spacingadd, includepad, ellipsize, ellipsizedWidth, Integer.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public StaticLayout(CharSequence source, int bufstart, int bufend,
|
||||||
|
TextPaint paint, int outerwidth,
|
||||||
|
Alignment align, TextDirectionHeuristic textDir,
|
||||||
|
float spacingmult, float spacingadd,
|
||||||
|
boolean includepad,
|
||||||
|
TextUtils.TruncateAt ellipsize, int ellipsizedWidth, int maxLines) {
|
||||||
|
this(Builder.obtain(source, bufstart, bufend, paint, outerwidth)
|
||||||
|
.setAlignment(align)
|
||||||
|
.setTextDirection(textDir)
|
||||||
|
.setLineSpacing(spacingadd, spacingmult)
|
||||||
|
.setIncludePad(includepad)
|
||||||
|
.setEllipsize(ellipsize)
|
||||||
|
.setEllipsizedWidth(ellipsizedWidth)
|
||||||
|
.setMaxLines(maxLines), includepad,
|
||||||
|
ellipsize != null ? COLUMNS_ELLIPSIZE : COLUMNS_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
private StaticLayout(Builder b, boolean trackPadding, int columnSize) {
|
||||||
|
super((b.mEllipsize == null) ? b.mText : (b.mText instanceof Spanned)
|
||||||
|
? new SpannedEllipsizer(b.mText) : new Ellipsizer(b.mText),
|
||||||
|
b.mPaint, b.mWidth, b.mAlignment, b.mTextDir, b.mSpacingMult, b.mSpacingAdd,
|
||||||
|
b.mIncludePad, b.mFallbackLineSpacing, b.mEllipsizedWidth, b.mEllipsize,
|
||||||
|
b.mMaxLines, b.mBreakStrategy, b.mHyphenationFrequency, b.mLeftIndents,
|
||||||
|
b.mRightIndents, b.mJustificationMode, b.mUseBoundsForWidth,
|
||||||
|
b.mShiftDrawingOffsetForStartOverhang, b.mMinimumFontMetrics);
|
||||||
|
|
||||||
|
mColumns = columnSize;
|
||||||
|
if (b.mEllipsize != null) {
|
||||||
|
Ellipsizer e = (Ellipsizer) getText();
|
||||||
|
|
||||||
|
e.mLayout = this;
|
||||||
|
e.mWidth = b.mEllipsizedWidth;
|
||||||
|
e.mMethod = b.mEllipsize;
|
||||||
|
throw new UnsupportedOperationException("Ellipsis not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
mLineDirections = new Directions[2];
|
||||||
|
mLines = new int[2 * mColumns];
|
||||||
|
mMaximumVisibleLineCount = b.mMaxLines;
|
||||||
|
|
||||||
|
mLeftIndents = b.mLeftIndents;
|
||||||
|
mRightIndents = b.mRightIndents;
|
||||||
|
|
||||||
|
String str = b.mText.subSequence(b.mStart, b.mEnd).toString();
|
||||||
|
AttributedString text = new AttributedString(str);
|
||||||
|
text.addAttribute(TextAttribute.FONT, getPaint().getFont());
|
||||||
|
FontRenderContext frc = new FontRenderContext(getPaint().getFont().getTransform(), RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT, RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT);
|
||||||
|
LineBreakMeasurer measurer = new LineBreakMeasurer(text.getIterator(), frc);
|
||||||
|
// TODO: directions
|
||||||
|
|
||||||
|
float y = 0;
|
||||||
|
while (measurer.getPosition() < str.length()) {
|
||||||
|
int off = mLineCount * mColumns;
|
||||||
|
int want = off + mColumns + TOP;
|
||||||
|
if (want >= mLines.length) {
|
||||||
|
final int[] grow = ArrayUtils.newUnpaddedIntArray(GrowingArrayUtils.growSize(want));
|
||||||
|
System.arraycopy(mLines, 0, grow, 0, mLines.length);
|
||||||
|
mLines = grow;
|
||||||
|
}
|
||||||
|
|
||||||
|
int pos = measurer.getPosition();
|
||||||
|
TextLayout l = measurer.nextLayout(getWidth());
|
||||||
|
mLines[off + START] = pos;
|
||||||
|
mLines[off + TOP] = (int) y;
|
||||||
|
mLines[off + DESCENT] = (int) (l.getDescent() + l.getLeading());
|
||||||
|
mLines[off + EXTRA] = (int) l.getLeading();
|
||||||
|
mLines[off + DIR] |= Layout.DIR_LEFT_TO_RIGHT << DIR_SHIFT;
|
||||||
|
|
||||||
|
y += l.getAscent();
|
||||||
|
y += l.getDescent() + l.getLeading();
|
||||||
|
|
||||||
|
mLines[off + mColumns + START] = measurer.getPosition();
|
||||||
|
mLines[off + mColumns + TOP] = (int) y;
|
||||||
|
|
||||||
|
mLineCount += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override the base class so we can directly access our members,
|
||||||
|
// rather than relying on member functions.
|
||||||
|
// The logic mirrors that of Layout.getLineForVertical
|
||||||
|
// FIXME: It may be faster to do a linear search for layouts without many lines.
|
||||||
|
@Override
|
||||||
|
public int getLineForVertical(int vertical) {
|
||||||
|
int high = mLineCount;
|
||||||
|
int low = -1;
|
||||||
|
int guess;
|
||||||
|
int[] lines = mLines;
|
||||||
|
while (high - low > 1) {
|
||||||
|
guess = (high + low) >> 1;
|
||||||
|
if (lines[mColumns * guess + TOP] > vertical){
|
||||||
|
high = guess;
|
||||||
|
} else {
|
||||||
|
low = guess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (low < 0) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return low;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLineCount() {
|
||||||
|
return mLineCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLineTop(int line) {
|
||||||
|
return mLines[mColumns * line + TOP];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLineExtra(int line) {
|
||||||
|
return mLines[mColumns * line + EXTRA];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLineDescent(int line) {
|
||||||
|
return mLines[mColumns * line + DESCENT];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLineStart(int line) {
|
||||||
|
return mLines[mColumns * line + START] & START_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getParagraphDirection(int line) {
|
||||||
|
return mLines[mColumns * line + DIR] >> DIR_SHIFT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getLineContainsTab(int line) {
|
||||||
|
return (mLines[mColumns * line + TAB] & TAB_MASK) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final Directions getLineDirections(int line) {
|
||||||
|
if (line > getLineCount()) {
|
||||||
|
throw new ArrayIndexOutOfBoundsException();
|
||||||
|
}
|
||||||
|
return new Directions(null);
|
||||||
|
// return mLineDirections[line];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTopPadding() {
|
||||||
|
return mTopPadding;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBottomPadding() {
|
||||||
|
return mBottomPadding;
|
||||||
|
}
|
||||||
|
|
||||||
|
// To store into single int field, pack the pair of start and end hyphen edit.
|
||||||
|
static int packHyphenEdit(
|
||||||
|
@Paint.StartHyphenEdit int start, @Paint.EndHyphenEdit int end) {
|
||||||
|
return start << START_HYPHEN_BITS_SHIFT | end;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int unpackStartHyphenEdit(int packedHyphenEdit) {
|
||||||
|
return (packedHyphenEdit & START_HYPHEN_MASK) >> START_HYPHEN_BITS_SHIFT;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int unpackEndHyphenEdit(int packedHyphenEdit) {
|
||||||
|
return packedHyphenEdit & END_HYPHEN_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Paint.StartHyphenEdit int getStartHyphenEdit(int lineNumber) {
|
||||||
|
return unpackStartHyphenEdit(mLines[mColumns * lineNumber + HYPHEN] & HYPHEN_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Paint.EndHyphenEdit int getEndHyphenEdit(int lineNumber) {
|
||||||
|
return unpackEndHyphenEdit(mLines[mColumns * lineNumber + HYPHEN] & HYPHEN_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getIndentAdjust(int line, Alignment align) {
|
||||||
|
if (align == Alignment.ALIGN_LEFT) {
|
||||||
|
if (mLeftIndents == null) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return mLeftIndents[Math.min(line, mLeftIndents.length - 1)];
|
||||||
|
}
|
||||||
|
} else if (align == Alignment.ALIGN_RIGHT) {
|
||||||
|
if (mRightIndents == null) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return -mRightIndents[Math.min(line, mRightIndents.length - 1)];
|
||||||
|
}
|
||||||
|
} else if (align == Alignment.ALIGN_CENTER) {
|
||||||
|
int left = 0;
|
||||||
|
if (mLeftIndents != null) {
|
||||||
|
left = mLeftIndents[Math.min(line, mLeftIndents.length - 1)];
|
||||||
|
}
|
||||||
|
int right = 0;
|
||||||
|
if (mRightIndents != null) {
|
||||||
|
right = mRightIndents[Math.min(line, mRightIndents.length - 1)];
|
||||||
|
}
|
||||||
|
return (left - right) >> 1;
|
||||||
|
} else {
|
||||||
|
throw new AssertionError("unhandled alignment " + align);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getEllipsisCount(int line) {
|
||||||
|
if (mColumns < COLUMNS_ELLIPSIZE) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mLines[mColumns * line + ELLIPSIS_COUNT];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getEllipsisStart(int line) {
|
||||||
|
if (mColumns < COLUMNS_ELLIPSIZE) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mLines[mColumns * line + ELLIPSIS_START];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull
|
||||||
|
public RectF computeDrawingBoundingBox() {
|
||||||
|
// Cache the drawing bounds result because it does not change after created.
|
||||||
|
if (mDrawingBounds == null) {
|
||||||
|
mDrawingBounds = super.computeDrawingBoundingBox();
|
||||||
|
}
|
||||||
|
return mDrawingBounds;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHeight(boolean cap) {
|
||||||
|
if (cap && mLineCount > mMaximumVisibleLineCount && mMaxLineHeight == -1
|
||||||
|
&& Log.isLoggable(TAG, Log.WARN)) {
|
||||||
|
Log.w(TAG, "maxLineHeight should not be -1. "
|
||||||
|
+ " maxLines:" + mMaximumVisibleLineCount
|
||||||
|
+ " lineCount:" + mLineCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cap && mLineCount > mMaximumVisibleLineCount && mMaxLineHeight != -1
|
||||||
|
? mMaxLineHeight : super.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int mLineCount;
|
||||||
|
private int mTopPadding, mBottomPadding;
|
||||||
|
private int mColumns;
|
||||||
|
private RectF mDrawingBounds = null; // lazy calculation.
|
||||||
|
|
||||||
|
private boolean mEllipsized;
|
||||||
|
|
||||||
|
private int mMaxLineHeight = DEFAULT_MAX_LINE_HEIGHT;
|
||||||
|
|
||||||
|
private static final int COLUMNS_NORMAL = 5;
|
||||||
|
private static final int COLUMNS_ELLIPSIZE = 7;
|
||||||
|
private static final int START = 0;
|
||||||
|
private static final int DIR = START;
|
||||||
|
private static final int TAB = START;
|
||||||
|
private static final int TOP = 1;
|
||||||
|
private static final int DESCENT = 2;
|
||||||
|
private static final int EXTRA = 3;
|
||||||
|
private static final int HYPHEN = 4;
|
||||||
|
private static final int ELLIPSIS_START = 5;
|
||||||
|
private static final int ELLIPSIS_COUNT = 6;
|
||||||
|
|
||||||
|
private int[] mLines;
|
||||||
|
private Directions[] mLineDirections;
|
||||||
|
private int mMaximumVisibleLineCount = Integer.MAX_VALUE;
|
||||||
|
|
||||||
|
private static final int START_MASK = 0x1FFFFFFF;
|
||||||
|
private static final int DIR_SHIFT = 30;
|
||||||
|
private static final int TAB_MASK = 0x20000000;
|
||||||
|
private static final int HYPHEN_MASK = 0xFF;
|
||||||
|
private static final int START_HYPHEN_BITS_SHIFT = 3;
|
||||||
|
private static final int START_HYPHEN_MASK = 0x18; // 0b11000
|
||||||
|
private static final int END_HYPHEN_MASK = 0x7; // 0b00111
|
||||||
|
|
||||||
|
private static final float TAB_INCREMENT = 20; // same as Layout, but that's private
|
||||||
|
|
||||||
|
private static final char CHAR_NEW_LINE = '\n';
|
||||||
|
|
||||||
|
private static final double EXTRA_ROUNDING = 0.5;
|
||||||
|
|
||||||
|
private static final int DEFAULT_MAX_LINE_HEIGHT = -1;
|
||||||
|
|
||||||
|
// Unused, here because of gray list private API accesses.
|
||||||
|
/*package*/ static class LineBreaks {
|
||||||
|
private static final int INITIAL_SIZE = 16;
|
||||||
|
public int[] breaks = new int[INITIAL_SIZE];
|
||||||
|
public float[] widths = new float[INITIAL_SIZE];
|
||||||
|
public float[] ascents = new float[INITIAL_SIZE];
|
||||||
|
public float[] descents = new float[INITIAL_SIZE];
|
||||||
|
public int[] flags = new int[INITIAL_SIZE]; // hasTab
|
||||||
|
// breaks, widths, and flags should all have the same length
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable private int[] mLeftIndents;
|
||||||
|
@Nullable private int[] mRightIndents;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,178 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.text;
|
||||||
|
|
||||||
|
import android.annotation.IntRange;
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Paint.FontMetricsInt;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.graphics.RectF;
|
||||||
|
import android.text.Layout.Directions;
|
||||||
|
import android.text.Layout.TabStops;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
|
import java.awt.font.FontRenderContext;
|
||||||
|
|
||||||
|
|
||||||
|
public class TextLine {
|
||||||
|
private TextPaint mPaint;
|
||||||
|
private CharSequence mText;
|
||||||
|
private int mStart;
|
||||||
|
private int mLen;
|
||||||
|
private int mDir;
|
||||||
|
private Directions mDirections;
|
||||||
|
private boolean mHasTabs;
|
||||||
|
private TabStops mTabs;
|
||||||
|
private char[] mChars;
|
||||||
|
private boolean mCharsValid;
|
||||||
|
private Spanned mSpanned;
|
||||||
|
private PrecomputedText mComputed;
|
||||||
|
private RectF mTmpRectForMeasure;
|
||||||
|
private RectF mTmpRectForPaintAPI;
|
||||||
|
private Rect mTmpRectForPrecompute;
|
||||||
|
|
||||||
|
|
||||||
|
public static final class LineInfo {
|
||||||
|
private int mClusterCount;
|
||||||
|
|
||||||
|
public int getClusterCount() {
|
||||||
|
return mClusterCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClusterCount(int clusterCount) {
|
||||||
|
mClusterCount = clusterCount;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public float getAddedWordSpacingInPx() {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getAddedLetterSpacingInPx() {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isJustifying() {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Not allowed to access. If it's for memory leak workaround, it was already fixed M. */
|
||||||
|
private static final TextLine[] sCached = new TextLine[3];
|
||||||
|
|
||||||
|
public static TextLine obtain() {
|
||||||
|
TextLine tl;
|
||||||
|
synchronized (sCached) {
|
||||||
|
for (int i = sCached.length; --i >= 0;) {
|
||||||
|
if (sCached[i] != null) {
|
||||||
|
tl = sCached[i];
|
||||||
|
sCached[i] = null;
|
||||||
|
return tl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tl = new TextLine();
|
||||||
|
return tl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TextLine recycle(TextLine tl) {
|
||||||
|
synchronized(sCached) {
|
||||||
|
for (int i = 0; i < sCached.length; ++i) {
|
||||||
|
if (sCached[i] == null) {
|
||||||
|
sCached[i] = tl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(TextPaint paint, CharSequence text, int start, int limit, int dir,
|
||||||
|
Directions directions, boolean hasTabs, TabStops tabStops,
|
||||||
|
int ellipsisStart, int ellipsisEnd, boolean useFallbackLineSpacing) {
|
||||||
|
mPaint = paint;
|
||||||
|
mText = text;
|
||||||
|
mStart = start;
|
||||||
|
mLen = limit - start;
|
||||||
|
mDir = dir;
|
||||||
|
mDirections = directions;
|
||||||
|
if (mDirections == null) {
|
||||||
|
throw new IllegalArgumentException("Directions cannot be null");
|
||||||
|
}
|
||||||
|
mHasTabs = hasTabs;
|
||||||
|
mSpanned = null;
|
||||||
|
|
||||||
|
if (text instanceof Spanned) {
|
||||||
|
mSpanned = (Spanned) text;
|
||||||
|
}
|
||||||
|
|
||||||
|
mComputed = null;
|
||||||
|
if (text instanceof PrecomputedText) {
|
||||||
|
// Here, no need to check line break strategy or hyphenation frequency since there is no
|
||||||
|
// line break concept here.
|
||||||
|
mComputed = (PrecomputedText) text;
|
||||||
|
if (!mComputed.getParams().getTextPaint().equalsForTextMeasurement(paint)) {
|
||||||
|
mComputed = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mTabs = tabStops;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void justify(@Layout.JustificationMode int justificationMode, float justifyWidth) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int calculateRunFlag(int bidiRunIndex, int bidiRunCount, int lineDirection) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int resolveRunFlagForSubSequence(int runFlag, boolean isRtlRun, int runStart,
|
||||||
|
int runEnd, int spanStart, int spanEnd) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public float metrics(FontMetricsInt fmi, @Nullable RectF drawBounds, boolean returnDrawWidth,
|
||||||
|
@Nullable LineInfo lineInfo) {
|
||||||
|
FontRenderContext frc = new FontRenderContext(null, RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT, RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT);
|
||||||
|
return (float) mPaint.getFont().getStringBounds(mText.toString(), mStart, mStart + mLen, frc).getWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
public float measure(@IntRange(from = 0) int offset, boolean trailing,
|
||||||
|
@NonNull FontMetricsInt fmi, @Nullable RectF drawBounds, @Nullable LineInfo lineInfo) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void measureAllBounds(@NonNull float[] bounds, @Nullable float[] advances) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public float[] measureAllOffsets(boolean[] trailing, FontMetricsInt fmi) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note: keep this in sync with Minikin LineBreaker::isLineEndSpace()
|
||||||
|
public static boolean isLineEndSpace(char ch) {
|
||||||
|
return ch == ' ' || ch == '\t' || ch == 0x1680
|
||||||
|
|| (0x2000 <= ch && ch <= 0x200A && ch != 0x2007)
|
||||||
|
|| ch == 0x205F || ch == 0x3000;
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw(Canvas c, float x, int top, int y, int bottom) {
|
||||||
|
c.drawText(mText, mStart, mStart + mLen, x, y, mPaint);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.text;
|
||||||
|
|
||||||
|
import android.annotation.ColorInt;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
|
||||||
|
public class TextPaint extends Paint {
|
||||||
|
|
||||||
|
// Special value 0 means no background paint
|
||||||
|
@ColorInt
|
||||||
|
public int bgColor;
|
||||||
|
public int baselineShift;
|
||||||
|
@ColorInt
|
||||||
|
public int linkColor;
|
||||||
|
public int[] drawableState;
|
||||||
|
public float density = 1.0f;
|
||||||
|
@ColorInt
|
||||||
|
public int underlineColor = 0;
|
||||||
|
|
||||||
|
public float underlineThickness;
|
||||||
|
|
||||||
|
public TextPaint() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextPaint(int flags) {
|
||||||
|
super(flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextPaint(Paint p) {
|
||||||
|
super(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(TextPaint tp) {
|
||||||
|
super.set(tp);
|
||||||
|
|
||||||
|
bgColor = tp.bgColor;
|
||||||
|
baselineShift = tp.baselineShift;
|
||||||
|
linkColor = tp.linkColor;
|
||||||
|
drawableState = tp.drawableState;
|
||||||
|
density = tp.density;
|
||||||
|
underlineColor = tp.underlineColor;
|
||||||
|
underlineThickness = tp.underlineThickness;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnderlineText(int color, float thickness) {
|
||||||
|
underlineColor = color;
|
||||||
|
underlineThickness = thickness;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getUnderlineThickness() {
|
||||||
|
if (underlineColor != 0) { // Return custom thickness only if underline color is set.
|
||||||
|
return underlineThickness;
|
||||||
|
} else {
|
||||||
|
return super.getUnderlineThickness();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -136,4 +136,4 @@ public final class Log {
|
|||||||
first.append(msg);
|
first.append(msg);
|
||||||
return first.toString();
|
return first.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,270 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.util;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
import android.annotation.SystemApi;
|
||||||
|
import android.os.Build;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API for sending log output to the {@link Log#LOG_ID_SYSTEM} buffer.
|
||||||
|
*
|
||||||
|
* <p>Should be used by system components. Use {@code adb logcat --buffer=system} to fetch the logs.
|
||||||
|
*
|
||||||
|
* @see Log
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public final class Slog {
|
||||||
|
|
||||||
|
private Slog() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs {@code msg} at {@link Log#VERBOSE} level.
|
||||||
|
*
|
||||||
|
* @param tag identifies the source of a log message. It usually represents system service,
|
||||||
|
* e.g. {@code PackageManager}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
*
|
||||||
|
* @see Log#v(String, String)
|
||||||
|
*/
|
||||||
|
public static int v(@Nullable String tag, @NonNull String msg) {
|
||||||
|
return Log.println(Log.VERBOSE, tag, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs {@code msg} at {@link Log#VERBOSE} level, attaching stack trace of the {@code tr} to
|
||||||
|
* the end of the log statement.
|
||||||
|
*
|
||||||
|
* @param tag identifies the source of a log message. It usually represents system service,
|
||||||
|
* e.g. {@code PackageManager}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
* @param tr an exception to log.
|
||||||
|
*
|
||||||
|
* @see Log#v(String, String, Throwable)
|
||||||
|
*/
|
||||||
|
public static int v(@Nullable String tag, @NonNull String msg, @Nullable Throwable tr) {
|
||||||
|
return Log.println(Log.VERBOSE, tag,
|
||||||
|
msg + '\n' + Log.getStackTraceString(tr));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs {@code msg} at {@link Log#DEBUG} level.
|
||||||
|
*
|
||||||
|
* @param tag identifies the source of a log message. It usually represents system service,
|
||||||
|
* e.g. {@code PackageManager}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
*
|
||||||
|
* @see Log#d(String, String)
|
||||||
|
*/
|
||||||
|
public static int d(@Nullable String tag, @NonNull String msg) {
|
||||||
|
return Log.println(Log.DEBUG, tag, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs {@code msg} at {@link Log#DEBUG} level, attaching stack trace of the {@code tr} to
|
||||||
|
* the end of the log statement.
|
||||||
|
*
|
||||||
|
* @param tag identifies the source of a log message. It usually represents system service,
|
||||||
|
* e.g. {@code PackageManager}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
* @param tr an exception to log.
|
||||||
|
*
|
||||||
|
* @see Log#d(String, String, Throwable)
|
||||||
|
*/
|
||||||
|
public static int d(@Nullable String tag, @NonNull String msg, @Nullable Throwable tr) {
|
||||||
|
return Log.println(Log.DEBUG, tag,
|
||||||
|
msg + '\n' + Log.getStackTraceString(tr));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs {@code msg} at {@link Log#INFO} level.
|
||||||
|
*
|
||||||
|
* @param tag identifies the source of a log message. It usually represents system service,
|
||||||
|
* e.g. {@code PackageManager}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
*
|
||||||
|
* @see Log#i(String, String)
|
||||||
|
*/
|
||||||
|
public static int i(@Nullable String tag, @NonNull String msg) {
|
||||||
|
return Log.println(Log.INFO, tag, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs {@code msg} at {@link Log#INFO} level, attaching stack trace of the {@code tr} to
|
||||||
|
* the end of the log statement.
|
||||||
|
*
|
||||||
|
* @param tag identifies the source of a log message. It usually represents system service,
|
||||||
|
* e.g. {@code PackageManager}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
* @param tr an exception to log.
|
||||||
|
*
|
||||||
|
* @see Log#i(String, String, Throwable)
|
||||||
|
*/
|
||||||
|
public static int i(@Nullable String tag, @NonNull String msg, @Nullable Throwable tr) {
|
||||||
|
return Log.println(Log.INFO, tag,
|
||||||
|
msg + '\n' + Log.getStackTraceString(tr));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs {@code msg} at {@link Log#WARN} level.
|
||||||
|
*
|
||||||
|
* @param tag identifies the source of a log message. It usually represents system service,
|
||||||
|
* e.g. {@code PackageManager}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
*
|
||||||
|
* @see Log#w(String, String)
|
||||||
|
*/
|
||||||
|
public static int w(@Nullable String tag, @NonNull String msg) {
|
||||||
|
return Log.println(Log.WARN, tag, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs {@code msg} at {@link Log#WARN} level, attaching stack trace of the {@code tr} to
|
||||||
|
* the end of the log statement.
|
||||||
|
*
|
||||||
|
* @param tag identifies the source of a log message. It usually represents system service,
|
||||||
|
* e.g. {@code PackageManager}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
* @param tr an exception to log.
|
||||||
|
*
|
||||||
|
* @see Log#w(String, String, Throwable)
|
||||||
|
*/
|
||||||
|
public static int w(@Nullable String tag, @NonNull String msg, @Nullable Throwable tr) {
|
||||||
|
return Log.println(Log.WARN, tag,
|
||||||
|
msg + '\n' + Log.getStackTraceString(tr));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs stack trace of {@code tr} at {@link Log#WARN} level.
|
||||||
|
*
|
||||||
|
* @param tag identifies the source of a log message. It usually represents system service,
|
||||||
|
* e.g. {@code PackageManager}.
|
||||||
|
* @param tr an exception to log.
|
||||||
|
*
|
||||||
|
* @see Log#w(String, Throwable)
|
||||||
|
*/
|
||||||
|
public static int w(@Nullable String tag, @Nullable Throwable tr) {
|
||||||
|
return Log.println(Log.WARN, tag, Log.getStackTraceString(tr));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs {@code msg} at {@link Log#ERROR} level.
|
||||||
|
*
|
||||||
|
* @param tag identifies the source of a log message. It usually represents system service,
|
||||||
|
* e.g. {@code PackageManager}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
*
|
||||||
|
* @see Log#e(String, String)
|
||||||
|
*/
|
||||||
|
public static int e(@Nullable String tag, @NonNull String msg) {
|
||||||
|
return Log.println(Log.ERROR, tag, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs {@code msg} at {@link Log#ERROR} level, attaching stack trace of the {@code tr} to
|
||||||
|
* the end of the log statement.
|
||||||
|
*
|
||||||
|
* @param tag identifies the source of a log message. It usually represents system service,
|
||||||
|
* e.g. {@code PackageManager}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
* @param tr an exception to log.
|
||||||
|
*
|
||||||
|
* @see Log#e(String, String, Throwable)
|
||||||
|
*/
|
||||||
|
public static int e(@Nullable String tag, @NonNull String msg, @Nullable Throwable tr) {
|
||||||
|
return Log.println(Log.ERROR, tag,
|
||||||
|
msg + '\n' + Log.getStackTraceString(tr));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a condition that should never happen.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Similar to {@link Log#wtf(String, String)}, but will never cause the caller to crash, and
|
||||||
|
* will always be handled asynchronously. Primarily to be used by the system server.
|
||||||
|
*
|
||||||
|
* @param tag identifies the source of a log message. It usually represents system service,
|
||||||
|
* e.g. {@code PackageManager}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
*
|
||||||
|
* @see Log#wtf(String, String)
|
||||||
|
*/
|
||||||
|
public static int wtf(@Nullable String tag, @NonNull String msg) {
|
||||||
|
return Log.wtf(tag, msg, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a condition that should never happen, attaching the full call stack to the log.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Similar to {@link Log#wtfStack(String, String)}, but will never cause the caller to crash,
|
||||||
|
* and will always be handled asynchronously. Primarily to be used by the system server.
|
||||||
|
*
|
||||||
|
* @param tag identifies the source of a log message. It usually represents system service,
|
||||||
|
* e.g. {@code PackageManager}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
*
|
||||||
|
* @see Log#wtfStack(String, String)
|
||||||
|
*/
|
||||||
|
public static int wtfStack(@Nullable String tag, @NonNull String msg) {
|
||||||
|
return Log.wtf(tag, msg, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a condition that should never happen, attaching stack trace of the {@code tr} to the
|
||||||
|
* end of the log statement.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Similar to {@link Log#wtf(String, Throwable)}, but will never cause the caller to crash,
|
||||||
|
* and will always be handled asynchronously. Primarily to be used by the system server.
|
||||||
|
*
|
||||||
|
* @param tag identifies the source of a log message. It usually represents system service,
|
||||||
|
* e.g. {@code PackageManager}.
|
||||||
|
* @param tr an exception to log.
|
||||||
|
*
|
||||||
|
* @see Log#wtf(String, Throwable)
|
||||||
|
*/
|
||||||
|
public static int wtf(@Nullable String tag, @Nullable Throwable tr) {
|
||||||
|
return Log.wtf(tag, tr.getMessage(), tr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a condition that should never happen, attaching stack trace of the {@code tr} to the
|
||||||
|
* end of the log statement.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Similar to {@link Log#wtf(String, String, Throwable)}, but will never cause the caller to
|
||||||
|
* crash, and will always be handled asynchronously. Primarily to be used by the system server.
|
||||||
|
*
|
||||||
|
* @param tag identifies the source of a log message. It usually represents system service,
|
||||||
|
* e.g. {@code PackageManager}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
* @param tr an exception to log.
|
||||||
|
*
|
||||||
|
* @see Log#wtf(String, String, Throwable)
|
||||||
|
*/
|
||||||
|
public static int wtf(@Nullable String tag, @NonNull String msg, @Nullable Throwable tr) {
|
||||||
|
return Log.wtf(tag, msg, tr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public static int println(int priority, @Nullable String tag, @NonNull String msg) {
|
||||||
|
return Log.println(priority, tag, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,371 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.util;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
import android.annotation.TestApi;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.SystemClock;
|
||||||
|
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class containing utility methods related to time zones.
|
||||||
|
*/
|
||||||
|
public class TimeUtils {
|
||||||
|
/** @hide */ public TimeUtils() {}
|
||||||
|
/** {@hide} */
|
||||||
|
private static final SimpleDateFormat sLoggingFormat =
|
||||||
|
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public static final SimpleDateFormat sDumpDateFormat =
|
||||||
|
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This timestamp is used in TimeUtils methods and by the SettingsUI to filter time zones
|
||||||
|
* to only "effective" ones in a country. It is compared against the notUsedAfter metadata that
|
||||||
|
* Android records for some time zones.
|
||||||
|
*
|
||||||
|
* <p>What is notUsedAfter?</p>
|
||||||
|
* Android chooses to avoid making users choose between functionally identical time zones at the
|
||||||
|
* expense of not being able to represent local times in the past.
|
||||||
|
*
|
||||||
|
* notUsedAfter exists because some time zones can "merge" with other time zones after a given
|
||||||
|
* point in time (i.e. they change to have identical transitions, offsets, display names, etc.).
|
||||||
|
* From the notUsedAfter time, the zone will express the same local time as the one it merged
|
||||||
|
* with.
|
||||||
|
*
|
||||||
|
* <p>Why hardcoded?</p>
|
||||||
|
* Rather than using System.currentTimeMillis(), a timestamp known to be in the recent past is
|
||||||
|
* used to ensure consistent behavior across devices and time, and avoid assumptions that the
|
||||||
|
* system clock on a device is currently set correctly. The fixed value should be updated
|
||||||
|
* occasionally, but it doesn't have to be very often as effective time zones for a country
|
||||||
|
* don't change very often.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final Instant MIN_USE_DATE_OF_TIMEZONE =
|
||||||
|
Instant.ofEpochMilli(1546300800000L); // 1/1/2019 00:00 UTC
|
||||||
|
|
||||||
|
/** @hide Field length that can hold 999 days of time */
|
||||||
|
public static final int HUNDRED_DAY_FIELD_LEN = 19;
|
||||||
|
|
||||||
|
private static final int SECONDS_PER_MINUTE = 60;
|
||||||
|
private static final int SECONDS_PER_HOUR = 60 * 60;
|
||||||
|
private static final int SECONDS_PER_DAY = 24 * 60 * 60;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public static final long NANOS_PER_MS = 1000000;
|
||||||
|
|
||||||
|
private static final Object sFormatSync = new Object();
|
||||||
|
private static char[] sFormatStr = new char[HUNDRED_DAY_FIELD_LEN+10];
|
||||||
|
private static char[] sTmpFormatStr = new char[HUNDRED_DAY_FIELD_LEN+10];
|
||||||
|
|
||||||
|
static private int accumField(int amt, int suffix, boolean always, int zeropad) {
|
||||||
|
if (amt > 999) {
|
||||||
|
int num = 0;
|
||||||
|
while (amt != 0) {
|
||||||
|
num++;
|
||||||
|
amt /= 10;
|
||||||
|
}
|
||||||
|
return num + suffix;
|
||||||
|
} else {
|
||||||
|
if (amt > 99 || (always && zeropad >= 3)) {
|
||||||
|
return 3+suffix;
|
||||||
|
}
|
||||||
|
if (amt > 9 || (always && zeropad >= 2)) {
|
||||||
|
return 2+suffix;
|
||||||
|
}
|
||||||
|
if (always || amt > 0) {
|
||||||
|
return 1+suffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static private int printFieldLocked(char[] formatStr, int amt, char suffix, int pos,
|
||||||
|
boolean always, int zeropad) {
|
||||||
|
if (always || amt > 0) {
|
||||||
|
final int startPos = pos;
|
||||||
|
if (amt > 999) {
|
||||||
|
int tmp = 0;
|
||||||
|
while (amt != 0 && tmp < sTmpFormatStr.length) {
|
||||||
|
int dig = amt % 10;
|
||||||
|
sTmpFormatStr[tmp] = (char)(dig + '0');
|
||||||
|
tmp++;
|
||||||
|
amt /= 10;
|
||||||
|
}
|
||||||
|
tmp--;
|
||||||
|
while (tmp >= 0) {
|
||||||
|
formatStr[pos] = sTmpFormatStr[tmp];
|
||||||
|
pos++;
|
||||||
|
tmp--;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ((always && zeropad >= 3) || amt > 99) {
|
||||||
|
int dig = amt/100;
|
||||||
|
formatStr[pos] = (char)(dig + '0');
|
||||||
|
pos++;
|
||||||
|
amt -= (dig*100);
|
||||||
|
}
|
||||||
|
if ((always && zeropad >= 2) || amt > 9 || startPos != pos) {
|
||||||
|
int dig = amt/10;
|
||||||
|
formatStr[pos] = (char)(dig + '0');
|
||||||
|
pos++;
|
||||||
|
amt -= (dig*10);
|
||||||
|
}
|
||||||
|
formatStr[pos] = (char)(amt + '0');
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
formatStr[pos] = suffix;
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int formatDurationLocked(long duration, int fieldLen) {
|
||||||
|
if (sFormatStr.length < fieldLen) {
|
||||||
|
sFormatStr = new char[fieldLen];
|
||||||
|
}
|
||||||
|
|
||||||
|
char[] formatStr = sFormatStr;
|
||||||
|
|
||||||
|
if (duration == 0) {
|
||||||
|
int pos = 0;
|
||||||
|
fieldLen -= 1;
|
||||||
|
while (pos < fieldLen) {
|
||||||
|
formatStr[pos++] = ' ';
|
||||||
|
}
|
||||||
|
formatStr[pos] = '0';
|
||||||
|
return pos+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
char prefix;
|
||||||
|
if (duration > 0) {
|
||||||
|
prefix = '+';
|
||||||
|
} else {
|
||||||
|
prefix = '-';
|
||||||
|
duration = -duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
int millis = (int)(duration%1000);
|
||||||
|
int seconds = (int) Math.floor(duration / 1000);
|
||||||
|
int days = 0, hours = 0, minutes = 0;
|
||||||
|
|
||||||
|
if (seconds >= SECONDS_PER_DAY) {
|
||||||
|
days = seconds / SECONDS_PER_DAY;
|
||||||
|
seconds -= days * SECONDS_PER_DAY;
|
||||||
|
}
|
||||||
|
if (seconds >= SECONDS_PER_HOUR) {
|
||||||
|
hours = seconds / SECONDS_PER_HOUR;
|
||||||
|
seconds -= hours * SECONDS_PER_HOUR;
|
||||||
|
}
|
||||||
|
if (seconds >= SECONDS_PER_MINUTE) {
|
||||||
|
minutes = seconds / SECONDS_PER_MINUTE;
|
||||||
|
seconds -= minutes * SECONDS_PER_MINUTE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int pos = 0;
|
||||||
|
|
||||||
|
if (fieldLen != 0) {
|
||||||
|
int myLen = accumField(days, 1, false, 0);
|
||||||
|
myLen += accumField(hours, 1, myLen > 0, 2);
|
||||||
|
myLen += accumField(minutes, 1, myLen > 0, 2);
|
||||||
|
myLen += accumField(seconds, 1, myLen > 0, 2);
|
||||||
|
myLen += accumField(millis, 2, true, myLen > 0 ? 3 : 0) + 1;
|
||||||
|
while (myLen < fieldLen) {
|
||||||
|
formatStr[pos] = ' ';
|
||||||
|
pos++;
|
||||||
|
myLen++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
formatStr[pos] = prefix;
|
||||||
|
pos++;
|
||||||
|
|
||||||
|
int start = pos;
|
||||||
|
boolean zeropad = fieldLen != 0;
|
||||||
|
pos = printFieldLocked(formatStr, days, 'd', pos, false, 0);
|
||||||
|
pos = printFieldLocked(formatStr, hours, 'h', pos, pos != start, zeropad ? 2 : 0);
|
||||||
|
pos = printFieldLocked(formatStr, minutes, 'm', pos, pos != start, zeropad ? 2 : 0);
|
||||||
|
pos = printFieldLocked(formatStr, seconds, 's', pos, pos != start, zeropad ? 2 : 0);
|
||||||
|
pos = printFieldLocked(formatStr, millis, 'm', pos, true, (zeropad && pos != start) ? 3 : 0);
|
||||||
|
formatStr[pos] = 's';
|
||||||
|
return pos + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @hide Just for debugging; not internationalized. */
|
||||||
|
public static void formatDuration(long duration, StringBuilder builder) {
|
||||||
|
synchronized (sFormatSync) {
|
||||||
|
int len = formatDurationLocked(duration, 0);
|
||||||
|
builder.append(sFormatStr, 0, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @hide Just for debugging; not internationalized. */
|
||||||
|
public static void formatDuration(long duration, StringBuilder builder, int fieldLen) {
|
||||||
|
synchronized (sFormatSync) {
|
||||||
|
int len = formatDurationLocked(duration, fieldLen);
|
||||||
|
builder.append(sFormatStr, 0, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @hide Just for debugging; not internationalized. */
|
||||||
|
public static void formatDuration(long duration, PrintWriter pw, int fieldLen) {
|
||||||
|
synchronized (sFormatSync) {
|
||||||
|
int len = formatDurationLocked(duration, fieldLen);
|
||||||
|
pw.print(new String(sFormatStr, 0, len));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @hide Just for debugging; not internationalized. */
|
||||||
|
@TestApi
|
||||||
|
public static String formatDuration(long duration) {
|
||||||
|
synchronized (sFormatSync) {
|
||||||
|
int len = formatDurationLocked(duration, 0);
|
||||||
|
return new String(sFormatStr, 0, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @hide Just for debugging; not internationalized. */
|
||||||
|
public static void formatDuration(long duration, PrintWriter pw) {
|
||||||
|
formatDuration(duration, pw, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @hide Just for debugging; not internationalized. */
|
||||||
|
public static void formatDuration(long time, long now, StringBuilder sb) {
|
||||||
|
if (time == 0) {
|
||||||
|
sb.append("--");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
formatDuration(time-now, sb, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @hide Just for debugging; not internationalized. */
|
||||||
|
public static void formatDuration(long time, long now, PrintWriter pw) {
|
||||||
|
if (time == 0) {
|
||||||
|
pw.print("--");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
formatDuration(time-now, pw, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @hide Just for debugging; not internationalized. */
|
||||||
|
public static String formatUptime(long time) {
|
||||||
|
return formatTime(time, SystemClock.uptimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @hide Just for debugging; not internationalized. */
|
||||||
|
public static String formatRealtime(long time) {
|
||||||
|
return formatTime(time, SystemClock.elapsedRealtime());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @hide Just for debugging; not internationalized. */
|
||||||
|
public static String formatTime(long time, long referenceTime) {
|
||||||
|
long diff = time - referenceTime;
|
||||||
|
if (diff > 0) {
|
||||||
|
return time + " (in " + diff + " ms)";
|
||||||
|
}
|
||||||
|
if (diff < 0) {
|
||||||
|
return time + " (" + -diff + " ms ago)";
|
||||||
|
}
|
||||||
|
return time + " (now)";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a System.currentTimeMillis() value to a time of day value like
|
||||||
|
* that printed in logs. MM-DD HH:MM:SS.MMM
|
||||||
|
*
|
||||||
|
* @param millis since the epoch (1/1/1970)
|
||||||
|
* @return String representation of the time.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static String logTimeOfDay(long millis) {
|
||||||
|
Calendar c = Calendar.getInstance();
|
||||||
|
if (millis >= 0) {
|
||||||
|
c.setTimeInMillis(millis);
|
||||||
|
return String.format("%tm-%td %tH:%tM:%tS.%tL", c, c, c, c, c, c);
|
||||||
|
} else {
|
||||||
|
return Long.toString(millis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@hide} */
|
||||||
|
public static String formatForLogging(long millis) {
|
||||||
|
if (millis <= 0) {
|
||||||
|
return "unknown";
|
||||||
|
} else {
|
||||||
|
return sLoggingFormat.format(new Date(millis));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dump a currentTimeMillis style timestamp for dumpsys.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static void dumpTime(PrintWriter pw, long time) {
|
||||||
|
pw.print(sDumpDateFormat.format(new Date(time)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to find if a clock time is inclusively between two other clock times
|
||||||
|
* @param reference The time of the day we want check if it is between start and end
|
||||||
|
* @param start The start time reference
|
||||||
|
* @param end The end time
|
||||||
|
* @return true if the reference time is between the two clock times, and false otherwise.
|
||||||
|
*/
|
||||||
|
public static boolean isTimeBetween(@NonNull LocalTime reference,
|
||||||
|
@NonNull LocalTime start,
|
||||||
|
@NonNull LocalTime end) {
|
||||||
|
// ////////E----+-----S////////
|
||||||
|
if ((reference.isBefore(start) && reference.isAfter(end)
|
||||||
|
// -----+----S//////////E------
|
||||||
|
|| (reference.isBefore(end) && reference.isBefore(start) && start.isBefore(end))
|
||||||
|
// ---------S//////////E---+---
|
||||||
|
|| (reference.isAfter(end) && reference.isAfter(start)) && start.isBefore(end))) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dump a currentTimeMillis style timestamp for dumpsys, with the delta time from now.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static void dumpTimeWithDelta(PrintWriter pw, long time, long now) {
|
||||||
|
pw.print(sDumpDateFormat.format(new Date(time)));
|
||||||
|
if (time == now) {
|
||||||
|
pw.print(" (now)");
|
||||||
|
} else {
|
||||||
|
pw.print(" (");
|
||||||
|
TimeUtils.formatDuration(time, now, pw);
|
||||||
|
pw.print(")");
|
||||||
|
}
|
||||||
|
}}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package android.os;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supplier for custom trace messages.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public interface TraceNameSupplier {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name used for trace messages.
|
||||||
|
*/
|
||||||
|
@NonNull String getTraceName();
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,247 @@
|
|||||||
|
package android.webkit;
|
||||||
|
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
import xyz.nulldev.androidcompat.webkit.CookieManagerImpl;
|
||||||
|
|
||||||
|
public abstract class CookieManager {
|
||||||
|
/**
|
||||||
|
* @deprecated This class should not be constructed by applications, use {@link #getInstance}
|
||||||
|
* instead to fetch the singleton instance.
|
||||||
|
*/
|
||||||
|
// TODO(ntfschr): mark this as @SystemApi after a year.
|
||||||
|
@Deprecated
|
||||||
|
public CookieManager() {}
|
||||||
|
@Override
|
||||||
|
protected Object clone() throws CloneNotSupportedException {
|
||||||
|
throw new CloneNotSupportedException("doesn't implement Cloneable");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static CookieManager INSTANCE = null;
|
||||||
|
private static final Object lock = new Object();
|
||||||
|
/**
|
||||||
|
* Gets the singleton CookieManager instance.
|
||||||
|
*
|
||||||
|
* @return the singleton CookieManager instance
|
||||||
|
*/
|
||||||
|
public static CookieManager getInstance() {
|
||||||
|
if (INSTANCE != null) {
|
||||||
|
return INSTANCE;
|
||||||
|
} else {
|
||||||
|
synchronized (lock) {
|
||||||
|
if (INSTANCE == null) {
|
||||||
|
INSTANCE = new CookieManagerImpl();
|
||||||
|
}
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Sets whether the application's {@link WebView} instances should send and
|
||||||
|
* accept cookies.
|
||||||
|
* By default this is set to {@code true} and the WebView accepts cookies.
|
||||||
|
* <p>
|
||||||
|
* When this is {@code true}
|
||||||
|
* {@link CookieManager#setAcceptThirdPartyCookies setAcceptThirdPartyCookies} and
|
||||||
|
* {@link CookieManager#setAcceptFileSchemeCookies setAcceptFileSchemeCookies}
|
||||||
|
* can be used to control the policy for those specific types of cookie.
|
||||||
|
*
|
||||||
|
* @param accept whether {@link WebView} instances should send and accept
|
||||||
|
* cookies
|
||||||
|
*/
|
||||||
|
public abstract void setAcceptCookie(boolean accept);
|
||||||
|
/**
|
||||||
|
* Gets whether the application's {@link WebView} instances send and accept
|
||||||
|
* cookies.
|
||||||
|
*
|
||||||
|
* @return {@code true} if {@link WebView} instances send and accept cookies
|
||||||
|
*/
|
||||||
|
public abstract boolean acceptCookie();
|
||||||
|
/**
|
||||||
|
* Sets whether the {@link WebView} should allow third party cookies to be set.
|
||||||
|
* Allowing third party cookies is a per WebView policy and can be set
|
||||||
|
* differently on different WebView instances.
|
||||||
|
* <p>
|
||||||
|
* Apps that target {@link android.os.Build.VERSION_CODES#KITKAT} or below
|
||||||
|
* default to allowing third party cookies. Apps targeting
|
||||||
|
* {@link android.os.Build.VERSION_CODES#LOLLIPOP} or later default to disallowing
|
||||||
|
* third party cookies.
|
||||||
|
*
|
||||||
|
* @param webview the {@link WebView} instance to set the cookie policy on
|
||||||
|
* @param accept whether the {@link WebView} instance should accept
|
||||||
|
* third party cookies
|
||||||
|
*/
|
||||||
|
public abstract void setAcceptThirdPartyCookies(WebView webview, boolean accept);
|
||||||
|
/**
|
||||||
|
* Gets whether the {@link WebView} should allow third party cookies to be set.
|
||||||
|
*
|
||||||
|
* @param webview the {@link WebView} instance to get the cookie policy for
|
||||||
|
* @return {@code true} if the {@link WebView} accepts third party cookies
|
||||||
|
*/
|
||||||
|
public abstract boolean acceptThirdPartyCookies(WebView webview);
|
||||||
|
/**
|
||||||
|
* Sets a single cookie (key-value pair) for the given URL. Any existing cookie with the same
|
||||||
|
* host, path and name will be replaced with the new cookie. The cookie being set
|
||||||
|
* will be ignored if it is expired. To set multiple cookies, your application should invoke
|
||||||
|
* this method multiple times.
|
||||||
|
*
|
||||||
|
* <p>The {@code value} parameter must follow the format of the {@code Set-Cookie} HTTP
|
||||||
|
* response header defined by
|
||||||
|
* <a href="https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03">RFC6265bis</a>.
|
||||||
|
* This is a key-value pair of the form {@code "key=value"}, optionally followed by a list of
|
||||||
|
* cookie attributes delimited with semicolons (ex. {@code "key=value; Max-Age=123"}). Please
|
||||||
|
* consult the RFC specification for a list of valid attributes.
|
||||||
|
*
|
||||||
|
* <p class="note"><b>Note:</b> if specifying a {@code value} containing the {@code "Secure"}
|
||||||
|
* attribute, {@code url} must use the {@code "https://"} scheme.
|
||||||
|
*
|
||||||
|
* @param url the URL for which the cookie is to be set
|
||||||
|
* @param value the cookie as a string, using the format of the 'Set-Cookie'
|
||||||
|
* HTTP response header
|
||||||
|
*/
|
||||||
|
public abstract void setCookie(String url, String value);
|
||||||
|
/**
|
||||||
|
* Sets a single cookie (key-value pair) for the given URL. Any existing cookie with the same
|
||||||
|
* host, path and name will be replaced with the new cookie. The cookie being set
|
||||||
|
* will be ignored if it is expired. To set multiple cookies, your application should invoke
|
||||||
|
* this method multiple times.
|
||||||
|
*
|
||||||
|
* <p>The {@code value} parameter must follow the format of the {@code Set-Cookie} HTTP
|
||||||
|
* response header defined by
|
||||||
|
* <a href="https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03">RFC6265bis</a>.
|
||||||
|
* This is a key-value pair of the form {@code "key=value"}, optionally followed by a list of
|
||||||
|
* cookie attributes delimited with semicolons (ex. {@code "key=value; Max-Age=123"}). Please
|
||||||
|
* consult the RFC specification for a list of valid attributes.
|
||||||
|
*
|
||||||
|
* <p>This method is asynchronous. If a {@link ValueCallback} is provided,
|
||||||
|
* {@link ValueCallback#onReceiveValue} will be called on the current
|
||||||
|
* thread's {@link android.os.Looper} once the operation is complete.
|
||||||
|
* The value provided to the callback indicates whether the cookie was set successfully.
|
||||||
|
* You can pass {@code null} as the callback if you don't need to know when the operation
|
||||||
|
* completes or whether it succeeded, and in this case it is safe to call the method from a
|
||||||
|
* thread without a Looper.
|
||||||
|
*
|
||||||
|
* <p class="note"><b>Note:</b> if specifying a {@code value} containing the {@code "Secure"}
|
||||||
|
* attribute, {@code url} must use the {@code "https://"} scheme.
|
||||||
|
*
|
||||||
|
* @param url the URL for which the cookie is to be set
|
||||||
|
* @param value the cookie as a string, using the format of the 'Set-Cookie'
|
||||||
|
* HTTP response header
|
||||||
|
* @param callback a callback to be executed when the cookie has been set
|
||||||
|
*/
|
||||||
|
public abstract void setCookie(String url, String value, @Nullable ValueCallback<Boolean>
|
||||||
|
callback);
|
||||||
|
/**
|
||||||
|
* Gets all the cookies for the given URL. This may return multiple key-value pairs if multiple
|
||||||
|
* cookies are associated with this URL, in which case each cookie will be delimited by {@code
|
||||||
|
* "; "} characters (semicolon followed by a space). Each key-value pair will be of the form
|
||||||
|
* {@code "key=value"}.
|
||||||
|
*
|
||||||
|
* @param url the URL for which the cookies are requested
|
||||||
|
* @return value the cookies as a string, using the format of the 'Cookie'
|
||||||
|
* HTTP request header
|
||||||
|
*/
|
||||||
|
public abstract String getCookie(String url);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all session cookies, which are cookies without an expiration
|
||||||
|
* date.
|
||||||
|
* @deprecated use {@link #removeSessionCookies(ValueCallback)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public abstract void removeSessionCookie();
|
||||||
|
/**
|
||||||
|
* Removes all session cookies, which are cookies without an expiration
|
||||||
|
* date.
|
||||||
|
* <p>
|
||||||
|
* This method is asynchronous.
|
||||||
|
* If a {@link ValueCallback} is provided,
|
||||||
|
* {@link ValueCallback#onReceiveValue(Object)} will be called on the current
|
||||||
|
* thread's {@link android.os.Looper} once the operation is complete.
|
||||||
|
* The value provided to the callback indicates whether any cookies were removed.
|
||||||
|
* You can pass {@code null} as the callback if you don't need to know when the operation
|
||||||
|
* completes or whether any cookie were removed, and in this case it is safe to call the
|
||||||
|
* method from a thread without a Looper.
|
||||||
|
* @param callback a callback which is executed when the session cookies have been removed
|
||||||
|
*/
|
||||||
|
public abstract void removeSessionCookies(@Nullable ValueCallback<Boolean> callback);
|
||||||
|
/**
|
||||||
|
* Removes all cookies.
|
||||||
|
* @deprecated Use {@link #removeAllCookies(ValueCallback)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public abstract void removeAllCookie();
|
||||||
|
/**
|
||||||
|
* Removes all cookies.
|
||||||
|
* <p>
|
||||||
|
* This method is asynchronous.
|
||||||
|
* If a {@link ValueCallback} is provided,
|
||||||
|
* {@link ValueCallback#onReceiveValue(Object)} will be called on the current
|
||||||
|
* thread's {@link android.os.Looper} once the operation is complete.
|
||||||
|
* The value provided to the callback indicates whether any cookies were removed.
|
||||||
|
* You can pass {@code null} as the callback if you don't need to know when the operation
|
||||||
|
* completes or whether any cookies were removed, and in this case it is safe to call the
|
||||||
|
* method from a thread without a Looper.
|
||||||
|
* @param callback a callback which is executed when the cookies have been removed
|
||||||
|
*/
|
||||||
|
public abstract void removeAllCookies(@Nullable ValueCallback<Boolean> callback);
|
||||||
|
/**
|
||||||
|
* Gets whether there are stored cookies.
|
||||||
|
*
|
||||||
|
* @return {@code true} if there are stored cookies
|
||||||
|
*/
|
||||||
|
public abstract boolean hasCookies();
|
||||||
|
/**
|
||||||
|
* Removes all expired cookies.
|
||||||
|
* @deprecated The WebView handles removing expired cookies automatically.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public abstract void removeExpiredCookie();
|
||||||
|
/**
|
||||||
|
* Ensures all cookies currently accessible through the getCookie API are
|
||||||
|
* written to persistent storage.
|
||||||
|
* This call will block the caller until it is done and may perform I/O.
|
||||||
|
*/
|
||||||
|
public abstract void flush();
|
||||||
|
/**
|
||||||
|
* Gets whether the application's {@link WebView} instances send and accept
|
||||||
|
* cookies for file scheme URLs.
|
||||||
|
*
|
||||||
|
* @return {@code true} if {@link WebView} instances send and accept cookies for
|
||||||
|
* file scheme URLs
|
||||||
|
*/
|
||||||
|
// Static for backward compatibility.
|
||||||
|
public static boolean allowFileSchemeCookies() {
|
||||||
|
return getInstance().allowFileSchemeCookiesImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract boolean allowFileSchemeCookiesImpl();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether the application's {@link WebView} instances should send and accept cookies for
|
||||||
|
* file scheme URLs.
|
||||||
|
* <p>
|
||||||
|
* Use of cookies with file scheme URLs is potentially insecure and turned off by default. All
|
||||||
|
* {@code file://} URLs share all their cookies, which may lead to leaking private app cookies
|
||||||
|
* (ex. any malicious file can access cookies previously set by other (trusted) files).
|
||||||
|
* <p class="note">
|
||||||
|
* Loading content via {@code file://} URLs is generally discouraged. See the note in
|
||||||
|
* {@link WebSettings#setAllowFileAccess}.
|
||||||
|
* Using <a href="{@docRoot}reference/androidx/webkit/WebViewAssetLoader.html">
|
||||||
|
* androidx.webkit.WebViewAssetLoader</a> to load files over {@code http(s)://} URLs allows
|
||||||
|
* the standard web security model to be used for setting and sharing cookies for local files.
|
||||||
|
* <p>
|
||||||
|
* Note that calls to this method will have no effect if made after calling other
|
||||||
|
* {@link CookieManager} APIs.
|
||||||
|
*
|
||||||
|
* @deprecated This setting is not secure, please use
|
||||||
|
* <a href="{@docRoot}reference/androidx/webkit/WebViewAssetLoader.html">
|
||||||
|
* androidx.webkit.WebViewAssetLoader</a> instead.
|
||||||
|
*/
|
||||||
|
// Static for backward compatibility.
|
||||||
|
@Deprecated
|
||||||
|
public static void setAcceptFileSchemeCookies(boolean accept) {
|
||||||
|
getInstance().setAcceptFileSchemeCookiesImpl(accept);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void setAcceptFileSchemeCookiesImpl(boolean accept);
|
||||||
|
}
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2008 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.webkit;
|
||||||
|
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
import android.annotation.SystemApi;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
|
public class WebChromeClient {
|
||||||
|
|
||||||
|
public void onProgressChanged(WebView view, int newProgress) {}
|
||||||
|
|
||||||
|
public void onReceivedTitle(WebView view, String title) {}
|
||||||
|
|
||||||
|
public void onReceivedIcon(WebView view, Bitmap icon) {}
|
||||||
|
|
||||||
|
public void onReceivedTouchIconUrl(WebView view, String url,
|
||||||
|
boolean precomposed) {}
|
||||||
|
|
||||||
|
public interface CustomViewCallback {
|
||||||
|
public void onCustomViewHidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onShowCustomView(View view, CustomViewCallback callback) {};
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public void onShowCustomView(View view, int requestedOrientation,
|
||||||
|
CustomViewCallback callback) {};
|
||||||
|
|
||||||
|
public void onHideCustomView() {}
|
||||||
|
|
||||||
|
public boolean onCreateWindow(WebView view, boolean isDialog,
|
||||||
|
boolean isUserGesture, Message resultMsg) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onRequestFocus(WebView view) {}
|
||||||
|
|
||||||
|
public void onCloseWindow(WebView window) {}
|
||||||
|
|
||||||
|
public boolean onJsAlert(WebView view, String url, String message,
|
||||||
|
JsResult result) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onJsConfirm(WebView view, String url, String message,
|
||||||
|
JsResult result) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onJsPrompt(WebView view, String url, String message,
|
||||||
|
String defaultValue, JsPromptResult result) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onJsBeforeUnload(WebView view, String url, String message,
|
||||||
|
JsResult result) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public void onExceededDatabaseQuota(String url, String databaseIdentifier,
|
||||||
|
long quota, long estimatedDatabaseSize, long totalQuota,
|
||||||
|
WebStorage.QuotaUpdater quotaUpdater) {
|
||||||
|
// This default implementation passes the current quota back to WebCore.
|
||||||
|
// WebCore will interpret this that new quota was declined.
|
||||||
|
quotaUpdater.updateQuota(quota);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public void onReachedMaxAppCacheSize(long requiredStorage, long quota,
|
||||||
|
WebStorage.QuotaUpdater quotaUpdater) {
|
||||||
|
quotaUpdater.updateQuota(quota);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onGeolocationPermissionsShowPrompt(String origin,
|
||||||
|
GeolocationPermissions.Callback callback) {}
|
||||||
|
|
||||||
|
public void onGeolocationPermissionsHidePrompt() {}
|
||||||
|
|
||||||
|
public void onPermissionRequest(PermissionRequest request) {
|
||||||
|
request.deny();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPermissionRequestCanceled(PermissionRequest request) {}
|
||||||
|
|
||||||
|
// This method was only called when using the JSC javascript engine. V8 became
|
||||||
|
// the default JS engine with Froyo and support for building with JSC was
|
||||||
|
// removed in b/5495373. V8 does not have a mechanism for making a callback such
|
||||||
|
// as this.
|
||||||
|
@Deprecated
|
||||||
|
public boolean onJsTimeout() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public void onConsoleMessage(String message, int lineNumber, String sourceID) { }
|
||||||
|
|
||||||
|
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
|
||||||
|
// Call the old version of this function for backwards compatability.
|
||||||
|
onConsoleMessage(consoleMessage.message(), consoleMessage.lineNumber(),
|
||||||
|
consoleMessage.sourceId());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Bitmap getDefaultVideoPoster() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public View getVideoLoadingProgressView() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Obtains a list of all visited history items, used for link coloring
|
||||||
|
*/
|
||||||
|
public void getVisitedHistory(ValueCallback<String[]> callback) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback,
|
||||||
|
FileChooserParams fileChooserParams) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static abstract class FileChooserParams {
|
||||||
|
@SystemApi
|
||||||
|
public static final long ENABLE_FILE_SYSTEM_ACCESS = 364980165L;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
public @interface Mode {}
|
||||||
|
|
||||||
|
/** Open single file. Requires that the file exists before allowing the user to pick it. */
|
||||||
|
public static final int MODE_OPEN = 0;
|
||||||
|
/** Like Open but allows multiple files to be selected. */
|
||||||
|
public static final int MODE_OPEN_MULTIPLE = 1;
|
||||||
|
/** Like Open but allows a folder to be selected. */
|
||||||
|
public static final int MODE_OPEN_FOLDER = 2;
|
||||||
|
/** Allows picking a nonexistent file and saving it. */
|
||||||
|
public static final int MODE_SAVE = 3;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
public @interface PermissionMode {}
|
||||||
|
|
||||||
|
/** File or directory should be opened for reading only. */
|
||||||
|
public static final int PERMISSION_MODE_READ = 0;
|
||||||
|
/** File or directory should be opened for read and write. */
|
||||||
|
public static final int PERMISSION_MODE_READ_WRITE = 1;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static Uri[] parseResult(int resultCode, Intent data) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Mode
|
||||||
|
public abstract int getMode();
|
||||||
|
|
||||||
|
public abstract String[] getAcceptTypes();
|
||||||
|
|
||||||
|
public abstract boolean isCaptureEnabled();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract CharSequence getTitle();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String getFilenameHint();
|
||||||
|
|
||||||
|
@PermissionMode
|
||||||
|
public int getPermissionMode() {
|
||||||
|
return PERMISSION_MODE_READ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Intent createIntent();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SystemApi
|
||||||
|
@Deprecated
|
||||||
|
public void openFileChooser(ValueCallback<Uri> uploadFile, String acceptType, String capture) {
|
||||||
|
uploadFile.onReceiveValue(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,609 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2008 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.webkit;
|
||||||
|
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.net.http.SslError;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.view.InputEvent;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
|
public class WebViewClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Give the host application a chance to take control when a URL is about to be loaded in the
|
||||||
|
* current WebView. If a WebViewClient is not provided, by default WebView will ask Activity
|
||||||
|
* Manager to choose the proper handler for the URL. If a WebViewClient is provided, returning
|
||||||
|
* {@code true} causes the current WebView to abort loading the URL, while returning
|
||||||
|
* {@code false} causes the WebView to continue loading the URL as usual.
|
||||||
|
*
|
||||||
|
* <p class="note"><b>Note:</b> Do not call {@link WebView#loadUrl(String)} with the same
|
||||||
|
* URL and then return {@code true}. This unnecessarily cancels the current load and starts a
|
||||||
|
* new load with the same URL. The correct way to continue loading a given URL is to simply
|
||||||
|
* return {@code false}, without calling {@link WebView#loadUrl(String)}.
|
||||||
|
*
|
||||||
|
* <p class="note"><b>Note:</b> This method is not called for POST requests.
|
||||||
|
*
|
||||||
|
* <p class="note"><b>Note:</b> This method may be called for subframes and with non-HTTP(S)
|
||||||
|
* schemes; calling {@link WebView#loadUrl(String)} with such a URL will fail.
|
||||||
|
*
|
||||||
|
* @param view The WebView that is initiating the callback.
|
||||||
|
* @param url The URL to be loaded.
|
||||||
|
* @return {@code true} to cancel the current load, otherwise return {@code false}.
|
||||||
|
* @deprecated Use {@link #shouldOverrideUrlLoading(WebView, WebResourceRequest)
|
||||||
|
* shouldOverrideUrlLoading(WebView, WebResourceRequest)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Give the host application a chance to take control when a URL is about to be loaded in the
|
||||||
|
* current WebView. If a WebViewClient is not provided, by default WebView will ask Activity
|
||||||
|
* Manager to choose the proper handler for the URL. If a WebViewClient is provided, returning
|
||||||
|
* {@code true} causes the current WebView to abort loading the URL, while returning
|
||||||
|
* {@code false} causes the WebView to continue loading the URL as usual.
|
||||||
|
*
|
||||||
|
* <p>This callback is not called for all page navigations. In particular, this is not called
|
||||||
|
* for navigations which the app initiated with {@code loadUrl()}: this callback would not serve
|
||||||
|
* a purpose in this case, because the app already knows about the navigation. This callback
|
||||||
|
* lets the app know about navigations initiated by the web page (such as navigations initiated
|
||||||
|
* by JavaScript code), by the user (such as when the user taps on a link), or by an HTTP
|
||||||
|
* redirect (ex. if {@code loadUrl("foo.com")} redirects to {@code "bar.com"} because of HTTP
|
||||||
|
* 301).
|
||||||
|
*
|
||||||
|
* <p class="note"><b>Note:</b> Do not call {@link WebView#loadUrl(String)} with the request's
|
||||||
|
* URL and then return {@code true}. This unnecessarily cancels the current load and starts a
|
||||||
|
* new load with the same URL. The correct way to continue loading a given URL is to simply
|
||||||
|
* return {@code false}, without calling {@link WebView#loadUrl(String)}.
|
||||||
|
*
|
||||||
|
* <p class="note"><b>Note:</b> This method is not called for POST requests.
|
||||||
|
*
|
||||||
|
* <p class="note"><b>Note:</b> This method may be called for subframes and with non-HTTP(S)
|
||||||
|
* schemes; calling {@link WebView#loadUrl(String)} with such a URL will fail.
|
||||||
|
*
|
||||||
|
* @param view The WebView that is initiating the callback.
|
||||||
|
* @param request Object containing the details of the request.
|
||||||
|
* @return {@code true} to cancel the current load, otherwise return {@code false}.
|
||||||
|
*/
|
||||||
|
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
|
||||||
|
return shouldOverrideUrlLoading(view, request.getUrl().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the host application that a page has started loading. This method
|
||||||
|
* is called once for each main frame load so a page with iframes or
|
||||||
|
* framesets will call onPageStarted one time for the main frame. This also
|
||||||
|
* means that onPageStarted will not be called when the contents of an
|
||||||
|
* embedded frame changes, i.e. clicking a link whose target is an iframe,
|
||||||
|
* it will also not be called for fragment navigations (navigations to
|
||||||
|
* #fragment_id).
|
||||||
|
*
|
||||||
|
* @param view The WebView that is initiating the callback.
|
||||||
|
* @param url The url to be loaded.
|
||||||
|
* @param favicon The favicon for this page if it already exists in the
|
||||||
|
* database.
|
||||||
|
*/
|
||||||
|
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the host application that a page has finished loading. This method
|
||||||
|
* is called only for main frame. Receiving an {@code onPageFinished()} callback does not
|
||||||
|
* guarantee that the next frame drawn by WebView will reflect the state of the DOM at this
|
||||||
|
* point. In order to be notified that the current DOM state is ready to be rendered, request a
|
||||||
|
* visual state callback with {@link WebView#postVisualStateCallback} and wait for the supplied
|
||||||
|
* callback to be triggered.
|
||||||
|
*
|
||||||
|
* @param view The WebView that is initiating the callback.
|
||||||
|
* @param url The url of the page.
|
||||||
|
*/
|
||||||
|
public void onPageFinished(WebView view, String url) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the host application that the WebView will load the resource
|
||||||
|
* specified by the given url.
|
||||||
|
*
|
||||||
|
* @param view The WebView that is initiating the callback.
|
||||||
|
* @param url The url of the resource the WebView will load.
|
||||||
|
*/
|
||||||
|
public void onLoadResource(WebView view, String url) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the host application that {@link android.webkit.WebView} content left over from
|
||||||
|
* previous page navigations will no longer be drawn.
|
||||||
|
*
|
||||||
|
* <p>This callback can be used to determine the point at which it is safe to make a recycled
|
||||||
|
* {@link android.webkit.WebView} visible, ensuring that no stale content is shown. It is called
|
||||||
|
* at the earliest point at which it can be guaranteed that {@link WebView#onDraw} will no
|
||||||
|
* longer draw any content from previous navigations. The next draw will display either the
|
||||||
|
* {@link WebView#setBackgroundColor background color} of the {@link WebView}, or some of the
|
||||||
|
* contents of the newly loaded page.
|
||||||
|
*
|
||||||
|
* <p>This method is called when the body of the HTTP response has started loading, is reflected
|
||||||
|
* in the DOM, and will be visible in subsequent draws. This callback occurs early in the
|
||||||
|
* document loading process, and as such you should expect that linked resources (for example,
|
||||||
|
* CSS and images) may not be available.
|
||||||
|
*
|
||||||
|
* <p>For more fine-grained notification of visual state updates, see {@link
|
||||||
|
* WebView#postVisualStateCallback}.
|
||||||
|
*
|
||||||
|
* <p>Please note that all the conditions and recommendations applicable to
|
||||||
|
* {@link WebView#postVisualStateCallback} also apply to this API.
|
||||||
|
*
|
||||||
|
* <p>This callback is only called for main frame navigations.
|
||||||
|
*
|
||||||
|
* @param view The {@link android.webkit.WebView} for which the navigation occurred.
|
||||||
|
* @param url The URL corresponding to the page navigation that triggered this callback.
|
||||||
|
*/
|
||||||
|
public void onPageCommitVisible(WebView view, String url) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the host application of a resource request and allow the
|
||||||
|
* application to return the data. If the return value is {@code null}, the WebView
|
||||||
|
* will continue to load the resource as usual. Otherwise, the return
|
||||||
|
* response and data will be used.
|
||||||
|
*
|
||||||
|
* <p>This callback is invoked for a variety of URL schemes (e.g., {@code http(s):}, {@code
|
||||||
|
* data:}, {@code file:}, etc.), not only those schemes which send requests over the network.
|
||||||
|
* This is not called for {@code javascript:} URLs, {@code blob:} URLs, or for assets accessed
|
||||||
|
* via {@code file:///android_asset/} or {@code file:///android_res/} URLs.
|
||||||
|
*
|
||||||
|
* <p>In the case of redirects, this is only called for the initial resource URL, not any
|
||||||
|
* subsequent redirect URLs.
|
||||||
|
*
|
||||||
|
* <p class="note"><b>Note:</b> This method is called on a thread
|
||||||
|
* other than the UI thread so clients should exercise caution
|
||||||
|
* when accessing private data or the view system.
|
||||||
|
*
|
||||||
|
* <p class="note"><b>Note:</b> When Safe Browsing is enabled, these URLs still undergo Safe
|
||||||
|
* Browsing checks. If this is undesired, you can use {@link WebView#setSafeBrowsingWhitelist}
|
||||||
|
* to skip Safe Browsing checks for that host or dismiss the warning in {@link
|
||||||
|
* #onSafeBrowsingHit} by calling {@link SafeBrowsingResponse#proceed}.
|
||||||
|
*
|
||||||
|
* @param view The {@link android.webkit.WebView} that is requesting the
|
||||||
|
* resource.
|
||||||
|
* @param url The raw url of the resource.
|
||||||
|
* @return A {@link android.webkit.WebResourceResponse} containing the
|
||||||
|
* response information or {@code null} if the WebView should load the
|
||||||
|
* resource itself.
|
||||||
|
* @deprecated Use {@link #shouldInterceptRequest(WebView, WebResourceRequest)
|
||||||
|
* shouldInterceptRequest(WebView, WebResourceRequest)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Nullable
|
||||||
|
public WebResourceResponse shouldInterceptRequest(WebView view,
|
||||||
|
String url) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the host application of a resource request and allow the
|
||||||
|
* application to return the data. If the return value is {@code null}, the WebView
|
||||||
|
* will continue to load the resource as usual. Otherwise, the return
|
||||||
|
* response and data will be used.
|
||||||
|
*
|
||||||
|
* <p>This callback is invoked for a variety of URL schemes (e.g., {@code http(s):}, {@code
|
||||||
|
* data:}, {@code file:}, etc.), not only those schemes which send requests over the network.
|
||||||
|
* This is not called for {@code javascript:} URLs, {@code blob:} URLs, or for assets accessed
|
||||||
|
* via {@code file:///android_asset/} or {@code file:///android_res/} URLs.
|
||||||
|
*
|
||||||
|
* <p>In the case of redirects, this is only called for the initial resource URL, not any
|
||||||
|
* subsequent redirect URLs.
|
||||||
|
*
|
||||||
|
* <p class="note"><b>Note:</b> This method is called on a thread
|
||||||
|
* other than the UI thread so clients should exercise caution
|
||||||
|
* when accessing private data or the view system.
|
||||||
|
*
|
||||||
|
* <p class="note"><b>Note:</b> When Safe Browsing is enabled, these URLs still undergo Safe
|
||||||
|
* Browsing checks. If this is undesired, you can use {@link WebView#setSafeBrowsingWhitelist}
|
||||||
|
* to skip Safe Browsing checks for that host or dismiss the warning in {@link
|
||||||
|
* #onSafeBrowsingHit} by calling {@link SafeBrowsingResponse#proceed}.
|
||||||
|
*
|
||||||
|
* @param view The {@link android.webkit.WebView} that is requesting the
|
||||||
|
* resource.
|
||||||
|
* @param request Object containing the details of the request.
|
||||||
|
* @return A {@link android.webkit.WebResourceResponse} containing the
|
||||||
|
* response information or {@code null} if the WebView should load the
|
||||||
|
* resource itself.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public WebResourceResponse shouldInterceptRequest(WebView view,
|
||||||
|
WebResourceRequest request) {
|
||||||
|
return shouldInterceptRequest(view, request.getUrl().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the host application that there have been an excessive number of
|
||||||
|
* HTTP redirects. As the host application if it would like to continue
|
||||||
|
* trying to load the resource. The default behavior is to send the cancel
|
||||||
|
* message.
|
||||||
|
*
|
||||||
|
* @param view The WebView that is initiating the callback.
|
||||||
|
* @param cancelMsg The message to send if the host wants to cancel
|
||||||
|
* @param continueMsg The message to send if the host wants to continue
|
||||||
|
* @deprecated This method is no longer called. When the WebView encounters
|
||||||
|
* a redirect loop, it will cancel the load.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public void onTooManyRedirects(WebView view, Message cancelMsg,
|
||||||
|
Message continueMsg) {
|
||||||
|
cancelMsg.sendToTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
// These ints must match up to the hidden values in EventHandler.
|
||||||
|
/** Generic error */
|
||||||
|
public static final int ERROR_UNKNOWN = -1;
|
||||||
|
/** Server or proxy hostname lookup failed */
|
||||||
|
public static final int ERROR_HOST_LOOKUP = -2;
|
||||||
|
/** Unsupported authentication scheme (not basic or digest) */
|
||||||
|
public static final int ERROR_UNSUPPORTED_AUTH_SCHEME = -3;
|
||||||
|
/** User authentication failed on server */
|
||||||
|
public static final int ERROR_AUTHENTICATION = -4;
|
||||||
|
/** User authentication failed on proxy */
|
||||||
|
public static final int ERROR_PROXY_AUTHENTICATION = -5;
|
||||||
|
/** Failed to connect to the server */
|
||||||
|
public static final int ERROR_CONNECT = -6;
|
||||||
|
/** Failed to read or write to the server */
|
||||||
|
public static final int ERROR_IO = -7;
|
||||||
|
/** Connection timed out */
|
||||||
|
public static final int ERROR_TIMEOUT = -8;
|
||||||
|
/** Too many redirects */
|
||||||
|
public static final int ERROR_REDIRECT_LOOP = -9;
|
||||||
|
/** Unsupported URI scheme */
|
||||||
|
public static final int ERROR_UNSUPPORTED_SCHEME = -10;
|
||||||
|
/** Failed to perform SSL handshake */
|
||||||
|
public static final int ERROR_FAILED_SSL_HANDSHAKE = -11;
|
||||||
|
/** Malformed URL */
|
||||||
|
public static final int ERROR_BAD_URL = -12;
|
||||||
|
/** Generic file error */
|
||||||
|
public static final int ERROR_FILE = -13;
|
||||||
|
/** File not found */
|
||||||
|
public static final int ERROR_FILE_NOT_FOUND = -14;
|
||||||
|
/** Too many requests during this load */
|
||||||
|
public static final int ERROR_TOO_MANY_REQUESTS = -15;
|
||||||
|
/** Resource load was canceled by Safe Browsing */
|
||||||
|
public static final int ERROR_UNSAFE_RESOURCE = -16;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
public @interface SafeBrowsingThreat {}
|
||||||
|
|
||||||
|
/** The resource was blocked for an unknown reason. */
|
||||||
|
public static final int SAFE_BROWSING_THREAT_UNKNOWN = 0;
|
||||||
|
/** The resource was blocked because it contains malware. */
|
||||||
|
public static final int SAFE_BROWSING_THREAT_MALWARE = 1;
|
||||||
|
/** The resource was blocked because it contains deceptive content. */
|
||||||
|
public static final int SAFE_BROWSING_THREAT_PHISHING = 2;
|
||||||
|
/** The resource was blocked because it contains unwanted software. */
|
||||||
|
public static final int SAFE_BROWSING_THREAT_UNWANTED_SOFTWARE = 3;
|
||||||
|
/**
|
||||||
|
* The resource was blocked because it may trick the user into a billing agreement.
|
||||||
|
*
|
||||||
|
* <p>This constant is only used when targetSdkVersion is at least {@link
|
||||||
|
* android.os.Build.VERSION_CODES#Q}. Otherwise, {@link #SAFE_BROWSING_THREAT_UNKNOWN} is used
|
||||||
|
* instead.
|
||||||
|
*/
|
||||||
|
public static final int SAFE_BROWSING_THREAT_BILLING = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report an error to the host application. These errors are unrecoverable
|
||||||
|
* (i.e. the main resource is unavailable). The {@code errorCode} parameter
|
||||||
|
* corresponds to one of the {@code ERROR_*} constants.
|
||||||
|
* @param view The WebView that is initiating the callback.
|
||||||
|
* @param errorCode The error code corresponding to an ERROR_* value.
|
||||||
|
* @param description A String describing the error.
|
||||||
|
* @param failingUrl The url that failed to load.
|
||||||
|
* @deprecated Use {@link #onReceivedError(WebView, WebResourceRequest, WebResourceError)
|
||||||
|
* onReceivedError(WebView, WebResourceRequest, WebResourceError)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public void onReceivedError(WebView view, int errorCode,
|
||||||
|
String description, String failingUrl) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report web resource loading error to the host application. These errors usually indicate
|
||||||
|
* inability to connect to the server. Note that unlike the deprecated version of the callback,
|
||||||
|
* the new version will be called for any resource (iframe, image, etc.), not just for the main
|
||||||
|
* page. Thus, it is recommended to perform minimum required work in this callback.
|
||||||
|
* @param view The WebView that is initiating the callback.
|
||||||
|
* @param request The originating request.
|
||||||
|
* @param error Information about the error occurred.
|
||||||
|
*/
|
||||||
|
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
|
||||||
|
if (request.isForMainFrame()) {
|
||||||
|
onReceivedError(view,
|
||||||
|
error.getErrorCode(), error.getDescription().toString(),
|
||||||
|
request.getUrl().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the host application that an HTTP error has been received from the server while
|
||||||
|
* loading a resource. HTTP errors have status codes >= 400. This callback will be called
|
||||||
|
* for any resource (iframe, image, etc.), not just for the main page. Thus, it is recommended
|
||||||
|
* to perform minimum required work in this callback. Note that the content of the server
|
||||||
|
* response may not be provided within the {@code errorResponse} parameter.
|
||||||
|
* @param view The WebView that is initiating the callback.
|
||||||
|
* @param request The originating request.
|
||||||
|
* @param errorResponse Information about the error occurred.
|
||||||
|
*/
|
||||||
|
public void onReceivedHttpError(
|
||||||
|
WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* As the host application if the browser should resend data as the
|
||||||
|
* requested page was a result of a POST. The default is to not resend the
|
||||||
|
* data.
|
||||||
|
*
|
||||||
|
* @param view The WebView that is initiating the callback.
|
||||||
|
* @param dontResend The message to send if the browser should not resend
|
||||||
|
* @param resend The message to send if the browser should resend data
|
||||||
|
*/
|
||||||
|
public void onFormResubmission(WebView view, Message dontResend,
|
||||||
|
Message resend) {
|
||||||
|
dontResend.sendToTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the host application to update its visited links database.
|
||||||
|
*
|
||||||
|
* @param view The WebView that is initiating the callback.
|
||||||
|
* @param url The url being visited.
|
||||||
|
* @param isReload {@code true} if this url is being reloaded.
|
||||||
|
*/
|
||||||
|
public void doUpdateVisitedHistory(WebView view, String url,
|
||||||
|
boolean isReload) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies the host application that an SSL error occurred while loading a
|
||||||
|
* resource. The host application must call either
|
||||||
|
* {@link SslErrorHandler#cancel()} or {@link SslErrorHandler#proceed()}.
|
||||||
|
*
|
||||||
|
* <p class="warning"><b>Warning:</b> Application overrides of this method
|
||||||
|
* can be used to display custom error pages or to silently log issues, but
|
||||||
|
* the host application should always call {@code SslErrorHandler#cancel()}
|
||||||
|
* and never proceed past errors.
|
||||||
|
*
|
||||||
|
* <p class="note"><b>Note:</b> Do not prompt the user about SSL errors.
|
||||||
|
* Users are unlikely to be able to make an informed security decision, and
|
||||||
|
* {@code WebView} does not provide a UI for showing the details of the
|
||||||
|
* error in a meaningful way.
|
||||||
|
*
|
||||||
|
* <p>The decision to call {@code proceed()} or {@code cancel()} may be
|
||||||
|
* retained to facilitate responses to future SSL errors. The default
|
||||||
|
* behavior is to cancel the resource loading process.
|
||||||
|
*
|
||||||
|
* <p>This API is called only for recoverable SSL certificate errors. For
|
||||||
|
* non-recoverable errors (such as when the server fails the client), the
|
||||||
|
* {@code WebView} calls {@link #onReceivedError(WebView,
|
||||||
|
* WebResourceRequest, WebResourceError) onReceivedError(WebView,
|
||||||
|
* WebResourceRequest, WebResourceError)} with the
|
||||||
|
* {@link #ERROR_FAILED_SSL_HANDSHAKE} argument.
|
||||||
|
*
|
||||||
|
* @param view {@code WebView} that initiated the callback.
|
||||||
|
* @param handler {@link SslErrorHandler} that handles the user's response.
|
||||||
|
* @param error SSL error object.
|
||||||
|
*/
|
||||||
|
public void onReceivedSslError(WebView view, SslErrorHandler handler,
|
||||||
|
SslError error) {
|
||||||
|
handler.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the host application to handle a SSL client certificate request. The host application
|
||||||
|
* is responsible for showing the UI if desired and providing the keys. There are three ways to
|
||||||
|
* respond: {@link ClientCertRequest#proceed}, {@link ClientCertRequest#cancel}, or {@link
|
||||||
|
* ClientCertRequest#ignore}. Webview stores the response in memory (for the life of the
|
||||||
|
* application) if {@link ClientCertRequest#proceed} or {@link ClientCertRequest#cancel} is
|
||||||
|
* called and does not call {@code onReceivedClientCertRequest()} again for the same host and
|
||||||
|
* port pair. Webview does not store the response if {@link ClientCertRequest#ignore}
|
||||||
|
* is called. Note that, multiple layers in chromium network stack might be
|
||||||
|
* caching the responses, so the behavior for ignore is only a best case
|
||||||
|
* effort.
|
||||||
|
*
|
||||||
|
* This method is called on the UI thread. During the callback, the
|
||||||
|
* connection is suspended.
|
||||||
|
*
|
||||||
|
* For most use cases, the application program should implement the
|
||||||
|
* {@link android.security.KeyChainAliasCallback} interface and pass it to
|
||||||
|
* {@link android.security.KeyChain#choosePrivateKeyAlias} to start an
|
||||||
|
* activity for the user to choose the proper alias. The keychain activity will
|
||||||
|
* provide the alias through the callback method in the implemented interface. Next
|
||||||
|
* the application should create an async task to call
|
||||||
|
* {@link android.security.KeyChain#getPrivateKey} to receive the key.
|
||||||
|
*
|
||||||
|
* An example implementation of client certificates can be seen at
|
||||||
|
* <A href="https://android.googlesource.com/platform/packages/apps/Browser/+/android-5.1.1_r1/src/com/android/browser/Tab.java">
|
||||||
|
* AOSP Browser</a>
|
||||||
|
*
|
||||||
|
* The default behavior is to cancel, returning no client certificate.
|
||||||
|
*
|
||||||
|
* @param view The WebView that is initiating the callback
|
||||||
|
* @param request An instance of a {@link ClientCertRequest}
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void onReceivedClientCertRequest(WebView view, ClientCertRequest request) {
|
||||||
|
request.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies the host application that the WebView received an HTTP
|
||||||
|
* authentication request. The host application can use the supplied
|
||||||
|
* {@link HttpAuthHandler} to set the WebView's response to the request.
|
||||||
|
* The default behavior is to cancel the request.
|
||||||
|
*
|
||||||
|
* <p class="note"><b>Note:</b> The supplied HttpAuthHandler must be used on
|
||||||
|
* the UI thread.
|
||||||
|
*
|
||||||
|
* @param view the WebView that is initiating the callback
|
||||||
|
* @param handler the HttpAuthHandler used to set the WebView's response
|
||||||
|
* @param host the host requiring authentication
|
||||||
|
* @param realm the realm for which authentication is required
|
||||||
|
* @see WebView#getHttpAuthUsernamePassword
|
||||||
|
*/
|
||||||
|
public void onReceivedHttpAuthRequest(WebView view,
|
||||||
|
HttpAuthHandler handler, String host, String realm) {
|
||||||
|
handler.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Give the host application a chance to handle the key event synchronously.
|
||||||
|
* e.g. menu shortcut key events need to be filtered this way. If return
|
||||||
|
* true, WebView will not handle the key event. If return {@code false}, WebView
|
||||||
|
* will always handle the key event, so none of the super in the view chain
|
||||||
|
* will see the key event. The default behavior returns {@code false}.
|
||||||
|
*
|
||||||
|
* @param view The WebView that is initiating the callback.
|
||||||
|
* @param event The key event.
|
||||||
|
* @return {@code true} if the host application wants to handle the key event
|
||||||
|
* itself, otherwise return {@code false}
|
||||||
|
*/
|
||||||
|
public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the host application that a key was not handled by the WebView.
|
||||||
|
* Except system keys, WebView always consumes the keys in the normal flow
|
||||||
|
* or if {@link #shouldOverrideKeyEvent} returns {@code true}. This is called asynchronously
|
||||||
|
* from where the key is dispatched. It gives the host application a chance
|
||||||
|
* to handle the unhandled key events.
|
||||||
|
*
|
||||||
|
* @param view The WebView that is initiating the callback.
|
||||||
|
* @param event The key event.
|
||||||
|
*/
|
||||||
|
public void onUnhandledKeyEvent(WebView view, KeyEvent event) {
|
||||||
|
onUnhandledInputEventInternal(view, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the host application that a input event was not handled by the WebView.
|
||||||
|
* Except system keys, WebView always consumes input events in the normal flow
|
||||||
|
* or if {@link #shouldOverrideKeyEvent} returns {@code true}. This is called asynchronously
|
||||||
|
* from where the event is dispatched. It gives the host application a chance
|
||||||
|
* to handle the unhandled input events.
|
||||||
|
*
|
||||||
|
* Note that if the event is a {@link android.view.MotionEvent}, then it's lifetime is only
|
||||||
|
* that of the function call. If the WebViewClient wishes to use the event beyond that, then it
|
||||||
|
* <i>must</i> create a copy of the event.
|
||||||
|
*
|
||||||
|
* It is the responsibility of overriders of this method to call
|
||||||
|
* {@link #onUnhandledKeyEvent(WebView, KeyEvent)}
|
||||||
|
* when appropriate if they wish to continue receiving events through it.
|
||||||
|
*
|
||||||
|
* @param view The WebView that is initiating the callback.
|
||||||
|
* @param event The input event.
|
||||||
|
* @removed
|
||||||
|
*/
|
||||||
|
public void onUnhandledInputEvent(WebView view, InputEvent event) {
|
||||||
|
if (event instanceof KeyEvent) {
|
||||||
|
onUnhandledKeyEvent(view, (KeyEvent) event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
onUnhandledInputEventInternal(view, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onUnhandledInputEventInternal(WebView view, InputEvent event) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the host application that the scale applied to the WebView has
|
||||||
|
* changed.
|
||||||
|
*
|
||||||
|
* @param view The WebView that is initiating the callback.
|
||||||
|
* @param oldScale The old scale factor
|
||||||
|
* @param newScale The new scale factor
|
||||||
|
*/
|
||||||
|
public void onScaleChanged(WebView view, float oldScale, float newScale) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the host application that a request to automatically log in the
|
||||||
|
* user has been processed.
|
||||||
|
* @param view The WebView requesting the login.
|
||||||
|
* @param realm The account realm used to look up accounts.
|
||||||
|
* @param account An optional account. If not {@code null}, the account should be
|
||||||
|
* checked against accounts on the device. If it is a valid
|
||||||
|
* account, it should be used to log in the user.
|
||||||
|
* @param args Authenticator specific arguments used to log in the user.
|
||||||
|
*/
|
||||||
|
public void onReceivedLoginRequest(WebView view, String realm,
|
||||||
|
@Nullable String account, String args) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify host application that the given WebView's render process has exited.
|
||||||
|
*
|
||||||
|
* Multiple WebView instances may be associated with a single render process;
|
||||||
|
* onRenderProcessGone will be called for each WebView that was affected.
|
||||||
|
* The application's implementation of this callback should only attempt to
|
||||||
|
* clean up the specific WebView given as a parameter, and should not assume
|
||||||
|
* that other WebView instances are affected.
|
||||||
|
*
|
||||||
|
* The given WebView can't be used, and should be removed from the view hierarchy,
|
||||||
|
* all references to it should be cleaned up, e.g any references in the Activity
|
||||||
|
* or other classes saved using {@link android.view.View#findViewById} and similar calls, etc.
|
||||||
|
*
|
||||||
|
* To cause an render process crash for test purpose, the application can
|
||||||
|
* call {@code loadUrl("chrome://crash")} on the WebView. Note that multiple WebView
|
||||||
|
* instances may be affected if they share a render process, not just the
|
||||||
|
* specific WebView which loaded chrome://crash.
|
||||||
|
*
|
||||||
|
* @param view The WebView which needs to be cleaned up.
|
||||||
|
* @param detail the reason why it exited.
|
||||||
|
* @return {@code true} if the host application handled the situation that process has
|
||||||
|
* exited, otherwise, application will crash if render process crashed,
|
||||||
|
* or be killed if render process was killed by the system.
|
||||||
|
*/
|
||||||
|
public boolean onRenderProcessGone(WebView view, RenderProcessGoneDetail detail) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the host application that a loading URL has been flagged by Safe Browsing.
|
||||||
|
*
|
||||||
|
* The application must invoke the callback to indicate the preferred response. The default
|
||||||
|
* behavior is to show an interstitial to the user, with the reporting checkbox visible.
|
||||||
|
*
|
||||||
|
* If the application needs to show its own custom interstitial UI, the callback can be invoked
|
||||||
|
* asynchronously with {@link SafeBrowsingResponse#backToSafety} or {@link
|
||||||
|
* SafeBrowsingResponse#proceed}, depending on user response.
|
||||||
|
*
|
||||||
|
* @param view The WebView that hit the malicious resource.
|
||||||
|
* @param request Object containing the details of the request.
|
||||||
|
* @param threatType The reason the resource was caught by Safe Browsing, corresponding to a
|
||||||
|
* {@code SAFE_BROWSING_THREAT_*} value.
|
||||||
|
* @param callback Applications must invoke one of the callback methods.
|
||||||
|
*/
|
||||||
|
public void onSafeBrowsingHit(WebView view, WebResourceRequest request,
|
||||||
|
@SafeBrowsingThreat int threatType, SafeBrowsingResponse callback) {
|
||||||
|
callback.showInterstitial(/* allowReporting */ true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,541 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2012 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.webkit;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.annotation.SystemApi;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.Picture;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.net.http.SslCertificate;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.print.PrintDocumentAdapter;
|
||||||
|
import android.util.LongSparseArray;
|
||||||
|
import android.util.SparseArray;
|
||||||
|
import android.view.DragEvent;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.PointerIcon;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup.LayoutParams;
|
||||||
|
import android.view.WindowInsets;
|
||||||
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
|
import android.view.accessibility.AccessibilityNodeInfo;
|
||||||
|
import android.view.accessibility.AccessibilityNodeProvider;
|
||||||
|
import android.view.autofill.AutofillId;
|
||||||
|
import android.view.autofill.AutofillValue;
|
||||||
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.view.inputmethod.InputConnection;
|
||||||
|
import android.view.textclassifier.TextClassifier;
|
||||||
|
import android.webkit.WebView.HitTestResult;
|
||||||
|
import android.webkit.WebView.PictureListener;
|
||||||
|
import android.webkit.WebView.VisualStateCallback;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WebView backend provider interface: this interface is the abstract backend to a WebView
|
||||||
|
* instance; each WebView object is bound to exactly one WebViewProvider object which implements
|
||||||
|
* the runtime behavior of that WebView.
|
||||||
|
*
|
||||||
|
* All methods must behave as per their namesake in {@link WebView}, unless otherwise noted.
|
||||||
|
*
|
||||||
|
* @hide Not part of the public API; only required by system implementors.
|
||||||
|
*/
|
||||||
|
@SystemApi
|
||||||
|
public interface WebViewProvider {
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
// Main interface for backend provider of the WebView class.
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* Initialize this WebViewProvider instance. Called after the WebView has fully constructed.
|
||||||
|
* @param javaScriptInterfaces is a Map of interface names, as keys, and
|
||||||
|
* object implementing those interfaces, as values.
|
||||||
|
* @param privateBrowsing If {@code true} the web view will be initialized in private /
|
||||||
|
* incognito mode.
|
||||||
|
*/
|
||||||
|
public void init(Map<String, Object> javaScriptInterfaces,
|
||||||
|
boolean privateBrowsing);
|
||||||
|
|
||||||
|
// Deprecated - should never be called
|
||||||
|
public void setHorizontalScrollbarOverlay(boolean overlay);
|
||||||
|
|
||||||
|
// Deprecated - should never be called
|
||||||
|
public void setVerticalScrollbarOverlay(boolean overlay);
|
||||||
|
|
||||||
|
// Deprecated - should never be called
|
||||||
|
public boolean overlayHorizontalScrollbar();
|
||||||
|
|
||||||
|
// Deprecated - should never be called
|
||||||
|
public boolean overlayVerticalScrollbar();
|
||||||
|
|
||||||
|
public int getVisibleTitleHeight();
|
||||||
|
|
||||||
|
public SslCertificate getCertificate();
|
||||||
|
|
||||||
|
public void setCertificate(SslCertificate certificate);
|
||||||
|
|
||||||
|
public void savePassword(String host, String username, String password);
|
||||||
|
|
||||||
|
public void setHttpAuthUsernamePassword(String host, String realm,
|
||||||
|
String username, String password);
|
||||||
|
|
||||||
|
public String[] getHttpAuthUsernamePassword(String host, String realm);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See {@link WebView#destroy()}.
|
||||||
|
* As well as releasing the internal state and resources held by the implementation,
|
||||||
|
* the provider should null all references it holds on the WebView proxy class, and ensure
|
||||||
|
* no further method calls are made to it.
|
||||||
|
*/
|
||||||
|
public void destroy();
|
||||||
|
|
||||||
|
public void setNetworkAvailable(boolean networkUp);
|
||||||
|
|
||||||
|
public WebBackForwardList saveState(Bundle outState);
|
||||||
|
|
||||||
|
public boolean savePicture(Bundle b, final File dest);
|
||||||
|
|
||||||
|
public boolean restorePicture(Bundle b, File src);
|
||||||
|
|
||||||
|
public WebBackForwardList restoreState(Bundle inState);
|
||||||
|
|
||||||
|
public void loadUrl(String url, Map<String, String> additionalHttpHeaders);
|
||||||
|
|
||||||
|
public void loadUrl(String url);
|
||||||
|
|
||||||
|
public void postUrl(String url, byte[] postData);
|
||||||
|
|
||||||
|
public void loadData(String data, String mimeType, String encoding);
|
||||||
|
|
||||||
|
public void loadDataWithBaseURL(String baseUrl, String data,
|
||||||
|
String mimeType, String encoding, String historyUrl);
|
||||||
|
|
||||||
|
public void evaluateJavaScript(String script, ValueCallback<String> resultCallback);
|
||||||
|
|
||||||
|
public void saveWebArchive(String filename);
|
||||||
|
|
||||||
|
public void saveWebArchive(String basename, boolean autoname, ValueCallback<String> callback);
|
||||||
|
|
||||||
|
public void stopLoading();
|
||||||
|
|
||||||
|
public void reload();
|
||||||
|
|
||||||
|
public boolean canGoBack();
|
||||||
|
|
||||||
|
public void goBack();
|
||||||
|
|
||||||
|
public boolean canGoForward();
|
||||||
|
|
||||||
|
public void goForward();
|
||||||
|
|
||||||
|
public boolean canGoBackOrForward(int steps);
|
||||||
|
|
||||||
|
public void goBackOrForward(int steps);
|
||||||
|
|
||||||
|
public boolean isPrivateBrowsingEnabled();
|
||||||
|
|
||||||
|
public boolean pageUp(boolean top);
|
||||||
|
|
||||||
|
public boolean pageDown(boolean bottom);
|
||||||
|
|
||||||
|
public void insertVisualStateCallback(long requestId, VisualStateCallback callback);
|
||||||
|
|
||||||
|
public void clearView();
|
||||||
|
|
||||||
|
public Picture capturePicture();
|
||||||
|
|
||||||
|
public PrintDocumentAdapter createPrintDocumentAdapter(String documentName);
|
||||||
|
|
||||||
|
public float getScale();
|
||||||
|
|
||||||
|
public void setInitialScale(int scaleInPercent);
|
||||||
|
|
||||||
|
public void invokeZoomPicker();
|
||||||
|
|
||||||
|
public HitTestResult getHitTestResult();
|
||||||
|
|
||||||
|
public void requestFocusNodeHref(Message hrefMsg);
|
||||||
|
|
||||||
|
public void requestImageRef(Message msg);
|
||||||
|
|
||||||
|
public String getUrl();
|
||||||
|
|
||||||
|
public String getOriginalUrl();
|
||||||
|
|
||||||
|
public String getTitle();
|
||||||
|
|
||||||
|
public Bitmap getFavicon();
|
||||||
|
|
||||||
|
public String getTouchIconUrl();
|
||||||
|
|
||||||
|
public int getProgress();
|
||||||
|
|
||||||
|
public int getContentHeight();
|
||||||
|
|
||||||
|
public int getContentWidth();
|
||||||
|
|
||||||
|
public void pauseTimers();
|
||||||
|
|
||||||
|
public void resumeTimers();
|
||||||
|
|
||||||
|
public void onPause();
|
||||||
|
|
||||||
|
public void onResume();
|
||||||
|
|
||||||
|
public boolean isPaused();
|
||||||
|
|
||||||
|
public void freeMemory();
|
||||||
|
|
||||||
|
public void clearCache(boolean includeDiskFiles);
|
||||||
|
|
||||||
|
public void clearFormData();
|
||||||
|
|
||||||
|
public void clearHistory();
|
||||||
|
|
||||||
|
public void clearSslPreferences();
|
||||||
|
|
||||||
|
public WebBackForwardList copyBackForwardList();
|
||||||
|
|
||||||
|
public void setFindListener(WebView.FindListener listener);
|
||||||
|
|
||||||
|
public void findNext(boolean forward);
|
||||||
|
|
||||||
|
public int findAll(String find);
|
||||||
|
|
||||||
|
public void findAllAsync(String find);
|
||||||
|
|
||||||
|
public boolean showFindDialog(String text, boolean showIme);
|
||||||
|
|
||||||
|
public void clearMatches();
|
||||||
|
|
||||||
|
public void documentHasImages(Message response);
|
||||||
|
|
||||||
|
public void setWebViewClient(WebViewClient client);
|
||||||
|
|
||||||
|
public WebViewClient getWebViewClient();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public WebViewRenderProcess getWebViewRenderProcess();
|
||||||
|
|
||||||
|
public void setWebViewRenderProcessClient(
|
||||||
|
@Nullable Executor executor,
|
||||||
|
@Nullable WebViewRenderProcessClient client);
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public WebViewRenderProcessClient getWebViewRenderProcessClient();
|
||||||
|
|
||||||
|
public void setDownloadListener(DownloadListener listener);
|
||||||
|
|
||||||
|
public void setWebChromeClient(WebChromeClient client);
|
||||||
|
|
||||||
|
public WebChromeClient getWebChromeClient();
|
||||||
|
|
||||||
|
public void setPictureListener(PictureListener listener);
|
||||||
|
|
||||||
|
public void addJavascriptInterface(Object obj, String interfaceName);
|
||||||
|
|
||||||
|
public void removeJavascriptInterface(String interfaceName);
|
||||||
|
|
||||||
|
public WebMessagePort[] createWebMessageChannel();
|
||||||
|
|
||||||
|
public void postMessageToMainFrame(WebMessage message, Uri targetOrigin);
|
||||||
|
|
||||||
|
public WebSettings getSettings();
|
||||||
|
|
||||||
|
public void setMapTrackballToArrowKeys(boolean setMap);
|
||||||
|
|
||||||
|
public void flingScroll(int vx, int vy);
|
||||||
|
|
||||||
|
public View getZoomControls();
|
||||||
|
|
||||||
|
public boolean canZoomIn();
|
||||||
|
|
||||||
|
public boolean canZoomOut();
|
||||||
|
|
||||||
|
public boolean zoomBy(float zoomFactor);
|
||||||
|
|
||||||
|
public boolean zoomIn();
|
||||||
|
|
||||||
|
public boolean zoomOut();
|
||||||
|
|
||||||
|
public void dumpViewHierarchyWithProperties(BufferedWriter out, int level);
|
||||||
|
|
||||||
|
public View findHierarchyView(String className, int hashCode);
|
||||||
|
|
||||||
|
public void setRendererPriorityPolicy(int rendererRequestedPriority, boolean waivedWhenNotVisible);
|
||||||
|
|
||||||
|
public int getRendererRequestedPriority();
|
||||||
|
|
||||||
|
public boolean getRendererPriorityWaivedWhenNotVisible();
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public default void setTextClassifier(@Nullable TextClassifier textClassifier) {}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public default TextClassifier getTextClassifier() { return TextClassifier.NO_OP; }
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
// Provider internal methods
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the ViewDelegate implementation. This provides the functionality to back all of
|
||||||
|
* the name-sake functions from the View and ViewGroup base classes of WebView.
|
||||||
|
*/
|
||||||
|
/* package */ ViewDelegate getViewDelegate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a ScrollDelegate implementation. Normally this would be same object as is
|
||||||
|
* returned by getViewDelegate().
|
||||||
|
*/
|
||||||
|
/* package */ ScrollDelegate getScrollDelegate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only used by FindActionModeCallback to inform providers that the find dialog has
|
||||||
|
* been dismissed.
|
||||||
|
*/
|
||||||
|
public void notifyFindDialogDismissed();
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
// View / ViewGroup delegation methods
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides mechanism for the name-sake methods declared in View and ViewGroup to be delegated
|
||||||
|
* into the WebViewProvider instance.
|
||||||
|
* NOTE: For many of these methods, the WebView will provide a super.Foo() call before or after
|
||||||
|
* making the call into the provider instance. This is done for convenience in the common case
|
||||||
|
* of maintaining backward compatibility. For remaining super class calls (e.g. where the
|
||||||
|
* provider may need to only conditionally make the call based on some internal state) see the
|
||||||
|
* {@link WebView.PrivateAccess} callback class.
|
||||||
|
*/
|
||||||
|
// TODO: See if the pattern of the super-class calls can be rationalized at all, and document
|
||||||
|
// the remainder on the methods below.
|
||||||
|
interface ViewDelegate {
|
||||||
|
public boolean shouldDelayChildPressedState();
|
||||||
|
|
||||||
|
public void onProvideVirtualStructure(android.view.ViewStructure structure);
|
||||||
|
|
||||||
|
default void onProvideAutofillVirtualStructure(
|
||||||
|
@SuppressWarnings("unused") android.view.ViewStructure structure,
|
||||||
|
@SuppressWarnings("unused") int flags) {
|
||||||
|
}
|
||||||
|
|
||||||
|
default void autofill(@SuppressWarnings("unused") SparseArray<AutofillValue> values) {
|
||||||
|
}
|
||||||
|
|
||||||
|
default boolean isVisibleToUserForAutofill(@SuppressWarnings("unused") int virtualId) {
|
||||||
|
return true; // true is the default value returned by View.isVisibleToUserForAutofill()
|
||||||
|
}
|
||||||
|
|
||||||
|
default void onProvideContentCaptureStructure(
|
||||||
|
@NonNull @SuppressWarnings("unused") android.view.ViewStructure structure,
|
||||||
|
@SuppressWarnings("unused") int flags) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// @SuppressLint("NullableCollection")
|
||||||
|
// default void onCreateVirtualViewTranslationRequests(
|
||||||
|
// @NonNull @SuppressWarnings("unused") long[] virtualIds,
|
||||||
|
// @NonNull @SuppressWarnings("unused") @DataFormat int[] supportedFormats,
|
||||||
|
// @NonNull @SuppressWarnings("unused")
|
||||||
|
// Consumer<ViewTranslationRequest> requestsCollector) {
|
||||||
|
// }
|
||||||
|
|
||||||
|
// default void onVirtualViewTranslationResponses(
|
||||||
|
// @NonNull @SuppressWarnings("unused")
|
||||||
|
// LongSparseArray<ViewTranslationResponse> response) {
|
||||||
|
// }
|
||||||
|
|
||||||
|
// default void dispatchCreateViewTranslationRequest(
|
||||||
|
// @NonNull @SuppressWarnings("unused") Map<AutofillId, long[]> viewIds,
|
||||||
|
// @NonNull @SuppressWarnings("unused") @DataFormat int[] supportedFormats,
|
||||||
|
// @Nullable @SuppressWarnings("unused") TranslationCapability capability,
|
||||||
|
// @NonNull @SuppressWarnings("unused") List<ViewTranslationRequest> requests) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
public AccessibilityNodeProvider getAccessibilityNodeProvider();
|
||||||
|
|
||||||
|
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info);
|
||||||
|
|
||||||
|
public void onInitializeAccessibilityEvent(AccessibilityEvent event);
|
||||||
|
|
||||||
|
public boolean performAccessibilityAction(int action, Bundle arguments);
|
||||||
|
|
||||||
|
public void setOverScrollMode(int mode);
|
||||||
|
|
||||||
|
public void setScrollBarStyle(int style);
|
||||||
|
|
||||||
|
public void onDrawVerticalScrollBar(Canvas canvas, Drawable scrollBar, int l, int t,
|
||||||
|
int r, int b);
|
||||||
|
|
||||||
|
public void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY);
|
||||||
|
|
||||||
|
public void onWindowVisibilityChanged(int visibility);
|
||||||
|
|
||||||
|
public void onDraw(Canvas canvas);
|
||||||
|
|
||||||
|
public void setLayoutParams(LayoutParams layoutParams);
|
||||||
|
|
||||||
|
public boolean performLongClick();
|
||||||
|
|
||||||
|
public void onConfigurationChanged(Configuration newConfig);
|
||||||
|
|
||||||
|
public InputConnection onCreateInputConnection(EditorInfo outAttrs);
|
||||||
|
|
||||||
|
public boolean onDragEvent(DragEvent event);
|
||||||
|
|
||||||
|
public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event);
|
||||||
|
|
||||||
|
public boolean onKeyDown(int keyCode, KeyEvent event);
|
||||||
|
|
||||||
|
public boolean onKeyUp(int keyCode, KeyEvent event);
|
||||||
|
|
||||||
|
public void onAttachedToWindow();
|
||||||
|
|
||||||
|
public void onDetachedFromWindow();
|
||||||
|
|
||||||
|
public default void onMovedToDisplay(int displayId, Configuration config) {}
|
||||||
|
|
||||||
|
public void onVisibilityChanged(View changedView, int visibility);
|
||||||
|
|
||||||
|
public void onWindowFocusChanged(boolean hasWindowFocus);
|
||||||
|
|
||||||
|
public void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect);
|
||||||
|
|
||||||
|
public boolean setFrame(int left, int top, int right, int bottom);
|
||||||
|
|
||||||
|
public void onSizeChanged(int w, int h, int ow, int oh);
|
||||||
|
|
||||||
|
public void onScrollChanged(int l, int t, int oldl, int oldt);
|
||||||
|
|
||||||
|
public boolean dispatchKeyEvent(KeyEvent event);
|
||||||
|
|
||||||
|
public boolean onTouchEvent(MotionEvent ev);
|
||||||
|
|
||||||
|
public boolean onHoverEvent(MotionEvent event);
|
||||||
|
|
||||||
|
public boolean onGenericMotionEvent(MotionEvent event);
|
||||||
|
|
||||||
|
public boolean onTrackballEvent(MotionEvent ev);
|
||||||
|
|
||||||
|
public boolean requestFocus(int direction, Rect previouslyFocusedRect);
|
||||||
|
|
||||||
|
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec);
|
||||||
|
|
||||||
|
public boolean requestChildRectangleOnScreen(View child, Rect rect, boolean immediate);
|
||||||
|
|
||||||
|
public void setBackgroundColor(int color);
|
||||||
|
|
||||||
|
public void setLayerType(int layerType, Paint paint);
|
||||||
|
|
||||||
|
public void preDispatchDraw(Canvas canvas);
|
||||||
|
|
||||||
|
public void onStartTemporaryDetach();
|
||||||
|
|
||||||
|
public void onFinishTemporaryDetach();
|
||||||
|
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data);
|
||||||
|
|
||||||
|
public Handler getHandler(Handler originalHandler);
|
||||||
|
|
||||||
|
public View findFocus(View originalFocusedView);
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
default boolean onCheckIsTextEditor() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see View#onApplyWindowInsets(WindowInsets).
|
||||||
|
*
|
||||||
|
* <p>This is the entry point for the WebView implementation to override. It returns
|
||||||
|
* {@code null} when the WebView implementation hasn't implemented the WindowInsets support
|
||||||
|
* on S yet. In this case, the {@link View#onApplyWindowInsets()} super method will be
|
||||||
|
* called instead.
|
||||||
|
*
|
||||||
|
* @param insets Insets to apply
|
||||||
|
* @return The supplied insets with any applied insets consumed.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Nullable
|
||||||
|
default WindowInsets onApplyWindowInsets(@Nullable WindowInsets insets) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide Only used by WebView.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Nullable
|
||||||
|
default PointerIcon onResolvePointerIcon(@NonNull MotionEvent event, int pointerIndex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ScrollDelegate {
|
||||||
|
// These methods are declared protected in the ViewGroup base class. This interface
|
||||||
|
// exists to promote them to public so they may be called by the WebView proxy class.
|
||||||
|
// TODO: Combine into ViewDelegate?
|
||||||
|
/**
|
||||||
|
* See {@link android.webkit.WebView#computeHorizontalScrollRange}
|
||||||
|
*/
|
||||||
|
public int computeHorizontalScrollRange();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See {@link android.webkit.WebView#computeHorizontalScrollOffset}
|
||||||
|
*/
|
||||||
|
public int computeHorizontalScrollOffset();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See {@link android.webkit.WebView#computeVerticalScrollRange}
|
||||||
|
*/
|
||||||
|
public int computeVerticalScrollRange();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See {@link android.webkit.WebView#computeVerticalScrollOffset}
|
||||||
|
*/
|
||||||
|
public int computeVerticalScrollOffset();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See {@link android.webkit.WebView#computeVerticalScrollExtent}
|
||||||
|
*/
|
||||||
|
public int computeVerticalScrollExtent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See {@link android.webkit.WebView#computeScroll}
|
||||||
|
*/
|
||||||
|
public void computeScroll();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.widget;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.RemoteViews.RemoteView;
|
||||||
|
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@RemoteView
|
||||||
|
public class AbsoluteLayout extends ViewGroup {
|
||||||
|
public AbsoluteLayout(Context context) {
|
||||||
|
this(context, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbsoluteLayout(Context context, AttributeSet attrs) {
|
||||||
|
this(context, attrs, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbsoluteLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
this(context, attrs, defStyleAttr, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbsoluteLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
|
||||||
|
return new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onLayout(boolean changed, int l, int t,
|
||||||
|
int r, int b) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) {
|
||||||
|
return new AbsoluteLayout.LayoutParams(getContext(), attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override to allow type-checking of LayoutParams.
|
||||||
|
@Override
|
||||||
|
protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
|
||||||
|
return p instanceof AbsoluteLayout.LayoutParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
|
||||||
|
return new LayoutParams(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldDelayChildPressedState() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class LayoutParams extends ViewGroup.LayoutParams {
|
||||||
|
public int x;
|
||||||
|
public int y;
|
||||||
|
|
||||||
|
public LayoutParams(int width, int height, int x, int y) {
|
||||||
|
super(width, height);
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LayoutParams(Context c, AttributeSet attrs) {
|
||||||
|
super(c, attrs);
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public LayoutParams(ViewGroup.LayoutParams source) {
|
||||||
|
super(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String debug(String output) {
|
||||||
|
return output + "Absolute.LayoutParams={width="
|
||||||
|
+ String.valueOf(width) + ", height=" + String.valueOf(height)
|
||||||
|
+ " x=" + x + " y=" + y + "}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package android.widget;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
public class EditText {
|
||||||
|
public EditText(android.content.Context context) { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
public EditText(android.content.Context context, android.util.AttributeSet attrs) { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
public EditText(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr) { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
public EditText(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr, int defStyleRes) { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
public boolean getFreezesText() { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
protected boolean getDefaultEditable() { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
protected android.text.method.MovementMethod getDefaultMovementMethod() { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
public android.text.Editable getText() { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
public void setText(java.lang.CharSequence text, android.widget.TextView.BufferType type) { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
public void setSelection(int start, int stop) { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
public void setSelection(int index) { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
public void selectAll() { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
public void extendSelection(int index) { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
public void setEllipsize(android.text.TextUtils.TruncateAt ellipsis) { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
public java.lang.CharSequence getAccessibilityClassName() { throw new RuntimeException("Stub!"); }
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package android.widget;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
public class Toast {
|
||||||
|
public static final int LENGTH_LONG = 1;
|
||||||
|
public static final int LENGTH_SHORT = 0;
|
||||||
|
|
||||||
|
private CharSequence text;
|
||||||
|
|
||||||
|
private Toast(CharSequence text) {
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Toast(android.content.Context context) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void show() {
|
||||||
|
System.out.printf("made a Toast: \"%s\"\n", text.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancel() {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setView(android.view.View view) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public android.view.View getView() {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDuration(int duration) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDuration() {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMargin(float horizontalMargin, float verticalMargin) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getHorizontalMargin() {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getVerticalMargin() {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGravity(int gravity, int xOffset, int yOffset) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGravity() {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getXOffset() {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getYOffset() {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Toast makeText(android.content.Context context, java.lang.CharSequence text, int duration) {
|
||||||
|
return new Toast(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static android.widget.Toast makeText(android.content.Context context, int resId, int duration) throws android.content.res.Resources.NotFoundException {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(int resId) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(java.lang.CharSequence s) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@file:Suppress("NOTHING_TO_INLINE") // Aliases to public API.
|
||||||
|
|
||||||
|
package androidx.core.net
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Uri from the given encoded URI string.
|
||||||
|
*
|
||||||
|
* @see Uri.parse
|
||||||
|
*/
|
||||||
|
public inline fun String.toUri(): Uri = Uri.parse(this)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Uri from the given file.
|
||||||
|
*
|
||||||
|
* @see Uri.fromFile
|
||||||
|
*/
|
||||||
|
public inline fun File.toUri(): Uri = Uri.fromFile(this)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a [File] from the given [Uri]. Note that this will throw an
|
||||||
|
* [IllegalArgumentException] when invoked on a [Uri] that lacks `file` scheme.
|
||||||
|
*/
|
||||||
|
public fun Uri.toFile(): File {
|
||||||
|
require(scheme == "file") { "Uri lacks 'file' scheme: $this" }
|
||||||
|
return File(requireNotNull(path) { "Uri path is null: $this" })
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package androidx.preference;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
public class CheckBoxPreference extends TwoStatePreference {
|
||||||
|
// reference: https://android.googlesource.com/platform/frameworks/support/+/996971f962fcd554339a7cb2859cef9ca89dbcb7/preference/preference/src/main/java/androidx/preference/CheckBoxPreference.java
|
||||||
|
|
||||||
|
public CheckBoxPreference(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package androidx.preference;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
public abstract class DialogPreference extends Preference {
|
||||||
|
private CharSequence dialogTitle;
|
||||||
|
private CharSequence dialogMessage;
|
||||||
|
|
||||||
|
public DialogPreference(Context context) { super(context); }
|
||||||
|
|
||||||
|
public CharSequence getDialogTitle() {
|
||||||
|
return dialogTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDialogTitle(CharSequence dialogTitle) {
|
||||||
|
this.dialogTitle = dialogTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CharSequence getDialogMessage() {
|
||||||
|
return dialogMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDialogMessage(CharSequence dialogMessage) {
|
||||||
|
this.dialogMessage = dialogMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package androidx.preference;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
|
public class EditTextPreference extends DialogPreference {
|
||||||
|
// reference: https://android.googlesource.com/platform/frameworks/support/+/996971f962fcd554339a7cb2859cef9ca89dbcb7/preference/preference/src/main/java/androidx/preference/EditTextPreference.java
|
||||||
|
|
||||||
|
private String text;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
private OnBindEditTextListener onBindEditTextListener;
|
||||||
|
|
||||||
|
public EditTextPreference(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OnBindEditTextListener getOnBindEditTextListener() {
|
||||||
|
return onBindEditTextListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnBindEditTextListener(@Nullable OnBindEditTextListener onBindEditTextListener) {
|
||||||
|
this.onBindEditTextListener = onBindEditTextListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnBindEditTextListener {
|
||||||
|
void onBindEditText(@NonNull EditText editText);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Tachidesk specific API */
|
||||||
|
@Override
|
||||||
|
public String getDefaultValueType() {
|
||||||
|
return "String";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package androidx.preference;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
|
public class ListPreference extends Preference {
|
||||||
|
// reference: https://android.googlesource.com/platform/frameworks/support/+/996971f962fcd554339a7cb2859cef9ca89dbcb7/preference/preference/src/main/java/androidx/preference/ListPreference.java
|
||||||
|
// Note: remove @JsonIgnore and implement methods if any extension ever uses these methods or the variables behind them
|
||||||
|
|
||||||
|
private CharSequence[] entries;
|
||||||
|
private CharSequence[] entryValues;
|
||||||
|
|
||||||
|
public ListPreference(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CharSequence[] getEntries() {
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntries(CharSequence[] entries) {
|
||||||
|
this.entries = entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int findIndexOfValue(String value) {
|
||||||
|
if (value != null && entryValues != null) {
|
||||||
|
for (int i = entryValues.length - 1; i >= 0; i--) {
|
||||||
|
if (TextUtils.equals(entryValues[i].toString(), value)) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CharSequence[] getEntryValues() {
|
||||||
|
return entryValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntryValues(CharSequence[] entryValues) {
|
||||||
|
this.entryValues = entryValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public void setValueIndex(int index) { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getValue() { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public void setValue(String value) { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
/** Tachidesk specific API */
|
||||||
|
@Override
|
||||||
|
public String getDefaultValueType() {
|
||||||
|
return "String";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package androidx.preference;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class MultiSelectListPreference extends DialogPreference {
|
||||||
|
// reference: https://android.googlesource.com/platform/frameworks/support/+/996971f962fcd554339a7cb2859cef9ca89dbcb7/preference/preference/src/main/java/androidx/preference/MultiSelectListPreference.java
|
||||||
|
// Note: remove @JsonIgnore and implement methods if any extension ever uses these methods or the variables behind them
|
||||||
|
|
||||||
|
private CharSequence[] entries;
|
||||||
|
private CharSequence[] entryValues;
|
||||||
|
|
||||||
|
public MultiSelectListPreference(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntries(CharSequence[] entries) {
|
||||||
|
this.entries = entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CharSequence[] getEntries() {
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntryValues(CharSequence[] entryValues) {
|
||||||
|
this.entryValues = entryValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CharSequence[] getEntryValues() {
|
||||||
|
return entryValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public void setValues(Set<String> values) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public Set<String> getValues() {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int findIndexOfValue(String value) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Tachidesk specific API */
|
||||||
|
@Override
|
||||||
|
public String getDefaultValueType() {
|
||||||
|
return "Set<String>";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
package androidx.preference;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A minimal implementation of androidx.preference.Preference
|
||||||
|
*/
|
||||||
|
public class Preference {
|
||||||
|
// reference: https://android.googlesource.com/platform/frameworks/support/+/996971f962fcd554339a7cb2859cef9ca89dbcb7/preference/preference/src/main/java/androidx/preference/Preference.java
|
||||||
|
// Note: `Preference` doesn't actually hold or persist the value, `OnPreferenceChangeListener` is called and it's up to the extension to persist it.
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
protected Context context;
|
||||||
|
|
||||||
|
private boolean isVisible;
|
||||||
|
private boolean isEnabled = true;
|
||||||
|
private String key;
|
||||||
|
private CharSequence title;
|
||||||
|
private CharSequence summary;
|
||||||
|
private Object defaultValue;
|
||||||
|
|
||||||
|
/** Tachidesk specific API */
|
||||||
|
@JsonIgnore
|
||||||
|
private SharedPreferences sharedPreferences;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public OnPreferenceChangeListener onChangeListener;
|
||||||
|
|
||||||
|
public Preference(Context context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Context getContext() {
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnPreferenceChangeListener(OnPreferenceChangeListener onPreferenceChangeListener) {
|
||||||
|
this.onChangeListener = onPreferenceChangeListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnPreferenceClickListener(OnPreferenceClickListener onPreferenceClickListener) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public CharSequence getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(CharSequence title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CharSequence getSummary() {
|
||||||
|
return summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSummary(CharSequence summary) {
|
||||||
|
this.summary = summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
isEnabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return isEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultValue(Object defaultValue) {
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean callChangeListener(Object newValue) {
|
||||||
|
return onChangeListener == null || onChangeListener.onPreferenceChange(this, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getDefaultValue() {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Tachidesk specific API */
|
||||||
|
public String getDefaultValueType() {
|
||||||
|
return defaultValue.getClass().getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Tachidesk specific API */
|
||||||
|
public SharedPreferences getSharedPreferences() {
|
||||||
|
return sharedPreferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVisible(boolean visible) {
|
||||||
|
isVisible = visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getVisible() {
|
||||||
|
return isVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Tachidesk specific API */
|
||||||
|
public void setSharedPreferences(SharedPreferences sharedPreferences) {
|
||||||
|
this.sharedPreferences = sharedPreferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnPreferenceChangeListener {
|
||||||
|
boolean onPreferenceChange(Preference preference, Object newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnPreferenceClickListener {
|
||||||
|
boolean onPreferenceClick(Preference preference);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Tachidesk specific API */
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Object getCurrentValue() {
|
||||||
|
switch (getDefaultValueType()) {
|
||||||
|
case "String":
|
||||||
|
return sharedPreferences.getString(key, (String)defaultValue);
|
||||||
|
case "Boolean":
|
||||||
|
return sharedPreferences.getBoolean(key, (Boolean)defaultValue);
|
||||||
|
case "Set<String>":
|
||||||
|
return sharedPreferences.getStringSet(key, (Set<String>)defaultValue);
|
||||||
|
default:
|
||||||
|
throw new RuntimeException("Unsupported type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Tachidesk specific API */
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void saveNewValue(Object value) {
|
||||||
|
switch (getDefaultValueType()) {
|
||||||
|
case "String":
|
||||||
|
sharedPreferences.edit().putString(key, (String)value).apply();
|
||||||
|
break;
|
||||||
|
case "Boolean":
|
||||||
|
sharedPreferences.edit().putBoolean(key, (Boolean)value).apply();
|
||||||
|
break;
|
||||||
|
case "Set<String>":
|
||||||
|
sharedPreferences.edit().putStringSet(key, (Set<String>)value).apply();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new RuntimeException("Unsupported type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package androidx.preference;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PreferenceScreen extends Preference {
|
||||||
|
/** Tachidesk specific API */
|
||||||
|
private List<Preference> preferences = new LinkedList<>();
|
||||||
|
|
||||||
|
public PreferenceScreen(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addPreference(Preference preference) {
|
||||||
|
// propagate own shared preferences
|
||||||
|
preference.setSharedPreferences(getSharedPreferences());
|
||||||
|
|
||||||
|
preferences.add(preference);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Tachidesk specific API */
|
||||||
|
public List<Preference> getPreferences(){
|
||||||
|
return preferences;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package androidx.preference;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
public class SwitchPreferenceCompat extends TwoStatePreference {
|
||||||
|
// reference: https://android.googlesource.com/platform/frameworks/support/+/996971f962fcd554339a7cb2859cef9ca89dbcb7/preference/preference/src/main/java/androidx/preference/CheckBoxPreference.java
|
||||||
|
|
||||||
|
public SwitchPreferenceCompat(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package androidx.preference;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
|
public class TwoStatePreference extends Preference {
|
||||||
|
private CharSequence mSummaryOn;
|
||||||
|
private CharSequence mSummaryOff;
|
||||||
|
|
||||||
|
public TwoStatePreference(Context context) {
|
||||||
|
super(context);
|
||||||
|
setDefaultValue(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isChecked() { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public void setChecked(boolean checked) { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public CharSequence getSummaryOn() {
|
||||||
|
return mSummaryOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public void setSummaryOn(CharSequence summary) {
|
||||||
|
this.mSummaryOn = summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public CharSequence getSummaryOff() {
|
||||||
|
return mSummaryOff;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public void setSummaryOff(CharSequence summary) {
|
||||||
|
this.mSummaryOff = summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharSequence getSummary() {
|
||||||
|
final CharSequence summary = super.getSummary();
|
||||||
|
if (summary != null) {
|
||||||
|
return summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
final boolean checked = (Boolean) getCurrentValue();
|
||||||
|
if (checked && mSummaryOn != null) {
|
||||||
|
return mSummaryOn;
|
||||||
|
} else if (!checked && mSummaryOff != null) {
|
||||||
|
return mSummaryOff;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean getDisableDependentsState() { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public void setDisableDependentsState(boolean disableDependentsState) { throw new RuntimeException("Stub!"); }
|
||||||
|
|
||||||
|
/** Tachidesk specific API */
|
||||||
|
@Override
|
||||||
|
public String getDefaultValueType() {
|
||||||
|
return "Boolean";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
package app.cash.quickjs;
|
||||||
|
|
||||||
|
import org.graalvm.polyglot.*;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public final class QuickJs implements Closeable {
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
public static QuickJs create() {
|
||||||
|
return new QuickJs();
|
||||||
|
}
|
||||||
|
|
||||||
|
public QuickJs() {
|
||||||
|
this.context = Context
|
||||||
|
.newBuilder("js")
|
||||||
|
.allowHostAccess(HostAccess.ALL)
|
||||||
|
.allowPolyglotAccess(PolyglotAccess.NONE)
|
||||||
|
.allowHostClassLoading(false)
|
||||||
|
.build();
|
||||||
|
context.enter();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object evaluate(String script, String ignoredFileName) {
|
||||||
|
return this.evaluate(script);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object evaluate(String script) {
|
||||||
|
try {
|
||||||
|
Value value = context.eval("js", script);
|
||||||
|
return translateType(value);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
throw new QuickJsException(exception.getMessage(), exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object translateType(Value obj) {
|
||||||
|
if (obj.isBoolean()) {
|
||||||
|
return obj.asBoolean();
|
||||||
|
} else if (obj.hasArrayElements()) {
|
||||||
|
if (obj.getArraySize() == 0) {
|
||||||
|
return new int[0];
|
||||||
|
} else {
|
||||||
|
Value element = obj.getArrayElement(0);
|
||||||
|
if (element.isBoolean()) {
|
||||||
|
return obj.as(boolean[].class);
|
||||||
|
} else if (element.isNumber()) {
|
||||||
|
if (element.fitsInInt()) {
|
||||||
|
return obj.as(int[].class);
|
||||||
|
} else if (element.fitsInBigInteger()) {
|
||||||
|
return Arrays.stream(obj.as(BigInteger[].class)).map(BigInteger::longValue).toArray();
|
||||||
|
} else {
|
||||||
|
return obj.as(double[].class);
|
||||||
|
}
|
||||||
|
} else if (element.isHostObject()) {
|
||||||
|
return obj.as(Object[].class);
|
||||||
|
} else if (element.isString()) {
|
||||||
|
return obj.as(String[].class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (obj.isNumber()) {
|
||||||
|
if (obj.fitsInInt()) {
|
||||||
|
return obj.asInt();
|
||||||
|
} else if (obj.fitsInBigInteger()) {
|
||||||
|
return obj.asBigInteger().longValue();
|
||||||
|
} else {
|
||||||
|
return obj.asDouble();
|
||||||
|
}
|
||||||
|
} else if (obj.isHostObject()) {
|
||||||
|
return obj.asHostObject();
|
||||||
|
} else if (obj.isString()) {
|
||||||
|
return obj.asString();
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] compile(String sourceCode, String ignoredFileName) {
|
||||||
|
return sourceCode.getBytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object execute(byte[] bytecode) {
|
||||||
|
return this.evaluate(new String(bytecode));
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void set(String name, Class<T> ignoredType, T object) {
|
||||||
|
context.getBindings("js").putMember(name, object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
if (this.context != null) {
|
||||||
|
this.context.leave();
|
||||||
|
this.context.close();
|
||||||
|
this.context = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package app.cash.quickjs;
|
||||||
|
|
||||||
|
public final class QuickJsException extends RuntimeException {
|
||||||
|
public QuickJsException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,13 +14,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.android.internal.util;
|
package com.android.internal.util;
|
||||||
import android.annotation.NonNull;
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
import libcore.util.EmptyArray;
|
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import libcore.util.EmptyArray;
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ArrayUtils contains some methods that you can call to find out
|
* ArrayUtils contains some methods that you can call to find out
|
||||||
* the most efficient increments by which to grow arrays.
|
* the most efficient increments by which to grow arrays.
|
||||||
@@ -50,6 +50,10 @@ public class ArrayUtils {
|
|||||||
public static Object[] newUnpaddedObjectArray(int minLen) {
|
public static Object[] newUnpaddedObjectArray(int minLen) {
|
||||||
return new Object[minLen];
|
return new Object[minLen];
|
||||||
}
|
}
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static <T> T[] newUnpaddedArray(Class<T> clazz, int minLen) {
|
||||||
|
return (T[])Array.newInstance(clazz, minLen);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Checks if the beginnings of two byte arrays are equal.
|
* Checks if the beginnings of two byte arrays are equal.
|
||||||
*
|
*
|
||||||
@@ -468,4 +472,4 @@ public class ArrayUtils {
|
|||||||
}
|
}
|
||||||
return size - leftIdx;
|
return size - leftIdx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,155 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.internal.util;
|
||||||
|
|
||||||
|
public final class GrowingArrayUtils {
|
||||||
|
|
||||||
|
public static <T> T[] append(T[] array, int currentSize, T element) {
|
||||||
|
assert currentSize <= array.length;
|
||||||
|
|
||||||
|
if (currentSize + 1 > array.length) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
T[] newArray = ArrayUtils.newUnpaddedArray(
|
||||||
|
(Class<T>) array.getClass().getComponentType(), growSize(currentSize));
|
||||||
|
System.arraycopy(array, 0, newArray, 0, currentSize);
|
||||||
|
array = newArray;
|
||||||
|
}
|
||||||
|
array[currentSize] = element;
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int[] append(int[] array, int currentSize, int element) {
|
||||||
|
assert currentSize <= array.length;
|
||||||
|
|
||||||
|
if (currentSize + 1 > array.length) {
|
||||||
|
int[] newArray = ArrayUtils.newUnpaddedIntArray(growSize(currentSize));
|
||||||
|
System.arraycopy(array, 0, newArray, 0, currentSize);
|
||||||
|
array = newArray;
|
||||||
|
}
|
||||||
|
array[currentSize] = element;
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long[] append(long[] array, int currentSize, long element) {
|
||||||
|
assert currentSize <= array.length;
|
||||||
|
|
||||||
|
if (currentSize + 1 > array.length) {
|
||||||
|
long[] newArray = ArrayUtils.newUnpaddedLongArray(growSize(currentSize));
|
||||||
|
System.arraycopy(array, 0, newArray, 0, currentSize);
|
||||||
|
array = newArray;
|
||||||
|
}
|
||||||
|
array[currentSize] = element;
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean[] append(boolean[] array, int currentSize, boolean element) {
|
||||||
|
assert currentSize <= array.length;
|
||||||
|
|
||||||
|
if (currentSize + 1 > array.length) {
|
||||||
|
boolean[] newArray = ArrayUtils.newUnpaddedBooleanArray(growSize(currentSize));
|
||||||
|
System.arraycopy(array, 0, newArray, 0, currentSize);
|
||||||
|
array = newArray;
|
||||||
|
}
|
||||||
|
array[currentSize] = element;
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float[] append(float[] array, int currentSize, float element) {
|
||||||
|
assert currentSize <= array.length;
|
||||||
|
|
||||||
|
if (currentSize + 1 > array.length) {
|
||||||
|
float[] newArray = ArrayUtils.newUnpaddedFloatArray(growSize(currentSize));
|
||||||
|
System.arraycopy(array, 0, newArray, 0, currentSize);
|
||||||
|
array = newArray;
|
||||||
|
}
|
||||||
|
array[currentSize] = element;
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T[] insert(T[] array, int currentSize, int index, T element) {
|
||||||
|
assert currentSize <= array.length;
|
||||||
|
|
||||||
|
if (currentSize + 1 <= array.length) {
|
||||||
|
System.arraycopy(array, index, array, index + 1, currentSize - index);
|
||||||
|
array[index] = element;
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
T[] newArray = ArrayUtils.newUnpaddedArray((Class<T>)array.getClass().getComponentType(),
|
||||||
|
growSize(currentSize));
|
||||||
|
System.arraycopy(array, 0, newArray, 0, index);
|
||||||
|
newArray[index] = element;
|
||||||
|
System.arraycopy(array, index, newArray, index + 1, array.length - index);
|
||||||
|
return newArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int[] insert(int[] array, int currentSize, int index, int element) {
|
||||||
|
assert currentSize <= array.length;
|
||||||
|
|
||||||
|
if (currentSize + 1 <= array.length) {
|
||||||
|
System.arraycopy(array, index, array, index + 1, currentSize - index);
|
||||||
|
array[index] = element;
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] newArray = ArrayUtils.newUnpaddedIntArray(growSize(currentSize));
|
||||||
|
System.arraycopy(array, 0, newArray, 0, index);
|
||||||
|
newArray[index] = element;
|
||||||
|
System.arraycopy(array, index, newArray, index + 1, array.length - index);
|
||||||
|
return newArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long[] insert(long[] array, int currentSize, int index, long element) {
|
||||||
|
assert currentSize <= array.length;
|
||||||
|
|
||||||
|
if (currentSize + 1 <= array.length) {
|
||||||
|
System.arraycopy(array, index, array, index + 1, currentSize - index);
|
||||||
|
array[index] = element;
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
long[] newArray = ArrayUtils.newUnpaddedLongArray(growSize(currentSize));
|
||||||
|
System.arraycopy(array, 0, newArray, 0, index);
|
||||||
|
newArray[index] = element;
|
||||||
|
System.arraycopy(array, index, newArray, index + 1, array.length - index);
|
||||||
|
return newArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean[] insert(boolean[] array, int currentSize, int index, boolean element) {
|
||||||
|
assert currentSize <= array.length;
|
||||||
|
|
||||||
|
if (currentSize + 1 <= array.length) {
|
||||||
|
System.arraycopy(array, index, array, index + 1, currentSize - index);
|
||||||
|
array[index] = element;
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean[] newArray = ArrayUtils.newUnpaddedBooleanArray(growSize(currentSize));
|
||||||
|
System.arraycopy(array, 0, newArray, 0, index);
|
||||||
|
newArray[index] = element;
|
||||||
|
System.arraycopy(array, index, newArray, index + 1, array.length - index);
|
||||||
|
return newArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int growSize(int currentSize) {
|
||||||
|
return currentSize <= 4 ? 8 : currentSize * 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Uninstantiable
|
||||||
|
private GrowingArrayUtils() {}
|
||||||
|
}
|
||||||
@@ -14,9 +14,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.android.internal.util;
|
package com.android.internal.util;
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.graphics.Bitmap.CompressFormat;
|
import android.graphics.Bitmap.CompressFormat;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
@@ -25,19 +26,14 @@ import android.util.Xml;
|
|||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
import org.xmlpull.v1.XmlSerializer;
|
import org.xmlpull.v1.XmlSerializer;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.ProtocolException;
|
import java.net.ProtocolException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
/** {@hide} */
|
/** {@hide} */
|
||||||
public class XmlUtils {
|
public class XmlUtils {
|
||||||
private static final String STRING_ARRAY_SEPARATOR = ":";
|
private static final String STRING_ARRAY_SEPARATOR = ":";
|
||||||
@@ -1396,9 +1392,9 @@ public class XmlUtils {
|
|||||||
} else if (tagName.equals("long")) {
|
} else if (tagName.equals("long")) {
|
||||||
return Long.valueOf(parser.getAttributeValue(null, "value"));
|
return Long.valueOf(parser.getAttributeValue(null, "value"));
|
||||||
} else if (tagName.equals("float")) {
|
} else if (tagName.equals("float")) {
|
||||||
return new Float(parser.getAttributeValue(null, "value"));
|
return Float.valueOf(parser.getAttributeValue(null, "value"));
|
||||||
} else if (tagName.equals("double")) {
|
} else if (tagName.equals("double")) {
|
||||||
return new Double(parser.getAttributeValue(null, "value"));
|
return Double.valueOf(parser.getAttributeValue(null, "value"));
|
||||||
} else if (tagName.equals("boolean")) {
|
} else if (tagName.equals("boolean")) {
|
||||||
return Boolean.valueOf(parser.getAttributeValue(null, "value"));
|
return Boolean.valueOf(parser.getAttributeValue(null, "value"));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
package com.f2prateek;
|
|
||||||
//TODO Consider if we can change this package into an Android dependency
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2014 Prateek Srivastava
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
This file may have been modified after being copied from it's original source.
|
|
||||||
*/
|
|
||||||
package com.f2prateek.rx.preferences;
|
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
|
|
||||||
final class BooleanAdapter implements Preference.Adapter<Boolean> {
|
|
||||||
static final BooleanAdapter INSTANCE = new BooleanAdapter();
|
|
||||||
|
|
||||||
@Override public Boolean get(@NonNull String key, @NonNull SharedPreferences preferences) {
|
|
||||||
return preferences.getBoolean(key, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void set(@NonNull String key, @NonNull Boolean value,
|
|
||||||
@NonNull SharedPreferences.Editor editor) {
|
|
||||||
editor.putBoolean(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2014 Prateek Srivastava
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
This file may have been modified after being copied from it's original source.
|
|
||||||
*/
|
|
||||||
package com.f2prateek.rx.preferences;
|
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
|
|
||||||
final class EnumAdapter<T extends Enum<T>> implements Preference.Adapter<T> {
|
|
||||||
private final Class<T> enumClass;
|
|
||||||
|
|
||||||
EnumAdapter(Class<T> enumClass) {
|
|
||||||
this.enumClass = enumClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public T get(@NonNull String key, @NonNull SharedPreferences preferences) {
|
|
||||||
String value = preferences.getString(key, null);
|
|
||||||
assert value != null; // Not called unless key is present.
|
|
||||||
return Enum.valueOf(enumClass, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void set(@NonNull String key, @NonNull T value, @NonNull SharedPreferences.Editor editor) {
|
|
||||||
editor.putString(key, value.name());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user