[
  {
    "path": ".gitignore",
    "content": ".gradle\n/local.properties\n/.idea\n.DS_Store\n/build\n\n*.iml\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<http://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<http://www.gnu.org/philosophy/why-not-lgpl.html>."
  },
  {
    "path": "README.md",
    "content": "# NHBooks for Android\n![NHBooksLogo](/art/nhbooks.png)\n\na Material Design NHentai client for Android.\n一枚 Material Design 風格的 NHentai Android 客戶端\n\n### 螢幕截圖\n![S0](/art/screenshot0.png)\n\n![S1](/art/screenshot1.png)\n\n## 軟體說明\n該程式按照 Material Design 設計規範，提供簡潔、美觀的介面，並通過 API 從 NHentai 獲取本子，給你一個輕量、方便的客戶端。\n\n### 特別聲明\n該應用程式所供應的內容不適合未成年人觀看，所有內容通過 Jsoup 解析 NHentai 官網獲得，內容有任何異議或造成心理甚至生理上的問題均與本項目無關。\n\n觀看時請留意是否適用於當地法律法規。\n\n### 聯絡我\n\nGoogle Plus: +Fung Jichun\n\n新浪微博: @某燒餅\n\n### 支持項目\n\nAlipay 支付寶: 316643843@qq.com\n\n### License 開源協議\n\n```\nGNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007\n\nCopyright (C) 2015 FengMoe Team\n\nThis program comes with ABSOLUTELY NO WARRANTY.\nThis is free software, and you are welcome to redistribute it under certain conditions.\n```\n"
  },
  {
    "path": "app/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "app/build.gradle",
    "content": "apply plugin: 'com.android.application'\n\nandroid {\n\tcompileSdkVersion 22\n\tbuildToolsVersion \"22.0.1\"\n\n\tdefaultConfig {\n\t\tapplicationId \"moe.feng.nhentai\"\n\t\tminSdkVersion 15\n\t\ttargetSdkVersion 22\n\t\tversionCode 1\n\t\tversionName \"1.0\"\n\t}\n\tbuildTypes {\n\t\trelease {\n\t\t\tminifyEnabled false\n\t\t\tproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n\t\t}\n\t}\n}\n\ndependencies {\n\tcompile fileTree(dir: 'libs', include: ['*.jar'])\n\tcompile project(':libraries:PersistentSearch')\n\tcompile 'com.android.support:support-v13:22.2.0'\n\tcompile 'com.android.support:design:22.2.0'\n\tcompile 'com.android.support:appcompat-v7:22.2.0'\n\tcompile 'com.android.support:cardview-v7:22.2.0'\n\tcompile 'com.android.support:recyclerview-v7:22.2.0'\n\tcompile 'com.google.code.gson:gson:2.3.1'\n\tcompile 'org.jsoup:jsoup:1.8.2'\n\tcompile 'com.github.chrisbanes.photoview:library:1.2.3'\n\tcompile 'com.squareup.picasso:picasso:2.5.2'\n\tcompile ('com.github.florent37:materialimageloading:1.0.1@aar'){\n\t\ttransitive = true\n\t}\n}\n"
  },
  {
    "path": "app/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in E:\\Feng\\sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n"
  },
  {
    "path": "app/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"moe.feng.nhentai\" >\n\n    <uses-permission android:name=\"android.permission.INTERNET\"/>\n    <uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>\n\n    <application\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:theme=\"@style/Theme.NHBooks.Light.DarkActionBar\" >\n        <activity\n            android:name=\".ui.MainActivity\"\n            android:label=\"@string/app_name\" >\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n\n        <activity\n            android:name=\".ui.BookDetailsActivity\"\n            android:label=\"@string/activity_details\" >\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n            </intent-filter>\n        </activity>\n\n\t    <activity\n\t\t    android:name=\".ui.GalleryActivity\"\n\t\t    android:label=\"@string/activity_gallery\"\n\t\t    android:theme=\"@style/Theme.NHBooks.Dark\">\n\t\t    <intent-filter>\n\t\t\t    <action android:name=\"android.intent.action.MAIN\" />\n\t\t    </intent-filter>\n\t    </activity>\n\n        <activity\n            android:name=\".ui.SearchResultActivity\"\n            android:label=\"@string/activity_search_result\"\n            android:theme=\"@style/Theme.NHBooks.Light.DarkActionBar\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n            </intent-filter>\n        </activity>\n\n        <activity\n            android:name=\".ui.CategoryActivity\"\n            android:label=\"@string/activity_search_result\"\n            android:theme=\"@style/Theme.NHBooks.Light.DarkActionBar\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n            </intent-filter>\n        </activity>\n\n        <activity\n            android:name=\".ui.SettingsActivity\"\n            android:label=\"@string/settings_main\"\n            android:theme=\"@style/Theme.NHBooks.Light.DarkActionBar.Fix\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n            </intent-filter>\n        </activity>\n    </application>\n\n</manifest>\n"
  },
  {
    "path": "app/src/main/assets/licenses.html",
    "content": "<html>\n<head>\n\t<style>\n\t\tbody {\n\t\tmargin: 1em;\n\t\t}\n\t\tpre {\n\t\tbackground: #DDD;\n\t\tpadding: 1em;\n\t\twhite-space: pre-wrap;\n\t\t}\n\t</style>\n</head>\n<body>\n\n<h2>Notices for Additional Libraries</h2>\n\n<p>This app contains several libraries that are released under the terms of the following licenses.</p>\n\n<h3>Notices for files:</h3>\n\n<ul>\n\t<li>Android Support Library (v4, v7, v13, Design Support)</li>\n</ul>\n\t<pre>Copyright (C) 2013 The Android Open Source Project\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.</pre>\n\n<h3>Notices for files:</h3>\n\n<ul>\n\t<li>QuickKV</li>\n</ul>\n\t<pre>Copyright 2014-2015 Sumi Makito\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0 \n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License. </pre>\n\n<h3>Notices for files:</h3>\n\n<ul>\n\t<li>Persistent Search</li>\n</ul>\n\t<pre>Copyright 2015 Kieron Quinn\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.</pre>\n\n<h3>Notices for files:</h3>\n\n<ul>\n\t<li>Picasso</li>\n</ul>\n\t<pre>Copyright 2013 Square, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.</pre>\n\n<h3>Notices for files:</h3>\n\n<ul>\n\t<li>Gson</li>\n</ul>\n\t<pre>Copyright 2008 Google, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.</pre>\n\n<h3>Notices for files:</h3>\n\n<ul>\n\t<li>Jsoup</li>\n</ul>\n\t<pre>The MIT License\n\n© 2009-2015, Jonathan Hedley <jonathan@hedley.net>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.</pre>\n\n<h3>Notices for files:</h3>\n\n<ul>\n\t<li>PhotoView</li>\n</ul>\n\t<pre>Copyright 2011, 2012 Chris Banes\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.</pre>\n\n<h3>Notices for files:</h3>\n\n<ul>\n\t<li>MaterialImageLoading</li>\n</ul>\n\t<pre>Copyright 2015 florent37, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.</pre>\n\n</body>\n</html>"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/api/BookApi.java",
    "content": "package moe.feng.nhentai.api;\n\nimport android.content.Context;\nimport android.graphics.Bitmap;\nimport android.util.Log;\n\nimport org.jsoup.Jsoup;\nimport org.jsoup.nodes.Document;\nimport org.jsoup.nodes.Element;\nimport org.jsoup.select.Elements;\n\nimport java.io.File;\nimport java.io.IOException;\n\nimport moe.feng.nhentai.api.common.NHentaiUrl;\nimport moe.feng.nhentai.cache.file.FileCacheManager;\nimport moe.feng.nhentai.model.BaseMessage;\nimport moe.feng.nhentai.model.Book;\nimport static moe.feng.nhentai.cache.common.Constants.CACHE_COVER;\nimport static moe.feng.nhentai.cache.common.Constants.CACHE_PAGE_THUMB;\nimport static moe.feng.nhentai.cache.common.Constants.CACHE_THUMB;\n\npublic class BookApi {\n\n\tpublic static final String TAG = BookApi.class.getSimpleName();\n\n\tpublic static BaseMessage getBook(String id) {\n\t\tBaseMessage result = new BaseMessage();\n\n\t\tString url = NHentaiUrl.getBookDetailsUrl(id);\n\n\t\tDocument doc;\n\t\ttry {\n\t\t\tdoc = Jsoup.connect(url).get();\n\t\t} catch (IOException e) {\n\t\t\tresult.setCode(403);\n\t\t\te.printStackTrace();\n\t\t\treturn result;\n\t\t}\n\n\t\tBook book = new Book();\n\n\t\tElements info = doc.getElementsByAttributeValue(\"id\", \"info\");\n\t\tElement element = info.get(0);\n\n\t\t/** Get basic info */\n\t\tbook.title = element.getElementsByTag(\"h1\").get(0).text();\n\t\ttry {\n\t\t\tbook.titleJP = element.getElementsByTag(\"h2\").get(0).text();\n\t\t} catch (Exception e) {\n\t\t\tLog.v(TAG, \"This book hasn\\'t japanese name.\");\n\t\t}\n\t\tbook.bookId = id;\n\n\t\t/** Get tags */\n\t\tElements tags = doc.getElementsByClass(\"field-name\");\n\t\tfor (Element r : tags) {\n\t\t\tif (r.text().contains(\"Parodies\")) {\n\t\t\t\tString ts = r.getElementsByClass(\"tagbutton\").get(0).text();\n\t\t\t\tif (ts.contains(\"(\")) {\n\t\t\t\t\tts = ts.substring(0, ts.indexOf(\"(\") - 1);\n\t\t\t\t}\n\t\t\t\tbook.parodies = ts;\n\t\t\t}\n\t\t\tif (r.text().contains(\"Tags\")) {\n\t\t\t\tfor (Element e : r.getElementsByClass(\"tagbutton\")) {\n\t\t\t\t\tString ts = e.text();\n\t\t\t\t\tif (ts.contains(\"(\")) {\n\t\t\t\t\t\tts = ts.substring(0, ts.indexOf(\"(\") - 1);\n\t\t\t\t\t}\n\t\t\t\t\tbook.tags.add(ts);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (r.text().contains(\"Language\")) {\n\t\t\t\tString ts = r.getElementsByClass(\"tagbutton\").get(0).text();\n\t\t\t\tif (ts.contains(\"(\")) {\n\t\t\t\t\tts = ts.substring(0, ts.indexOf(\"(\") - 1);\n\t\t\t\t}\n\t\t\t\tbook.language = ts;\n\t\t\t}\n\t\t\tif (r.text().contains(\"Groups\")) {\n\t\t\t\tString ts = r.getElementsByClass(\"tagbutton\").get(0).text();\n\t\t\t\tif (ts.contains(\"(\")) {\n\t\t\t\t\tts = ts.substring(0, ts.indexOf(\"(\") - 1);\n\t\t\t\t}\n\t\t\t\tbook.group = ts;\n\t\t\t}\n\t\t\tif (r.text().contains(\"Artists\")) {\n\t\t\t\tString ts = r.getElementsByClass(\"tagbutton\").get(0).text();\n\t\t\t\tif (ts.contains(\"(\")) {\n\t\t\t\t\tts = ts.substring(0, ts.indexOf(\"(\") - 1);\n\t\t\t\t}\n\t\t\t\tbook.artist = ts;\n\t\t\t}\n\t\t\tif (r.text().contains(\"Characters\")) {\n\t\t\t\tfor (Element e : r.getElementsByClass(\"tagbutton\")) {\n\t\t\t\t\tString ts = e.text();\n\t\t\t\t\tif (ts.contains(\"(\")) {\n\t\t\t\t\t\tts = ts.substring(0, ts.indexOf(\"(\") - 1);\n\t\t\t\t\t}\n\t\t\t\t\tbook.characters.add(ts);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/** Get page count */\n\t\tString htmlSrc = element.html();\n\t\ttry {\n\t\t\tint position = htmlSrc.indexOf(\"pages\");\n\t\t\tString s = htmlSrc.substring(0, position);\n\t\t\tSystem.out.println(s);\n\t\t\ts = s.substring(s.lastIndexOf(\"<div>\") + \"<div>\".length(), s.length()).trim();\n\t\t\tSystem.out.println(s);\n\t\t\tbook.pageCount = Integer.valueOf(s);\n\t\t} catch (Exception e) {\n\n\t\t}\n\n\t\t/** Get uploaded time */\n\t\ttry {\n\t\t\tElement timeElement = doc.getElementsByTag(\"time\").get(0);\n\t\t\tbook.uploadTime = timeElement.attr(\"datetime\");\n\t\t\tbook.uploadTimeText = timeElement.text();\n\t\t} catch (Exception e) {\n\n\t\t}\n\n\t\t/** Get gallery id and preview image url */\n\t\tElement coverDiv = doc.getElementById(\"cover\").getElementsByTag(\"a\").get(0);\n\t\tfor (Element e : coverDiv.getElementsByTag(\"img\")) {\n\t\t\ttry {\n\t\t\t\tLog.i(TAG, coverDiv.html());\n\t\t\t\tString coverUrl = e.attr(\"src\");\n\t\t\t\tLog.i(TAG, coverUrl);\n\t\t\t\tcoverUrl = coverUrl.substring(0, coverUrl.lastIndexOf(\"/\"));\n\t\t\t\tString galleryId = coverUrl.substring(coverUrl.lastIndexOf(\"/\") + 1, coverUrl.length());\n\t\t\t\tbook.galleryId = galleryId;\n\t\t\t\tbook.previewImageUrl = NHentaiUrl.getThumbUrl(galleryId);\n\t\t\t\tbook.bigCoverImageUrl = NHentaiUrl.getBigCoverUrl(galleryId);\n\t\t\t\tbreak;\n\t\t\t} catch (Exception ex) {\n\t\t\t\tex.printStackTrace();\n\t\t\t}\n\t\t}\n\n\t\tLog.i(TAG, book.toJSONString());\n\n\t\tresult.setCode(0);\n\t\tresult.setData(book);\n\n\t\treturn result;\n\t}\n\t\n\tpublic static Bitmap getCover(Context context, Book book) {\n\t\tString url = book.bigCoverImageUrl;\n\t\tFileCacheManager m = FileCacheManager.getInstance(context);\n\t\t\n\t\tif (!m.cacheExistsUrl(CACHE_COVER, url) && !m.createCacheFromNetwork(CACHE_COVER, url)) {\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\treturn m.getBitmapUrl(CACHE_COVER, url);\n\t}\n\n\tpublic static Bitmap getThumb(Context context, Book book) {\n\t\tString url = book.previewImageUrl;\n\t\tFileCacheManager m = FileCacheManager.getInstance(context);\n\n\t\tif (!m.cacheExistsUrl(CACHE_THUMB, url) && !m.createCacheFromNetwork(CACHE_THUMB, url)) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn m.getBitmapUrl(CACHE_THUMB, url);\n\t}\n\n\tpublic static Bitmap getPageThumb(Context context, Book book, int position) {\n\t\tString url = NHentaiUrl.getThumbPictureUrl(book.galleryId, Integer.toString(position));\n\t\tFileCacheManager m = FileCacheManager.getInstance(context);\n\n\t\tif (!m.cacheExistsUrl(CACHE_PAGE_THUMB, url) && !m.createCacheFromNetwork(CACHE_PAGE_THUMB, url)) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn m.getBitmapUrl(CACHE_PAGE_THUMB, url);\n\t}\n\n\tpublic static File getCoverFile(Context context, Book book) {\n\t\tString url = book.bigCoverImageUrl;\n\t\tFileCacheManager m = FileCacheManager.getInstance(context);\n\n\t\tif (!m.cacheExistsUrl(CACHE_COVER, url) && !m.createCacheFromNetwork(CACHE_COVER, url)) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn m.getBitmapUrlFile(CACHE_COVER, url);\n\t}\n\n\tpublic static File getThumbFile(Context context, Book book) {\n\t\tString url = book.previewImageUrl;\n\t\tFileCacheManager m = FileCacheManager.getInstance(context);\n\n\t\tif (!m.cacheExistsUrl(CACHE_THUMB, url) && !m.createCacheFromNetwork(CACHE_THUMB, url)) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn m.getBitmapUrlFile(CACHE_THUMB, url);\n\t}\n\n\tpublic static File getPageThumbFile(Context context, Book book, int position) {\n\t\tString url = NHentaiUrl.getThumbPictureUrl(book.galleryId, Integer.toString(position));\n\t\tFileCacheManager m = FileCacheManager.getInstance(context);\n\n\t\tif (!m.cacheExistsUrl(CACHE_PAGE_THUMB, url) && !m.createCacheFromNetwork(CACHE_PAGE_THUMB, url)) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn m.getBitmapUrlFile(CACHE_PAGE_THUMB, url);\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/api/PageApi.java",
    "content": "package moe.feng.nhentai.api;\n\nimport android.content.Context;\nimport android.graphics.Bitmap;\nimport android.util.Log;\n\nimport org.jsoup.Jsoup;\nimport org.jsoup.nodes.Document;\nimport org.jsoup.nodes.Element;\nimport org.jsoup.select.Elements;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.util.ArrayList;\n\nimport moe.feng.nhentai.api.common.NHentaiUrl;\nimport moe.feng.nhentai.cache.file.FileCacheManager;\nimport moe.feng.nhentai.model.BaseMessage;\nimport moe.feng.nhentai.model.Book;\n\nimport static moe.feng.nhentai.cache.common.Constants.CACHE_PAGE_IMG;\n\npublic class PageApi {\n\n\tpublic static final String TAG = PageApi.class.getSimpleName();\n\n\tpublic static BaseMessage getPageList(String url) {\n\t\tBaseMessage result = new BaseMessage();\n\n\t\tDocument doc;\n\t\ttry {\n\t\t\tdoc = Jsoup.connect(url).get();\n\t\t} catch (IOException e) {\n\t\t\tresult.setCode(403);\n\t\t\te.printStackTrace();\n\t\t\treturn result;\n\t\t}\n\n\t\tElements container = doc.getElementsByClass(\"outer-preview-container\");\n\n\t\tArrayList<Book> books = new ArrayList<>();\n\n\t\tfor (Element e : container) {\n\t\t\tBook book = new Book();\n\n\t\t\tElement caption = e.getElementsByClass(\"caption\").get(0);\n\t\t\tElement titleElement = caption.getElementsByTag(\"a\").get(0);\n\t\t\tString bookId = titleElement.attr(\"href\");\n\t\t\tbookId = bookId.substring(0, bookId.lastIndexOf(\"/\"));\n\t\t\tbookId = bookId.substring(bookId.lastIndexOf(\"/\") + 1, bookId.length());\n\t\t\tbook.bookId = bookId;\n\t\t\tbook.title = titleElement.text();\n\n\t\t\tElements imgs = e.getElementsByTag(\"img\");\n\t\t\tfor (Element imge : imgs) {\n\t\t\t\tif (imge.hasAttr(\"src\")) {\n\t\t\t\t\tString thumbUrl = imge.attr(\"src\");\n\t\t\t\t\tthumbUrl = thumbUrl.substring(0, thumbUrl.lastIndexOf(\"/\"));\n\t\t\t\t\tString galleryId = thumbUrl.substring(thumbUrl.lastIndexOf(\"/\") + 1, thumbUrl.length());\n\t\t\t\t\tbook.galleryId = galleryId;\n\t\t\t\t\tbook.bigCoverImageUrl = NHentaiUrl.getBigCoverUrl(galleryId);\n\t\t\t\t\tbook.previewImageUrl = NHentaiUrl.getThumbUrl(galleryId);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tbook.thumbHeight = Integer.valueOf(imge.attr(\"height\"));\n\t\t\t\t\t\tbook.thumbWidth = Integer.valueOf(imge.attr(\"width\"));\n\t\t\t\t\t} catch (Exception ex) {\n\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (book.bookId != null && !book.bookId.isEmpty()) {\n\t\t\t\tbooks.add(book);\n\t\t\t}\n\n\t\t\tLog.i(TAG, \"Get book: \" + book.toJSONString());\n\t\t}\n\n\t\tresult.setCode(0);\n\t\tresult.setData(books);\n\n\t\treturn result;\n\t}\n\n\tpublic static BaseMessage getHomePageList(int number) {\n\t\treturn getPageList(NHentaiUrl.getHomePageUrl(number));\n\t}\n\n\tpublic static BaseMessage getSearchPageList(String keyword, int number) {\n\t\treturn getPageList(NHentaiUrl.getSearchUrl(keyword, number));\n\t}\n\n\tpublic static Bitmap getPageOriginImage(Context context, Book book, int page_num) {\n\t\tString url = NHentaiUrl.getOriginPictureUrl(book.galleryId, String.valueOf(page_num));\n\t\tFileCacheManager m = FileCacheManager.getInstance(context);\n\n\t\tif (!m.cacheExistsUrl(CACHE_PAGE_IMG, url) && !m.createCacheFromNetwork(CACHE_PAGE_IMG, url)) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn m.getBitmapUrl(CACHE_PAGE_IMG, url);\n\t}\n\n\tpublic static File getPageOriginImageFile(Context context, Book book, int page_num) {\n\t\tString url = NHentaiUrl.getOriginPictureUrl(book.galleryId, String.valueOf(page_num));\n\t\tFileCacheManager m = FileCacheManager.getInstance(context);\n\n\t\tif (!m.cacheExistsUrl(CACHE_PAGE_IMG, url) && !m.createCacheFromNetwork(CACHE_PAGE_IMG, url)) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn m.getBitmapUrlFile(CACHE_PAGE_IMG, url);\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/api/common/NHentaiUrl.java",
    "content": "package moe.feng.nhentai.api.common;\n\npublic class NHentaiUrl {\n\n\tpublic static final String NHENTAI_HOME = \"http://nhentai.net\";\n\tpublic static final String NHENTAI_I = \"http://i.nhentai.net\";\n\n\tpublic static String getSearchUrl(String content) {\n\t\treturn getSearchUrl(content, 1);\n\t}\n\n\tpublic static String getSearchUrl(String content, int page_num) {\n\t\tString targetContent = content;\n\t\tif (targetContent.contains(\" \")) {\n\t\t\ttargetContent = targetContent.replaceAll(\" \", \"+\");\n\t\t}\n\t\treturn NHENTAI_HOME + \"/search/?q=\" + targetContent + \"&page=\" + page_num;\n\t}\n\n\tpublic static String getBookDetailsUrl(String book_id) {\n\t\treturn NHENTAI_HOME + \"/g/\" + book_id;\n\t}\n\n\tpublic static String getBookPageUrl(String book_id, int page_num) {\n\t\treturn getBookDetailsUrl(book_id) + \"/\" + page_num;\n\t}\n\n\tpublic static String getGalleryUrl(String g_id) {\n\t\treturn NHENTAI_I + \"/galleries/\" + g_id;\n\t}\n\n\tpublic static String getOriginPictureUrl(String g_id, String page_num) {\n\t\treturn getPictureUrl(g_id, page_num, \"jpg\");\n\t}\n\n\tpublic static String getThumbPictureUrl(String g_id, String page_num) {\n\t\treturn getPictureUrl(g_id, page_num + \"t\", \"jpg\");\n\t}\n\n\tpublic static String getThumbUrl(String g_id) {\n\t\treturn getPictureUrl(g_id, \"thumb\", \"jpg\");\n\t}\n\n\tpublic static String getBigCoverUrl(String g_id) {\n\t\t// TODO Not all covers are jpgs\n\t\treturn getPictureUrl(g_id, \"cover\", \"jpg\");\n\t}\n\n\tpublic static String getPictureUrl(String g_id, String page_num, String file_type) {\n\t\treturn getGalleryUrl(g_id) + \"/\" + page_num + \".\" + file_type;\n\t}\n\n\tpublic static String getParodyUrl(String name) {\n\t\tString targetName = name;\n\t\tif (targetName.contains(\" \")) {\n\t\t\ttargetName = targetName.replaceAll(\" \", \"-\");\n\t\t}\n\t\treturn NHENTAI_HOME + \"/parody/\" + targetName;\n\t}\n\n\tpublic static String getCharacterUrl(String name) {\n\t\tString targetName = name;\n\t\tif (targetName.contains(\" \")) {\n\t\t\ttargetName = targetName.replaceAll(\" \", \"-\");\n\t\t}\n\t\treturn NHENTAI_HOME + \"/character/\" + targetName;\n\t}\n\n\tpublic static String getTagUrl(String tag) {\n\t\tString targetTag = tag;\n\t\tif (targetTag.contains(\" \")) {\n\t\t\ttargetTag = targetTag.replaceAll(\" \", \"-\");\n\t\t}\n\t\treturn NHENTAI_HOME + \"/tagged/\" + targetTag;\n\t}\n\n\tpublic static String getArtistUrl(String name) {\n\t\tString targetName = name;\n\t\tif (targetName.contains(\" \")) {\n\t\t\ttargetName = targetName.replaceAll(\" \", \"-\");\n\t\t}\n\t\treturn NHENTAI_HOME + \"/artist/\" + targetName;\n\t}\n\n\tpublic static String getGroupUrl(String name) {\n\t\tString targetName = name;\n\t\tif (targetName.contains(\" \")) {\n\t\t\ttargetName = targetName.replaceAll(\" \", \"-\");\n\t\t}\n\t\treturn NHENTAI_HOME + \"/group/\" + targetName;\n\t}\n\n\tpublic static String getLanguageUrl(String name) {\n\t\tString targetName = name;\n\t\tif (targetName.contains(\" \")) {\n\t\t\ttargetName = targetName.replaceAll(\" \", \"-\");\n\t\t}\n\t\treturn NHENTAI_HOME + \"/language/\" + targetName;\n\t}\n\n\tpublic static String getHomePageUrl(int page) {\n\t\treturn NHENTAI_HOME + \"/?page=\" + page;\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/cache/common/Constants.java",
    "content": "package moe.feng.nhentai.cache.common;\n\npublic class Constants {\n\n\tpublic static final String CACHE_COVER = \"cover\", CACHE_PAGE_IMG = \"pages\",\n\t\t\tCACHE_PAGE_THUMB = \"thumb\", CACHE_THUMB = \"thumb\", CACHE_DOCUMENT = \"document\";\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/cache/file/FileCacheManager.java",
    "content": "package moe.feng.nhentai.cache.file;\n\nimport android.content.Context;\nimport android.graphics.Bitmap;\nimport android.graphics.BitmapFactory;\nimport android.util.Log;\n\nimport java.io.File;\nimport java.io.FileNotFoundException;\nimport java.io.FileInputStream;\nimport java.io.FileOutputStream;\nimport java.io.InputStream;\nimport java.io.IOException;\nimport java.net.URL;\nimport java.net.HttpURLConnection;\nimport java.net.MalformedURLException;\n\nimport static moe.feng.nhentai.BuildConfig.DEBUG;\n\npublic class FileCacheManager {\n\n\tprivate static final String TAG = FileCacheManager.class.getSimpleName();\n\t\n\tprivate static FileCacheManager sInstance;\n\t\n\tprivate File mCacheDir;\n\t\n\tpublic static final FileCacheManager getInstance(Context context) {\n\t\tif (sInstance == null) {\n\t\t\tsInstance = new FileCacheManager(context);\n\t\t}\n\t\t\n\t\treturn sInstance;\n\t}\n\t\n\tprivate FileCacheManager(Context context) {\n\t\tmCacheDir = context.getExternalCacheDir();\n\t}\n\t\n\tpublic boolean createCacheFromNetwork(String type, String url) {\n\n\t\tif (DEBUG) {\n\t\t\tLog.d(TAG, \"requesting cache from \" + url);\n\t\t}\n\t\t\n\t\tURL u;\n\t\t\n\t\ttry {\n\t\t\tu = new URL(url);\n\t\t} catch (MalformedURLException e) {\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tHttpURLConnection conn;\n\t\t\n\t\ttry {\n\t\t\tconn = (HttpURLConnection) u.openConnection();\n\t\t} catch (IOException e) {\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tconn.setConnectTimeout(5000);\n\n\t\ttry {\n\t\t\tif (conn.getResponseCode() != 200) {\n\t\t\t\tif (url.contains(\"jpg\")) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tu = new URL(url.replace(\"jpg\", \"png\"));\n\t\t\t\t\t} catch (MalformedURLException ex) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconn = (HttpURLConnection) u.openConnection();\n\t\t\t\t\t} catch (IOException ex) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\n\t\ttry {\n\t\t\treturn createCacheFromStrem(type, getCacheName(url), conn.getInputStream());\n\t\t} catch (IOException e) {\n\t\t\treturn false;\n\t\t}\n\t}\n\t\n\tpublic boolean createCacheFromStrem(String type, String name, InputStream stream) {\n\t\tFile f = new File(getCachePath(type, name) + \"_downloading\");\n\t\tf.getParentFile().mkdirs();\n\t\tf.getParentFile().mkdir();\n\t\t\n\t\tif (f.exists()) {\n\t\t\tf.delete();\n\t\t}\n\t\t\n\t\ttry {\n\t\t\tf.createNewFile();\n\t\t} catch (IOException e) {\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tFileOutputStream opt;\n\t\t\n\t\ttry {\n\t\t\topt = new FileOutputStream(f);\n\t\t} catch (FileNotFoundException e) {\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tbyte[] buf = new byte[512];\n\t\tint len = 0;\n\t\t\n\t\ttry {\n\t\t\twhile ((len = stream.read(buf)) != -1) {\n\t\t\t\topt.write(buf, 0, len);\n\t\t\t}\n\t\t} catch (IOException e) {\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\ttry {\n\t\t\tstream.close();\n\t\t\topt.close();\n\t\t} catch (IOException e) {\n\t\t\t\n\t\t}\n\n\t\tf.renameTo(new File(getCachePath(type, name)));\n\n\t\treturn true;\n\t}\n\t\n\t// True if the cache downloaded from url exists\n\tpublic boolean cacheExistsUrl(String type, String url) {\n\t\treturn cacheExists(type, getCacheName(url));\n\t}\n\t\n\tpublic boolean cacheExists(String type, String name) {\n\t\treturn new File(getCachePath(type, name)).isFile();\n\t}\n\n\tpublic boolean deleteCacheUrl(String type, String url) {\n\t\treturn deleteCache(type, getCacheName(url));\n\t}\n\n\tpublic boolean deleteCache(String type, String name) {\n\t\tif (cacheExists(type, name)) {\n\t\t\treturn new File(getCachePath(type, name)).delete();\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tpublic InputStream openCacheStream(String type, String name) {\n\t\ttry {\n\t\t\treturn new FileInputStream(new File(getCachePath(type, name)));\n\t\t} catch (IOException e) {\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\tpublic InputStream openCacheStreamUrl(String type, String url) {\n\t\treturn openCacheStream(type, getCacheName(url));\n\t}\n\t\n\tpublic Bitmap getBitmap(String type, String name) {\n\t\tInputStream ipt = openCacheStream(type, name);\n\t\t\n\t\tif (ipt == null) return null;\n\t\t\n\t\tBitmap ret = BitmapFactory.decodeStream(ipt);\n\t\t\n\t\ttry {\n\t\t\tipt.close();\n\t\t} catch (IOException e) {\n\t\t\t\n\t\t}\n\t\t\n\t\treturn ret;\n\t}\n\t\n\tpublic Bitmap getBitmapUrl(String type, String url) {\n\t\treturn getBitmap(type, getCacheName(url));\n\t}\n\n\tpublic File getBitmapFile(String type, String name) {\n\t\treturn new File(getCachePath(type, name));\n\t}\n\n\tpublic File getBitmapUrlFile(String type, String url) {\n\t\treturn getBitmapFile(type, getCacheName(url));\n\t}\n\n\tprivate String getCacheName(String url) {\n\t\treturn url.replaceAll(\"/\", \".\").replaceAll(\":\", \"\");\n\t}\n\t\n\tprivate String getCachePath(String type, String name) {\n\t\treturn mCacheDir.getAbsolutePath() + \"/\" + type + \"/\" + name + \".cache\";\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/cache/file/OfflineDocumentManager.java",
    "content": "package moe.feng.nhentai.cache.file;\n\nimport android.content.Context;\n\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\nimport moe.feng.nhentai.cache.common.Constants;\n\npublic class OfflineDocumentManager {\n\n\tprivate FileCacheManager mCacheManager;\n\n\tprivate static OfflineDocumentManager sInstance;\n\n\tpublic static OfflineDocumentManager getInstance(Context context) {\n\t\tif (sInstance == null) {\n\t\t\tsInstance = new OfflineDocumentManager(context);\n\t\t}\n\n\t\treturn sInstance;\n\t}\n\n\tprivate OfflineDocumentManager(Context context) {\n\t\tmCacheManager = FileCacheManager.getInstance(context);\n\t}\n\n\tpublic String getOfflineDocument(String url) {\n\t\tif (mCacheManager.cacheExistsUrl(Constants.CACHE_DOCUMENT, url)) {\n\t\t\tBufferedReader bf = new BufferedReader(\n\t\t\t\t\tnew InputStreamReader(mCacheManager.openCacheStreamUrl(Constants.CACHE_DOCUMENT, url))\n\t\t\t);\n\t\t\tStringBuffer buffer = new StringBuffer();\n\t\t\tString line = \"\";\n\t\t\ttry {\n\t\t\t\twhile ((line = bf.readLine()) != null){\n\t\t\t\t\tbuffer.append(line);\n\t\t\t\t}\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn buffer.toString();\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tpublic boolean hasOfflineCache(String url) {\n\t\treturn mCacheManager.cacheExistsUrl(Constants.CACHE_DOCUMENT, url);\n\t}\n\n\tpublic boolean createOfflineCache(String url) {\n\t\treturn mCacheManager.createCacheFromNetwork(Constants.CACHE_DOCUMENT, url);\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/dao/CommonPreferences.java",
    "content": "package moe.feng.nhentai.dao;\n\nimport android.content.Context;\n\nimport java.util.ArrayList;\n\nimport sumimakito.android.quickkv.QuickKV;\nimport sumimakito.android.quickkv.database.KeyValueDatabase;\n\npublic class CommonPreferences {\n\n\tprivate QuickKV mQuickKV;\n\tprivate KeyValueDatabase mKVDB;\n\tprivate String mDBName;\n\n\tprivate static ArrayList<Instance> sInstances = new ArrayList<>();\n\n\tpublic static CommonPreferences getInstance(Context context, String dbName) {\n\t\tCommonPreferences sInstance = null;\n\t\tfor (Instance i : sInstances) {\n\t\t\tif (i.dbName == dbName) {\n\t\t\t\tsInstance = i.preferences;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (sInstance == null) {\n\t\t\tsInstance = new CommonPreferences(context, dbName);\n\t\t\tsInstances.add(new Instance(sInstance, dbName));\n\t\t}\n\t\treturn sInstance;\n\t}\n\n\tprivate CommonPreferences(Context context, String dbName) {\n\t\tthis.mQuickKV = new QuickKV(context);\n\t\tthis.mDBName = dbName;\n\t\treload();\n\t}\n\n\tpublic void sync() {\n\t\tthis.mKVDB.sync(true);\n\t}\n\n\tpublic void reload() {\n\t\tthis.mKVDB = this.mQuickKV.getDatabase(\"prefs_\" + mDBName);\n\t}\n\n\tpublic Editor edit() {\n\t\treturn new Editor(mKVDB);\n\t}\n\n\tpublic int getInt(String key, int defValue) {\n\t\treturn contains(key) ? (int) mKVDB.get(key) : defValue;\n\t}\n\n\tpublic String getString(String key, String defValue) {\n\t\treturn contains(key) ? (String) mKVDB.get(key) : defValue;\n\t}\n\n\tpublic boolean getBoolean(String key, boolean defValue) {\n\t\treturn contains(key) ? (boolean) mKVDB.get(key) : defValue;\n\t}\n\n\tpublic long getLong(String key, long defValue) {\n\t\treturn contains(key) ? (long) mKVDB.get(key) : defValue;\n\t}\n\n\tpublic float getFloat(String key, float defValue) {\n\t\treturn contains(key) ? (float) mKVDB.get(key) : defValue;\n\t}\n\n\tpublic boolean contains(String key) {\n\t\treturn mKVDB.containsKey(key);\n\t}\n\n\tpublic class Editor {\n\n\t\tprivate KeyValueDatabase mKVDB;\n\n\t\tprivate Editor(KeyValueDatabase kvdb) {\n\t\t\tthis.mKVDB = kvdb;\n\t\t}\n\n\t\tpublic Editor putBoolean(String key, boolean value) {\n\t\t\tthis.mKVDB.put(key, value);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic Editor putInt(String key, int value) {\n\t\t\tthis.mKVDB.put(key, value);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic Editor putString(String key, String value) {\n\t\t\tthis.mKVDB.put(key, value);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic Editor putLong(String key, long value) {\n\t\t\tthis.mKVDB.put(key, value);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic Editor putFloat(String key, float value) {\n\t\t\tthis.mKVDB.put(key, value);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic Editor remove(String key){\n\t\t\tthis.mKVDB.remove(key);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic void clear() {\n\t\t\tthis.mKVDB.clear();\n\t\t\tthis.mKVDB.persist();\n\t\t}\n\n\t\tpublic boolean commit() {\n\t\t\treturn this.mKVDB.persist();\n\t\t}\n\n\t}\n\n\tprivate static class Instance {\n\n\t\tCommonPreferences preferences;\n\t\tString dbName;\n\n\t\tpublic Instance(CommonPreferences preferences, String dbName) {\n\t\t\tthis.preferences = preferences;\n\t\t\tthis.dbName = dbName;\n\t\t}\n\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/dao/SearchHistoryManager.java",
    "content": "package moe.feng.nhentai.dao;\n\nimport android.content.Context;\n\nimport com.quinny898.library.persistentsearch.SearchResult;\n\nimport java.util.ArrayList;\n\nimport moe.feng.nhentai.R;\nimport sumimakito.android.quickkv.QuickKV;\nimport sumimakito.android.quickkv.database.KeyValueDatabase;\n\npublic class SearchHistoryManager {\n\n\tprivate QuickKV mQuickKV;\n\tprivate KeyValueDatabase mDB;\n\tprivate String mSectionName;\n\n\tprivate static ArrayList<Instance> sInstances = new ArrayList<>();\n\n\tprivate static final String DATABASE_NAME = \"search_history\";\n\n\tpublic static SearchHistoryManager getInstance(Context context, String sectionName) {\n\t\tSearchHistoryManager sInstance = null;\n\t\tfor (Instance i : sInstances) {\n\t\t\tif (i.sectionName == sectionName) {\n\t\t\t\tsInstance = i.manager;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (sInstance == null) {\n\t\t\tsInstance = new SearchHistoryManager(context, sectionName);\n\t\t\tsInstances.add(new Instance(sInstance, sectionName));\n\t\t}\n\t\treturn sInstance;\n\t}\n\n\tpublic SearchHistoryManager(Context context, String sectionName) {\n\t\tthis.mQuickKV = new QuickKV(context);\n\t\tthis.mSectionName = sectionName;\n\t\treloadDatabase();\n\t}\n\n\tpublic void reloadDatabase() {\n\t\tmDB = mQuickKV.getDatabase(DATABASE_NAME + \"_\" + mSectionName);\n\t}\n\n\tpublic void add(String keyword) {\n\t\tint pos = find(keyword);\n\t\tif (pos < 0) {\n\t\t\tpos = 9;\n\t\t}\n\t\tmoveArrayToNext(pos - 1);\n\t\tmDB.put(\"history_0\", keyword);\n\t\tmDB.persist();\n\t}\n\n\tpublic String get(int pos) {\n\t\treturn (String) mDB.get(\"history_\" + pos);\n\t}\n\n\tpublic int find(String keyword) {\n\t\tfor (int i = 9; i >= 0; i--) {\n\t\t\tif (mDB.containsKey(\"history_\" + i)) {\n\t\t\t\tif (mDB.get(\"history_\" + i).equals(keyword)){\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}\n\n\tprivate void moveArrayToNext(int end) {\n\t\tfor (int i = end; i >= 0; i--) {\n\t\t\tif (mDB.containsKey(\"history_\" + i)) {\n\t\t\t\tmDB.put(\"history_\" + (i + 1), mDB.get(\"history_\" + i));\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic void cleanAll() {\n\t\tmDB.clear();\n\t\tmDB.persist();\n\t}\n\n\tpublic String[] getAll() {\n\t\tString[] histories = new String[10];\n\t\tfor (int i = 0; i < 10; i++) {\n\t\t\thistories[i] = (String) mDB.get(\"history_\" + i);\n\t\t}\n\t\treturn histories;\n\t}\n\n\tpublic ArrayList<SearchResult> getSearchResults() {\n\t\tArrayList<SearchResult> results = new ArrayList<>();\n\t\tfor (String history : getAll()) {\n\t\t\tif (history == null) continue;\n\t\t\tresults.add(new SearchResult(history, R.drawable.ic_history));\n\t\t}\n\t\treturn results;\n\t}\n\n\tprivate static class Instance {\n\n\t\tSearchHistoryManager manager;\n\t\tString sectionName;\n\n\t\tpublic Instance(SearchHistoryManager manager, String sectionName) {\n\t\t\tthis.manager = manager;\n\t\t\tthis.sectionName = sectionName;\n\t\t}\n\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/model/BaseMessage.java",
    "content": "package moe.feng.nhentai.model;\n\npublic class BaseMessage {\n\n\tprivate int code = -1;\n\tprivate Object data;\n\n\tpublic BaseMessage(int code, Object data) {\n\t\tthis.code = code;\n\t\tthis.data = data;\n\t}\n\n\tpublic BaseMessage() {\n\n\t}\n\n\tpublic int getCode() {\n\t\treturn code;\n\t}\n\n\tpublic void setCode(int code) {\n\t\tthis.code = code;\n\t}\n\n\tpublic <T> T getData() {\n\t\treturn (T) data;\n\t}\n\n\tpublic void setData(Object data) {\n\t\tthis.data = data;\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/model/Book.java",
    "content": "package moe.feng.nhentai.model;\n\nimport com.google.gson.Gson;\n\nimport java.util.ArrayList;\n\npublic class Book {\n\n\t/** 必须获取到的数据 */\n\tpublic String title, other, bookId;\n\n\t/** 次要数据 */\n\tpublic String previewImageUrl, bigCoverImageUrl, titleJP, galleryId;\n\tpublic int pageCount;\n\n\tpublic int thumbHeight = 0, thumbWidth = 0;\n\n\tpublic String parodies, language, artist, group;\n\tpublic ArrayList<String> tags = new ArrayList<>();\n\tpublic ArrayList<String> characters = new ArrayList<>();\n\n\tpublic String uploadTime, uploadTimeText;\n\n\tpublic Book() {\n\t\tthis(null, null, null);\n\t}\n\n\tpublic Book(String title, String other, String bookId) {\n\t\tthis.title = title;\n\t\tthis.other = other;\n\t\tthis.bookId = bookId;\n\t}\n\n\tpublic Book(String title, String other, String bookId, String previewImageUrl) {\n\t\tthis.title = title;\n\t\tthis.other = other;\n\t\tthis.bookId = bookId;\n\t\tthis.previewImageUrl = previewImageUrl;\n\t}\n\n\tpublic String toJSONString() {\n\t\treturn new Gson().toJson(this);\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/BookDetailsActivity.java",
    "content": "package moe.feng.nhentai.ui;\n\nimport android.app.Activity;\nimport android.content.Intent;\nimport android.os.Bundle;\nimport android.support.design.widget.CollapsingToolbarLayout;\nimport android.support.design.widget.FloatingActionButton;\nimport android.support.design.widget.Snackbar;\nimport android.support.v4.app.ActivityCompat;\nimport android.support.v4.app.ActivityOptionsCompat;\nimport android.support.v4.view.ViewCompat;\nimport android.support.v7.app.AppCompatActivity;\nimport android.support.v7.widget.Toolbar;\nimport android.text.TextUtils;\nimport android.view.ContextThemeWrapper;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.ImageView;\nimport android.widget.LinearLayout;\nimport android.widget.TextView;\n\nimport com.github.florent37.materialimageloading.MaterialImageLoading;\nimport com.google.gson.Gson;\nimport com.squareup.picasso.Callback;\nimport com.squareup.picasso.Picasso;\n\nimport java.io.File;\n\nimport moe.feng.nhentai.R;\nimport moe.feng.nhentai.api.BookApi;\nimport moe.feng.nhentai.api.common.NHentaiUrl;\nimport moe.feng.nhentai.cache.common.Constants;\nimport moe.feng.nhentai.cache.file.FileCacheManager;\nimport moe.feng.nhentai.model.BaseMessage;\nimport moe.feng.nhentai.model.Book;\nimport moe.feng.nhentai.util.AsyncTask;\nimport moe.feng.nhentai.util.ColorGenerator;\nimport moe.feng.nhentai.util.TextDrawable;\nimport moe.feng.nhentai.view.AutoWrapLayout;\nimport moe.feng.nhentai.view.WheelProgressView;\n\npublic class BookDetailsActivity extends AppCompatActivity {\n\n\tprivate ImageView mImageView;\n\tprivate CollapsingToolbarLayout collapsingToolbar;\n\tprivate FloatingActionButton mFAB;\n\tprivate TextView mTitleText;\n\tprivate LinearLayout mTagsLayout;\n\tprivate LinearLayout mContentView;\n\tprivate WheelProgressView mProgressWheel;\n\n\tprivate Book book;\n\n\tprivate final static String EXTRA_BOOK_DATA = \"book_data\";\n\tprivate final static String TRANSITION_NAME_IMAGE = \"BookDetailsActivity:image\";\n\n\t@Override\n\tprotected void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\t\tsetContentView(R.layout.activity_book_details);\n\n\t\tIntent intent = getIntent();\n\t\tbook = new Gson().fromJson(intent.getStringExtra(EXTRA_BOOK_DATA), Book.class);\n\n\t\tToolbar toolbar = $(R.id.toolbar);\n\t\tsetSupportActionBar(toolbar);\n\t\tgetSupportActionBar().setDisplayHomeAsUpEnabled(true);\n\n\t\tcollapsingToolbar = $(R.id.collapsing_toolbar);\n\t\tcollapsingToolbar.setTitle(book.title);\n\n\t\tmImageView = $(R.id.app_bar_background);\n\t\tViewCompat.setTransitionName(mImageView, TRANSITION_NAME_IMAGE);\n\n\t\tmFAB = $(R.id.fab);\n\t\tmTitleText = $(R.id.tv_title);\n\t\tmTagsLayout = $(R.id.book_tags_layout);\n\t\tmContentView = $(R.id.book_content);\n\t\tmProgressWheel = $(R.id.wheel_progress);\n\n\t\tFileCacheManager cm = FileCacheManager.getInstance(getApplicationContext());\n\t\tif (cm.cacheExistsUrl(Constants.CACHE_THUMB, book.previewImageUrl)) {\n\t\t\tPicasso.with(getApplicationContext())\n\t\t\t\t\t.load(cm.getBitmapUrlFile(Constants.CACHE_THUMB, book.previewImageUrl))\n\t\t\t\t\t.fit()\n\t\t\t\t\t.centerCrop()\n\t\t\t\t\t.into(mImageView, new Callback() {\n\t\t\t\t\t\t@Override\n\t\t\t\t\t\tpublic void onSuccess() {\n\t\t\t\t\t\t\tMaterialImageLoading.animate(mImageView).setDuration(1500).start();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t@Override\n\t\t\t\t\t\tpublic void onError() {\n\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t} else {\n\t\t\tint color = ColorGenerator.MATERIAL.getColor(book.title);\n\t\t\tTextDrawable drawable = TextDrawable.builder().buildRect(book.title.substring(0, 1), color);\n\t\t\tmImageView.setImageDrawable(drawable);\n\t\t}\n\t\tif (cm.cacheExistsUrl(Constants.CACHE_COVER, book.bigCoverImageUrl)) {\n\t\t\tPicasso.with(getApplicationContext())\n\t\t\t\t\t.load(cm.getBitmapUrlFile(Constants.CACHE_COVER, book.bigCoverImageUrl))\n\t\t\t\t\t.fit()\n\t\t\t\t\t.centerCrop()\n\t\t\t\t\t.into(mImageView, new Callback() {\n\t\t\t\t\t\t@Override\n\t\t\t\t\t\tpublic void onSuccess() {\n\t\t\t\t\t\t\tMaterialImageLoading.animate(mImageView).setDuration(1500).start();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t@Override\n\t\t\t\t\t\tpublic void onError() {\n\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t} else {\n\t\t\tnew CoverTask().execute(book);\n\t\t}\n\n\t\tstartBookGet();\n\t}\n\n\tpublic static void launch(Activity activity, ImageView imageView, Book book) {\n\t\tActivityOptionsCompat options = ActivityOptionsCompat\n\t\t\t\t.makeSceneTransitionAnimation(activity, imageView, TRANSITION_NAME_IMAGE);\n\t\tIntent intent = new Intent(activity, BookDetailsActivity.class);\n\t\tintent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);\n\t\tintent.putExtra(EXTRA_BOOK_DATA, book.toJSONString());\n\t\tActivityCompat.startActivity(activity, intent, options.toBundle());\n\t}\n\n\tprivate void updateUIContent() {\n\t\tcollapsingToolbar.setTitle(book.title);\n\t\tcollapsingToolbar.invalidate();\n\t\t$(R.id.toolbar).invalidate();\n\t\t$(R.id.appbar).invalidate();\n\n\t\tmFAB.setOnClickListener(new View.OnClickListener() {\n\t\t\t@Override\n\t\t\tpublic void onClick(View view) {\n\t\t\t\tGalleryActivity.launch(BookDetailsActivity.this, book, 0);\n\t\t\t}\n\t\t});\n\n\t\tupdateDetailsContent();\n\t}\n\n\tprivate void updateDetailsContent() {\n\t\tmProgressWheel.setVisibility(View.GONE);\n\t\tmContentView.setVisibility(View.VISIBLE);\n\t\tmContentView.animate().alphaBy(0f).alpha(1f).setDuration(1500).start();\n\t\tmTitleText.setText(TextUtils.isEmpty(book.titleJP) ? book.title : book.titleJP);\n\n\t\tupdateTagsContent();\n\t}\n\n\tprivate void updateTagsContent() {\n\t\tint x = getResources().getDimensionPixelSize(R.dimen.tag_margin_x);\n\t\tint y = getResources().getDimensionPixelSize(R.dimen.tag_margin_y);\n\t\tint min_width = getResources().getDimensionPixelSize(R.dimen.tag_title_width);\n\t\tContextThemeWrapper ctw = new ContextThemeWrapper(this, R.style.TextTag);\n\n\t\t// Add Parodies Tags\n\t\tif (!TextUtils.isEmpty(book.parodies)) {\n\t\t\tLinearLayout tagGroupLayout = new LinearLayout(this);\n\t\t\ttagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);\n\t\t\tAutoWrapLayout tagLayout = new AutoWrapLayout(this);\n\n\t\t\tTextView groupNameView = new TextView(this);\n\t\t\tgroupNameView.setMinWidth(min_width);\n\t\t\tgroupNameView.setText(R.string.tag_type_parodies);\n\t\t\tLinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(\n\t\t\t\t\tLinearLayout.LayoutParams.WRAP_CONTENT,\n\t\t\t\t\tLinearLayout.LayoutParams.WRAP_CONTENT);\n\t\t\tlp.setMargins(x, y, x, y);\n\t\t\tlp.width = min_width;\n\t\t\ttagGroupLayout.addView(groupNameView, lp);\n\n\t\t\tTextView tagView = new TextView(ctw);\n\t\t\ttagView.setText(book.parodies);\n\t\t\ttagView.setBackgroundResource(R.color.deep_purple_800);\n\t\t\ttagView.setOnClickListener(new View.OnClickListener() {\n\t\t\t\t@Override\n\t\t\t\tpublic void onClick(View v) {\n\t\t\t\t\tCategoryActivity.launch(\n\t\t\t\t\t\t\tBookDetailsActivity.this,\n\t\t\t\t\t\t\tNHentaiUrl.getParodyUrl(book.parodies),\n\t\t\t\t\t\t\tgetString(R.string.tag_type_parodies).trim() + \" \" + book.parodies\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t\tAutoWrapLayout.LayoutParams alp = new AutoWrapLayout.LayoutParams();\n\t\t\talp.setMargins(x, y, x, y);\n\t\t\ttagLayout.addView(tagView, alp);\n\t\t\ttagGroupLayout.addView(tagLayout);\n\t\t\tmTagsLayout.addView(tagGroupLayout);\n\t\t}\n\n\t\t// Add Characters\n\t\tif (!book.characters.isEmpty()) {\n\t\t\tLinearLayout tagGroupLayout = new LinearLayout(this);\n\t\t\ttagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);\n\t\t\tAutoWrapLayout tagLayout = new AutoWrapLayout(this);\n\n\t\t\tTextView groupNameView = new TextView(this);\n\t\t\tgroupNameView.setMinWidth(min_width);\n\t\t\tgroupNameView.setText(R.string.tag_type_characters);\n\t\t\tLinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(\n\t\t\t\t\tLinearLayout.LayoutParams.WRAP_CONTENT,\n\t\t\t\t\tLinearLayout.LayoutParams.WRAP_CONTENT);\n\t\t\tlp.setMargins(x, y, x, y);\n\t\t\tlp.width = min_width;\n\t\t\ttagGroupLayout.addView(groupNameView, lp);\n\n\t\t\tfor (final String tag : book.characters) {\n\t\t\t\tTextView tagView = new TextView(ctw);\n\t\t\t\ttagView.setText(tag);\n\t\t\t\ttagView.setBackgroundResource(R.color.deep_purple_800);\n\t\t\t\ttagView.setOnClickListener(new View.OnClickListener() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void onClick(View v) {\n\t\t\t\t\t\tCategoryActivity.launch(\n\t\t\t\t\t\t\t\tBookDetailsActivity.this,\n\t\t\t\t\t\t\t\tNHentaiUrl.getCharacterUrl(tag),\n\t\t\t\t\t\t\t\tgetString(R.string.tag_type_characters).trim() + \" \" + tag\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tAutoWrapLayout.LayoutParams alp = new AutoWrapLayout.LayoutParams();\n\t\t\t\talp.setMargins(x, y, x, y);\n\t\t\t\ttagLayout.addView(tagView, alp);\n\t\t\t}\n\t\t\ttagGroupLayout.addView(tagLayout);\n\t\t\tmTagsLayout.addView(tagGroupLayout);\n\t\t}\n\n\t\t// Add Tags\n\t\tif (!book.tags.isEmpty()) {\n\t\t\tLinearLayout tagGroupLayout = new LinearLayout(this);\n\t\t\ttagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);\n\t\t\tAutoWrapLayout tagLayout = new AutoWrapLayout(this);\n\n\t\t\tTextView groupNameView = new TextView(this);\n\t\t\tgroupNameView.setMinWidth(min_width);\n\t\t\tgroupNameView.setText(R.string.tag_type_tag);\n\t\t\tLinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(\n\t\t\t\t\tLinearLayout.LayoutParams.WRAP_CONTENT,\n\t\t\t\t\tLinearLayout.LayoutParams.WRAP_CONTENT);\n\t\t\tlp.setMargins(x, y, x, y);\n\t\t\tlp.width = min_width;\n\t\t\ttagGroupLayout.addView(groupNameView, lp);\n\n\t\t\tfor (final String tag : book.tags) {\n\t\t\t\tTextView tagView = new TextView(ctw);\n\t\t\t\ttagView.setText(tag);\n\t\t\t\ttagView.setBackgroundResource(R.color.deep_purple_800);\n\t\t\t\ttagView.setOnClickListener(new View.OnClickListener() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void onClick(View v) {\n\t\t\t\t\t\tCategoryActivity.launch(\n\t\t\t\t\t\t\t\tBookDetailsActivity.this,\n\t\t\t\t\t\t\t\tNHentaiUrl.getTagUrl(tag),\n\t\t\t\t\t\t\t\tgetString(R.string.tag_type_tag).trim() + \" \" + tag\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tAutoWrapLayout.LayoutParams alp1 = new AutoWrapLayout.LayoutParams();\n\t\t\t\talp1.setMargins(x, y, x, y);\n\t\t\t\ttagLayout.addView(tagView, alp1);\n\t\t\t}\n\t\t\ttagGroupLayout.addView(tagLayout);\n\t\t\tmTagsLayout.addView(tagGroupLayout);\n\t\t}\n\n\t\t// Add Artist Tag\n\t\tif (!TextUtils.isEmpty(book.artist)) {\n\t\t\tLinearLayout tagGroupLayout = new LinearLayout(this);\n\t\t\ttagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);\n\t\t\tAutoWrapLayout tagLayout = new AutoWrapLayout(this);\n\n\t\t\tTextView groupNameView = new TextView(this);\n\t\t\tgroupNameView.setMinWidth(min_width);\n\t\t\tgroupNameView.setText(R.string.tag_type_artists);\n\t\t\tLinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(\n\t\t\t\t\tLinearLayout.LayoutParams.WRAP_CONTENT,\n\t\t\t\t\tLinearLayout.LayoutParams.WRAP_CONTENT);\n\t\t\tlp.setMargins(x, y, x, y);\n\t\t\tlp.width = min_width;\n\t\t\ttagGroupLayout.addView(groupNameView, lp);\n\n\t\t\tTextView tagView = new TextView(ctw);\n\t\t\ttagView.setText(book.artist);\n\t\t\ttagView.setBackgroundResource(R.color.deep_purple_800);\n\t\t\ttagView.setOnClickListener(new View.OnClickListener() {\n\t\t\t\t@Override\n\t\t\t\tpublic void onClick(View v) {\n\t\t\t\t\tCategoryActivity.launch(\n\t\t\t\t\t\t\tBookDetailsActivity.this,\n\t\t\t\t\t\t\tNHentaiUrl.getArtistUrl(book.artist),\n\t\t\t\t\t\t\tgetString(R.string.tag_type_artists).trim() + \" \" + book.artist\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t\tAutoWrapLayout.LayoutParams alp = new AutoWrapLayout.LayoutParams();\n\t\t\talp.setMargins(x, y, x, y);\n\t\t\ttagLayout.addView(tagView, alp);\n\t\t\ttagGroupLayout.addView(tagLayout);\n\t\t\tmTagsLayout.addView(tagGroupLayout);\n\t\t}\n\n\t\t// Add Groups Tag\n\t\tif (!TextUtils.isEmpty(book.group)) {\n\t\t\tLinearLayout tagGroupLayout = new LinearLayout(this);\n\t\t\ttagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);\n\t\t\tAutoWrapLayout tagLayout = new AutoWrapLayout(this);\n\n\t\t\tTextView groupNameView = new TextView(this);\n\t\t\tgroupNameView.setMinWidth(min_width);\n\t\t\tgroupNameView.setText(R.string.tag_type_group);\n\t\t\tLinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(\n\t\t\t\t\tLinearLayout.LayoutParams.WRAP_CONTENT,\n\t\t\t\t\tLinearLayout.LayoutParams.WRAP_CONTENT);\n\t\t\tlp.setMargins(x, y, x, y);\n\t\t\tlp.width = min_width;\n\t\t\ttagGroupLayout.addView(groupNameView, lp);\n\n\t\t\tTextView tagView = new TextView(ctw);\n\t\t\ttagView.setText(book.group);\n\t\t\ttagView.setBackgroundResource(R.color.deep_purple_800);\n\t\t\ttagView.setOnClickListener(new View.OnClickListener() {\n\t\t\t\t@Override\n\t\t\t\tpublic void onClick(View v) {\n\t\t\t\t\tCategoryActivity.launch(\n\t\t\t\t\t\t\tBookDetailsActivity.this,\n\t\t\t\t\t\t\tNHentaiUrl.getGroupUrl(book.group),\n\t\t\t\t\t\t\tgetString(R.string.tag_type_group).trim() + \" \" + book.group\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t\tAutoWrapLayout.LayoutParams alp = new AutoWrapLayout.LayoutParams();\n\t\t\talp.setMargins(x, y, x, y);\n\t\t\ttagLayout.addView(tagView, alp);\n\t\t\ttagGroupLayout.addView(tagLayout);\n\t\t\tmTagsLayout.addView(tagGroupLayout);\n\t\t}\n\n\t\t// Add Language Tag\n\t\tif (!TextUtils.isEmpty(book.language)) {\n\t\t\tLinearLayout tagGroupLayout = new LinearLayout(this);\n\t\t\ttagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);\n\t\t\tAutoWrapLayout tagLayout = new AutoWrapLayout(this);\n\n\t\t\tTextView groupNameView = new TextView(this);\n\t\t\tgroupNameView.setText(R.string.tag_type_language);\n\t\t\tLinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(\n\t\t\t\t\tLinearLayout.LayoutParams.WRAP_CONTENT,\n\t\t\t\t\tLinearLayout.LayoutParams.WRAP_CONTENT);\n\t\t\tlp.setMargins(x, y, x, y);\n\t\t\tlp.width = min_width;\n\t\t\ttagGroupLayout.addView(groupNameView, lp);\n\n\t\t\tTextView tagView = new TextView(ctw);\n\t\t\ttagView.setText(book.language);\n\t\t\ttagView.setBackgroundResource(R.color.deep_purple_800);\n\t\t\ttagView.setOnClickListener(new View.OnClickListener() {\n\t\t\t\t@Override\n\t\t\t\tpublic void onClick(View v) {\n\t\t\t\t\tCategoryActivity.launch(\n\t\t\t\t\t\t\tBookDetailsActivity.this,\n\t\t\t\t\t\t\tNHentaiUrl.getLanguageUrl(book.language),\n\t\t\t\t\t\t\tgetString(R.string.tag_type_language).trim() + \" \" + book.language\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t\tAutoWrapLayout.LayoutParams alp = new AutoWrapLayout.LayoutParams();\n\t\t\talp.setMargins(x, y, x, y);\n\t\t\ttagLayout.addView(tagView, alp);\n\t\t\ttagGroupLayout.addView(tagLayout);\n\t\t\tmTagsLayout.addView(tagGroupLayout);\n\t\t}\n\t}\n\n\t@Override\n\tpublic boolean onOptionsItemSelected(MenuItem item) {\n\t\tint id = item.getItemId();\n\t\tif (id == android.R.id.home) {\n\t\t\tthis.onBackPressed();\n\t\t\treturn true;\n\t\t}\n\t\treturn super.onOptionsItemSelected(item);\n\t}\n\n\tprivate void startBookGet() {\n\t\tmContentView.setVisibility(View.GONE);\n\t\tmProgressWheel.setVisibility(View.VISIBLE);\n\t\tmProgressWheel.spin();\n\n\t\tnew BookGetTask().execute(book.bookId);\n\t}\n\n\tprivate class BookGetTask extends AsyncTask<String, Void, BaseMessage> {\n\n\t\t@Override\n\t\tprotected BaseMessage doInBackground(String... params) {\n\t\t\treturn BookApi.getBook(params[0]);\n\t\t}\n\n\t\t@Override\n\t\tprotected void onPostExecute(BaseMessage result) {\n\t\t\tif (result.getCode() == 0) {\n\t\t\t\tbook = result.getData();\n\t\t\t\tupdateUIContent();\n\t\t\t} else {\n\t\t\t\tmProgressWheel.setVisibility(View.GONE);\n\n\t\t\t\tSnackbar.make(\n\t\t\t\t\t\t$(R.id.main_content),\n\t\t\t\t\t\tR.string.tips_network_error,\n\t\t\t\t\t\tSnackbar.LENGTH_LONG\n\t\t\t\t).setAction(\n\t\t\t\t\t\tR.string.snack_action_try_again,\n\t\t\t\t\t\tnew View.OnClickListener() {\n\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\tpublic void onClick(View view) {\n\t\t\t\t\t\t\t\tstartBookGet();\n\t\t\t\t\t\t\t}\n\t\t\t\t}).show();\n\t\t\t}\n\t\t}\n\n\t}\n\t\n\tprivate class CoverTask extends AsyncTask<Book, Void, File> {\n\n\t\t@Override\n\t\tprotected File doInBackground(Book... params) {\n\t\t\treturn BookApi.getCoverFile(BookDetailsActivity.this, params[0]);\n\t\t}\n\n\t\t@Override\n\t\tprotected void onPostExecute(File result) {\n\t\t\tPicasso.with(getApplicationContext())\n\t\t\t\t\t.load(result)\n\t\t\t\t\t.into(mImageView, new Callback() {\n\t\t\t\t\t\t@Override\n\t\t\t\t\t\tpublic void onSuccess() {\n\t\t\t\t\t\t\tMaterialImageLoading.animate(mImageView).setDuration(1500).start();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t@Override\n\t\t\t\t\t\tpublic void onError() {\n\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t}\n\t}\n\n\tprotected <T extends View> T $(int id) {\n\t\treturn (T) findViewById(id);\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/CategoryActivity.java",
    "content": "package moe.feng.nhentai.ui;\n\nimport android.content.Intent;\nimport android.os.Build;\nimport android.os.Bundle;\nimport android.support.design.widget.Snackbar;\nimport android.support.v4.widget.SwipeRefreshLayout;\nimport android.support.v7.app.AppCompatActivity;\nimport android.support.v7.widget.RecyclerView;\nimport android.support.v7.widget.StaggeredGridLayoutManager;\n\nimport java.util.ArrayList;\n\nimport moe.feng.nhentai.R;\nimport moe.feng.nhentai.api.PageApi;\nimport moe.feng.nhentai.model.BaseMessage;\nimport moe.feng.nhentai.model.Book;\nimport moe.feng.nhentai.ui.adapter.BookListRecyclerAdapter;\nimport moe.feng.nhentai.ui.common.AbsActivity;\nimport moe.feng.nhentai.ui.common.AbsRecyclerViewAdapter;\nimport moe.feng.nhentai.util.AsyncTask;\n\npublic class CategoryActivity extends AbsActivity {\n\n\tprivate RecyclerView mRecyclerView;\n\tprivate BookListRecyclerAdapter mAdapter;\n\tprivate StaggeredGridLayoutManager mLayoutManager;\n\n\tprivate SwipeRefreshLayout mSwipeRefreshLayout;\n\n\tprivate ArrayList<Book> mBooks;\n\n\tprivate int mNowPage = 1;\n\tprivate String url, title;\n\n\tprivate static final String EXTRA_URL = \"url\", EXTRA_TITLE = \"title\";\n\n\tpublic static final String TAG = CategoryActivity.class.getSimpleName();\n\n\t@Override\n\tprotected void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\n\t\tIntent intent = getIntent();\n\t\turl = intent.getStringExtra(EXTRA_URL);\n\t\ttitle = intent.getStringExtra(EXTRA_TITLE);\n\n\t\tsetContentView(R.layout.activity_search_result);\n\n\t\tmActionBar.setDisplayHomeAsUpEnabled(true);\n\t\tmActionBar.setTitle(title);\n\t\tif (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {\n\t\t\tmActionBar.setElevation(getResources().getDimension(R.dimen.appbar_elevation));\n\t\t}\n\n\t\tmSwipeRefreshLayout.setRefreshing(true);\n\t\tnew PageGetTask().execute(mNowPage);\n\t}\n\n\t@Override\n\tprotected void setUpViews() {\n\t\tmRecyclerView = $(R.id.recycler_view);\n\t\tmSwipeRefreshLayout = $(R.id.swipe_refresh_layout);\n\n\t\tmLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);\n\t\tmRecyclerView.setLayoutManager(mLayoutManager);\n\t\tmRecyclerView.setHasFixedSize(true);\n\n\t\tmBooks = new ArrayList<>();\n\t\tmAdapter = new BookListRecyclerAdapter(mRecyclerView, mBooks);\n\t\tsetRecyclerViewAdapter(mAdapter);\n\n\t\tmSwipeRefreshLayout.setColorSchemeResources(\n\t\t\t\tR.color.deep_purple_500, R.color.pink_500, R.color.orange_500, R.color.brown_500,\n\t\t\t\tR.color.indigo_500, R.color.blue_500, R.color.teal_500, R.color.green_500\n\t\t);\n\t\tmSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {\n\t\t\t@Override\n\t\t\tpublic void onRefresh() {\n\t\t\t\tif (!mSwipeRefreshLayout.isRefreshing()) {\n\t\t\t\t\tmSwipeRefreshLayout.setRefreshing(true);\n\t\t\t\t}\n\n\t\t\t\tmBooks = new ArrayList<>();\n\t\t\t\tmAdapter = new BookListRecyclerAdapter(mRecyclerView, mBooks);\n\t\t\t\tsetRecyclerViewAdapter(mAdapter);\n\t\t\t\tnew PageGetTask().execute(mNowPage = 1);\n\t\t\t}\n\t\t});\n\t}\n\n\n\tprivate void setRecyclerViewAdapter(BookListRecyclerAdapter adapter) {\n\t\tadapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {\n\t\t\t@Override\n\t\t\tpublic void onItemClick(int position, AbsRecyclerViewAdapter.ClickableViewHolder viewHolder) {\n\t\t\t\tBookListRecyclerAdapter.ViewHolder holder = (BookListRecyclerAdapter.ViewHolder) viewHolder;\n\t\t\t\tBookDetailsActivity.launch(CategoryActivity.this, holder.mPreviewImageView, holder.book);\n\t\t\t}\n\t\t});\n\t\tadapter.addOnScrollListener(new RecyclerView.OnScrollListener() {\n\t\t\t@Override\n\t\t\tpublic void onScrolled(RecyclerView rv, int dx, int dy) {\n\t\t\t\tif (!mSwipeRefreshLayout.isRefreshing() && mLayoutManager.findLastCompletelyVisibleItemPositions(new int[2])[1] >= mAdapter.getItemCount() - 2) {\n\t\t\t\t\tmSwipeRefreshLayout.setRefreshing(true);\n\t\t\t\t\tnew PageGetTask().execute(++mNowPage);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tmRecyclerView.setAdapter(adapter);\n\t}\n\n\tprivate class PageGetTask extends AsyncTask<Integer, Void, BaseMessage> {\n\n\t\t@Override\n\t\tprotected BaseMessage doInBackground(Integer... params) {\n\t\t\treturn PageApi.getPageList(url + \"/?page=\" + mNowPage);\n\t\t}\n\n\t\t@Override\n\t\tprotected void onPostExecute(BaseMessage msg) {\n\t\t\tmSwipeRefreshLayout.setRefreshing(false);\n\t\t\tif (msg != null) {\n\t\t\t\tif (msg.getCode() == 0 && msg.getData() != null) {\n\t\t\t\t\tif (!((ArrayList<Book>) msg.getData()).isEmpty()) {\n\t\t\t\t\t\tmBooks.addAll((ArrayList<Book>) msg.getData());\n\t\t\t\t\t\tmAdapter.notifyDataSetChanged();\n\t\t\t\t\t\tif (mNowPage == 1) {\n\t\t\t\t\t\t\tmRecyclerView.setAdapter(mAdapter);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tSnackbar.make(mRecyclerView, R.string.tips_no_result, Snackbar.LENGTH_LONG).show();\n\t\t\t\t\t}\n\t\t\t\t} else if (mNowPage == 1) {\n\t\t\t\t\tSnackbar.make(mRecyclerView, R.string.tips_no_result, Snackbar.LENGTH_LONG).show();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tpublic static void launch(AppCompatActivity activity, String url, String title) {\n\t\tIntent intent = new Intent(activity, CategoryActivity.class);\n\t\tintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\n\t\tintent.putExtra(EXTRA_URL, url);\n\t\tintent.putExtra(EXTRA_TITLE, title);\n\t\tactivity.startActivity(intent);\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/GalleryActivity.java",
    "content": "package moe.feng.nhentai.ui;\n\nimport android.app.Activity;\nimport android.content.Intent;\nimport android.graphics.Color;\nimport android.os.Build;\nimport android.os.Bundle;\nimport android.support.v4.view.ViewPager;\nimport android.view.View;\nimport android.view.WindowManager;\n\nimport com.google.gson.Gson;\n\nimport moe.feng.nhentai.R;\nimport moe.feng.nhentai.model.Book;\nimport moe.feng.nhentai.ui.adapter.GalleryPagerAdapter;\nimport moe.feng.nhentai.ui.common.AbsActivity;\nimport moe.feng.nhentai.util.FullScreenHelper;\n\npublic class GalleryActivity extends AbsActivity {\n\n\tprivate Book book;\n\tprivate int page_num;\n\n\tprivate ViewPager mPager;\n\tprivate GalleryPagerAdapter mPagerAdpater;\n\tprivate View mAppBar;\n\n\tprivate FullScreenHelper mFullScreenHelper;\n\n\tprivate static final String EXTRA_BOOK_DATA = \"book_data\", EXTRA_FISRT_PAGE = \"first_page\";\n\n\t@Override\n\tprotected void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\n\t\tif (Build.VERSION.SDK_INT >= 21) {\n\t\t\tgetWindow().setStatusBarColor(Color.TRANSPARENT);\n\t\t\tgetWindow().setNavigationBarColor(Color.TRANSPARENT);\n\t\t}\n\n\t\tmFullScreenHelper = new FullScreenHelper(this);\n\t\t// 别问我为什么这么干 让我先冷静一下→_→\n\t\tmFullScreenHelper.setFullScreen(true);\n\t\tmFullScreenHelper.setFullScreen(false);\n\n\t\tIntent intent = getIntent();\n\t\tbook = new Gson().fromJson(intent.getStringExtra(EXTRA_BOOK_DATA), Book.class);\n\t\tpage_num = intent.getIntExtra(EXTRA_FISRT_PAGE, 0);\n\n\t\tsetContentView(R.layout.activity_gallery);\n\t}\n\n\t@Override\n\tprotected void setUpViews() {\n\t\tgetSupportActionBar().setDisplayHomeAsUpEnabled(true);\n\t\tgetSupportActionBar().setTitle(book.titleJP != null ? book.titleJP : book.title);\n\n\t\tmAppBar = $(R.id.my_app_bar);\n\t\tmPager = $(R.id.pager);\n\t\tmPagerAdpater = new GalleryPagerAdapter(getFragmentManager(), book);\n\t\tmPager.setAdapter(mPagerAdpater);\n\t\tmPager.setCurrentItem(page_num, false);\n\t}\n\n\tpublic static void launch(Activity activity, Book book, int firstPageNum) {\n\t\tIntent intent = new Intent(activity, GalleryActivity.class);\n\t\tintent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);\n\t\tintent.putExtra(EXTRA_BOOK_DATA, book.toJSONString());\n\t\tintent.putExtra(EXTRA_FISRT_PAGE, firstPageNum);\n\t\tactivity.startActivity(intent);\n\t}\n\n\tpublic void toggleControlBar() {\n\t\tif (mAppBar.getAlpha() != 0f) {\n\t\t\tmAppBar.animate().alpha(0f).start();\n\t\t\tmFullScreenHelper.setFullScreen(true);\n\t\t} else if (mAppBar.getAlpha() != 1f) {\n\t\t\tmAppBar.animate().alpha(1f).start();\n\t\t\tmFullScreenHelper.setFullScreen(false);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void onBackPressed() {\n\t\tif (mAppBar.getAlpha() != 1f) {\n\t\t\ttoggleControlBar();\n\t\t} else {\n\t\t\tsuper.onBackPressed();\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/MainActivity.java",
    "content": "package moe.feng.nhentai.ui;\n\nimport android.content.res.Configuration;\nimport android.os.Build;\nimport android.os.Bundle;\nimport android.os.Handler;\nimport android.support.design.widget.NavigationView;\nimport android.support.design.widget.TabLayout;\nimport android.support.v4.view.ViewPager;\nimport android.support.v4.widget.DrawerLayout;\nimport android.support.v7.app.ActionBarDrawerToggle;\nimport android.view.Menu;\nimport android.view.MenuItem;\nimport android.view.View;\n\nimport com.quinny898.library.persistentsearch.SearchBox;\n\nimport moe.feng.nhentai.R;\nimport moe.feng.nhentai.dao.SearchHistoryManager;\nimport moe.feng.nhentai.ui.adapter.HomePagerAdapter;\nimport moe.feng.nhentai.ui.common.AbsActivity;\n\npublic class MainActivity extends AbsActivity implements NavigationView.OnNavigationItemSelectedListener {\n\n\tprivate ViewPager mPager;\n\tprivate HomePagerAdapter mPagerAdapter;\n\tprivate TabLayout mTabLayout;\n\tprivate SearchBox mSearchBox;\n\tprivate DrawerLayout mDrawerLayout;\n\tprivate NavigationView mNavigationView;\n\tprivate ActionBarDrawerToggle mDrawerToggle;\n\n\tprivate SearchHistoryManager mSearchHistoryManager;\n\n\t@Override\n\tprotected void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState, false);\n\n\t\tif (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {\n\t\t\tgetWindow().setStatusBarColor(getResources().getColor(R.color.deep_purple_800));\n\t\t}\n\n\t\tsetContentView(R.layout.activity_main);\n\n\t\tmActionBar.setDisplayHomeAsUpEnabled(true);\n\n\t\tmSearchHistoryManager = SearchHistoryManager.getInstance(getApplicationContext(), \"all\");\n\t}\n\n\t@Override\n\tprotected void setUpViews() {\n\t\tmPager = $(R.id.viewpager);\n\t\tmTabLayout = $(R.id.tabs);\n\t\tmSearchBox = $(R.id.search_box);\n\n\t\tmDrawerLayout = $(R.id.drawer_layout);\n\t\tmNavigationView = $(R.id.navigation_view);\n\t\tmDrawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() {\n\t\t\t@Override\n\t\t\tpublic void onDrawerOpened(View drawerView) {\n\t\t\t\tmDrawerToggle.onDrawerOpened(drawerView);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void onDrawerClosed(View drawerView) {\n\t\t\t\tmDrawerToggle.onDrawerClosed(drawerView);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void onDrawerSlide(View drawerView, float slideOffset) {\n\t\t\t\tmDrawerToggle.onDrawerSlide(drawerView, slideOffset);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void onDrawerStateChanged(int newState) {\n\t\t\t\tmDrawerToggle.onDrawerStateChanged(newState);\n\t\t\t}\n\t\t});\n\t\tmNavigationView.setNavigationItemSelectedListener(this);\n\n\t\tmDrawerToggle = new ActionBarDrawerToggle(this,\n\t\t\t\tmDrawerLayout,\n\t\t\t\tR.string.abc_action_bar_home_description,\n\t\t\t\tR.string.abc_action_bar_home_description\n\t\t) {\n\t\t\t@Override\n\t\t\tpublic void onDrawerClosed(View drawerView) {\n\t\t\t\tsuper.onDrawerClosed(drawerView);\n\t\t\t\tinvalidateOptionsMenu();\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void onDrawerOpened(View drawerView) {\n\t\t\t\tsuper.onDrawerOpened(drawerView);\n\t\t\t\tinvalidateOptionsMenu();\n\t\t\t}\n\t\t};\n\n\t\tmDrawerLayout.post(new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tmDrawerToggle.syncState();\n\t\t\t}\n\t\t});\n\n\t\tmDrawerLayout.setDrawerListener(mDrawerToggle);\n\n\t\tmPagerAdapter = new HomePagerAdapter(getApplicationContext(), getFragmentManager());\n\t\tmPager.setAdapter(mPagerAdapter);\n\t\tmTabLayout.setupWithViewPager(mPager);\n\t\tmSearchBox.setLogoText(\"\");\n\t\tmSearchBox.setSearchListener(new SearchBox.SearchListener() {\n\t\t\t@Override\n\t\t\tpublic void onSearchOpened() {\n\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void onSearchCleared() {\n\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void onSearchClosed() {\n\t\t\t\tcloseSearchBox();\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void onSearchTermChanged() {\n\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void onSearch(String result) {\n\t\t\t\tmSearchHistoryManager.add(result);\n\t\t\t\tSearchResultActivity.launch(MainActivity.this, result);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate void openSearchBox() {\n\t\tmSearchBox.setVisibility(View.VISIBLE);\n\t\tmSearchBox.setSearchables(mSearchHistoryManager.getSearchResults());\n\t\tmSearchBox.setSearchString(\"\");\n\n\t\tmSearchBox.revealFromMenuItem(R.id.action_search, this);\n\t}\n\n\tprivate void closeSearchBox() {\n\t\tmSearchBox.hideCircularly(this);\n\n\t\tnew Handler().postDelayed(new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\trunOnUiThread(new Runnable() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\tmSearchBox.setVisibility(View.INVISIBLE);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}, 250);\n\t}\n\n\t@Override\n\tprotected void onPostCreate(Bundle savedInstanceState) {\n\t\tsuper.onPostCreate(savedInstanceState);\n\t\tmDrawerToggle.syncState();\n\t}\n\n\t@Override\n\tpublic void onConfigurationChanged(Configuration newConfig) {\n\t\tsuper.onConfigurationChanged(newConfig);\n\t\tmDrawerToggle.onConfigurationChanged(newConfig);\n\t}\n\n\t@Override\n\tpublic boolean onCreateOptionsMenu(Menu menu) {\n\t\tgetMenuInflater().inflate(R.menu.menu_main, menu);\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic boolean onOptionsItemSelected(MenuItem item) {\n\t\tif (mDrawerToggle.onOptionsItemSelected(item)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tint id = item.getItemId();\n\t\tif (id == R.id.action_search) {\n\t\t\topenSearchBox();\n\t\t\treturn true;\n\t\t}\n\t\tif (id == R.id.action_settings) {\n\t\t\tSettingsActivity.launchActivity(this, SettingsActivity.FLAG_MAIN);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn super.onOptionsItemSelected(item);\n\t}\n\n\t@Override\n\tpublic void onBackPressed() {\n\t\tif (mSearchBox.isSearchOpened()) {\n\t\t\tmSearchBox.toggleSearch();\n\t\t} else {\n\t\t\tsuper.onBackPressed();\n\t\t}\n\t}\n\n\t@Override\n\tpublic boolean onNavigationItemSelected(MenuItem menuItem) {\n\t\tmDrawerLayout.closeDrawer(mNavigationView);\n\t\tswitch (menuItem.getItemId()) {\n\t\t\t// TODO Update page\n\t\t\tcase R.id.navigation_item_home:\n\t\t\t\tmenuItem.setChecked(true);\n\t\t\t\treturn true;\n\t\t\tcase R.id.navigation_item_tag:\n\t\t\t\treturn true;\n\t\t\tcase R.id.navigation_item_character:\n\t\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/SearchResultActivity.java",
    "content": "package moe.feng.nhentai.ui;\n\nimport android.content.Intent;\nimport android.os.Build;\nimport android.os.Bundle;\nimport android.support.design.widget.Snackbar;\nimport android.support.v4.widget.SwipeRefreshLayout;\nimport android.support.v7.app.AppCompatActivity;\nimport android.support.v7.widget.RecyclerView;\nimport android.support.v7.widget.StaggeredGridLayoutManager;\n\nimport java.util.ArrayList;\n\nimport moe.feng.nhentai.R;\nimport moe.feng.nhentai.api.PageApi;\nimport moe.feng.nhentai.model.BaseMessage;\nimport moe.feng.nhentai.model.Book;\nimport moe.feng.nhentai.ui.adapter.BookListRecyclerAdapter;\nimport moe.feng.nhentai.ui.common.AbsActivity;\nimport moe.feng.nhentai.ui.common.AbsRecyclerViewAdapter;\nimport moe.feng.nhentai.util.AsyncTask;\n\npublic class SearchResultActivity extends AbsActivity {\n\n\tprivate RecyclerView mRecyclerView;\n\tprivate BookListRecyclerAdapter mAdapter;\n\tprivate StaggeredGridLayoutManager mLayoutManager;\n\n\tprivate SwipeRefreshLayout mSwipeRefreshLayout;\n\n\tprivate ArrayList<Book> mBooks;\n\n\tprivate int mNowPage = 1;\n\tprivate String keyword;\n\n\tprivate static final String EXTRA_KEYWORD = \"keyword\";\n\n\tpublic static final String TAG = SearchResultActivity.class.getSimpleName();\n\n\t@Override\n\tprotected void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\n\t\tIntent intent = getIntent();\n\t\tkeyword = intent.getStringExtra(EXTRA_KEYWORD);\n\n\t\tsetContentView(R.layout.activity_search_result);\n\n\t\tmActionBar.setDisplayHomeAsUpEnabled(true);\n\t\tmActionBar.setTitle(String.format(getString(R.string.title_search_result), keyword));\n\t\tif (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {\n\t\t\tmActionBar.setElevation(getResources().getDimension(R.dimen.appbar_elevation));\n\t\t}\n\n\t\tmSwipeRefreshLayout.setRefreshing(true);\n\t\tnew PageGetTask().execute(mNowPage);\n\t}\n\n\t@Override\n\tprotected void setUpViews() {\n\t\tmRecyclerView = $(R.id.recycler_view);\n\t\tmSwipeRefreshLayout = $(R.id.swipe_refresh_layout);\n\n\t\tmLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);\n\t\tmRecyclerView.setLayoutManager(mLayoutManager);\n\t\tmRecyclerView.setHasFixedSize(true);\n\n\t\tmBooks = new ArrayList<>();\n\t\tmAdapter = new BookListRecyclerAdapter(mRecyclerView, mBooks);\n\t\tsetRecyclerViewAdapter(mAdapter);\n\n\t\tmSwipeRefreshLayout.setColorSchemeResources(\n\t\t\t\tR.color.deep_purple_500, R.color.pink_500, R.color.orange_500, R.color.brown_500,\n\t\t\t\tR.color.indigo_500, R.color.blue_500, R.color.teal_500, R.color.green_500\n\t\t);\n\t\tmSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {\n\t\t\t@Override\n\t\t\tpublic void onRefresh() {\n\t\t\t\tif (!mSwipeRefreshLayout.isRefreshing()) {\n\t\t\t\t\tmSwipeRefreshLayout.setRefreshing(true);\n\t\t\t\t}\n\n\t\t\t\tmBooks = new ArrayList<>();\n\t\t\t\tmAdapter = new BookListRecyclerAdapter(mRecyclerView, mBooks);\n\t\t\t\tsetRecyclerViewAdapter(mAdapter);\n\t\t\t\tnew PageGetTask().execute(mNowPage = 1);\n\t\t\t}\n\t\t});\n\t}\n\n\n\tprivate void setRecyclerViewAdapter(BookListRecyclerAdapter adapter) {\n\t\tadapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {\n\t\t\t@Override\n\t\t\tpublic void onItemClick(int position, AbsRecyclerViewAdapter.ClickableViewHolder viewHolder) {\n\t\t\t\tBookListRecyclerAdapter.ViewHolder holder = (BookListRecyclerAdapter.ViewHolder) viewHolder;\n\t\t\t\tBookDetailsActivity.launch(SearchResultActivity.this, holder.mPreviewImageView, holder.book);\n\t\t\t}\n\t\t});\n\t\tadapter.addOnScrollListener(new RecyclerView.OnScrollListener() {\n\t\t\t@Override\n\t\t\tpublic void onScrolled(RecyclerView rv, int dx, int dy) {\n\t\t\t\tif (!mSwipeRefreshLayout.isRefreshing() && mLayoutManager.findLastCompletelyVisibleItemPositions(new int[2])[1] >= mAdapter.getItemCount() - 2) {\n\t\t\t\t\tmSwipeRefreshLayout.setRefreshing(true);\n\t\t\t\t\tnew PageGetTask().execute(++mNowPage);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tmRecyclerView.setAdapter(adapter);\n\t}\n\n\tprivate class PageGetTask extends AsyncTask<Integer, Void, BaseMessage> {\n\n\t\t@Override\n\t\tprotected BaseMessage doInBackground(Integer... params) {\n\t\t\treturn PageApi.getSearchPageList(keyword, params[0]);\n\t\t}\n\n\t\t@Override\n\t\tprotected void onPostExecute(BaseMessage msg) {\n\t\t\tmSwipeRefreshLayout.setRefreshing(false);\n\t\t\tif (msg != null) {\n\t\t\t\tif (msg.getCode() == 0 && msg.getData() != null) {\n\t\t\t\t\tif (!((ArrayList<Book>) msg.getData()).isEmpty()) {\n\t\t\t\t\t\tmBooks.addAll((ArrayList<Book>) msg.getData());\n\t\t\t\t\t\tmAdapter.notifyDataSetChanged();\n\t\t\t\t\t\tif (mNowPage == 1) {\n\t\t\t\t\t\t\tmRecyclerView.setAdapter(mAdapter);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tSnackbar.make(mRecyclerView, R.string.tips_no_result, Snackbar.LENGTH_LONG).show();\n\t\t\t\t\t}\n\t\t\t\t} else if (mNowPage == 1) {\n\t\t\t\t\tSnackbar.make(mRecyclerView, R.string.tips_no_result, Snackbar.LENGTH_LONG).show();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tpublic static void launch(AppCompatActivity activity, String keyword) {\n\t\tIntent intent = new Intent(activity, SearchResultActivity.class);\n\t\tintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\n\t\tintent.putExtra(EXTRA_KEYWORD, keyword);\n\t\tactivity.startActivity(intent);\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/SettingsActivity.java",
    "content": "package moe.feng.nhentai.ui;\n\nimport android.app.Activity;\nimport android.app.Fragment;\nimport android.content.Intent;\nimport android.os.Bundle;\nimport android.support.v4.view.ViewCompat;\n\nimport moe.feng.nhentai.R;\nimport moe.feng.nhentai.ui.common.AbsActivity;\nimport moe.feng.nhentai.ui.fragment.settings.SettingsLicense;\nimport moe.feng.nhentai.ui.fragment.settings.SettingsMain;\n\npublic class SettingsActivity extends AbsActivity {\n\n\tprivate Fragment mFragment;\n\tprivate int flag;\n\n\tpublic static final String EXTRA_FLAG = \"flag\";\n\tpublic static final int FLAG_MAIN = 0, FLAG_LICENSE = 1, FLAG_GUI = 2, FLAG_NETWORK = 3;\n\n\t@Override\n\tpublic void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\n\t\tIntent intent = getIntent();\n\t\tflag = intent.getIntExtra(EXTRA_FLAG, FLAG_MAIN);\n\n\t\tsetContentView(R.layout.activity_settings);\n\n\t\tmActionBar.setDisplayHomeAsUpEnabled(true);\n\t}\n\n\t@Override\n\tpublic void setUpViews() {\n\t\tViewCompat.setElevation(mToolbar, getResources().getDimension(R.dimen.appbar_elevation));\n\n\t\tswitch (flag) {\n\t\t\tcase FLAG_MAIN:\n\t\t\t\tmFragment = new SettingsMain();\n\t\t\t\tbreak;\n\t\t\tcase FLAG_LICENSE:\n\t\t\t\tmFragment = new SettingsLicense();\n\t\t\t\tbreak;\n\t\t}\n\t\tgetFragmentManager().beginTransaction()\n\t\t\t\t.replace(R.id.container, mFragment)\n\t\t\t\t.commit();\n\t}\n\n\n\tpublic static void launchActivity(Activity mActivity, int flag) {\n\t\tIntent intent = new Intent(mActivity, SettingsActivity.class);\n\t\tintent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);\n\t\tintent.putExtra(EXTRA_FLAG, flag);\n\t\tmActivity.startActivity(intent);\n\t}\n\n}"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/adapter/BookListRecyclerAdapter.java",
    "content": "package moe.feng.nhentai.ui.adapter;\n\nimport android.graphics.Bitmap;\nimport android.support.v7.widget.ListPopupWindow;\nimport android.support.v7.widget.RecyclerView;\nimport android.text.TextUtils;\nimport android.util.Log;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\nimport android.view.ViewTreeObserver;\nimport android.widget.AdapterView;\nimport android.widget.ImageView;\nimport android.widget.TextView;\n\nimport java.util.ArrayList;\n\nimport moe.feng.nhentai.R;\nimport moe.feng.nhentai.api.BookApi;\nimport moe.feng.nhentai.model.Book;\nimport moe.feng.nhentai.ui.common.AbsRecyclerViewAdapter;\nimport moe.feng.nhentai.util.AsyncTask;\nimport moe.feng.nhentai.util.ColorGenerator;\nimport moe.feng.nhentai.util.TextDrawable;\nimport moe.feng.nhentai.util.Utility;\n\npublic class BookListRecyclerAdapter extends AbsRecyclerViewAdapter {\n\n\tprivate ArrayList<Book> data;\n\n\tprivate ColorGenerator mColorGenerator;\n\n\tpublic static final String TAG = BookListRecyclerAdapter.class.getSimpleName();\n\n\tpublic BookListRecyclerAdapter(RecyclerView recyclerView, ArrayList<Book> data) {\n\t\tsuper(recyclerView);\n\t\tthis.data = data;\n\t\tmColorGenerator = ColorGenerator.MATERIAL;\n\t}\n\n\t@Override\n\tpublic ClickableViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {\n\t\tbindContext(viewGroup.getContext());\n\t\tView view = LayoutInflater.from(getContext()).inflate(R.layout.list_item_book_card, viewGroup, false);\n\t\treturn new ViewHolder(view);\n\t}\n\t\n\t@Override\n\tpublic void onBindViewHolder(ClickableViewHolder holder, final int position) {\n\t\tsuper.onBindViewHolder(holder, position);\n\t\tif (holder instanceof ViewHolder) {\n\t\t\tfinal ViewHolder mHolder = (ViewHolder) holder;\n\t\t\tmHolder.mTitleTextView.setText(data.get(position).title);\n\t\t\tString previewImageUrl = data.get(position).previewImageUrl;\n\n\t\t\tint color = mColorGenerator.getColor(data.get(position).title);\n\t\t\tTextDrawable drawable = TextDrawable.builder().buildRect(Utility.getFirstCharacter(data.get(position).title), color);\n\t\t\tmHolder.mPreviewImageView.setImageDrawable(drawable);\n\n\t\t\tif (previewImageUrl != null) {\n\t\t\t\tswitch (previewImageUrl) {\n\t\t\t\t\tcase \"0\":\n\t\t\t\t\t\tmHolder.mPreviewImageView.setImageResource(R.drawable.holder_0);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"1\":\n\t\t\t\t\t\tmHolder.mPreviewImageView.setImageResource(R.drawable.holder_1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"2\":\n\t\t\t\t\t\tmHolder.mPreviewImageView.setImageResource(R.drawable.holder_2);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tViewTreeObserver vto = mHolder.mPreviewImageView.getViewTreeObserver();\n\t\t\t\t\t\tvto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {\n\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\tpublic void onGlobalLayout() {\n\t\t\t\t\t\t\t\tint thumbWidth = data.get(position).thumbWidth;\n\t\t\t\t\t\t\t\tint thumbHeight = data.get(position).thumbHeight;\n\t\t\t\t\t\t\t\tif (thumbWidth > 0 && thumbHeight > 0) {\n\t\t\t\t\t\t\t\t\tint width = mHolder.mPreviewImageView.getMeasuredWidth();\n\t\t\t\t\t\t\t\t\tint height = Math.round(width * ((float) thumbHeight / thumbWidth));\n\t\t\t\t\t\t\t\t\tmHolder.mPreviewImageView.getLayoutParams().height = height;\n\t\t\t\t\t\t\t\t\tmHolder.mPreviewImageView.setMinimumHeight(height);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tmHolder.mPreviewImageView.getViewTreeObserver().removeGlobalOnLayoutListener(this);\n\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tnew ImageDownloader().execute(mHolder.getParentView());\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tmHolder.book = data.get(position);\n\t\t}\n\t}\n\n\t@Override\n\tpublic int getItemCount() {\n\t\treturn data.size();\n\t}\n\n\tprivate class ImageDownloader extends AsyncTask<Object, Object, Void> {\n\n\t\t@Override\n\t\tprotected Void doInBackground(Object[] params) {\n\t\t\tView v = (View) params[0];\n\t\t\tViewHolder h = (ViewHolder) v.getTag();\n\t\t\tBook book = h.book;\n\n\t\t\tif (v != null && !TextUtils.isEmpty(book.previewImageUrl)) {\n\t\t\t\tImageView imgView = h.mPreviewImageView;\n\n\t\t\t\tBitmap img = BookApi.getThumb(getContext(), book);\n\n\t\t\t\tif (img != null) {\n\t\t\t\t\tpublishProgress(new Object[]{v, img, imgView, book});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn null;\n\t\t}\n\n\t\t@Override\n\t\tprotected void onProgressUpdate(Object[] values) {\n\t\t\tsuper.onProgressUpdate(values);\n\n\t\t\tView v = (View) values[0];\n\n\t\t\tif (!(v.getTag() instanceof ViewHolder) || (((ViewHolder) v.getTag()).book != null &&\n\t\t\t\t\t((ViewHolder) v.getTag()).book.bookId != ((Book) values[3]).bookId)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tBitmap img = (Bitmap) values[1];\n\t\t\tImageView iv = (ImageView) values[2];\n\t\t\tiv.setVisibility(View.VISIBLE);\n\t\t\tiv.setImageBitmap(img);\n\t\t\tiv.setTag(false);\n\t\t}\n\n\n\t}\n\n\tpublic class ViewHolder extends ClickableViewHolder {\n\n\t\tpublic ImageView mPreviewImageView;\n\t\tpublic TextView mTitleTextView;\n\n\t\tpublic Book book;\n\n\t\tpublic ViewHolder(View itemView) {\n\t\t\tsuper(itemView);\n\t\t\tmPreviewImageView = (ImageView) itemView.findViewById(R.id.book_preview);\n\t\t\tmTitleTextView = (TextView) itemView.findViewById(R.id.book_title);\n\n\t\t\titemView.setTag(this);\n\t\t}\n\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/adapter/BookPreviewGridAdapter.java",
    "content": "package moe.feng.nhentai.ui.adapter;\n\nimport android.content.Context;\nimport android.graphics.Bitmap;\nimport android.text.TextUtils;\nimport android.view.View;\nimport android.view.ViewGroup;\nimport android.widget.BaseAdapter;\nimport android.widget.GridView;\nimport android.widget.ImageView;\nimport android.widget.TextView;\n\nimport moe.feng.nhentai.R;\nimport moe.feng.nhentai.api.BookApi;\nimport moe.feng.nhentai.model.Book;\nimport moe.feng.nhentai.util.AsyncTask;\n\npublic class BookPreviewGridAdapter extends BaseAdapter {\n\n\tprivate Book book;\n\tprivate Context mContext;\n\n\tpublic BookPreviewGridAdapter(Context context, Book book) {\n\t\tsuper();\n\t\tthis.mContext = context;\n\t\tthis.book = book;\n\t}\n\n\t@Override\n\tpublic int getCount() {\n\t\treturn book.pageCount;\n\t}\n\n\t@Override\n\tpublic Object getItem(int i) {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic long getItemId(int i) {\n\t\treturn 0;\n\t}\n\n\t@Override\n\tpublic View getView(int position, View view, ViewGroup viewGroup) {\n\t\tViewHolder holder;\n\t\tif (view == null) {\n\t\t\tview = View.inflate(mContext, R.layout.list_item_book_picture_thumb, null);\n\n\t\t\tholder = new ViewHolder(view);\n\t\t\tview.setTag(holder);\n\t\t} else {\n\t\t\tholder = (ViewHolder) view.getTag();\n\t\t}\n\n\t\tholder.mImageView.setLayoutParams(new GridView.LayoutParams(300, 100));\n\t\tholder.mNumberText.setText(position);\n\n\t\tnew ImageDownloader().execute(holder.mImageView, position);\n\n\t\treturn view;\n\t}\n\n\tprivate class ViewHolder {\n\n\t\tView mParentView;\n\t\tImageView mImageView;\n\t\tTextView mNumberText;\n\n\t\tpublic ViewHolder(View itemView) {\n\t\t\tthis.mParentView = itemView;\n\t\t\tthis.mImageView = (ImageView) itemView.findViewById(R.id.image_view);\n\t\t\tthis.mNumberText = (TextView) itemView.findViewById(R.id.number_text);\n\t\t}\n\n\t}\n\n\tprivate class ImageDownloader extends AsyncTask<Object, Object, Void> {\n\n\t\t@Override\n\t\tprotected Void doInBackground(Object[] params) {\n\t\t\tView v = (View) params[0];\n\t\t\tViewHolder h = (ViewHolder) v.getTag();\n\n\t\t\tif (v != null && !TextUtils.isEmpty(book.previewImageUrl)) {\n\t\t\t\tImageView imgView = h.mImageView;\n\n\t\t\t\tBitmap img = BookApi.getPageThumb(mContext, book, (int) params[1]);\n\n\t\t\t\tif (img != null) {\n\t\t\t\t\tpublishProgress(new Object[]{v, img, imgView, book});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn null;\n\t\t}\n\n\t\t@Override\n\t\tprotected void onProgressUpdate(Object[] values) {\n\t\t\tsuper.onProgressUpdate(values);\n\n\t\t\tView v = (View) values[0];\n\n\t\t\tif (!(v.getTag() instanceof ViewHolder)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tBitmap img = (Bitmap) values[1];\n\t\t\tImageView iv = (ImageView) values[2];\n\t\t\tiv.setVisibility(View.VISIBLE);\n\t\t\tiv.setImageBitmap(img);\n\t\t\tiv.setTag(false);\n\t\t}\n\n\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/adapter/GalleryPagerAdapter.java",
    "content": "package moe.feng.nhentai.ui.adapter;\n\nimport android.app.Fragment;\nimport android.app.FragmentManager;\nimport android.support.v13.app.FragmentPagerAdapter;\n\nimport moe.feng.nhentai.model.Book;\nimport moe.feng.nhentai.ui.fragment.BookPageFragment;\n\npublic class GalleryPagerAdapter extends FragmentPagerAdapter {\n\n\tprivate Book book;\n\tprivate Fragment[] fragments;\n\n\tpublic GalleryPagerAdapter(FragmentManager fm, Book book) {\n\t\tsuper(fm);\n\t\tthis.book = book;\n\t\tthis.fragments = new Fragment[book.pageCount];\n\t}\n\n\t@Override\n\tpublic Fragment getItem(int position) {\n\t\tif (fragments[position] == null) {\n\t\t\tfragments[position] = BookPageFragment.newInstance(book, position + 1);\n\t\t}\n\t\treturn fragments[position];\n\t}\n\n\t@Override\n\tpublic int getCount() {\n\t\treturn book.pageCount;\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/adapter/HomePagerAdapter.java",
    "content": "package moe.feng.nhentai.ui.adapter;\n\nimport android.app.Fragment;\nimport android.app.FragmentManager;\nimport android.content.Context;\nimport android.support.v13.app.FragmentPagerAdapter;\n\nimport moe.feng.nhentai.R;\nimport moe.feng.nhentai.ui.fragment.main.DownloadManagerFragment;\nimport moe.feng.nhentai.ui.fragment.main.FavoriteFragment;\nimport moe.feng.nhentai.ui.fragment.main.HomeFragment;\n\npublic class HomePagerAdapter extends FragmentPagerAdapter {\n\n\tprivate HomeFragment homeFragment;\n\tprivate DownloadManagerFragment downloadManagerFragment;\n\tprivate FavoriteFragment favoriteFragment;\n\n\tprivate String[] titles;\n\n\tpublic HomePagerAdapter(Context context, FragmentManager fm) {\n\t\tsuper(fm);\n\t\ttitles = context.getResources().getStringArray(R.array.page_titles);\n\t\thomeFragment = new HomeFragment();\n\t\tdownloadManagerFragment = new DownloadManagerFragment();\n\t\tfavoriteFragment = new FavoriteFragment();\n\t}\n\n\t@Override\n\tpublic Fragment getItem(int position) {\n\t\tswitch (position) {\n\t\t\tcase 0:\n\t\t\t\treturn homeFragment;\n\t\t\tcase 1:\n\t\t\t\treturn downloadManagerFragment;\n\t\t\tcase 2:\n\t\t\t\treturn favoriteFragment;\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\t}\n\n\t@Override\n\tpublic int getCount() {\n\t\treturn 3;\n\t}\n\n\t@Override\n\tpublic CharSequence getPageTitle(int position) {\n\t\treturn titles[position];\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/common/AbsActivity.java",
    "content": "package moe.feng.nhentai.ui.common;\n\nimport android.graphics.Color;\nimport android.os.Build;\nimport android.os.Bundle;\nimport android.support.annotation.LayoutRes;\nimport android.support.v7.app.ActionBar;\nimport android.support.v7.app.AppCompatActivity;\nimport android.support.v7.widget.Toolbar;\nimport android.util.Log;\nimport android.view.MenuItem;\nimport android.view.View;\n\nimport moe.feng.nhentai.R;\nimport moe.feng.nhentai.util.Utility;\n\npublic abstract class AbsActivity extends AppCompatActivity {\n\n\tprotected Toolbar mToolbar;\n\tprotected ActionBar mActionBar;\n\n\tprotected int statusBarHeight = 0;\n\n\t@Override\n\tprotected void onCreate(Bundle savedInstanceState) {\n\t\tthis.onCreate(savedInstanceState, true);\n\t}\n\n\tprotected void onCreate(Bundle savedInstanceState, boolean statusBarTranslucent) {\n\t\t/** Set up translucent status bar */\n\t\tif (statusBarTranslucent) {\n\t\t\tif (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && !Utility.isChrome()) {\n\t\t\t\tgetWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);\n\t\t\t\tstatusBarHeight = Utility.getStatusBarHeight(getApplicationContext());\n\t\t\t}\n\n\t\t\tif (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {\n\t\t\t\tgetWindow().setStatusBarColor(Color.TRANSPARENT);\n\t\t\t\tgetWindow().setNavigationBarColor(getResources().getColor(R.color.deep_purple_800));\n\t\t\t}\n\t\t}\n\n\t\tsuper.onCreate(savedInstanceState);\n\t}\n\n\tprotected abstract void setUpViews();\n\n\t@Override\n\tpublic void setContentView(@LayoutRes int layoutResId) {\n\t\tsuper.setContentView(layoutResId);\n\n\t\ttry {\n\t\t\tView statusHeaderView = $(R.id.status_bar_header);\n\t\t\tstatusHeaderView.getLayoutParams().height = statusBarHeight;\n\t\t} catch (NullPointerException e) {\n\t\t\tLog.e(\"setContentView\", \"Cannot find status header.\");\n\t\t}\n\n\t\ttry {\n\t\t\tmToolbar = $(R.id.toolbar);\n\t\t\tsetSupportActionBar(mToolbar);\n\t\t} catch (Exception e) {\n\t\t\tLog.e(\"setContentView\", \"Cannot find toolbar.\");\n\t\t}\n\t\tmActionBar = getSupportActionBar();\n\n\t\tsetUpViews();\n\t}\n\n\t@Override\n\tpublic boolean onOptionsItemSelected(MenuItem item) {\n\t\tif (item.getItemId() == android.R.id.home) {\n\t\t\tthis.onBackPressed();\n\t\t\treturn true;\n\t\t}\n\n\t\treturn super.onOptionsItemSelected(item);\n\t}\n\n\tprotected <T extends View> T $(int id) {\n\t\treturn (T) findViewById(id);\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/common/AbsRecyclerViewAdapter.java",
    "content": "package moe.feng.nhentai.ui.common;\n\nimport android.content.Context;\nimport android.support.v7.widget.RecyclerView;\nimport android.view.View;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic abstract class AbsRecyclerViewAdapter extends RecyclerView.Adapter<AbsRecyclerViewAdapter.ClickableViewHolder> {\n\n\tprivate Context context;\n\n\tprotected RecyclerView mRecyclerView;\n\tprotected List<RecyclerView.OnScrollListener> mListeners = new ArrayList<RecyclerView.OnScrollListener>();\n\n\tpublic AbsRecyclerViewAdapter(RecyclerView recyclerView) {\n\t\tthis.mRecyclerView = recyclerView;\n\t\tthis.mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {\n\t\t\t@Override\n\t\t\tpublic void onScrollStateChanged(RecyclerView rv, int newState) {\n\t\t\t\tfor (RecyclerView.OnScrollListener listener : mListeners) {\n\t\t\t\t\tlistener.onScrollStateChanged(rv, newState);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void onScrolled(RecyclerView rv, int dx, int dy) {\n\t\t\t\tfor (RecyclerView.OnScrollListener listener : mListeners) {\n\t\t\t\t\tlistener.onScrolled(rv, dx, dy);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tpublic void addOnScrollListener(RecyclerView.OnScrollListener listener) {\n\t\tmListeners.add(listener);\n\t}\n\n\tpublic interface OnItemClickListener {\n\t\tpublic void onItemClick(int position, ClickableViewHolder holder);\n\t}\n\n\tpublic interface OnItemLongClickListener {\n\t\tpublic boolean onItemLongClick(int position, ClickableViewHolder holder);\n\t}\n\n\tprivate OnItemClickListener itemClickListener;\n\tprivate OnItemLongClickListener itemLongClickListener;\n\n\tpublic void setOnItemClickListener(OnItemClickListener listener) {\n\t\tthis.itemClickListener = listener;\n\t}\n\n\tpublic void setOnItemLongClickListener(OnItemLongClickListener listener) {\n\t\tthis.itemLongClickListener = listener;\n\t}\n\n\tpublic void bindContext(Context context) {\n\t\tthis.context = context;\n\t}\n\n\tpublic Context getContext() {\n\t\treturn this.context;\n\t}\n\n\t@Override\n\tpublic void onBindViewHolder(final ClickableViewHolder holder, final int position) {\n\t\tholder.getParentView().setOnClickListener(new View.OnClickListener() {\n\t\t\t@Override\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tif (itemClickListener != null) {\n\t\t\t\t\titemClickListener.onItemClick(position, holder);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tholder.getParentView().setOnLongClickListener(new View.OnLongClickListener() {\n\t\t\t@Override\n\t\t\tpublic boolean onLongClick(View v) {\n\t\t\t\tif (itemLongClickListener != null) {\n\t\t\t\t\treturn itemLongClickListener.onItemLongClick(position, holder);\n\t\t\t\t} else {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tpublic class ClickableViewHolder extends RecyclerView.ViewHolder {\n\n\t\tprivate View parentView;\n\n\t\tpublic ClickableViewHolder(View itemView) {\n\t\t\tsuper(itemView);\n\t\t\tthis.parentView = itemView;\n\t\t}\n\n\t\tpublic View getParentView() {\n\t\t\treturn parentView;\n\t\t}\n\n\t}\n\n}"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/fragment/BookPageFragment.java",
    "content": "package moe.feng.nhentai.ui.fragment;\n\nimport android.app.Fragment;\nimport android.graphics.Bitmap;\nimport android.graphics.PointF;\nimport android.os.Bundle;\nimport android.os.Handler;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\nimport android.widget.ImageView;\n\nimport com.github.florent37.materialimageloading.MaterialImageLoading;\nimport com.google.gson.Gson;\nimport com.squareup.picasso.Callback;\nimport com.squareup.picasso.Picasso;\n\nimport java.io.File;\n\nimport moe.feng.nhentai.R;\nimport moe.feng.nhentai.api.PageApi;\nimport moe.feng.nhentai.model.Book;\nimport moe.feng.nhentai.ui.GalleryActivity;\nimport moe.feng.nhentai.util.AsyncTask;\nimport uk.co.senab.photoview.PhotoViewAttacher;\n\npublic class BookPageFragment extends Fragment {\n\n\tprivate Book book;\n\tprivate int pageNum;\n\tprivate ImageView mImageView;\n\tprivate PhotoViewAttacher mPhotoViewAttacher;\n\n\tprivate static final String ARG_BOOK_DATA = \"arg_book_data\", ARG_PAGE_NUM = \"arg_page_num\";\n\n\tpublic static final String TAG = BookPageFragment.class.getSimpleName();\n\n\tpublic static BookPageFragment newInstance(Book book, int pageNum) {\n\t\tBookPageFragment fragment = new BookPageFragment();\n\t\tBundle data = new Bundle();\n\t\tdata.putString(ARG_BOOK_DATA, book.toJSONString());\n\t\tdata.putInt(ARG_PAGE_NUM, pageNum);\n\t\tfragment.setArguments(data);\n\t\treturn fragment;\n\t}\n\n\t@Override\n\tpublic void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\t\tBundle data = getArguments();\n\t\tbook = new Gson().fromJson(data.getString(ARG_BOOK_DATA), Book.class);\n\t\tpageNum = data.getInt(ARG_PAGE_NUM);\n\t}\n\n\t@Override\n\tpublic View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) {\n\t\tView view = inflater.inflate(R.layout.fragment_book_page, container, false);\n\n\t\tmImageView = (ImageView) view.findViewById(R.id.image_view);\n\t\tmPhotoViewAttacher = new PhotoViewAttacher(mImageView);\n\t\tnew DownloadTask().execute();\n\n\t\treturn view;\n\t}\n\n\tprivate class DownloadTask extends AsyncTask<Void, Void, File> {\n\n\t\t@Override\n\t\tprotected File doInBackground(Void... params) {\n\t\t\treturn PageApi.getPageOriginImageFile(getActivity().getApplicationContext(), book, pageNum);\n\t\t}\n\n\t\t@Override\n\t\tprotected void onPostExecute(File result) {\n\t\t\tsuper.onPostExecute(result);\n\n\t\t\tif (result != null) {\n\t\t\t\tPicasso.with(getActivity().getApplicationContext())\n\t\t\t\t\t\t.load(result)\n\t\t\t\t\t\t.into(mImageView, new Callback() {\n\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\tpublic void onSuccess() {\n\t\t\t\t\t\t\t\tMaterialImageLoading.animate(mImageView).setDuration(700).start();\n\t\t\t\t\t\t\t\tmPhotoViewAttacher.update();\n\t\t\t\t\t\t\t\tmPhotoViewAttacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {\n\t\t\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\t\t\tpublic void onViewTap(View view, float v, float v1) {\n\t\t\t\t\t\t\t\t\t\t((GalleryActivity) getActivity()).toggleControlBar();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\tpublic void onError() {\n\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/fragment/main/DownloadManagerFragment.java",
    "content": "package moe.feng.nhentai.ui.fragment.main;\n\nimport android.app.Fragment;\nimport android.os.Bundle;\nimport android.support.v7.widget.RecyclerView;\nimport android.support.v7.widget.StaggeredGridLayoutManager;\nimport android.util.Log;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\n\nimport java.util.ArrayList;\n\nimport moe.feng.nhentai.R;\nimport moe.feng.nhentai.model.Book;\nimport moe.feng.nhentai.ui.BookDetailsActivity;\nimport moe.feng.nhentai.ui.adapter.BookListRecyclerAdapter;\nimport moe.feng.nhentai.ui.common.AbsRecyclerViewAdapter;\n\npublic class DownloadManagerFragment extends Fragment {\n\n\tprivate RecyclerView mRecyclerView;\n\tprivate BookListRecyclerAdapter mAdapter;\n\n\tpublic static final String TAG = DownloadManagerFragment.class.getSimpleName();\n\n\t@Override\n\tpublic View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) {\n\t\tView view = inflater.inflate(R.layout.fragment_home, container, false);\n\n\t\tmRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);\n\t\tmRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));\n\t\tmRecyclerView.setHasFixedSize(false);\n\n\t\tArrayList<Book> books = new ArrayList<>();\n\n\t\tmAdapter = new BookListRecyclerAdapter(mRecyclerView, books);\n\t\tmAdapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {\n\t\t\t@Override\n\t\t\tpublic void onItemClick(int position, AbsRecyclerViewAdapter.ClickableViewHolder viewHolder) {\n\t\t\t\tif (viewHolder instanceof BookListRecyclerAdapter.ViewHolder) {\n\t\t\t\t\tBookListRecyclerAdapter.ViewHolder holder = (BookListRecyclerAdapter.ViewHolder) viewHolder;\n\t\t\t\t\tLog.i(TAG, \"You clicked position no.\" + position + \" item, \" +\n\t\t\t\t\t\t\t\"its name is \" + holder.mTitleTextView.getText().toString());\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tsetRecyclerViewAdapter(mAdapter);\n\n\t\treturn view;\n\t}\n\n\n\tprivate void setRecyclerViewAdapter(BookListRecyclerAdapter adapter) {\n\t\tmRecyclerView.setAdapter(mAdapter);\n\t\tmAdapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {\n\t\t\t@Override\n\t\t\tpublic void onItemClick(int position, AbsRecyclerViewAdapter.ClickableViewHolder viewHolder) {\n\t\t\t\tBookListRecyclerAdapter.ViewHolder holder = (BookListRecyclerAdapter.ViewHolder) viewHolder;\n\t\t\t\tLog.i(TAG, \"You clicked position no.\" + position + \" item, \" +\n\t\t\t\t\t\t\"its name is \" + holder.mTitleTextView.getText().toString());\n\t\t\t\tBookDetailsActivity.launch(getActivity(), holder.mPreviewImageView, holder.book);\n\t\t\t}\n\t\t});\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/fragment/main/FavoriteFragment.java",
    "content": "package moe.feng.nhentai.ui.fragment.main;\n\nimport android.app.Fragment;\nimport android.os.Bundle;\nimport android.support.v7.widget.RecyclerView;\nimport android.support.v7.widget.StaggeredGridLayoutManager;\nimport android.util.Log;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\n\nimport java.util.ArrayList;\n\nimport moe.feng.nhentai.R;\nimport moe.feng.nhentai.model.Book;\nimport moe.feng.nhentai.ui.BookDetailsActivity;\nimport moe.feng.nhentai.ui.adapter.BookListRecyclerAdapter;\nimport moe.feng.nhentai.ui.common.AbsRecyclerViewAdapter;\n\npublic class FavoriteFragment extends Fragment {\n\n\tprivate RecyclerView mRecyclerView;\n\tprivate BookListRecyclerAdapter mAdapter;\n\n\tpublic static final String TAG = FavoriteFragment.class.getSimpleName();\n\n\t@Override\n\tpublic View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) {\n\t\tView view = inflater.inflate(R.layout.fragment_home, container, false);\n\n\t\tmRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);\n\t\tmRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));\n\t\tmRecyclerView.setHasFixedSize(false);\n\n\t\tArrayList<Book> books = new ArrayList<>();\n\n\t\tmAdapter = new BookListRecyclerAdapter(mRecyclerView, books);\n\t\tmAdapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {\n\t\t\t@Override\n\t\t\tpublic void onItemClick(int position, AbsRecyclerViewAdapter.ClickableViewHolder viewHolder) {\n\t\t\t\tif (viewHolder instanceof BookListRecyclerAdapter.ViewHolder) {\n\t\t\t\t\tBookListRecyclerAdapter.ViewHolder holder = (BookListRecyclerAdapter.ViewHolder) viewHolder;\n\t\t\t\t\tLog.i(TAG, \"You clicked position no.\" + position + \" item, \" +\n\t\t\t\t\t\t\t\"its name is \" + holder.mTitleTextView.getText().toString());\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tsetRecyclerViewAdapter(mAdapter);\n\n\t\treturn view;\n\t}\n\n\n\tprivate void setRecyclerViewAdapter(BookListRecyclerAdapter adapter) {\n\t\tmRecyclerView.setAdapter(mAdapter);\n\t\tmAdapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {\n\t\t\t@Override\n\t\t\tpublic void onItemClick(int position, AbsRecyclerViewAdapter.ClickableViewHolder viewHolder) {\n\t\t\t\tBookListRecyclerAdapter.ViewHolder holder = (BookListRecyclerAdapter.ViewHolder) viewHolder;\n\t\t\t\tLog.i(TAG, \"You clicked position no.\" + position + \" item, \" +\n\t\t\t\t\t\t\"its name is \" + holder.mTitleTextView.getText().toString());\n\t\t\t\tBookDetailsActivity.launch(getActivity(), holder.mPreviewImageView, holder.book);\n\t\t\t}\n\t\t});\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/fragment/main/HomeFragment.java",
    "content": "package moe.feng.nhentai.ui.fragment.main;\n\nimport android.app.Fragment;\nimport android.os.Bundle;\nimport android.support.design.widget.Snackbar;\nimport android.support.v4.widget.SwipeRefreshLayout;\nimport android.support.v7.widget.RecyclerView;\nimport android.support.v7.widget.StaggeredGridLayoutManager;\nimport android.util.Log;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\n\nimport java.util.ArrayList;\n\nimport moe.feng.nhentai.R;\nimport moe.feng.nhentai.api.PageApi;\nimport moe.feng.nhentai.model.BaseMessage;\nimport moe.feng.nhentai.model.Book;\nimport moe.feng.nhentai.ui.BookDetailsActivity;\nimport moe.feng.nhentai.ui.adapter.BookListRecyclerAdapter;\nimport moe.feng.nhentai.ui.common.AbsRecyclerViewAdapter;\nimport moe.feng.nhentai.util.AsyncTask;\n\npublic class HomeFragment extends Fragment {\n\n\tprivate RecyclerView mRecyclerView;\n\tprivate BookListRecyclerAdapter mAdapter;\n\tprivate StaggeredGridLayoutManager mLayoutManager;\n\n\tprivate SwipeRefreshLayout mSwipeRefreshLayout;\n\n\tprivate ArrayList<Book> mBooks;\n\n\tprivate int mNowPage = 1;\n\n\tpublic static final String TAG = HomeFragment.class.getSimpleName();\n\n\t@Override\n\tpublic View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) {\n\t\tView view = inflater.inflate(R.layout.fragment_home, container, false);\n\n\t\tmSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_layout);\n\t\tmRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);\n\t\tmLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);\n\t\tmRecyclerView.setLayoutManager(mLayoutManager);\n\t\tmRecyclerView.setHasFixedSize(true);\n\n\t\tmBooks = new ArrayList<>();\n\t\tmAdapter = new BookListRecyclerAdapter(mRecyclerView, mBooks);\n\t\tsetRecyclerViewAdapter(mAdapter);\n\n\t\tmSwipeRefreshLayout.setColorSchemeResources(\n\t\t\t\tR.color.deep_purple_500, R.color.pink_500, R.color.orange_500, R.color.brown_500,\n\t\t\t\tR.color.indigo_500, R.color.blue_500, R.color.teal_500, R.color.green_500\n\t\t);\n\t\tmSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {\n\t\t\t@Override\n\t\t\tpublic void onRefresh() {\n\t\t\t\tif (!mSwipeRefreshLayout.isRefreshing()) {\n\t\t\t\t\tmSwipeRefreshLayout.setRefreshing(true);\n\t\t\t\t}\n\n\t\t\t\tmBooks = new ArrayList<>();\n\t\t\t\tmAdapter = new BookListRecyclerAdapter(mRecyclerView, mBooks);\n\t\t\t\tsetRecyclerViewAdapter(mAdapter);\n\t\t\t\tnew PageGetTask().execute(mNowPage = 1);\n\t\t\t}\n\t\t});\n\n\t\tnew PageGetTask().execute(mNowPage);\n\n\t\treturn view;\n\t}\n\n\tprivate void setRecyclerViewAdapter(BookListRecyclerAdapter adapter) {\n\t\tadapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {\n\t\t\t@Override\n\t\t\tpublic void onItemClick(int position, AbsRecyclerViewAdapter.ClickableViewHolder viewHolder) {\n\t\t\t\tBookListRecyclerAdapter.ViewHolder holder = (BookListRecyclerAdapter.ViewHolder) viewHolder;\n\t\t\t\tLog.i(TAG, \"You clicked position no.\" + position + \" item, \" +\n\t\t\t\t\t\t\"its name is \" + holder.mTitleTextView.getText().toString());\n\t\t\t\tBookDetailsActivity.launch(getActivity(), holder.mPreviewImageView, holder.book);\n\t\t\t}\n\t\t});\n\t\tadapter.addOnScrollListener(new RecyclerView.OnScrollListener() {\n\t\t\t@Override\n\t\t\tpublic void onScrolled(RecyclerView rv, int dx, int dy) {\n\t\t\t\tif (!mSwipeRefreshLayout.isRefreshing() && mLayoutManager.findLastCompletelyVisibleItemPositions(new int[2])[1] >= mAdapter.getItemCount() - 2) {\n\t\t\t\t\tmSwipeRefreshLayout.setRefreshing(true);\n\t\t\t\t\tnew PageGetTask().execute(++mNowPage);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tmRecyclerView.setAdapter(adapter);\n\t}\n\n\tprivate class PageGetTask extends AsyncTask<Integer, Void, BaseMessage> {\n\n\t\t@Override\n\t\tprotected BaseMessage doInBackground(Integer... params) {\n\t\t\treturn PageApi.getHomePageList(params[0]);\n\t\t}\n\n\t\t@Override\n\t\tprotected void onPostExecute(BaseMessage msg) {\n\t\t\tmSwipeRefreshLayout.setRefreshing(false);\n\t\t\tif (msg != null) {\n\t\t\t\tif (msg.getCode() == 0 && msg.getData() != null) {\n\t\t\t\t\tif (!((ArrayList<Book>) msg.getData()).isEmpty()) {\n\t\t\t\t\t\tmBooks.addAll((ArrayList<Book>) msg.getData());\n\t\t\t\t\t\tmAdapter.notifyDataSetChanged();\n\t\t\t\t\t}\n\t\t\t\t} else if (mNowPage == 1) {\n\t\t\t\t\tSnackbar.make(\n\t\t\t\t\t\t\tmRecyclerView,\n\t\t\t\t\t\t\tR.string.tips_network_error,\n\t\t\t\t\t\t\tSnackbar.LENGTH_LONG\n\t\t\t\t\t).setAction(\n\t\t\t\t\t\t\tR.string.snack_action_try_again,\n\t\t\t\t\t\t\tnew View.OnClickListener() {\n\t\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\t\tpublic void onClick(View view) {\n\t\t\t\t\t\t\t\t\tmSwipeRefreshLayout.setRefreshing(true);\n\t\t\t\t\t\t\t\t\tnew PageGetTask().execute(mNowPage);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t).show();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/fragment/settings/SettingsLicense.java",
    "content": "package moe.feng.nhentai.ui.fragment.settings;\n\nimport android.app.Fragment;\nimport android.os.Bundle;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\nimport android.webkit.WebView;\n\nimport moe.feng.nhentai.R;\n\npublic class SettingsLicense extends Fragment {\n\n\t@Override\n\tpublic View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle bundle) {\n\t\tWebView webView = new WebView(inflater.getContext());\n\t\twebView.loadUrl(\"file:///android_asset/licenses.html\");\n\n\t\tgetActivity().setTitle(R.string.settings_license);\n\n\t\treturn webView;\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/fragment/settings/SettingsMain.java",
    "content": "package moe.feng.nhentai.ui.fragment.settings;\n\nimport android.content.Intent;\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.preference.PreferenceFragment;\n\nimport moe.feng.nhentai.R;\nimport moe.feng.nhentai.ui.SettingsActivity;\nimport moe.feng.nhentai.view.pref.Preference;\n\npublic class SettingsMain extends PreferenceFragment implements Preference.OnPreferenceClickListener {\n\n\tprivate Preference mVersionPref;\n\tprivate Preference mLicensePref;\n\tprivate Preference mWeiboPref;\n\tprivate Preference mGooglePlusPref;\n\tprivate Preference mGithubPref;\n\n\t@Override\n\tpublic void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\t\taddPreferencesFromResource(R.xml.settings_main);\n\n\t\tmVersionPref = (Preference) findPreference(\"version\");\n\t\tmLicensePref = (Preference) findPreference(\"license\");\n\t\tmWeiboPref = (Preference) findPreference(\"weibo\");\n\t\tmGooglePlusPref = (Preference) findPreference(\"google_plus\");\n\t\tmGithubPref = (Preference) findPreference(\"github\");\n\n\t\tString version = \"Unknown\";\n\t\ttry {\n\t\t\tversion = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName;\n\t\t\tversion += \" (\" + getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionCode + \")\";\n\t\t} catch (Exception e) {\n\n\t\t}\n\t\tmVersionPref.setSummary(version);\n\n\t\tmLicensePref.setOnPreferenceClickListener(this);\n\t\tmWeiboPref.setOnPreferenceClickListener(this);\n\t\tmGooglePlusPref.setOnPreferenceClickListener(this);\n\t\tmGithubPref.setOnPreferenceClickListener(this);\n\t}\n\n\t@Override\n\tpublic boolean onPreferenceClick(android.preference.Preference pref) {\n\t\tif (pref == mLicensePref) {\n\t\t\tSettingsActivity.launchActivity(getActivity(), SettingsActivity.FLAG_LICENSE);\n\t\t\treturn true;\n\t\t}\n\t\tif (pref == mWeiboPref) {\n\t\t\topenWebUrl(\"http://weibo.com/fython\");\n\t\t\treturn true;\n\t\t}\n\t\tif (pref == mGooglePlusPref) {\n\t\t\topenWebUrl(\"https://plus.google.com/+FungJichun\");\n\t\t\treturn true;\n\t\t}\n\t\tif (pref == mGithubPref) {\n\t\t\topenWebUrl(getString(R.string.set_title_github_website));\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate void openWebUrl(String url) {\n\t\tUri uri = Uri.parse(url);\n\t\tstartActivity(new Intent(Intent.ACTION_VIEW, uri));\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/util/AsyncTask.java",
    "content": "package moe.feng.nhentai.util;\n\n\nimport android.os.Handler;\nimport android.os.Message;\nimport android.util.Log;\n\nimport static moe.feng.nhentai.BuildConfig.DEBUG;\n\n/*\n Real AsyncTask\n */\n\npublic abstract class AsyncTask<Params, Progress, Result>\n{\n\tprivate static final String TAG = AsyncTask.class.getSimpleName();\n\n\tprivate static class AsyncResult<Data> {\n\t\tpublic AsyncTask task;\n\t\tpublic Data[] data;\n\n\t\tpublic AsyncResult(AsyncTask task, Data... data) {\n\t\t\tthis.task = task;\n\t\t\tthis.data = data;\n\t\t}\n\t}\n\n\tprivate static final int MSG_FINISH = 1000;\n\tprivate static final int MSG_PROGRESS = 1001;\n\n\tprivate static Handler sInternalHandler = new Handler() {\n\t\t@SuppressWarnings({\"unchecked\", \"RawUseOfParameterizedType\"})\n\t\t@Override\n\t\tpublic void handleMessage(Message msg) {\n\t\t\tAsyncResult result = (AsyncResult) msg.obj;\n\t\t\tswitch (msg.what) {\n\t\t\t\tcase MSG_FINISH:\n\t\t\t\t\tresult.task.onPostExecute(result.data[0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase MSG_PROGRESS:\n\t\t\t\t\tresult.task.onProgressUpdate(result.data);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate Params[] mParams;\n\n\tprivate Thread mThread = new Thread(new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\t// TODO: CrashHandler.register();\n\n\t\t\t\ttry {\n\t\t\t\t\tResult result = doInBackground(mParams);\n\t\t\t\t\tsInternalHandler.sendMessage(sInternalHandler.obtainMessage(MSG_FINISH, new AsyncResult<Result>(AsyncTask.this, result)));\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t// Don't crash the whole app\n\t\t\t\t\tif (DEBUG) {\n\t\t\t\t\t\tLog.d(TAG, e.getClass().getSimpleName() + \" caught when running background task. Printing stack trace.\");\n\t\t\t\t\t\tLog.d(TAG, Log.getStackTraceString(e));\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tThread.currentThread().interrupt();\n\t\t\t}\n\t\t});\n\n\tprotected void onPostExecute(Result result) {}\n\n\tprotected abstract Result doInBackground(Params... params);\n\n\tprotected void onPreExecute() {}\n\n\tprotected void onProgressUpdate(Progress... progress) {}\n\n\tprotected void publishProgress(Progress... progress) {\n\t\tsInternalHandler.sendMessage(sInternalHandler.obtainMessage(MSG_PROGRESS, new AsyncResult<Progress>(this, progress)));\n\t}\n\n\tpublic void execute(Params... params) {\n\t\tonPreExecute();\n\t\tmParams = params;\n\t\tmThread.start();\n\t}\n}\n\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/util/ColorGenerator.java",
    "content": "package moe.feng.nhentai.util;\n\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Random;\n\n/**\n * @author amulya\n * @datetime 14 Oct 2014, 5:20 PM\n */\npublic class ColorGenerator {\n\n\tpublic static ColorGenerator DEFAULT;\n\n\tpublic static ColorGenerator MATERIAL;\n\n\tstatic {\n\t\tDEFAULT = create(Arrays.asList(\n\t\t\t\t0xfff16364,\n\t\t\t\t0xfff58559,\n\t\t\t\t0xfff9a43e,\n\t\t\t\t0xffe4c62e,\n\t\t\t\t0xff67bf74,\n\t\t\t\t0xff59a2be,\n\t\t\t\t0xff2093cd,\n\t\t\t\t0xffad62a7,\n\t\t\t\t0xff805781\n\t\t));\n\t\tMATERIAL = create(Arrays.asList(\n\t\t\t\t0xffe57373,\n\t\t\t\t0xfff06292,\n\t\t\t\t0xffba68c8,\n\t\t\t\t0xff9575cd,\n\t\t\t\t0xff7986cb,\n\t\t\t\t0xff64b5f6,\n\t\t\t\t0xff4fc3f7,\n\t\t\t\t0xff4dd0e1,\n\t\t\t\t0xff4db6ac,\n\t\t\t\t0xff81c784,\n\t\t\t\t0xffaed581,\n\t\t\t\t0xffff8a65,\n\t\t\t\t0xffd4e157,\n\t\t\t\t0xffffd54f,\n\t\t\t\t0xffffb74d,\n\t\t\t\t0xffa1887f,\n\t\t\t\t0xff90a4ae\n\t\t));\n\t}\n\n\tprivate final List<Integer> mColors;\n\tprivate final Random mRandom;\n\n\tpublic static ColorGenerator create(List<Integer> colorList) {\n\t\treturn new ColorGenerator(colorList);\n\t}\n\n\tprivate ColorGenerator(List<Integer> colorList) {\n\t\tmColors = colorList;\n\t\tmRandom = new Random(System.currentTimeMillis());\n\t}\n\n\tpublic int getRandomColor() {\n\t\treturn mColors.get(mRandom.nextInt(mColors.size()));\n\t}\n\n\tpublic int getColor(Object key) {\n\t\treturn mColors.get(Math.abs(key.hashCode()) % mColors.size());\n\t}\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/util/FullScreenHelper.java",
    "content": "package moe.feng.nhentai.util;\n\nimport android.annotation.SuppressLint;\nimport android.app.Activity;\nimport android.os.Build;\nimport android.view.View;\nimport android.view.ViewConfiguration;\nimport android.view.Window;\nimport android.view.WindowManager;\n\n@SuppressLint(\"InlinedApi\")\npublic final class FullScreenHelper implements View.OnSystemUiVisibilityChangeListener {\n\n\tprivate static final String TAG = FullScreenHelper.class.getSimpleName();\n\n\tprivate final int NOT_FULL_SCREEN_JELLY_BEAN =\n\t\t\tView.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |\n\t\t\t\t\tView.SYSTEM_UI_FLAG_LAYOUT_STABLE;\n\n\tprivate final int FULL_SCREEN_JELLY_BEAN =\n\t\t\tNOT_FULL_SCREEN_JELLY_BEAN |\n\t\t\t\t\tView.SYSTEM_UI_FLAG_LOW_PROFILE |\n\t\t\t\t\tView.SYSTEM_UI_FLAG_FULLSCREEN;\n\n\tprivate final int FULL_SCREEN_FLAG_JELLY_BEAN =\n\t\t\tView.SYSTEM_UI_FLAG_LOW_PROFILE |\n\t\t\t\t\tView.SYSTEM_UI_FLAG_FULLSCREEN;\n\n\tprivate final int NOT_FULL_SCREEN_KITKAT =\n\t\t\tNOT_FULL_SCREEN_JELLY_BEAN |\n\t\t\t\t\tView.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;\n\n\tprivate final int FULL_SCREEN_KITKAT =\n\t\t\tNOT_FULL_SCREEN_KITKAT |\n\t\t\t\t\tView.SYSTEM_UI_FLAG_LOW_PROFILE |\n\t\t\t\t\tView.SYSTEM_UI_FLAG_FULLSCREEN |\n\t\t\t\t\tView.SYSTEM_UI_FLAG_HIDE_NAVIGATION |\n\t\t\t\t\tView.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;\n\n\tprivate boolean mFullScreen;\n\tprivate final Activity mActivity;\n\tprivate final Window mWindow;\n\tprivate final View mDecorView;\n\n\tprivate boolean mHasNavBar;\n\n\tprivate OnFullScreenBrokenListener mListener;\n\n\tprivate final int TEST_SDK = Build.VERSION.SDK_INT;\n\n\tpublic interface OnFullScreenBrokenListener {\n\n\t\t/**\n\t\t * FullScreen state should be fullScreen or not,\n\t\t * but user or system broke it\n\t\t *\n\t\t * @param fullScreen support to be\n\t\t */\n\t\tpublic void onFullScreenBroken(boolean fullScreen);\n\n\t}\n\n\tpublic FullScreenHelper(Activity activity) {\n\t\tmFullScreen = false;\n\t\tmActivity = activity;\n\t\tmWindow = mActivity.getWindow();\n\t\tmDecorView = mWindow.getDecorView();\n\t\tmDecorView.setOnSystemUiVisibilityChangeListener(this);\n\n\t\tString mainKey = Utility.getSystemProperties(\"qemu.hw.mainkeys\");\n\t\tint resourceId = activity.getResources().getIdentifier(\"config_showNavigationBar\", \"bool\", \"android\");\n\t\tif (resourceId != 0) {\n\t\t\tmHasNavBar = activity.getResources().getBoolean(resourceId);\n\t\t\t// check override flag (see static block)\n\t\t\tif (\"1\".equals(mainKey)) {\n\t\t\t\tmHasNavBar = false;\n\t\t\t} else if (\"0\".equals(mainKey)) {\n\t\t\t\tmHasNavBar = true;\n\t\t\t}\n\t\t} else {\n\t\t\tmHasNavBar = !ViewConfiguration.get(activity).hasPermanentMenuKey();\n\t\t}\n\t}\n\n\tpublic boolean willHideNavBar() {\n\t\tif (TEST_SDK >= Build.VERSION_CODES.KITKAT && mHasNavBar)\n\t\t\treturn true;\n\t\telse\n\t\t\treturn false;\n\t}\n\n\t@Override\n\tpublic void onSystemUiVisibilityChange(int visibility) {\n\t\tif (TEST_SDK >= Build.VERSION_CODES.JELLY_BEAN &&\n\t\t\t\tTEST_SDK < Build.VERSION_CODES.KITKAT) {\n\t\t\tif ((mFullScreen && visibility != FULL_SCREEN_FLAG_JELLY_BEAN) ||\n\t\t\t\t\t(!mFullScreen && visibility != 0)) {\n\t\t\t\t// User or system change visibility\n\t\t\t\tif (mListener != null)\n\t\t\t\t\tmListener.onFullScreenBroken(mFullScreen);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic void setOnFullScreenBrokenListener(OnFullScreenBrokenListener l) {\n\t\tmListener = l;\n\t}\n\n\tpublic boolean getFullScreen() {\n\t\treturn mFullScreen;\n\t}\n\n\tpublic void setFullScreen(boolean fullScreen) {\n\t\tmFullScreen = fullScreen;\n\t\tif (fullScreen) {\n\t\t\tif (TEST_SDK < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {\n\t\t\t\t// Empty\n\t\t\t} else if (TEST_SDK < Build.VERSION_CODES.JELLY_BEAN) {\n\t\t\t\tmWindow.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,\n\t\t\t\t\t\tWindowManager.LayoutParams.FLAG_FULLSCREEN);\n\n\t\t\t} else if (TEST_SDK < Build.VERSION_CODES.KITKAT) {\n\t\t\t\tmDecorView.setSystemUiVisibility(FULL_SCREEN_JELLY_BEAN);\n\n\t\t\t} else {\n\t\t\t\tmDecorView.setSystemUiVisibility(FULL_SCREEN_KITKAT);\n\t\t\t}\n\t\t} else {\n\t\t\tif (TEST_SDK < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {\n\t\t\t\t// Empty\n\t\t\t} else if (TEST_SDK < Build.VERSION_CODES.JELLY_BEAN) {\n\t\t\t\tmWindow.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);\n\n\t\t\t} else if (TEST_SDK < Build.VERSION_CODES.KITKAT) {\n\t\t\t\tmDecorView.setSystemUiVisibility(NOT_FULL_SCREEN_JELLY_BEAN);\n\n\t\t\t} else {\n\t\t\t\tmDecorView.setSystemUiVisibility(NOT_FULL_SCREEN_KITKAT);\n\t\t\t}\n\t\t}\n\t}\n\n}"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/util/HttpTools.java",
    "content": "package moe.feng.nhentai.util;\n\nimport java.io.IOException;\nimport java.net.HttpURLConnection;\nimport java.net.URL;\nimport java.net.URLEncoder;\n\npublic class HttpTools {\n\n\tpublic static HttpURLConnection openConnection(String url) throws IOException {\n\t\tURL u = new URL(url);\n\t\tHttpURLConnection conn = (HttpURLConnection) u.openConnection();\n\t\tconn.setConnectTimeout(5000);\n\t\tconn.setRequestMethod(\"GET\");\n\t\tconn.setRequestProperty(\"Accept-Encoding\", \"identity\");\n\t\tconn.setRequestProperty(\"Referer\", URLEncoder.encode(url, \"UTF-8\"));\n\t\tconn.setRequestProperty(\"Charset\", \"UTF-8\");\n\t\tconn.setRequestProperty(\"Connection\", \"Keep-Alive\");\n\t\treturn conn;\n\t}\n\n\tpublic static long getTargetContentSize(String url) throws IOException {\n\t\tHttpURLConnection conn = openConnection(url);\n\t\tif (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {\n\t\t\treturn conn.getContentLength();\n\t\t}\n\t\treturn -1;\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/util/Settings.java",
    "content": "package moe.feng.nhentai.util;\n\nimport android.content.Context;\n\nimport moe.feng.nhentai.dao.CommonPreferences;\n\npublic class Settings {\n\n\tpublic static final String PREFERENCES_NAME = \"settings\";\n\n\tprivate static Settings sInstance;\n\n\tprivate CommonPreferences mPrefs;\n\n\tpublic static Settings getInstance(Context context) {\n\t\tif (sInstance == null) {\n\t\t\tsInstance = new Settings(context);\n\t\t}\n\t\treturn sInstance;\n\t}\n\n\tprivate Settings(Context context) {\n\t\tmPrefs = CommonPreferences.getInstance(context, PREFERENCES_NAME);\n\t}\n\n\tpublic Settings putBoolean(String key, boolean value) {\n\t\tmPrefs.edit().putBoolean(key, value).commit();\n\t\treturn this;\n\t}\n\n\tpublic boolean getBoolean(String key, boolean def) {\n\t\treturn mPrefs.getBoolean(key, def);\n\t}\n\n\tpublic Settings putInt(String key, int value) {\n\t\tmPrefs.edit().putInt(key, value).commit();\n\t\treturn this;\n\t}\n\n\tpublic int getInt(String key, int defValue) {\n\t\treturn mPrefs.getInt(key, defValue);\n\t}\n\n\n\tpublic Settings putString(String key, String value) {\n\t\tmPrefs.edit().putString(key, value).commit();\n\t\treturn this;\n\t}\n\n\tpublic String getString(String key, String defValue) {\n\t\treturn mPrefs.getString(key, defValue);\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/util/TextDrawable.java",
    "content": "package moe.feng.nhentai.util;\n\nimport android.graphics.*;\nimport android.graphics.drawable.ShapeDrawable;\nimport android.graphics.drawable.shapes.OvalShape;\nimport android.graphics.drawable.shapes.RectShape;\nimport android.graphics.drawable.shapes.RoundRectShape;\n\n/**\n * @author amulya\n * @datetime 14 Oct 2014, 3:53 PM\n */\npublic class TextDrawable extends ShapeDrawable {\n\n\tprivate final Paint textPaint;\n\tprivate final Paint borderPaint;\n\tprivate static final float SHADE_FACTOR = 0.9f;\n\tprivate final String text;\n\tprivate final int color;\n\tprivate final RectShape shape;\n\tprivate final int height;\n\tprivate final int width;\n\tprivate final int fontSize;\n\tprivate final float radius;\n\tprivate final int borderThickness;\n\n\tprivate TextDrawable(Builder builder) {\n\t\tsuper(builder.shape);\n\n\t\t// shape properties\n\t\tshape = builder.shape;\n\t\theight = builder.height;\n\t\twidth = builder.width;\n\t\tradius = builder.radius;\n\n\t\t// text and color\n\t\ttext = builder.toUpperCase ? builder.text.toUpperCase() : builder.text;\n\t\tcolor = builder.color;\n\n\t\t// text paint settings\n\t\tfontSize = builder.fontSize;\n\t\ttextPaint = new Paint();\n\t\ttextPaint.setColor(builder.textColor);\n\t\ttextPaint.setAntiAlias(true);\n\t\ttextPaint.setFakeBoldText(builder.isBold);\n\t\ttextPaint.setStyle(Paint.Style.FILL);\n\t\ttextPaint.setTypeface(builder.font);\n\t\ttextPaint.setTextAlign(Paint.Align.CENTER);\n\t\ttextPaint.setStrokeWidth(builder.borderThickness);\n\n\t\t// border paint settings\n\t\tborderThickness = builder.borderThickness;\n\t\tborderPaint = new Paint();\n\t\tborderPaint.setColor(getDarkerShade(color));\n\t\tborderPaint.setStyle(Paint.Style.STROKE);\n\t\tborderPaint.setStrokeWidth(borderThickness);\n\n\t\t// drawable paint color\n\t\tPaint paint = getPaint();\n\t\tpaint.setColor(color);\n\n\t}\n\n\tprivate int getDarkerShade(int color) {\n\t\treturn Color.rgb((int)(SHADE_FACTOR * Color.red(color)),\n\t\t\t\t(int)(SHADE_FACTOR * Color.green(color)),\n\t\t\t\t(int)(SHADE_FACTOR * Color.blue(color)));\n\t}\n\n\t@Override\n\tpublic void draw(Canvas canvas) {\n\t\tsuper.draw(canvas);\n\t\tRect r = getBounds();\n\n\n\t\t// draw border\n\t\tif (borderThickness > 0) {\n\t\t\tdrawBorder(canvas);\n\t\t}\n\n\t\tint count = canvas.save();\n\t\tcanvas.translate(r.left, r.top);\n\n\t\t// draw text\n\t\tint width = this.width < 0 ? r.width() : this.width;\n\t\tint height = this.height < 0 ? r.height() : this.height;\n\t\tint fontSize = this.fontSize < 0 ? (Math.min(width, height) / 2) : this.fontSize;\n\t\ttextPaint.setTextSize(fontSize);\n\t\tcanvas.drawText(text, width / 2, height / 2 - ((textPaint.descent() + textPaint.ascent()) / 2), textPaint);\n\n\t\tcanvas.restoreToCount(count);\n\n\t}\n\n\tprivate void drawBorder(Canvas canvas) {\n\t\tRectF rect = new RectF(getBounds());\n\t\trect.inset(borderThickness/2, borderThickness/2);\n\n\t\tif (shape instanceof OvalShape) {\n\t\t\tcanvas.drawOval(rect, borderPaint);\n\t\t}\n\t\telse if (shape instanceof RoundRectShape) {\n\t\t\tcanvas.drawRoundRect(rect, radius, radius, borderPaint);\n\t\t}\n\t\telse {\n\t\t\tcanvas.drawRect(rect, borderPaint);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void setAlpha(int alpha) {\n\t\ttextPaint.setAlpha(alpha);\n\t}\n\n\t@Override\n\tpublic void setColorFilter(ColorFilter cf) {\n\t\ttextPaint.setColorFilter(cf);\n\t}\n\n\t@Override\n\tpublic int getOpacity() {\n\t\treturn PixelFormat.TRANSLUCENT;\n\t}\n\n\t@Override\n\tpublic int getIntrinsicWidth() {\n\t\treturn width;\n\t}\n\n\t@Override\n\tpublic int getIntrinsicHeight() {\n\t\treturn height;\n\t}\n\n\tpublic static IShapeBuilder builder() {\n\t\treturn new Builder();\n\t}\n\n\tpublic static class Builder implements IConfigBuilder, IShapeBuilder, IBuilder {\n\n\t\tprivate String text;\n\n\t\tprivate int color;\n\n\t\tprivate int borderThickness;\n\n\t\tprivate int width;\n\n\t\tprivate int height;\n\n\t\tprivate Typeface font;\n\n\t\tprivate RectShape shape;\n\n\t\tpublic int textColor;\n\n\t\tprivate int fontSize;\n\n\t\tprivate boolean isBold;\n\n\t\tprivate boolean toUpperCase;\n\n\t\tpublic float radius;\n\n\t\tprivate Builder() {\n\t\t\ttext = \"\";\n\t\t\tcolor = Color.GRAY;\n\t\t\ttextColor = Color.WHITE;\n\t\t\tborderThickness = 0;\n\t\t\twidth = -1;\n\t\t\theight = -1;\n\t\t\tshape = new RectShape();\n\t\t\tfont = Typeface.create(\"sans-serif-light\", Typeface.NORMAL);\n\t\t\tfontSize = -1;\n\t\t\tisBold = false;\n\t\t\ttoUpperCase = false;\n\t\t}\n\n\t\tpublic IConfigBuilder width(int width) {\n\t\t\tthis.width = width;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic IConfigBuilder height(int height) {\n\t\t\tthis.height = height;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic IConfigBuilder textColor(int color) {\n\t\t\tthis.textColor = color;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic IConfigBuilder withBorder(int thickness) {\n\t\t\tthis.borderThickness = thickness;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic IConfigBuilder useFont(Typeface font) {\n\t\t\tthis.font = font;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic IConfigBuilder fontSize(int size) {\n\t\t\tthis.fontSize = size;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic IConfigBuilder bold() {\n\t\t\tthis.isBold = true;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic IConfigBuilder toUpperCase() {\n\t\t\tthis.toUpperCase = true;\n\t\t\treturn this;\n\t\t}\n\n\t\t@Override\n\t\tpublic IConfigBuilder beginConfig() {\n\t\t\treturn this;\n\t\t}\n\n\t\t@Override\n\t\tpublic IShapeBuilder endConfig() {\n\t\t\treturn this;\n\t\t}\n\n\t\t@Override\n\t\tpublic IBuilder rect() {\n\t\t\tthis.shape = new RectShape();\n\t\t\treturn this;\n\t\t}\n\n\t\t@Override\n\t\tpublic IBuilder round() {\n\t\t\tthis.shape = new OvalShape();\n\t\t\treturn this;\n\t\t}\n\n\t\t@Override\n\t\tpublic IBuilder roundRect(int radius) {\n\t\t\tthis.radius = radius;\n\t\t\tfloat[] radii = {radius, radius, radius, radius, radius, radius, radius, radius};\n\t\t\tthis.shape = new RoundRectShape(radii, null, null);\n\t\t\treturn this;\n\t\t}\n\n\t\t@Override\n\t\tpublic TextDrawable buildRect(String text, int color) {\n\t\t\trect();\n\t\t\treturn build(text, color);\n\t\t}\n\n\t\t@Override\n\t\tpublic TextDrawable buildRoundRect(String text, int color, int radius) {\n\t\t\troundRect(radius);\n\t\t\treturn build(text, color);\n\t\t}\n\n\t\t@Override\n\t\tpublic TextDrawable buildRound(String text, int color) {\n\t\t\tround();\n\t\t\treturn build(text, color);\n\t\t}\n\n\t\t@Override\n\t\tpublic TextDrawable build(String text, int color) {\n\t\t\tthis.color = color;\n\t\t\tthis.text = text;\n\t\t\treturn new TextDrawable(this);\n\t\t}\n\t}\n\n\tpublic interface IConfigBuilder {\n\t\tpublic IConfigBuilder width(int width);\n\n\t\tpublic IConfigBuilder height(int height);\n\n\t\tpublic IConfigBuilder textColor(int color);\n\n\t\tpublic IConfigBuilder withBorder(int thickness);\n\n\t\tpublic IConfigBuilder useFont(Typeface font);\n\n\t\tpublic IConfigBuilder fontSize(int size);\n\n\t\tpublic IConfigBuilder bold();\n\n\t\tpublic IConfigBuilder toUpperCase();\n\n\t\tpublic IShapeBuilder endConfig();\n\t}\n\n\tpublic static interface IBuilder {\n\n\t\tpublic TextDrawable build(String text, int color);\n\t}\n\n\tpublic static interface IShapeBuilder {\n\n\t\tpublic IConfigBuilder beginConfig();\n\n\t\tpublic IBuilder rect();\n\n\t\tpublic IBuilder round();\n\n\t\tpublic IBuilder roundRect(int radius);\n\n\t\tpublic TextDrawable buildRect(String text, int color);\n\n\t\tpublic TextDrawable buildRoundRect(String text, int color, int radius);\n\n\t\tpublic TextDrawable buildRound(String text, int color);\n\t}\n}"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/util/Utility.java",
    "content": "package moe.feng.nhentai.util;\n\nimport android.content.Context;\nimport android.os.Build;\n\nimport java.lang.reflect.Method;\n\npublic class Utility {\n\n\tpublic static boolean isChrome() {\n\t\treturn Build.BRAND.equals(\"chromium\") || Build.BRAND.equals(\"chrome\");\n\t}\n\n\tpublic static int getStatusBarHeight(Context context) {\n\t\tint result = 0;\n\t\tint resourceId = context.getResources().getIdentifier(\"status_bar_height\", \"dimen\", \"android\");\n\t\tif (resourceId > 0) {\n\t\t\tresult = context.getResources().getDimensionPixelSize(resourceId);\n\t\t}\n\t\treturn result;\n\t}\n\n\tpublic static String getFirstCharacter(String sentence) {\n\t\tfor (int i = 0; i < sentence.length(); i++) {\n\t\t\tString s = sentence.substring(i, i+1);\n\t\t\tif (s.equals(\"[\") || s.equals(\"]\")) continue;\n\t\t\tif (s.equals(\"{\") || s.equals(\"}\")) continue;\n\t\t\tif (s.equals(\"(\") || s.equals(\")\")) continue;\n\t\t\tif (s.equals(\",\") || s.equals(\".\")) continue;\n\t\t\tif (s.equals(\"<\") || s.equals(\">\")) continue;\n\t\t\tif (s.equals(\"《\") || s.equals(\"》\")) continue;\n\t\t\tif (s.equals(\"【\") || s.equals(\"】\")) continue;\n\t\t\tif (s.equals(\"｛\") || s.equals(\"｝\")) continue;\n\t\t\treturn s;\n\t\t}\n\t\treturn null;\n\t}\n\n\tpublic static String getSystemProperties(String key) {\n\t\ttry {\n\t\t\tClass c = Class.forName(\"android.os.SystemProperties\");\n\t\t\tMethod m = c.getDeclaredMethod(\"get\", String.class);\n\t\t\tm.setAccessible(true);\n\t\t\treturn (String) m.invoke(null, key);\n\t\t} catch (Throwable e) {\n\t\t\treturn \"\";\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/view/AutoWrapLayout.java",
    "content": "package moe.feng.nhentai.view;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport android.annotation.SuppressLint;\nimport android.content.Context;\nimport android.content.res.TypedArray;\nimport android.graphics.Rect;\nimport android.util.AttributeSet;\nimport android.view.View;\nimport android.view.ViewGroup;\n\nimport moe.feng.nhentai.R;\n\n/**\n * A ViewGroup that can layout views in line and auto wrap\n *\n * @author Hippo\n *\n */\npublic class AutoWrapLayout extends ViewGroup {\n\t@SuppressWarnings(\"unused\")\n\tprivate final static String TAG = \"AutoWrapLayout\";\n\tprivate final List<Rect> rectList = new ArrayList<Rect>();\n\n\tprivate Alignment mAlignment;\n\n\tprivate static final Alignment[] sBaseLineArray = { Alignment.TOP,\n\t\t\tAlignment.CENTER, Alignment.BOTTOM };\n\n\n\tpublic enum Alignment {\n\t\tTOP(0),\n\t\tCENTER(1),\n\t\tBOTTOM(2);\n\n\t\tAlignment(int ni) {\n\t\t\tnativeInt = ni;\n\t\t}\n\n\t\tfinal int nativeInt;\n\t}\n\n\tpublic AutoWrapLayout(Context context) {\n\t\tsuper(context);\n\t}\n\tpublic AutoWrapLayout(Context context, AttributeSet attrs) {\n\t\tthis(context, attrs, 0);\n\t}\n\tpublic AutoWrapLayout(Context context, AttributeSet attrs, int defStyle) {\n\t\tsuper(context, attrs, defStyle);\n\n\t\tTypedArray a = context.obtainStyledAttributes(attrs,\n\t\t\t\tR.styleable.AutoWrapLayout, defStyle, 0);\n\n\t\tint index = a.getInt(R.styleable.AutoWrapLayout_alignment, -1);\n\t\tif (index >= 0)\n\t\t\tsetAlignment(sBaseLineArray[index]);\n\n\t\ta.recycle();\n\t}\n\n\tpublic void setAlignment(Alignment baseLine) {\n\t\tif (baseLine == null)\n\t\t\treturn;\n\n\t\tif (mAlignment != baseLine) {\n\t\t\tmAlignment = baseLine;\n\n\t\t\trequestLayout();\n\t\t\tinvalidate();\n\t\t}\n\t}\n\n\tpublic Alignment getScaleType() {\n\t\treturn mAlignment;\n\t}\n\n\tprivate void adjustBaseLine(int lineHeight, int startIndex, int endIndex) {\n\t\tif (mAlignment == Alignment.TOP)\n\t\t\treturn;\n\n\t\tfor (int index = startIndex; index < endIndex; index++) {\n\t\t\tfinal View child = getChildAt(index);\n\t\t\tfinal AutoWrapLayout.LayoutParams lp =\n\t\t\t\t\t(AutoWrapLayout.LayoutParams)child.getLayoutParams();\n\t\t\tRect rect = rectList.get(index);\n\t\t\tint offsetRaw = lineHeight - rect.height() - lp.topMargin - lp.bottomMargin;\n\t\t\tif (mAlignment == Alignment.CENTER)\n\t\t\t\trect.offset(0, offsetRaw/2);\n\t\t\telse if (mAlignment == Alignment.BOTTOM)\n\t\t\t\trect.offset(0, offsetRaw);\n\t\t}\n\t}\n\n\n\t// TODO Take vertical mode\n\t/**\n\t * each row or line at least show one child\n\t *\n\t * horizontal only show child can show or partly show in parent\n\t */\n\t@SuppressLint(\"DrawAllocation\")\n\t@Override\n\tprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {\n\t\tint widthMode = MeasureSpec.getMode(widthMeasureSpec);\n\t\tint heightMode = MeasureSpec.getMode(heightMeasureSpec);\n\n\t\tint maxWidth = MeasureSpec.getSize(widthMeasureSpec);\n\t\tint maxHeight = MeasureSpec.getSize(heightMeasureSpec);\n\n\t\tif (widthMode == MeasureSpec.UNSPECIFIED)\n\t\t\tmaxWidth = Integer.MAX_VALUE;\n\t\tif (heightMode == MeasureSpec.UNSPECIFIED)\n\t\t\tmaxHeight = Integer.MAX_VALUE;\n\n\t\tint paddingLeft = getPaddingLeft();\n\t\tint paddingTop = getPaddingTop();\n\t\tint paddingRight = getPaddingRight();\n\t\tint paddingBottom = getPaddingBottom();\n\n\t\tint maxRightBound = maxWidth - paddingRight;\n\t\tint maxBottomBound = maxHeight - paddingBottom;\n\n\t\tint left;\n\t\tint top;\n\t\tint right;\n\t\tint bottom;\n\t\tint rightBound = paddingLeft;\n\t\tint maxRightNoPadding = rightBound;\n\t\tint bottomBound;\n\t\tint lastMaxBottom = paddingTop;\n\t\tint maxBottom = lastMaxBottom;\n\t\tint childWidth;\n\t\tint childHeight;\n\n\t\tint lineStartIndex = 0;\n\t\tint lineEndIndex = 0; // endIndex + 1\n\n\t\trectList.clear();\n\t\tint childCount = getChildCount();\n\t\tfor (int index = 0; index < childCount; index++) {\n\t\t\tfinal View child = getChildAt(index);\n\t\t\tchild.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);\n\t\t\tif (child.getVisibility() == View.GONE)\n\t\t\t\tcontinue;\n\t\t\tfinal AutoWrapLayout.LayoutParams lp =\n\t\t\t\t\t(AutoWrapLayout.LayoutParams)child.getLayoutParams();\n\t\t\tchildWidth = child.getMeasuredWidth();\n\t\t\tchildHeight = child.getMeasuredHeight();\n\n\t\t\tleft = rightBound + lp.leftMargin;\n\t\t\tright = left + childWidth;\n\t\t\trightBound = right + lp.rightMargin;\n\t\t\tif (rightBound > maxRightBound) { // Go to next row\n\t\t\t\tlineEndIndex = index;\n\t\t\t\t// Adjust child position base on baseline\n\t\t\t\tadjustBaseLine(maxBottom - lastMaxBottom, lineStartIndex, lineEndIndex);\n\n\t\t\t\t// If child can't show in parent begin this line\n\t\t\t\tif (maxBottom >= maxBottomBound)\n\t\t\t\t\tbreak;\n\n\t\t\t\t// If it is first item in line, try to show it all\n\t\t\t\tif (lineEndIndex == lineStartIndex) {\n\t\t\t\t\tchild.measure(MeasureSpec.makeMeasureSpec(\n\t\t\t\t\t\t\t\t\tmaxWidth - paddingLeft - paddingRight\n\t\t\t\t\t\t\t\t\t\t\t- lp.leftMargin - lp.rightMargin, MeasureSpec.AT_MOST),\n\t\t\t\t\t\t\tMeasureSpec.UNSPECIFIED);\n\t\t\t\t\tchildWidth = child.getMeasuredWidth();\n\t\t\t\t\tchildHeight = child.getMeasuredHeight();\n\t\t\t\t}\n\t\t\t\tleft = paddingLeft + lp.leftMargin;\n\t\t\t\tright = left + childWidth;\n\t\t\t\trightBound = right + lp.rightMargin;\n\n\t\t\t\tlastMaxBottom = maxBottom;\n\t\t\t\ttop = lastMaxBottom + lp.topMargin;\n\t\t\t\tbottom = top + childHeight;\n\t\t\t\tbottomBound = bottom + lp.bottomMargin;\n\n\t\t\t\tlineStartIndex = index;\n\t\t\t} else {\n\t\t\t\ttop = lastMaxBottom + lp.topMargin;\n\t\t\t\tbottom = top + childHeight;\n\t\t\t\tbottomBound = bottom + lp.bottomMargin;\n\t\t\t}\n\t\t\t// Update max\n\t\t\tif (rightBound > maxRightNoPadding)\n\t\t\t\tmaxRightNoPadding = rightBound;\n\t\t\tif (bottomBound > maxBottom)\n\t\t\t\tmaxBottom = bottomBound;\n\t\t\tRect rect = new Rect();\n\t\t\trect.left = left;\n\t\t\trect.top = top;\n\t\t\trect.right = right;\n\t\t\trect.bottom = bottom;\n\t\t\trectList.add(rect);\n\t\t}\n\n\t\t// Handle last line baseline\n\t\tadjustBaseLine(maxBottom - lastMaxBottom, lineStartIndex, rectList.size());\n\n\t\tint measuredWidth;\n\t\tint measuredHeight;\n\n\t\tif (widthMode == MeasureSpec.EXACTLY)\n\t\t\tmeasuredWidth = maxWidth;\n\t\telse\n\t\t\tmeasuredWidth = maxRightNoPadding + paddingRight;\n\t\tif (heightMode == MeasureSpec.EXACTLY)\n\t\t\tmeasuredHeight = maxHeight;\n\t\telse {\n\t\t\tmeasuredHeight = maxBottom + paddingBottom;\n\t\t\tif (heightMode == MeasureSpec.AT_MOST)\n\t\t\t\tmeasuredHeight = measuredHeight > maxHeight ? maxHeight : measuredHeight;\n\t\t}\n\n\t\tsetMeasuredDimension(measuredWidth, measuredHeight);\n\t}\n\n\t@Override\n\tprotected void onLayout(boolean changed, int l, int t, int r, int b) {\n\t\tfinal int count = rectList.size();\n\t\tfor(int i = 0; i < count; i++){\n\t\t\tfinal View child = this.getChildAt(i);\n\t\t\tif (child.getVisibility() == View.GONE)\n\t\t\t\tcontinue;\n\t\t\tRect rect = rectList.get(i);\n\t\t\tchild.layout(rect.left, rect.top, rect.right, rect.bottom);\n\t\t}\n\t}\n\n\t@Override\n\tpublic LayoutParams generateLayoutParams(AttributeSet attrs) {\n\t\treturn new AutoWrapLayout.LayoutParams(getContext(), attrs);\n\t}\n\n\t@Override\n\tprotected LayoutParams generateDefaultLayoutParams() {\n\t\treturn new AutoWrapLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);\n\t}\n\n\t@Override\n\tprotected LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {\n\t\treturn new LayoutParams(p);\n\t}\n\n\tpublic static class LayoutParams extends ViewGroup.MarginLayoutParams {\n\t\tpublic LayoutParams() {\n\t\t\tthis(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);\n\t\t}\n\t\tpublic LayoutParams(Context c, AttributeSet attrs) {\n\t\t\tsuper(c, attrs);\n\t\t}\n\t\tpublic LayoutParams(int width, int height) {\n\t\t\tsuper(width, height);\n\t\t}\n\t\tpublic LayoutParams(android.view.ViewGroup.LayoutParams source) {\n\t\t\tsuper(source);\n\t\t}\n\t\tpublic LayoutParams(MarginLayoutParams source) {\n\t\t\tsuper(source);\n\t\t}\n\t}\n}"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/view/ExpandableHeightGridView.java",
    "content": "package moe.feng.nhentai.view;\n\nimport android.content.Context;\nimport android.util.AttributeSet;\nimport android.view.ViewGroup;\nimport android.widget.GridView;\n\npublic class ExpandableHeightGridView extends GridView {\n\n\tprivate boolean expanded = false;\n\n\tpublic ExpandableHeightGridView(Context context) {\n\t\tsuper(context);\n\t}\n\n\tpublic ExpandableHeightGridView(Context context, AttributeSet attrs) {\n\t\tsuper(context, attrs);\n\t}\n\n\tpublic ExpandableHeightGridView(Context context, AttributeSet attrs, int defStyle) {\n\t\tsuper(context, attrs, defStyle);\n\t}\n\n\tpublic boolean isExpanded() {\n\t\treturn expanded;\n\t}\n\n\t@Override\n\tpublic void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {\n\t\tif (isExpanded()) {\n\t\t\tint expandSpec = MeasureSpec.makeMeasureSpec(\n\t\t\t\t\tInteger.MAX_VALUE >> 2, MeasureSpec.AT_MOST);\n\t\t\tsuper.onMeasure(widthMeasureSpec, expandSpec);\n\n\t\t\tViewGroup.LayoutParams params = getLayoutParams();\n\t\t\tparams.height = getMeasuredHeight();\n\t\t} else {\n\t\t\tsuper.onMeasure(widthMeasureSpec, heightMeasureSpec);\n\t\t}\n\t}\n\n\tpublic void setExpanded(boolean expanded) {\n\t\tthis.expanded = expanded;\n\t}\n\n}"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/view/WheelProgressView.java",
    "content": "package moe.feng.nhentai.view;\n\nimport android.content.Context;\nimport android.content.res.TypedArray;\nimport android.graphics.Canvas;\nimport android.graphics.Paint;\nimport android.graphics.Paint.Style;\nimport android.graphics.RectF;\nimport android.os.Parcel;\nimport android.os.Parcelable;\nimport android.os.SystemClock;\nimport android.support.annotation.NonNull;\nimport android.util.AttributeSet;\nimport android.util.DisplayMetrics;\nimport android.util.TypedValue;\nimport android.view.View;\n\nimport moe.feng.nhentai.R;\n\n/**\n * A Material style progress wheel, compatible up to 2.2.\n * Todd Davies' Progress Wheel https://github.com/Todd-Davies/ProgressWheel\n *\n * @author Nico Hormazabal\n *         <p/>\n *         Licensed under the Apache License 2.0 license see:\n *         http://www.apache.org/licenses/LICENSE-2.0\n */\npublic class WheelProgressView extends View {\n\n\tprivate static final String TAG = WheelProgressView.class.getSimpleName();\n\n\tprivate int circleRadius = 28;\n\tprivate int barWidth = 4;\n\tprivate int rimWidth = 4;\n\n\tprivate final int barLength = 16;\n\tprivate final int barMaxLength = 270;\n\n\tprivate boolean fillRadius = false;\n\n\tprivate double timeStartGrowing = 0;\n\tprivate double barSpinCycleTime = 460;\n\tprivate float barExtraLength = 0;\n\tprivate boolean barGrowingFromFront = true;\n\n\tprivate long pausedTimeWithoutGrowing = 0;\n\tprivate final long pauseGrowingTime = 200;\n\n\tprivate int barColor = 0xAA000000;\n\tprivate int rimColor = 0x00FFFFFF;\n\n\tprivate Paint barPaint = new Paint();\n\tprivate Paint rimPaint = new Paint();\n\n\tprivate RectF circleBounds = new RectF();\n\n\tprivate float spinSpeed = 230.0f;\n\tprivate long lastTimeAnimated = 0;\n\n\tprivate boolean linearProgress;\n\n\tprivate float mProgress = 0.0f;\n\tprivate float mTargetProgress = 0.0f;\n\tprivate boolean isSpinning = false;\n\n\tprivate ProgressCallback callback;\n\n\t/**\n\t * The constructor for the ProgressWheel\n\t *\n\t * @param context\n\t * @param attrs\n\t */\n\tpublic WheelProgressView(Context context, AttributeSet attrs) {\n\t\tsuper(context, attrs);\n\n\t\tparseAttributes(context.obtainStyledAttributes(attrs,\n\t\t\t\tR.styleable.WheelProgressView));\n\t}\n\n\t/**\n\t * The constructor for the ProgressWheel\n\t *\n\t * @param context\n\t */\n\tpublic WheelProgressView(Context context) {\n\t\tsuper(context);\n\t}\n\n\t@Override\n\tprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {\n\t\tsuper.onMeasure(widthMeasureSpec, heightMeasureSpec);\n\n\t\tint viewWidth = circleRadius + this.getPaddingLeft() + this.getPaddingRight();\n\t\tint viewHeight = circleRadius + this.getPaddingTop() + this.getPaddingBottom();\n\n\t\tint widthMode = MeasureSpec.getMode(widthMeasureSpec);\n\t\tint widthSize = MeasureSpec.getSize(widthMeasureSpec);\n\t\tint heightMode = MeasureSpec.getMode(heightMeasureSpec);\n\t\tint heightSize = MeasureSpec.getSize(heightMeasureSpec);\n\n\t\tint width;\n\t\tint height;\n\n\t\tif (widthMode == MeasureSpec.EXACTLY) {\n\t\t\twidth = widthSize;\n\t\t} else if (widthMode == MeasureSpec.AT_MOST) {\n\t\t\twidth = Math.min(viewWidth, widthSize);\n\t\t} else {\n\t\t\twidth = viewWidth;\n\t\t}\n\n\t\tif (heightMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.EXACTLY) {\n\t\t\theight = heightSize;\n\t\t} else if (heightMode == MeasureSpec.AT_MOST) {\n\t\t\theight = Math.min(viewHeight, heightSize);\n\t\t} else {\n\t\t\theight = viewHeight;\n\t\t}\n\n\t\tsetMeasuredDimension(width, height);\n\t}\n\n\t/**\n\t * Use onSizeChanged instead of onAttachedToWindow to get the dimensions of the view,\n\t * because this method is called after measuring the dimensions of MATCH_PARENT & WRAP_CONTENT.\n\t * Use this dimensions to setup the bounds and paints.\n\t */\n\t@Override\n\tprotected void onSizeChanged(int w, int h, int oldw, int oldh) {\n\t\tsuper.onSizeChanged(w, h, oldw, oldh);\n\n\t\tsetupBounds(w, h);\n\t\tsetupPaints();\n\t\tinvalidate();\n\t}\n\n\t/**\n\t * Set the properties of the paints we're using to\n\t * draw the progress wheel\n\t */\n\tprivate void setupPaints() {\n\t\tbarPaint.setColor(barColor);\n\t\tbarPaint.setAntiAlias(true);\n\t\tbarPaint.setStyle(Style.STROKE);\n\t\tbarPaint.setStrokeWidth(barWidth);\n\n\t\trimPaint.setColor(rimColor);\n\t\trimPaint.setAntiAlias(true);\n\t\trimPaint.setStyle(Style.STROKE);\n\t\trimPaint.setStrokeWidth(rimWidth);\n\t}\n\n\t/**\n\t * Set the bounds of the component\n\t */\n\tprivate void setupBounds(int layout_width, int layout_height) {\n\t\tint paddingTop = getPaddingTop();\n\t\tint paddingBottom = getPaddingBottom();\n\t\tint paddingLeft = getPaddingLeft();\n\t\tint paddingRight = getPaddingRight();\n\n\t\tif (!fillRadius) {\n\t\t\tint minValue = Math.min(layout_width - paddingLeft - paddingRight,\n\t\t\t\t\tlayout_height - paddingBottom - paddingTop);\n\n\t\t\tint circleDiameter = Math.min(minValue, circleRadius * 2 - barWidth * 2);\n\n\t\t\tint xOffset = (layout_width - paddingLeft - paddingRight - circleDiameter) / 2 + paddingLeft;\n\t\t\tint yOffset = (layout_height - paddingTop - paddingBottom - circleDiameter) / 2 + paddingTop;\n\n\t\t\tcircleBounds = new RectF(xOffset + barWidth,\n\t\t\t\t\tyOffset + barWidth,\n\t\t\t\t\txOffset + circleDiameter - barWidth,\n\t\t\t\t\tyOffset + circleDiameter - barWidth);\n\t\t} else {\n\t\t\tcircleBounds = new RectF(paddingLeft + barWidth,\n\t\t\t\t\tpaddingTop + barWidth,\n\t\t\t\t\tlayout_width - paddingRight - barWidth,\n\t\t\t\t\tlayout_height - paddingBottom - barWidth);\n\t\t}\n\t}\n\n\t/**\n\t * Parse the attributes passed to the view from the XML\n\t *\n\t * @param a the attributes to parse\n\t */\n\tprivate void parseAttributes(TypedArray a) {\n\t\tDisplayMetrics metrics = getContext().getResources().getDisplayMetrics();\n\t\tbarWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, barWidth, metrics);\n\t\trimWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, rimWidth, metrics);\n\t\tcircleRadius = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, circleRadius, metrics);\n\n\t\tcircleRadius = (int) a.getDimension(R.styleable.WheelProgressView_matProg_circleRadius, circleRadius);\n\n\t\tfillRadius = a.getBoolean(R.styleable.WheelProgressView_matProg_fillRadius, false);\n\n\t\tbarWidth = (int) a.getDimension(R.styleable.WheelProgressView_matProg_barWidth, barWidth);\n\n\t\trimWidth = (int) a.getDimension(R.styleable.WheelProgressView_matProg_rimWidth, rimWidth);\n\n\t\tfloat baseSpinSpeed = a.getFloat(R.styleable.WheelProgressView_matProg_spinSpeed, spinSpeed / 360.0f);\n\t\tspinSpeed = baseSpinSpeed * 360;\n\n\t\tbarSpinCycleTime = a.getInt(R.styleable.WheelProgressView_matProg_barSpinCycleTime, (int) barSpinCycleTime);\n\n\t\tbarColor = a.getColor(R.styleable.WheelProgressView_matProg_barColor, barColor);\n\n\t\trimColor = a.getColor(R.styleable.WheelProgressView_matProg_rimColor, rimColor);\n\n\t\tlinearProgress = a.getBoolean(R.styleable.WheelProgressView_matProg_linearProgress, false);\n\n\t\tif (a.getBoolean(R.styleable.WheelProgressView_matProg_progressIndeterminate, false)) {\n\t\t\tspin();\n\t\t}\n\n\t\ta.recycle();\n\t}\n\n\tpublic void setCallback(ProgressCallback progressCallback) {\n\t\tcallback = progressCallback;\n\n\t\tif (!isSpinning) {\n\t\t\trunCallback();\n\t\t}\n\t}\n\n\tprotected void onDraw(Canvas canvas) {\n\t\tsuper.onDraw(canvas);\n\n\t\tcanvas.drawArc(circleBounds, 360, 360, false, rimPaint);\n\n\t\tboolean mustInvalidate = false;\n\n\t\tif (isSpinning) {\n\t\t\tmustInvalidate = true;\n\n\t\t\tlong deltaTime = (SystemClock.uptimeMillis() - lastTimeAnimated);\n\t\t\tfloat deltaNormalized = deltaTime * spinSpeed / 1000.0f;\n\n\t\t\tupdateBarLength(deltaTime);\n\n\t\t\tmProgress += deltaNormalized;\n\t\t\tif (mProgress > 360) {\n\t\t\t\tmProgress -= 360f;\n\n\t\t\t\trunCallback(-1.0f);\n\t\t\t}\n\t\t\tlastTimeAnimated = SystemClock.uptimeMillis();\n\n\t\t\tfloat from = mProgress - 90;\n\t\t\tfloat length = barLength + barExtraLength;\n\n\t\t\tif (isInEditMode()) {\n\t\t\t\tfrom = 0;\n\t\t\t\tlength = 135;\n\t\t\t}\n\n\t\t\tcanvas.drawArc(circleBounds, from, length, false,\n\t\t\t\t\tbarPaint);\n\t\t} else {\n\t\t\tfloat oldProgress = mProgress;\n\n\t\t\tif (mProgress != mTargetProgress) {\n\t\t\t\tmustInvalidate = true;\n\n\t\t\t\tfloat deltaTime = (float) (SystemClock.uptimeMillis() - lastTimeAnimated) / 1000;\n\t\t\t\tfloat deltaNormalized = deltaTime * spinSpeed;\n\n\t\t\t\tmProgress = Math.min(mProgress + deltaNormalized, mTargetProgress);\n\t\t\t\tlastTimeAnimated = SystemClock.uptimeMillis();\n\t\t\t}\n\n\t\t\tif (oldProgress != mProgress) {\n\t\t\t\trunCallback();\n\t\t\t}\n\n\t\t\tfloat offset = 0.0f;\n\t\t\tfloat progress = mProgress;\n\t\t\tif (!linearProgress) {\n\t\t\t\tfloat factor = 2.0f;\n\t\t\t\toffset = (float) (1.0f - Math.pow(1.0f - mProgress / 360.0f, 2.0f * factor)) * 360.0f;\n\t\t\t\tprogress = (float) (1.0f - Math.pow(1.0f - mProgress / 360.0f, factor)) * 360.0f;\n\t\t\t}\n\n\t\t\tif (isInEditMode()) {\n\t\t\t\tprogress = 360;\n\t\t\t}\n\n\t\t\tcanvas.drawArc(circleBounds, offset - 90, progress, false, barPaint);\n\t\t}\n\n\t\tif (mustInvalidate) {\n\t\t\tinvalidate();\n\t\t}\n\t}\n\n\t@Override\n\tprotected void onVisibilityChanged(@NonNull View changedView, int visibility) {\n\t\tsuper.onVisibilityChanged(changedView, visibility);\n\n\t\tif (visibility == VISIBLE) {\n\t\t\tlastTimeAnimated = SystemClock.uptimeMillis();\n\t\t}\n\t}\n\n\tprivate void updateBarLength(long deltaTimeInMilliSeconds) {\n\t\tif (pausedTimeWithoutGrowing >= pauseGrowingTime) {\n\t\t\ttimeStartGrowing += deltaTimeInMilliSeconds;\n\n\t\t\tif (timeStartGrowing > barSpinCycleTime) {\n\t\t\t\ttimeStartGrowing -= barSpinCycleTime;\n\t\t\t\tpausedTimeWithoutGrowing = 0;\n\t\t\t\tbarGrowingFromFront = !barGrowingFromFront;\n\t\t\t}\n\n\t\t\tfloat distance = (float) Math.cos((timeStartGrowing / barSpinCycleTime + 1) * Math.PI) / 2 + 0.5f;\n\t\t\tfloat destLength = (barMaxLength - barLength);\n\n\t\t\tif (barGrowingFromFront) {\n\t\t\t\tbarExtraLength = distance * destLength;\n\t\t\t} else {\n\t\t\t\tfloat newLength = destLength * (1 - distance);\n\t\t\t\tmProgress += (barExtraLength - newLength);\n\t\t\t\tbarExtraLength = newLength;\n\t\t\t}\n\t\t} else {\n\t\t\tpausedTimeWithoutGrowing += deltaTimeInMilliSeconds;\n\t\t}\n\t}\n\n\t/**\n\t * Check if the wheel is currently spinning\n\t */\n\n\tpublic boolean isSpinning() {\n\t\treturn isSpinning;\n\t}\n\n\t/**\n\t * Reset the count (in increment mode)\n\t */\n\tpublic void resetCount() {\n\t\tmProgress = 0.0f;\n\t\tmTargetProgress = 0.0f;\n\t\tinvalidate();\n\t}\n\n\t/**\n\t * Turn off spin mode\n\t */\n\tpublic void stopSpinning() {\n\t\tisSpinning = false;\n\t\tmProgress = 0.0f;\n\t\tmTargetProgress = 0.0f;\n\t\tinvalidate();\n\t}\n\n\t/**\n\t * Puts the view on spin mode\n\t */\n\tpublic void spin() {\n\t\tlastTimeAnimated = SystemClock.uptimeMillis();\n\t\tisSpinning = true;\n\t\tinvalidate();\n\t}\n\n\tprivate void runCallback(float value) {\n\t\tif (callback != null) {\n\t\t\tcallback.onProgressUpdate(value);\n\t\t}\n\t}\n\n\tprivate void runCallback() {\n\t\tif (callback != null) {\n\t\t\tfloat normalizedProgress = (float) Math.round(mProgress * 100 / 360.0f) / 100;\n\t\t\tcallback.onProgressUpdate(normalizedProgress);\n\t\t}\n\t}\n\n\t/**\n\t * Set the progress to a specific value,\n\t * the bar will smoothly animate until that value\n\t *\n\t * @param progress the progress between 0 and 1\n\t */\n\tpublic void setProgress(float progress) {\n\t\tif (isSpinning) {\n\t\t\tmProgress = 0.0f;\n\t\t\tisSpinning = false;\n\n\t\t\trunCallback();\n\t\t}\n\n\t\tif (progress > 1.0f) {\n\t\t\tprogress -= 1.0f;\n\t\t} else if (progress < 0) {\n\t\t\tprogress = 0;\n\t\t}\n\n\t\tif (progress == mTargetProgress) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (mProgress == mTargetProgress) {\n\t\t\tlastTimeAnimated = SystemClock.uptimeMillis();\n\t\t}\n\n\t\tmTargetProgress = Math.min(progress * 360.0f, 360.0f);\n\n\t\tinvalidate();\n\t}\n\n\t/**\n\t * Set the progress to a specific value,\n\t * the bar will be set instantly to that value\n\t *\n\t * @param progress the progress between 0 and 1\n\t */\n\tpublic void setInstantProgress(float progress) {\n\t\tif (isSpinning) {\n\t\t\tmProgress = 0.0f;\n\t\t\tisSpinning = false;\n\t\t}\n\n\t\tif (progress > 1.0f) {\n\t\t\tprogress -= 1.0f;\n\t\t} else if (progress < 0) {\n\t\t\tprogress = 0;\n\t\t}\n\n\t\tif (progress == mTargetProgress) {\n\t\t\treturn;\n\t\t}\n\n\t\tmTargetProgress = Math.min(progress * 360.0f, 360.0f);\n\t\tmProgress = mTargetProgress;\n\t\tlastTimeAnimated = SystemClock.uptimeMillis();\n\t\tinvalidate();\n\t}\n\n\t@Override\n\tpublic Parcelable onSaveInstanceState() {\n\t\tParcelable superState = super.onSaveInstanceState();\n\n\t\tWheelSavedState ss = new WheelSavedState(superState);\n\n\t\tss.mProgress = this.mProgress;\n\t\tss.mTargetProgress = this.mTargetProgress;\n\t\tss.isSpinning = this.isSpinning;\n\t\tss.spinSpeed = this.spinSpeed;\n\t\tss.barWidth = this.barWidth;\n\t\tss.barColor = this.barColor;\n\t\tss.rimWidth = this.rimWidth;\n\t\tss.rimColor = this.rimColor;\n\t\tss.circleRadius = this.circleRadius;\n\t\tss.linearProgress = this.linearProgress;\n\t\tss.fillRadius = this.fillRadius;\n\n\t\treturn ss;\n\t}\n\n\t@Override\n\tpublic void onRestoreInstanceState(Parcelable state) {\n\t\tif (!(state instanceof WheelSavedState)) {\n\t\t\tsuper.onRestoreInstanceState(state);\n\t\t\treturn;\n\t\t}\n\n\t\tWheelSavedState ss = (WheelSavedState) state;\n\t\tsuper.onRestoreInstanceState(ss.getSuperState());\n\n\t\tthis.mProgress = ss.mProgress;\n\t\tthis.mTargetProgress = ss.mTargetProgress;\n\t\tthis.isSpinning = ss.isSpinning;\n\t\tthis.spinSpeed = ss.spinSpeed;\n\t\tthis.barWidth = ss.barWidth;\n\t\tthis.barColor = ss.barColor;\n\t\tthis.rimWidth = ss.rimWidth;\n\t\tthis.rimColor = ss.rimColor;\n\t\tthis.circleRadius = ss.circleRadius;\n\t\tthis.linearProgress = ss.linearProgress;\n\t\tthis.fillRadius = ss.fillRadius;\n\n\t\tthis.lastTimeAnimated = SystemClock.uptimeMillis();\n\t}\n\n\t/**\n\t * @return the current progress between 0.0 and 1.0,\n\t * if the wheel is indeterminate, then the result is -1\n\t */\n\tpublic float getProgress() {\n\t\treturn isSpinning ? -1 : mProgress / 360.0f;\n\t}\n\n\t/**\n\t * Sets the determinate progress mode\n\t *\n\t * @param isLinear if the progress should increase linearly\n\t */\n\tpublic void setLinearProgress(boolean isLinear) {\n\t\tlinearProgress = isLinear;\n\t\tif (!isSpinning) {\n\t\t\tinvalidate();\n\t\t}\n\t}\n\n\t/**\n\t * @return the radius of the wheel in pixels\n\t */\n\tpublic int getCircleRadius() {\n\t\treturn circleRadius;\n\t}\n\n\t/**\n\t * Sets the radius of the wheel\n\t *\n\t * @param circleRadius the expected radius, in pixels\n\t */\n\tpublic void setCircleRadius(int circleRadius) {\n\t\tthis.circleRadius = circleRadius;\n\t\tif (!isSpinning) {\n\t\t\tinvalidate();\n\t\t}\n\t}\n\n\t/**\n\t * @return the width of the spinning bar\n\t */\n\tpublic int getBarWidth() {\n\t\treturn barWidth;\n\t}\n\n\t/**\n\t * Sets the width of the spinning bar\n\t *\n\t * @param barWidth the spinning bar width in pixels\n\t */\n\tpublic void setBarWidth(int barWidth) {\n\t\tthis.barWidth = barWidth;\n\t\tif (!isSpinning) {\n\t\t\tinvalidate();\n\t\t}\n\t}\n\n\t/**\n\t * @return the color of the spinning bar\n\t */\n\tpublic int getBarColor() {\n\t\treturn barColor;\n\t}\n\n\t/**\n\t * Sets the color of the spinning bar\n\t *\n\t * @param barColor The spinning bar color\n\t */\n\tpublic void setBarColor(int barColor) {\n\t\tthis.barColor = barColor;\n\t\tsetupPaints();\n\t\tif (!isSpinning) {\n\t\t\tinvalidate();\n\t\t}\n\t}\n\n\t/**\n\t * @return the color of the wheel's contour\n\t */\n\tpublic int getRimColor() {\n\t\treturn rimColor;\n\t}\n\n\t/**\n\t * Sets the color of the wheel's contour\n\t *\n\t * @param rimColor the color for the wheel\n\t */\n\tpublic void setRimColor(int rimColor) {\n\t\tthis.rimColor = rimColor;\n\t\tsetupPaints();\n\t\tif (!isSpinning) {\n\t\t\tinvalidate();\n\t\t}\n\t}\n\n\t/**\n\t * @return the base spinning speed, in full circle turns per second\n\t * (1.0 equals on full turn in one second), this value also is applied for\n\t * the smoothness when setting a progress\n\t */\n\tpublic float getSpinSpeed() {\n\t\treturn spinSpeed / 360.0f;\n\t}\n\n\t/**\n\t * Sets the base spinning speed, in full circle turns per second\n\t * (1.0 equals on full turn in one second), this value also is applied for\n\t * the smoothness when setting a progress\n\t *\n\t * @param spinSpeed the desired base speed in full turns per second\n\t */\n\tpublic void setSpinSpeed(float spinSpeed) {\n\t\tthis.spinSpeed = spinSpeed * 360.0f;\n\t}\n\n\t/**\n\t * @return the width of the wheel's contour in pixels\n\t */\n\tpublic int getRimWidth() {\n\t\treturn rimWidth;\n\t}\n\n\t/**\n\t * Sets the width of the wheel's contour\n\t *\n\t * @param rimWidth the width in pixels\n\t */\n\tpublic void setRimWidth(int rimWidth) {\n\t\tthis.rimWidth = rimWidth;\n\t\tif (!isSpinning) {\n\t\t\tinvalidate();\n\t\t}\n\t}\n\n\tstatic class WheelSavedState extends BaseSavedState {\n\t\tfloat mProgress;\n\t\tfloat mTargetProgress;\n\t\tboolean isSpinning;\n\t\tfloat spinSpeed;\n\t\tint barWidth;\n\t\tint barColor;\n\t\tint rimWidth;\n\t\tint rimColor;\n\t\tint circleRadius;\n\t\tboolean linearProgress;\n\t\tboolean fillRadius;\n\n\t\tWheelSavedState(Parcelable superState) {\n\t\t\tsuper(superState);\n\t\t}\n\n\t\tprivate WheelSavedState(Parcel in) {\n\t\t\tsuper(in);\n\t\t\tthis.mProgress = in.readFloat();\n\t\t\tthis.mTargetProgress = in.readFloat();\n\t\t\tthis.isSpinning = in.readByte() != 0;\n\t\t\tthis.spinSpeed = in.readFloat();\n\t\t\tthis.barWidth = in.readInt();\n\t\t\tthis.barColor = in.readInt();\n\t\t\tthis.rimWidth = in.readInt();\n\t\t\tthis.rimColor = in.readInt();\n\t\t\tthis.circleRadius = in.readInt();\n\t\t\tthis.linearProgress = in.readByte() != 0;\n\t\t\tthis.fillRadius = in.readByte() != 0;\n\t\t}\n\n\t\t@Override\n\t\tpublic void writeToParcel(Parcel out, int flags) {\n\t\t\tsuper.writeToParcel(out, flags);\n\t\t\tout.writeFloat(this.mProgress);\n\t\t\tout.writeFloat(this.mTargetProgress);\n\t\t\tout.writeByte((byte) (isSpinning ? 1 : 0));\n\t\t\tout.writeFloat(this.spinSpeed);\n\t\t\tout.writeInt(this.barWidth);\n\t\t\tout.writeInt(this.barColor);\n\t\t\tout.writeInt(this.rimWidth);\n\t\t\tout.writeInt(this.rimColor);\n\t\t\tout.writeInt(this.circleRadius);\n\t\t\tout.writeByte((byte) (linearProgress ? 1 : 0));\n\t\t\tout.writeByte((byte) (fillRadius ? 1 : 0));\n\t\t}\n\n\t\tpublic static final Parcelable.Creator<WheelSavedState> CREATOR =\n\t\t\t\tnew Parcelable.Creator<WheelSavedState>() {\n\t\t\t\t\tpublic WheelSavedState createFromParcel(Parcel in) {\n\t\t\t\t\t\treturn new WheelSavedState(in);\n\t\t\t\t\t}\n\n\t\t\t\t\tpublic WheelSavedState[] newArray(int size) {\n\t\t\t\t\t\treturn new WheelSavedState[size];\n\t\t\t\t\t}\n\t\t\t\t};\n\t}\n\n\tpublic interface ProgressCallback {\n\t\t/**\n\t\t * Method to call when the progress reaches a value\n\t\t * in order to avoid float precision issues, the progress\n\t\t * is rounded to a float with two decimals.\n\t\t *\n\t\t * In indeterminate mode, the callback is called each time\n\t\t * the wheel completes an animation cycle, with, the progress value is -1.0f\n\t\t *\n\t\t * @param progress a double value between 0.00 and 1.00 both included\n\t\t */\n\t\tpublic void onProgressUpdate(float progress);\n\t}\n}"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/view/pref/Preference.java",
    "content": "package moe.feng.nhentai.view.pref;\n\nimport android.annotation.TargetApi;\nimport android.content.Context;\nimport android.os.Build.VERSION_CODES;\nimport android.util.AttributeSet;\n\nimport moe.feng.nhentai.R;\n\npublic class Preference extends android.preference.Preference {\n\n\tprivate boolean _isInitialized = false;\n\n\tprotected void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {\n\t\tsetLayoutResource(R.layout.custom_preference);\n\t}\n\n\t@TargetApi(VERSION_CODES.LOLLIPOP)\n\tpublic Preference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {\n\t\tsuper(context, attrs, defStyleAttr, defStyleRes);\n\t\tif (!_isInitialized) {\n\t\t\t_isInitialized = true;\n\t\t\tinit(context, attrs, defStyleAttr, defStyleRes);\n\t\t}\n\t}\n\n\tpublic Preference(Context context, AttributeSet attrs, int defStyleAttr) {\n\t\tsuper(context, attrs, defStyleAttr);\n\t\tif (!_isInitialized) {\n\t\t\t_isInitialized = true;\n\t\t\tinit(context, attrs, defStyleAttr, 0);\n\t\t}\n\t}\n\n\tpublic Preference(Context context, AttributeSet attrs) {\n\t\tsuper(context, attrs);\n\t\tif (!_isInitialized) {\n\t\t\t_isInitialized = true;\n\t\t\tinit(context, attrs, 0, 0);\n\t\t}\n\t}\n\n\tpublic Preference(Context context) {\n\t\tsuper(context);\n\t\tif (!_isInitialized) {\n\t\t\t_isInitialized = true;\n\t\t\tinit(context, null, 0, 0);\n\t\t}\n\t}\n\n}"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/view/pref/SwitchPreference.java",
    "content": "package moe.feng.nhentai.view.pref;\n\nimport android.content.Context;\nimport android.content.res.TypedArray;\nimport android.support.v7.widget.SwitchCompat;\nimport android.util.AttributeSet;\nimport android.view.View;\nimport android.widget.Checkable;\nimport android.widget.CompoundButton;\n\nimport moe.feng.nhentai.R;\n\n/**\n * A {@link Preference} that provides a two-state toggleable option.\n * <p/>\n * This preference will store a boolean into the SharedPreferences.\n *\n * @attr ref android.R.styleable#SwitchPreference_summaryOff\n * @attr ref android.R.styleable#SwitchPreference_summaryOn\n * @attr ref android.R.styleable#SwitchPreference_switchTextOff\n * @attr ref android.R.styleable#SwitchPreference_switchTextOn\n * @attr ref android.R.styleable#SwitchPreference_disableDependentsState\n */\npublic class SwitchPreference extends TwoStatePreference\n{\n\tprivate final Listener mListener = new Listener();\n\n\tprivate CharSequence mSwitchOn;\n\tprivate CharSequence mSwitchOff;\n\n\tprivate class Listener implements CompoundButton.OnCheckedChangeListener {\n\t\t@Override\n\t\tpublic void onCheckedChanged (CompoundButton buttonView, boolean isChecked) {\n\t\t\tif (!callChangeListener(isChecked)) {\n\t\t\t\tbuttonView.setChecked(!isChecked);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tSwitchPreference.this.setChecked(isChecked);\n\t\t}\n\t}\n\n\t/**\n\t * Construct a new SwitchPreference with the given style options.\n\t *\n\t * @param context      The Context that will style this preference\n\t * @param attrs        Style attributes that differ from the default\n\t * @param defStyleAttr An attribute in the current theme that contains a\n\t *                     reference to a style resource that supplies default values for\n\t *                     the view. Can be 0 to not look for defaults.\n\t * @param defStyleRes  A resource identifier of a style resource that\n\t *                     supplies default values for the view, used only if\n\t *                     defStyleAttr is 0 or can not be found in the theme. Can be 0\n\t *                     to not look for defaults.\n\t */\n\tpublic SwitchPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {\n\t\tsuper(context, attrs, defStyleAttr, defStyleRes);\n\t}\n\n\t/**\n\t * Construct a new SwitchPreference with the given style options.\n\t *\n\t * @param context      The Context that will style this preference\n\t * @param attrs        Style attributes that differ from the default\n\t * @param defStyleAttr An attribute in the current theme that contains a\n\t *                     reference to a style resource that supplies default values for\n\t *                     the view. Can be 0 to not look for defaults.\n\t */\n\tpublic SwitchPreference(Context context, AttributeSet attrs, int defStyleAttr) {\n\t\tsuper(context, attrs, defStyleAttr);\n\t}\n\n\t/**\n\t * Construct a new SwitchPreference with the given style options.\n\t *\n\t * @param context The Context that will style this preference\n\t * @param attrs   Style attributes that differ from the default\n\t */\n\tpublic SwitchPreference(Context context,AttributeSet attrs) {\n\t\tthis(context, attrs, R.attr.switchPreferenceStyle);\n\t}\n\n\t/**\n\t * Construct a new SwitchPreference with default style options.\n\t *\n\t * @param context The Context that will style this preference\n\t */\n\tpublic SwitchPreference(Context context) {\n\t\tthis(context, null);\n\t}\n\n\t@Override\n\tprotected void init(final Context context,final AttributeSet attrs,final int defStyleAttr,final int defStyleRes) {\n\t\tsuper.init(context,attrs,defStyleAttr,defStyleRes);\n\t\tthis.setWidgetLayoutResource(R.layout.custom_preference_widget_switch);\n\n\t\tTypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwitchPreference, defStyleAttr, defStyleRes);\n\t\tsetSummaryOn(a.getString(R.styleable.SwitchPreference_summaryOn));\n\t\tsetSummaryOff(a.getString(R.styleable.SwitchPreference_summaryOff));\n\t\tsetSwitchTextOn(a.getString(R.styleable.SwitchPreference_switchTextOn));\n\t\tsetSwitchTextOff(a.getString(R.styleable.SwitchPreference_switchTextOff));\n\t\tsetDisableDependentsState(a.getBoolean(R.styleable.SwitchPreference_disableDependentsState, false));\n\t\ta.recycle();\n\t}\n\n\t@Override\n\tprotected void onBindView(View view) {\n\t\tsuper.onBindView(view);\n\t\tView checkableView = view.findViewById(android.R.id.checkbox);\n\t\tif (checkableView != null && checkableView instanceof Checkable) {\n\t\t\tif (checkableView instanceof SwitchCompat) {\n\t\t\t\tfinal SwitchCompat switchView = (SwitchCompat) checkableView;\n\t\t\t\tswitchView.setOnCheckedChangeListener(null);\n\t\t\t}\n\n\t\t\t((Checkable) checkableView).setChecked(mChecked);\n\n\t\t\tif (checkableView instanceof SwitchCompat) {\n\t\t\t\tfinal SwitchCompat switchView = (SwitchCompat) checkableView;\n\t\t\t\tswitchView.setTextOn(mSwitchOn);\n\t\t\t\tswitchView.setTextOff(mSwitchOff);\n\t\t\t\tswitchView.setOnCheckedChangeListener(mListener);\n\t\t\t}\n\t\t}\n\n\t\tsyncSummaryView(view);\n\t}\n\n\t/**\n\t * Set the text displayed on the switch widget in the on state.\n\t * This should be a very short string; one word if possible.\n\t *\n\t * @param onText Text to display in the on state\n\t */\n\tpublic void setSwitchTextOn(CharSequence onText) {\n\t\tmSwitchOn = onText;\n\t\tnotifyChanged();\n\t}\n\n\t/**\n\t * Set the text displayed on the switch widget in the off state.\n\t * This should be a very short string; one word if possible.\n\t *\n\t * @param offText Text to display in the off state\n\t */\n\tpublic void setSwitchTextOff(CharSequence offText) {\n\t\tmSwitchOff = offText;\n\t\tnotifyChanged();\n\t}\n\n\t/**\n\t * Set the text displayed on the switch widget in the on state.\n\t * This should be a very short string; one word if possible.\n\t *\n\t * @param resId The text as a string resource ID\n\t */\n\tpublic void setSwitchTextOn(int resId) {\n\t\tsetSwitchTextOn(getContext().getString(resId));\n\t}\n\n\t/**\n\t * Set the text displayed on the switch widget in the off state.\n\t * This should be a very short string; one word if possible.\n\t *\n\t * @param resId The text as a string resource ID\n\t */\n\tpublic void setSwitchTextOff(int resId) {\n\t\tsetSwitchTextOff(getContext().getString(resId));\n\t}\n\n\t/**\n\t * @return The text that will be displayed on the switch widget in the on state\n\t */\n\tpublic CharSequence getSwitchTextOn() {\n\t\treturn mSwitchOn;\n\t}\n\n\t/**\n\t * @return The text that will be displayed on the switch widget in the off state\n\t */\n\tpublic CharSequence getSwitchTextOff() {\n\t\treturn mSwitchOff;\n\t}\n\n}"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/view/pref/TwoStatePreference.java",
    "content": "package moe.feng.nhentai.view.pref;\n\nimport android.content.Context;\nimport android.content.SharedPreferences;\nimport android.content.res.TypedArray;\nimport android.os.Parcel;\nimport android.os.Parcelable;\nimport android.text.TextUtils;\nimport android.util.AttributeSet;\nimport android.view.View;\nimport android.widget.TextView;\n\n/**\n * Common base class for preferences that have two selectable states, persist a\n * boolean value in SharedPreferences, and may have dependent preferences that are\n * enabled/disabled based on the current state.\n */\npublic abstract class TwoStatePreference extends Preference {\n\tprivate CharSequence mSummaryOn;\n\tprivate CharSequence mSummaryOff;\n\tboolean mChecked;\n\tprivate boolean mCheckedSet;\n\tprivate boolean mDisableDependentsState;\n\n\tpublic TwoStatePreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {\n\t\tsuper(context, attrs, defStyleAttr, defStyleRes);\n\t}\n\n\tpublic TwoStatePreference(Context context, AttributeSet attrs, int defStyleAttr) {\n\t\tsuper(context, attrs, defStyleAttr);\n\t}\n\n\tpublic TwoStatePreference(Context context, AttributeSet attrs) {\n\t\tthis(context, attrs, 0);\n\t}\n\n\tpublic TwoStatePreference(Context context) {\n\t\tthis(context, null);\n\t}\n\n\t@Override\n\tprotected void onClick() {\n\t\tsuper.onClick();\n\t\tfinal boolean newValue = !isChecked();\n\t\tif (callChangeListener(newValue))  {\n\t\t\tsetChecked(newValue);\n\t\t}\n\t}\n\n\t/**\n\t * Sets the checked state and saves it to the {@link SharedPreferences}.\n\t *\n\t * @param checked The checked state.\n\t */\n\tpublic void setChecked(boolean checked) {\n\t\tfinal boolean changed = mChecked != checked;\n\t\tif (changed || !mCheckedSet) {\n\t\t\tmChecked = checked;\n\t\t\tmCheckedSet = true;\n\t\t\tpersistBoolean(checked);\n\t\t\tif (changed) {\n\t\t\t\tnotifyDependencyChange(shouldDisableDependents());\n\t\t\t\tnotifyChanged();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns the checked state.\n\t *\n\t * @return The checked state.\n\t */\n\tpublic boolean isChecked() {\n\t\treturn mChecked;\n\t}\n\n\t@Override\n\tpublic boolean shouldDisableDependents() {\n\t\tboolean shouldDisable = mDisableDependentsState?mChecked:!mChecked;\n\t\treturn shouldDisable || super.shouldDisableDependents();\n\t}\n\n\t/**\n\t * Sets the summary to be shown when checked.\n\t *\n\t * @param summary The summary to be shown when checked.\n\t */\n\tpublic void setSummaryOn(CharSequence summary) {\n\t\tmSummaryOn = summary;\n\t\tif (isChecked()) {\n\t\t\tnotifyChanged();\n\t\t}\n\t}\n\n\t/**\n\t * @param summaryResId The summary as a resource.\n\t * @see #setSummaryOn(CharSequence)\n\t */\n\tpublic void setSummaryOn(int summaryResId) {\n\t\tsetSummaryOn(getContext().getString(summaryResId));\n\t}\n\n\t/**\n\t * Returns the summary to be shown when checked.\n\t *\n\t * @return The summary.\n\t */\n\tpublic CharSequence getSummaryOn() {\n\t\treturn mSummaryOn;\n\t}\n\n\t/**\n\t * Sets the summary to be shown when unchecked.\n\t *\n\t * @param summary The summary to be shown when unchecked.\n\t */\n\tpublic void setSummaryOff(CharSequence summary) {\n\t\tmSummaryOff = summary;\n\t\tif (!isChecked()) {\n\t\t\tnotifyChanged();\n\t\t}\n\t}\n\n\t/**\n\t * @param summaryResId The summary as a resource.\n\t * @see #setSummaryOff(CharSequence)\n\t */\n\tpublic void setSummaryOff(int summaryResId) {\n\t\tsetSummaryOff(getContext().getString(summaryResId));\n\t}\n\n\t/**\n\t * Returns the summary to be shown when unchecked.\n\t *\n\t * @return The summary.\n\t */\n\tpublic CharSequence getSummaryOff() {\n\t\treturn mSummaryOff;\n\t}\n\n\t/**\n\t * Returns whether dependents are disabled when this preference is on ({@code true})\n\t * or when this preference is off ({@code false}).\n\t *\n\t * @return Whether dependents are disabled when this preference is on ({@code true})\n\t * or when this preference is off ({@code false}).\n\t */\n\tpublic boolean getDisableDependentsState() {\n\t\treturn mDisableDependentsState;\n\t}\n\n\t/**\n\t * Sets whether dependents are disabled when this preference is on ({@code true})\n\t * or when this preference is off ({@code false}).\n\t *\n\t * @param disableDependentsState The preference state that should disable dependents.\n\t */\n\tpublic void setDisableDependentsState(boolean disableDependentsState) {\n\t\tmDisableDependentsState = disableDependentsState;\n\t}\n\n\t@Override\n\tprotected Object onGetDefaultValue(TypedArray a,int index) {\n\t\treturn a.getBoolean(index, false);\n\t}\n\n\t@Override\n\tprotected void onSetInitialValue(boolean restoreValue,Object defaultValue) {\n\t\tsetChecked(restoreValue ? getPersistedBoolean(mChecked) : (Boolean) defaultValue);\n\t}\n\n\t/**\n\t * Sync a summary view contained within view's subhierarchy with the correct summary text.\n\t *\n\t * @param view View where a summary should be located\n\t */\n\tvoid syncSummaryView(View view) {\n\t\tTextView summaryView = (TextView) view.findViewById(android.R.id.summary);\n\t\tif (summaryView != null) {\n\t\t\tboolean useDefaultSummary = true;\n\t\t\tif (mChecked && !TextUtils.isEmpty(mSummaryOn)) {\n\t\t\t\tsummaryView.setText(mSummaryOn);\n\t\t\t\tuseDefaultSummary = false;\n\t\t\t}\n\t\t\telse if (!mChecked && !TextUtils.isEmpty(mSummaryOff)) {\n\t\t\t\tsummaryView.setText(mSummaryOff);\n\t\t\t\tuseDefaultSummary = false;\n\t\t\t}\n\n\t\t\tif (useDefaultSummary) {\n\t\t\t\tfinal CharSequence summary = getSummary();\n\t\t\t\tif (!TextUtils.isEmpty(summary)) {\n\t\t\t\t\tsummaryView.setText(summary);\n\t\t\t\t\tuseDefaultSummary = false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tint newVisibility = View.GONE;\n\t\t\tif (!useDefaultSummary) {\n\t\t\t\tnewVisibility = View.VISIBLE;\n\t\t\t}\n\t\t\tif (newVisibility != summaryView.getVisibility()) {\n\t\t\t\tsummaryView.setVisibility(newVisibility);\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tprotected Parcelable onSaveInstanceState() {\n\t\tfinal Parcelable superState = super.onSaveInstanceState();\n\t\tif (isPersistent()) {\n\t\t\treturn superState;\n\t\t}\n\n\t\tfinal SavedState myState = new SavedState(superState);\n\t\tmyState.checked = isChecked();\n\t\treturn myState;\n\t}\n\n\t@Override\n\tprotected void onRestoreInstanceState(Parcelable state) {\n\t\tif (state == null || !state.getClass().equals(SavedState.class)) {\n\t\t\tsuper.onRestoreInstanceState(state);\n\t\t\treturn;\n\t\t}\n\n\t\tSavedState myState = (SavedState) state;\n\t\tsuper.onRestoreInstanceState(myState.getSuperState());\n\t\tsetChecked(myState.checked);\n\t}\n\n\tstatic class SavedState extends BaseSavedState {\n\n\t\tboolean checked;\n\n\t\tpublic SavedState(Parcel source) {\n\t\t\tsuper(source);\n\t\t\tchecked = source.readInt() == 1;\n\t\t}\n\n\t\t@Override\n\t\tpublic void writeToParcel(Parcel dest, int flags) {\n\t\t\tsuper.writeToParcel(dest, flags);\n\t\t\tdest.writeInt(checked ? 1 : 0);\n\t\t}\n\n\t\tpublic SavedState(Parcelable superState) {\n\t\t\tsuper(superState);\n\t\t}\n\n\t\tpublic static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() {\n\t\t\tpublic SavedState createFromParcel(Parcel in) {\n\t\t\t\treturn new SavedState(in);\n\t\t\t}\n\n\t\t\tpublic SavedState[] newArray(int size) {\n\t\t\t\treturn new SavedState[size];\n\t\t\t}\n\t\t};\n\n\t}\n\n}"
  },
  {
    "path": "app/src/main/java/sumimakito/android/quickkv/DataProcessor.java",
    "content": "/**      \n * QucikKV\n * Copyright (c) 2014-2015 Sumi Makito\n * Licensed under Apache License 2.0.\n * @author sumimakito<sumimakito@hotmail.com>\n * @version 0.8.2\n */\n\npackage sumimakito.android.quickkv;\n\nimport org.json.JSONArray;\nimport org.json.JSONException;\nimport org.json.JSONObject;\n\npublic class DataProcessor\n{\n\tpublic static class Persistable\n\t{\n\t\tpublic static Object dePrefix(String k) throws JSONException\n\t\t{\n\t\t\t\tif (k.startsWith(\"String_\"))\n\t\t\t\t{\n\t\t\t\t\treturn k.substring(\"String_\".length());\n\t\t\t\t}\n\t\t\t\telse if (k.startsWith(\"Boolean_\"))\n\t\t\t\t{\n\t\t\t\t\treturn Boolean.parseBoolean(k.substring(\"Boolean_\".length()));\n\t\t\t\t}\n\t\t\t\telse if (k.startsWith(\"Integer_\"))\n\t\t\t\t{\n\t\t\t\t\treturn Integer.parseInt(k.substring(\"Integer_\".length()));\n\t\t\t\t}\n\t\t\t\telse if (k.startsWith(\"Float_\"))\n\t\t\t\t{\n\t\t\t\t\treturn Float.parseFloat(k.substring(\"Float_\".length()));\n\t\t\t\t}\n\t\t\t\telse if (k.startsWith(\"Double_\"))\n\t\t\t\t{\n\t\t\t\t\treturn Double.parseDouble(k.substring(\"Double_\".length()));\n\t\t\t\t}\n\t\t\t\telse if (k.startsWith(\"Long_\"))\n\t\t\t\t{\n\t\t\t\t\treturn Long.parseLong(k.substring(\"Long_\".length()));\n\t\t\t\t}\n\t\t\t\telse if (k.startsWith(\"JSONArray_\"))\n\t\t\t\t{\n\t\t\t\t\treturn new JSONArray(k.substring(\"JSONArray_\".length()));\n\t\t\t\t}\n\t\t\t\telse if (k.startsWith(\"JSONObject_\"))\n\t\t\t\t{\n\t\t\t\t\treturn new JSONObject(k.substring(\"JSONObject_\".length()));\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t}\n\n\t\tpublic static boolean isValidDataType(Object obj)\n\t\t{\n\t\t\tif (obj instanceof String\n\t\t\t\t|| obj instanceof Integer\n\t\t\t\t|| obj instanceof Boolean\n\t\t\t\t|| obj instanceof Long\n\t\t\t\t|| obj instanceof Float\n\t\t\t\t|| obj instanceof Double\n\t\t\t\t|| obj instanceof JSONObject\n\t\t\t\t|| obj instanceof JSONArray)\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tpublic static String addPrefix(Object obj)\n\t\t{\n\t\t\tif (obj instanceof String)\n\t\t\t{\n\t\t\t\treturn \"String_\" + obj.toString();\n\t\t\t}\n\t\t\telse if (obj instanceof Integer)\n\t\t\t{\n\t\t\t\treturn \"Integer_\" + obj.toString();\n\t\t\t}\n\t\t\telse if (obj instanceof Boolean)\n\t\t\t{\n\t\t\t\treturn \"Boolean_\" + obj.toString();\n\t\t\t}\n\t\t\telse if (obj instanceof Long)\n\t\t\t{\n\t\t\t\treturn \"Long_\" + obj.toString();\n\t\t\t}\n\t\t\telse if (obj instanceof Float)\n\t\t\t{\n\t\t\t\treturn \"Float_\" + obj.toString();\n\t\t\t}\n\t\t\telse if (obj instanceof Double)\n\t\t\t{\n\t\t\t\treturn \"Double_\" + obj.toString();\n\t\t\t}\n\t\t\telse if (obj instanceof org.json.JSONObject)\n\t\t\t{\n\t\t\t\treturn \"JSONObject_\" + obj.toString();\n\t\t\t}\n\t\t\telse if (obj instanceof org.json.JSONArray)\n\t\t\t{\n\t\t\t\treturn \"JSONArray_\" + obj.toString();\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn obj.toString();\n\t\t\t}\n\t\t}\n\t} \n}\n"
  },
  {
    "path": "app/src/main/java/sumimakito/android/quickkv/QKVConfig.java",
    "content": "/**      \n * QucikKV\n * Copyright (c) 2014-2015 Sumi Makito\n * Licensed under Apache License 2.0.\n * @author sumimakito<sumimakito@hotmail.com>\n * @version 0.8.2\n */\n\npackage sumimakito.android.quickkv;\n\npublic class QKVConfig\n{\n\tpublic static final boolean DEBUG = false; //Change it to true in development mode.\n\tpublic static final String PUBLIC_LTAG = \"QuickKV\"; //Default log tag. There is no need to change it.\n\tpublic static final String KVDB_FILE_NAME = \"database.qkv\"; //Default KVDB filename\n\tpublic static final String KVDB_NAME = \"database\"; //Name (must match above)\n\tpublic static final String KVDB_EXT = \".qkv\"; //Ext (must match above above)\n\tpublic static final String EC_PREFIX = \"__QKVEC_\"; // :-/ Abandoned\n}\n"
  },
  {
    "path": "app/src/main/java/sumimakito/android/quickkv/QKVFSReader.java",
    "content": "/**      \n * QucikKV\n * Copyright (c) 2014-2015 Sumi Makito\n * Licensed under Apache License 2.0.\n * @author sumimakito<sumimakito@hotmail.com>\n * @version 0.8.2\n */\n \npackage sumimakito.android.quickkv;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.io.RandomAccessFile;\nimport java.io.StringReader;\nimport java.nio.ByteBuffer;\nimport java.nio.CharBuffer;\nimport java.nio.channels.FileChannel;\nimport java.nio.charset.Charset;\n\npublic class QKVFSReader\n{\n\tpublic static String readFileBFD(String pFileAbsPath) throws IOException {\n\t\treturn bfd(pFileAbsPath);\n\t}\n\t\n\tpublic static String readFileNIO(String pFileAbsPath) throws IOException{\n\t\treturn nio(pFileAbsPath);\n\t}\n\t\n\tprivate static String bfd(String pFilePath) throws FileNotFoundException,IOException{\n\t\tBufferedReader bufferedReader = new BufferedReader(new FileReader(pFilePath));\n\t\tStringBuilder sb = new StringBuilder();\n\t\tString str = null;\n\t\twhile((str = bufferedReader.readLine()) != null){\n\t\t\tsb.append(str);\n\t\t}\n\t\treturn sb.toString();\n\t}\n\t\n\tprivate static String nio(String pFilePath) throws FileNotFoundException,IOException{\n\t\tRandomAccessFile file = new RandomAccessFile(pFilePath, \"r\");\n\t\tFileChannel fileChannel = file.getChannel();\n\t\tByteBuffer buffer = ByteBuffer.allocateDirect((int) fileChannel.size());\n\t\tfileChannel.read(buffer);\n\t\tbuffer.flip();\n\t\tCharBuffer charBuffer = Charset.forName(\"utf-8\").decode(buffer);\n\t\tfile.close();\n\t\tBufferedReader bufferedReader = new BufferedReader(new StringReader(charBuffer.toString()));\n\t\tStringBuilder sb = new StringBuilder();\n\t\tString str = null;\n\t\twhile((str = bufferedReader.readLine()) != null){\n\t\t\tsb.append(str);\n\t\t}\n\t\treturn sb.toString();\n\t}\n}\n"
  },
  {
    "path": "app/src/main/java/sumimakito/android/quickkv/QKVLogger.java",
    "content": "/**      \n * QucikKV\n * Copyright (c) 2014-2015 Sumi Makito\n * Licensed under Apache License 2.0.\n * @author sumimakito<sumimakito@hotmail.com>\n * @version 0.8.2\n */\n\npackage sumimakito.android.quickkv;\n\nimport android.util.Log;\n\npublic class QKVLogger\n{\n\tpublic static void log(String level, String msg)\n\t{\n\t\tif (QKVConfig.DEBUG)\n\t\t{\n\t\t\tif (level.equals(\"i\"))\n\t\t\t{\n\t\t\t\tLog.i(QKVConfig.PUBLIC_LTAG, msg);\n\t\t\t}\n\t\t\telse if (level.equals(\"w\"))\n\t\t\t{\n\t\t\t\tLog.w(QKVConfig.PUBLIC_LTAG, msg);\n\t\t\t}\n\t\t}\n\t}\n\tpublic static void ex(Exception e)\n\t{\n\t\tif (QKVConfig.DEBUG)\n\t\t{\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "app/src/main/java/sumimakito/android/quickkv/QuickKV.java",
    "content": "/**      \n * QucikKV\n * Copyright (c) 2014-2015 Sumi Makito\n * Licensed under Apache License 2.0.\n * @author sumimakito<sumimakito@hotmail.com>\n * @version 0.8.2\n */\n\npackage sumimakito.android.quickkv;\n\nimport android.content.Context;\n\nimport java.util.HashMap;\n\nimport sumimakito.android.quickkv.database.KeyValueDatabase;\n\npublic class QuickKV\n{\n\tprivate Context pContext;\n\tprivate HashMap<String, KeyValueDatabase> sKVDB;\n\n\tpublic QuickKV(Context context)\n\t{\n\t\tthis.pContext = context;\n\t\tthis.sKVDB = new HashMap<String, KeyValueDatabase>();\n\t}\n\n\tpublic KeyValueDatabase getDatabase()\n\t{\n\t\tif (!this.sKVDB.containsKey(QKVConfig.KVDB_FILE_NAME))\n\t\t{\n\t\t\tthis.sKVDB.put(QKVConfig.KVDB_FILE_NAME, new KeyValueDatabase(pContext));\n\t\t}\n\t\treturn this.sKVDB.get(QKVConfig.KVDB_FILE_NAME);\n\t}\n\n\tpublic KeyValueDatabase getDatabase(String dbAlias)\n\t{\n\t\tif (dbAlias.equals(QKVConfig.KVDB_NAME) || dbAlias.equals(QKVConfig.KVDB_FILE_NAME))\n\t\t{\n\t\t\treturn getDatabase();\n\t\t}\n\t\tif (dbAlias == null)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (dbAlias.length() == 0)\n\t\t\t{\n\t\t\t\tdbAlias = QKVConfig.KVDB_FILE_NAME;\n\t\t\t}\n\t\t\tdbAlias = dbAlias.endsWith(QKVConfig.KVDB_EXT) ?dbAlias: dbAlias + QKVConfig.KVDB_EXT;\n\t\t}\n\t\tif (!this.sKVDB.containsKey(dbAlias))\n\t\t{\n\t\t\tthis.sKVDB.put(dbAlias, new KeyValueDatabase(pContext, dbAlias));\n\t\t}\n\n\t\treturn this.sKVDB.get(dbAlias);\n\t}\n\n\tpublic KeyValueDatabase getDatabase(String dbAlias, String key)\n\t{\n\t\tif (dbAlias.equals(QKVConfig.KVDB_NAME) || dbAlias.equals(QKVConfig.KVDB_FILE_NAME))\n\t\t{\n\t\t\treturn getDatabase();\n\t\t}\n\t\tif (dbAlias == null)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (dbAlias.length() == 0)\n\t\t\t{\n\t\t\t\tdbAlias = QKVConfig.KVDB_FILE_NAME;\n\t\t\t}\n\t\t\tdbAlias = dbAlias.endsWith(QKVConfig.KVDB_EXT) ?dbAlias: dbAlias + QKVConfig.KVDB_EXT;\n\t\t}\n\t\tif (!this.sKVDB.containsKey(dbAlias))\n\t\t{\n\t\t\tthis.sKVDB.put(dbAlias, new KeyValueDatabase(pContext, dbAlias, key));\n\t\t}\n\n\t\treturn this.sKVDB.get(dbAlias);\n\t}\n\n\tpublic boolean isDatabaseOpened()\n\t{\n\t\treturn this.sKVDB.containsKey(QKVConfig.KVDB_FILE_NAME);\n\t}\n\n\tpublic boolean isDatabaseOpened(String dbAlias)\n\t{\n\t\tif (dbAlias.equals(QKVConfig.KVDB_NAME) || dbAlias.equals(QKVConfig.KVDB_FILE_NAME))\n\t\t{\n\t\t\treturn isDatabaseOpened();\n\t\t}\n\t\tif (dbAlias == null)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (dbAlias.length() == 0)\n\t\t\t{\n\t\t\t\tdbAlias = QKVConfig.KVDB_FILE_NAME;\n\t\t\t}\n\t\t\tdbAlias = dbAlias.endsWith(QKVConfig.KVDB_EXT) ?dbAlias: dbAlias + QKVConfig.KVDB_EXT;\n\t\t}\n\t\treturn this.sKVDB.containsKey(dbAlias);\n\t}\n\n\tpublic boolean releaseDatabase()\n\t{\n\t\tif (isDatabaseOpened())\n\t\t{\n\t\t\tthis.sKVDB.remove(QKVConfig.KVDB_FILE_NAME);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic boolean releaseDatabase(String dbAlias)\n\t{\n\t\tif (isDatabaseOpened(dbAlias))\n\t\t{\n\t\t\tdbAlias = dbAlias.endsWith(QKVConfig.KVDB_EXT) ?dbAlias: dbAlias + QKVConfig.KVDB_EXT;\n\t\t\tthis.sKVDB.remove(dbAlias);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic void releaseAllDatabases()\n\t{\n\t\tthis.sKVDB.clear();\n\t}\n}\n"
  },
  {
    "path": "app/src/main/java/sumimakito/android/quickkv/database/KeyValueDatabase.java",
    "content": "/**      \n * QucikKV\n * Copyright (c) 2014-2015 Sumi Makito\n * Licensed under Apache License 2.0.\n * @author sumimakito<sumimakito@hotmail.com>\n * @version 0.8.2\n */\n\npackage sumimakito.android.quickkv.database;\n\nimport android.content.*;\n\nimport org.json.JSONObject;\n\nimport java.io.*;\nimport java.util.*;\nimport sumimakito.android.quickkv.*;\nimport sumimakito.android.quickkv.security.*;\n\npublic class KeyValueDatabase implements QKVDatabase\n{\n\tprivate HashMap<Object, Object> dMap;\n\tprivate Context pContext;\n\tprivate String dbAlias;\n\tprivate String pKey;\n\n\tpublic KeyValueDatabase(Context context)\n\t{\n\t\tthis.pContext = context;\n\t\tthis.dbAlias = QKVConfig.KVDB_FILE_NAME;\n\t\tthis.dMap = new HashMap<Object, Object>();\n\t\tthis.sync(false);\n\t\tQKVLogger.log(\"i\", \"KVDB Initialized!\");\n\t}\n\n\tpublic KeyValueDatabase(Context context, String dbAlias)\n\t{\n\t\tthis.pContext = context;\n\t\tthis.dbAlias = dbAlias.endsWith(QKVConfig.KVDB_EXT) ?dbAlias: dbAlias + QKVConfig.KVDB_EXT;\n\t\tthis.dMap = new HashMap<Object, Object>();\n\t\tthis.sync(false);\n\t\tQKVLogger.log(\"i\", \"KVDB Initialized!\");\n\t}\n\n\tpublic KeyValueDatabase(Context context, String dbAlias, String key)\n\t{\n\t\tthis.pKey = key;\n\t\tthis.pContext = context;\n\t\tthis.dbAlias = dbAlias.endsWith(QKVConfig.KVDB_EXT) ?dbAlias: dbAlias + QKVConfig.KVDB_EXT;\n\t\tthis.dMap = new HashMap<Object, Object>();\n\t\tthis.sync(false);\n\t\tQKVLogger.log(\"i\", \"KVDB Initialized!\");\n\t}\n\n\t@Override\n\tpublic <K extends Object, V extends Object> boolean put(K k, V v)\n\t{\n\t\tif (k == null || v == null)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tthis.dMap.put(k, v);\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic <K extends Object> Object get(K k)\n\t{\n\t\tif (k == null)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\t\tif (this.dMap.containsKey(k)) return this.dMap.get(k);\n\t\telse return null;\n\t}\n\n\t@Override\n\tpublic <K extends Object> boolean containsKey(K k)\n\t{\n\t\tif (this.dMap.containsKey(k)) return true;\n\t\telse return false;\n\t}\n\n\t@Override\n\tpublic <V extends Object> boolean containsValue(V v)\n\t{\n\t\tif (this.dMap.containsValue(v)) return true;\n\t\telse return false;\n\t}\n\n\t@Override\n\tpublic <K extends Object> boolean remove(K k)\n\t{\n\t\tif (k == null)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (this.dMap.containsKey(k)) \n\t\t{\n\t\t\tthis.dMap.remove(k);\n\t\t\treturn true;\n\t\t}\n\t\telse return false;\n\t}\n\n\t@Override\n\tpublic <K extends Object> boolean remove(K[] k)\n\t{\n\t\tif (k == null || k.length == 0)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tint r = 0;\n\t\tfor (K key:k)\n\t\t{\n\t\t\tif (this.dMap.containsKey(key))\n\t\t\t{\n\t\t\t\tthis.dMap.remove(key);\n\t\t\t\tr++;\n\t\t\t}\n\t\t}\n\t\tif (r < k.length) return false;\n\t\telse return true;\n\t}\n\n\t@Override\n\tpublic void clear()\n\t{\n\t\tthis.dMap.clear();\n\t}\n\n\t@Override\n\tpublic int size()\n\t{\n\t\treturn this.dMap.size();\n\t}\n\n\tpublic List<Object> getKeys()\n\t{\n\t\tList<Object> list = new ArrayList<Object>();\n\t\tif (this.dMap.size() > 0)\n\t\t{\n\t\t\tIterator iter = dMap.entrySet().iterator(); \n\t\t\twhile (iter.hasNext())\n\t\t\t{ \n\t\t\t\tMap.Entry entry = (Map.Entry) iter.next(); \n\t\t\t\tObject key = entry.getKey(); \n\t\t\t\tlist.add(key);\n\t\t\t} \n\t\t}\n\t\treturn list;\n\t}\n\n\tpublic List<Object> getValues()\n\t{\n\t\tList<Object> list = new ArrayList<Object>();\n\t\tif (this.dMap.size() > 0)\n\t\t{\n\t\t\tIterator iter = dMap.entrySet().iterator(); \n\t\t\twhile (iter.hasNext())\n\t\t\t{ \n\t\t\t\tMap.Entry entry = (Map.Entry) iter.next(); \n\t\t\t\tObject value = entry.getValue(); \n\t\t\t\tlist.add(value);\n\t\t\t} \n\t\t}\n\t\treturn list;\n\t}\n\n\tpublic boolean persist()\n\t{\n\t\tif (this.dMap.size() > 0)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tJSONObject treeRoot = new JSONObject();\n\t\t\t\ttreeRoot.put(\"kv_prop\", new JSONObject());\n\t\t\t\tJSONObject propRoot = (JSONObject) treeRoot.get(\"kv_prop\");\n\t\t\t\tpropRoot.put(\"strc_ver\", \"0.8@3\");\n\t\t\t\tpropRoot.put(\"enc_enabled\", (this.pKey != null && this.pKey.length() > 0));\n\t\t\t\ttreeRoot.put(\"kv_data\", new JSONObject());\n\t\t\t\tJSONObject dataRoot = (JSONObject) treeRoot.get(\"kv_data\");\n\t\t\t\tIterator iter = this.dMap.entrySet().iterator(); \n\t\t\t\twhile (iter.hasNext())\n\t\t\t\t{ \n\t\t\t\t\tMap.Entry entry = (Map.Entry) iter.next(); \n\t\t\t\t\tObject key = entry.getKey(); \n\t\t\t\t\tObject val = entry.getValue(); \n\t\t\t\t\tif (DataProcessor.Persistable.isValidDataType(key)\n\t\t\t\t\t\t&& DataProcessor.Persistable.isValidDataType(val))\n\t\t\t\t\t{\n\t\t\t\t\t\tif (this.pKey != null && this.pKey.length() > 0) dataRoot.put(AES256.encode(this.pKey, DataProcessor.Persistable.addPrefix(key)), AES256.encode(this.pKey, DataProcessor.Persistable.addPrefix(val)));\n\t\t\t\t\t\telse dataRoot.put(DataProcessor.Persistable.addPrefix(key), DataProcessor.Persistable.addPrefix(val));\n\t\t\t\t\t}\n\t\t\t\t} \n\t\t\t\tFileOutputStream kvdbFos = pContext.openFileOutput(dbAlias == null ?QKVConfig.KVDB_FILE_NAME: dbAlias, Context.MODE_PRIVATE);\n\t\t\t\tkvdbFos.write(treeRoot.toString().getBytes());\n\t\t\t\tkvdbFos.close();\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tcatch (Exception e)\n\t\t\t{\n\t\t\t\tQKVLogger.ex(e);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\telse return true;\n\t}\n\n\tpublic void persist(final Callback callback)\n\t{\n\t\tnew Thread(new Runnable(){\n\t\t\t\t@Override\n\t\t\t\tpublic void run()\n\t\t\t\t{\n\t\t\t\t\tsynchronized (dMap)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (persist()) callback.onSuccess();\n\t\t\t\t\t\telse callback.onFailed();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}).start();\n\t}\n\n\tpublic boolean sync()\n\t{\n\t\treturn this.sync(true);\n\t}\n\n\tpublic boolean sync(boolean merge)\n\t{\n\t\ttry\n\t\t{\n\t\t\tif (!merge)\n\t\t\t{\n\t\t\t\tthis.dMap.clear();\n\t\t\t}\n\t\t\tFile kvdbFile = new File(pContext.getFilesDir(), dbAlias == null ? QKVConfig.KVDB_FILE_NAME: dbAlias);\n\t\t\tString rawData = QKVFSReader.readFileBFD(kvdbFile.getAbsolutePath());\n\t\t\tif (rawData.length() > 0)\n\t\t\t{\n\t\t\t\tJSONObject treeRoot = new JSONObject(rawData);\n\t\t\t\tif (parseKVJS((JSONObject) treeRoot.get(\"kv_data\"))) return true;\n\t\t\t\telse return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tQKVLogger.ex(e);\n\t\t\treturn false;\n\t\t}\n\t}\n\t\n\tpublic void sync(final Callback callback)\n\t{\n\t\tnew Thread(new Runnable(){\n\t\t\t\t@Override\n\t\t\t\tpublic void run()\n\t\t\t\t{\n\t\t\t\t\tsynchronized (dMap)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (sync()) callback.onSuccess();\n\t\t\t\t\t\telse callback.onFailed();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}).start();\n\t}\n\t\n\tpublic void sync(final boolean merge, final Callback callback)\n\t{\n\t\tnew Thread(new Runnable(){\n\t\t\t\t@Override\n\t\t\t\tpublic void run()\n\t\t\t\t{\n\t\t\t\t\tsynchronized (dMap)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (sync(merge)) callback.onSuccess();\n\t\t\t\t\t\telse callback.onFailed();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}).start();\n\t}\n\n\tpublic boolean enableEncryption(String key)\n\t{\n\t\tif (key != null && key.length() > 0)\n\t\t{\n\t\t\tthis.pKey = key;\n\t\t\tpersist();\n\t\t\treturn true;\n\t\t}\n\t\telse return false;\n\t}\n\n\tpublic void disableEncryption()\n\t{\n\t\tthis.pKey = null;\n\t\tpersist();\n\t}\n\n\tprivate boolean parseKVJS(JSONObject json)\n\t{\n\t\ttry\n\t\t{\n\t\t\tIterator<String> keys = json.keys();\n\t\t\twhile (keys.hasNext())\n\t\t\t{\n\t\t\t\tString key = keys.next();\n\t\t\t\tString val = json.get(key).toString();\n\t\t\t\tObject k,v;\n\t\t\t\tif (this.pKey != null && this.pKey.length() > 0)\n\t\t\t\t{\n\t\t\t\t\tk = DataProcessor.Persistable.dePrefix(AES256.decode(this.pKey, key));\n\t\t\t\t\tv = DataProcessor.Persistable.dePrefix(AES256.decode(this.pKey, val));\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tk = DataProcessor.Persistable.dePrefix(key);\n\t\t\t\t\tv = DataProcessor.Persistable.dePrefix(val);\n\t\t\t\t}\n\t\t\t\tthis.dMap.put(k, v);\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tQKVLogger.ex(e);\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tpublic interface Callback\n\t{\n\t\tpublic void onSuccess();\n\t\tpublic void onFailed();\n\t}\n}\n"
  },
  {
    "path": "app/src/main/java/sumimakito/android/quickkv/database/QKVDatabase.java",
    "content": "/**      \n * QucikKV\n * Copyright (c) 2014-2015 Sumi Makito\n * Licensed under Apache License 2.0.\n * @author sumimakito<sumimakito@hotmail.com>\n * @version 0.8.2\n */\n\npackage sumimakito.android.quickkv.database;\n\npublic interface QKVDatabase\n{\n\t<K, V> boolean put(K k, V v);\n\t<K> Object get(K k);\n\t<K> boolean containsKey(K k);\n\t<V> boolean containsValue(V v);\n\t<K> boolean remove(K k);\n\t<K> boolean remove(K[] k);\n\tvoid clear();\n\tint size();\n}\n"
  },
  {
    "path": "app/src/main/java/sumimakito/android/quickkv/security/AES256.java",
    "content": "/**      \n * QucikKV\n * Copyright (c) 2014-2015 Sumi Makito\n * Licensed under Apache License 2.0.\n * @author sumimakito<sumimakito@hotmail.com>\n * @version 0.8.2\n */\n \npackage sumimakito.android.quickkv.security;\n\nimport android.util.Base64;\n\nimport java.io.UnsupportedEncodingException;\nimport java.util.Arrays;\n\nimport javax.crypto.Cipher;\nimport javax.crypto.SecretKey;\nimport javax.crypto.spec.IvParameterSpec;\nimport javax.crypto.spec.SecretKeySpec;\n\nimport moe.feng.nhentai.BuildConfig;\nimport sumimakito.android.quickkv.QKVConfig;\n\npublic class AES256\n{\n\tpublic static String encode(String ePasK, String eConT){\n\t\tif (ePasK.length() == 0 || ePasK == null) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\tif (eConT.length() == 0 || eConT == null) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\ttry {\n\t\t\tSecretKeySpec skeySpec = getKey(ePasK);\n\t\t\tbyte[] clearText = eConT.getBytes(\"UTF8\");\n\t\t\t\n\t\t\tfinal byte[] iv = new byte[16];\n\t\t\tArrays.fill(iv, (byte) 0x00);\n\t\t\tIvParameterSpec ivParameterSpec = new IvParameterSpec(iv);\n\n\t\t\tCipher cipher = Cipher.getInstance(\"AES/CBC/PKCS7Padding\");\n\t\t\tcipher.init(Cipher.ENCRYPT_MODE, skeySpec, ivParameterSpec);\n\n\t\t\tString encrypedValue = Base64.encodeToString(cipher.doFinal(clearText), Base64.DEFAULT);\n\t\t\treturn encrypedValue;\n\n\t\t} catch (Exception e) {\n\t\t\tif (QKVConfig.DEBUG){\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t}\n\t\treturn \"\";\n\t}\n\n\tpublic static String decode(String ePasK, String eConT){\n\t\tif (ePasK.length() == 0 || ePasK == null) {\n\t\t\treturn \"\";\n\t\t}\n\t\tif (eConT.length() == 0 || eConT == null) {\n\t\t\treturn \"\";\n\t\t}\n\t\ttry {\n\t\t\tSecretKey key = getKey(ePasK);\n\t\t\tfinal byte[] iv = new byte[16];\n\t\t\tArrays.fill(iv, (byte) 0x00);\n\t\t\tIvParameterSpec ivParameterSpec = new IvParameterSpec(iv);\n\t\t\tbyte[] encrypedPwdBytes = Base64.decode(eConT, Base64.DEFAULT);\n\t\t\tCipher cipher = Cipher.getInstance(\"AES/CBC/PKCS7Padding\");\n\t\t\tcipher.init(Cipher.DECRYPT_MODE, key, ivParameterSpec);\n\t\t\tbyte[] decrypedValueBytes = (cipher.doFinal(encrypedPwdBytes));\n\n\t\t\tString decrypedValue = new String(decrypedValueBytes);\n\t\t\treturn decrypedValue;\n\n\t\t} catch (Exception e) {\n\t\t\tif (BuildConfig.DEBUG){\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t}\n\t\treturn \"\";\n\t}\n\tprivate static SecretKeySpec getKey(String password) throws UnsupportedEncodingException {\n\t\tint keyLength = 256;\n\t\tbyte[] keyBytes = new byte[keyLength / 8];\n\t\tArrays.fill(keyBytes, (byte) 0x0);\n\t\tbyte[] passwordBytes = password.getBytes(\"UTF-8\");\n\t\tint length = passwordBytes.length < keyBytes.length ? passwordBytes.length : keyBytes.length;\n\t\tSystem.arraycopy(passwordBytes, 0, keyBytes, 0, length);\n\t\tSecretKeySpec key = new SecretKeySpec(keyBytes, \"AES\");\n\t\treturn key;\n\t}\n}\n"
  },
  {
    "path": "app/src/main/res/color/drawer_item_color.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n\t<item android:state_checked=\"false\" android:color=\"#8f000000\"/>\n\t<item android:state_checked=\"true\" android:color=\"@color/deep_purple_800\"/>\n\n</selector>"
  },
  {
    "path": "app/src/main/res/drawable/shadow_gradient.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\"\n       android:shape=\"rectangle\">\n\n\t<gradient android:startColor=\"#9a000000\"\n\t          android:endColor=\"#00000000\"\n\t          android:type=\"linear\"\n\t          android:angle=\"270\" />\n\n</shape>"
  },
  {
    "path": "app/src/main/res/drawable/shadow_gradient_reserve.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\"\n       android:shape=\"rectangle\">\n\n\t<gradient android:startColor=\"#00000000\"\n\t\t\t  android:endColor=\"#9a000000\"\n\t          android:type=\"linear\"\n\t          android:angle=\"270\" />\n\n</shape>"
  },
  {
    "path": "app/src/main/res/drawable/shadow_normal.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\"\n       android:shape=\"rectangle\">\n\n\t<gradient android:startColor=\"#44000000\"\n\t          android:endColor=\"#00000000\"\n\t          android:type=\"linear\"\n\t          android:angle=\"270\" />\n\n</shape>"
  },
  {
    "path": "app/src/main/res/drawable/shadow_normal_reserve.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\"\n       android:shape=\"rectangle\">\n\n\t<gradient android:startColor=\"#00000000\"\n\t          android:endColor=\"#44000000\"\n\t          android:type=\"linear\"\n\t          android:angle=\"270\" />\n\n</shape>"
  },
  {
    "path": "app/src/main/res/layout/activity_book_details.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<android.support.design.widget.CoordinatorLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n                                                 xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n                                                 android:id=\"@+id/main_content\"\n                                                 android:layout_width=\"match_parent\"\n                                                 android:layout_height=\"match_parent\"\n                                                 android:fitsSystemWindows=\"true\">\n\n    <android.support.design.widget.AppBarLayout\n        android:id=\"@+id/appbar\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"@dimen/details_big_cover_max_height\"\n        android:theme=\"@style/ThemeOverlay.AppCompat.Dark.ActionBar\"\n        android:fitsSystemWindows=\"true\">\n\n        <android.support.design.widget.CollapsingToolbarLayout\n            android:id=\"@+id/collapsing_toolbar\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\"\n            app:layout_scrollFlags=\"scroll|exitUntilCollapsed\"\n            android:fitsSystemWindows=\"true\"\n            app:contentScrim=\"?attr/colorPrimary\"\n            app:expandedTitleMarginStart=\"48dp\"\n            app:expandedTitleMarginEnd=\"64dp\">\n\n            <ImageView\n                android:id=\"@+id/app_bar_background\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"match_parent\"\n                android:scaleType=\"centerCrop\"\n                android:fitsSystemWindows=\"true\"\n                app:layout_collapseMode=\"parallax\" />\n\n            <View\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"?attr/actionBarSize\"\n                android:background=\"@drawable/shadow_normal_reserve\"\n                android:layout_gravity=\"bottom\"\n                app:layout_collapseMode=\"parallax\"/>\n\n            <android.support.v7.widget.Toolbar\n                android:id=\"@+id/toolbar\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"?attr/actionBarSize\"\n                app:popupTheme=\"@style/ThemeOverlay.AppCompat.Light\"\n                app:layout_collapseMode=\"pin\" />\n\n        </android.support.design.widget.CollapsingToolbarLayout>\n\n    </android.support.design.widget.AppBarLayout>\n\n    <android.support.v4.widget.NestedScrollView\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:id=\"@+id/scrollView\"\n        android:paddingTop=\"24dp\"\n        android:paddingBottom=\"24dp\"\n        android:clipToPadding=\"false\"\n        app:layout_behavior=\"@string/appbar_scrolling_view_behavior\">\n\n        <LinearLayout\n            android:orientation=\"vertical\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"wrap_content\"\n            android:paddingLeft=\"16dp\"\n            android:paddingRight=\"16dp\"\n            android:minHeight=\"420dp\">\n\n            <moe.feng.nhentai.view.WheelProgressView\n                android:layout_width=\"64dp\"\n                android:layout_height=\"64dp\"\n                android:layout_gravity=\"center\"\n                android:layout_marginTop=\"64dp\"\n                android:layout_marginBottom=\"128dp\"\n                android:id=\"@+id/wheel_progress\"\n                app:matProg_barColor=\"@color/pink_500\"\n                app:matProg_barWidth=\"4dp\"/>\n\n            <LinearLayout\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"wrap_content\"\n                android:id=\"@+id/book_content\"\n                android:orientation=\"vertical\"\n                android:visibility=\"gone\">\n\n                <TextView\n                    android:layout_width=\"wrap_content\"\n                    android:layout_height=\"wrap_content\"\n                    android:textAppearance=\"?android:attr/textAppearanceMedium\"\n                    android:id=\"@+id/tv_title\"/>\n\n                <View\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"0.5dp\"\n                    android:background=\"@android:color/black\"\n                    android:alpha=\"0.3\"\n                    android:layout_marginTop=\"24dp\"\n                    android:layout_marginBottom=\"24dp\"/>\n\n                <LinearLayout\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"wrap_content\"\n                    android:id=\"@+id/book_tags_layout\"\n                    android:orientation=\"vertical\"/>\n\n            </LinearLayout>\n\n        </LinearLayout>\n\n    </android.support.v4.widget.NestedScrollView>\n\n    <android.support.design.widget.FloatingActionButton\n        android:layout_height=\"wrap_content\"\n        android:layout_width=\"wrap_content\"\n        android:id=\"@+id/fab\"\n        app:layout_anchor=\"@id/appbar\"\n        app:layout_anchorGravity=\"bottom|right\"\n        android:src=\"@drawable/ic_photo_library_black_24dp\"\n        android:tint=\"@android:color/white\"\n        android:layout_margin=\"24dp\"\n        app:borderWidth=\"0dp\"\n        app:elevation=\"5dp\"/>\n\n</android.support.design.widget.CoordinatorLayout>"
  },
  {
    "path": "app/src/main/res/layout/activity_gallery.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout\n\txmlns:android=\"http://schemas.android.com/apk/res/android\"\n\tandroid:id=\"@+id/main_content\"\n\tandroid:layout_width=\"match_parent\"\n\tandroid:layout_height=\"match_parent\">\n\n\t<android.support.v4.view.ViewPager\n\t\tandroid:id=\"@+id/pager\"\n\t\tandroid:layout_width=\"match_parent\"\n\t\tandroid:layout_height=\"match_parent\"/>\n\n\t<LinearLayout\n\t\tandroid:layout_width=\"match_parent\"\n\t\tandroid:layout_height=\"wrap_content\"\n\t\tandroid:id=\"@+id/my_app_bar\"\n\t\tandroid:orientation=\"vertical\"\n\t\tandroid:background=\"@color/app_bar_translucent_black\">\n\n\t\t<View\n\t\t\tandroid:layout_width=\"match_parent\"\n\t\t\tandroid:layout_height=\"0dp\"\n\t\t\tandroid:id=\"@+id/status_bar_header\"/>\n\n\t\t<android.support.v7.widget.Toolbar\n\t\t\tandroid:layout_width=\"match_parent\"\n\t\t\tandroid:layout_height=\"?attr/actionBarSize\"\n\t\t\tandroid:background=\"@android:color/transparent\"\n\t\t\tandroid:id=\"@+id/toolbar\"\n\t\t\tandroid:theme=\"@style/ThemeOverlay.AppCompat.Dark.ActionBar\"/>\n\n\t</LinearLayout>\n\n</FrameLayout>"
  },
  {
    "path": "app/src/main/res/layout/activity_main.xml",
    "content": "<android.support.v4.widget.DrawerLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n                                        xmlns:tools=\"http://schemas.android.com/tools\"\n                                        xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n                                        android:id=\"@+id/drawer_layout\"\n                                        android:layout_width=\"match_parent\"\n                                        android:layout_height=\"match_parent\">\n\n\t<android.support.design.widget.CoordinatorLayout\n\t\tandroid:id=\"@+id/main_content\"\n\t\tandroid:layout_width=\"match_parent\"\n\t\tandroid:layout_height=\"match_parent\">\n\n\t\t<android.support.design.widget.AppBarLayout\n\t\t\tandroid:id=\"@+id/appbar\"\n\t\t\tandroid:layout_width=\"match_parent\"\n\t\t\tandroid:layout_height=\"wrap_content\"\n\t\t\tandroid:theme=\"@style/ThemeOverlay.AppCompat.Dark.ActionBar\">\n\n\t\t\t<android.support.v7.widget.Toolbar\n\t\t\t\tandroid:layout_width=\"match_parent\"\n\t\t\t\tandroid:layout_height=\"?attr/actionBarSize\"\n\t\t\t\tandroid:background=\"?attr/colorPrimary\"\n\t\t\t\tandroid:id=\"@+id/toolbar\"\n\t\t\t\tapp:layout_scrollFlags=\"scroll|enterAlways\"\n\t\t\t\tapp:popupTheme=\"@style/ThemeOverlay.AppCompat.Light\"/>\n\n\t\t\t<android.support.design.widget.TabLayout\n\t\t\t\tandroid:layout_width=\"wrap_content\"\n\t\t\t\tandroid:layout_height=\"wrap_content\"\n\t\t\t\tandroid:id=\"@+id/tabs\"\n\t\t\t\tandroid:layout_marginLeft=\"8dp\"\n\t\t\t\tandroid:layout_marginRight=\"8dp\"/>\n\n\t\t</android.support.design.widget.AppBarLayout>\n\n\t\t<android.support.v4.view.ViewPager\n\t\t\tandroid:layout_width=\"match_parent\"\n\t\t\tandroid:layout_height=\"match_parent\"\n\t\t\tandroid:id=\"@+id/viewpager\"\n\t\t\tapp:layout_behavior=\"@string/appbar_scrolling_view_behavior\"/>\n\n\t</android.support.design.widget.CoordinatorLayout>\n\n\t<com.quinny898.library.persistentsearch.SearchBox\n\t\tandroid:layout_width=\"wrap_content\"\n\t\tandroid:layout_height=\"wrap_content\"\n\t\tandroid:id=\"@+id/search_box\"\n\t\tandroid:visibility=\"invisible\"/>\n\n\t<android.support.design.widget.NavigationView\n\t\tandroid:layout_height=\"match_parent\"\n\t    android:layout_width=\"@dimen/navigation_view_width\"\n\t    android:id=\"@+id/navigation_view\"\n\t\tandroid:layout_gravity=\"left\"\n\t    app:headerLayout=\"@layout/navigation_header\"\n\t\tapp:menu=\"@menu/navigation_menu\"\n\t\tapp:itemTextColor=\"@color/drawer_item_color\"\n\t\tapp:itemIconTint=\"@color/drawer_item_color\"/>\n\n</android.support.v4.widget.DrawerLayout>"
  },
  {
    "path": "app/src/main/res/layout/activity_search_result.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n              android:orientation=\"vertical\"\n              android:layout_width=\"match_parent\"\n              android:layout_height=\"match_parent\">\n\n    <View\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"0dp\"\n        android:id=\"@+id/status_bar_header\"\n        android:background=\"?attr/colorPrimaryDark\"/>\n\n    <android.support.v7.widget.Toolbar\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"?attr/actionBarSize\"\n        android:background=\"?attr/colorPrimary\"\n        android:id=\"@+id/toolbar\"\n        android:theme=\"@style/ThemeOverlay.AppCompat.Dark.ActionBar\"/>\n\n    <android.support.v4.widget.SwipeRefreshLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:id=\"@+id/swipe_refresh_layout\">\n\n        <android.support.v7.widget.RecyclerView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\"\n            android:id=\"@+id/recycler_view\"/>\n\n    </android.support.v4.widget.SwipeRefreshLayout>\n\n</LinearLayout>"
  },
  {
    "path": "app/src/main/res/layout/activity_settings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n              android:orientation=\"vertical\"\n              android:layout_width=\"match_parent\"\n              android:layout_height=\"match_parent\">\n\n    <View\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"0dp\"\n        android:id=\"@+id/status_bar_header\"\n        android:background=\"?attr/colorPrimaryDark\"/>\n\n    <android.support.v7.widget.Toolbar\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"?attr/actionBarSize\"\n        android:background=\"?attr/colorPrimary\"\n        android:id=\"@+id/toolbar\"\n        android:theme=\"@style/ThemeOverlay.AppCompat.Dark.ActionBar\"/>\n\n    <FrameLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:id=\"@+id/container\"/>\n\n</LinearLayout>"
  },
  {
    "path": "app/src/main/res/layout/custom_preference.xml",
    "content": "<android.support.v7.widget.LinearLayoutCompat\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"wrap_content\"\n    android:background=\"?attr/selectableItemBackground\"\n    android:clipToPadding=\"false\"\n    android:gravity=\"center_vertical\"\n    android:minHeight=\"?attr/listPreferredItemHeightSmall\"\n    android:orientation=\"horizontal\"\n    android:paddingEnd=\"?attr/listPreferredItemPaddingRight\"\n    android:paddingLeft=\"?attr/listPreferredItemPaddingLeft\"\n    android:paddingRight=\"?attr/listPreferredItemPaddingRight\"\n    android:paddingStart=\"?attr/listPreferredItemPaddingLeft\"\n    tools:ignore=\"NewApi\">\n\n    <RelativeLayout\n        android:layout_width=\"0px\"\n        android:layout_height=\"wrap_content\"\n        android:layout_weight=\"1\"\n        android:paddingBottom=\"16dp\"\n        android:paddingTop=\"16dp\">\n\n        <android.support.v7.widget.AppCompatTextView\n            android:id=\"@android:id/title\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:textAppearance=\"?attr/textAppearanceListItem\"\n            tools:text=\"title\"/>\n\n        <!--NOTE: original: android:textAppearance=\"?attr/textAppearanceListItemSecondary\"-->\n        <android.support.v7.widget.AppCompatTextView\n            android:id=\"@android:id/summary\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_alignLeft=\"@android:id/title\"\n            android:layout_alignStart=\"@android:id/title\"\n            android:layout_below=\"@android:id/title\"\n            android:textAppearance=\"@style/TextAppearance.AppCompat.Body1\"\n            android:textColor=\"?android:attr/textColorSecondary\"\n            tools:text=\"summary\"/>\n        <!--TextAppearance.Material.Body1-->\n    </RelativeLayout>\n\n    <!-- Preference should place its actual preference widget here. -->\n    <android.support.v7.widget.LinearLayoutCompat\n        android:id=\"@android:id/widget_frame\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"match_parent\"\n        android:gravity=\"end|center_vertical\"\n        android:orientation=\"vertical\"\n        android:paddingLeft=\"16dp\"\n        android:paddingStart=\"16dp\"/>\n\n</android.support.v7.widget.LinearLayoutCompat>"
  },
  {
    "path": "app/src/main/res/layout/custom_preference_widget_switch.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<android.support.v7.widget.SwitchCompat\n    android:id=\"@android:id/checkbox\"\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    android:background=\"@null\"\n    android:clickable=\"false\"\n    android:focusable=\"false\"/>"
  },
  {
    "path": "app/src/main/res/layout/fragment_book_page.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n              android:orientation=\"vertical\"\n              android:layout_width=\"match_parent\"\n              android:layout_height=\"match_parent\">\n\n    <ImageView\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:id=\"@+id/image_view\"/>\n\n</LinearLayout>"
  },
  {
    "path": "app/src/main/res/layout/fragment_download.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n             android:layout_width=\"match_parent\"\n             android:layout_height=\"match_parent\">\n\n\t<android.support.v7.widget.RecyclerView\n\t\tandroid:layout_width=\"match_parent\"\n\t\tandroid:layout_height=\"match_parent\"\n\t\tandroid:id=\"@+id/recylcer_view\"/>\n\n</FrameLayout>"
  },
  {
    "path": "app/src/main/res/layout/fragment_favorite.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n             android:layout_width=\"match_parent\"\n             android:layout_height=\"match_parent\">\n\n\t<android.support.v7.widget.RecyclerView\n\t\tandroid:layout_width=\"match_parent\"\n\t\tandroid:layout_height=\"match_parent\"\n\t\tandroid:id=\"@+id/recylcer_view\"/>\n\n</FrameLayout>"
  },
  {
    "path": "app/src/main/res/layout/fragment_home.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n             android:layout_width=\"match_parent\"\n             android:layout_height=\"match_parent\">\n\n\t<android.support.v4.widget.SwipeRefreshLayout\n\t\tandroid:layout_width=\"match_parent\"\n\t\tandroid:layout_height=\"match_parent\"\n\t\tandroid:id=\"@+id/swipe_refresh_layout\">\n\n\t\t<android.support.v7.widget.RecyclerView\n\t\t\tandroid:layout_width=\"match_parent\"\n\t\t\tandroid:layout_height=\"match_parent\"\n\t\t\tandroid:id=\"@+id/recycler_view\"/>\n\n\t</android.support.v4.widget.SwipeRefreshLayout>\n\n</FrameLayout>"
  },
  {
    "path": "app/src/main/res/layout/list_item_book_card.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<android.support.v7.widget.CardView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n                                    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n                                    xmlns:tools=\"http://schemas.android.com/tools\"\n                                    android:layout_width=\"match_parent\"\n                                    android:layout_height=\"wrap_content\"\n                                    android:layout_margin=\"5dp\"\n                                    android:foreground=\"?attr/selectableItemBackground\"\n                                    android:clickable=\"true\"\n                                    android:id=\"@+id/book_card\"\n                                    app:cardElevation=\"4dp\"\n                                    app:cardCornerRadius=\"2dp\"\n                                    tools:minWidth=\"160dp\">\n\n\t<LinearLayout\n\t\tandroid:layout_width=\"match_parent\"\n\t\tandroid:layout_height=\"wrap_content\"\n\t\tandroid:orientation=\"vertical\">\n\n\t\t<ImageView\n\t\t\tandroid:layout_width=\"match_parent\"\n\t\t\tandroid:layout_height=\"wrap_content\"\n\t\t\tandroid:id=\"@+id/book_preview\"\n\t\t\tandroid:scaleType=\"fitXY\"\n\t\t\tandroid:adjustViewBounds=\"true\"\n\t\t\ttools:src=\"@mipmap/ic_launcher\"/>\n\n\t\t<LinearLayout\n\t\t\tandroid:layout_width=\"match_parent\"\n\t\t\tandroid:layout_height=\"wrap_content\"\n\t\t\tandroid:orientation=\"horizontal\"\n\t\t\tandroid:paddingLeft=\"10dp\"\n\t\t\tandroid:paddingRight=\"10dp\"\n\t\t\tandroid:paddingTop=\"10dp\"\n\t\t\tandroid:paddingBottom=\"10dp\">\n\n\t\t\t<TextView\n\t\t\t\tandroid:layout_width=\"wrap_content\"\n\t\t\t\tandroid:layout_height=\"wrap_content\"\n\t\t\t\tandroid:id=\"@+id/book_title\"\n\t\t\t\tandroid:textAppearance=\"?android:attr/textAppearanceSmall\"\n\t\t\t\ttools:text=\"Title\"/>\n\n\t\t</LinearLayout>\n\n\t</LinearLayout>\n\n</android.support.v7.widget.CardView>"
  },
  {
    "path": "app/src/main/res/layout/list_item_book_picture_thumb.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n              xmlns:tools=\"http://schemas.android.com/tools\"\n              android:orientation=\"vertical\"\n              android:layout_width=\"match_parent\"\n              android:layout_height=\"wrap_content\"\n              android:padding=\"8dp\"\n              android:gravity=\"center_horizontal\"\n              android:clickable=\"true\"\n              android:background=\"?attr/selectableItemBackground\">\n\n    <ImageView\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:id=\"@+id/image_view\"\n        android:src=\"@drawable/holder_0\"/>\n\n    <TextView\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:id=\"@+id/number_text\"\n        android:layout_marginTop=\"4dp\"\n        tools:text=\"1\"/>\n\n</LinearLayout>"
  },
  {
    "path": "app/src/main/res/layout/list_item_menu_row.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n              android:orientation=\"vertical\"\n              android:layout_width=\"match_parent\"\n              android:layout_height=\"match_parent\"\n              android:paddingBottom=\"24dp\"\n              android:background=\"#eeeeee\">\n\n\t<TextView\n\t\tandroid:layout_width=\"wrap_content\"\n\t\tandroid:layout_height=\"wrap_content\"\n\t\tandroid:id=\"@+id/menu_text\"\n\t\tandroid:textSize=\"16sp\"\n\t\tandroid:paddingLeft=\"16dp\"\n\t\tandroid:paddingRight=\"16dp\"\n\t\tandroid:textColor=\"#000000\"/>\n\n</LinearLayout>"
  },
  {
    "path": "app/src/main/res/layout/navigation_header.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n              android:orientation=\"vertical\"\n              android:layout_width=\"match_parent\"\n              android:layout_height=\"180dp\"\n              android:background=\"?attr/colorPrimary\">\n\n</LinearLayout>"
  },
  {
    "path": "app/src/main/res/menu/menu_main.xml",
    "content": "<menu xmlns:android=\"http://schemas.android.com/apk/res/android\"\n      xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n      xmlns:tools=\"http://schemas.android.com/tools\"\n      tools:context=\".MainActivity\">\n\n\t<item android:id=\"@+id/action_search\"\n\t      android:title=\"@string/action_search\"\n\t      android:orderInCategory=\"0\"\n\t      android:icon=\"@drawable/abc_ic_search_api_mtrl_alpha\"\n\t      app:showAsAction=\"ifRoom\"/>\n\n\t<item android:id=\"@+id/action_settings\"\n\t      android:title=\"@string/action_settings\"\n\t      android:orderInCategory=\"100\"\n\t      app:showAsAction=\"never\"/>\n\n</menu>\n"
  },
  {
    "path": "app/src/main/res/menu/navigation_menu.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<menu xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n\t<group android:checkableBehavior=\"single\">\n\n\t\t<item android:id=\"@+id/navigation_item_home\"\n\t\t      android:checked=\"true\"\n\t\t      android:icon=\"@drawable/ic_home_black_24dp\"\n\t\t      android:title=\"@string/item_home\"/>\n\n\t\t<item android:id=\"@+id/navigation_item_tag\"\n\t\t      android:icon=\"@drawable/ic_style_black_24dp\"\n\t\t      android:title=\"@string/item_tag\"/>\n\n\t\t<item android:id=\"@+id/navigation_item_character\"\n\t\t      android:icon=\"@drawable/ic_face_unlock_black_24dp\"\n\t\t      android:title=\"@string/item_character\"/>\n\n\t</group>\n\n</menu>"
  },
  {
    "path": "app/src/main/res/values/attrs.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n\t<attr name=\"dialogPreferenceStyle\" format=\"reference\"/>\n\t<attr name=\"editTextPreferenceStyle\" format=\"reference\"/>\n\t<attr name=\"switchPreferenceStyle\" format=\"reference\"/>\n\t<attr name=\"checkBoxPreferenceStyle\" format=\"reference\"/>\n\n\t<declare-styleable name=\"ListPreference\">\n\t\t<attr name=\"entries\" format=\"reference\"/>\n\t\t<attr name=\"entryValues\" format=\"reference\"/>\n\t</declare-styleable>\n\n\t<declare-styleable name=\"DialogPreference\">\n\t\t<attr name=\"dialogTitle\" format=\"string\"/>\n\t\t<attr name=\"dialogMessage\" format=\"string\"/>\n\t\t<attr name=\"dialogIcon\" format=\"reference\"/>\n\t\t<attr name=\"positiveButtonText\" format=\"string\"/>\n\t\t<attr name=\"negativeButtonText\" format=\"string\"/>\n\t\t<attr name=\"dialogLayout\" format=\"reference\"/>\n\t</declare-styleable>\n\n\t<declare-styleable name=\"CheckBoxPreference\">\n\t\t<attr name=\"summaryOn\" format=\"string\"/>\n\t\t<attr name=\"summaryOff\" format=\"string\"/>\n\t\t<attr name=\"disableDependentsState\" format=\"boolean\"/>\n\t</declare-styleable>\n\n\t<declare-styleable name=\"SwitchPreference\">\n\t\t<attr name=\"summaryOn\"/>\n\t\t<attr name=\"summaryOff\" />\n\t\t<attr name=\"switchTextOn\" format=\"string\"/>\n\t\t<attr name=\"switchTextOff\" format=\"string\"/>\n\t\t<attr name=\"disableDependentsState\" />\n\t</declare-styleable>\n\n\t<declare-styleable name=\"AutoWrapLayout\">\n\t\t<attr name=\"alignment\">\n\t\t\t<enum name=\"top\" value=\"0\" />\n\t\t\t<enum name=\"center\" value=\"1\" />\n\t\t\t<enum name=\"bottom\" value=\"2\" />\n\t\t</attr>\n\t</declare-styleable>\n\n\t<declare-styleable name=\"WheelProgressView\">\n\t\t<attr name=\"matProg_progressIndeterminate\" format=\"boolean\" />\n\t\t<attr name=\"matProg_barColor\" format=\"color\" />\n\t\t<attr name=\"matProg_rimColor\" format=\"color\" />\n\t\t<attr name=\"matProg_rimWidth\" format=\"dimension\" />\n\t\t<attr name=\"matProg_spinSpeed\" format=\"float\" />\n\t\t<attr name=\"matProg_barSpinCycleTime\" format=\"integer\" />\n\t\t<attr name=\"matProg_circleRadius\" format=\"dimension\" />\n\t\t<attr name=\"matProg_fillRadius\" format=\"boolean\" />\n\t\t<attr name=\"matProg_barWidth\" format=\"dimension\" />\n\t\t<attr name=\"matProg_linearProgress\" format=\"boolean\" />\n\t</declare-styleable>\n\n</resources>"
  },
  {
    "path": "app/src/main/res/values/color.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n\t<color name=\"deep_purple_300\">#9575CD</color>\n\t<color name=\"deep_purple_500\">#673AB7</color>\n\t<color name=\"deep_purple_800\">#4527A0</color>\n\n\t<color name=\"purple_300\">#BA68C8</color>\n\t<color name=\"pink_500\">#E91E63</color>\n\t<color name=\"indigo_500\">#3F51B5</color>\n\t<color name=\"blue_500\">#2196F3</color>\n\t<color name=\"teal_500\">#009688</color>\n\t<color name=\"green_500\">#4CAF50</color>\n\t<color name=\"green_300\">#81C784</color>\n\t<color name=\"orange_500\">#FF9800</color>\n\t<color name=\"brown_500\">#795548</color>\n\n\t<color name=\"app_bar_translucent_black\">#4F000000</color>\n\t\n</resources>"
  },
  {
    "path": "app/src/main/res/values/dimen.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n\t<dimen name=\"fab_transition_z\">5dp</dimen>\n\n\t<dimen name=\"navigation_view_width\">256dp</dimen>\n\n\t<dimen name=\"details_big_cover_max_height\">320dp</dimen>\n\n\t<dimen name=\"tag_margin_x\">2dp</dimen>\n\t<dimen name=\"tag_margin_y\">4dp</dimen>\n\t<dimen name=\"tag_text_size\">14sp</dimen>\n\t<dimen name=\"tag_title_width\">72sp</dimen>\n\n</resources>"
  },
  {
    "path": "app/src/main/res/values/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n    <string name=\"app_name\">NHBooks</string>\n    <string name=\"action_settings\">Settings</string>\n    <string name=\"action_search\">Search</string>\n\n    <string name=\"item_home\">Home</string>\n    <string name=\"item_tag\">Tags</string>\n    <string name=\"item_character\">Characters</string>\n\n    <string name=\"title_page_latest\">Latest</string>\n    <string name=\"title_page_download\">Saved books</string>\n    <string name=\"title_page_favorite\">Favorites</string>\n    <string-array name=\"page_titles\">\n        <item>@string/title_page_latest</item>\n        <item>@string/title_page_download</item>\n        <item>@string/title_page_favorite</item>\n    </string-array>\n    <string name=\"tips_network_error\">Failed to connect to NHentai.</string>\n    <string name=\"snack_action_try_again\">Try again</string>\n\n    <string name=\"activity_details\">Details</string>\n    <string name=\"tag_type_tag\">Tags: </string>\n    <string name=\"tag_type_parodies\">Parodies: </string>\n    <string name=\"tag_type_language\">Language: </string>\n    <string name=\"tag_type_characters\">Characters: </string>\n    <string name=\"tag_type_artists\">Artists: </string>\n    <string name=\"tag_type_group\">Groups: </string>\n    <string name=\"tag_type_upload_time\">Uploaded time: </string>\n\n    <string name=\"activity_gallery\">Gallery</string>\n\n    <string name=\"activity_search_result\">Search result</string>\n    <string name=\"title_search_result\">Search result: %s</string>\n    <string name=\"tips_no_result\">No result.</string>\n\n    <string name=\"settings_main\">Settings</string>\n    <string name=\"category_about\">About</string>\n    <string name=\"set_title_app_version\">Application version</string>\n    <string name=\"settings_license\">Licenses</string>\n    <string name=\"set_title_weibo\">Sina Weibo</string>\n    <string name=\"set_title_weibo_summary\">\\@某燒餅</string>\n    <string name=\"set_title_google_plus\">Google Plus</string>\n    <string name=\"set_title_google_plus_summary\">+Fung Jichun</string>\n    <string name=\"set_title_github\">Github Repo</string>\n    <string name=\"set_title_github_website\">\"https://github.com/fython/NHentai-android\"</string>\n\n</resources>\n"
  },
  {
    "path": "app/src/main/res/values/styles.xml",
    "content": "<resources>\n\n\t<style name=\"Base.Theme.NHBooks.Light\" parent=\"Theme.AppCompat.Light.DarkActionBar\">\n\t\t<item name=\"windowActionBar\">false</item>\n\t\t<item name=\"windowNoTitle\">true</item>\n\t</style>\n\n\t<style name=\"Base.Theme.NHBooks.Dark\" parent=\"Theme.AppCompat\">\n\t\t<item name=\"windowActionBar\">false</item>\n\t\t<item name=\"windowNoTitle\">true</item>\n\t</style>\n\n\t<style name=\"Theme.NHBooks.Light.DarkActionBar\" parent=\"Base.Theme.NHBooks.Light\">\n\t\t<item name=\"windowActionBar\">false</item>\n\t\t<item name=\"windowNoTitle\">true</item>\n\t\t<item name=\"colorPrimary\">@color/deep_purple_500</item>\n\t\t<item name=\"colorPrimaryDark\">@color/deep_purple_800</item>\n\t\t<item name=\"colorAccent\">@color/pink_500</item>\n\t\t<item name=\"colorControlNormal\">@android:color/white</item>\n\t\t<item name=\"android:textColorPrimary\">@android:color/white</item>\n\t</style>\n\n\t<style name=\"Theme.NHBooks.Light.DarkActionBar.Fix\" parent=\"Theme.NHBooks.Light.DarkActionBar\">\n\t\t<item name=\"android:textColorPrimary\">@color/primary_text_default_material_light</item>\n\t</style>\n\n\t<style name=\"Theme.NHBooks.Dark\" parent=\"Base.Theme.NHBooks.Dark\">\n\t\t<item name=\"windowActionBar\">false</item>\n\t\t<item name=\"windowNoTitle\">true</item>\n\t\t<item name=\"colorPrimary\">@color/deep_purple_500</item>\n\t\t<item name=\"colorPrimaryDark\">@color/deep_purple_800</item>\n\t\t<item name=\"colorAccent\">@color/pink_500</item>\n\t\t<item name=\"colorControlNormal\">@android:color/white</item>\n\t\t<item name=\"android:textColorPrimary\">@android:color/white</item>\n\t</style>\n\n\t<style name=\"TextTag\">\n\t\t<item name=\"@android:textSize\">@dimen/tag_text_size</item>\n\t\t<item name=\"@android:textColor\">@android:color/white</item>\n\t\t<item name=\"@android:background\">@color/deep_purple_800</item>\n\t\t<item name=\"@android:ellipsize\">marquee</item>\n\t\t<item name=\"@android:singleLine\">true</item>\n\t\t<item name=\"@android:paddingTop\">4dp</item>\n\t\t<item name=\"@android:paddingBottom\">4dp</item>\n\t\t<item name=\"@android:paddingLeft\">8dp</item>\n\t\t<item name=\"@android:paddingRight\">8dp</item>\n\t</style>\n\n</resources>\n"
  },
  {
    "path": "app/src/main/res/values-v21/styles.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n\t<style name=\"Base.Theme.NHBooks.Light\" parent=\"Theme.AppCompat.Light.DarkActionBar\">\n\t\t<item name=\"windowActionBar\">false</item>\n\t\t<item name=\"windowNoTitle\">true</item>\n\t\t<item name=\"android:windowDrawsSystemBarBackgrounds\">true</item>\n\t\t<item name=\"android:statusBarColor\">@android:color/transparent</item>\n\t</style>\n\n\t<style name=\"Base.Theme.NHBooks.Dark\" parent=\"Theme.AppCompat\">\n\t\t<item name=\"windowActionBar\">false</item>\n\t\t<item name=\"windowNoTitle\">true</item>\n\t\t<item name=\"android:windowDrawsSystemBarBackgrounds\">true</item>\n\t\t<item name=\"android:statusBarColor\">@android:color/transparent</item>\n\t</style>\n\n</resources>"
  },
  {
    "path": "app/src/main/res/values-zh-rCN/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n    <string name=\"app_name\">NH 本子</string>\n    <string name=\"action_settings\">设置</string>\n    <string name=\"action_search\">搜索</string>\n\n    <string name=\"item_home\">主页</string>\n    <string name=\"item_tag\">标签</string>\n    <string name=\"item_character\">人物</string>\n\n    <string name=\"title_page_latest\">最新</string>\n    <string name=\"title_page_download\">已保存的本子</string>\n    <string name=\"title_page_favorite\">我的收藏</string>\n    <string-array name=\"page_titles\">\n        <item>@string/title_page_latest</item>\n        <item>@string/title_page_download</item>\n        <item>@string/title_page_favorite</item>\n    </string-array>\n    <string name=\"tips_network_error\">无法连接到 NHentai。</string>\n    <string name=\"snack_action_try_again\">重试</string>\n\n    <string name=\"activity_details\">详情</string>\n    <string name=\"tag_type_tag\">标签:</string>\n    <string name=\"tag_type_parodies\">作品:</string>\n    <string name=\"tag_type_language\">语言:</string>\n    <string name=\"tag_type_characters\">人物:</string>\n    <string name=\"tag_type_artists\">画家:</string>\n    <string name=\"tag_type_group\">组别:</string>\n    <string name=\"tag_type_upload_time\">上传时间:</string>\n\n    <string name=\"activity_gallery\">图库</string>\n\n    <string name=\"activity_search_result\">搜索结果</string>\n    <string name=\"title_search_result\">搜索结果: %s</string>\n    <string name=\"tips_no_result\">没有结果。</string>\n\n    <string name=\"settings_main\">设置</string>\n    <string name=\"category_about\">关于</string>\n    <string name=\"set_title_app_version\">应用程序版本</string>\n    <string name=\"settings_license\">开源项目许可协议</string>\n    <string name=\"set_title_weibo\">新浪微博</string>\n    <string name=\"set_title_weibo_summary\">\\@某燒餅</string>\n    <string name=\"set_title_google_plus\">Google+</string>\n    <string name=\"set_title_google_plus_summary\">+Fung Jichun</string>\n    <string name=\"set_title_github\">Github 开源项目</string>\n    <string name=\"set_title_github_website\">\"https://github.com/fython/NHentai-android\"</string>\n\n</resources>\n"
  },
  {
    "path": "app/src/main/res/values-zh-rTW/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n    <string name=\"app_name\">NH 本子</string>\n    <string name=\"action_settings\">設置</string>\n    <string name=\"action_search\">搜尋</string>\n\n    <string name=\"item_home\">主頁</string>\n    <string name=\"item_tag\">標籤</string>\n    <string name=\"item_character\">角色</string>\n\n    <string name=\"title_page_latest\">最新</string>\n    <string name=\"title_page_download\">已儲存的本子</string>\n    <string name=\"title_page_favorite\">我的最愛</string>\n    <string-array name=\"page_titles\">\n        <item>@string/title_page_latest</item>\n        <item>@string/title_page_download</item>\n        <item>@string/title_page_favorite</item>\n    </string-array>\n    <string name=\"tips_network_error\">無法連接到 NHentai。</string>\n    <string name=\"snack_action_try_again\">重試</string>\n\n    <string name=\"activity_details\">詳情</string>\n    <string name=\"tag_type_tag\">標籤:</string>\n    <string name=\"tag_type_parodies\">作品:</string>\n    <string name=\"tag_type_language\">語言:</string>\n    <string name=\"tag_type_characters\">角色:</string>\n    <string name=\"tag_type_artists\">畫家:</string>\n    <string name=\"tag_type_group\">組別:</string>\n    <string name=\"tag_type_upload_time\">上載時間:</string>\n\n    <string name=\"activity_gallery\">畫廊</string>\n\n    <string name=\"activity_search_result\">搜尋結果</string>\n    <string name=\"title_search_result\">搜尋結果: %s</string>\n    <string name=\"tips_no_result\">沒有結果。</string>\n\n    <string name=\"settings_main\">設置</string>\n    <string name=\"category_about\">關於</string>\n    <string name=\"set_title_app_version\">應用程式版本</string>\n    <string name=\"settings_license\">開源項目許可協議</string>\n    <string name=\"set_title_weibo\">新浪微博</string>\n    <string name=\"set_title_weibo_summary\">\\@某燒餅</string>\n    <string name=\"set_title_google_plus\">Google+</string>\n    <string name=\"set_title_google_plus_summary\">+Fung Jichun</string>\n    <string name=\"set_title_github\">Github 開源項目</string>\n    <string name=\"set_title_github_website\">\"https://github.com/fython/NHentai-android\"</string>\n\n</resources>\n"
  },
  {
    "path": "app/src/main/res/xml/settings_main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<PreferenceScreen xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n\t<PreferenceCategory android:key=\"about\" android:title=\"@string/category_about\">\n\n\t\t<moe.feng.nhentai.view.pref.Preference\n\t\t\tandroid:key=\"version\"\n\t\t    android:title=\"@string/set_title_app_version\"/>\n\n\t\t<moe.feng.nhentai.view.pref.Preference\n\t\t\tandroid:key=\"license\"\n\t\t    android:title=\"@string/settings_license\"/>\n\n\t\t<moe.feng.nhentai.view.pref.Preference\n\t\t\tandroid:key=\"github\"\n\t\t    android:title=\"@string/set_title_github\"\n\t\t    android:summary=\"@string/set_title_github_website\"/>\n\n\t\t<moe.feng.nhentai.view.pref.Preference\n\t\t\tandroid:key=\"google_plus\"\n\t\t    android:title=\"@string/set_title_google_plus\"\n\t\t    android:summary=\"@string/set_title_google_plus_summary\"/>\n\n\t\t<moe.feng.nhentai.view.pref.Preference\n\t\t\tandroid:key=\"weibo\"\n\t\t    android:title=\"@string/set_title_weibo\"\n\t\t    android:summary=\"@string/set_title_weibo_summary\"/>\n\n\t</PreferenceCategory>\n\n</PreferenceScreen>"
  },
  {
    "path": "build.gradle",
    "content": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n\trepositories {\n\t\tjcenter()\n\t}\n\tdependencies {\n\t\tclasspath 'com.android.tools.build:gradle:1.1.0'\n\n\t\t// NOTE: Do not place your application dependencies here; they belong\n\t\t// in the individual module build.gradle files\n\t}\n}\n\nallprojects {\n\trepositories {\n\t\tjcenter()\n\t}\n}\n"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "#Wed May 27 13:24:38 CST 2015\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-2.2-all.zip\n"
  },
  {
    "path": "gradle.properties",
    "content": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will override*\n# any settings specified in this file.\n\n# For more details on how to configure your build environment visit\n# http://www.gradle.org/docs/current/userguide/build_environment.html\n\n# Specifies the JVM arguments used for the daemon process.\n# The setting is particularly useful for tweaking memory settings.\n# Default value: -Xmx10248m -XX:MaxPermSize=256m\n# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8\n\n# When configured, Gradle will run in incubating parallel mode.\n# This option should only be used with decoupled projects. More details, visit\n# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects\n# org.gradle.parallel=true"
  },
  {
    "path": "gradlew",
    "content": "#!/usr/bin/env bash\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS=\"\"\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn ( ) {\n    echo \"$*\"\n}\n\ndie ( ) {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\nesac\n\n# For Cygwin, ensure paths are in UNIX format before anything is touched.\nif $cygwin ; then\n    [ -n \"$JAVA_HOME\" ] && JAVA_HOME=`cygpath --unix \"$JAVA_HOME\"`\nfi\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >&-\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >&-\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin, switch paths to Windows format before running java\nif $cygwin ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=$((i+1))\n    done\n    case $i in\n        (0) set -- ;;\n        (1) set -- \"$args0\" ;;\n        (2) set -- \"$args0\" \"$args1\" ;;\n        (3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        (4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        (5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        (6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        (7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        (8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        (9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules\nfunction splitJvmOpts() {\n    JVM_OPTS=(\"$@\")\n}\neval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS\nJVM_OPTS[${#JVM_OPTS[*]}]=\"-Dorg.gradle.appname=$APP_BASE_NAME\"\n\nexec \"$JAVACMD\" \"${JVM_OPTS[@]}\" -classpath \"$CLASSPATH\" org.gradle.wrapper.GradleWrapperMain \"$@\"\n"
  },
  {
    "path": "gradlew.bat",
    "content": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem  Gradle startup script for Windows\n@rem\n@rem ##########################################################################\n\n@rem Set local scope for the variables with windows NT shell\nif \"%OS%\"==\"Windows_NT\" setlocal\n\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nset DEFAULT_JVM_OPTS=\n\nset DIRNAME=%~dp0\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\nset APP_BASE_NAME=%~n0\nset APP_HOME=%DIRNAME%\n\n@rem Find java.exe\nif defined JAVA_HOME goto findJavaFromJavaHome\n\nset JAVA_EXE=java.exe\n%JAVA_EXE% -version >NUL 2>&1\nif \"%ERRORLEVEL%\" == \"0\" goto init\n\necho.\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:findJavaFromJavaHome\nset JAVA_HOME=%JAVA_HOME:\"=%\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\n\nif exist \"%JAVA_EXE%\" goto init\n\necho.\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:init\n@rem Get command-line arguments, handling Windowz variants\n\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\nif \"%@eval[2+2]\" == \"4\" goto 4NT_args\n\n:win9xME_args\n@rem Slurp the command line arguments.\nset CMD_LINE_ARGS=\nset _SKIP=2\n\n:win9xME_args_slurp\nif \"x%~1\" == \"x\" goto execute\n\nset CMD_LINE_ARGS=%*\ngoto execute\n\n:4NT_args\n@rem Get arguments from the 4NT Shell from JP Software\nset CMD_LINE_ARGS=%$\n\n:execute\n@rem Setup the command line\n\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\n\n@rem Execute Gradle\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\n\n:end\n@rem End local scope for the variables with windows NT shell\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\n\n:fail\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\nrem the _cmd.exe /c_ return code!\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\nexit /b 1\n\n:mainEnd\nif \"%OS%\"==\"Windows_NT\" endlocal\n\n:omega\n"
  },
  {
    "path": "libraries/PersistentSearch/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "libraries/PersistentSearch/build.gradle",
    "content": "apply plugin: 'com.android.library'\n\nandroid {\n    compileSdkVersion 22\n    buildToolsVersion \"22.0.1\"\n\n    defaultConfig {\n        minSdkVersion 11\n        targetSdkVersion 22\n        versionCode 1\n        versionName \"1.0\"\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n    lintOptions {\n        abortOnError false\n    }\n\n}\n\ndependencies {\n    compile fileTree(dir: 'libs', include: ['*.jar'])\n    compile 'com.nineoldandroids:library:2.4.0+'\n    compile 'com.android.support:appcompat-v7:22.2.0'\n}\n"
  },
  {
    "path": "libraries/PersistentSearch/gradle.properties",
    "content": "POM_NAME=Persistent Search\nPOM_ARTIFACT_ID=library\nPOM_PACKAGING=aar"
  },
  {
    "path": "libraries/PersistentSearch/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in C:/Users/Kieron/Android/adt-bundle-windows-x86_64-20140702/adt-bundle-windows-x86_64-20140702/sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n"
  },
  {
    "path": "libraries/PersistentSearch/src/main/AndroidManifest.xml",
    "content": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.quinny898.library.persistentsearch\">\n\n    <application android:allowBackup=\"true\">\n\n    </application>\n\n</manifest>\n"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/com/balysv/materialmenu/MaterialMenu.java",
    "content": "/*\n * Copyright (C) 2014 Balys Valentukevicius\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.balysv.materialmenu;\n\nimport android.view.animation.Interpolator;\n\nimport com.nineoldandroids.animation.Animator;\n\nimport static com.balysv.materialmenu.MaterialMenuDrawable.IconState;\n\n/**\n * API for interaction with {@link MaterialMenuDrawable}\n */\npublic interface MaterialMenu {\n    /**\n     * Change icon without animation\n     *\n     * @param state new icon state\n     */\n    public void setState(IconState state);\n\n    /**\n     * Return current icon state\n     *\n     * @return icon state\n     */\n    public IconState getState();\n\n    /**\n     * Animate icon to given state.\n     *\n     * @param state new icon state\n     */\n    public void animateState(IconState state);\n\n    /**\n     * Animate icon to given state and draw touch circle\n     *\n     * @param state new icon state\n     */\n    public void animatePressedState(IconState state);\n\n    /**\n     * Set color of icon\n     *\n     * @param color new icon color\n     */\n    public void setColor(int color);\n\n    /**\n     * Set duration of transformation animations\n     *\n     * @param duration new animation duration\n     */\n    public void setTransformationDuration(int duration);\n\n    /**\n     * Set duration of pressed state circle animation\n     *\n     * @param duration new animation duration\n     */\n    public void setPressedDuration(int duration);\n\n    /**\n     * Set interpolator for transformation animations\n     *\n     * @param interpolator new interpolator\n     */\n    public void setInterpolator(Interpolator interpolator);\n\n    /**\n     * Set listener for {@code MaterialMenuDrawable} animation events\n     *\n     * @param listener new listener or null to remove any listener\n     */\n    public void setAnimationListener(Animator.AnimatorListener listener);\n\n    /**\n     * Enable RTL layout. Flips all icons horizontally\n     *\n     * @param rtlEnabled true to enable RTL layout\n     */\n    public void setRTLEnabled(boolean rtlEnabled);\n\n    /**\n     * Manually set a transformation value for an {@link com.balysv.materialmenu.MaterialMenuDrawable.AnimationState}\n     *\n     * @param animationState state to set value in\n     * @param value          between {@link com.balysv.materialmenu.MaterialMenuDrawable#TRANSFORMATION_START} and\n     *                       {@link com.balysv.materialmenu.MaterialMenuDrawable#TRANSFORMATION_END}.\n     */\n    public void setTransformationOffset(MaterialMenuDrawable.AnimationState animationState, float value);\n\n    /**\n     * @return {@link MaterialMenuDrawable} to be used for the menu\n     */\n    public MaterialMenuDrawable getDrawable();\n}\n"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/com/balysv/materialmenu/MaterialMenuDrawable.java",
    "content": "/*\n * Copyright (C) 2014 Balys Valentukevicius\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.balysv.materialmenu;\n\n\nimport android.content.Context;\nimport android.content.res.Resources;\nimport android.graphics.Canvas;\nimport android.graphics.Color;\nimport android.graphics.ColorFilter;\nimport android.graphics.Paint;\nimport android.graphics.PixelFormat;\nimport android.graphics.drawable.Animatable;\nimport android.graphics.drawable.Drawable;\nimport android.util.TypedValue;\nimport android.view.animation.DecelerateInterpolator;\nimport android.view.animation.Interpolator;\n\nimport com.nineoldandroids.animation.Animator;\nimport com.nineoldandroids.animation.AnimatorListenerAdapter;\nimport com.nineoldandroids.animation.ObjectAnimator;\nimport com.nineoldandroids.util.Property;\n\nimport static android.graphics.Paint.Style;\nimport static com.nineoldandroids.animation.Animator.AnimatorListener;\n\n\npublic class MaterialMenuDrawable extends Drawable implements Animatable {\n\n    public enum IconState {\n        BURGER, ARROW, X, CHECK\n    }\n\n    public enum AnimationState {\n        BURGER_ARROW, BURGER_X, ARROW_X, ARROW_CHECK, BURGER_CHECK, X_CHECK;\n\n        public IconState getFirstState() {\n            switch (this) {\n                case BURGER_ARROW:\n                    return IconState.BURGER;\n                case BURGER_X:\n                    return IconState.BURGER;\n                case ARROW_X:\n                    return IconState.ARROW;\n                case ARROW_CHECK:\n                    return IconState.ARROW;\n                case BURGER_CHECK:\n                    return IconState.BURGER;\n                case X_CHECK:\n                    return IconState.X;\n                default:\n                    return null;\n            }\n        }\n\n        public IconState getSecondState() {\n            switch (this) {\n                case BURGER_ARROW:\n                    return IconState.ARROW;\n                case BURGER_X:\n                    return IconState.X;\n                case ARROW_X:\n                    return IconState.X;\n                case ARROW_CHECK:\n                    return IconState.CHECK;\n                case BURGER_CHECK:\n                    return IconState.CHECK;\n                case X_CHECK:\n                    return IconState.CHECK;\n                default:\n                    return null;\n            }\n        }\n    }\n\n    public enum Stroke {\n        /**\n         * 3 dip\n         */\n        REGULAR(3),\n        /**\n         * 2 dip\n         */\n        THIN(2),\n        /**\n         * 1 dip\n         */\n        EXTRA_THIN(1);\n\n        private final int strokeWidth;\n\n        Stroke(int strokeWidth) {\n            this.strokeWidth = strokeWidth;\n        }\n\n        protected static Stroke valueOf(int strokeWidth) {\n            switch (strokeWidth) {\n                case 3:\n                    return REGULAR;\n                case 2:\n                    return THIN;\n                case 1:\n                    return EXTRA_THIN;\n                default:\n                    return THIN;\n            }\n        }\n    }\n\n    public static final int DEFAULT_COLOR              = Color.WHITE;\n    public static final int DEFAULT_SCALE              = 1;\n    public static final int DEFAULT_TRANSFORM_DURATION = 800;\n    public static final int DEFAULT_PRESSED_DURATION   = 400;\n\n    private static final int BASE_DRAWABLE_WIDTH  = 40;\n    private static final int BASE_DRAWABLE_HEIGHT = 40;\n    private static final int BASE_ICON_WIDTH      = 20;\n    private static final int BASE_CIRCLE_RADIUS   = 18;\n\n    private static final float ARROW_MID_LINE_ANGLE = 180;\n    private static final float ARROW_TOP_LINE_ANGLE = 135;\n    private static final float ARROW_BOT_LINE_ANGLE = 225;\n    private static final float X_TOP_LINE_ANGLE     = 44;\n    private static final float X_BOT_LINE_ANGLE     = -44;\n    private static final float X_ROTATION_ANGLE     = 90;\n    private static final float CHECK_MIDDLE_ANGLE   = 135;\n    private static final float CHECK_BOTTOM_ANGLE   = -90;\n\n    private static final float TRANSFORMATION_START = 0;\n    private static final float TRANSFORMATION_MID   = 1.0f;\n    private static final float TRANSFORMATION_END   = 2.0f;\n\n    private static final int DEFAULT_CIRCLE_ALPHA = 200;\n\n    private final float diph;\n    private final float dip1;\n    private final float dip2;\n    private final float dip3;\n    private final float dip4;\n    private final float dip6;\n    private final float dip8;\n\n    private final int   width;\n    private final int   height;\n    private final float strokeWidth;\n    private final float iconWidth;\n    private final float topPadding;\n    private final float sidePadding;\n    private final float circleRadius;\n\n    private final Stroke stroke;\n\n    private final Object lock = new Object();\n\n    private final Paint iconPaint   = new Paint();\n    private final Paint circlePaint = new Paint();\n\n    private float   transformationValue   = 0f;\n    private float   pressedProgressValue  = 0f;\n    private boolean transformationRunning = false;\n\n    private IconState      currentIconState = IconState.BURGER;\n    private AnimationState animationState   = AnimationState.BURGER_ARROW;\n\n    private IconState animatingIconState;\n    private boolean   drawTouchCircle;\n    private boolean   neverDrawTouch;\n    private boolean   rtlEnabled;\n\n    private ObjectAnimator   transformation;\n    private ObjectAnimator   pressedCircle;\n    private AnimatorListener animatorListener;\n\n    private MaterialMenuState materialMenuState;\n\n    public MaterialMenuDrawable(Context context, int color, Stroke stroke) {\n        this(context, color, stroke, DEFAULT_SCALE, DEFAULT_TRANSFORM_DURATION, DEFAULT_PRESSED_DURATION);\n    }\n\n    public MaterialMenuDrawable(Context context, int color, Stroke stroke, int transformDuration, int pressedDuration) {\n        this(context, color, stroke, DEFAULT_SCALE, transformDuration, pressedDuration);\n    }\n\n    public MaterialMenuDrawable(Context context, int color, Stroke stroke, int scale, int transformDuration, int pressedDuration) {\n        Resources resources = context.getResources();\n        // convert each separately due to various densities\n        this.dip1 = dpToPx(resources, 1) * scale;\n        this.dip2 = dpToPx(resources, 2) * scale;\n        this.dip3 = dpToPx(resources, 3) * scale;\n        this.dip4 = dpToPx(resources, 4) * scale;\n        this.dip6 = dpToPx(resources, 6) * scale;\n        this.dip8 = dpToPx(resources, 8) * scale;\n        this.diph = dip1 / 2;\n\n        this.stroke = stroke;\n        this.width = (int) (dpToPx(resources, BASE_DRAWABLE_WIDTH) * scale);\n        this.height = (int) (dpToPx(resources, BASE_DRAWABLE_HEIGHT) * scale);\n        this.iconWidth = dpToPx(resources, BASE_ICON_WIDTH) * scale;\n        this.circleRadius = dpToPx(resources, BASE_CIRCLE_RADIUS) * scale;\n        this.strokeWidth = dpToPx(resources, stroke.strokeWidth) * scale;\n\n        this.sidePadding = (width - iconWidth) / 2;\n        this.topPadding = (height - 5 * dip3) / 2;\n\n        initPaint(color);\n        initAnimations(transformDuration, pressedDuration);\n\n        materialMenuState = new MaterialMenuState();\n    }\n\n    private MaterialMenuDrawable(int color, Stroke stroke, long transformDuration, long pressedDuration,\n        int width, int height, float iconWidth, float circleRadius, float strokeWidth, float dip1\n    ) {\n        this.dip1 = dip1;\n        this.dip2 = dip1 * 2;\n        this.dip3 = dip1 * 3;\n        this.dip4 = dip1 * 4;\n        this.dip6 = dip1 * 6;\n        this.dip8 = dip1 * 8;\n        this.diph = dip1 / 2;\n        this.stroke = stroke;\n        this.width = width;\n        this.height = height;\n        this.iconWidth = iconWidth;\n        this.circleRadius = circleRadius;\n        this.strokeWidth = strokeWidth;\n        this.sidePadding = (width - iconWidth) / 2;\n        this.topPadding = (height - 5 * dip3) / 2;\n\n        initPaint(color);\n        initAnimations((int) transformDuration, (int) pressedDuration);\n\n        materialMenuState = new MaterialMenuState();\n    }\n\n    private void initPaint(int color) {\n        iconPaint.setAntiAlias(true);\n        iconPaint.setStyle(Style.STROKE);\n        iconPaint.setStrokeWidth(strokeWidth);\n        iconPaint.setColor(color);\n\n        circlePaint.setAntiAlias(true);\n        circlePaint.setStyle(Style.FILL);\n        circlePaint.setColor(color);\n        circlePaint.setAlpha(DEFAULT_CIRCLE_ALPHA);\n\n        setBounds(0, 0, width, height);\n    }\n\n    /*\n     * Drawing\n     */\n\n    @Override public void draw(Canvas canvas) {\n        final float ratio = transformationValue <= 1 ? transformationValue : 2 - transformationValue;\n\n        if (rtlEnabled) {\n            canvas.save();\n            canvas.scale(-1, 1, 0, 0);\n            canvas.translate(-getIntrinsicWidth(), 0);\n        }\n\n        drawTopLine(canvas, ratio);\n        drawMiddleLine(canvas, ratio);\n        drawBottomLine(canvas, ratio);\n\n        if (rtlEnabled) {\n            canvas.restore();\n        }\n\n        if (drawTouchCircle) drawTouchCircle(canvas);\n    }\n\n    private void drawTouchCircle(Canvas canvas) {\n        canvas.restore();\n        canvas.drawCircle(width / 2, height / 2, pressedProgressValue, circlePaint);\n    }\n\n    private void drawMiddleLine(Canvas canvas, float ratio) {\n        canvas.restore();\n        canvas.save();\n\n        float rotation = 0;\n        float pivotX = width / 2;\n        float pivotY = width / 2;\n        float startX = sidePadding;\n        float startY = topPadding + dip3 / 2 * 5;\n        float stopX = width - sidePadding;\n        float stopY = topPadding + dip3 / 2 * 5;\n        int alpha = 255;\n\n        switch (animationState) {\n            case BURGER_ARROW:\n                // rotate by 180\n                if (isMorphingForward()) {\n                    rotation = ratio * ARROW_MID_LINE_ANGLE;\n                } else {\n                    rotation = ARROW_MID_LINE_ANGLE + (1 - ratio) * ARROW_MID_LINE_ANGLE;\n                }\n                // shorten one end\n                stopX -= ratio * resolveStrokeModifier(ratio) / 2;\n                break;\n            case BURGER_X:\n                // fade out\n                alpha = (int) ((1 - ratio) * 255);\n                break;\n            case ARROW_X:\n                // fade out and shorten one end\n                alpha = (int) ((1 - ratio) * 255);\n                startX += (1 - ratio) * dip2;\n                break;\n            case ARROW_CHECK:\n                if (isMorphingForward()) {\n                    // rotate until required angle\n                    rotation = ratio * CHECK_MIDDLE_ANGLE;\n                } else {\n                    // rotate back to starting angle\n                    rotation = CHECK_MIDDLE_ANGLE - CHECK_MIDDLE_ANGLE * (1 - ratio);\n                }\n                // shorten one end and lengthen the other\n                startX += dip3 / 2 + dip4 - (1 - ratio) * dip2;\n                stopX += ratio * dip1;\n                pivotX = width / 2 + dip3 + diph;\n                break;\n            case BURGER_CHECK:\n                // rotate until required angle\n                rotation = ratio * CHECK_MIDDLE_ANGLE;\n                // lengthen both ends\n                startX += ratio * (dip4 + dip3 / 2);\n                stopX += ratio * dip1;\n                pivotX = width / 2 + dip3 + diph;\n                break;\n            case X_CHECK:\n                // fade in\n                alpha = (int) (ratio * 255);\n                // rotation to check angle\n                rotation = ratio * CHECK_MIDDLE_ANGLE;\n                // lengthen both ends\n                startX += ratio * (dip4 + dip3 / 2);\n                stopX += ratio * dip1;\n                pivotX = width / 2 + dip3 + diph;\n                break;\n        }\n\n        iconPaint.setAlpha(alpha);\n        canvas.rotate(rotation, pivotX, pivotY);\n        canvas.drawLine(startX, startY, stopX, stopY, iconPaint);\n        iconPaint.setAlpha(255);\n    }\n\n    private void drawTopLine(Canvas canvas, float ratio) {\n        canvas.save();\n\n        float rotation = 0, pivotX = 0, pivotY = 0;\n        float rotation2 = 0;\n        // pivot at center of line\n        float pivotX2 = width / 2 + dip3 / 2;\n        float pivotY2 = topPadding + dip2;\n\n        float startX = sidePadding;\n        float startY = topPadding + dip2;\n        float stopX = width - sidePadding;\n        float stopY = topPadding + dip2;\n        int alpha = 255;\n\n        switch (animationState) {\n            case BURGER_ARROW:\n                if (isMorphingForward()) {\n                    // rotate until required angle\n                    rotation = ratio * ARROW_BOT_LINE_ANGLE;\n                } else {\n                    // rotate back to start doing a 360\n                    rotation = ARROW_BOT_LINE_ANGLE + (1 - ratio) * ARROW_TOP_LINE_ANGLE;\n                }\n                // rotate by middle\n                pivotX = width / 2;\n                pivotY = height / 2;\n\n                // shorten both ends\n                stopX -= resolveStrokeModifier(ratio);\n                startX += dip3 * ratio;\n\n                break;\n            case BURGER_X:\n                // rotate until required angles\n                rotation = X_TOP_LINE_ANGLE * ratio;\n                rotation2 = X_ROTATION_ANGLE * ratio;\n\n                // pivot at left corner of line\n                pivotX = sidePadding + dip4;\n                pivotY = topPadding + dip3;\n\n                // shorten one end\n                startX += dip3 * ratio;\n                break;\n            case ARROW_X:\n                // rotate from ARROW angle to X angle\n                rotation = ARROW_BOT_LINE_ANGLE + (X_TOP_LINE_ANGLE - ARROW_BOT_LINE_ANGLE) * ratio;\n                rotation2 = X_ROTATION_ANGLE * ratio;\n\n                // move pivot from ARROW pivot to X pivot\n                pivotX = width / 2 + (sidePadding + dip4 - width / 2) * ratio;\n                pivotY = height / 2 + (topPadding + dip3 - height / 2) * ratio;\n\n                // lengthen both ends\n                stopX -= resolveStrokeModifier(ratio);\n                startX += dip3;\n                break;\n            case ARROW_CHECK:\n                // fade out\n                alpha = (int) ((1 - ratio) * 255);\n                // retain starting arrow configuration\n                rotation = ARROW_BOT_LINE_ANGLE;\n                pivotX = width / 2;\n                pivotY = height / 2;\n\n                // shorted both ends\n                stopX -= resolveStrokeModifier(1);\n                startX += dip3;\n                break;\n            case BURGER_CHECK:\n                // fade out\n                alpha = (int) ((1 - ratio) * 255);\n                break;\n            case X_CHECK:\n                // retain X configuration\n                rotation = X_TOP_LINE_ANGLE;\n                rotation2 = X_ROTATION_ANGLE;\n                pivotX = sidePadding + dip4;\n                pivotY = topPadding + dip3;\n                stopX += dip3 - dip3 * (1 - ratio);\n                startX += dip3;\n\n                // fade out\n                alpha = (int) ((1 - ratio) * 255);\n                break;\n        }\n\n        iconPaint.setAlpha(alpha);\n        canvas.rotate(rotation, pivotX, pivotY);\n        canvas.rotate(rotation2, pivotX2, pivotY2);\n        canvas.drawLine(startX, startY, stopX, stopY, iconPaint);\n        iconPaint.setAlpha(255);\n    }\n\n    private void drawBottomLine(Canvas canvas, float ratio) {\n        canvas.restore();\n        canvas.save();\n\n        float rotation = 0, pivotX = 0, pivotY = 0;\n        float rotation2 = 0;\n        // pivot at center of line\n        float pivotX2 = width / 2 + dip3 / 2;\n        float pivotY2 = height - topPadding - dip2;\n\n        float startX = sidePadding;\n        float startY = height - topPadding - dip2;\n        float stopX = width - sidePadding;\n        float stopY = height - topPadding - dip2;\n\n        switch (animationState) {\n            case BURGER_ARROW:\n                if (isMorphingForward()) {\n                    // rotate to required angle\n                    rotation = ARROW_TOP_LINE_ANGLE * ratio;\n                } else {\n                    // rotate back to start doing a 360\n                    rotation = ARROW_TOP_LINE_ANGLE + (1 - ratio) * ARROW_BOT_LINE_ANGLE;\n                }\n                // pivot center of canvas\n                pivotX = width / 2;\n                pivotY = height / 2;\n\n                // shorten both ends\n                stopX = width - sidePadding - resolveStrokeModifier(ratio);\n                startX = sidePadding + dip3 * ratio;\n                break;\n            case BURGER_X:\n                if (isMorphingForward()) {\n                    // rotate around\n                    rotation2 = -X_ROTATION_ANGLE * ratio;\n                } else {\n                    // rotate directly\n                    rotation2 = X_ROTATION_ANGLE * ratio;\n                }\n                // rotate to required angle\n                rotation = X_BOT_LINE_ANGLE * ratio;\n\n                // pivot left corner of line\n                pivotX = sidePadding + dip4;\n                pivotY = height - topPadding - dip3;\n\n                // shorten one end\n                startX += dip3 * ratio;\n                break;\n            case ARROW_X:\n                // rotate from ARROW angle to X angle\n                rotation = ARROW_TOP_LINE_ANGLE + (360 + X_BOT_LINE_ANGLE - ARROW_TOP_LINE_ANGLE) * ratio;\n                rotation2 = -X_ROTATION_ANGLE * ratio;\n\n                // move pivot from ARROW pivot to X pivot\n                pivotX = width / 2 + (sidePadding + dip4 - width / 2) * ratio;\n                pivotY = height / 2 + (height / 2 - topPadding - dip3) * ratio;\n\n                // lengthen both ends\n                stopX -= resolveStrokeModifier(ratio);\n                startX += dip3;\n                break;\n            case ARROW_CHECK:\n                // rotate from ARROW angle to CHECK angle\n                rotation = ARROW_TOP_LINE_ANGLE + ratio * CHECK_BOTTOM_ANGLE;\n\n                // move pivot from ARROW pivot to CHECK pivot\n                pivotX = width / 2 + dip3 * ratio;\n                pivotY = height / 2 - dip3 * ratio;\n\n                // length stays same as ARROW\n                stopX -= resolveStrokeModifier(1);\n                startX += dip3 + (dip4 + dip1) * ratio;\n                break;\n            case BURGER_CHECK:\n                // rotate from ARROW angle to CHECK angle\n                rotation = ratio * (CHECK_BOTTOM_ANGLE + ARROW_TOP_LINE_ANGLE);\n\n                // move pivot from BURGER pivot to CHECK pivot\n                pivotX = width / 2 + dip3 * ratio;\n                pivotY = height / 2 - dip3 * ratio;\n\n                // length stays same as BURGER\n                startX += dip8 * ratio;\n                stopX -= resolveStrokeModifier(ratio);\n                break;\n            case X_CHECK:\n                // rotate from X to CHECK angles\n                rotation2 = -X_ROTATION_ANGLE * (1 - ratio);\n                rotation = X_BOT_LINE_ANGLE + (CHECK_BOTTOM_ANGLE + ARROW_TOP_LINE_ANGLE - X_BOT_LINE_ANGLE) * ratio;\n\n                // move pivot from X to CHECK\n                pivotX = sidePadding + dip4 + (width / 2 + dip3 - sidePadding - dip4) * ratio;\n                pivotY = height - topPadding - dip3 + (topPadding + height / 2 - height) * ratio;\n\n                // shorten both ends\n                startX += dip8 - (dip4 + dip1) * (1 - ratio);\n                stopX -= resolveStrokeModifier(1 - ratio);\n                break;\n        }\n\n        canvas.rotate(rotation, pivotX, pivotY);\n        canvas.rotate(rotation2, pivotX2, pivotY2);\n        canvas.drawLine(startX, startY, stopX, stopY, iconPaint);\n    }\n\n    private boolean isMorphingForward() {\n        return transformationValue <= TRANSFORMATION_MID;\n    }\n\n    private float resolveStrokeModifier(float ratio) {\n        switch (stroke) {\n            case REGULAR:\n                if (animationState == AnimationState.ARROW_X || animationState == AnimationState.X_CHECK) {\n                    return dip3 - (dip3 * ratio);\n                }\n                return ratio * dip3;\n            case THIN:\n                if (animationState == AnimationState.ARROW_X || animationState == AnimationState.X_CHECK) {\n                    return dip3 + diph - (dip3 + diph) * ratio;\n                }\n                return ratio * (dip3 + diph);\n            case EXTRA_THIN:\n                if (animationState == AnimationState.ARROW_X || animationState == AnimationState.X_CHECK) {\n                    return dip4 - ((dip3 + dip1) * ratio);\n                }\n                return ratio * dip4;\n        }\n        return 0;\n    }\n\n    @Override public void setAlpha(int alpha) {\n        iconPaint.setAlpha(alpha);\n    }\n\n    @Override public void setColorFilter(ColorFilter cf) {\n        iconPaint.setColorFilter(cf);\n    }\n\n    @Override public int getOpacity() {\n        return PixelFormat.TRANSPARENT;\n    }\n\n    /*\n     * Accessor methods\n     */\n\n    public void setColor(int color) {\n        iconPaint.setColor(color);\n        circlePaint.setColor(color);\n        invalidateSelf();\n    }\n\n    public void setTransformationDuration(int duration) {\n        transformation.setDuration(duration);\n    }\n\n    public void setPressedDuration(int duration) {\n        pressedCircle.setDuration(duration);\n    }\n\n    public void setInterpolator(Interpolator interpolator) {\n        transformation.setInterpolator(interpolator);\n    }\n\n    public void setAnimationListener(AnimatorListener listener) {\n        if (animatorListener != null) {\n            transformation.removeListener(animatorListener);\n        }\n\n        if (listener != null) {\n            transformation.addListener(listener);\n        }\n\n        animatorListener = listener;\n    }\n\n    public void setNeverDrawTouch(boolean neverDrawTouch) {\n        this.neverDrawTouch = neverDrawTouch;\n    }\n\n    public void setIconState(IconState iconState) {\n        synchronized (lock) {\n            if (transformationRunning) {\n                transformation.cancel();\n                transformationRunning = false;\n            }\n\n            if (currentIconState == iconState) return;\n\n            switch (iconState) {\n                case BURGER:\n                    animationState = AnimationState.BURGER_ARROW;\n                    transformationValue = TRANSFORMATION_START;\n                    break;\n                case ARROW:\n                    animationState = AnimationState.BURGER_ARROW;\n                    transformationValue = TRANSFORMATION_MID;\n                    break;\n                case X:\n                    animationState = AnimationState.BURGER_X;\n                    transformationValue = TRANSFORMATION_MID;\n                    break;\n                case CHECK:\n                    animationState = AnimationState.BURGER_CHECK;\n                    transformationValue = TRANSFORMATION_MID;\n            }\n            currentIconState = iconState;\n            invalidateSelf();\n        }\n    }\n\n    public void animateIconState(IconState state, boolean drawTouch) {\n        synchronized (lock) {\n            if (transformationRunning) {\n                transformation.end();\n                pressedCircle.end();\n            }\n            drawTouchCircle = drawTouch;\n            animatingIconState = state;\n            start();\n        }\n    }\n\n    public IconState setTransformationOffset(AnimationState animationState, float offset) {\n        if (offset < TRANSFORMATION_START || offset > TRANSFORMATION_END) {\n            throw new IllegalArgumentException(\n                String.format(\"Value must be between %s and %s\", TRANSFORMATION_START, TRANSFORMATION_END)\n            );\n        }\n\n        this.animationState = animationState;\n\n        final boolean isFirstIcon = offset < TRANSFORMATION_MID || offset == TRANSFORMATION_END;\n\n        currentIconState = isFirstIcon ? animationState.getFirstState() : animationState.getSecondState();\n        animatingIconState = isFirstIcon ? animationState.getSecondState() : animationState.getFirstState();\n\n        setTransformationValue(offset);\n\n        return currentIconState;\n    }\n\n    public void setRTLEnabled(boolean rtlEnabled) {\n        this.rtlEnabled = rtlEnabled;\n        invalidateSelf();\n    }\n\n    public IconState getIconState() {\n        return currentIconState;\n    }\n\n    /*\n     * Animations\n     */\n    private Property<MaterialMenuDrawable, Float> transformationProperty\n        = new Property<MaterialMenuDrawable, Float>(Float.class, \"transformation\") {\n        @Override\n        public Float get(MaterialMenuDrawable object) {\n            return object.getTransformationValue();\n        }\n\n        @Override\n        public void set(MaterialMenuDrawable object, Float value) {\n            object.setTransformationValue(value);\n        }\n    };\n\n    private Property<MaterialMenuDrawable, Float> pressedProgressProperty\n        = new Property<MaterialMenuDrawable, Float>(Float.class, \"pressedProgress\") {\n        @Override\n        public Float get(MaterialMenuDrawable object) {\n            return object.getPressedProgress();\n        }\n\n        @Override\n        public void set(MaterialMenuDrawable object, Float value) {\n            object.setPressedProgress(value);\n        }\n    };\n\n    public Float getTransformationValue() {\n        return transformationValue;\n    }\n\n    public void setTransformationValue(Float value) {\n        this.transformationValue = value;\n        invalidateSelf();\n    }\n\n    public Float getPressedProgress() {\n        return pressedProgressValue;\n    }\n\n    public void setPressedProgress(Float value) {\n        this.pressedProgressValue = value;\n        circlePaint.setAlpha((int) (DEFAULT_CIRCLE_ALPHA * (1 - value / (circleRadius * 1.22f))));\n        invalidateSelf();\n    }\n\n    private void initAnimations(int transformDuration, int pressedDuration) {\n        transformation = ObjectAnimator.ofFloat(this, transformationProperty, 0);\n        transformation.setInterpolator(new DecelerateInterpolator(3));\n        transformation.setDuration(transformDuration);\n        transformation.addListener(new AnimatorListenerAdapter() {\n            @Override public void onAnimationEnd(Animator animation) {\n                transformationRunning = false;\n                setIconState(animatingIconState);\n            }\n        });\n\n\n        pressedCircle = ObjectAnimator.ofFloat(this, pressedProgressProperty, 0, 0);\n        pressedCircle.setDuration(pressedDuration);\n        pressedCircle.setInterpolator(new DecelerateInterpolator());\n        pressedCircle.addListener(new AnimatorListenerAdapter() {\n            @Override public void onAnimationEnd(Animator animation) {\n                pressedProgressValue = 0;\n            }\n\n            @Override public void onAnimationCancel(Animator animation) {\n                pressedProgressValue = 0;\n            }\n        });\n    }\n\n    private boolean resolveTransformation() {\n        boolean isCurrentBurger = currentIconState == IconState.BURGER;\n        boolean isCurrentArrow = currentIconState == IconState.ARROW;\n        boolean isCurrentX = currentIconState == IconState.X;\n        boolean isCurrentCheck = currentIconState == IconState.CHECK;\n        boolean isAnimatingBurger = animatingIconState == IconState.BURGER;\n        boolean isAnimatingArrow = animatingIconState == IconState.ARROW;\n        boolean isAnimatingX = animatingIconState == IconState.X;\n        boolean isAnimatingCheck = animatingIconState == IconState.CHECK;\n\n        if ((isCurrentBurger && isAnimatingArrow) || (isCurrentArrow && isAnimatingBurger)) {\n            animationState = AnimationState.BURGER_ARROW;\n            return isCurrentBurger;\n        }\n\n        if ((isCurrentArrow && isAnimatingX) || (isCurrentX && isAnimatingArrow)) {\n            animationState = AnimationState.ARROW_X;\n            return isCurrentArrow;\n        }\n\n        if ((isCurrentBurger && isAnimatingX) || (isCurrentX && isAnimatingBurger)) {\n            animationState = AnimationState.BURGER_X;\n            return isCurrentBurger;\n        }\n\n        if ((isCurrentArrow && isAnimatingCheck) || (isCurrentCheck && isAnimatingArrow)) {\n            animationState = AnimationState.ARROW_CHECK;\n            return isCurrentArrow;\n        }\n\n        if ((isCurrentBurger && isAnimatingCheck) || (isCurrentCheck && isAnimatingBurger)) {\n            animationState = AnimationState.BURGER_CHECK;\n            return isCurrentBurger;\n        }\n\n        if ((isCurrentX && isAnimatingCheck) || (isCurrentCheck && isAnimatingX)) {\n            animationState = AnimationState.X_CHECK;\n            return isCurrentX;\n        }\n\n        throw new IllegalStateException(\n            String.format(\"Animating from %s to %s is not supported\", currentIconState, animatingIconState)\n        );\n    }\n\n    @Override public void start() {\n        if (transformationRunning) return;\n\n        if (animatingIconState != null && animatingIconState != currentIconState) {\n            transformationRunning = true;\n\n            final boolean direction = resolveTransformation();\n            transformation.setFloatValues(\n                direction ? TRANSFORMATION_START : TRANSFORMATION_MID,\n                direction ? TRANSFORMATION_MID : TRANSFORMATION_END\n            );\n            transformation.start();\n        }\n\n        if (pressedCircle.isRunning()) {\n            pressedCircle.cancel();\n        }\n        if (drawTouchCircle && !neverDrawTouch) {\n            pressedCircle.setFloatValues(0, circleRadius * 1.22f);\n            pressedCircle.start();\n        }\n\n        invalidateSelf();\n    }\n\n    @Override public void stop() {\n        if (isRunning() && transformation.isRunning()) {\n            transformation.end();\n        } else {\n            transformationRunning = false;\n            invalidateSelf();\n        }\n    }\n\n    @Override public boolean isRunning() {\n        return transformationRunning;\n    }\n\n    @Override\n    public int getIntrinsicWidth() {\n        return width;\n    }\n\n    @Override\n    public int getIntrinsicHeight() {\n        return height;\n    }\n\n\n    @Override\n    public ConstantState getConstantState() {\n        materialMenuState.changingConfigurations = getChangingConfigurations();\n        return materialMenuState;\n    }\n\n    @Override\n    public Drawable mutate() {\n        materialMenuState = new MaterialMenuState();\n        return this;\n    }\n\n    private final class MaterialMenuState extends ConstantState {\n        private int changingConfigurations;\n\n        private MaterialMenuState() {\n        }\n\n        @Override\n        public Drawable newDrawable() {\n            MaterialMenuDrawable drawable = new MaterialMenuDrawable(\n                circlePaint.getColor(), stroke, transformation.getDuration(),\n                pressedCircle.getDuration(), width, height, iconWidth, circleRadius, strokeWidth, dip1\n            );\n            drawable.setIconState(animatingIconState != null ? animatingIconState : currentIconState);\n            drawable.setRTLEnabled(rtlEnabled);\n            return drawable;\n        }\n\n        @Override\n        public int getChangingConfigurations() {\n            return changingConfigurations;\n        }\n    }\n\n    static float dpToPx(Resources resources, float dp) {\n        return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics());\n    }\n}\n"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/com/balysv/materialmenu/MaterialMenuView.java",
    "content": "/*\n * Copyright (C) 2014 Balys Valentukevicius\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.balysv.materialmenu;\n\nimport android.content.Context;\nimport android.content.res.TypedArray;\nimport android.graphics.Canvas;\nimport android.graphics.drawable.Drawable;\nimport android.os.Build;\nimport android.os.Parcel;\nimport android.os.Parcelable;\nimport android.util.AttributeSet;\nimport android.view.View;\nimport android.view.animation.Interpolator;\n\nimport com.nineoldandroids.animation.Animator;\n\nimport com.quinny898.library.persistentsearch.R;\n\nimport static com.balysv.materialmenu.MaterialMenuDrawable.DEFAULT_COLOR;\nimport static com.balysv.materialmenu.MaterialMenuDrawable.DEFAULT_PRESSED_DURATION;\nimport static com.balysv.materialmenu.MaterialMenuDrawable.DEFAULT_SCALE;\nimport static com.balysv.materialmenu.MaterialMenuDrawable.DEFAULT_TRANSFORM_DURATION;\nimport static com.balysv.materialmenu.MaterialMenuDrawable.IconState;\nimport static com.balysv.materialmenu.MaterialMenuDrawable.Stroke;\n\n/**\n * A basic View wrapper of {@link com.balysv.materialmenu.MaterialMenuDrawable}. Used\n * for custom view ActionBar or other layouts\n */\npublic class MaterialMenuView extends View implements MaterialMenu {\n\n    private MaterialMenuDrawable drawable;\n\n    private IconState currentState = IconState.BURGER;\n\n    public MaterialMenuView(Context context) {\n        this(context, null);\n    }\n\n    public MaterialMenuView(Context context, AttributeSet attrs) {\n        this(context, attrs, 0);\n    }\n\n    public MaterialMenuView(Context context, AttributeSet attrs, int defStyleAttr) {\n        super(context, attrs, defStyleAttr);\n        init(context, attrs);\n    }\n\n    private void init(Context context, AttributeSet attributeSet) {\n        TypedArray attr = getTypedArray(context, attributeSet, R.styleable.MaterialMenuView);\n\n        try {\n            int color = attr.getColor(R.styleable.MaterialMenuView_mm_color, DEFAULT_COLOR);\n            int scale = attr.getInteger(R.styleable.MaterialMenuView_mm_scale, DEFAULT_SCALE);\n            int transformDuration = attr.getInteger(R.styleable.MaterialMenuView_mm_transformDuration, DEFAULT_TRANSFORM_DURATION);\n            int pressedDuration = attr.getInteger(R.styleable.MaterialMenuView_mm_pressedDuration, DEFAULT_PRESSED_DURATION);\n            Stroke stroke = Stroke.valueOf(attr.getInteger(R.styleable.MaterialMenuView_mm_strokeWidth, 0));\n            boolean rtlEnabled = attr.getBoolean(R.styleable.MaterialMenuView_mm_rtlEnabled, false);\n\n            drawable = new MaterialMenuDrawable(context, color, stroke, scale, transformDuration, pressedDuration);\n            drawable.setRTLEnabled(rtlEnabled);\n        } finally {\n            attr.recycle();\n        }\n\n        drawable.setCallback(this);\n    }\n\n    @Override\n    public void draw(Canvas canvas) {\n        super.draw(canvas);\n        if (getPaddingLeft() != 0 || getPaddingTop() != 0) {\n            int saveCount = canvas.getSaveCount();\n            canvas.save();\n            canvas.translate(getPaddingLeft(), getPaddingTop());\n            drawable.draw(canvas);\n            canvas.restoreToCount(saveCount);\n        } else {\n            drawable.draw(canvas);\n        }\n    }\n\n    @Override\n    public void setPadding(int left, int top, int right, int bottom) {\n        super.setPadding(left, top, right, bottom);\n        adjustDrawablePadding();\n    }\n\n    @Override\n    protected boolean verifyDrawable(Drawable who) {\n        return who == drawable || super.verifyDrawable(who);\n    }\n\n    @Override\n    public void setState(IconState state) {\n        currentState = state;\n        drawable.setIconState(state);\n    }\n\n    @Override\n    public IconState getState() {\n        return drawable.getIconState();\n    }\n\n    @Override\n    public void animateState(IconState state) {\n        currentState = state;\n        drawable.animateIconState(state, false);\n    }\n\n    @Override\n    public void animatePressedState(IconState state) {\n        currentState = state;\n        drawable.animateIconState(state, true);\n    }\n\n    @Override\n    public void setColor(int color) {\n        drawable.setColor(color);\n    }\n\n    @Override\n    public void setTransformationDuration(int duration) {\n        drawable.setTransformationDuration(duration);\n    }\n\n    @Override\n    public void setPressedDuration(int duration) {\n        drawable.setPressedDuration(duration);\n    }\n\n    @Override\n    public void setInterpolator(Interpolator interpolator) {\n        drawable.setInterpolator(interpolator);\n    }\n\n    @Override\n    public void setAnimationListener(Animator.AnimatorListener listener) {\n        drawable.setAnimationListener(listener);\n    }\n\n    @Override\n    public void setRTLEnabled(boolean rtlEnabled) {\n        drawable.setRTLEnabled(rtlEnabled);\n    }\n\n    @Override\n    public void setTransformationOffset(MaterialMenuDrawable.AnimationState animationState, float value) {\n        currentState = drawable.setTransformationOffset(animationState, value);\n    }\n\n    @Override\n    public MaterialMenuDrawable getDrawable() {\n        return drawable;\n    }\n\n    @Override\n    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {\n        int paddingX = getPaddingLeft() + getPaddingRight();\n        int paddingY = getPaddingTop() + getPaddingBottom();\n\n        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {\n            widthMeasureSpec = MeasureSpec.makeMeasureSpec(drawable.getIntrinsicWidth() + paddingX, MeasureSpec.EXACTLY);\n            heightMeasureSpec = MeasureSpec.makeMeasureSpec(drawable.getIntrinsicHeight() + paddingY, MeasureSpec.EXACTLY);\n            setMeasuredDimension(widthMeasureSpec, heightMeasureSpec);\n        } else {\n            setMeasuredDimension(drawable.getIntrinsicWidth() + paddingX, drawable.getIntrinsicHeight() + paddingY);\n        }\n    }\n\n    @Override\n    protected void onSizeChanged(int w, int h, int oldw, int oldh) {\n        super.onSizeChanged(w, h, oldw, oldh);\n        adjustDrawablePadding();\n    }\n\n    @Override\n    public Parcelable onSaveInstanceState() {\n        Parcelable superState = super.onSaveInstanceState();\n        SavedState savedState = new SavedState(superState);\n        savedState.state = currentState;\n        return savedState;\n    }\n\n    @Override\n    public void onRestoreInstanceState(Parcelable state) {\n        SavedState savedState = (SavedState) state;\n        super.onRestoreInstanceState(savedState.getSuperState());\n        setState(savedState.state);\n    }\n\n    private void adjustDrawablePadding() {\n        if (drawable != null) {\n            drawable.setBounds(\n                0, 0,\n                drawable.getIntrinsicWidth() + getPaddingLeft() + getPaddingRight(),\n                drawable.getIntrinsicHeight() + getPaddingTop() + getPaddingBottom()\n            );\n        }\n    }\n\n    private TypedArray getTypedArray(Context context, AttributeSet attributeSet, int[] attr) {\n        return context.obtainStyledAttributes(attributeSet, attr, 0, 0);\n    }\n\n    private static class SavedState extends BaseSavedState {\n        protected IconState state;\n\n        SavedState(Parcelable superState) {\n            super(superState);\n        }\n\n        private SavedState(Parcel in) {\n            super(in);\n            state = IconState.valueOf(in.readString());\n        }\n\n        @Override\n        public void writeToParcel(Parcel out, int flags) {\n            super.writeToParcel(out, flags);\n            out.writeString(state.name());\n        }\n\n        public static final Creator<SavedState> CREATOR = new Creator<SavedState>() {\n            @Override\n            public SavedState createFromParcel(Parcel in) {\n                return new SavedState(in);\n            }\n\n            @Override\n            public SavedState[] newArray(int size) {\n                return new SavedState[size];\n            }\n        };\n    }\n}\n"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java",
    "content": "package com.quinny898.library.persistentsearch;\n\nimport android.animation.LayoutTransition;\nimport android.app.Activity;\nimport android.app.Fragment;\nimport android.content.Context;\nimport android.content.Intent;\nimport android.content.pm.PackageManager;\nimport android.content.pm.ResolveInfo;\nimport android.content.res.Resources;\nimport android.graphics.Point;\nimport android.graphics.drawable.Drawable;\nimport android.os.Build;\nimport android.speech.RecognizerIntent;\nimport android.text.Editable;\nimport android.text.InputFilter;\nimport android.text.TextUtils;\nimport android.text.TextWatcher;\nimport android.util.AttributeSet;\nimport android.util.TypedValue;\nimport android.view.Display;\nimport android.view.KeyEvent;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\nimport android.view.animation.AccelerateDecelerateInterpolator;\nimport android.view.animation.Animation;\nimport android.view.animation.AnimationUtils;\nimport android.view.inputmethod.EditorInfo;\nimport android.view.inputmethod.InputMethodManager;\nimport android.widget.AdapterView;\nimport android.widget.AdapterView.OnItemClickListener;\nimport android.widget.ArrayAdapter;\nimport android.widget.EditText;\nimport android.widget.FrameLayout;\nimport android.widget.ImageView;\nimport android.widget.ListView;\nimport android.widget.ProgressBar;\nimport android.widget.RelativeLayout;\nimport android.widget.TextView;\nimport android.widget.TextView.OnEditorActionListener;\n\nimport com.balysv.materialmenu.MaterialMenuDrawable.IconState;\nimport com.balysv.materialmenu.MaterialMenuView;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport io.codetail.animation.ReverseInterpolator;\nimport io.codetail.animation.SupportAnimator;\nimport io.codetail.animation.ViewAnimationUtils;\n\npublic class SearchBox extends RelativeLayout {\n\n\tpublic static final int VOICE_RECOGNITION_CODE = 1234;\n\n\tprivate MaterialMenuView materialMenu;\n\tprivate TextView logo;\n\tprivate EditText search;\n\tprivate Context context;\n\tprivate ListView results;\n\tprivate ArrayList<SearchResult> resultList;\n\tprivate ArrayList<SearchResult> searchables;\n\tprivate boolean searchOpen;\n\tprivate boolean animate;\n\tprivate View tint;\n\tprivate boolean isMic;\n\tprivate ImageView mic;\n\tprivate ImageView drawerLogo;\n\tprivate SearchListener listener;\n\tprivate MenuListener menuListener;\n\tprivate FrameLayout rootLayout;\n\tprivate String logoText;\n\tprivate ProgressBar pb;\n\tprivate ArrayList<SearchResult> initialResults;\n\tprivate boolean searchWithoutSuggestions = true;\n\n\tprivate boolean isVoiceRecognitionIntentSupported;\n\tprivate VoiceRecognitionListener voiceRecognitionListener;\n\tprivate Activity mContainerActivity;\n\tprivate Fragment mContainerFragment;\n\tprivate android.support.v4.app.Fragment mContainerSupportFragment;\n\n\n\t/**\n\t * Create a new searchbox\n\t * @param context Context\n\t */\n\tpublic SearchBox(Context context) {\n\t\tthis(context, null);\n\t}\n\n\t/**\n\t * Create a searchbox with params\n\t * @param context Context\n\t * @param attrs Attributes\n\t */\n\tpublic SearchBox(Context context, AttributeSet attrs) {\n\t\tthis(context, attrs, 0);\n\t}\n\t\n\t/**\n\t * Create a searchbox with params and a style\n\t * @param context Context\n\t * @param attrs Attributes\n\t * @param defStyle Style\n\t */\n\tpublic SearchBox(Context context, AttributeSet attrs, int defStyle) {\n\t\tsuper(context, attrs, defStyle);\n\t\tinflate(context, R.layout.searchbox, this);\n\t\tthis.searchOpen = false;\n\t\tthis.isMic = true;\n\t\tthis.materialMenu = (MaterialMenuView) findViewById(R.id.material_menu_button);\n\t\tthis.logo = (TextView) findViewById(R.id.logo);\n\t\tthis.search = (EditText) findViewById(R.id.search);\n\t\tthis.results = (ListView) findViewById(R.id.results);\n\t\tthis.context = context;\n\t\tthis.pb = (ProgressBar) findViewById(R.id.pb);\n\t\tthis.mic = (ImageView) findViewById(R.id.mic);\n\t\tthis.drawerLogo = (ImageView) findViewById(R.id.drawer_logo);\n\t\tmaterialMenu.setOnClickListener(new OnClickListener() {\n\n\t\t\t@Override\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tif (searchOpen) {\n\t\t\t\t\ttoggleSearch();\n\t\t\t\t} else {\n\t\t\t\t\tif (menuListener != null)\n\t\t\t\t\t\tmenuListener.onMenuClick();\n\t\t\t\t}\n\t\t\t}\n\n\t\t});\n\t\tresultList = new ArrayList<SearchResult>();\n\t\tresults.setAdapter(new SearchAdapter(context, resultList));\n\t\tanimate = true;\n\t\tisVoiceRecognitionIntentSupported = isIntentAvailable(context, new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH));\n\t\tlogo.setOnClickListener(new OnClickListener() {\n\n\t\t\t@Override\n\t\t\tpublic void onClick(View v) {\n\t\t\t\ttoggleSearch();\n\t\t\t}\n\n\t\t});\n\t\tif(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){\n\t\t\tRelativeLayout searchRoot = (RelativeLayout) findViewById(R.id.search_root);\n\t\t\tLayoutTransition lt = new LayoutTransition();\n\t\t\tlt.setDuration(100);\n\t\t\tsearchRoot.setLayoutTransition(lt);\n\t\t}\n\t\tsearchables = new ArrayList<SearchResult>();\n\t\tsearch.setOnEditorActionListener(new OnEditorActionListener() {\n\t\t\tpublic boolean onEditorAction(TextView v, int actionId,\n\t\t\t\t\tKeyEvent event) {\n\t\t\t\tif (actionId == EditorInfo.IME_ACTION_SEARCH) {\n\t\t\t\t\tsearch(getSearchText());\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t\tsearch.setOnKeyListener(new OnKeyListener() {\n\t\t\tpublic boolean onKey(View v, int keyCode, KeyEvent event) {\n\t\t\t\tif (keyCode == KeyEvent.KEYCODE_ENTER) {\n\t\t\t\t\tif (TextUtils.isEmpty(getSearchText())) {\n\t\t\t\t\t\ttoggleSearch();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsearch(getSearchText());\n\t\t\t\t\t}\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t\tlogoText = \"Logo\";\n\t\tmicStateChanged();\n\t\tmic.setOnClickListener(new OnClickListener() {\n\t\t\t@Override\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tif (voiceRecognitionListener != null) {\n\t\t\t\t\tvoiceRecognitionListener.onClick();\n\t\t\t\t} else {\n\t\t\t\t\tmicClick();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tpublic boolean isSearchOpened() {\n\t\treturn searchOpen;\n\t}\n\n\tprivate static boolean isIntentAvailable(Context context, Intent intent) {\n\t\tPackageManager mgr = context.getPackageManager();\n\t\tList<ResolveInfo> list = mgr.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);\n\t\treturn list.size() > 0;\n\t}\n\t\n\t/***\n\t * Reveal the searchbox from a menu item. Specify the menu item id and pass the activity so the item can be found\n\t * @param id View ID\n\t * @param activity Activity\n\t */\n\tpublic void revealFromMenuItem(int id, Activity activity) {\n\t\tsetVisibility(View.VISIBLE);\n\t\tView menuButton = activity.findViewById(id);\n\t\tif (menuButton != null) {\n\t\t\tFrameLayout layout = (FrameLayout) activity.getWindow().getDecorView()\n\t\t\t\t\t.findViewById(android.R.id.content);\n\t\t\tif (layout.findViewWithTag(\"searchBox\") == null) {\n\t\t\t\tint[] location = new int[2];\n\t\t\t\tmenuButton.getLocationInWindow(location);\n\t\t\t\trevealFrom((float) location[0], (float) location[1],\n\t\t\t\t\t\tactivity, this);\n\t\t\t}\n\t\t}\n\t}\n\t\n\t/***\n\t * Hide the searchbox using the circle animation. Can be called regardless of result list length\n\t * @param activity Activity\n\t */\n\tpublic void hideCircularly(Activity activity){\n\t\tDisplay display = activity.getWindowManager().getDefaultDisplay();\n\t\tPoint size = new Point();\n\t\tfinal FrameLayout layout = (FrameLayout) activity.getWindow().getDecorView()\n\t\t\t\t.findViewById(android.R.id.content);\n\t\tRelativeLayout root = (RelativeLayout) findViewById(R.id.search_root);\n\t\tdisplay.getSize(size);\n\t\tResources r = getResources();\n\t\tfloat px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96,\n\t\t\t\tr.getDisplayMetrics());\n\t\tint cx = layout.getLeft() + layout.getRight();\n\t\tint cy = layout.getTop();\n\t\tint finalRadius = (int) Math.max(layout.getWidth()*1.5, px);\n\n\t\tSupportAnimator animator = ViewAnimationUtils.createCircularReveal(\n\t\t\t\troot, cx, cy, 0, finalRadius);\n\t\tanimator.setInterpolator(new ReverseInterpolator());\n\t\tanimator.setDuration(250);\n\t\tanimator.start();\n\t\tanimator.addListener(new SupportAnimator.AnimatorListener(){\n\n\t\t\t@Override\n\t\t\tpublic void onAnimationStart() {\n\t\t\t\t\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void onAnimationEnd() {\n\t\t\t\tsetVisibility(View.GONE);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void onAnimationCancel() {\n\t\t\t\t\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void onAnimationRepeat() {\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t});\n\t}\n\t\n\t/***\n\t * Toggle the searchbox's open/closed state manually\n\t */\n\tpublic void toggleSearch() {\n\t\tif (searchOpen) {\n\t\t\tif (TextUtils.isEmpty(getSearchText())) {\n\t\t\t\tsetLogoTextInt(logoText);\n\t\t\t}\n\t\t\tcloseSearch();\n\t\t} else {\n\t\t\topenSearch(true);\n\t\t}\n\t\tsearchOpen = !searchOpen;\n\t}\n\t\n\t/***\n\t * Hide the search results manually\n\t */\n\tpublic void hideResults(){\n\t\tthis.search.setVisibility(View.GONE);\n\t\tthis.results.setVisibility(View.GONE);\n\t}\n\t\n\t/***\n\t * Start the voice input activity manually\n\t */\n\tpublic void startVoiceRecognition() {\n\t\tif (isMicEnabled()) {\n\t\t\tIntent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);\n\t\t\tintent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,\n\t\t\t\t\tRecognizerIntent.LANGUAGE_MODEL_FREE_FORM);\n\t\t\tintent.putExtra(RecognizerIntent.EXTRA_PROMPT,\n\t\t\t\t\tcontext.getString(R.string.speak_now));\n\t\t\tif (mContainerActivity != null) {\n\t\t\t\tmContainerActivity.startActivityForResult(intent, VOICE_RECOGNITION_CODE);\n\t\t\t} else if (mContainerFragment != null) {\n\t\t\t\tmContainerFragment.startActivityForResult(intent, VOICE_RECOGNITION_CODE);\n\t\t\t} else if (mContainerSupportFragment != null) {\n\t\t\t\tmContainerSupportFragment.startActivityForResult(intent, VOICE_RECOGNITION_CODE);\n\t\t\t}\n\t\t}\n\t}\n\n\t/***\n\t * Enable voice recognition for Activity\n\t * @param context Context\n\t */\n\tpublic void enableVoiceRecognition(Activity context) {\n\t\tmContainerActivity = context;\n\t\tmicStateChanged();\n\t}\n\n\t/***\n\t * Enable voice recognition for Fragment\n\t * @param context Fragment\n\t */\n\tpublic void enableVoiceRecognition(Fragment context) {\n\t\tmContainerFragment = context;\n\t\tmicStateChanged();\n\t}\n\n\t/***\n\t * Enable voice recognition for Support Fragment\n\t * @param context Fragment\n\t */\n\tpublic void enableVoiceRecognition(android.support.v4.app.Fragment context) {\n\t\tmContainerSupportFragment = context;\n\t\tmicStateChanged();\n\t}\n\n\tprivate boolean isMicEnabled() {\n\t\treturn isVoiceRecognitionIntentSupported && (mContainerActivity != null || mContainerSupportFragment != null || mContainerFragment != null);\n\t}\n\n\tprivate void micStateChanged() {\n\t\tmic.setVisibility((!isMic || isMicEnabled()) ? VISIBLE : INVISIBLE);\n\t}\n\n\tprivate void micStateChanged(boolean isMic) {\n\t\tthis.isMic = isMic;\n\t\tmicStateChanged();\n\t}\n\t\n\t/***\n\t * Set whether to show the progress bar spinner\n\t * @param show Whether to show\n\t */\n\t\n\tpublic void showLoading(boolean show){\n\t\tif(show){\n\t\t\tpb.setVisibility(View.VISIBLE);\n\t\t\tmic.setVisibility(View.INVISIBLE);\n\t\t}else{\n\t\t\tpb.setVisibility(View.INVISIBLE);\n\t\t\tmic.setVisibility(View.VISIBLE);\n\t\t}\n\t}\n\t\n\t/***\n\t * Mandatory method for the onClick event\n\t */\n\tpublic void micClick() {\n\t\tif (!isMic) {\n\t\t\tsetSearchString(\"\");\n\t\t} else {\n\t\t\tstartVoiceRecognition();\n\t\t}\n\n\t}\n\t\n\t/***\n\t * Populate the searchbox with words, in an arraylist. Used by the voice input\n\t * @param matches Matches\n\t */\n\tpublic void populateEditText(ArrayList<String> matches) {\n\t\ttoggleSearch();\n\t\tString text = \"\";\n\t\tfor (int x = 0; x < matches.size(); x++) {\n\t\t\ttext = text + matches.get(x) + \" \";\n\t\t}\n\t\ttext = text.trim();\n\t\tsetSearchString(text);\n\t\tsearch(text);\n\t}\n\t\n\t/***\n\t * Force an update of the results\n\t */\n\tpublic void updateResults() {\n\t\tresultList.clear();\n\t\tint count = 0;\n\t\tfor (int x = 0; x < searchables.size(); x++) {\n\t\t\tif (searchables.get(x).title.toLowerCase().startsWith(\n\t\t\t\t\tgetSearchText().toLowerCase())\n\t\t\t\t\t&& count < 5) {\n\t\t\t\taddResult(searchables.get(x));\n\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t\tif (resultList.size() == 0) {\n\t\t\tresults.setVisibility(View.GONE);\n\t\t} else {\n\t\t\tresults.setVisibility(View.VISIBLE);\n\t\t}\n\n\t}\n\t\n\t/***\n\t * \n\t * Set the results that are shown (up to 5) when the searchbox is opened with no text \n\t * @param results Results\n\t */\n\tpublic void setInitialResults(ArrayList<SearchResult> results){\n\t\tthis.initialResults = results;\n\t}\n\t\n\t/***\n\t * Set whether the menu button should be shown. Particularly useful for apps that adapt to screen sizes\n\t * @param visibility Whether to show\n\t */\n\t\n\tpublic void setMenuVisibility(int visibility){\n\t\tmaterialMenu.setVisibility(visibility);\n\t}\n\t\n\t/***\n\t * Set the menu listener\n\t * @param menuListener MenuListener\n\t */\n\tpublic void setMenuListener(MenuListener menuListener) {\n\t\tthis.menuListener = menuListener;\n\t}\n\t\n\t/***\n\t * Set the search listener\n\t * @param listener SearchListener\n\t */\n\tpublic void setSearchListener(SearchListener listener) {\n\t\tthis.listener = listener;\n\t}\n\t\n\t/***\n\t * Set whether to search without suggestions being available (default is true). Disable if your app only works with provided options\n\t * @param state Whether to show\n\t */\n\tpublic void setSearchWithoutSuggestions(boolean state){\n\t\tthis.searchWithoutSuggestions = state;\n\t}\n\n\t/***\n\t * Set the maximum length of the searchbox's edittext\n\t * @param length Length\n\t */\n\tpublic void setMaxLength(int length) {\n\t\tsearch.setFilters(new InputFilter[] { new InputFilter.LengthFilter(\n\t\t\t\tlength) });\n\t}\n\t\n\t/***\n\t * Set the text of the logo (default text when closed)\n\t * @param text Text\n\t */\n\tpublic void setLogoText(String text) {\n\t\tthis.logoText = text;\n\t\tsetLogoTextInt(text);\n\t}\n\t\n\t/***\n\t * Set the image drawable of the drawer icon logo (do not set if you have not hidden the menu icon)\n\t * @param icon Icon\n\t */\n\tpublic void setDrawerLogo(Drawable icon) {\n\t\tdrawerLogo.setImageDrawable(icon);\n\t}\n\t\n\t/***\n\t * Get the searchbox's current text\n\t * @return Text\n\t */\n\tpublic String getSearchText() {\n\t\treturn search.getText().toString();\n\t}\n\t\n\t/***\n\t * Set the searchbox's current text manually\n\t * @param text Text\n\t */\n\tpublic void setSearchString(String text) {\n\t\tsearch.setText(text);\n\t}\n\t\n\t/***\n\t * Add a result\n\t * @param result SearchResult\n\t */\n\tprivate void addResult(SearchResult result) {\n\t\tif (resultList != null && resultList.size() < 6) {\n\t\t\tresultList.add(result);\n\t\t\t((SearchAdapter) results.getAdapter()).notifyDataSetChanged();\n\t\t}\n\t}\n\t\n\t/***\n\t * Clear all the results\n\t */\n\tpublic void clearResults() {\n\t\tif (resultList != null) {\n\t\t\tresultList.clear();\n\t\t\t((SearchAdapter) results.getAdapter()).notifyDataSetChanged();\n\t\t}\n\t\tlistener.onSearchCleared();\n\t}\n\n\t/***\n\t * Return the number of results that are currently shown\n\t * @return Number of Results\n\t */\n\tpublic int getNumberOfResults() {\n\t\tif (resultList != null)return resultList.size();\n\t\treturn 0;\n\t}\n\t\n\t/***\n\t * Set the searchable items from a list (replaces any current items)\n\t */\n\tpublic void setSearchables(ArrayList<SearchResult> searchables){\n\t\tthis.searchables = searchables;\n\t}\n\n\t/***\n\t * Add a searchable item\n\t * @param searchable SearchResult\n\t */\n\tpublic void addSearchable(SearchResult searchable) {\n\t\tif (!searchables.contains(searchable))\n\t\t\tsearchables.add(searchable);\n\t}\n\n\t/***\n\t * Remove a searchable item\n\t * @param searchable SearchResult\n\t */\n\tpublic void removeSearchable(SearchResult searchable) {\n\t\tif (searchables.contains(searchable))\n\t\t\tsearchables.remove(search);\n\t}\n\n\t/***\n\t * Clear all searchable items\n\t */\n\tpublic void clearSearchable() {\n\t\tsearchables.clear();\n\t}\n\n\t/***\n\t * Get all searchable items\n\t * @return ArrayList of SearchResults\n\t */\n\tpublic ArrayList<SearchResult> getSearchables() {\n\t\treturn searchables;\n\t}\n\n\tprivate void revealFrom(float x, float y, Activity a, SearchBox s) {\n\t\tFrameLayout layout = (FrameLayout) a.getWindow().getDecorView()\n\t\t\t\t.findViewById(android.R.id.content);\n\t\tRelativeLayout root = (RelativeLayout) s.findViewById(R.id.search_root);\n\t\tResources r = getResources();\n\t\tfloat px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96,\n\t\t\t\tr.getDisplayMetrics());\n\t\tint cx = layout.getLeft() + layout.getRight();\n\t\tint cy = layout.getTop();\n\n\t\tint finalRadius = (int) Math.max(layout.getWidth(), px);\n\n\t\tSupportAnimator animator = ViewAnimationUtils.createCircularReveal(\n\t\t\t\troot, cx, cy, 0, finalRadius);\n\t\tanimator.setInterpolator(new AccelerateDecelerateInterpolator());\n\t\tanimator.setDuration(500);\n\t\tanimator.addListener(new SupportAnimator.AnimatorListener(){\n\n\t\t\t@Override\n\t\t\tpublic void onAnimationCancel() {\n\t\t\t\t\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void onAnimationEnd() {\n\t\t\t\ttoggleSearch();\t\t\t\t\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void onAnimationRepeat() {\n\t\t\t\t\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void onAnimationStart() {\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t});\n\t\tanimator.start();\n\t}\n\n\tprivate void search(SearchResult result) {\n\t\tif(!searchWithoutSuggestions && getNumberOfResults() == 0)return;\n\t\tsetSearchString(result.title);\n\t\tif (!TextUtils.isEmpty(getSearchText())) {\n\t\t\tsetLogoTextInt(result.title);\n\t\t\tif (listener != null)\n\t\t\t\tlistener.onSearch(result.title);\n\t\t} else {\n\t\t\tsetLogoTextInt(logoText);\n\t\t}\n\t\ttoggleSearch();\n\t}\n\n\t\n\n\t\n\n\tprivate void openSearch(Boolean openKeyboard) {\n\t\tthis.materialMenu.animateState(IconState.ARROW);\n\t\tthis.logo.setVisibility(View.GONE);\n\t\tthis.drawerLogo.setVisibility(View.GONE);\n\t\tthis.search.setVisibility(View.VISIBLE);\n\t\tsearch.requestFocus();\n\t\tthis.results.setVisibility(View.VISIBLE);\n\t\tanimate = true;\n\t\tresults.setAdapter(new SearchAdapter(context, resultList));\n\t\tsearch.addTextChangedListener(new TextWatcher() {\n\n\t\t\t@Override\n\t\t\tpublic void afterTextChanged(Editable s) {\n\t\t\t\tif (s.length() > 0) {\n\t\t\t\t\tmicStateChanged(false);\n\t\t\t\t\tmic.setImageDrawable(context.getResources().getDrawable(\n\t\t\t\t\t\t\tR.drawable.ic_clear));\n\t\t\t\t\tupdateResults();\n\t\t\t\t} else {\n\t\t\t\t\tmicStateChanged(true);\n\t\t\t\t\tmic.setImageDrawable(context.getResources().getDrawable(\n\t\t\t\t\t\t\tR.drawable.ic_action_mic));\n\t\t\t\t\tif(initialResults != null){\n\t\t\t\t\t\tsetInitialResults();\n\t\t\t\t\t}else{\n\t\t\t\t\t\tupdateResults();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (listener != null)\n\t\t\t\t\tlistener.onSearchTermChanged();\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void beforeTextChanged(CharSequence s, int start, int count,\n\t\t\t\t\tint after) {\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void onTextChanged(CharSequence s, int start, int before,\n\t\t\t\t\tint count) {\n\n\t\t\t}\n\n\t\t});\n\t\tresults.setOnItemClickListener(new OnItemClickListener() {\n\n\t\t\t@Override\n\t\t\tpublic void onItemClick(AdapterView<?> arg0, View arg1, int arg2,\n\t\t\t\t\tlong arg3) {\n\t\t\t\tSearchResult result = resultList.get(arg2);\n\t\t\t\tsearch(result);\n\n\t\t\t}\n\n\t\t});\n\t\tif(initialResults != null){\n\t\t\tsetInitialResults();\n\t\t}else{\n\t\t\tupdateResults();\n\t\t}\n\t\t\n\t\tif (listener != null)\n\t\t\tlistener.onSearchOpened();\n\t\tif (getSearchText().length() > 0) {\n\t\t\tmicStateChanged(false);\n\t\t\tmic.setImageDrawable(context.getResources().getDrawable(\n\t\t\t\t\tR.drawable.ic_clear));\n\t\t}\n\t\tif (openKeyboard) {\n\t\t\tInputMethodManager inputMethodManager = (InputMethodManager) context\n\t\t\t\t\t.getSystemService(Context.INPUT_METHOD_SERVICE);\n\t\t\tinputMethodManager.toggleSoftInputFromWindow(\n\t\t\t\t\tgetApplicationWindowToken(),\n\t\t\t\t\tInputMethodManager.SHOW_FORCED, 0);\n\t\t}\n\t}\n\t\n\tprivate void setInitialResults(){\n\t\tresultList.clear();\n\t\tint count = 0;\n\t\tfor (int x = 0; x < initialResults.size(); x++) {\n\t\t\tif (count < 5) {\n\t\t\t\taddResult(initialResults.get(x));\n\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t\tif (resultList.size() == 0) {\n\t\t\tresults.setVisibility(View.GONE);\n\t\t} else {\n\t\t\tresults.setVisibility(View.VISIBLE);\n\t\t}\n\t}\n\n\t\n\n\t\n\n\tprivate void closeSearch() {\n\t\tthis.materialMenu.animateState(IconState.BURGER);\n\t\tthis.logo.setVisibility(View.VISIBLE);\n\t\tthis.drawerLogo.setVisibility(View.VISIBLE);\n\t\tthis.search.setVisibility(View.GONE);\n\t\tthis.results.setVisibility(View.GONE);\n\t\tif (tint != null && rootLayout != null) {\n\t\t\trootLayout.removeView(tint);\n\t\t}\n\t\tif (listener != null)\n\t\t\tlistener.onSearchClosed();\n\t\tmicStateChanged(true);\n\t\tmic.setImageDrawable(context.getResources().getDrawable(\n\t\t\t\tR.drawable.ic_action_mic));\n\t\tInputMethodManager inputMethodManager = (InputMethodManager) context\n\t\t\t\t.getSystemService(Context.INPUT_METHOD_SERVICE);\n\t\tinputMethodManager.hideSoftInputFromWindow(getApplicationWindowToken(),\n\t\t\t\t0);\n\t}\n\n\t\n\n\t\n\n\tprivate void setLogoTextInt(String text) {\n\t\tlogo.setText(text);\n\t}\n\n\t\n\t\n\t\n\n\tprivate void search(String text) {\n\t\tSearchResult option = new SearchResult(text, null);\n\t\tsearch(option);\n\t\t\n\t}\n\n\t\n\n\tclass SearchAdapter extends ArrayAdapter<SearchResult> {\n\t\tpublic SearchAdapter(Context context, ArrayList<SearchResult> options) {\n\t\t\tsuper(context, 0, options);\n\t\t}\n\n\t\tint count = 0;\n\n\t\t@Override\n\t\tpublic View getView(int position, View convertView, ViewGroup parent) {\n\t\t\tSearchResult option = getItem(position);\n\t\t\tif (convertView == null) {\n\t\t\t\tconvertView = LayoutInflater.from(getContext()).inflate(\n\t\t\t\t\t\tR.layout.search_option, parent, false);\n\n\t\t\t\tif (animate) {\n\t\t\t\t\tAnimation anim = AnimationUtils.loadAnimation(context,\n\t\t\t\t\t\t\tR.anim.anim_down);\n\t\t\t\t\tanim.setDuration(400);\n\t\t\t\t\tconvertView.startAnimation(anim);\n\t\t\t\t\tif (count == this.getCount()) {\n\t\t\t\t\t\tanimate = false;\n\t\t\t\t\t}\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tView border = convertView.findViewById(R.id.border);\n\t\t\tif (position == 0) {\n\t\t\t\tborder.setVisibility(View.VISIBLE);\n\t\t\t} else {\n\t\t\t\tborder.setVisibility(View.GONE);\n\t\t\t}\n\t\t\tfinal TextView title = (TextView) convertView\n\t\t\t\t\t.findViewById(R.id.title);\n\t\t\ttitle.setText(option.title);\n\t\t\tImageView icon = (ImageView) convertView.findViewById(R.id.icon);\n\t\t\tif (option.icon != null) {\n\t\t\t\ticon.setImageDrawable(option.icon);\n\t\t\t} else {\n\t\t\t\ticon.setImageResource(option.drawableResId);\n\t\t\t}\n\t\t\tImageView up = (ImageView) convertView.findViewById(R.id.up);\n\t\t\tup.setOnClickListener(new OnClickListener() {\n\n\t\t\t\t@Override\n\t\t\t\tpublic void onClick(View v) {\n\t\t\t\t\tsetSearchString(title.getText().toString());\n\t\t\t\t\tsearch.setSelection(search.getText().length());\n\t\t\t\t}\n\n\t\t\t});\n\n\t\t\treturn convertView;\n\t\t}\n\t}\n\n\tpublic interface SearchListener {\n\t\t/**\n\t\t * Called when the searchbox is opened\n\t\t */\n\t\tpublic void onSearchOpened();\n\n\t\t/**\n\t\t * Called when the clear button is pressed\n\t\t */\n\t\tpublic void onSearchCleared();\n\n\t\t/**\n\t\t * Called when the searchbox is closed\n\t\t */\n\t\tpublic void onSearchClosed();\n\n\t\t/**\n\t\t * Called when the searchbox's edittext changes\n\t\t */\n\t\tpublic void onSearchTermChanged();\n\n\t\t/**\n\t\t * Called when a search happens, with a result\n\t\t * @param result\n\t\t */\n\t\tpublic void onSearch(String result);\n\t}\n\n\tpublic interface MenuListener {\n\t\t/**\n\t\t * Called when the menu button is pressed\n\t\t */\n\t\tpublic void onMenuClick();\n\t}\n\n\tpublic interface VoiceRecognitionListener {\n\t\t/**\n\t\t * Called when the menu button is pressed\n\t\t */\n\t\tpublic void onClick();\n\t}\n\n}\n"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/com/quinny898/library/persistentsearch/SearchResult.java",
    "content": "package com.quinny898.library.persistentsearch;\n\nimport android.graphics.drawable.Drawable;\nimport android.support.annotation.DrawableRes;\n\npublic class SearchResult {\n\n    public String title;\n    public Drawable icon;\n    public int drawableResId;\n\n    /**\n     * Create a search result with text and an icon\n     * @param title\n     * @param icon\n     */\n    public SearchResult(String title, Drawable icon) {\n       this.title = title;\n       this.icon = icon;\n    }\n\n    public SearchResult(String title, @DrawableRes int drawableResId) {\n        this.title = title;\n        this.drawableResId = drawableResId;\n    }\n    \n    /**\n     * Return the title of the result\n     */\n    @Override\n    public String toString() {\n        return title;\n    }\n    \n}"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/io/codetail/animation/RevealAnimator.java",
    "content": "package io.codetail.animation;\n\nimport android.annotation.TargetApi;\nimport android.graphics.Rect;\nimport android.os.Build;\nimport android.view.View;\n\nimport com.nineoldandroids.animation.Animator;\n\nimport java.lang.ref.WeakReference;\n\nimport static io.codetail.animation.ViewAnimationUtils.SimpleAnimationListener;\n\n/**\n * @hide\n */\npublic interface RevealAnimator{\n\n    public void setClipOutlines(boolean clip);\n\n    public void setCenter(float cx, float cy);\n\n    public void setTarget(View target);\n\n    public void setRevealRadius(float value);\n\n    public float getRevealRadius();\n\n    public void invalidate(Rect bounds);\n\n    static class RevealFinishedGingerbread extends SimpleAnimationListener {\n        WeakReference<RevealAnimator> mReference;\n        volatile Rect mInvalidateBounds;\n\n        RevealFinishedGingerbread(RevealAnimator target, Rect bounds) {\n            mReference = new WeakReference<>(target);\n            mInvalidateBounds = bounds;\n        }\n\n        @Override\n        public void onAnimationEnd(Animator animation) {\n            super.onAnimationEnd(animation);\n\n            RevealAnimator target = mReference.get();\n\n            if(target == null){\n                return;\n            }\n\n            target.setClipOutlines(false);\n            target.setCenter(0, 0);\n            target.setTarget(null);\n            target.invalidate(mInvalidateBounds);\n        }\n    }\n\n    static class RevealFinishedIceCreamSandwich extends SimpleAnimationListener {\n        WeakReference<RevealAnimator> mReference;\n        volatile Rect mInvalidateBounds;\n\n        int mLayerType;\n\n        @TargetApi(Build.VERSION_CODES.HONEYCOMB)\n        RevealFinishedIceCreamSandwich(RevealAnimator target, Rect bounds) {\n            mReference = new WeakReference<>(target);\n            mInvalidateBounds = bounds;\n\n            mLayerType = ((View) target).getLayerType();\n        }\n\n        @Override\n        @TargetApi(Build.VERSION_CODES.HONEYCOMB)\n        public void onAnimationStart(Animator animation) {\n            super.onAnimationStart(animation);\n            ((View) mReference.get()).setLayerType(View.LAYER_TYPE_SOFTWARE, null);\n        }\n\n        @Override\n        @TargetApi(Build.VERSION_CODES.HONEYCOMB)\n        public void onAnimationEnd(Animator animation) {\n            super.onAnimationEnd(animation);\n            ((View) mReference.get()).setLayerType(mLayerType, null);\n\n            RevealAnimator target = mReference.get();\n\n            if(target == null){\n                return;\n            }\n\n            target.setClipOutlines(false);\n            target.setCenter(0, 0);\n            target.setTarget(null);\n            target.invalidate(mInvalidateBounds);\n        }\n    }\n\n    static class RevealFinishedJellyBeanMr1 extends SimpleAnimationListener {\n        WeakReference<RevealAnimator> mReference;\n        volatile Rect mInvalidateBounds;\n\n        int mLayerType;\n\n        @TargetApi(Build.VERSION_CODES.HONEYCOMB)\n        RevealFinishedJellyBeanMr1(RevealAnimator target, Rect bounds) {\n            mReference = new WeakReference<>(target);\n            mInvalidateBounds = bounds;\n\n            mLayerType = ((View) target).getLayerType();\n        }\n\n        @Override\n        @TargetApi(Build.VERSION_CODES.HONEYCOMB)\n        public void onAnimationStart(Animator animation) {\n            super.onAnimationStart(animation);\n            ((View) mReference.get()).setLayerType(View.LAYER_TYPE_HARDWARE, null);\n        }\n\n        @Override\n        @TargetApi(Build.VERSION_CODES.HONEYCOMB)\n        public void onAnimationEnd(Animator animation) {\n            super.onAnimationEnd(animation);\n            ((View) mReference.get()).setLayerType(mLayerType, null);\n\n            RevealAnimator target = mReference.get();\n\n            if(target == null){\n                return;\n            }\n\n            target.setClipOutlines(false);\n            target.setCenter(0, 0);\n            target.setTarget(null);\n            target.invalidate(mInvalidateBounds);\n        }\n    }\n}"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/io/codetail/animation/ReverseInterpolator.java",
    "content": "package io.codetail.animation;\n\nimport android.view.animation.Interpolator;\n\npublic class ReverseInterpolator implements Interpolator {\n\t\n    public float getInterpolation(float t) {\n    \tt = Math.abs(t -1f);\n        float x = t*2.0f;\n        if (t<0.5f) return 0.5f*x*x*x*x*x;\n        x = (t-0.5f)*2-1;\n        return 0.5f*x*x*x*x*x+1;\n    }\n}"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/io/codetail/animation/SupportAnimator.java",
    "content": "package io.codetail.animation;\n\nimport android.view.animation.Interpolator;\n\npublic abstract class SupportAnimator {\n\n    /**\n     * @return true if using native android animation framework, otherwise is\n     * nineoldandroids\n     */\n    public abstract boolean isNativeAnimator();\n\n    /**\n     * @return depends from {@link android.os.Build.VERSION} if sdk version\n     * {@link android.os.Build.VERSION_CODES#LOLLIPOP} and greater will return\n     * {@link android.animation.Animator} otherwise {@link com.nineoldandroids.animation.Animator}\n     */\n    public abstract Object get();\n\n    /**\n     * Starts this animation. If the animation has a nonzero startDelay, the animation will start\n     * running after that delay elapses. A non-delayed animation will have its initial\n     * value(s) set immediately, followed by calls to\n     * {@link android.animation.Animator.AnimatorListener#onAnimationStart(android.animation.Animator)}\n     * for any listeners of this animator.\n     *\n     * <p>The animation started by calling this method will be run on the thread that called\n     * this method. This thread should have a Looper on it (a runtime exception will be thrown if\n     * this is not the case). Also, if the animation will animate\n     * properties of objects in the view hierarchy, then the calling thread should be the UI\n     * thread for that view hierarchy.</p>\n     *\n     */\n    public abstract void start();\n\n    /**\n     * Sets the duration of the animation.\n     *\n     * @param duration The length of the animation, in milliseconds.\n     */\n    public abstract void setDuration(int duration);\n\n    /**\n     * The time interpolator used in calculating the elapsed fraction of the\n     * animation. The interpolator determines whether the animation runs with\n     * linear or non-linear motion, such as acceleration and deceleration. The\n     * default value is {@link android.view.animation.AccelerateDecelerateInterpolator}.\n     *\n     * @param value the interpolator to be used by this animation\n     */\n    public abstract void setInterpolator(Interpolator value);\n\n\n    /**\n     * Adds a listener to the set of listeners that are sent events through the life of an\n     * animation, such as start, repeat, and end.\n     *\n     * @param listener the listener to be added to the current set of listeners for this animation.\n     */\n    public abstract void addListener(AnimatorListener listener);\n\n\n    /**\n     * Returns whether this Animator is currently running (having been started and gone past any\n     * initial startDelay period and not yet ended).\n     *\n     * @return Whether the Animator is running.\n     */\n    public abstract boolean isRunning();\n\n\n    /**\n     * <p>An animation listener receives notifications from an animation.\n     * Notifications indicate animation related events, such as the end or the\n     * repetition of the animation.</p>\n     */\n    public static interface AnimatorListener {\n        /**\n         * <p>Notifies the start of the animation.</p>\n         */\n        void onAnimationStart();\n\n        /**\n         * <p>Notifies the end of the animation. This callback is not invoked\n         * for animations with repeat count set to INFINITE.</p>\n         */\n        void onAnimationEnd();\n\n        /**\n         * <p>Notifies the cancellation of the animation. This callback is not invoked\n         * for animations with repeat count set to INFINITE.</p>\n         */\n        void onAnimationCancel();\n\n        /**\n         * <p>Notifies the repetition of the animation.</p>\n         */\n        void onAnimationRepeat();\n    }\n\n}\n"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/io/codetail/animation/SupportAnimatorLollipop.java",
    "content": "package io.codetail.animation;\n\nimport android.animation.Animator;\nimport android.annotation.TargetApi;\nimport android.os.Build;\nimport android.view.animation.Interpolator;\n\nimport java.lang.ref.WeakReference;\n\n@TargetApi(Build.VERSION_CODES.HONEYCOMB)\nfinal class SupportAnimatorLollipop extends SupportAnimator{\n\n    WeakReference<Animator> mNativeAnimator;\n\n    SupportAnimatorLollipop(Animator animator) {\n        mNativeAnimator = new WeakReference<Animator>(animator);\n    }\n\n    @Override\n    public boolean isNativeAnimator() {\n        return true;\n    }\n\n    @Override\n    public Object get() {\n        return mNativeAnimator;\n    }\n\n\n    @Override\n    public void start() {\n        Animator a = mNativeAnimator.get();\n        if(a != null) {\n            a.start();\n        }\n    }\n\n    @Override\n    public void setDuration(int duration) {\n        Animator a = mNativeAnimator.get();\n        if(a != null) {\n            a.setDuration(duration);\n        }\n    }\n\n    @Override\n    public void setInterpolator(Interpolator value) {\n        Animator a = mNativeAnimator.get();\n        if(a != null) {\n            a.setInterpolator(value);\n        }\n    }\n\n    @Override\n    public void addListener(final AnimatorListener listener) {\n        Animator a = mNativeAnimator.get();\n        if(a == null) {\n            return;\n        }\n\n        if(listener == null){\n            a.addListener(null);\n            return;\n        }\n\n        a.addListener(new Animator.AnimatorListener() {\n            @Override\n            public void onAnimationStart(Animator animation) {\n                listener.onAnimationStart();\n            }\n\n            @Override\n            public void onAnimationEnd(Animator animation) {\n                listener.onAnimationEnd();\n            }\n\n            @Override\n            public void onAnimationCancel(Animator animation) {\n                listener.onAnimationCancel();\n            }\n\n            @Override\n            public void onAnimationRepeat(Animator animation) {\n                listener.onAnimationRepeat();\n            }\n        });\n    }\n\n    @Override\n    public boolean isRunning() {\n        Animator a = mNativeAnimator.get();\n        return a != null && a.isRunning();\n    }\n}\n"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/io/codetail/animation/SupportAnimatorPreL.java",
    "content": "package io.codetail.animation;\n\nimport android.view.animation.Interpolator;\n\nimport com.nineoldandroids.animation.Animator;\n\nimport java.lang.ref.WeakReference;\n\nfinal class SupportAnimatorPreL extends SupportAnimator {\n\n    WeakReference<Animator> mSupportFramework;\n\n    SupportAnimatorPreL(Animator animator) {\n        mSupportFramework = new WeakReference<Animator>(animator);\n    }\n\n    @Override\n    public boolean isNativeAnimator() {\n        return false;\n    }\n\n    @Override\n    public Object get() {\n        return mSupportFramework.get();\n    }\n\n    @Override\n    public void start() {\n        Animator a = mSupportFramework.get();\n        if(a != null) {\n            a.start();\n        }\n    }\n\n    @Override\n    public void setDuration(int duration) {\n        Animator a = mSupportFramework.get();\n        if(a != null) {\n            a.setDuration(duration);\n        }\n    }\n\n    @Override\n    public void setInterpolator(Interpolator value) {\n        Animator a = mSupportFramework.get();\n        if(a != null) {\n            a.setInterpolator(value);\n        }\n    }\n\n    @Override\n    public void addListener(final AnimatorListener listener) {\n        Animator a = mSupportFramework.get();\n        if(a == null) {\n            return;\n        }\n\n        if(listener == null){\n            a.addListener(null);\n            return;\n        }\n\n        a.addListener(new Animator.AnimatorListener() {\n            @Override\n            public void onAnimationStart(Animator animation) {\n                listener.onAnimationStart();\n            }\n\n            @Override\n            public void onAnimationEnd(Animator animation) {\n                listener.onAnimationEnd();\n            }\n\n            @Override\n            public void onAnimationCancel(Animator animation) {\n                listener.onAnimationCancel();\n            }\n\n            @Override\n            public void onAnimationRepeat(Animator animation) {\n                listener.onAnimationRepeat();\n            }\n        });\n    }\n\n    @Override\n    public boolean isRunning() {\n        Animator a = mSupportFramework.get();\n        return a != null && a.isRunning();\n    }\n}\n"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/io/codetail/animation/ViewAnimationUtils.java",
    "content": "package io.codetail.animation;\n\nimport android.annotation.TargetApi;\nimport android.graphics.Rect;\nimport android.os.Build;\nimport android.view.View;\nimport android.view.animation.AccelerateDecelerateInterpolator;\n\nimport com.nineoldandroids.animation.Animator;\nimport com.nineoldandroids.animation.ObjectAnimator;\nimport com.nineoldandroids.view.ViewHelper;\nimport com.nineoldandroids.view.ViewPropertyAnimator;\n\nimport static android.os.Build.VERSION.SDK_INT;\nimport static android.os.Build.VERSION_CODES.LOLLIPOP;\n\npublic class ViewAnimationUtils {\n\n    private final static boolean LOLLIPOP_PLUS = SDK_INT >= LOLLIPOP;\n\n    public static final int SCALE_UP_DURATION = 500;\n\n    /**\n     * Returns an Animator which can animate a clipping circle.\n     * <p>\n     * Any shadow cast by the View will respect the circular clip from this animator.\n     * <p>\n     * Only a single non-rectangular clip can be applied on a View at any time.\n     * Views clipped by a circular reveal animation take priority over\n     * {@link android.view.View#setClipToOutline(boolean) View Outline clipping}.\n     * <p>\n     * Note that the animation returned here is a one-shot animation. It cannot\n     * be re-used, and once started it cannot be paused or resumed.\n     *\n     * @param view The View will be clipped to the animating circle.\n     * @param centerX The x coordinate of the center of the animating circle.\n     * @param centerY The y coordinate of the center of the animating circle.\n     * @param startRadius The starting radius of the animating circle.\n     * @param endRadius The ending radius of the animating circle.\n     */\n    @TargetApi(Build.VERSION_CODES.LOLLIPOP)\n    public static SupportAnimator createCircularReveal(View view,\n                                                int centerX,  int centerY,\n                                                float startRadius, float endRadius) {\n\n        if(LOLLIPOP_PLUS){\n            return new SupportAnimatorLollipop(android.view.ViewAnimationUtils\n                    .createCircularReveal(view, centerX, centerY, startRadius, endRadius));\n        }\n\n        if(!(view.getParent() instanceof RevealAnimator)){\n            throw new IllegalArgumentException(\"View must be inside RevealFrameLayout or RevealLinearLayout.\");\n        }\n\n        RevealAnimator revealLayout = (RevealAnimator) view.getParent();\n        revealLayout.setTarget(view);\n        revealLayout.setCenter(centerX, centerY);\n\n        Rect bounds = new Rect();\n        view.getHitRect(bounds);\n\n        ObjectAnimator reveal = ObjectAnimator.ofFloat(revealLayout, \"revealRadius\", startRadius, endRadius);\n        reveal.addListener(getRevealFinishListener(revealLayout, bounds));\n\n        return new SupportAnimatorPreL(reveal);\n    }\n\n\n    static Animator.AnimatorListener getRevealFinishListener(RevealAnimator target, Rect bounds){\n        if(SDK_INT >= 17){\n            return new RevealAnimator.RevealFinishedJellyBeanMr1(target, bounds);\n        }else if(SDK_INT >= 14){\n            return new RevealAnimator.RevealFinishedIceCreamSandwich(target, bounds);\n        }else {\n            return new RevealAnimator.RevealFinishedGingerbread(target, bounds);\n        }\n    }\n\n\n    /**\n     * Lifting view\n     *\n     * @param view The animation target\n     * @param baseRotation initial Rotation X in 3D space\n     * @param fromY initial Y position of view\n     * @param duration aniamtion duration\n     * @param startDelay start delay before animation begin\n     */\n    public static void liftingFromBottom(View view, float baseRotation, float fromY, int duration, int startDelay){\n        ViewHelper.setRotationX(view, baseRotation);\n        ViewHelper.setTranslationY(view, fromY);\n\n        ViewPropertyAnimator\n                .animate(view)\n                .setInterpolator(new AccelerateDecelerateInterpolator())\n                .setDuration(duration)\n                .setStartDelay(startDelay)\n                .rotationX(0)\n                .translationY(0)\n                .start();\n\n    }\n\n    /**\n     * Lifting view\n     *\n     * @param view The animation target\n     * @param baseRotation initial Rotation X in 3D space\n     * @param duration aniamtion duration\n     * @param startDelay start delay before animation begin\n     */\n    public static void liftingFromBottom(View view, float baseRotation, int duration, int startDelay){\n        ViewHelper.setRotationX(view, baseRotation);\n        ViewHelper.setTranslationY(view, view.getHeight() / 3);\n\n        ViewPropertyAnimator\n                .animate(view)\n                .setInterpolator(new AccelerateDecelerateInterpolator())\n                .setDuration(duration)\n                .setStartDelay(startDelay)\n                .rotationX(0)\n                .translationY(0)\n                .start();\n\n    }\n\n    /**\n     * Lifting view\n     *\n     * @param view The animation target\n     * @param baseRotation initial Rotation X in 3D space\n     * @param duration aniamtion duration\n     */\n    public static void liftingFromBottom(View view, float baseRotation, int duration){\n        ViewHelper.setRotationX(view, baseRotation);\n        ViewHelper.setTranslationY(view, view.getHeight() / 3);\n\n        ViewPropertyAnimator\n                .animate(view)\n                .setInterpolator(new AccelerateDecelerateInterpolator())\n                .setDuration(duration)\n                .rotationX(0)\n                .translationY(0)\n                .start();\n\n    }\n\n    public static class SimpleAnimationListener implements Animator.AnimatorListener{\n\n        @Override\n        public void onAnimationStart(Animator animation) {\n\n        }\n\n        @Override\n        public void onAnimationEnd(Animator animation) {\n\n        }\n\n        @Override\n        public void onAnimationCancel(Animator animation) {\n\n        }\n\n        @Override\n        public void onAnimationRepeat(Animator animation) {\n\n        }\n    }\n\n}\n"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/io/codetail/widget/RevealFrameLayout.java",
    "content": "package io.codetail.widget;\n\nimport android.content.Context;\nimport android.graphics.Canvas;\nimport android.graphics.Path;\nimport android.util.AttributeSet;\nimport android.view.View;\nimport android.widget.FrameLayout;\n\nimport io.codetail.animation.RevealAnimator;\n\npublic class RevealFrameLayout extends FrameLayout implements RevealAnimator{\n\n    Path mRevealPath;\n\n    boolean mClipOutlines;\n\n    float mCenterX;\n    float mCenterY;\n    float mRadius;\n\n    View mTarget;\n\n    public RevealFrameLayout(Context context) {\n        this(context, null);\n    }\n\n    public RevealFrameLayout(Context context, AttributeSet attrs) {\n        this(context, attrs, 0);\n    }\n\n    public RevealFrameLayout(Context context, AttributeSet attrs, int defStyle) {\n        super(context, attrs, defStyle);\n        mRevealPath = new Path();\n    }\n\n    /**\n     * Animation target\n     *\n     * @hide\n     */\n    @Override\n    public void setTarget(View view){\n        mTarget = view;\n    }\n\n    /**\n     * Epicenter of animation circle reveal\n     *\n     * @hide\n     */\n    @Override\n    public void setCenter(float centerX, float centerY){\n        mCenterX = centerX;\n        mCenterY = centerY;\n    }\n\n    /**\n     * Flag that animation is enabled\n     *\n     * @hide\n     */\n    @Override\n    public void setClipOutlines(boolean clip){\n        mClipOutlines = clip;\n    }\n\n    /**\n     * Circle radius size\n     *\n     * @hide\n     */\n    @Override\n    public void setRevealRadius(float radius){\n        mRadius = radius;\n        invalidate();\n    }\n\n    /**\n     * Circle radius size\n     *\n     * @hide\n     */\n    @Override\n    public float getRevealRadius(){\n        return mRadius;\n    }\n\n\n    @Override\n    protected boolean drawChild(Canvas canvas, View child, long drawingTime) {\n        if(!mClipOutlines && child != mTarget)\n            return super.drawChild(canvas, child, drawingTime);\n\n        final int state = canvas.save();\n\n        mRevealPath.reset();\n        mRevealPath.addCircle(mCenterX, mCenterY, mRadius, Path.Direction.CW);\n\n        canvas.clipPath(mRevealPath);\n\n        boolean isInvalided = super.drawChild(canvas, child, drawingTime);\n\n        canvas.restoreToCount(state);\n\n        return isInvalided;\n    }\n\n}\n"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/io/codetail/widget/RevealLinearLayout.java",
    "content": "package io.codetail.widget;\n\nimport android.content.Context;\nimport android.graphics.Canvas;\nimport android.graphics.Path;\nimport android.util.AttributeSet;\nimport android.view.View;\nimport android.widget.LinearLayout;\n\nimport io.codetail.animation.RevealAnimator;\n\npublic class RevealLinearLayout extends LinearLayout implements RevealAnimator{\n\n    Path mRevealPath;\n\n    boolean mClipOutlines;\n\n    float mCenterX;\n    float mCenterY;\n    float mRadius;\n\n    View mTarget;\n\n    public RevealLinearLayout(Context context) {\n        this(context, null);\n    }\n\n    public RevealLinearLayout(Context context, AttributeSet attrs) {\n        this(context, attrs, 0);\n    }\n\n    public RevealLinearLayout(Context context, AttributeSet attrs, int defStyle) {\n        super(context, attrs);\n        mRevealPath = new Path();\n    }\n\n    /**\n     * @hide\n     */\n    @Override\n    public void setTarget(View view){\n        mTarget = view;\n    }\n\n    /**\n     * @hide\n     */\n    @Override\n    public void setCenter(float centerX, float centerY){\n        mCenterX = centerX;\n        mCenterY = centerY;\n    }\n\n    /**\n     * @hide\n     */\n    @Override\n    public void setClipOutlines(boolean clip){\n        mClipOutlines = clip;\n    }\n\n    /**\n     * @hide\n     */\n    @Override\n    public void setRevealRadius(float radius){\n        mRadius = radius;\n        invalidate();\n    }\n\n    /**\n     * @hide\n     */\n    @Override\n    public float getRevealRadius(){\n        return mRadius;\n    }\n\n\n    @Override\n    protected boolean drawChild(Canvas canvas, View child, long drawingTime) {\n        if (!mClipOutlines && child != mTarget)\n            return super.drawChild(canvas, child, drawingTime);\n\n        final int state = canvas.save();\n\n        mRevealPath.reset();\n        mRevealPath.addCircle(mCenterX, mCenterY, mRadius, Path.Direction.CW);\n\n        canvas.clipPath(mRevealPath);\n\n        boolean isInvalided = super.drawChild(canvas, child, drawingTime);\n\n        canvas.restoreToCount(state);\n\n        return isInvalided;\n    }\n}\n"
  },
  {
    "path": "libraries/PersistentSearch/src/main/res/anim/anim_down.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<translate xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:fromYDelta=\"-100%p\"\n    android:toYDelta=\"0%p\" />\n"
  },
  {
    "path": "libraries/PersistentSearch/src/main/res/layout/search_option.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"48dp\"\n    android:layout_marginLeft=\"8dp\"\n    android:layout_marginRight=\"8dp\"\n    android:background=\"@android:color/white\"\n    android:foreground=\"?attr/selectableItemBackground\">\n\n    <RelativeLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:orientation=\"horizontal\">\n\n        <ImageView\n            android:id=\"@+id/icon\"\n            android:layout_width=\"32dp\"\n            android:layout_height=\"match_parent\"\n            android:layout_centerVertical=\"true\"\n            android:layout_margin=\"10dp\"\n            android:paddingLeft=\"3dp\"\n            android:adjustViewBounds=\"true\"\n            android:cropToPadding=\"true\"/>\n\n        <TextView\n            android:id=\"@+id/title\"\n            android:singleLine=\"true\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:textColor=\"#212121\"\n            android:layout_centerVertical=\"true\"\n            android:layout_marginLeft=\"62dp\"\n            android:layout_alignParentLeft=\"true\"\n            android:layout_toLeftOf=\"@+id/up\"\n            android:textAppearance=\"?android:attr/textAppearanceMedium\" />\n\n        <ImageView\n            android:id=\"@+id/up\"\n            android:layout_alignParentRight=\"true\"\n            android:layout_width=\"wrap_content\"\n            android:layout_marginRight=\"24dp\"\n            android:layout_gravity=\"center|right\"\n            android:layout_height=\"match_parent\"\n            android:src=\"@drawable/ic_up\"\n            android:background=\"?attr/selectableItemBackgroundBorderless\"/>\n\n        <View\n            android:id=\"@+id/border\"\n            android:layout_width=\"fill_parent\"\n            android:layout_height=\"1dp\"\n            android:background=\"#E8E8E8\" />\n\n    </RelativeLayout>\n\n</FrameLayout>"
  },
  {
    "path": "libraries/PersistentSearch/src/main/res/layout/searchbox.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<io.codetail.widget.RevealFrameLayout\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:id=\"@+id/searchbox_rfl\"\n    android:layout_height=\"wrap_content\">\n    <RelativeLayout\n        xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n        android:id=\"@+id/search_root\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:layout_marginLeft=\"-4dp\"\n        android:layout_marginRight=\"-4dp\"\n        android:layout_marginTop=\"-4dp\"\n        android:background=\"@drawable/search_bg\"\n        android:orientation=\"vertical\" >\n\n        <ListView\n            android:id=\"@+id/results\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"wrap_content\"\n            android:layout_alignParentLeft=\"true\"\n            android:layout_below=\"@+id/card_view\">\n        </ListView>\n\n        <RelativeLayout\n            android:id=\"@+id/card_view\"\n            android:layout_marginTop=\"4dp\"\n            android:paddingBottom=\"4dp\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"wrap_content\" >\n\n            <TextView\n                android:id=\"@+id/logo\"\n                android:layout_width=\"wrap_content\"\n                android:layout_height=\"wrap_content\"\n                android:layout_alignBottom=\"@+id/material_menu_button\"\n                android:layout_alignParentTop=\"true\"\n                android:layout_centerVertical=\"true\"\n                android:layout_toLeftOf=\"@+id/mic\"\n                android:layout_alignParentLeft=\"true\"\n                android:layout_marginLeft=\"54dp\"\n                android:singleLine=\"true\"\n                android:gravity=\"center_vertical\"\n                android:textColor=\"#212121\"\n                android:textAppearance=\"?android:attr/textAppearanceMedium\" />\n\n            <EditText\n                android:id=\"@+id/search\"\n                android:layout_width=\"wrap_content\"\n                android:layout_height=\"wrap_content\"\n                android:layout_alignBottom=\"@+id/material_menu_button\"\n                android:layout_alignParentTop=\"true\"\n                android:layout_alignParentLeft=\"true\"\n                android:layout_marginLeft=\"64dp\"\n                android:background=\"@null\"\n                android:ems=\"10\"\n                android:textColor=\"#212121\"\n                android:singleLine=\"true\"\n                android:imeOptions=\"actionSearch\"\n                android:visibility=\"gone\" >\n\n                <requestFocus />\n            </EditText>\n\n            <ImageView\n                android:id=\"@+id/mic\"\n                android:layout_width=\"25dp\"\n                android:layout_height=\"25dp\"\n                android:layout_alignBottom=\"@+id/material_menu_button\"\n                android:layout_alignParentRight=\"true\"\n                android:layout_alignParentTop=\"true\"\n                android:layout_toLeftOf=\"@+id/mic\"\n                android:onClick=\"mic\"\n                android:layout_marginRight=\"13dp\"\n                android:src=\"@drawable/ic_action_mic\" />\n\n            <com.balysv.materialmenu.MaterialMenuView\n                android:id=\"@+id/material_menu_button\"\n                android:layout_width=\"wrap_content\"\n                android:layout_height=\"wrap_content\"\n                android:layout_marginLeft=\"8dp\"\n                app:mm_color=\"#616161\"\n                app:mm_strokeWidth=\"2\"\n                app:mm_transformDuration=\"500\" />\n\n            <ProgressBar\n                android:id=\"@+id/pb\"\n                android:visibility=\"gone\"\n                android:layout_width=\"25dp\"\n                android:layout_height=\"25dp\"\n                android:layout_alignBottom=\"@+id/material_menu_button\"\n                android:layout_alignParentRight=\"true\"\n                android:layout_alignParentTop=\"true\"\n                android:layout_toLeftOf=\"@+id/mic\"\n                android:layout_marginRight=\"13dp\"/>\n\n            <ImageView\n                android:id=\"@+id/drawer_logo\"\n                android:layout_width=\"24dp\"\n                android:layout_height=\"24dp\"\n                android:layout_alignParentLeft=\"true\"\n                android:layout_marginLeft=\"16dp\"\n                android:layout_marginTop=\"8dp\" />\n\n        </RelativeLayout>\n\n    </RelativeLayout>\n</io.codetail.widget.RevealFrameLayout>"
  },
  {
    "path": "libraries/PersistentSearch/src/main/res/values/strings.xml",
    "content": "<resources>\n\n    <string name=\"speak_now\">Speak now</string>\n\n</resources>\n"
  },
  {
    "path": "libraries/PersistentSearch/src/main/res/values/styles.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <declare-styleable name=\"MaterialMenuView\">\n        <attr name=\"mm_color\" format=\"color\"/>\n        <attr name=\"mm_scale\" format=\"integer\"/>\n        <attr name=\"mm_transformDuration\" format=\"integer\"/>\n        <attr name=\"mm_pressedDuration\" format=\"integer\"/>\n        <attr name=\"mm_strokeWidth\" format=\"integer\"/>\n        <attr name=\"mm_rtlEnabled\" format=\"boolean\"/>\n    </declare-styleable>\n</resources>"
  },
  {
    "path": "settings.gradle",
    "content": "include ':app', ':libraries:PersistentSearch'\n"
  }
]