diff --git a/LICENSE b/LICENSE deleted file mode 100644 index f288702..0000000 --- a/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/README.md b/README.md index 709c618..2b020ed 100644 --- a/README.md +++ b/README.md @@ -1,76 +1,5 @@ # Ariane -A Gemini Protocol browser for Android based OS. Formerly called Två, and briefly Gem. - -## Releases - -* See the project page on Öppenlab.net for latest download: [oppenlab.net/pr/ariane](https://oppenlab.net/pr/ariane/) -* Install on [Google Play](https://play.google.com/store/apps/details?id=oppen.gemini.ariane) - -## Issue tracker - -[todo.sr.ht/~oppen/ariane](https://todo.sr.ht/~oppen/ariane) - -## Contact and Mailing Lists - -Email direct to `ariane@fastmail.se` or join a mailing list - -### Mailing Lists: -* [lists.sr.ht/~oppen/ariane-announce](https://lists.sr.ht/~oppen/ariane-announce) - project announcements and new releases -* [lists.sr.ht/~oppen/ariane-discuss](https://lists.sr.ht/~oppen/ariane-discuss) - general queries, suggestions, chat -* [lists.sr.ht/~oppen/ariane-devel](https://lists.sr.ht/~oppen/ariane-devel) - for develop discussion and to submit patches - -# TLS - -From the [Gemini specification](https://gemini.circumlunar.space/docs/specification.html): - -> Use of TLS for Gemini transactions is mandatory. -> Use of the Server Name Indication (SNI) extension to TLS is also mandatory, to facilitate name-based virtual hosting. - -Ariane uses TLS but does not implement TOFU at all: - -> Clients can validate TLS connections however they like (including not at all) but the strongly RECOMMENDED approach is to implement a lightweight "TOFU" certificate-pinning system which treats self-signed certificates as first- class citizens - -See [Drew's note on TOFU](https://drewdevault.com/2020/09/21/Gemini-TOFU.html) - -## Client TLS - -> Although rarely seen on the web, TLS permits clients to identify themselves to servers using certificates - -From the spec: - - -* Short-lived client certificates which are generated on demand and deleted immediately after use can be used as "session identifiers" to maintain server-side state for applications. In this role, client certificates act as a substitute for HTTP cookies, but unlike cookies they are generated voluntarily by the client, and once the client deletes a certificate and its matching key, the server cannot possibly "resurrect" the same value later (unlike so-called "super cookies"). -* Long-lived client certificates can reliably identify a user to a multi-user application without the need for passwords which may be brute-forced. Even a stolen database table mapping certificate hashes to user identities is not a security risk, as rainbow tables for certificates are not feasible. -* Self-hosted, single-user applications can be easily and reliably secured in a manner familiar from OpenSSH: the user generates a self-signed certificate and adds its hash to a server-side list of permitted certificates, analogous to the .authorized_keys file for SSH). - -Looking at [Kristall](https://kristall.random-projects.net/) a client should offer full cert management, including import and export. Ariane has NONE of this currently. - -A key sentence in the spec: - -> Gemini requests will typically be made without a client certificate. - -Client certs should only be required for protected content: - -> Gemini requests will typically be made without a client certificate. If a requested resource requires a client certificate and one is not included in a request, the server can respond with a status code of 60, 61 or 62 (see Appendix 1 below for a description of all status codes related to client certificates). A client certificate which is generated or loaded in response to such a status code has its scope bound to the same hostname as the request URL and to all paths below the path of the request URL path. E.g. if a request for gemini://example.com/foo returns status 60 and the user chooses to generate a new client certificate in response to this, that same certificate should be used for subsequent requests to gemini://example.com/foo, gemini://example.com/foo/bar/, gemini://example.com/foo/bar/baz, etc., until such time as the user decides to delete the certificate or to temporarily deactivate it. Interactive clients for human users are strongly recommended to make such actions easy and to generally give users full control over the use of client certificates. - -From this it's clear general requests should NOT use a client cert (to protect user identity if nothing else), if a server requests a client cert we should offer various configurations: - -* Always use identity cert -* Always use a fresh session cert -* Prompt user - -That's it as far as the spec is concered, the rest is down to the Android API - -## Ariane TLS - -Not implemented yet. - -Display a servers certs with: -`openssl s_client -showcerts -connect gus.guru:1965` - -## Android API - -* [SSLSocket](https://developer.android.com/reference/javax/net/ssl/SSLSocket) -* [Android keystore system](https://developer.android.com/training/articles/keystore.html) +A Gemini Protocol browser for Android based OS. +This project is now hosted at: [codeberg.org/oppenlab/Ariane](https://codeberg.org/oppenlab/Ariane) \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore deleted file mode 100644 index 42afabf..0000000 --- a/app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index 591b608..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,70 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' -apply plugin: 'kotlin-kapt' - -android { - compileSdkVersion 30 - buildToolsVersion "30.0.2" - - defaultConfig { - applicationId "oppen.gemini.ariane" - minSdkVersion 21 - targetSdkVersion 30 - versionCode 17 - versionName "2.0.9" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - buildFeatures{ - dataBinding true - } - - compileOptions{ - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions{ - jvmTarget = JavaVersion.VERSION_1_8.toString() - } -} - -dependencies { - implementation fileTree(dir: "libs", include: ["*.jar"]) - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.3.2' - implementation 'com.google.android.material:material:1.3.0-alpha03' - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0" - implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' - implementation 'androidx.activity:activity-ktx:1.1.0' - implementation "androidx.recyclerview:recyclerview:1.1.0" - implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0' - implementation 'androidx.preference:preference:1.1.1' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9' - - - implementation 'androidx.appcompat:appcompat:1.2.0' - implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' - - //ROOM DB - def room_version = "2.2.5" - implementation "androidx.room:room-runtime:$room_version" - kapt "androidx.room:room-compiler:$room_version" - implementation "androidx.room:room-ktx:$room_version" - - testImplementation 'junit:junit:4.13.1' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' - androidTestImplementation 'androidx.test:runner:1.3.0' - androidTestImplementation 'androidx.test:rules:1.3.0' - androidTestImplementation 'com.google.truth:truth:1.0' - -} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro deleted file mode 100644 index d45169b..0000000 --- a/app/proguard-rules.pro +++ /dev/null @@ -1,36 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile - --keep public class * implements com.bumptech.glide.module.GlideModule --keep class * extends com.bumptech.glide.module.AppGlideModule { - (...); -} --keep public enum com.bumptech.glide.load.ImageHeaderParser$** { - **[] $VALUES; - public *; -} --keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder { - *** rewind(); -} - -# for DexGuard only -# -keepresourcexmlelements manifest/application/meta-data@value=GlideModule \ No newline at end of file diff --git a/app/release/oppen_gemini_ariane_2_0_6.apk b/app/release/oppen_gemini_ariane_2_0_6.apk deleted file mode 100644 index 0ad6ed5..0000000 Binary files a/app/release/oppen_gemini_ariane_2_0_6.apk and /dev/null differ diff --git a/app/release/oppen_gemini_ariane_2_0_7.apk b/app/release/oppen_gemini_ariane_2_0_7.apk deleted file mode 100644 index cb5bd49..0000000 Binary files a/app/release/oppen_gemini_ariane_2_0_7.apk and /dev/null differ diff --git a/app/release/oppen_gemini_ariane_2_0_8.apk b/app/release/oppen_gemini_ariane_2_0_8.apk deleted file mode 100644 index defacc1..0000000 Binary files a/app/release/oppen_gemini_ariane_2_0_8.apk and /dev/null differ diff --git a/app/release/oppen_gemini_ariane_2_0_9.apk b/app/release/oppen_gemini_ariane_2_0_9.apk deleted file mode 100644 index 7bcdc23..0000000 Binary files a/app/release/oppen_gemini_ariane_2_0_9.apk and /dev/null differ diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json deleted file mode 100644 index 4944d9c..0000000 --- a/app/release/output-metadata.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "version": 2, - "artifactType": { - "type": "APK", - "kind": "Directory" - }, - "applicationId": "oppen.gemini.ariane", - "variantName": "processReleaseResources", - "elements": [ - { - "type": "SINGLE", - "filters": [], - "versionCode": 17, - "versionName": "2.0.9", - "outputFile": "app-release.apk" - } - ] -} \ No newline at end of file diff --git a/app/src/androidTest/java/oppen/ariane/ExampleInstrumentedTest.kt b/app/src/androidTest/java/oppen/ariane/ExampleInstrumentedTest.kt deleted file mode 100644 index fa46b4e..0000000 --- a/app/src/androidTest/java/oppen/ariane/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package oppen.ariane - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("oppen.tva", appContext.packageName) - } -} \ No newline at end of file diff --git a/app/src/androidTest/java/oppen/ariane/io/gemini/AddressTests.kt b/app/src/androidTest/java/oppen/ariane/io/gemini/AddressTests.kt deleted file mode 100644 index 9e3f592..0000000 --- a/app/src/androidTest/java/oppen/ariane/io/gemini/AddressTests.kt +++ /dev/null @@ -1,88 +0,0 @@ -package oppen.ariane.io.gemini - -import android.net.Uri -import oppen.ariane.Ariane -import com.google.common.truth.Truth.assertThat -import org.junit.Test - -class AddressTests { - - @Test - fun uriApiTests(){ - var uri = Uri.parse(Ariane.DEFAULT_HOME_CAPSULE) - - assertThat(uri.toString()).isEqualTo("gemini://gemini.circumlunar.space/~oppen/index.gmi") - assertThat(uri.isAbsolute).isTrue() - assertThat(uri.isHierarchical).isTrue() - assertThat(uri.isRelative).isFalse() - - val lastSegment = uri.lastPathSegment - assertThat(lastSegment).isEqualTo("index.gmi") - - uri = Uri.parse(uri.pathSegments.joinToString("/")) - assertThat(uri.toString()).isEqualTo("~oppen/index.gmi") - assertThat(uri.isRelative).isTrue() - } - - @Test - fun arianeUriTests(){ - val builder = AddressBuilder() - var uri = builder.request("gemini://gemini.circumlunar.space/~oppen/index.gmi").uri() - - assertThat(uri.toString()).isEqualTo("gemini://gemini.circumlunar.space/~oppen/index.gmi") - assertThat(uri.path).isEqualTo("/~oppen/index.gmi") - - uri = builder.request("hello/index.gmi").uri() - - assertThat(uri.toString()).isEqualTo("gemini://gemini.circumlunar.space/~oppen/hello/index.gmi") - - uri = builder.request("world/index.gmi").uri() - assertThat(uri.toString()).isEqualTo("gemini://gemini.circumlunar.space/~oppen/hello/world/index.gmi") - - uri = builder.request("./foo/index.gmi").uri() - assertThat(uri.toString()).isEqualTo("gemini://gemini.circumlunar.space/~oppen/hello/world/foo/index.gmi") - - uri = builder.request("bar/").uri() - assertThat(uri.toString()).isEqualTo("gemini://gemini.circumlunar.space/~oppen/hello/world/foo/bar/index.gmi") - - } - - - //https://todo.sr.ht/~oppen/ariane/28 - @Test - fun userTicketUriTests(){ - val builder = AddressBuilder() - - builder.request("gemini://mycapsule.com") - val relativeWithGmi = builder.request("art/index.gmi").uri() - assertThat(relativeWithGmi.toString()).isEqualTo("gemini://mycapsule.com/art/index.gmi") - - builder.request("gemini://mycapsule.com") - val relativeWithoutGmi = builder.request("art/").uri() - assertThat(relativeWithoutGmi.toString()).isEqualTo("gemini://mycapsule.com/art/index.gmi") - - } - - @Test - fun doubleSlashTest(){ - val builder = AddressBuilder() - - val uri = builder.request("//mycapsule.com").uri() - assertThat(uri.toString()).isEqualTo("gemini://mycapsule.com") - } - - @Test - fun pathTest(){ - val builder = AddressBuilder() - var uri = builder - .request("gemini://mycapsule.com") - .request("hello/") - .uri() - assertThat(uri.toString()).isEqualTo("gemini://mycapsule.com/hello/index.gmi") - - uri = builder.request("/world/").uri() - - assertThat(uri.toString()).isEqualTo("gemini://mycapsule.com/world/index.gmi") - - } -} \ No newline at end of file diff --git a/app/src/androidTest/java/oppen/ariane/io/gemini/DeviceTLSTests.kt b/app/src/androidTest/java/oppen/ariane/io/gemini/DeviceTLSTests.kt deleted file mode 100644 index 3de1ad9..0000000 --- a/app/src/androidTest/java/oppen/ariane/io/gemini/DeviceTLSTests.kt +++ /dev/null @@ -1,44 +0,0 @@ -package oppen.ariane.io.gemini - -import androidx.test.ext.junit.runners.AndroidJUnit4 -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import java.security.SecureRandom -import javax.net.ssl.SSLContext -import javax.net.ssl.SSLSocket -import javax.net.ssl.SSLSocketFactory - -@RunWith(AndroidJUnit4::class) -class DeviceTLSTests { - - lateinit var socket: SSLSocket - - @Before - fun setupSocket(){ - val sslContext = SSLContext.getInstance("TLS") - sslContext.init(null, null, SecureRandom()) - val factory: SSLSocketFactory = sslContext.socketFactory - socket = factory.createSocket() as SSLSocket - } - - @Test - fun supportsTLSv1(){ - socket.supportedProtocols.contains("TLSv1") - } - - @Test - fun supportsTLSv1_1(){ - socket.supportedProtocols.contains("TLSv1.1") - } - - @Test - fun supportsTLSv1_2(){ - socket.supportedProtocols.contains("TLSv1.2") - } - - @Test - fun supportsTLSv1_3(){ - socket.supportedProtocols.contains("TLSv1.3") - } -} \ No newline at end of file diff --git a/app/src/androidTest/java/oppen/ariane/io/gemini/GeminiDatasourceTests.kt b/app/src/androidTest/java/oppen/ariane/io/gemini/GeminiDatasourceTests.kt deleted file mode 100644 index 842cf33..0000000 --- a/app/src/androidTest/java/oppen/ariane/io/gemini/GeminiDatasourceTests.kt +++ /dev/null @@ -1,90 +0,0 @@ -package oppen.ariane.io.gemini - -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.platform.app.InstrumentationRegistry -import oppen.ariane.Ariane -import oppen.toURI -import com.google.common.truth.Truth.assertThat -import oppen.ariane.io.GemState -import oppen.ariane.io.database.ArianeDatabase -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -class GeminiDatasourceTests { - - private lateinit var gemini: Datasource - private val capsules = listOf( - "gemini://gemini.circumlunar.space", - "gemini://rawtext.club", - "gemini://drewdevault.com", - "gemini://talon.computer", - "gemini://tilde.team", - "gemini://tilde.pink", - "gemini://gemini.conman.org", - "gemini://idiomdrottning.org" - ) - - private var capsuleIndex = 0 - - @Before - fun setup(){ - val capsule = capsules.random() - println("Using $capsule for Gemini tests") - capsuleIndex = capsules.indexOf(capsule) - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - val db = ArianeDatabase(appContext) - gemini = Datasource.factory(InstrumentationRegistry.getInstrumentation().targetContext, db.history()) - } - - @Test - fun arianeHomePageTest(){ - var hasRequested = false - var hasResponded = false - - gemini.request(Ariane.DEFAULT_HOME_CAPSULE.toURI()){ state -> - - when(state){ - is GemState.Requesting -> { - assertThat(state.uri.toString()).isEqualTo(Ariane.DEFAULT_HOME_CAPSULE) - hasRequested = true - } - is GemState.ResponseGemtext -> { - assertThat(state.uri.toString()).isEqualTo(Ariane.DEFAULT_HOME_CAPSULE) - hasResponded = true - } - else -> { - //This will cause a failed test if request fails - assertThat(hasRequested).isTrue() - assertThat(hasResponded).isTrue() - } - } - } - } - - @Test - fun aCapsuleTest(){ - var hasRequested = false - var hasResponded = false - - gemini.request(capsules[capsuleIndex].toURI()){ state -> - - when(state){ - is GemState.Requesting -> { - assertThat(state.uri.toString()).isEqualTo(capsules[capsuleIndex]) - hasRequested = true - } - is GemState.ResponseGemtext -> { - assertThat(state.uri.toString()).isEqualTo(capsules[capsuleIndex]) - hasResponded = true - } - else -> { - //This will cause a failed test if request fails - assertThat(hasRequested).isTrue() - assertThat(hasResponded).isTrue() - } - } - } - } -} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml deleted file mode 100644 index f215b7f..0000000 --- a/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/java/oppen/Extensions.kt b/app/src/main/java/oppen/Extensions.kt deleted file mode 100644 index e945e92..0000000 --- a/app/src/main/java/oppen/Extensions.kt +++ /dev/null @@ -1,67 +0,0 @@ -package oppen - -import android.annotation.SuppressLint -import android.content.Context -import android.net.Uri -import android.os.CountDownTimer -import android.view.View -import android.view.inputmethod.InputMethodManager -import androidx.core.content.ContextCompat.getSystemService -import java.net.URI - - -fun View.visible(visible: Boolean) = when { - visible -> this.visibility = View.VISIBLE - else -> this.visibility = View.GONE -} - -fun View.visibleRetainingSpace(visible: Boolean) = when { - visible -> this.visibility = View.VISIBLE - else -> this.visibility = View.INVISIBLE -} - -fun View.hideKeyboard(){ - val imm: InputMethodManager? = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager? - imm?.hideSoftInputFromWindow(windowToken, 0) -} - -fun String.toURI(): URI { - return URI.create(this) -} - -fun URI.toUri(): Uri { - return Uri.parse(this.toString()) -} - -fun Uri.toURI(): URI { - return URI.create(this.toString()) -} - -fun Uri.isGemini(): Boolean{ - return this.toString().startsWith("gemini://") -} - -@SuppressLint("DefaultLocale") -fun String.endsWithImage(): Boolean{ - return this.toLowerCase().endsWith(".png") || - this.toLowerCase().endsWith(".jpg") || - this.toLowerCase().endsWith(".jpeg") || - this.toLowerCase().endsWith(".gif") -} - -@SuppressLint("DefaultLocale") -fun String.isWeb(): Boolean{ - return this.toLowerCase().startsWith("https://") || - this.toLowerCase().startsWith("http://") -} - -fun delay(ms: Long, action: () -> Unit){ - object : CountDownTimer(ms, ms/2) { - override fun onTick(millisUntilFinished: Long) {} - - override fun onFinish() { - action.invoke() - } - }.start() - -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/Ariane.kt b/app/src/main/java/oppen/ariane/Ariane.kt deleted file mode 100644 index 9ef2d6d..0000000 --- a/app/src/main/java/oppen/ariane/Ariane.kt +++ /dev/null @@ -1,29 +0,0 @@ -package oppen.ariane - -import android.app.Application -import androidx.appcompat.app.AppCompatDelegate -import androidx.preference.PreferenceManager - -class Ariane: Application() { - - override fun onCreate() { - super.onCreate() - - val prefs = PreferenceManager.getDefaultSharedPreferences(this) - - when { - prefs.getBoolean("theme_Light", false) -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) - prefs.getBoolean("theme_Dark", false) -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) - prefs.getBoolean("theme_FollowSystem", true) -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) - } - - } - - companion object{ - const val DEFAULT_HOME_CAPSULE = "gemini://gemini.circumlunar.space/~oppen/index.gmi" - const val GEMINI_USER_SEARCH_BASE = "gemini://gus.guru/search?" - const val GEMINI_BACKLINK_BASE = "gemini://gus.guru/backlinks?" - - const val FEATURE_CLIENT_CERTS = true - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/GemState.kt b/app/src/main/java/oppen/ariane/io/GemState.kt deleted file mode 100644 index d46f2f4..0000000 --- a/app/src/main/java/oppen/ariane/io/GemState.kt +++ /dev/null @@ -1,22 +0,0 @@ -package oppen.ariane.io - -import android.net.Uri -import oppen.ariane.io.gemini.GeminiResponse -import java.net.URI - -sealed class GemState { - data class AppQuery(val uri: URI): GemState() - data class Requesting(val uri: URI): GemState() - data class NotGeminiRequest(val uri: URI) : GemState() - - data class ResponseGemtext(val uri: URI, val header: GeminiResponse.Header, val lines: List) : GemState() - data class ResponseInput(val uri: URI, val header: GeminiResponse.Header) : GemState() - data class ResponseText(val uri: URI, val header: GeminiResponse.Header, val content: String) : GemState() - data class ResponseImage(val uri: URI, val header: GeminiResponse.Header, val cacheUri: Uri) : GemState() - data class ResponseAudio(val uri: URI, val header: GeminiResponse.Header, val cacheUri: Uri) : GemState() - data class ResponseBinary(val uri: URI, val header: GeminiResponse.Header, val cacheUri: Uri) : GemState() - data class ResponseUnknownMime(val uri: URI, val header: GeminiResponse.Header) : GemState() - data class ResponseError(val header: GeminiResponse.Header): GemState() - - object Blank: GemState() -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/database/ArianeAbstractDatabase.kt b/app/src/main/java/oppen/ariane/io/database/ArianeAbstractDatabase.kt deleted file mode 100644 index f5cf97c..0000000 --- a/app/src/main/java/oppen/ariane/io/database/ArianeAbstractDatabase.kt +++ /dev/null @@ -1,14 +0,0 @@ -package oppen.ariane.io.database - -import androidx.room.Database -import androidx.room.RoomDatabase -import oppen.ariane.io.database.bookmarks.BookmarkEntity -import oppen.ariane.io.database.bookmarks.BookmarksDao -import oppen.ariane.io.database.history.HistoryDao -import oppen.ariane.io.database.history.HistoryEntity - -@Database(entities = [BookmarkEntity::class, HistoryEntity::class], version = 3) -abstract class ArianeAbstractDatabase: RoomDatabase() { - abstract fun bookmarks(): BookmarksDao - abstract fun history(): HistoryDao -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/database/ArianeDatabase.kt b/app/src/main/java/oppen/ariane/io/database/ArianeDatabase.kt deleted file mode 100644 index e7e2f3d..0000000 --- a/app/src/main/java/oppen/ariane/io/database/ArianeDatabase.kt +++ /dev/null @@ -1,14 +0,0 @@ -package oppen.ariane.io.database - -import android.content.Context -import androidx.room.Room -import oppen.ariane.io.database.bookmarks.ArianeBookmarks -import oppen.ariane.io.database.history.ArianeHistory - -class ArianeDatabase(context: Context) { - - private val db: ArianeAbstractDatabase = Room.databaseBuilder(context, ArianeAbstractDatabase::class.java, "ariane_database_v1").build() - - fun bookmarks(): ArianeBookmarks = ArianeBookmarks(db) - fun history(): ArianeHistory = ArianeHistory(db) -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/database/bookmarks/ArianeBookmarks.kt b/app/src/main/java/oppen/ariane/io/database/bookmarks/ArianeBookmarks.kt deleted file mode 100644 index e77c020..0000000 --- a/app/src/main/java/oppen/ariane/io/database/bookmarks/ArianeBookmarks.kt +++ /dev/null @@ -1,80 +0,0 @@ -package oppen.ariane.io.database.bookmarks - -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import oppen.ariane.io.database.ArianeAbstractDatabase -import java.net.URI - -class ArianeBookmarks(private val db: ArianeAbstractDatabase): BookmarksDatasource { - - override fun get(onBookmarks: (List) -> Unit) { - GlobalScope.launch(Dispatchers.IO){ - val dbBookmarks = db.bookmarks().getAll() - val bookmarks = mutableListOf() - - dbBookmarks.forEach { bookmarkEntity -> - bookmarks.add( - BookmarkEntry( - uid = bookmarkEntity.uid, - label = bookmarkEntity.label ?: "Unknown", - uri = URI.create(bookmarkEntity.uri), - index = bookmarkEntity.uiIndex ?: 0) - ) - } - onBookmarks(bookmarks) - } - } - - override fun add(bookmarkEntry: BookmarkEntry, onAdded: () -> Unit) { - GlobalScope.launch(Dispatchers.IO){ - val bookmarkEntity = BookmarkEntity( - label = bookmarkEntry.label, - uri = bookmarkEntry.uri.toString(), - uiIndex = bookmarkEntry.index, - folder = "~/") - - db.bookmarks().insertAll(bookmarkEntity) - onAdded() - } - } - - override fun moveUp(bookmarkEntry: BookmarkEntry, onMoved: () -> Unit) { - GlobalScope.launch(Dispatchers.IO){ - - //todo - this method is broken: - val prev = db.bookmarks().getBookmark(bookmarkEntry.index -1) - val target = db.bookmarks().getBookmark(bookmarkEntry.index) - - db.bookmarks().updateUIIndex(prev.uid, bookmarkEntry.index) - db.bookmarks().updateUIIndex(target.uid, bookmarkEntry.index - 1) - onMoved() - } - } - - override fun moveDown(bookmarkEntry: BookmarkEntry, onMoved: () -> Unit) { - GlobalScope.launch(Dispatchers.IO){ - val next = db.bookmarks().getBookmark(bookmarkEntry.index + 1) - val target = db.bookmarks().getBookmark(bookmarkEntry.index) - - db.bookmarks().updateUIIndex(next.uid, bookmarkEntry.index) - db.bookmarks().updateUIIndex(target.uid, bookmarkEntry.index + 1) - onMoved() - } - } - - override fun update(bookmarkEntry: BookmarkEntry, label: String?, uri: String?, onUpdate: () -> Unit) { - GlobalScope.launch(Dispatchers.IO){ - db.bookmarks().updateContent(bookmarkEntry.uid, label ?: "", uri ?: "") - onUpdate() - } - } - - override fun delete(bookmarkEntry: BookmarkEntry, onDelete: () -> Unit) { - GlobalScope.launch(Dispatchers.IO){ - val entity = db.bookmarks().getBookmark(bookmarkEntry.index) - db.bookmarks().delete(entity) - onDelete() - } - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/database/bookmarks/BookmarkEntity.kt b/app/src/main/java/oppen/ariane/io/database/bookmarks/BookmarkEntity.kt deleted file mode 100644 index 600f053..0000000 --- a/app/src/main/java/oppen/ariane/io/database/bookmarks/BookmarkEntity.kt +++ /dev/null @@ -1,16 +0,0 @@ -package oppen.ariane.io.database.bookmarks - -import androidx.room.ColumnInfo -import androidx.room.Entity -import androidx.room.PrimaryKey - -@Entity(tableName = "bookmarks") -class BookmarkEntity( - @ColumnInfo(name = "label") val label: String?, - @ColumnInfo(name = "uri") val uri: String?, - @ColumnInfo(name = "uiIndex") val uiIndex: Int?, - @ColumnInfo(name = "folder") val folder: String? -){ - @PrimaryKey(autoGenerate = true) - var uid: Int = 0 -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/database/bookmarks/BookmarkEntry.kt b/app/src/main/java/oppen/ariane/io/database/bookmarks/BookmarkEntry.kt deleted file mode 100644 index 400ac56..0000000 --- a/app/src/main/java/oppen/ariane/io/database/bookmarks/BookmarkEntry.kt +++ /dev/null @@ -1,12 +0,0 @@ -package oppen.ariane.io.database.bookmarks - -import java.net.URI - -class BookmarkEntry( - val uid: Int, - val label: String, - val uri: URI, - val index: Int -){ - var visible = true -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/database/bookmarks/BookmarksDao.kt b/app/src/main/java/oppen/ariane/io/database/bookmarks/BookmarksDao.kt deleted file mode 100644 index b21ba26..0000000 --- a/app/src/main/java/oppen/ariane/io/database/bookmarks/BookmarksDao.kt +++ /dev/null @@ -1,24 +0,0 @@ -package oppen.ariane.io.database.bookmarks - -import androidx.room.* - -@Dao -interface BookmarksDao { - @Query("SELECT * FROM bookmarks ORDER BY uiIndex ASC") - suspend fun getAll(): List - - @Query("SELECT * from bookmarks WHERE uiIndex = :index LIMIT 1") - suspend fun getBookmark(index: Int): BookmarkEntity - - @Insert(onConflict = OnConflictStrategy.REPLACE) - suspend fun insertAll(vararg bookmarks: BookmarkEntity) - - @Query("UPDATE bookmarks SET uiIndex=:index WHERE uid = :id") - fun updateUIIndex(id: Int, index: Int) - - @Query("UPDATE bookmarks SET label=:label, uri=:uri WHERE uid = :id") - fun updateContent(id: Int, label: String, uri: String) - - @Delete - suspend fun delete(bookmark: BookmarkEntity) -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/database/bookmarks/BookmarksDatasource.kt b/app/src/main/java/oppen/ariane/io/database/bookmarks/BookmarksDatasource.kt deleted file mode 100644 index 95fb3dd..0000000 --- a/app/src/main/java/oppen/ariane/io/database/bookmarks/BookmarksDatasource.kt +++ /dev/null @@ -1,12 +0,0 @@ -package oppen.ariane.io.database.bookmarks - -interface BookmarksDatasource { - - fun get(onBookmarks: (List) -> Unit) - fun add(bookmarkEntry: BookmarkEntry, onAdded: () -> Unit) - fun delete(bookmarkEntry: BookmarkEntry, onDelete: () -> Unit) - - fun moveUp(bookmarkEntry: BookmarkEntry, onMoved: () -> Unit) - fun moveDown(bookmarkEntry: BookmarkEntry, onMoved: () -> Unit) - fun update(bookmarkEntry: BookmarkEntry, label: String?, uri: String?, onUpdate: () -> Unit) -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/database/history/ArianeHistory.kt b/app/src/main/java/oppen/ariane/io/database/history/ArianeHistory.kt deleted file mode 100644 index 2c949b8..0000000 --- a/app/src/main/java/oppen/ariane/io/database/history/ArianeHistory.kt +++ /dev/null @@ -1,70 +0,0 @@ -package oppen.ariane.io.database.history - -import android.net.Uri -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import oppen.ariane.io.database.ArianeAbstractDatabase - -class ArianeHistory(private val db: ArianeAbstractDatabase): HistoryDatasource { - - override fun get(onHistory: (List) -> Unit) { - GlobalScope.launch(Dispatchers.IO){ - val dbBookmarks = db.history().getAll() - val history = mutableListOf() - - dbBookmarks.forEach { entity -> - history.add(HistoryEntry(entity.uid, entity.timestamp ?: 0L, Uri.parse(entity.uri))) - } - onHistory(history) - } - } - - override fun add(entry: HistoryEntry, onAdded: () -> Unit) { - GlobalScope.launch(Dispatchers.IO){ - val lastAdded = db.history().getLastAdded() - val entity = HistoryEntity(entry.uri.toString(), System.currentTimeMillis()) - - when (lastAdded) { - null -> db.history().insert(entity) - else -> { - when { - lastAdded.uri.toString() != entry.uri.toString() -> db.history().insert(entity) - } - } - } - - onAdded() - } - } - - override fun add(uri: Uri, onAdded: () -> Unit) { - GlobalScope.launch(Dispatchers.IO){ - val lastAdded = db.history().getLastAdded() - val entity = HistoryEntity(uri.toString(), System.currentTimeMillis()) - - when (lastAdded) { - null -> db.history().insert(entity) - else -> { - when { - lastAdded.uri.toString() != uri.toString() -> db.history().insert(entity) - } - } - } - - onAdded() - } - } - - override fun clear(onClear: () -> Unit) { - //todo - } - - override fun delete(entry: HistoryEntry, onDelete: () -> Unit) { - GlobalScope.launch(Dispatchers.IO){ - val entity = db.history().getEntry(entry.uid) - db.history().delete(entity) - onDelete() - } - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/database/history/HistoryDao.kt b/app/src/main/java/oppen/ariane/io/database/history/HistoryDao.kt deleted file mode 100644 index bfbe6c8..0000000 --- a/app/src/main/java/oppen/ariane/io/database/history/HistoryDao.kt +++ /dev/null @@ -1,24 +0,0 @@ -package oppen.ariane.io.database.history - -import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert -import androidx.room.Query - -@Dao -interface HistoryDao { - @Query("SELECT * FROM history ORDER BY timestamp DESC") - suspend fun getAll(): List - - @Query("SELECT * FROM history WHERE uid = :uid LIMIT 1") - fun getEntry(uid: Int): HistoryEntity - - @Query("SELECT * FROM history ORDER BY timestamp DESC LIMIT 1") - fun getLastAdded(): HistoryEntity? - - @Insert - fun insert(vararg history: HistoryEntity) - - @Delete - fun delete(history: HistoryEntity) -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/database/history/HistoryDatasource.kt b/app/src/main/java/oppen/ariane/io/database/history/HistoryDatasource.kt deleted file mode 100644 index 52541f1..0000000 --- a/app/src/main/java/oppen/ariane/io/database/history/HistoryDatasource.kt +++ /dev/null @@ -1,12 +0,0 @@ -package oppen.ariane.io.database.history - -import android.net.Uri - -interface HistoryDatasource { - - fun get(onHistory: (List) -> Unit) - fun add(entry: HistoryEntry, onAdded: () -> Unit) - fun add(uri: Uri, onAdded: () -> Unit) - fun clear(onClear: () -> Unit) - fun delete(entry: HistoryEntry, onDelete: () -> Unit) -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/database/history/HistoryEntity.kt b/app/src/main/java/oppen/ariane/io/database/history/HistoryEntity.kt deleted file mode 100644 index ab6336b..0000000 --- a/app/src/main/java/oppen/ariane/io/database/history/HistoryEntity.kt +++ /dev/null @@ -1,14 +0,0 @@ -package oppen.ariane.io.database.history - -import androidx.room.ColumnInfo -import androidx.room.Entity -import androidx.room.PrimaryKey - -@Entity(tableName = "history") -class HistoryEntity( - @ColumnInfo(name = "uri") val uri: String?, - @ColumnInfo(name = "timestamp") val timestamp: Long? -){ - @PrimaryKey(autoGenerate = true) - var uid: Int = 0 -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/database/history/HistoryEntry.kt b/app/src/main/java/oppen/ariane/io/database/history/HistoryEntry.kt deleted file mode 100644 index 8d63e48..0000000 --- a/app/src/main/java/oppen/ariane/io/database/history/HistoryEntry.kt +++ /dev/null @@ -1,9 +0,0 @@ -package oppen.ariane.io.database.history - -import android.net.Uri - -class HistoryEntry( - val uid: Int, - val timestamp: Long, - val uri: Uri -) \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/gemini/AddressBuilder.kt b/app/src/main/java/oppen/ariane/io/gemini/AddressBuilder.kt deleted file mode 100644 index 4c3e3e2..0000000 --- a/app/src/main/java/oppen/ariane/io/gemini/AddressBuilder.kt +++ /dev/null @@ -1,70 +0,0 @@ -package oppen.ariane.io.gemini - -import android.net.Uri -import java.net.URI - -class AddressBuilder { - - private var uri: Uri = Uri.EMPTY - - fun set(uri: Uri){ - this.uri = uri - } - - fun request(link: URI): AddressBuilder { - return request(link.toString()) - } - - fun request(link: String): AddressBuilder { - val linkUri = Uri.parse(link) - when { - linkUri.isAbsolute -> { - uri = linkUri - } - linkUri.toString().startsWith("//") -> { - uri = Uri.parse("gemini:$link") - } - linkUri.toString().startsWith("/") -> { - val pathLink = "${uri.scheme}://${uri.host}$linkUri" - uri = when { - pathLink.endsWith("/") -> Uri.parse("${pathLink}index.gmi") - else -> Uri.parse(pathLink) - } - } - else -> { - val currentAddress = uri.toString() - - val directoryPath = when { - currentAddress.lastIndexOf("/") > 8 -> { - currentAddress.substring(0, currentAddress.lastIndexOf("/")+1) - } - else -> { - "${uri.scheme}://${uri.host}/" - } - } - - var cleanedLink = when { - link.startsWith("./") -> { - link.substring(2) - } - link.startsWith("/") -> { - link.substring(1) - } - else -> { - link - } - } - - if(link.endsWith("/")) cleanedLink += "index.gmi" - - uri = Uri.parse("$directoryPath$cleanedLink") - } - } - - return this - } - - fun uri(): Uri{ - return uri - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/gemini/Datasource.kt b/app/src/main/java/oppen/ariane/io/gemini/Datasource.kt deleted file mode 100644 index ef8e83c..0000000 --- a/app/src/main/java/oppen/ariane/io/gemini/Datasource.kt +++ /dev/null @@ -1,19 +0,0 @@ -package oppen.ariane.io.gemini - -import android.content.Context -import oppen.ariane.io.GemState -import oppen.ariane.io.database.history.ArianeHistory -import java.net.URI - -interface Datasource { - fun request(uri: URI, forceDownload: Boolean, onUpdate: (state: GemState) -> Unit) - fun request(uri: URI, onUpdate: (state: GemState) -> Unit) - fun canGoBack(): Boolean - fun goBack(onUpdate: (state: GemState) -> Unit) - - companion object{ - fun factory(context: Context, history: ArianeHistory): Datasource { - return GeminiDatasource(context, history) - } - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/gemini/DummyTrustManager.kt b/app/src/main/java/oppen/ariane/io/gemini/DummyTrustManager.kt deleted file mode 100644 index de4e308..0000000 --- a/app/src/main/java/oppen/ariane/io/gemini/DummyTrustManager.kt +++ /dev/null @@ -1,37 +0,0 @@ -package oppen.ariane.io.gemini - -import java.security.cert.X509Certificate -import javax.net.ssl.TrustManager -import javax.net.ssl.X509TrustManager -import javax.security.cert.CertificateException -import kotlin.jvm.Throws - -object DummyTrustManager { - - fun get(): Array { - return arrayOf( - object : X509TrustManager { - override fun checkClientTrusted( - chain: Array?, - authType: String? - ) { - - } - - override fun checkServerTrusted( - chain: Array?, - authType: String? - ) { - println("checkServerTrusted()") - println("checkServerTrusted() authType: $authType") - chain?.forEach { cert -> - println("checkServerTrusted() cert: ${cert.subjectDN}") - } - } - - override fun getAcceptedIssuers(): Array { - return arrayOf() - } - }) - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/gemini/GeminiDatasource.kt b/app/src/main/java/oppen/ariane/io/gemini/GeminiDatasource.kt deleted file mode 100644 index 8516910..0000000 --- a/app/src/main/java/oppen/ariane/io/gemini/GeminiDatasource.kt +++ /dev/null @@ -1,263 +0,0 @@ -package oppen.ariane.io.gemini - -import android.content.Context -import androidx.core.net.toUri -import androidx.preference.PreferenceManager -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import oppen.ariane.io.GemState -import oppen.ariane.io.database.history.ArianeHistory -import oppen.ariane.io.database.history.HistoryEntry -import oppen.ariane.io.keymanager.ArianeKeyManager -import oppen.isGemini -import oppen.toURI -import oppen.toUri -import java.io.* -import java.lang.IllegalStateException -import java.net.ConnectException -import java.net.URI -import javax.net.ssl.* - -const val GEMINI_SCHEME = "gemini" - -class GeminiDatasource(private val context: Context, val history: ArianeHistory): Datasource { - - private val prefs = PreferenceManager.getDefaultSharedPreferences(context) - private val addressBuilder = AddressBuilder() - private val runtimeHistory = mutableListOf() - private var forceDownload = false - private val arianeKeyManager = ArianeKeyManager() - - override fun request(uri: URI, onUpdate: (state: GemState) -> Unit) = request(uri, false, onUpdate) - - override fun request(uri: URI, forceDownload: Boolean, onUpdate: (state: GemState) -> Unit) { - this.forceDownload = forceDownload - //Any inputted uri starting with a colon is an app-specific command, eg. :prefs :settings - if(uri.toString().startsWith(":")){ - onUpdate(GemState.AppQuery(uri)) - return - } - - when (uri.scheme) { - GEMINI_SCHEME -> { - addressBuilder.set(uri.toUri()) - val cached = RuntimeCache.get(uri) - when { - cached != null -> { - updateHistory(uri) - onUpdate(GemState.ResponseGemtext(uri, cached.first, cached.second)) - return - } - else -> { - onUpdate(GemState.Requesting(uri)) - - GlobalScope.launch { - geminiRequest(uri, onUpdate) - } - } - } - } - else -> { - val parsedUri = addressBuilder.request(uri).uri() - if(parsedUri.isGemini()){ - val cached = RuntimeCache.get(parsedUri) - when { - cached != null -> { - updateHistory(uri) - onUpdate(GemState.ResponseGemtext(parsedUri.toURI(), cached.first, cached.second)) - } - else -> request(parsedUri.toURI(), forceDownload, onUpdate) - } - }else{ - onUpdate(GemState.NotGeminiRequest(uri)) - return - } - } - } - } - - private fun geminiRequest(uri: URI, onUpdate: (state: GemState) -> Unit){ - - //todo - extract and reuse this ------------------------------------------------------------ - val protocol = prefs.getString("tls_protocol", "TLS") - - println("REQ_PROTOCOL: $protocol") - - - val sslContext = when (protocol) { - "TLS_ALL" -> SSLContext.getInstance("TLS") - else -> SSLContext.getInstance(protocol) - } - - sslContext.init(arianeKeyManager.getFactory()?.keyManagers, DummyTrustManager.get(), null) - val factory: SSLSocketFactory = sslContext.socketFactory - - //todo to here ---------------------------------------------------------------------------- - - val socket: SSLSocket? - try { - socket = factory.createSocket(uri.host, 1965) as SSLSocket - - when (protocol) { - "TLS" -> {}//Use default enabled protocols - "TLS_ALL" -> socket.enabledProtocols = socket.supportedProtocols - else -> socket.enabledProtocols = arrayOf(protocol) - } - - println("Ariane socket handshake with ${uri.host}") - socket.startHandshake() - }catch (ce: ConnectException){ - println("Ariane socket error: $ce") - onUpdate(GemState.ResponseError(GeminiResponse.Header(-1, ce.message ?: ce.toString()))) - return - }catch (she: SSLHandshakeException){ - println("Ariane socket error: $she") - onUpdate(GemState.ResponseError(GeminiResponse.Header(-2, she.message ?: she.toString()))) - return - } - - // OUT >>>>>>>>>>>>>>>>>>>>>>>>>> - val outputStreamWriter = OutputStreamWriter(socket.outputStream) - val bufferedWriter = BufferedWriter(outputStreamWriter) - val outWriter = PrintWriter(bufferedWriter) - - val requestEntity = uri.toString() + "\r\n" - println("Ariane socket requesting $requestEntity") - outWriter.print(requestEntity) - outWriter.flush() - - if (outWriter.checkError()) { - onUpdate(GemState.ResponseError(GeminiResponse.Header(-1, "Print Writer Error"))) - outWriter.close() - return - } - - // IN <<<<<<<<<<<<<<<<<<<<<<<<<<< - - val inputStream = socket.inputStream - val headerInputReader = InputStreamReader(inputStream) - val bufferedReader = BufferedReader(headerInputReader) - val headerLine = bufferedReader.readLine() - - println("Ariane: response header: $headerLine") - - if(headerLine == null){ - onUpdate(GemState.ResponseError(GeminiResponse.Header(-2, "Server did not respond with a Gemini header"))) - return - } - - val header = GeminiResponse.parseHeader(headerLine) - - when { - header.code == GeminiResponse.INPUT -> onUpdate(GemState.ResponseInput(uri, header)) - header.code == GeminiResponse.REDIRECT -> request(URI.create(header.meta), forceDownload, onUpdate) - header.code != GeminiResponse.SUCCESS -> onUpdate(GemState.ResponseError(header)) - header.meta.startsWith("text/gemini") -> getGemtext(bufferedReader, uri, header, onUpdate) - header.meta.startsWith("text/") -> getString(socket, uri, header, onUpdate) - header.meta.startsWith("image/") -> getBinary(socket, uri, header, onUpdate) - header.meta.startsWith("audio/") -> getBinary(socket, uri, header, onUpdate) - else -> { - //File served over Gemini but not handled in-app, eg .pdf - if(forceDownload){ - getBinary(socket, uri, header, onUpdate) - }else{ - onUpdate(GemState.ResponseUnknownMime(uri, header)) - } - - } - } - - //Close input - bufferedReader.close() - headerInputReader.close() - - //Close output: - outputStreamWriter.close() - bufferedWriter.close() - outWriter.close() - - socket.close() - } - - private fun getGemtext(reader: BufferedReader, uri: URI, header: GeminiResponse.Header, onUpdate: (state: GemState) -> Unit){ - - val lines = mutableListOf() - - lines.addAll(reader.readLines()) - - val processed = GemtextHelper.findCodeBlocks(lines) - - when { - !uri.toString().startsWith("gemini://") -> throw IllegalStateException("Not a Gemini Uri") - } - - RuntimeCache.put(uri, header, processed) - - updateHistory(uri) - - onUpdate(GemState.ResponseGemtext(uri, header, processed)) - } - - private fun updateHistory(uri: URI) { - if (runtimeHistory.isEmpty() || runtimeHistory.last().toString() != uri.toString()) { - runtimeHistory.add(uri) - println("Ariane added $uri to runtime history (size ${runtimeHistory.size})") - } - - history.add(uri.toUri()){} - } - - private fun getString(socket: SSLSocket?, uri: URI, header: GeminiResponse.Header, onUpdate: (state: GemState) -> Unit){ - val content = socket?.inputStream?.bufferedReader().use { - reader -> reader?.readText() - } - socket?.close() - onUpdate(GemState.ResponseText(uri, header, content ?: "Error fetching content")) - } - - private fun getBinary(socket: SSLSocket?, uri: URI, header: GeminiResponse.Header, onUpdate: (state: GemState) -> Unit){ - - var filename: String? = null - val fileSegmentIndex: Int = uri.path.lastIndexOf('/') - - when { - fileSegmentIndex != -1 -> filename = uri.path.substring(fileSegmentIndex + 1) - } - - val host = uri.host.replace(".", "_") - val cacheName = "${host}_$filename" - println("Caching file: $filename from uri: $uri, cacheName: $cacheName") - - val cacheFile = File(context.cacheDir, cacheName) - - when { - cacheFile.exists() -> { - when { - header.meta.startsWith("image/") -> onUpdate(GemState.ResponseImage(uri, header, cacheFile.toUri())) - header.meta.startsWith("audio/") -> onUpdate(GemState.ResponseAudio(uri, header, cacheFile.toUri())) - else -> onUpdate(GemState.ResponseBinary(uri, header, cacheFile.toUri())) - } - } - else -> { - cacheFile.createNewFile() - cacheFile.outputStream().use{ outputStream -> - socket?.inputStream?.copyTo(outputStream) - socket?.close() - } - - when { - header.meta.startsWith("image/") -> onUpdate(GemState.ResponseImage(uri, header, cacheFile.toUri())) - header.meta.startsWith("audio/") -> onUpdate(GemState.ResponseAudio(uri, header, cacheFile.toUri())) - else -> onUpdate(GemState.ResponseBinary(uri, header, cacheFile.toUri())) - } - } - } - } - - override fun canGoBack(): Boolean = runtimeHistory.isEmpty() || runtimeHistory.size > 1 - - override fun goBack(onUpdate: (state: GemState) -> Unit) { - runtimeHistory.removeLast() - request(runtimeHistory.last(), onUpdate) - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/gemini/GeminiResponse.kt b/app/src/main/java/oppen/ariane/io/gemini/GeminiResponse.kt deleted file mode 100644 index 0e28d27..0000000 --- a/app/src/main/java/oppen/ariane/io/gemini/GeminiResponse.kt +++ /dev/null @@ -1,78 +0,0 @@ -package oppen.ariane.io.gemini - -object GeminiResponse { - - const val INPUT = 1 - const val SUCCESS = 2 - const val REDIRECT = 3 - const val TEMPORARY_FAILURE = 4 - const val PERMANENT_FAILURE = 5 - const val CLIENT_CERTIFICATE_REQUIRED = 6 - const val UNKNOWN = -1 - - fun parseHeader(header: String): Header { - val cleanHeader = header.replace("\\s+".toRegex(), " ") - val meta: String - when { - header.startsWith("2") -> { - val segments = cleanHeader.trim().split(" ") - meta = when { - segments.size > 1 -> segments[1] - else -> "text/gemini; charset=utf-8" - } - } - else -> { - - meta = when { - cleanHeader.contains(" ") -> cleanHeader.substring(cleanHeader.indexOf(" ") + 1) - else -> cleanHeader - } - } - } - - return when { - header.startsWith("1") -> Header( - INPUT, - meta - ) - header.startsWith("2") -> Header( - SUCCESS, - meta - ) - header.startsWith("3") -> Header( - REDIRECT, - meta - ) - header.startsWith("4") -> Header( - TEMPORARY_FAILURE, - meta - ) - header.startsWith("5") -> Header( - PERMANENT_FAILURE, - meta - ) - header.startsWith("6") -> Header( - CLIENT_CERTIFICATE_REQUIRED, - meta - ) - else -> Header( - UNKNOWN, - meta - ) - } - } - - fun getCodeString(code: Int): String{ - return when(code){ - 1 -> "Input" - 2 -> "Success" - 3 -> "Redirect" - 4 -> "Temporary Failure" - 5 -> "Permanent Failure" - 6 -> "Client Certificate Required" - else -> "Unknown: $code" - } - } - - class Header(val code: Int, val meta: String) -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/gemini/GemtextHelper.kt b/app/src/main/java/oppen/ariane/io/gemini/GemtextHelper.kt deleted file mode 100644 index 4184603..0000000 --- a/app/src/main/java/oppen/ariane/io/gemini/GemtextHelper.kt +++ /dev/null @@ -1,38 +0,0 @@ -package oppen.ariane.io.gemini - -import java.lang.StringBuilder - -object GemtextHelper { - - /** - * - * This is safe for most cases but fails when a line starts with ``` _within_ a code block - * - */ - fun findCodeBlocks(source: List): List{ - val sb = StringBuilder() - var inCodeBlock = false - val parsed = mutableListOf() - source.forEach { line -> - if (line.startsWith("```")) { - if (!inCodeBlock) { - //New code block starting - sb.clear() - sb.append("```") - } else { - //End of code block - parsed.add(sb.toString()) - } - inCodeBlock = !inCodeBlock - } else { - if (inCodeBlock) { - sb.append("$line\n") - } else { - parsed.add(line) - } - } - } - - return parsed - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/gemini/RuntimeCache.kt b/app/src/main/java/oppen/ariane/io/gemini/RuntimeCache.kt deleted file mode 100644 index abe012d..0000000 --- a/app/src/main/java/oppen/ariane/io/gemini/RuntimeCache.kt +++ /dev/null @@ -1,26 +0,0 @@ -package oppen.ariane.io.gemini - -import android.net.Uri -import androidx.collection.LruCache -import java.net.URI - -object RuntimeCache { - - private const val CACHE_SIZE = 4 * 1024 * 1024 - private val lruCache = LruCache>>( - CACHE_SIZE - ) - - fun put(uri: URI, header: GeminiResponse.Header, lines: List){ - lruCache.put(uri.toString(), Pair(header, lines)) - } - - fun get(uri: URI): Pair>? = lruCache[uri.toString()] - fun get(uri: Uri): Pair>? = lruCache[uri.toString()] - - fun clear() = lruCache.evictAll() - - fun remove(address: String) { - lruCache.remove(address) - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/history/uris/BasicURIHistory.kt b/app/src/main/java/oppen/ariane/io/history/uris/BasicURIHistory.kt deleted file mode 100644 index 4655972..0000000 --- a/app/src/main/java/oppen/ariane/io/history/uris/BasicURIHistory.kt +++ /dev/null @@ -1,44 +0,0 @@ -package oppen.ariane.io.history.uris - -import android.content.Context - -/** - * - * Another shared prefs implementation so I don't get slowed down by a Room implementation at this point - * - */ -class BasicURIHistory(context: Context): HistoryInterface { - - private val DELIM = "||" - private val prefsKey = "oppen.tva.io.history.BasicURIHistory.prefsKey" - private val prefsHistoryKey = "oppen.tva.io.history.BasicURIHistory.prefsHistoryKey" - private val prefs = context.getSharedPreferences(prefsKey, Context.MODE_PRIVATE) - - override fun add(address: String) { - - val history = get() - - when { - history.size >= 50 -> history.removeAt(0) - } - - if(history.isNotEmpty() && history.size > 10){ - if(history.subList(history.size - 10, history.size).contains(address)) return - } - - history.add(address) - val raw = history.joinToString(DELIM) - prefs.edit().putString(prefsHistoryKey, raw).apply() - } - - override fun clear(){ - prefs.edit().clear().apply() - } - - override fun get(): ArrayList { - return when (val raw = prefs.getString(prefsHistoryKey, null)) { - null -> arrayListOf() - else -> ArrayList(raw.split(DELIM)) - } - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/history/uris/HistoryInterface.kt b/app/src/main/java/oppen/ariane/io/history/uris/HistoryInterface.kt deleted file mode 100644 index 8a21260..0000000 --- a/app/src/main/java/oppen/ariane/io/history/uris/HistoryInterface.kt +++ /dev/null @@ -1,15 +0,0 @@ -package oppen.ariane.io.history.uris - -import android.content.Context - -interface HistoryInterface { - fun add(address: String) - fun get(): List - fun clear() - - companion object{ - fun default(context: Context): HistoryInterface { - return BasicURIHistory(context) - } - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/io/keymanager/ArianeKeyManager.kt b/app/src/main/java/oppen/ariane/io/keymanager/ArianeKeyManager.kt deleted file mode 100644 index ae95608..0000000 --- a/app/src/main/java/oppen/ariane/io/keymanager/ArianeKeyManager.kt +++ /dev/null @@ -1,43 +0,0 @@ -package oppen.ariane.io.keymanager - -import android.content.Context -import oppen.ariane.R -import java.io.ByteArrayInputStream -import java.io.InputStream -import java.security.KeyStore -import javax.net.ssl.KeyManagerFactory - - -class ArianeKeyManager { - - //todo - add other methods to update state - - //If the user has a key loaded load it here - or else return null - fun getFactory(): KeyManagerFactory? { - val hasLoadedKey = false - return when { - hasLoadedKey -> { - val keyStore: KeyStore = KeyStore.getInstance("BKS")//or "pkcs12"v? - val inputStream: InputStream = ByteArrayInputStream("dummy".toByteArray()) - keyStore.load(inputStream, "yourKeyStorePassword".toCharArray()) - inputStream.close() - - val keyManagerFactory: KeyManagerFactory = KeyManagerFactory.getInstance("X509") - keyManagerFactory.init(keyStore, "yourKeyStorePassword".toCharArray()) - - keyManagerFactory - } - else -> null - } - } - - fun getFactoryDemo(context: Context): KeyManagerFactory? { - val keyStore: KeyStore = KeyStore.getInstance("pkcs12")//or "pkcs12"v? - keyStore.load(context.resources.openRawResource(R.raw.cert), "PASSWORD".toCharArray()) - - val keyManagerFactory: KeyManagerFactory = KeyManagerFactory.getInstance("X509") - keyManagerFactory.init(keyStore, "PASSWORD".toCharArray()) - - return keyManagerFactory - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/ui/GemActivity.kt b/app/src/main/java/oppen/ariane/ui/GemActivity.kt deleted file mode 100644 index 5c9a1b5..0000000 --- a/app/src/main/java/oppen/ariane/ui/GemActivity.kt +++ /dev/null @@ -1,413 +0,0 @@ -package oppen.ariane.ui - -import android.app.DownloadManager -import android.content.ActivityNotFoundException -import android.content.Intent -import android.media.MediaPlayer -import android.net.Uri -import android.os.Bundle -import android.view.inputmethod.EditorInfo -import androidx.activity.viewModels -import androidx.appcompat.app.AlertDialog -import androidx.appcompat.app.AppCompatActivity -import androidx.databinding.DataBindingUtil -import androidx.preference.PreferenceManager -import androidx.recyclerview.widget.LinearLayoutManager -import com.google.android.material.snackbar.Snackbar -import oppen.ariane.Ariane -import oppen.ariane.R -import oppen.ariane.databinding.ActivityGemBinding -import oppen.ariane.io.GemState -import oppen.ariane.io.database.ArianeDatabase -import oppen.ariane.io.database.bookmarks.BookmarksDatasource -import oppen.ariane.io.gemini.Datasource -import oppen.ariane.io.gemini.GeminiResponse -import oppen.ariane.io.gemini.RuntimeCache -import oppen.ariane.ui.audio_player.AudioPlayer -import oppen.ariane.ui.bookmarks.BookmarkDialog -import oppen.ariane.ui.bookmarks.BookmarksDialog -import oppen.ariane.ui.content_image.ImageDialog -import oppen.ariane.ui.content_text.TextDialog -import oppen.ariane.ui.modals_menus.LinkPopup -import oppen.ariane.ui.modals_menus.about.AboutDialog -import oppen.ariane.ui.modals_menus.history.HistoryDialog -import oppen.ariane.ui.modals_menus.input.InputDialog -import oppen.ariane.ui.modals_menus.overflow.OverflowPopup -import oppen.ariane.ui.settings.SettingsActivity -import oppen.hideKeyboard -import oppen.visibleRetainingSpace -import java.io.File -import java.io.FileInputStream -import java.io.FileOutputStream -import java.net.URLEncoder - -const val CREATE_IMAGE_FILE_REQ = 628 -const val CREATE_AUDIO_FILE_REQ = 629 -const val CREATE_BINARY_FILE_REQ = 630 - -class GemActivity : AppCompatActivity() { - - private var inSearch = false - private val mediaPlayer = MediaPlayer() - - private lateinit var bookmarkDatasource: BookmarksDatasource - private val model by viewModels() - private lateinit var binding: ActivityGemBinding - - private val adapter = GemtextAdapter { adapter, uri, longTap, position: Int, view -> - if(longTap){ - LinkPopup.show(view, uri){ menuId -> - when (menuId) { - R.id.link_menu_load_image -> { - loadingView(true) - model.requestInlineImage(uri){ imageUri -> - imageUri?.let{ - runOnUiThread { - loadingView(false) - adapter.loadImage(position, imageUri) - } - } - } - } - R.id.link_menu_copy -> { - Intent().apply { - action = Intent.ACTION_SEND - putExtra(Intent.EXTRA_TEXT, uri.toString()) - type = "text/plain" - startActivity(Intent.createChooser(this, null)) - } - } - } - } - }else{ - //Reset input text hint after user has been searching - if(inSearch) { - binding.addressEdit.hint = getString(R.string.main_input_hint) - inSearch = false - } - - model.request(uri) - } - } - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - val db = ArianeDatabase(applicationContext) - bookmarkDatasource = db.bookmarks() - - binding = DataBindingUtil.setContentView(this, R.layout.activity_gem) - binding.viewmodel = model - binding.lifecycleOwner = this - - binding.gemtextRecycler.layoutManager = LinearLayoutManager(this) - binding.gemtextRecycler.adapter = adapter - - model.initialise( - home = PreferenceManager.getDefaultSharedPreferences(this).getString("home_capsule", Ariane.DEFAULT_HOME_CAPSULE) ?: Ariane.DEFAULT_HOME_CAPSULE, - gemini = Datasource.factory(this, db.history()), - db = db, - onState = this::handleState) - - binding.addressEdit.setOnEditorActionListener { _, actionId, _ -> - when (actionId) { - EditorInfo.IME_ACTION_GO -> { - val input = binding.addressEdit.text.toString() - - when { - input.startsWith("gemini://") -> model.request(input) - else -> model.request("${Ariane.GEMINI_USER_SEARCH_BASE}${URLEncoder.encode(input, "UTF-8")}") - } - - binding.addressEdit.hideKeyboard() - - return@setOnEditorActionListener true - } - else -> return@setOnEditorActionListener false - } - } - - binding.more.setOnClickListener { - OverflowPopup.show(binding.more){ menuId -> - when (menuId) { - R.id.overflow_menu_search -> { - binding.addressEdit.hint = getString(R.string.main_input_search_hint) - binding.addressEdit.text?.clear() - binding.addressEdit.requestFocus() - inSearch = true - } - R.id.overflow_menu_bookmark -> { - println("Bookmark: ---------------------------") - val name = adapter.inferTitle() - BookmarkDialog( - this, - BookmarkDialog.mode_new, - bookmarkDatasource, - binding.addressEdit.text.toString(), - name ?: "" - ) { _, _ -> - bookmarkDatasource.get { bookmarks -> - bookmarks.forEach { bookmark -> - println("Bookmark: ${bookmark.label}: ${bookmark.uri}") - } - } - }.show() - } - R.id.overflow_menu_bookmarks -> { - println("Bookmarks: --------------------------") - BookmarksDialog(this, bookmarkDatasource) { bookmark -> - model.request(bookmark.uri) - }.show() - } - R.id.overflow_menu_share -> { - Intent().apply { - action = Intent.ACTION_SEND - putExtra(Intent.EXTRA_TEXT, binding.addressEdit.text.toString()) - type = "text/plain" - startActivity(Intent.createChooser(this, null)) - } - } - R.id.overflow_menu_history -> HistoryDialog.show(this, db.history()) { historyAddress -> - model.request(historyAddress) - } - R.id.overflow_menu_about -> AboutDialog.show(this) - R.id.overflow_menu_settings -> { - startActivity(Intent(this, SettingsActivity::class.java)) - } - } - } - } - - binding.home.setOnClickListener { - val home = PreferenceManager.getDefaultSharedPreferences(this).getString("home_capsule", Ariane.DEFAULT_HOME_CAPSULE) - model.request(home!!) - } - - binding.pullToRefresh.setOnRefreshListener { - val address = binding.addressEdit.text.toString() - RuntimeCache.remove(address) - model.request(address) - } - - checkIntentExtras(intent) - } - - private fun handleState(state: GemState) { - binding.pullToRefresh.isRefreshing = false - - when (state) { - is GemState.AppQuery -> runOnUiThread { showAlert("App backdoor/query not implemented yet") } - is GemState.ResponseInput -> runOnUiThread { - loadingView(false) - InputDialog.show(this, state) { queryAddress -> - model.request(queryAddress) - } - } - is GemState.Requesting -> loadingView(true) - is GemState.NotGeminiRequest -> externalProtocol(state) - is GemState.ResponseError -> showAlert("${GeminiResponse.getCodeString(state.header.code)}: ${state.header.meta}") - is GemState.ResponseGemtext -> renderGemtext(state) - is GemState.ResponseText -> renderText(state) - is GemState.ResponseImage -> renderImage(state) - is GemState.ResponseAudio -> renderAudio(state) - is GemState.ResponseBinary -> renderBinary(state) - is GemState.Blank -> { - binding.addressEdit.setText("") - adapter.render(arrayListOf()) - } - is GemState.ResponseUnknownMime -> { - runOnUiThread { - loadingView(false) - AlertDialog.Builder(this, R.style.AppDialogTheme) - .setTitle(R.string.unknown_mime_dialog_title) - .setMessage("Address: ${state.uri}\nMeta: ${state.header.meta}") - .setPositiveButton("Download") { _, _ -> - loadingView(true) - model.requestBinaryDownload(state.uri) - } - .setNegativeButton("Cancel") { _, _ -> } - .show() - } - } - } - } - - override fun onNewIntent(intent: Intent?) { - super.onNewIntent(intent) - - intent?.let{ - checkIntentExtras(intent) - } - } - - /** - * - * Checks intent to see if Activity was opened to handle selected text - * - */ - private fun checkIntentExtras(intent: Intent) { - - //Via ProcessTextActivity from selected text in another app - if(intent.hasExtra("process_text")){ - val processText = intent.getStringExtra("process_text") - binding.addressEdit.setText(processText) - model.request(processText ?: "") - return - } - - //From clicking a gemini:// address - val uri = intent.data - if(uri != null){ - binding.addressEdit.setText(uri.toString()) - model.request(uri.toString()) - return - } - } - - private fun showAlert(message: String) = runOnUiThread{ - loadingView(false) - - if(message.length > 40){ - AlertDialog.Builder(this) - .setMessage(message) - .show() - }else { - Snackbar.make(binding.root, message, Snackbar.LENGTH_SHORT).show() - } - } - - private fun externalProtocol(state: GemState.NotGeminiRequest) = runOnUiThread { - loadingView(false) - val browserIntent = Intent(Intent.ACTION_VIEW) - browserIntent.data = Uri.parse(state.uri.toString()) - - try { - startActivity(browserIntent) - }catch (e: ActivityNotFoundException){ - showAlert("No app installed that can open ${state.uri}") - } - } - - private fun renderGemtext(state: GemState.ResponseGemtext) = runOnUiThread { - loadingView(false) - - //todo - colours didn't change when switching themes, so disabled for now - //val addressSpan = SpannableString(state.uri.toString()) - //addressSpan.set(0, 9, ForegroundColorSpan(resources.getColor(R.color.protocol_address))) - binding.addressEdit.setText(state.uri.toString()) - - adapter.render(state.lines) - - //Scroll to top - binding.gemtextRecycler.post { - binding.gemtextRecycler.scrollToPosition(0) - } - } - - private fun renderText(state: GemState.ResponseText) = runOnUiThread { - loadingView(false) - TextDialog.show(this, state) - } - - var imageState: GemState.ResponseImage? = null - var audioState: GemState.ResponseAudio? = null - var binaryState: GemState.ResponseBinary? = null - - private fun renderAudio(state: GemState.ResponseAudio) = runOnUiThread { - loadingView(false) - AudioPlayer.play(this, binding, mediaPlayer, state){ state -> - audioState = state - val intent = Intent(Intent.ACTION_CREATE_DOCUMENT) - intent.addCategory(Intent.CATEGORY_OPENABLE) - intent.type = "audio/mpeg" - intent.putExtra(Intent.EXTRA_TITLE, File(state.uri.path).name) - startActivityForResult(intent, CREATE_AUDIO_FILE_REQ) - } - } - - private fun renderImage(state: GemState.ResponseImage) = runOnUiThread{ - loadingView(false) - ImageDialog.show(this, state){ state -> - imageState = state - val intent = Intent(Intent.ACTION_CREATE_DOCUMENT) - intent.addCategory(Intent.CATEGORY_OPENABLE) - intent.type = "image/*" - intent.putExtra(Intent.EXTRA_TITLE, File(state.uri.path).name) - startActivityForResult(intent, CREATE_IMAGE_FILE_REQ) - } - } - - private fun renderBinary(state: GemState.ResponseBinary) = runOnUiThread{ - loadingView(false) - binaryState = state - val intent = Intent(Intent.ACTION_CREATE_DOCUMENT) - intent.addCategory(Intent.CATEGORY_OPENABLE) - intent.type = state.header.meta - intent.putExtra(Intent.EXTRA_TITLE, File(state.uri.path).name) - startActivityForResult(intent, CREATE_BINARY_FILE_REQ) - } - - override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { - super.onActivityResult(requestCode, resultCode, data) - if(resultCode == RESULT_OK && (requestCode == CREATE_IMAGE_FILE_REQ || requestCode == CREATE_AUDIO_FILE_REQ || requestCode == CREATE_BINARY_FILE_REQ)){ - //todo - tidy this mess up... refactor - none of this should be here - if(imageState == null && audioState == null && binaryState == null) return - data?.data?.let{ uri -> - val cachedFile = when { - imageState != null -> File(imageState!!.cacheUri.path ?: "") - audioState != null -> File(audioState!!.cacheUri.path ?: "") - binaryState != null -> File(binaryState!!.cacheUri.path ?: "") - else -> { - println("File download error - no state object exists") - showAlert("File download error - no state object exists") - null - } - } - - cachedFile?.let{ - contentResolver.openFileDescriptor(uri, "w")?.use { fileDescriptor -> - FileOutputStream(fileDescriptor.fileDescriptor).use { destOutput -> - val sourceChannel = FileInputStream(cachedFile).channel - val destChannel = destOutput.channel - sourceChannel.transferTo(0, sourceChannel.size(), destChannel) - sourceChannel.close() - destChannel.close() - - cachedFile.deleteOnExit() - - if(binaryState != null){ - startActivity(Intent(DownloadManager.ACTION_VIEW_DOWNLOADS)) - }else{ - Snackbar.make(binding.root, "File saved to device", Snackbar.LENGTH_SHORT).show() - } - } - } - } - } - - imageState = null - audioState = null - binaryState = null - } - } - - private fun loadingView(visible: Boolean) = runOnUiThread { - binding.progressBar.visibleRetainingSpace(visible) - if(visible) binding.appBar.setExpanded(true) - } - - override fun onBackPressed() { - if(model.canGoBack()){ - model.goBack{ state -> - /* - Passing the callback here so we can eventually add a mechanism to restore scroll position - */ - handleState(state) - } - }else{ - println("Ariane history is empty - exiting") - super.onBackPressed() - cacheDir.deleteRecursively() - } - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/ui/GemViewModel.kt b/app/src/main/java/oppen/ariane/ui/GemViewModel.kt deleted file mode 100644 index 197cff3..0000000 --- a/app/src/main/java/oppen/ariane/ui/GemViewModel.kt +++ /dev/null @@ -1,53 +0,0 @@ -package oppen.ariane.ui - -import android.net.Uri -import androidx.lifecycle.ViewModel -import oppen.ariane.io.gemini.Datasource -import oppen.ariane.io.GemState -import oppen.ariane.io.database.ArianeDatabase -import oppen.ariane.io.database.bookmarks.BookmarksDatasource -import java.net.URI - -class GemViewModel: ViewModel() { - - private lateinit var gemini: Datasource - private lateinit var db: ArianeDatabase - private var onState: (state: GemState) -> Unit = {} - - fun initialise(home: String, gemini: Datasource, db: ArianeDatabase, onState: (state: GemState) -> Unit){ - this.gemini = gemini - this.db = db - this.onState = onState - - request(home) - } - - fun request(address: String) { - request(URI.create(address)) - } - - fun request(uri: URI){ - gemini.request(uri){ state -> - onState(state) - } - } - - fun requestBinaryDownload(uri: URI) { - gemini.request(uri, true){ state -> - onState(state) - } - } - - //todo - same action as above... refactor - fun requestInlineImage(uri: URI, onImageReady: (cacheUri: Uri?) -> Unit){ - gemini.request(uri){ state -> - when (state) { - is GemState.ResponseImage -> onImageReady(state.cacheUri) - else -> onState(state) - } - } - } - - fun canGoBack(): Boolean = gemini.canGoBack() - fun goBack(onGoBack: (state: GemState) -> Unit) = gemini.goBack(onGoBack) -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/ui/GemtextAdapter.kt b/app/src/main/java/oppen/ariane/ui/GemtextAdapter.kt deleted file mode 100644 index dfbc202..0000000 --- a/app/src/main/java/oppen/ariane/ui/GemtextAdapter.kt +++ /dev/null @@ -1,188 +0,0 @@ -package oppen.ariane.ui - -import android.annotation.SuppressLint -import android.net.Uri -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.recyclerview.widget.RecyclerView -import kotlinx.android.synthetic.main.gemtext_code_block.view.* -import kotlinx.android.synthetic.main.gemtext_image_link.view.* -import kotlinx.android.synthetic.main.gemtext_link.view.gemtext_text_link -import kotlinx.android.synthetic.main.gemtext_text.view.gemtext_text_textview -import oppen.ariane.R -import oppen.endsWithImage -import oppen.visible -import java.net.URI - -class GemtextAdapter(val onLink: (adapter: GemtextAdapter, link: URI, longTap: Boolean, adapterPosition: Int, view: View?) -> Unit): RecyclerView.Adapter() { - - var lines = mutableListOf() - var inlineImages = HashMap() - - private val typeText = 0 - private val typeH1 = 1 - private val typeH2 = 2 - private val typeH3 = 3 - private val typeListItem = 4 - private val typeImageLink = 5 - private val typeLink = 6 - private val typeCodeBlock = 7 - private val typeQuote = 8 - - sealed class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView){ - class Text(itemView: View): ViewHolder(itemView) - class H1(itemView: View): ViewHolder(itemView) - class H2(itemView: View): ViewHolder(itemView) - class H3(itemView: View): ViewHolder(itemView) - class ListItem(itemView: View): ViewHolder(itemView) - class ImageLink(itemView: View): ViewHolder(itemView) - class Link(itemView: View): ViewHolder(itemView) - class Code(itemView: View): ViewHolder(itemView) - class Quote(itemView: View): ViewHolder(itemView) - } - - fun render(lines: List){ - this.inlineImages.clear() - this.lines.clear() - this.lines.addAll(lines) - notifyDataSetChanged() - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - return when(viewType){ - typeText -> ViewHolder.Text(LayoutInflater.from(parent.context).inflate(R.layout.gemtext_text, parent, false)) - typeH1 -> ViewHolder.H1(LayoutInflater.from(parent.context).inflate(R.layout.gemtext_h1, parent, false)) - typeH2 -> ViewHolder.H2(LayoutInflater.from(parent.context).inflate(R.layout.gemtext_h2, parent, false)) - typeH3 -> ViewHolder.H3(LayoutInflater.from(parent.context).inflate(R.layout.gemtext_h3, parent, false)) - typeListItem -> ViewHolder.ListItem(LayoutInflater.from(parent.context).inflate(R.layout.gemtext_text, parent, false)) - typeImageLink -> ViewHolder.ImageLink(LayoutInflater.from(parent.context).inflate(R.layout.gemtext_image_link, parent, false)) - typeLink -> ViewHolder.Link(LayoutInflater.from(parent.context).inflate(R.layout.gemtext_link, parent, false)) - typeCodeBlock-> ViewHolder.Code(LayoutInflater.from(parent.context).inflate(R.layout.gemtext_code_block, parent, false)) - typeQuote -> ViewHolder.Quote(LayoutInflater.from(parent.context).inflate(R.layout.gemtext_quote, parent, false)) - else -> ViewHolder.Text(LayoutInflater.from(parent.context).inflate(R.layout.gemtext_text, parent, false)) - } - } - - override fun getItemViewType(position: Int): Int { - val line = lines[position] - return when { - line.startsWith("```") -> typeCodeBlock - line.startsWith("###") -> typeH3 - line.startsWith("##") -> typeH2 - line.startsWith("#") -> typeH1 - line.startsWith("*") -> typeListItem - line.startsWith("=>") && getLink(line).endsWithImage() -> typeImageLink - line.startsWith("=>") -> typeLink - line.startsWith(">") -> typeQuote - else -> typeText - } - } - - override fun getItemCount(): Int = lines.size - - @SuppressLint("SetTextI18n") - override fun onBindViewHolder(holder: ViewHolder, position: Int) { - val line = lines[position] - - when(holder){ - is ViewHolder.Text -> holder.itemView.gemtext_text_textview.text = line - is ViewHolder.Code-> holder.itemView.gemtext_text_monospace_textview.text = line.substring(3) - is ViewHolder.Quote-> holder.itemView.gemtext_text_monospace_textview.text = line.substring(1).trim() - is ViewHolder.H1 -> { - when { - line.length > 2 -> holder.itemView.gemtext_text_textview.text = line.substring(2).trim() - else -> holder.itemView.gemtext_text_textview.text = "" - } - } - is ViewHolder.H2 -> { - when { - line.length > 3 -> holder.itemView.gemtext_text_textview.text = line.substring(3).trim() - else -> holder.itemView.gemtext_text_textview.text = "" - } - } - is ViewHolder.H3 -> { - when { - line.length > 4 -> holder.itemView.gemtext_text_textview.text = line.substring(4).trim() - else -> holder.itemView.gemtext_text_textview.text = "" - } - } - is ViewHolder.ListItem -> holder.itemView.gemtext_text_textview.text = "• ${line.substring(1)}".trim() - is ViewHolder.Link -> { - val linkParts = line.substring(2).trim().split("\\s+".toRegex(), 2) - var linkName = linkParts[0] - if(linkParts.size > 1) { - linkName = linkParts[1] - } - val displayText = linkName - holder.itemView.gemtext_text_link.text = displayText - holder.itemView.gemtext_text_link.paint.isUnderlineText = true - holder.itemView.gemtext_text_link.setOnClickListener { - val uri = getUri(lines[holder.adapterPosition]) - println("User clicked link: $uri") - onLink(this, uri, false, holder.adapterPosition, null) - - } - holder.itemView.gemtext_text_link.setOnLongClickListener {view -> - val uri = getUri(lines[holder.adapterPosition]) - println("User long-clicked link: $uri") - onLink(this, uri, true, holder.adapterPosition, view) - true - } - } - is ViewHolder.ImageLink -> { - //todo - extract, largely duplicate of above - val linkParts = line.substring(2).trim().split("\\s+".toRegex(), 2) - var linkName = linkParts[0] - if(linkParts.size > 1) { - linkName = linkParts[1] - } - val displayText = linkName - holder.itemView.gemtext_text_link.text = displayText - holder.itemView.gemtext_text_link.paint.isUnderlineText = true - holder.itemView.gemtext_text_link.setOnClickListener { - val uri = getUri(lines[holder.adapterPosition]) - println("User clicked link: $uri") - onLink(this, uri, false, holder.adapterPosition, null) - - } - holder.itemView.gemtext_text_link.setOnLongClickListener {view -> - val uri = getUri(lines[holder.adapterPosition]) - println("User long-clicked link: $uri") - onLink(this, uri, true, holder.adapterPosition, view) - true - } - - if(inlineImages.containsKey(position)){ - holder.itemView.gemtext_inline_image.visible(true) - holder.itemView.gemtext_inline_image.setImageURI(inlineImages[position]) - }else{ - holder.itemView.gemtext_inline_image.visible(false) - } - } - } - } - - private fun getLink(line: String): String{ - val linkParts = line.substring(2).trim().split("\\s+".toRegex(), 2) - return linkParts[0] - } - - private fun getUri(linkLine: String): URI{ - val linkParts = linkLine.substring(2).trim().split("\\s+".toRegex(), 2) - return URI.create(linkParts.first()) - } - - fun inferTitle(): String? { - lines.forEach { line -> - if(line.startsWith("#")) return line.replace("#", "").trim() - } - - return null - } - - fun loadImage(position: Int, cacheUri: Uri){ - inlineImages[position] = cacheUri - notifyItemChanged(position) - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/ui/ProcessTextActivity.kt b/app/src/main/java/oppen/ariane/ui/ProcessTextActivity.kt deleted file mode 100644 index 95b8e58..0000000 --- a/app/src/main/java/oppen/ariane/ui/ProcessTextActivity.kt +++ /dev/null @@ -1,24 +0,0 @@ -package oppen.ariane.ui - -import android.content.Intent -import android.os.Build -import android.os.Bundle -import androidx.appcompat.app.AppCompatActivity - -class ProcessTextActivity: AppCompatActivity() { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - val processText = when { - Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && intent.hasExtra(Intent.EXTRA_PROCESS_TEXT) -> intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT).toString() - else -> null - } - - Intent(this, GemActivity::class.java).run { - putExtra("process_text", processText) - startActivity(this) - finish() - } - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/ui/audio_player/AudioPlayer.kt b/app/src/main/java/oppen/ariane/ui/audio_player/AudioPlayer.kt deleted file mode 100644 index 5a86bd3..0000000 --- a/app/src/main/java/oppen/ariane/ui/audio_player/AudioPlayer.kt +++ /dev/null @@ -1,95 +0,0 @@ -package oppen.ariane.ui.audio_player - -import android.content.Context -import android.media.MediaMetadataRetriever -import android.media.MediaPlayer -import android.view.MenuInflater -import androidx.appcompat.widget.PopupMenu -import androidx.core.view.MenuCompat -import oppen.ariane.R -import oppen.ariane.databinding.ActivityGemBinding -import oppen.ariane.io.GemState -import oppen.visible - -object AudioPlayer { - - fun play(context: Context, - binding: ActivityGemBinding, - mediaPlayer: MediaPlayer, - state: GemState.ResponseAudio, - onSaveAudio: (state: GemState.ResponseAudio) -> Unit){ - val metadataRetriever = MediaMetadataRetriever() - metadataRetriever.setDataSource(context, state.cacheUri) - - val artist = metadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST) - val trackName = metadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE) - - binding.audioTitle.text = "$trackName - $artist" - - mediaPlayer.reset() - mediaPlayer.setDataSource(context, state.cacheUri) - mediaPlayer.prepare() - - binding.audioPlayButton.setImageResource(R.drawable.vector_pause) - - mediaPlayer.setOnCompletionListener { _ -> - binding.audioPlayButton.setImageResource(R.drawable.vector_play) - } - - binding.audioPlayButton.setOnClickListener { - if(mediaPlayer.isPlaying){ - binding.audioPlayButton.setImageResource(R.drawable.vector_play) - mediaPlayer.pause() - }else{ - binding.audioPlayButton.setImageResource(R.drawable.vector_pause) - mediaPlayer.start() - } - } - - mediaPlayer.setOnInfoListener { _, what, _ -> - when(what){ - MediaPlayer.MEDIA_INFO_UNKNOWN -> println("MEDIA_INFO_UNKNOWN") - MediaPlayer.MEDIA_INFO_VIDEO_TRACK_LAGGING-> println("MEDIA_INFO_VIDEO_TRACK_LAGGING") - MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START-> println("MEDIA_INFO_VIDEO_RENDERING_START") - MediaPlayer.MEDIA_INFO_BUFFERING_START-> println("MEDIA_INFO_BUFFERING_START") - MediaPlayer.MEDIA_INFO_BUFFERING_END-> println("MEDIA_INFO_BUFFERING_END") - MediaPlayer.MEDIA_INFO_BAD_INTERLEAVING-> println("MEDIA_INFO_BAD_INTERLEAVING") - MediaPlayer.MEDIA_INFO_NOT_SEEKABLE-> println("MEDIA_INFO_NOT_SEEKABLE") - MediaPlayer.MEDIA_INFO_METADATA_UPDATE-> println("MEDIA_INFO_METADATA_UPDATE") - MediaPlayer.MEDIA_INFO_UNSUPPORTED_SUBTITLE-> println("MEDIA_INFO_UNSUPPORTED_SUBTITLE") - MediaPlayer.MEDIA_INFO_SUBTITLE_TIMED_OUT-> println("MEDIA_INFO_SUBTITLE_TIMED_OUT") - } - - true - } - - mediaPlayer.setOnErrorListener{ _, i: Int, i1: Int -> - println("Error Listener.... $i, $i1") - true - } - - binding.audioPlayer.visible(true) - mediaPlayer.start() - - binding.audioOverflow.setOnClickListener { - val popup = PopupMenu(context, binding.audioOverflow) - val inflater: MenuInflater = popup.menuInflater - inflater.inflate(R.menu.audio_overflow, popup.menu) - popup.setOnMenuItemClickListener { menuItem -> - when(menuItem.itemId){ - R.id.audio_overflow_save_file -> { - onSaveAudio(state) - } - R.id.audio_overflow_dismiss -> { - mediaPlayer.stop() - mediaPlayer.release() - binding.audioPlayer.visible(false) - } - } - true - } - MenuCompat.setGroupDividerEnabled(popup.menu, true) - popup.show() - } - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/ui/bookmarks/BookmarkDialog.kt b/app/src/main/java/oppen/ariane/ui/bookmarks/BookmarkDialog.kt deleted file mode 100644 index eded755..0000000 --- a/app/src/main/java/oppen/ariane/ui/bookmarks/BookmarkDialog.kt +++ /dev/null @@ -1,83 +0,0 @@ -package oppen.ariane.ui.bookmarks - -import android.content.Context -import android.os.Handler -import android.os.Looper -import android.view.View -import androidx.appcompat.app.AppCompatDialog -import kotlinx.android.synthetic.main.fragment_bookmark_dialog.view.* -import oppen.ariane.R -import oppen.ariane.io.database.bookmarks.BookmarkEntry -import oppen.ariane.io.database.bookmarks.BookmarksDatasource -import java.net.URI - - -class BookmarkDialog( - context: Context, - private val mode: Int, - private val bookmarkDatasource: BookmarksDatasource?, - val uri: String, - val name: String, - onDismiss: (label: String?, uri: String?) -> Unit) : AppCompatDialog(context, R.style.FSDialog) { - - companion object{ - const val mode_new = 0 - const val mode_edit = 1 - } - - init { - val view = View.inflate(context, R.layout.fragment_bookmark_dialog, null) - - setContentView(view) - - view.bookmark_toolbar.setNavigationIcon(R.drawable.vector_close) - view.bookmark_toolbar.setNavigationOnClickListener { - onDismiss(null, null) - dismiss() - } - - view.bookmark_name.setText(name) - view.bookmark_uri.setText(uri) - - view.bookmark_toolbar.inflateMenu(R.menu.add_bookmark) - view.bookmark_toolbar.setOnMenuItemClickListener {menuItem -> - if(menuItem.itemId == R.id.menu_action_save_bookmark){ - - if(mode == mode_new) { - //Determine index: - //todo - this is expensive, just get last item, limit1? - bookmarkDatasource?.get { allBookmarks -> - - val index = when { - allBookmarks.isEmpty() -> 0 - else -> allBookmarks.last().index + 1 - } - - bookmarkDatasource.add( - - BookmarkEntry( - uid = -1, - label = view.bookmark_name.text.toString(), - uri = URI.create(view.bookmark_uri.text.toString()), - index = index - ) - ) { - Handler(Looper.getMainLooper()).post { - onDismiss(null, null) - dismiss() - } - } - } - }else if(mode == mode_edit){ - onDismiss( - view.bookmark_name.text.toString(), - view.bookmark_uri.text.toString()) - dismiss() - } - } - - true - - } - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/ui/bookmarks/BookmarksAdapter.kt b/app/src/main/java/oppen/ariane/ui/bookmarks/BookmarksAdapter.kt deleted file mode 100644 index 95026b2..0000000 --- a/app/src/main/java/oppen/ariane/ui/bookmarks/BookmarksAdapter.kt +++ /dev/null @@ -1,69 +0,0 @@ -package oppen.ariane.ui.bookmarks - -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.recyclerview.widget.RecyclerView -import kotlinx.android.synthetic.main.bookmark.view.* -import oppen.ariane.R -import oppen.ariane.io.database.bookmarks.BookmarkEntry -import oppen.visible - -class BookmarksAdapter(val onBookmark: (bookmarkEntry: BookmarkEntry) -> Unit, val onOverflow: (view: View, bookmarkEntry: BookmarkEntry, isFirst: Boolean, isLast: Boolean) -> Unit): RecyclerView.Adapter() { - - val bookmarks = mutableListOf() - - class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) - - fun update(bookmarkEntries: List){ - this.bookmarks.clear() - this.bookmarks.addAll(bookmarkEntries) - notifyDataSetChanged() - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - return ViewHolder( - LayoutInflater.from(parent.context).inflate(R.layout.bookmark, parent, false) - ) - } - - override fun onBindViewHolder(holder: ViewHolder, position: Int) { - val bookmark = bookmarks[position] - - if(bookmark.visible) { - holder.itemView.visible(true) - holder.itemView.bookmark_name.text = bookmark.label - holder.itemView.bookmark_uri.text = bookmark.uri.toString() - - holder.itemView.bookmark_layout.setOnClickListener { - onBookmark(bookmarks[holder.adapterPosition]) - } - - holder.itemView.bookmark_overflow.setOnClickListener { view -> - val isFirst = (holder.adapterPosition == 0) - val isLast = (holder.adapterPosition == bookmarks.size - 1) - onOverflow(view, bookmarks[holder.adapterPosition], isFirst, isLast) - } - }else{ - holder.itemView.visible(false) - } - } - - override fun getItemCount(): Int = bookmarks.size - - fun hide(bookmarkEntry: BookmarkEntry) { - bookmarkEntry.visible = false - notifyItemChanged(bookmarks.indexOf(bookmarkEntry)) - } - - fun show(bookmarkEntry: BookmarkEntry) { - bookmarkEntry.visible = true - notifyItemChanged(bookmarks.indexOf(bookmarkEntry)) - } - - fun remove(bookmarkEntry: BookmarkEntry){ - val index = bookmarks.indexOf(bookmarkEntry) - bookmarks.remove(bookmarkEntry) - notifyItemRemoved(index) - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/ui/bookmarks/BookmarksDialog.kt b/app/src/main/java/oppen/ariane/ui/bookmarks/BookmarksDialog.kt deleted file mode 100644 index 620df92..0000000 --- a/app/src/main/java/oppen/ariane/ui/bookmarks/BookmarksDialog.kt +++ /dev/null @@ -1,138 +0,0 @@ -package oppen.ariane.ui.bookmarks - -import android.content.Context -import android.os.Handler -import android.os.Looper -import android.view.View -import androidx.appcompat.app.AppCompatDialog -import androidx.appcompat.widget.PopupMenu -import androidx.recyclerview.widget.LinearLayoutManager -import com.google.android.material.snackbar.BaseTransientBottomBar -import com.google.android.material.snackbar.Snackbar -import kotlinx.android.synthetic.main.dialog_bookmarks.view.* -import oppen.ariane.R -import oppen.ariane.io.database.bookmarks.BookmarkEntry -import oppen.ariane.io.database.bookmarks.BookmarksDatasource -import oppen.visible - - -class BookmarksDialog( - context: Context, - private val bookmarkDatasource: BookmarksDatasource, - onBookmark: (bookmarkEntry: BookmarkEntry) -> Unit): AppCompatDialog(context, R.style.FSDialog) { - - var bookmarksAdapter: BookmarksAdapter - - var view: View = View.inflate(context, R.layout.dialog_bookmarks, null) - - init { - - setContentView(view) - - view.bookmarks_toolbar.setNavigationIcon(R.drawable.vector_close) - view.bookmarks_toolbar.setNavigationOnClickListener { - dismiss() - } - - //None as yet - view.bookmarks_toolbar.inflateMenu(R.menu.add_bookmarks) - view.bookmarks_toolbar.setOnMenuItemClickListener {_ -> - true - } - - view.bookmarks_recycler.layoutManager = LinearLayoutManager(context) - - bookmarksAdapter = BookmarksAdapter({ bookmark -> - //onBookmark - onBookmark(bookmark) - dismiss() - - }){ view, bookmark, isFirst, isLast -> - //onOverflow - val bookmarkOverflow = PopupMenu(context, view) - - bookmarkOverflow.inflate(R.menu.menu_bookmark) - - if(isFirst) bookmarkOverflow.menu.removeItem(R.id.menu_bookmark_move_up) - if(isLast) bookmarkOverflow.menu.removeItem(R.id.menu_bookmark_move_down) - - bookmarkOverflow.setOnMenuItemClickListener { menuItem -> - when(menuItem.itemId){ - R.id.menu_bookmark_edit -> edit(bookmark) - R.id.menu_bookmark_delete -> delete(bookmark) - R.id.menu_bookmark_move_up -> moveUp(bookmark) - R.id.menu_bookmark_move_down-> moveDown(bookmark) - } - true - } - - bookmarkOverflow.show() - } - - view.bookmarks_recycler.adapter = bookmarksAdapter - - bookmarkDatasource.get { bookmarks -> - - Handler(Looper.getMainLooper()).post { - when { - bookmarks.isEmpty() -> view.bookmarks_empty_layout.visible(true) - else -> bookmarksAdapter.update(bookmarks) - } - } - } - } - - private fun edit(bookmarkEntry: BookmarkEntry){ - BookmarkDialog(context, BookmarkDialog.mode_edit, null, bookmarkEntry.uri.toString(), bookmarkEntry.label){ label, uri -> - bookmarkDatasource.update(bookmarkEntry, label, uri){ - bookmarkDatasource.get {bookmarks -> - Handler(Looper.getMainLooper()).post { - bookmarksAdapter.update(bookmarks) - } - } - } - }.show() - } - - /** - * - * Bookmark isn't actually deleted from the DB until the Snackbar disappears. Which is nice. - * - */ - private fun delete(bookmarkEntry: BookmarkEntry){ - //OnDelete - bookmarksAdapter.hide(bookmarkEntry) - Snackbar.make(view, "Deleted ${bookmarkEntry.label}", Snackbar.LENGTH_SHORT).addCallback(object: Snackbar.Callback() { - override fun onDismissed(transientBottomBar: Snackbar?, event: Int) = when (event) { - BaseTransientBottomBar.BaseCallback.DISMISS_EVENT_ACTION -> bookmarksAdapter.show(bookmarkEntry) - else -> bookmarkDatasource.delete(bookmarkEntry){ - Handler(Looper.getMainLooper()).post { - bookmarksAdapter.remove(bookmarkEntry) - } - } - } - }).setAction("Undo"){ - //Action listener unused - }.show() - } - - private fun moveUp(bookmarkEntry: BookmarkEntry){ - bookmarkDatasource.moveUp(bookmarkEntry){ - bookmarkDatasource.get { bookmarks -> - Handler(Looper.getMainLooper()).post { - bookmarksAdapter.update(bookmarks) - } - } - } - } - - private fun moveDown(bookmarkEntry: BookmarkEntry){ - bookmarkDatasource.moveDown(bookmarkEntry){ - bookmarkDatasource.get { bookmarks -> - Handler(Looper.getMainLooper()).post { - bookmarksAdapter.update(bookmarks) - } - } - } - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/ui/content_image/ImageDialog.kt b/app/src/main/java/oppen/ariane/ui/content_image/ImageDialog.kt deleted file mode 100644 index d31d88d..0000000 --- a/app/src/main/java/oppen/ariane/ui/content_image/ImageDialog.kt +++ /dev/null @@ -1,62 +0,0 @@ -package oppen.ariane.ui.content_image - -import android.content.Context -import android.graphics.Bitmap -import android.net.Uri -import android.view.MenuInflater -import android.view.View -import androidx.appcompat.app.AppCompatDialog -import androidx.appcompat.widget.PopupMenu -import kotlinx.android.synthetic.main.dialog_content_image.view.* -import oppen.ariane.R -import oppen.ariane.io.GemState -import java.io.FileOutputStream - -object ImageDialog { - - fun show(context: Context, state: GemState.ResponseImage, onDownloadRequest: (state: GemState.ResponseImage) -> Unit){ - val dialog = AppCompatDialog(context, R.style.AppTheme) - - val view = View.inflate(context, R.layout.dialog_content_image, null) - dialog.setContentView(view) - - view.image_view.setImageURI(state.cacheUri) - - view.close_image_content_dialog.setOnClickListener { - dialog.dismiss() - } - - view.image_overflow.setOnClickListener { - val overflowMenu = PopupMenu(context, view.image_overflow) - val inflater: MenuInflater = overflowMenu.menuInflater - inflater.inflate(R.menu.image_overflow_menu, overflowMenu.menu) - overflowMenu.setOnMenuItemClickListener { menuItem -> - if(menuItem.itemId == R.id.image_overflow_save_image){ - onDownloadRequest(state) - } - true - } - - overflowMenu.show() - } - - dialog.show() - } - - /** - * - * Save bitmap using Storage Access Framework Uri - * @param bitmap - * @param uri - must be a SAF Uri - * @param onComplete - */ - fun publicExport(context: Context, bitmap: Bitmap?, uri: Uri, onComplete: (uri: Uri) -> Unit) { - context.contentResolver.openFileDescriptor(uri, "w")?.use { - FileOutputStream(it.fileDescriptor).use { outputStream -> - bitmap?.compress(Bitmap.CompressFormat.JPEG, 90, outputStream) - } - bitmap?.recycle() - onComplete(uri) - } - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/ui/content_image/TouchImageView.java b/app/src/main/java/oppen/ariane/ui/content_image/TouchImageView.java deleted file mode 100644 index 661759c..0000000 --- a/app/src/main/java/oppen/ariane/ui/content_image/TouchImageView.java +++ /dev/null @@ -1,306 +0,0 @@ -package oppen.ariane.ui.content_image; - - - -import android.content.Context; -import android.graphics.Matrix; -import android.graphics.PointF; -import android.graphics.drawable.Drawable; -import android.util.AttributeSet; -import android.util.Log; -import android.view.GestureDetector; -import android.view.MotionEvent; -import android.view.ScaleGestureDetector; -import android.view.View; - -/** - * - * From SO: https://stackoverflow.com/a/54474590/7641428 - * - * todo - Rewrite in Kotlin at some point, possibly, maybe, never - * - */ -public class TouchImageView extends androidx.appcompat.widget.AppCompatImageView implements GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener { - - Matrix matrix; - - // We can be in one of these 3 states - static final int NONE = 0; - static final int DRAG = 1; - static final int ZOOM = 2; - int mode = NONE; - - // Remember some things for zooming - PointF last = new PointF(); - PointF start = new PointF(); - float minScale = 0.9f; - float maxScale = 3f; - float[] m; - - int viewWidth, viewHeight; - static final int CLICK = 3; - float saveScale = 1f; - protected float origWidth, origHeight; - int oldMeasuredWidth, oldMeasuredHeight; - - ScaleGestureDetector mScaleDetector; - - Context context; - - public TouchImageView(Context context) { - super(context); - sharedConstructing(context); - } - - public TouchImageView(Context context, AttributeSet attrs) { - super(context, attrs); - sharedConstructing(context); - } - - GestureDetector mGestureDetector; - - private void sharedConstructing(Context context) { - super.setClickable(true); - this.context = context; - mGestureDetector = new GestureDetector(context, this); - mGestureDetector.setOnDoubleTapListener(this); - - mScaleDetector = new ScaleGestureDetector(context, new ScaleListener()); - matrix = new Matrix(); - m = new float[9]; - setImageMatrix(matrix); - setScaleType(ScaleType.MATRIX); - - setOnTouchListener(new OnTouchListener() { - - @Override - public boolean onTouch(View v, MotionEvent event) { - mScaleDetector.onTouchEvent(event); - mGestureDetector.onTouchEvent(event); - - PointF curr = new PointF(event.getX(), event.getY()); - - switch (event.getAction()) { - case MotionEvent.ACTION_DOWN: - last.set(curr); - start.set(last); - mode = DRAG; - break; - - case MotionEvent.ACTION_MOVE: - if (mode == DRAG) { - float deltaX = curr.x - last.x; - float deltaY = curr.y - last.y; - float fixTransX = getFixDragTrans(deltaX, viewWidth, - origWidth * saveScale); - float fixTransY = getFixDragTrans(deltaY, viewHeight, - origHeight * saveScale); - matrix.postTranslate(fixTransX, fixTransY); - fixTrans(); - last.set(curr.x, curr.y); - } - break; - - case MotionEvent.ACTION_UP: - mode = NONE; - int xDiff = (int) Math.abs(curr.x - start.x); - int yDiff = (int) Math.abs(curr.y - start.y); - if (xDiff < CLICK && yDiff < CLICK) - performClick(); - break; - - case MotionEvent.ACTION_POINTER_UP: - mode = NONE; - break; - } - - setImageMatrix(matrix); - invalidate(); - return true; // indicate event was handled - } - - }); - - invalidate(); - } - - public void setMaxZoom(float x) { - maxScale = x; - } - - @Override - public boolean onSingleTapConfirmed(MotionEvent e) { - return false; - } - - public void reset(){ - saveScale = 1f; - fixTrans(); - } - - @Override - public boolean onDoubleTap(MotionEvent e) { - // Double tap is detected - - float origScale = saveScale; - float mScaleFactor; - - if (saveScale == maxScale) { - saveScale = minScale; - mScaleFactor = minScale / origScale; - } else { - saveScale = maxScale; - mScaleFactor = maxScale / origScale; - } - - matrix.postScale(mScaleFactor, mScaleFactor, viewWidth / 2f, viewHeight / 2f); - - fixTrans(); - - return false; - } - - @Override - public boolean onDoubleTapEvent(MotionEvent e) { - return false; - } - - @Override - public boolean onDown(MotionEvent e) { - return false; - } - - @Override - public void onShowPress(MotionEvent e) { - - } - - @Override - public boolean onSingleTapUp(MotionEvent e) { - return false; - } - - @Override - public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { - return false; - } - - @Override - public void onLongPress(MotionEvent e) { - - } - - @Override - public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { - return false; - } - - private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener { - @Override - public boolean onScaleBegin(ScaleGestureDetector detector) { - mode = ZOOM; - return true; - } - - @Override - public boolean onScale(ScaleGestureDetector detector) { - float mScaleFactor = detector.getScaleFactor(); - float origScale = saveScale; - saveScale *= mScaleFactor; - if (saveScale > maxScale) { - saveScale = maxScale; - mScaleFactor = maxScale / origScale; - } else if (saveScale < minScale) { - saveScale = minScale; - mScaleFactor = minScale / origScale; - } - - if (origWidth * saveScale <= viewWidth || origHeight * saveScale <= viewHeight) { - matrix.postScale(mScaleFactor, mScaleFactor, viewWidth / 2f, viewHeight / 2f); - }else { - matrix.postScale(mScaleFactor, mScaleFactor, detector.getFocusX(), detector.getFocusY()); - } - - fixTrans(); - return true; - } - } - - void fixTrans() { - matrix.getValues(m); - float transX = m[Matrix.MTRANS_X]; - float transY = m[Matrix.MTRANS_Y]; - - float fixTransX = getFixTrans(transX, viewWidth, origWidth * saveScale); - float fixTransY = getFixTrans(transY, viewHeight, origHeight * saveScale); - - if (fixTransX != 0 || fixTransY != 0) matrix.postTranslate(fixTransX, fixTransY); - } - - float getFixTrans(float trans, float viewSize, float contentSize) { - float minTrans, maxTrans; - - if (contentSize <= viewSize) { - minTrans = 0; - maxTrans = viewSize - contentSize; - } else { - minTrans = viewSize - contentSize; - maxTrans = 0; - } - - if (trans < minTrans) return -trans + minTrans; - if (trans > maxTrans) return -trans + maxTrans; - return 0; - } - - float getFixDragTrans(float delta, float viewSize, float contentSize) { - if (contentSize <= viewSize) { - return 0; - } - return delta; - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - viewWidth = MeasureSpec.getSize(widthMeasureSpec); - viewHeight = MeasureSpec.getSize(heightMeasureSpec); - - // - // Rescales image on rotation - // - if (oldMeasuredHeight == viewWidth && oldMeasuredHeight == viewHeight || viewWidth == 0 || viewHeight == 0) return; - oldMeasuredHeight = viewHeight; - oldMeasuredWidth = viewWidth; - - if (saveScale == 1) { - // Fit to screen. - float scale; - - Drawable drawable = getDrawable(); - if (drawable == null || drawable.getIntrinsicWidth() == 0 || drawable.getIntrinsicHeight() == 0) return; - int bmWidth = drawable.getIntrinsicWidth(); - int bmHeight = drawable.getIntrinsicHeight(); - - Log.d("bmSize", "bmWidth: " + bmWidth + " bmHeight : " + bmHeight); - - float scaleX = (float) viewWidth / (float) bmWidth; - float scaleY = (float) viewHeight / (float) bmHeight; - scale = Math.min(scaleX, scaleY); - matrix.setScale(scale, scale); - - // Center the image - float redundantYSpace = (float) viewHeight - (scale * (float) bmHeight); - float redundantXSpace = (float) viewWidth - (scale * (float) bmWidth); - redundantYSpace /= (float) 2; - redundantXSpace /= (float) 2; - - matrix.postTranslate(redundantXSpace, redundantYSpace); - - origWidth = viewWidth - 2 * redundantXSpace; - origHeight = viewHeight - 2 * redundantYSpace; - setImageMatrix(matrix); - } - fixTrans(); - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/ui/content_text/TextDialog.kt b/app/src/main/java/oppen/ariane/ui/content_text/TextDialog.kt deleted file mode 100644 index b08c80c..0000000 --- a/app/src/main/java/oppen/ariane/ui/content_text/TextDialog.kt +++ /dev/null @@ -1,27 +0,0 @@ -package oppen.ariane.ui.content_text - -import android.content.Context -import android.view.View -import androidx.appcompat.app.AppCompatDialog -import kotlinx.android.synthetic.main.dialog_content_text.view.* -import oppen.ariane.R -import oppen.ariane.io.GemState - -object TextDialog { - - fun show(context: Context, state: GemState.ResponseText){ - val dialog = AppCompatDialog(context, R.style.AppTheme) - - val view = View.inflate(context, R.layout.dialog_content_text, null) - dialog.setContentView(view) - - view.text_content.text = state.content - - view.close_text_content_dialog.setOnClickListener { - dialog.dismiss() - } - - - dialog.show() - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/ui/modals_menus/LinkPopup.kt b/app/src/main/java/oppen/ariane/ui/modals_menus/LinkPopup.kt deleted file mode 100644 index 5d8f985..0000000 --- a/app/src/main/java/oppen/ariane/ui/modals_menus/LinkPopup.kt +++ /dev/null @@ -1,34 +0,0 @@ -package oppen.ariane.ui.modals_menus - -import android.view.MenuInflater -import android.view.View -import androidx.appcompat.widget.PopupMenu -import oppen.ariane.R -import oppen.endsWithImage -import oppen.isWeb -import java.net.URI - -object LinkPopup { - - fun show(view: View?, uri: URI, onMenuOption: (menuId: Int) -> Unit){ - if(view != null) { - - val popup = PopupMenu(view.context, view) - val inflater: MenuInflater = popup.menuInflater - - val uriStr = uri.toString() - - when { - uriStr.endsWithImage() && !uriStr.isWeb() -> inflater.inflate(R.menu.image_link_menu, popup.menu) - else -> inflater.inflate(R.menu.link_menu, popup.menu) - } - - popup.setOnMenuItemClickListener { menuItem -> - onMenuOption(menuItem.itemId) - true - } - - popup.show() - } - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/ui/modals_menus/about/AboutDialog.kt b/app/src/main/java/oppen/ariane/ui/modals_menus/about/AboutDialog.kt deleted file mode 100644 index 4f85c05..0000000 --- a/app/src/main/java/oppen/ariane/ui/modals_menus/about/AboutDialog.kt +++ /dev/null @@ -1,83 +0,0 @@ -package oppen.ariane.ui.modals_menus.about - -import android.content.Context -import android.content.Intent -import android.net.Uri -import android.os.Handler -import android.os.Looper -import android.view.View -import androidx.appcompat.app.AppCompatDialog -import androidx.appcompat.widget.AppCompatTextView -import kotlinx.android.synthetic.main.dialog_about.view.* -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import oppen.ariane.BuildConfig -import oppen.ariane.R -import java.lang.StringBuilder -import java.security.SecureRandom -import javax.net.ssl.SSLContext -import javax.net.ssl.SSLSocket -import javax.net.ssl.SSLSocketFactory - -object AboutDialog { - - fun show(context: Context){ - val dialog = AppCompatDialog(context, R.style.AppTheme) - - val view = View.inflate(context, R.layout.dialog_about, null) - dialog.setContentView(view) - - view.close_tab_dialog.setOnClickListener { - dialog.dismiss() - } - - view.version_label.text = BuildConfig.VERSION_NAME - - view.gnu_license_button.setOnClickListener { - context.startActivity(Intent(Intent.ACTION_VIEW).apply { - data = Uri.parse("https://www.gnu.org/licenses/gpl-3.0.html") - }) - } - - view.oppenlab_button.setOnClickListener { - context.startActivity(Intent(Intent.ACTION_VIEW).apply { - data = Uri.parse("https://oppenlab.net") - }) - } - - buildTLSInfo(view.tls_info) - - - dialog.show() - } - - private fun buildTLSInfo(tlsInfo: AppCompatTextView?) { - GlobalScope.launch { - val sb = StringBuilder() - - val sslContext = SSLContext.getInstance("TLS") - sslContext.init(null, null, SecureRandom()) - val factory: SSLSocketFactory = sslContext.socketFactory - val socket = factory.createSocket() as SSLSocket - - sb.append("\n") - sb.append("Supported TLS protocols on this device:\n\n") - socket.supportedProtocols.forEach { protocol -> - sb.append("$protocol \n") - } - - sb.append("\n\n") - - sb.append("Supported cipher suites on this device:\n\n") - val allCipherSuites = factory.supportedCipherSuites - allCipherSuites.forEach { cipherSuite -> - sb.append("$cipherSuite \n") - } - - sb.append("\n") - Handler(Looper.getMainLooper()).post{ - tlsInfo?.text = sb.toString() - } - } - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/ui/modals_menus/history/HistoryAdapter.kt b/app/src/main/java/oppen/ariane/ui/modals_menus/history/HistoryAdapter.kt deleted file mode 100644 index 36cd767..0000000 --- a/app/src/main/java/oppen/ariane/ui/modals_menus/history/HistoryAdapter.kt +++ /dev/null @@ -1,30 +0,0 @@ -package oppen.ariane.ui.modals_menus.history - -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.recyclerview.widget.RecyclerView -import kotlinx.android.synthetic.main.row_history.view.* -import oppen.delay -import oppen.ariane.R -import oppen.ariane.io.database.history.HistoryEntry - -class HistoryAdapter(val history: List, val onClick:(entry: HistoryEntry) -> Unit): RecyclerView.Adapter() { - - class ViewHolder(view: View): RecyclerView.ViewHolder(view) - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - return ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.row_history, parent, false)) - } - - override fun getItemCount(): Int = history.size - - override fun onBindViewHolder(holder: ViewHolder, position: Int) { - holder.itemView.history_address.text = history[position].uri.toString() - holder.itemView.history_row.setOnClickListener { - delay(500){ - onClick(history[holder.adapterPosition]) - } - } - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/ui/modals_menus/history/HistoryDialog.kt b/app/src/main/java/oppen/ariane/ui/modals_menus/history/HistoryDialog.kt deleted file mode 100644 index 060f76a..0000000 --- a/app/src/main/java/oppen/ariane/ui/modals_menus/history/HistoryDialog.kt +++ /dev/null @@ -1,64 +0,0 @@ -package oppen.ariane.ui.modals_menus.history - -import android.content.Context -import android.os.Handler -import android.os.Looper -import android.view.MenuInflater -import android.view.View -import android.widget.Toast -import androidx.appcompat.app.AppCompatDialog -import androidx.appcompat.widget.PopupMenu -import androidx.core.view.MenuCompat -import androidx.recyclerview.widget.LinearLayoutManager -import kotlinx.android.synthetic.main.dialog_about.view.close_tab_dialog -import kotlinx.android.synthetic.main.dialog_history.view.* -import oppen.ariane.R -import oppen.ariane.io.database.history.ArianeHistory -import oppen.ariane.io.gemini.RuntimeCache - -object HistoryDialog { - fun show(context: Context, history: ArianeHistory, onHistoryItem: (address: String) -> Unit){ - val dialog = AppCompatDialog(context, R.style.AppTheme) - - val view = View.inflate(context, R.layout.dialog_history, null) - dialog.setContentView(view) - - view.close_tab_dialog.setOnClickListener { - dialog.dismiss() - } - - view.history_overflow.setOnClickListener { - val popup = PopupMenu(view.context, view.history_overflow) - val inflater: MenuInflater = popup.menuInflater - inflater.inflate(R.menu.history_overflow_menu, popup.menu) - popup.setOnMenuItemClickListener { menuItem -> - if(menuItem.itemId == R.id.history_overflow_clear_history){ - history.clear { - dialog.dismiss() - Toast.makeText(context, "History cleared", Toast.LENGTH_SHORT).show() - } - }else if(menuItem.itemId == R.id.history_overflow_clear_runtime_cache){ - RuntimeCache.clear() - dialog.dismiss() - Toast.makeText(context, "Runtime cache cleared", Toast.LENGTH_SHORT).show() - } - true - } - MenuCompat.setGroupDividerEnabled(popup.menu, true) - popup.show() - } - - view.history_recycler.layoutManager = LinearLayoutManager(context) - - history.get { history -> - Handler(Looper.getMainLooper()).post { - view.history_recycler.adapter = HistoryAdapter(history) { entry -> - onHistoryItem(entry.uri.toString()) - dialog.dismiss() - } - - dialog.show() - } - } - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/ui/modals_menus/input/InputDialog.kt b/app/src/main/java/oppen/ariane/ui/modals_menus/input/InputDialog.kt deleted file mode 100644 index 59e9b4d..0000000 --- a/app/src/main/java/oppen/ariane/ui/modals_menus/input/InputDialog.kt +++ /dev/null @@ -1,33 +0,0 @@ -package oppen.ariane.ui.modals_menus.input - -import android.content.Context -import android.view.View -import androidx.appcompat.app.AppCompatDialog -import kotlinx.android.synthetic.main.dialog_input_query.view.* -import oppen.ariane.R -import oppen.ariane.io.GemState -import java.net.URLEncoder - -object InputDialog { - - fun show(context: Context, state: GemState.ResponseInput, onQuery: (queryAddress: String) -> Unit) { - val dialog = AppCompatDialog(context, R.style.AppTheme) - - val view = View.inflate(context, R.layout.dialog_input_query, null) - dialog.setContentView(view) - - view.close_input_query_dialog.setOnClickListener { - dialog.dismiss() - } - - view.query_text.text = state.header.meta - - view.query_submit_button.setOnClickListener { - val encoded = URLEncoder.encode(view.query_input.text.toString(), "UTF-8") - onQuery("${state.uri}?$encoded") - dialog.dismiss() - } - - dialog.show() - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/ui/modals_menus/overflow/OverflowPopup.kt b/app/src/main/java/oppen/ariane/ui/modals_menus/overflow/OverflowPopup.kt deleted file mode 100644 index 60921c6..0000000 --- a/app/src/main/java/oppen/ariane/ui/modals_menus/overflow/OverflowPopup.kt +++ /dev/null @@ -1,64 +0,0 @@ -package oppen.ariane.ui.modals_menus.overflow - -import android.content.Context -import android.graphics.Color -import android.graphics.drawable.Drawable -import android.text.SpannableStringBuilder -import android.text.style.ImageSpan -import android.view.Menu -import android.view.MenuInflater -import android.view.MenuItem -import android.view.View -import androidx.appcompat.widget.PopupMenu -import androidx.core.view.MenuCompat -import oppen.ariane.R - - -object OverflowPopup { - - fun show(view: View?, onMenuOption: (menuId: Int) -> Unit){ - if(view != null) { - val popup = PopupMenu(view.context, view) - val inflater: MenuInflater = popup.menuInflater - inflater.inflate(R.menu.overflow_menu, popup.menu) - popup.setOnMenuItemClickListener { menuItem -> - onMenuOption(menuItem.itemId) - true - } - MenuCompat.setGroupDividerEnabled(popup.menu, true) - //insertMenuItemIcons(view.context, popup) - popup.show() - } - } - - fun insertMenuItemIcons(context: Context, popupMenu: PopupMenu) { - val menu: Menu = popupMenu.menu - if (hasIcon(menu)) { - for (i in 0 until menu.size()) { - insertMenuItemIcon(context, menu.getItem(i)) - } - } - } - - private fun hasIcon(menu: Menu): Boolean { - for (i in 0 until menu.size()) { - if (menu.getItem(i).icon != null) return true - } - return false - } - - /** - * Converts the given MenuItem's title into a Spannable containing both its icon and title. - */ - private fun insertMenuItemIcon(context: Context, menuItem: MenuItem) { - val icon: Drawable = menuItem.icon - val iconSize = context.resources.getDimensionPixelSize(R.dimen.menu_item_icon_size) - icon.setBounds(0, 0, iconSize, iconSize) - icon.setTint(Color.WHITE) - val imageSpan = ImageSpan(icon) - val ssb = SpannableStringBuilder(" " + menuItem.title) - ssb.setSpan(imageSpan, 1, 2, 0) - menuItem.title = ssb - menuItem.icon = null - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/ui/modals_menus/set_home/SetHomeDialog.kt b/app/src/main/java/oppen/ariane/ui/modals_menus/set_home/SetHomeDialog.kt deleted file mode 100644 index b488b4d..0000000 --- a/app/src/main/java/oppen/ariane/ui/modals_menus/set_home/SetHomeDialog.kt +++ /dev/null @@ -1,37 +0,0 @@ -package oppen.ariane.ui.modals_menus.set_home - -import android.content.Context -import android.view.View -import androidx.appcompat.app.AppCompatDialog -import kotlinx.android.synthetic.main.dialog_set_home.view.* -import oppen.ariane.R - -object SetHomeDialog { - - fun show(context: Context, currentAddress: String, onUpdate: () -> Unit){ - val prefs = context.getSharedPreferences("oppen.tva.ui.dialogs.set_home", Context.MODE_PRIVATE) - - val home = prefs.getString("home", "") - - val dialog = AppCompatDialog(context, R.style.DayNightDialog) - - val view = View.inflate(context, R.layout.dialog_set_home, null) - - view.home_edit_text.setText(home) - - view.set_home_button.setOnClickListener { - prefs.edit().putString("home", view.home_edit_text.text.toString()).apply() - onUpdate() - dialog.dismiss() - } - - view.use_current_button.setOnClickListener { - view.home_edit_text.setText(currentAddress) - } - - dialog.setTitle("Set home capsule") - - dialog.setContentView(view) - dialog.show() - } -} \ No newline at end of file diff --git a/app/src/main/java/oppen/ariane/ui/settings/SettingsActivity.kt b/app/src/main/java/oppen/ariane/ui/settings/SettingsActivity.kt deleted file mode 100644 index c9b14bb..0000000 --- a/app/src/main/java/oppen/ariane/ui/settings/SettingsActivity.kt +++ /dev/null @@ -1,24 +0,0 @@ -package oppen.ariane.ui.settings - -import android.os.Bundle -import android.view.MenuItem -import androidx.appcompat.app.AppCompatActivity -import oppen.ariane.R - -class SettingsActivity: AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - setContentView(R.layout.activity_settings) - - supportActionBar?.setDisplayHomeAsUpEnabled(true) - supportActionBar?.setHomeAsUpIndicator(R.drawable.vector_close) - - supportFragmentManager.beginTransaction().replace(R.id.settings_container, SettingsFragment()).commit() - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - finish() - return super.onOptionsItemSelected(item) - } -} diff --git a/app/src/main/java/oppen/ariane/ui/settings/SettingsFragment.kt b/app/src/main/java/oppen/ariane/ui/settings/SettingsFragment.kt deleted file mode 100644 index 7eb8b4a..0000000 --- a/app/src/main/java/oppen/ariane/ui/settings/SettingsFragment.kt +++ /dev/null @@ -1,215 +0,0 @@ -package oppen.ariane.ui.settings - -import android.content.SharedPreferences -import android.os.Bundle -import android.text.Spannable -import android.text.SpannableString -import android.text.style.ForegroundColorSpan -import android.view.inputmethod.EditorInfo -import androidx.appcompat.app.AppCompatDelegate -import androidx.core.content.ContextCompat -import androidx.preference.* -import oppen.ariane.Ariane -import java.security.SecureRandom -import java.util.* -import javax.net.ssl.SSLContext -import javax.net.ssl.SSLSocket -import javax.net.ssl.SSLSocketFactory - -class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChangeListener { - - lateinit var prefs: SharedPreferences - lateinit var protocols: Array - - override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { - - prefs = preferenceManager.sharedPreferences - - val context = preferenceManager.context - val screen = preferenceManager.createPreferenceScreen(context) - - /** - * Ariane App Settings - */ - val appCategory = PreferenceCategory(context) - appCategory.key = "app_category" - appCategory.title = "Configure Ariane" - screen.addPreference(appCategory) - - //Home - val homePreference = EditTextPreference(context) - homePreference.title = "Home Capsule" - homePreference.key = "home_capsule" - - val homecapsule = preferenceManager.sharedPreferences.getString("home_capsule", Ariane.DEFAULT_HOME_CAPSULE) - homePreference.summary = homecapsule - - homePreference.positiveButtonText = getThemedSpan("Update") - homePreference.negativeButtonText = getThemedSpan("Cancel") - homePreference.title = getThemedSpan("Home Capsule") - homePreference.setOnPreferenceChangeListener { _, newValue -> - homePreference.summary = newValue.toString() - true - } - homePreference.setOnBindEditTextListener{ editText -> - editText.imeOptions = EditorInfo.IME_ACTION_DONE - editText.setSelection(editText.text.toString().length)//Set caret position to end - } - appCategory.addPreference(homePreference) - - /** - * Day/Night Theme - */ - val themeCategory = PreferenceCategory(context) - themeCategory.key = "theme_category" - themeCategory.title = "Theme" - appCategory.addPreference(themeCategory) - - val themeFollowSystemPreference = SwitchPreferenceCompat(context) - themeFollowSystemPreference.key = "theme_FollowSystem" - themeFollowSystemPreference.title = "System Default" - themeFollowSystemPreference.onPreferenceChangeListener = this - themeCategory.addPreference(themeFollowSystemPreference) - - val themeLightPreference = SwitchPreferenceCompat(context) - themeLightPreference.key = "theme_Light" - themeLightPreference.title = "Light" - themeLightPreference.onPreferenceChangeListener = this - themeCategory.addPreference(themeLightPreference) - - val themeDarkPreference = SwitchPreferenceCompat(context) - themeDarkPreference.key = "theme_Dark" - themeDarkPreference.title = "Dark" - themeDarkPreference.onPreferenceChangeListener = this - themeCategory.addPreference(themeDarkPreference) - - - val isThemePrefSet = - prefs.getBoolean("theme_FollowSystem", false) || - prefs.getBoolean("theme_Light", false) || - prefs.getBoolean("theme_Dark", false) - if(!isThemePrefSet) themeFollowSystemPreference.isChecked = true - - /** - * TLS Settings - */ - val tlsCategory = PreferenceCategory(context) - tlsCategory.key = "tls_category" - tlsCategory.title = "TLS Config" - screen.addPreference(tlsCategory) - - val tlsDefaultPreference = SwitchPreferenceCompat(context) - tlsDefaultPreference.key = "tls_Default" - tlsDefaultPreference.title = "TLS Default" - tlsDefaultPreference.onPreferenceChangeListener = this - tlsCategory.addPreference(tlsDefaultPreference) - - val tlsAllSupportedPreference = SwitchPreferenceCompat(context) - tlsAllSupportedPreference.key = "tls_All_Supported" - tlsAllSupportedPreference.title = "TLS Enable all supported" - tlsAllSupportedPreference.onPreferenceChangeListener = this - tlsCategory.addPreference(tlsAllSupportedPreference) - - val sslContext = SSLContext.getInstance("TLS") - sslContext.init(null, null, SecureRandom()) - val factory: SSLSocketFactory = sslContext.socketFactory - val socket = factory.createSocket() as SSLSocket - protocols = socket.supportedProtocols - protocols.forEach { protocol -> - val tlsPreference = SwitchPreferenceCompat(context) - tlsPreference.key = "tls_${protocol.toLowerCase(Locale.getDefault())}" - tlsPreference.title = protocol - tlsPreference.onPreferenceChangeListener = this - tlsCategory.addPreference(tlsPreference) - } - - preferenceScreen = screen - } - - override fun onPreferenceChange(preference: Preference?, newValue: Any?): Boolean { - if(preference == null) return false - - if(preference.key.startsWith("tls")){ - tlsChangeListener(preference, newValue) - return true - } - - if(preference.key.startsWith("theme")){ - when(preference.key){ - "theme_FollowSystem" -> { - preferenceScreen.findPreference("theme_Light")?.isChecked = false - preferenceScreen.findPreference("theme_Dark")?.isChecked = false - AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) - } - "theme_Light" -> { - preferenceScreen.findPreference("theme_FollowSystem")?.isChecked = false - preferenceScreen.findPreference("theme_Dark")?.isChecked = false - AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) - } - "theme_Dark" -> { - preferenceScreen.findPreference("theme_FollowSystem")?.isChecked = false - preferenceScreen.findPreference("theme_Light")?.isChecked = false - AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) - } - } - return true - } - - - return false - } - - private fun tlsChangeListener( - preference: Preference?, - newValue: Any? - ) { - if (preference is SwitchPreferenceCompat && newValue is Boolean && newValue == true) { - preference.key?.let { key -> - when { - key.startsWith("tls_") -> { - if (key != "tls_Default") { - val default = preferenceScreen.findPreference("tls_Default") - default?.isChecked = false - } - if (key != "tls_All_Supported") { - val all = preferenceScreen.findPreference("tls_All_Supported") - all?.isChecked = false - } - protocols.forEach { protocol -> - val tlsSwitchKey = "tls_${protocol.toLowerCase(Locale.getDefault())}" - if (tlsSwitchKey != key) { - val otherTLSSwitch = - preferenceScreen.findPreference( - tlsSwitchKey - ) - otherTLSSwitch?.isChecked = false - } - } - } - } - } - - when (preference.key) { - "tls_Default" -> setTLSProtocol("TLS") - "tls_All_Supported" -> setTLSProtocol("TLS_ALL") - else -> { - val prefTitle = preference.title.toString() - setTLSProtocol(prefTitle) - } - } - } - } - - private fun setTLSProtocol(protocol: String) = preferenceManager.sharedPreferences.edit().putString("tls_protocol", protocol).apply() - - /** - * Unfortunately it doesn't look like EditTextPreference supports Day/Night theme - * or else is otherwise broken - OR I'M MISSING SOMETHING. - * Use Spannable to set a suitable text colour for the dialog buttons - */ - private fun getThemedSpan(text: String): Spannable{ - val textSpan = SpannableString(text) - textSpan.setSpan(ForegroundColorSpan(ContextCompat.getColor(requireContext(), oppen.ariane.R.color.themed_text)), 0, text.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) - return textSpan - } -} diff --git a/app/src/main/res/anim/fade_in.xml b/app/src/main/res/anim/fade_in.xml deleted file mode 100644 index 3b0c30e..0000000 --- a/app/src/main/res/anim/fade_in.xml +++ /dev/null @@ -1,6 +0,0 @@ - - \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/vector_olab.xml b/app/src/main/res/drawable-v24/vector_olab.xml deleted file mode 100644 index f2abfbf..0000000 --- a/app/src/main/res/drawable-v24/vector_olab.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - diff --git a/app/src/main/res/drawable/drawable_filled_rounded_rect.xml b/app/src/main/res/drawable/drawable_filled_rounded_rect.xml deleted file mode 100644 index 89a739d..0000000 --- a/app/src/main/res/drawable/drawable_filled_rounded_rect.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/drawable_stroke_rounded_rect.xml b/app/src/main/res/drawable/drawable_stroke_rounded_rect.xml deleted file mode 100644 index b4a4e62..0000000 --- a/app/src/main/res/drawable/drawable_stroke_rounded_rect.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/vector_about.xml b/app/src/main/res/drawable/vector_about.xml deleted file mode 100644 index 17255b7..0000000 --- a/app/src/main/res/drawable/vector_about.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/vector_app_icon.xml b/app/src/main/res/drawable/vector_app_icon.xml deleted file mode 100644 index c7f0f25..0000000 --- a/app/src/main/res/drawable/vector_app_icon.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - diff --git a/app/src/main/res/drawable/vector_ariane.xml b/app/src/main/res/drawable/vector_ariane.xml deleted file mode 100644 index c7f0f25..0000000 --- a/app/src/main/res/drawable/vector_ariane.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - diff --git a/app/src/main/res/drawable/vector_bookmark.xml b/app/src/main/res/drawable/vector_bookmark.xml deleted file mode 100644 index 7e480e2..0000000 --- a/app/src/main/res/drawable/vector_bookmark.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/vector_bookmarks.xml b/app/src/main/res/drawable/vector_bookmarks.xml deleted file mode 100644 index bcb76cd..0000000 --- a/app/src/main/res/drawable/vector_bookmarks.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/vector_cancel.xml b/app/src/main/res/drawable/vector_cancel.xml deleted file mode 100644 index 1ab7bac..0000000 --- a/app/src/main/res/drawable/vector_cancel.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/vector_close.xml b/app/src/main/res/drawable/vector_close.xml deleted file mode 100644 index 16d6d37..0000000 --- a/app/src/main/res/drawable/vector_close.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/vector_confirm.xml b/app/src/main/res/drawable/vector_confirm.xml deleted file mode 100644 index 0432fa6..0000000 --- a/app/src/main/res/drawable/vector_confirm.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/vector_history.xml b/app/src/main/res/drawable/vector_history.xml deleted file mode 100644 index 9bc1fc3..0000000 --- a/app/src/main/res/drawable/vector_history.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/vector_home.xml b/app/src/main/res/drawable/vector_home.xml deleted file mode 100644 index 2a8afa8..0000000 --- a/app/src/main/res/drawable/vector_home.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/vector_link.xml b/app/src/main/res/drawable/vector_link.xml deleted file mode 100644 index 2c0a73f..0000000 --- a/app/src/main/res/drawable/vector_link.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/vector_overflow.xml b/app/src/main/res/drawable/vector_overflow.xml deleted file mode 100644 index 34b93ec..0000000 --- a/app/src/main/res/drawable/vector_overflow.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/vector_pause.xml b/app/src/main/res/drawable/vector_pause.xml deleted file mode 100644 index 13d6d2e..0000000 --- a/app/src/main/res/drawable/vector_pause.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/vector_play.xml b/app/src/main/res/drawable/vector_play.xml deleted file mode 100644 index 13c137a..0000000 --- a/app/src/main/res/drawable/vector_play.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/vector_refresh.xml b/app/src/main/res/drawable/vector_refresh.xml deleted file mode 100644 index f2be45b..0000000 --- a/app/src/main/res/drawable/vector_refresh.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/vector_save.xml b/app/src/main/res/drawable/vector_save.xml deleted file mode 100644 index 5c30d1c..0000000 --- a/app/src/main/res/drawable/vector_save.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/vector_search.xml b/app/src/main/res/drawable/vector_search.xml deleted file mode 100644 index 07b76d6..0000000 --- a/app/src/main/res/drawable/vector_search.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/vector_set_home.xml b/app/src/main/res/drawable/vector_set_home.xml deleted file mode 100644 index 3a4c7da..0000000 --- a/app/src/main/res/drawable/vector_set_home.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/vector_share.xml b/app/src/main/res/drawable/vector_share.xml deleted file mode 100644 index fe37f93..0000000 --- a/app/src/main/res/drawable/vector_share.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/font/code_font.xml b/app/src/main/res/font/code_font.xml deleted file mode 100644 index 3bbc22b..0000000 --- a/app/src/main/res/font/code_font.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - diff --git a/app/src/main/res/font/deja_vu_sans_mono.ttf b/app/src/main/res/font/deja_vu_sans_mono.ttf deleted file mode 100644 index 8b7bb2a..0000000 Binary files a/app/src/main/res/font/deja_vu_sans_mono.ttf and /dev/null differ diff --git a/app/src/main/res/layout/activity_gem.xml b/app/src/main/res/layout/activity_gem.xml deleted file mode 100644 index 03df101..0000000 --- a/app/src/main/res/layout/activity_gem.xml +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml deleted file mode 100644 index 6dbc60f..0000000 --- a/app/src/main/res/layout/activity_settings.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/bookmark.xml b/app/src/main/res/layout/bookmark.xml deleted file mode 100644 index bcf8498..0000000 --- a/app/src/main/res/layout/bookmark.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_about.xml b/app/src/main/res/layout/dialog_about.xml deleted file mode 100644 index 2a764d6..0000000 --- a/app/src/main/res/layout/dialog_about.xml +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_bookmarks.xml b/app/src/main/res/layout/dialog_bookmarks.xml deleted file mode 100644 index 09c0a00..0000000 --- a/app/src/main/res/layout/dialog_bookmarks.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_content_image.xml b/app/src/main/res/layout/dialog_content_image.xml deleted file mode 100644 index 9e8ca98..0000000 --- a/app/src/main/res/layout/dialog_content_image.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_content_text.xml b/app/src/main/res/layout/dialog_content_text.xml deleted file mode 100644 index fac2245..0000000 --- a/app/src/main/res/layout/dialog_content_text.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_history.xml b/app/src/main/res/layout/dialog_history.xml deleted file mode 100644 index a22b3da..0000000 --- a/app/src/main/res/layout/dialog_history.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input_query.xml b/app/src/main/res/layout/dialog_input_query.xml deleted file mode 100644 index 9f190fa..0000000 --- a/app/src/main/res/layout/dialog_input_query.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_set_home.xml b/app/src/main/res/layout/dialog_set_home.xml deleted file mode 100644 index 7d88f0d..0000000 --- a/app/src/main/res/layout/dialog_set_home.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_tabs.xml b/app/src/main/res/layout/dialog_tabs.xml deleted file mode 100644 index 2bb7069..0000000 --- a/app/src/main/res/layout/dialog_tabs.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_bookmark_dialog.xml b/app/src/main/res/layout/fragment_bookmark_dialog.xml deleted file mode 100644 index 2a0d484..0000000 --- a/app/src/main/res/layout/fragment_bookmark_dialog.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/gemtext_code_block.xml b/app/src/main/res/layout/gemtext_code_block.xml deleted file mode 100644 index 1a0d6a1..0000000 --- a/app/src/main/res/layout/gemtext_code_block.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/gemtext_h1.xml b/app/src/main/res/layout/gemtext_h1.xml deleted file mode 100644 index 26567c1..0000000 --- a/app/src/main/res/layout/gemtext_h1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - \ No newline at end of file diff --git a/app/src/main/res/layout/gemtext_h2.xml b/app/src/main/res/layout/gemtext_h2.xml deleted file mode 100644 index d3d8182..0000000 --- a/app/src/main/res/layout/gemtext_h2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - \ No newline at end of file diff --git a/app/src/main/res/layout/gemtext_h3.xml b/app/src/main/res/layout/gemtext_h3.xml deleted file mode 100644 index b18ecb3..0000000 --- a/app/src/main/res/layout/gemtext_h3.xml +++ /dev/null @@ -1,13 +0,0 @@ - - \ No newline at end of file diff --git a/app/src/main/res/layout/gemtext_image_link.xml b/app/src/main/res/layout/gemtext_image_link.xml deleted file mode 100644 index 2a98ac4..0000000 --- a/app/src/main/res/layout/gemtext_image_link.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/gemtext_link.xml b/app/src/main/res/layout/gemtext_link.xml deleted file mode 100644 index 2bdef64..0000000 --- a/app/src/main/res/layout/gemtext_link.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/gemtext_quote.xml b/app/src/main/res/layout/gemtext_quote.xml deleted file mode 100644 index b09364a..0000000 --- a/app/src/main/res/layout/gemtext_quote.xml +++ /dev/null @@ -1,18 +0,0 @@ - - \ No newline at end of file diff --git a/app/src/main/res/layout/gemtext_text.xml b/app/src/main/res/layout/gemtext_text.xml deleted file mode 100644 index cae3ef9..0000000 --- a/app/src/main/res/layout/gemtext_text.xml +++ /dev/null @@ -1,12 +0,0 @@ - - \ No newline at end of file diff --git a/app/src/main/res/layout/grid_cell_tab.xml b/app/src/main/res/layout/grid_cell_tab.xml deleted file mode 100644 index ff7e08d..0000000 --- a/app/src/main/res/layout/grid_cell_tab.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/row_history.xml b/app/src/main/res/layout/row_history.xml deleted file mode 100644 index 6689149..0000000 --- a/app/src/main/res/layout/row_history.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/menu/add_bookmark.xml b/app/src/main/res/menu/add_bookmark.xml deleted file mode 100644 index f748e4d..0000000 --- a/app/src/main/res/menu/add_bookmark.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/menu/add_bookmarks.xml b/app/src/main/res/menu/add_bookmarks.xml deleted file mode 100644 index fe187c0..0000000 --- a/app/src/main/res/menu/add_bookmarks.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/menu/audio_overflow.xml b/app/src/main/res/menu/audio_overflow.xml deleted file mode 100644 index 9170b86..0000000 --- a/app/src/main/res/menu/audio_overflow.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/menu/history_overflow_menu.xml b/app/src/main/res/menu/history_overflow_menu.xml deleted file mode 100644 index 861457d..0000000 --- a/app/src/main/res/menu/history_overflow_menu.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/menu/image_link_menu.xml b/app/src/main/res/menu/image_link_menu.xml deleted file mode 100644 index 099518b..0000000 --- a/app/src/main/res/menu/image_link_menu.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/app/src/main/res/menu/image_overflow_menu.xml b/app/src/main/res/menu/image_overflow_menu.xml deleted file mode 100644 index 6efd056..0000000 --- a/app/src/main/res/menu/image_overflow_menu.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/menu/link_menu.xml b/app/src/main/res/menu/link_menu.xml deleted file mode 100644 index d3846b8..0000000 --- a/app/src/main/res/menu/link_menu.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - diff --git a/app/src/main/res/menu/menu_bookmark.xml b/app/src/main/res/menu/menu_bookmark.xml deleted file mode 100644 index 53a093e..0000000 --- a/app/src/main/res/menu/menu_bookmark.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/menu/overflow_menu.xml b/app/src/main/res/menu/overflow_menu.xml deleted file mode 100644 index b87dc3b..0000000 --- a/app/src/main/res/menu/overflow_menu.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/raw/cert.pfx b/app/src/main/res/raw/cert.pfx deleted file mode 100644 index 142dbb0..0000000 Binary files a/app/src/main/res/raw/cert.pfx and /dev/null differ diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml deleted file mode 100644 index 0caba93..0000000 --- a/app/src/main/res/values-night/colors.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - #ffffff - #1d1d1d - #03DAC5 - #000000 - #1d1d1d - #ffdede - #2e2e2e - - #ffffff - #ffffff - #1d1d1d - #d2d2d2 - \ No newline at end of file diff --git a/app/src/main/res/values-night/styles.xml b/app/src/main/res/values-night/styles.xml deleted file mode 100644 index 8e99719..0000000 --- a/app/src/main/res/values-night/styles.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml deleted file mode 100644 index 315ee35..0000000 --- a/app/src/main/res/values/colors.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - #ffffff - #efefef - #03DAC5 - #efefef - #efefef - #002121 - #dfdfdf - - #000000 - #000000 - #eeeeee - #0d0d0d - \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml deleted file mode 100644 index 93b9167..0000000 --- a/app/src/main/res/values/dimens.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - 8dp - 16dp - 20dp - 12dp - 16sp - 20sp - 14sp - 28sp - 22sp - 18sp - 32dp - 50dp - 20dp - 18sp - 12sp - \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml deleted file mode 100644 index 7acc704..0000000 --- a/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,41 +0,0 @@ - - Ariane - gemini:// - Enter gemini:// address - Enter search term - Share address - Display inline - About - Address copied to clipboard - Gemini address - Share - Set Home - Settings - Ariane: Gemini protocol client from Öppenlab - GPL v3 - Copyright © 2020 Öppenlab - GNU General Public License, version 3\n -\nThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or any later version.\n -\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n -\nYou should have received a copy of the GNU General Public License along with this program. If not, see www.gnu.org/licenses - Code blocks are rendered using DejaVu Sans Mono:\n\nCopyright © 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is a trademark of Bitstream, Inc.\n\nSome included glyphs, imported from Arev Fonts:\n\nCopyright © 2006 by Tavmjong Bah. All Rights Reserved. - Clear runtime cache - History - Clear history - Refresh - Submit - Search - Save Image - Save track - Dismiss player - Backlinks - Add Bookmark - Bookmarks - Name - Gemini URL - Edit - Delete - Move down - Move up - Unknown Mime Type - \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml deleted file mode 100644 index d935efc..0000000 --- a/app/src/main/res/values/styles.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - -