diff --git a/android/LICENSE b/android/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/android/LICENSE @@ -0,0 +1,674 @@ + 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/android/README.md b/android/README.md new file mode 100644 index 0000000..f48f4fc --- /dev/null +++ b/android/README.md @@ -0,0 +1,8 @@ +# Tinelix IRC Client (Legacy edition) +**Minimal Android version:** Android 2.0 Eclair (API level 5) and higher + +**IMPORTANT!** Until May 1, 2024 all files from this repository will be moved to https://github.com/tinelix/irc-client-legacy. + +See https://github.com/tinelix/irc-client/issues/14#issue-2225137465. + + diff --git a/android/TinelixIRCLegacy.iml b/android/TinelixIRCLegacy.iml new file mode 100644 index 0000000..2a02201 --- /dev/null +++ b/android/TinelixIRCLegacy.iml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/app.iml b/android/app/app.iml new file mode 100644 index 0000000..f782803 --- /dev/null +++ b/android/app/app.iml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/build.gradle b/android/app/build.gradle new file mode 100644 index 0000000..fe8c81a --- /dev/null +++ b/android/app/build.gradle @@ -0,0 +1,24 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 21 + buildToolsVersion "21.1.2" + defaultConfig { + applicationId "dev.tinelix.irc.android.legacy" + minSdkVersion 5 // Android 2.0 Eclair + targetSdkVersion 21 + versionCode 22 + versionName '0.4.0_beta_20220506' + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + debug { + debuggable true + } + } + productFlavors { + } +} diff --git a/android/app/build/readme.txt b/android/app/build/readme.txt new file mode 100644 index 0000000..292c28c --- /dev/null +++ b/android/app/build/readme.txt @@ -0,0 +1 @@ +'build' - folder for output build diff --git a/android/app/libs/readme.txt b/android/app/libs/readme.txt new file mode 100644 index 0000000..4e9d86a --- /dev/null +++ b/android/app/libs/readme.txt @@ -0,0 +1 @@ +'libs' - folder for Gradle libs \ No newline at end of file diff --git a/android/app/readme.txt b/android/app/readme.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/android/app/readme.txt @@ -0,0 +1 @@ + diff --git a/android/app/src/androidTest/java/dev/tinelix/irc/android/ExampleInstrumentedTest.java b/android/app/src/androidTest/java/dev/tinelix/irc/android/ExampleInstrumentedTest.java new file mode 100644 index 0000000..0257a09 --- /dev/null +++ b/android/app/src/androidTest/java/dev/tinelix/irc/android/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package dev.tinelix.irc; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumentation test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("dev.tinelix.irc", appContext.getPackageName()); + } +} diff --git a/android/app/src/androidTest/java/dev/tinelix/irc/android/legacy/ExampleInstrumentedTest.java b/android/app/src/androidTest/java/dev/tinelix/irc/android/legacy/ExampleInstrumentedTest.java new file mode 100644 index 0000000..596443b --- /dev/null +++ b/android/app/src/androidTest/java/dev/tinelix/irc/android/legacy/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package dev.tinelix.irc.android; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("dev.tinelix.irc.android", appContext.getPackageName()); + } +} diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..85d0030 --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/AboutApplicationActivity.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/AboutApplicationActivity.java new file mode 100644 index 0000000..a639303 --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/AboutApplicationActivity.java @@ -0,0 +1,213 @@ +package dev.tinelix.irc.android.legacy; + +import android.app.Activity; +import android.app.Application; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.graphics.Color; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.text.method.LinkMovementMethod; +import android.view.MenuItem; +import android.view.View; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import java.util.Locale; + +public class AboutApplicationActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + setCustomTheme(global_prefs); + setContentView(R.layout.about_application_activity); + setColorStyle(global_prefs); + Button repoButton = (Button) findViewById(R.id.repo_button); + Button websiteButton = (Button) findViewById(R.id.website_button); + + repoButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Uri uri = Uri.parse("https://github.com/tinelix/irc-client-for-android"); + Intent intent = new Intent(Intent.ACTION_VIEW, uri); + startActivity(intent); + } + }); + websiteButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Uri uri = Uri.parse("http://tinelix.downmail.ru/web1/pages/tinelix/irc-client_utf8.html"); + Intent intent = new Intent(Intent.ACTION_VIEW, uri); + startActivity(intent); + } + }); + if (global_prefs.getString("language", "OS dependent").contains("English")) { + websiteButton.setVisibility(View.GONE); + } + TextView license_label = (TextView) findViewById(R.id.license_label); + license_label.setMovementMethod(LinkMovementMethod.getInstance()); + TextView version_label = (TextView) findViewById(R.id.version_label); + version_label.setText(getResources().getString(R.string.version_str, ((IRCClientApp) getApplicationContext()).version, ((IRCClientApp) getApplicationContext()).build_date)); + }; + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) { + if(id == android.R.id.home) { + onBackPressed(); + } + } + return super.onOptionsItemSelected(item); + } + + @Override + public void onBackPressed() { + finish(); + } + + private void setColorStyle(SharedPreferences global_prefs) { + if (global_prefs.getString("theme", "Light").contains("Light")) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.white_75)); + TextView app_title = (TextView) findViewById(R.id.activity_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.white_75)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.white_75)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.white)); + TextView app_title2 = (TextView) findViewById(R.id.app_title_label); + app_title2.setTextColor(getResources().getColor(R.color.black)); + ((TextView) findViewById(R.id.license_label)).setTextColor(Color.DKGRAY); + } else { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.title_v11_transparent)); + TextView app_title = (TextView) findViewById(R.id.activity_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + TextView app_title2 = (TextView) findViewById(R.id.app_title_label); + app_title2.setTextColor(getResources().getColor(R.color.white)); + ((TextView) findViewById(R.id.license_label)).setTextColor(Color.LTGRAY); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + TextView app_title2 = (TextView) findViewById(R.id.app_title_label); + app_title2.setTextColor(getResources().getColor(R.color.black)); + } else { + TextView app_title2 = (TextView) findViewById(R.id.app_title_label); + app_title2.setTextColor(getResources().getColor(R.color.white)); + } + } + } else { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.title_v11_transparent)); + TextView app_title = (TextView) findViewById(R.id.activity_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + TextView app_title2 = (TextView) findViewById(R.id.app_title_label); + app_title2.setTextColor(getResources().getColor(R.color.white)); + ((TextView) findViewById(R.id.license_label)).setTextColor(Color.LTGRAY); + } else { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.white_75)); + TextView app_title = (TextView) findViewById(R.id.activity_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.white_75)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.white_75)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.white)); + TextView app_title2 = (TextView) findViewById(R.id.app_title_label); + app_title2.setTextColor(getResources().getColor(R.color.black)); + ((TextView) findViewById(R.id.license_label)).setTextColor(Color.DKGRAY); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + TextView app_title2 = (TextView) findViewById(R.id.app_title_label); + app_title2.setTextColor(getResources().getColor(R.color.white)); + } else { + TextView app_title2 = (TextView) findViewById(R.id.app_title_label); + app_title2.setTextColor(getResources().getColor(R.color.black)); + } + } + } + } + + private void setCustomTheme(SharedPreferences global_prefs) { + if (global_prefs.getString("language", "OS dependent").contains("Russian")) { + if (global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + config.locale = locale; + config.setLayoutDirection(locale); + } + } else if (global_prefs.getString("language", "OS dependent").contains("English")) { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + config.locale = locale; + config.setLayoutDirection(locale); + } + getApplicationContext().getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } + } else if (global_prefs.getString("language", "OS dependent").contains("English")) { + if (global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + config.locale = locale; + config.setLayoutDirection(locale); + } + getApplicationContext().getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + config.locale = locale; + config.setLayoutDirection(locale); + } + getApplicationContext().getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } + } + if (global_prefs.getString("theme", "Light").contains("Light")) { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + setTheme(R.style.IRCClient_Light); + } else { + setTheme(R.style.IRCClient); + } + } else { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + setTheme(R.style.IRCClient); + } else { + setTheme(R.style.IRCClient_Light); + } + } + } +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/ConnectionManagerActivity.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/ConnectionManagerActivity.java new file mode 100644 index 0000000..2a14466 --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/ConnectionManagerActivity.java @@ -0,0 +1,590 @@ +package dev.tinelix.irc.android.legacy; + +import android.app.Activity; +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.FragmentManager; +import android.app.FragmentTransaction; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.graphics.Typeface; +import android.os.Build; +import android.os.Bundle; +import android.app.DialogFragment; +import android.preference.PreferenceManager; +import android.text.Editable; +import android.text.TextWatcher; +import android.util.DisplayMetrics; +import android.util.Log; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.ListView; +import android.widget.TextView; +import android.widget.Toast; + +import java.io.File; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; + +public class ConnectionManagerActivity extends Activity implements SharedPreferences.OnSharedPreferenceChangeListener { + public List profilesArray = new ArrayList(); + ArrayList profilesList = new ArrayList(); + ProfileAdapter profilesAdapter; + public String selected_profile_name; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + setCustomTheme(global_prefs); + setContentView(R.layout.activity_connection_manager); + setColorStyle(global_prefs); + if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + ImageButton menu_button = (ImageButton) findViewById(R.id.menu_button); + menu_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + openOptionsMenu(); + } + }); + } else { + getActionBar().setTitle(getResources().getString(R.string.connection_manager_title)); + } + profilesAdapter = new ProfileAdapter(this, profilesList); + String package_name = getApplicationContext().getPackageName(); + String profile_path = "/data/data/" + package_name + "/shared_prefs"; + File prefs_directory = new File(profile_path); + File[] prefs_files = prefs_directory.listFiles(); + ListView profilesListView = (ListView) findViewById(R.id.profiles_list); + LinearLayout profilesLinearLayout = (LinearLayout) findViewById(R.id.empty_profiles_list_layout); + profilesArray = new LinkedList(); + String file_extension; + Context context = getApplicationContext(); + try { + for (int i = 0; i < prefs_files.length; i++) { + if(prefs_files[i].getName().substring(0, (int) (prefs_files[i].getName().length() - 4)).startsWith(getApplicationInfo().packageName + "_preferences")) + { + } else { + SharedPreferences prefs = context.getSharedPreferences(prefs_files[i].getName().substring(0, (int) (prefs_files[i].getName().length() - 4)), 0); + file_extension = prefs_files[i].getName().substring((int) (prefs_files[i].getName().length() - 4)); + if (file_extension.contains(".xml") && file_extension.length() == 4) { + profilesList.add(new Profile(prefs_files[i].getName().substring(0, (int) (prefs_files[i].getName().length() - 4)), + prefs.getString("server", ""), prefs.getInt("port", 0), false, false)); + } + } + } + if(prefs_files == null || profilesList.size() == 0) { + profilesListView.setVisibility(View.GONE); + profilesLinearLayout.setVisibility(View.VISIBLE); + } else { + profilesListView.setVisibility(View.VISIBLE); + profilesLinearLayout.setVisibility(View.GONE); + } + ArrayAdapter profilesAdapter2 = new ArrayAdapter(this, + android.R.layout.simple_list_item_1, profilesArray); + profilesListView.setAdapter(profilesAdapter); + profilesListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + Toast.makeText(getApplicationContext(), ((TextView)view.findViewById(R.id.profile_item_label)).getText(), Toast.LENGTH_LONG).show(); + } + }); + } catch(Exception ex) { + ex.printStackTrace(); + } + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { + FragmentManager fragmentManager = null; + fragmentManager = getFragmentManager(); + FragmentTransaction fragmentTransaction = null; + fragmentTransaction = fragmentManager.beginTransaction(); + CreateItemFragm ci_fragment = new CreateItemFragm(); + fragmentTransaction.add(R.id.create_item_layout2, ci_fragment); + fragmentTransaction.commit(); + } else { + LinearLayout add_item_ll = (LinearLayout) findViewById(R.id.add_item_ll); + add_item_ll.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + showEnterTextDialog(); + } + }); + } + }; + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.connection_manager_menu, menu); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + getActionBar().setHomeButtonEnabled(true); + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + getActionBar().setDisplayHomeAsUpEnabled(true); + } + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.add_item) { + return showEnterTextDialog(); + } + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) { + if(id == android.R.id.home) { + onBackPressed(); + } + } + + return super.onOptionsItemSelected(item); + } + + public boolean showEnterTextDialog() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + DialogFragment enterTextDialogFragm = new EnterTextDialogFragm(); + enterTextDialogFragm.show(getFragmentManager(), "enter_text_dlg"); + } else { + final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); + LayoutInflater inflater = this.getLayoutInflater(); + final View dialogView = inflater.inflate(R.layout.enter_text_activity, null); + TextView dialog_title = (TextView) dialogView.findViewById(R.id.dialog_title); + dialog_title.setText(getString(R.string.enter_the_pfn_title)); + final EditText profile_name = (EditText) dialogView.findViewById(R.id.profile_name_text); + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + dialogView.setMinimumWidth(metrics.widthPixels); + dialogBuilder.setView(dialogView); + dialogBuilder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + profileNameOkClicked(profile_name.getText().toString()); + } + }); + dialogBuilder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + + } + }); + final AlertDialog alertDialog = dialogBuilder.create(); + alertDialog.getWindow().setGravity(Gravity.BOTTOM); + profile_name.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + if(profile_name.getText().toString().contains("/")) { + profile_name.setError(getResources().getString(R.string.text_field_wrong_characters)); + ((AlertDialog) alertDialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); + } else { + ((AlertDialog) alertDialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); + } + } + + @Override + public void afterTextChanged(Editable editable) { + + } + }); + alertDialog.show(); + + Button dialogButton; + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + customizeDialogStyle(dialogButton, global_prefs, alertDialog); + } + return false; + }; + + @Override + protected void onResume() { + super.onResume(); + profilesAdapter = new ProfileAdapter(this, profilesList); + String package_name = getApplicationContext().getPackageName(); + String profile_path = "/data/data/" + package_name + "/shared_prefs"; + File prefs_directory = new File(profile_path); + File[] prefs_files = prefs_directory.listFiles(); + profilesList.clear(); + profilesArray.clear(); + String file_extension; + Context context = getApplicationContext(); + ListView profilesListView = (ListView) findViewById(R.id.profiles_list); + LinearLayout profilesLinearLayout = (LinearLayout) findViewById(R.id.empty_profiles_list_layout); + try { + for (int i = 0; i < prefs_files.length; i++) { + if(prefs_files[i].getName().substring(0, (int) (prefs_files[i].getName().length() - 4)).startsWith(getApplicationInfo().packageName + "_preferences")) + { + } else { + SharedPreferences prefs = context.getSharedPreferences(prefs_files[i].getName().substring(0, (int) (prefs_files[i].getName().length() - 4)), 0); + file_extension = prefs_files[i].getName().substring((int) (prefs_files[i].getName().length() - 4)); + if (file_extension.contains(".xml") && file_extension.length() == 4) { + profilesList.add(new Profile(prefs_files[i].getName().substring(0, (int) (prefs_files[i].getName().length() - 4)), + prefs.getString("server", ""), prefs.getInt("port", 0), false, false)); + } + } + } + if(prefs_files == null || profilesList.size() == 0) { + profilesListView.setVisibility(View.GONE); + profilesLinearLayout.setVisibility(View.VISIBLE); + } else { + profilesListView.setVisibility(View.VISIBLE); + profilesLinearLayout.setVisibility(View.GONE); + } + ArrayAdapter profilesAdapter2 = new ArrayAdapter(this, + android.R.layout.simple_list_item_1, profilesArray); + profilesListView.setAdapter(profilesAdapter); + } catch(Exception ex) { + ex.printStackTrace(); + } + } + + public void profileNameOkClicked(String profile_name) { + profilesArray.clear(); + profilesList.clear(); + profilesAdapter = new ProfileAdapter(this, profilesList); + String package_name = getApplicationContext().getPackageName(); + String profile_path = "/data/data/" + package_name + "/shared_prefs"; + File prefs_directory = new File(profile_path); + File[] prefs_files = prefs_directory.listFiles(); + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(profile_name, 0); + SharedPreferences.Editor editor = prefs.edit(); + editor.putString("name", profile_name); + editor.putString("auth_method", "Disabled"); + editor.putString("hide_ip", "Disabled"); + editor.putString("quit_message", getString(R.string.default_quit_msg)); + editor.putBoolean("connected", false); + editor.commit(); + Intent intent = new Intent(this, ProfileSettingsActivity.class); + intent.putExtra("profile_name", profile_name); + intent.putExtra("package_name", getApplicationContext().getPackageName()); + startActivity(intent); + } + + public void selectProfile(View v) { + } + + public void connectProfile(int position) { + Context context = getApplicationContext(); + Intent intent = new Intent(context, ThreadActivity.class); + Intent parentIntent = new Intent(); + Profile profile_item = null; + profile_item = (Profile) profilesAdapter.getItem(position); + intent.putExtra("profile_name", profile_item.name); + SharedPreferences prefs = context.getSharedPreferences(profile_item.name, 0); + SharedPreferences.Editor editor = prefs.edit(); + editor.putBoolean("connected", true); + editor.commit(); + SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + if(prefs.getString("nicknames", "").length() > 0) { + if (global_prefs.getBoolean("connected", false) == false) { + editor = global_prefs.edit(); + editor.putBoolean("connected", true); + editor.commit(); + setResult(RESULT_OK, parentIntent); + intent.setAction(Intent.ACTION_MAIN); + intent.addCategory(Intent.CATEGORY_LAUNCHER); + startActivity(intent); + } else { + if(prefs.getBoolean("connected", false)) { + Toast.makeText(getApplicationContext(), getResources().getString(R.string.first_end_session), Toast.LENGTH_LONG).show(); + } + } + finish(); + } else { + Toast.makeText(getApplicationContext(), getResources().getString(R.string.forgot_nicknames), Toast.LENGTH_LONG).show(); + } + } + + public void editProfile(int position) { + Context context = getApplicationContext(); + Intent intent = new Intent(context, ProfileSettingsActivity.class); + Profile profile_item = null; + profile_item = (Profile) profilesAdapter.getItem(position); + intent.putExtra("profile_name", profile_item.name); + intent.putExtra("package_name", getApplicationContext().getPackageName()); + startActivity(intent); + } + + public void deleteProfile(int position) { + profilesAdapter = new ProfileAdapter(this, profilesList); + String package_name = getApplicationContext().getPackageName(); + Profile profile_item = null; + profile_item = (Profile) profilesAdapter.getItem(position); + profilesArray.clear(); + profilesList.clear(); + String profile_path = "/data/data/" + package_name + "/shared_prefs/" + profile_item.name + ".xml"; + File file = new File(profile_path); + file.delete(); + profilesAdapter = new ProfileAdapter(this, profilesList); + package_name = getApplicationContext().getPackageName(); + profile_path = "/data/data/" + package_name + "/shared_prefs"; + File prefs_directory = new File(profile_path); + File[] prefs_files = prefs_directory.listFiles(); + profilesList.clear(); + profilesArray.clear(); + String file_extension; + Context context = getApplicationContext(); + ListView profilesListView = (ListView) findViewById(R.id.profiles_list); + LinearLayout profilesLinearLayout = (LinearLayout) findViewById(R.id.empty_profiles_list_layout); + try { + for (int i = 0; i < prefs_files.length; i++) { + if(prefs_files[i].getName().substring(0, (int) (prefs_files[i].getName().length() - 4)).startsWith(getApplicationInfo().packageName + "_preferences")) + { + } else { + SharedPreferences prefs = context.getSharedPreferences(prefs_files[i].getName().substring(0, (int) (prefs_files[i].getName().length() - 4)), 0); + file_extension = prefs_files[i].getName().substring((int) (prefs_files[i].getName().length() - 4)); + if (file_extension.contains(".xml") && file_extension.length() == 4) { + profilesList.add(new Profile(prefs_files[i].getName().substring(0, (int) (prefs_files[i].getName().length() - 4)), + prefs.getString("server", ""), prefs.getInt("port", 0), false, false)); + } + } + } + if(prefs_files == null || profilesList.size() == 0) { + profilesListView.setVisibility(View.GONE); + profilesLinearLayout.setVisibility(View.VISIBLE); + } else { + profilesListView.setVisibility(View.VISIBLE); + profilesLinearLayout.setVisibility(View.GONE); + } + ArrayAdapter profilesAdapter2 = new ArrayAdapter(this, + android.R.layout.simple_list_item_1, profilesArray); + profilesListView.setAdapter(profilesAdapter); + profilesListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + Toast.makeText(getApplicationContext(), ((TextView)view.findViewById(R.id.profile_item_label)).getText(), Toast.LENGTH_LONG).show(); + } + }); + } catch(Exception ex) { + ex.printStackTrace(); + } + } + + public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { + + } + + private void setColorStyle(SharedPreferences global_prefs) { + if (global_prefs.getString("theme", "Light").contains("Light")) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.white_75)); + TextView app_title = (TextView) findViewById(R.id.app_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.white_75)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.white_75)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.white)); + } else { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.title_v11_transparent)); + TextView app_title = (TextView) findViewById(R.id.app_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + } + } + } else { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.title_v11_transparent)); + TextView app_title = (TextView) findViewById(R.id.app_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + } else { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.white_75)); + TextView app_title = (TextView) findViewById(R.id.app_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.white_75)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.white_75)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.white)); + } + } + } + } + + private void setCustomTheme(SharedPreferences global_prefs) { + if(global_prefs.getString("language", "OS dependent").contains("Russian")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } + } else if (global_prefs.getString("language", "OS dependent").contains("English")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } + } + if (global_prefs.getString("theme", "Light").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + setTheme(R.style.IRCClient_Light); + } else { + setTheme(R.style.IRCClient); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + setTheme(R.style.IRCClient); + } else { + setTheme(R.style.IRCClient_Light); + } + } + } + + private void customizeDialogStyle(Button dialogButton, SharedPreferences global_prefs, AlertDialog alertDialog) { + if(global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } else { + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } else { + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } + } + } +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/CreateItemFragm.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/CreateItemFragm.java new file mode 100644 index 0000000..5802b86 --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/CreateItemFragm.java @@ -0,0 +1,46 @@ +package dev.tinelix.irc.android.legacy; + +import android.annotation.TargetApi; +import android.app.Fragment; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.os.Build; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.TextView; + +import java.util.Locale; + +@TargetApi(Build.VERSION_CODES.HONEYCOMB) +public class CreateItemFragm extends Fragment { + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + View view = inflater.inflate(R.layout.create_item, + container, false); + if(global_prefs.getString("theme", "Dark").contains("Light")) { + TextView add_item_label = (TextView) view.findViewById(R.id.add_item_label); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + add_item_label.setTextColor(getResources().getColor(android.R.color.holo_blue_light)); + } else { + add_item_label.setTextColor(getResources().getColor(R.color.orange)); + } + } + Button create_item_button = (Button) view.findViewById(R.id.create_item_button); + create_item_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + ((ConnectionManagerActivity) getActivity()).showEnterTextDialog(); + } + } + }); + + return view; + } +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/CreateItemFragm2.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/CreateItemFragm2.java new file mode 100644 index 0000000..5f9f135 --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/CreateItemFragm2.java @@ -0,0 +1,44 @@ +package dev.tinelix.irc.android.legacy; + +import android.annotation.SuppressLint; +import android.app.Fragment; +import android.content.SharedPreferences; +import android.os.Build; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.TextView; + +@SuppressLint("NewApi") +public class CreateItemFragm2 extends Fragment { + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + View view = inflater.inflate(R.layout.create_item2, + container, false); + if(global_prefs.getString("theme", "Dark").contains("Light")) { + TextView add_item_label = (TextView) view.findViewById(R.id.add_item_label); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + add_item_label.setTextColor(getResources().getColor(android.R.color.holo_blue_light)); + } else { + add_item_label.setTextColor(getResources().getColor(R.color.orange)); + } + } + Button create_item_button = (Button) view.findViewById(R.id.create_item_button2); + create_item_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + ((CustomNicknamesActivity) getActivity()).showEnterTextDialog(); + } + } + }); + + return view; + } + +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/CustomNicknamesActivity.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/CustomNicknamesActivity.java new file mode 100644 index 0000000..86d0be3 --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/CustomNicknamesActivity.java @@ -0,0 +1,403 @@ +package dev.tinelix.irc.android.legacy; + +import android.app.Activity; +import android.app.AlertDialog; +import android.app.DialogFragment; +import android.content.Context; +import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.graphics.Typeface; +import android.os.Build; +import android.os.Bundle; +import android.preference.Preference; +import android.preference.PreferenceManager; +import android.util.DisplayMetrics; +import android.util.Log; +import android.view.ContextThemeWrapper; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.ListView; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; + +public class CustomNicknamesActivity extends Activity { + + List nicknamesArray = new ArrayList(); + String nicknamesString; + String old_profile_name; + public String current_parameter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + setCustomTheme(global_prefs); + setContentView(R.layout.custom_nicknames_activity); + setColorStyle(global_prefs); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + getActionBar().setHomeButtonEnabled(true); + } + getActionBar().setTitle(getResources().getString(R.string.nicknames_manager_title)); + } + current_parameter = "creating_nickname"; + if (savedInstanceState == null) { + Bundle extras = getIntent().getExtras(); + if(extras == null) { + old_profile_name = null; + } else { + old_profile_name = extras.getString("profile_name"); + } + } else { + old_profile_name = (String) savedInstanceState.getSerializable("profile_name"); + }; + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + nicknamesArray = new LinkedList(Arrays.asList(prefs.getString("nicknames", "").split(", "))); + if(nicknamesArray.size() == 1 && nicknamesArray.get(0).length() == 0) { + nicknamesArray.remove(0); + } + ListView nicknamesList = (ListView) findViewById(R.id.nicknames_list); + ArrayAdapter nicknamesAdapter = new ArrayAdapter(this, + android.R.layout.simple_list_item_1, nicknamesArray); + if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + LinearLayout add_item_ll = (LinearLayout) findViewById(R.id.create_item_layout2); + add_item_ll.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + showEnterTextDialog(); + } + }); + } + + nicknamesList.setAdapter(nicknamesAdapter); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.nicknames_manager_menu, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if(id == R.id.add_nickname_item) { + showEnterTextDialog(); + } else if (id == R.id.clear_nicknames_item) { + nicknamesArray.clear(); + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + SharedPreferences.Editor editor = prefs.edit(); + editor.putString("nicknames", ""); + editor.commit(); + ListView nicknamesList = (ListView) findViewById(R.id.nicknames_list); + ArrayAdapter nicknamesAdapter = new ArrayAdapter(this, + android.R.layout.simple_list_item_1, nicknamesArray); + nicknamesList.setAdapter(nicknamesAdapter); + return true; + } + + return super.onOptionsItemSelected(item); + } + + public void onCreatingNicknames(String parameter, String value) { + if(parameter == "creating_nickname") { + StringBuilder nicknames_sb = new StringBuilder(); + if(value.length() > 0) { + + nicknamesArray.add(value); + }; + for (int i = 0; i < nicknamesArray.size(); i++) { + if(i < nicknamesArray.size() - 1 && nicknamesArray.get(i).length() > 0) { + nicknames_sb.append(nicknamesArray.get(i)).append(", "); + } else if(nicknamesArray.get(i).length() > 0) { + nicknames_sb.append(nicknamesArray.get(i)); + } + }; + ListView nicknamesList = (ListView) findViewById(R.id.nicknames_list); + ArrayAdapter nicknamesAdapter = new ArrayAdapter(this, + android.R.layout.simple_list_item_1, nicknamesArray); + nicknamesList.setAdapter(nicknamesAdapter); + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + SharedPreferences.Editor editor = prefs.edit(); + editor.putString("nicknames", nicknames_sb.toString()); + editor.commit(); + } + } + + public String getCurrentParameter() { + return current_parameter; + } + + public boolean showEnterTextDialog() { + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + DialogFragment enterTextDialogFragm = new EnterTextDialogFragm3(); + enterTextDialogFragm.show(getFragmentManager(), "enter_text_dlg"); + } else { + AlertDialog.Builder dialogBuilder; + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(CustomNicknamesActivity.this, R.style.IRCClient_Light)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(CustomNicknamesActivity.this, R.style.IRCClient)); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(CustomNicknamesActivity.this, R.style.IRCClient)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(CustomNicknamesActivity.this, R.style.IRCClient_Light)); + } + } + LayoutInflater inflater = getLayoutInflater(); + final View dialogView = inflater.inflate(R.layout.enter_text_activity, null); + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + dialogView.setMinimumWidth(metrics.widthPixels); + dialogBuilder.setView(dialogView); + dialogBuilder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + EditText profile_name = (EditText) dialogView.findViewById(R.id.profile_name_text); + onCreatingNicknames(current_parameter, profile_name.getText().toString()); + } + }); + dialogBuilder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + + } + }); + TextView textAreaTitle = (TextView) dialogView.findViewById(R.id.profile_name_label); + textAreaTitle.setText(R.string.your_nickname); + TextView dialog_title = (TextView) dialogView.findViewById(R.id.dialog_title); + dialog_title.setText(getString(R.string.enter_the_nick_title)); + AlertDialog alertDialog = dialogBuilder.create(); + alertDialog.getWindow().setGravity(Gravity.BOTTOM); + alertDialog.show(); + Button dialogButton; + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + + customizeDialogStyle(dialogButton, global_prefs, alertDialog); + } + return false; + }; + + private void setColorStyle(SharedPreferences global_prefs) { + if (global_prefs.getString("theme", "Light").contains("Light")) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.white_75)); + TextView app_title = (TextView) findViewById(R.id.app_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.white_75)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.white_75)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.white)); + } else { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.title_v11_transparent)); + TextView app_title = (TextView) findViewById(R.id.app_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + } + } + } else { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.title_v11_transparent)); + TextView app_title = (TextView) findViewById(R.id.app_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + } else { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.white_75)); + TextView app_title = (TextView) findViewById(R.id.app_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.white_75)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.white_75)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.white)); + } + } + } + } + + private void setCustomTheme(SharedPreferences global_prefs) { + if(global_prefs.getString("language", "OS dependent").contains("Russian")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getApplicationContext().getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getApplicationContext().getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } + } else if (global_prefs.getString("language", "OS dependent").contains("English")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getApplicationContext().getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getApplicationContext().getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } + } + if (global_prefs.getString("theme", "Light").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + setTheme(R.style.IRCClient_Light); + } else { + setTheme(R.style.IRCClient); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + setTheme(R.style.IRCClient); + } else { + setTheme(R.style.IRCClient_Light); + } + } + } + private void customizeDialogStyle(Button dialogButton, SharedPreferences global_prefs, AlertDialog alertDialog) { + if(global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } else { + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } else { + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } + } + } +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/CustomSpinnerAdapter.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/CustomSpinnerAdapter.java new file mode 100644 index 0000000..f250f78 --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/CustomSpinnerAdapter.java @@ -0,0 +1,78 @@ +package dev.tinelix.irc.android.legacy; + +import android.content.Context; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.TextView; + +import java.util.ArrayList; + +public class CustomSpinnerAdapter extends BaseAdapter { + Context ctx; + LayoutInflater inflater; + ArrayList objects; + + CustomSpinnerAdapter(Context context, ArrayList products) { + ctx = context; + objects = products; + inflater = (LayoutInflater) ctx + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + } + + @Override + public int getCount() { + return objects.size(); + } + + @Override + public Object getItem(int position) { + return objects.get(position); + } + + @Override + public long getItemId(int position) { + return position; + } + + CustomSpinnerItem getProfile(int position) { + return ((CustomSpinnerItem) getItem(position)); + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + View view = convertView; + if (view == null) { + view = inflater.inflate(R.layout.custom_spinner_item, parent, false); + } + + CustomSpinnerItem p = getProfile(position); + ((TextView) view.findViewById(R.id.spinner_item_text)).setText(p.name); + TextView item_name = (TextView) view.findViewById(R.id.spinner_item_text); + SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(ctx); + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + item_name.setTextColor(ctx.getResources().getColor(R.color.black)); + } else { + item_name.setTextColor(ctx.getResources().getColor(R.color.white)); + } + } else { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + item_name.setTextColor(ctx.getResources().getColor(R.color.white)); + } else { + item_name.setTextColor(ctx.getResources().getColor(R.color.black)); + } + } + return view; + } + + public class ViewHolder { + public TextView profile_name; + public TextView server; + } + + +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/CustomSpinnerItem.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/CustomSpinnerItem.java new file mode 100644 index 0000000..8da2f6d --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/CustomSpinnerItem.java @@ -0,0 +1,10 @@ +package dev.tinelix.irc.android.legacy; + +public class CustomSpinnerItem { + + String name; + + CustomSpinnerItem(String _describe) { + name = _describe; + } +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/DebugLogsActivity.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/DebugLogsActivity.java new file mode 100644 index 0000000..ac4bd9d --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/DebugLogsActivity.java @@ -0,0 +1,369 @@ +package dev.tinelix.irc.android.legacy; + +import android.Manifest; +import android.annotation.SuppressLint; +import android.app.Activity; +import android.app.AlertDialog; +import android.app.Fragment; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.content.res.Configuration; +import android.graphics.Typeface; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.os.Environment; +import android.preference.PreferenceManager; +import android.provider.Settings; +import android.util.Log; +import android.util.TypedValue; +import android.view.MotionEvent; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.ListView; +import android.widget.TextView; +import android.widget.Toast; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + +import static android.Manifest.permission.READ_EXTERNAL_STORAGE; +import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE; + +public class DebugLogsActivity extends Activity { + + public EditText debug_log_text; + public String log_text; + + @SuppressLint("ClickableViewAccessibility") + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + setCustomTheme(global_prefs); + setContentView(R.layout.debug_log_activity); + setColorStyle(global_prefs); + try { + Process process = Runtime.getRuntime().exec("logcat -d"); + BufferedReader bufferedReader = new BufferedReader( + new InputStreamReader(process.getInputStream())); + + StringBuilder log = new StringBuilder(); + String line = ""; + while ((line = bufferedReader.readLine()) != null) { + log.append(line + "\r\n"); + } + final EditText debug_log_text = (EditText) findViewById(R.id.debug_log_text); + log_text = log.toString(); + debug_log_text.setText(log_text); + debug_log_text.setKeyListener(null); + debug_log_text.setTypeface(Typeface.MONOSPACE); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + debug_log_text.setTextIsSelectable(true); + } + if(global_prefs.getInt("font_size", 0) >= 12) { + debug_log_text.setTextSize(TypedValue.COMPLEX_UNIT_SP, global_prefs.getInt("font_size", 0)); + } + } catch (IOException e) { + // Handle Exception + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + getActionBar().setHomeButtonEnabled(true); + } + Button save_log_btn = (Button) findViewById(R.id.save_log_btn); + save_log_btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + File directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "Tinelix"); + if (!directory.exists()) { + directory.mkdirs(); + } + + directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Tinelix", "IRC Client"); + if (!directory.exists()) { + directory.mkdirs(); + } + directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Tinelix/IRC Client", "App Logs"); + if (!directory.exists()) { + directory.mkdirs(); + } + + try { + Date dt = new Date(System.currentTimeMillis()); + Log.d("App", "Attempting creating log file..."); + File file = new File(directory, "LOG_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(dt) + ".log"); + if (!file.exists()) { + file.createNewFile(); + } + Log.d("App", "Log file created!"); + FileWriter writer = new FileWriter(file); + writer.append(log_text); + writer.flush(); + writer.close(); + Toast.makeText(getApplicationContext(), getResources().getString(R.string.saved_log, "Tinelix/IRC Client/App Logs"), Toast.LENGTH_LONG).show(); + } catch (Exception e) { + Log.e("App", "Could not save log to file: " + e.getMessage()); + } + } + }); + } + + private void showMissingPermssionDialog() { + AlertDialog dialog; + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(getResources().getString(R.string.allow_permisssion_in_storage_title)); + builder.setMessage(getResources().getString(R.string.allow_permisssion_in_storage)); + builder.setPositiveButton(getResources().getString(R.string.open_button), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + Uri uri = Uri.fromParts("package", getPackageName(), null); + intent.setData(uri); + startActivity(intent); + } + }); + builder.setNegativeButton(getResources().getString(R.string.cancel_button), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + return; + } + }); + dialog = builder.create(); + dialog.show(); + } + + private void setCustomTheme(SharedPreferences global_prefs) { + if (global_prefs.getString("language", "OS dependent").contains("Russian")) { + if (global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + config.locale = locale; + config.setLayoutDirection(locale); + } + getApplicationContext().getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } else if (global_prefs.getString("language", "OS dependent").contains("English")) { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + config.locale = locale; + config.setLayoutDirection(locale); + } + getApplicationContext().getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } + } else if (global_prefs.getString("language", "OS dependent").contains("English")) { + if (global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + config.locale = locale; + config.setLayoutDirection(locale); + } + getApplicationContext().getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + config.locale = locale; + config.setLayoutDirection(locale); + } + getApplicationContext().getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } + } + if (global_prefs.getString("theme", "Light").contains("Light")) { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + setTheme(R.style.IRCClient_Light); + } else { + setTheme(R.style.IRCClient); + } + } else { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + setTheme(R.style.IRCClient); + } else { + setTheme(R.style.IRCClient_Light); + } + } + } + + private void customizeDialogStyle(Button dialogButton, SharedPreferences global_prefs, AlertDialog alertDialog) { + if(global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } else { + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } else { + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } + } + } + + private void setColorStyle(SharedPreferences global_prefs) { + if (global_prefs.getString("theme", "Light").contains("Light")) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.white_75)); + TextView app_title = (TextView) findViewById(R.id.app_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.white_75)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.white_75)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.white)); + ListView main_menu = (ListView) findViewById(R.id.mainmenu); + debug_log_text = (EditText) findViewById(R.id.debug_log_text); + debug_log_text.setBackgroundColor(getResources().getColor(R.color.white_90)); + } else { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.title_v11_transparent)); + TextView app_title = (TextView) findViewById(R.id.app_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + ListView main_menu = (ListView) findViewById(R.id.mainmenu); + debug_log_text = (EditText) findViewById(R.id.debug_log_text); + debug_log_text.setBackgroundColor(getResources().getColor(R.color.gray_v2)); + } + } + } else { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.title_v11_transparent)); + TextView app_title = (TextView) findViewById(R.id.app_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + debug_log_text = (EditText) findViewById(R.id.debug_log_text); + debug_log_text.setBackgroundColor(getResources().getColor(R.color.gray_v2)); + } else { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.white_75)); + TextView app_title = (TextView) findViewById(R.id.app_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.white_75)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.white_75)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.white)); + debug_log_text = (EditText) findViewById(R.id.debug_log_text); + debug_log_text.setBackgroundColor(getResources().getColor(R.color.white_90)); + } + } + } +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/EnterPasswordDialogFragm.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/EnterPasswordDialogFragm.java new file mode 100644 index 0000000..3359497 --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/EnterPasswordDialogFragm.java @@ -0,0 +1,87 @@ +package dev.tinelix.irc.android.legacy; + +import android.annotation.SuppressLint; +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.DialogFragment; +import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.EditText; + +import java.util.Locale; + +@SuppressLint("NewApi") +public class EnterPasswordDialogFragm extends DialogFragment { + + public String current_parameter; + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + setLocale(global_prefs); + current_parameter = ((ProfileSettingsActivity) getActivity()).getCurrentParameter(); + String current_value; + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + if(current_parameter == "setting_password") { + LayoutInflater inflater = getActivity().getLayoutInflater(); + final View view = inflater.inflate(R.layout.enter_password_activity, null); + builder.setView(view); + builder.setTitle(R.string.enter_the_password_title); + builder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + EditText profile_name = (EditText) view.findViewById(R.id.password_text); + ((ProfileSettingsActivity) getActivity()).onChangingValues(current_parameter, profile_name.getText().toString()); + } + }); + builder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + return; + } + }); + }; + return builder.create(); + } + + private void setLocale(SharedPreferences global_prefs) { + if(global_prefs.getString("language", "OS dependent").contains("Russian")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } + } else if (global_prefs.getString("language", "OS dependent").contains("English")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } + } + } +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/EnterTextDialogFragm.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/EnterTextDialogFragm.java new file mode 100644 index 0000000..b91dc60 --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/EnterTextDialogFragm.java @@ -0,0 +1,105 @@ +package dev.tinelix.irc.android.legacy; + +import android.annotation.SuppressLint; +import android.app.AlertDialog; +import android.app.Dialog; +import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.os.Bundle; +import android.app.DialogFragment; +import android.preference.PreferenceManager; +import android.text.Editable; +import android.text.TextWatcher; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.EditText; +import android.widget.TextView; + +import java.util.Locale; + +@SuppressLint("NewApi") +public class EnterTextDialogFragm extends DialogFragment { + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + setLocale(global_prefs); + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + LayoutInflater inflater = getActivity().getLayoutInflater(); + final View view = inflater.inflate(R.layout.enter_text_activity, null); + final EditText profile_name = (EditText) view.findViewById(R.id.profile_name_text); + profile_name.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + if(profile_name.getText().toString().contains("/")) { + profile_name.setError(getResources().getString(R.string.text_field_wrong_characters)); + ((AlertDialog) getDialog()).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); + } else { + ((AlertDialog) getDialog()).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); + } + } + + @Override + public void afterTextChanged(Editable editable) { + + } + }); + builder.setView(view); + builder.setTitle(R.string.enter_the_pfn_title); + builder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + ((ConnectionManagerActivity) getActivity()).profileNameOkClicked(profile_name.getText().toString()); + } + }); + builder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + return; + } + }); + return builder.create(); + } + + private void setLocale(SharedPreferences global_prefs) { + if(global_prefs.getString("language", "OS dependent").contains("Russian")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } + } else if (global_prefs.getString("language", "OS dependent").contains("English")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } + } + } +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/EnterTextDialogFragm2.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/EnterTextDialogFragm2.java new file mode 100644 index 0000000..3faf38d --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/EnterTextDialogFragm2.java @@ -0,0 +1,227 @@ +package dev.tinelix.irc.android.legacy; + +import android.annotation.SuppressLint; +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.DialogFragment; +import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.text.Editable; +import android.text.TextWatcher; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.EditText; +import android.widget.TextView; + +import java.util.Locale; + +@SuppressLint("NewApi") +public class EnterTextDialogFragm2 extends DialogFragment { + + public String current_parameter; + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + setLocale(global_prefs); + current_parameter = ((ProfileSettingsActivity) getActivity()).getCurrentParameter(); + String current_value; + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + if(current_parameter == "changing_profile_name") { + current_value = ((ProfileSettingsActivity) getActivity()).getCurrentValue(current_parameter); + LayoutInflater inflater = getActivity().getLayoutInflater(); + final View view = inflater.inflate(R.layout.enter_text_activity, null); + final EditText profile_name = (EditText) view.findViewById(R.id.profile_name_text); + profile_name.setText(current_value); + profile_name.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + if(profile_name.getText().toString().contains("/")) { + profile_name.setError(getResources().getString(R.string.text_field_wrong_characters)); + ((AlertDialog) getDialog()).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); + } else { + ((AlertDialog) getDialog()).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); + } + } + + @Override + public void afterTextChanged(Editable editable) { + + } + }); + builder.setView(view); + builder.setTitle(R.string.enter_the_pfn_title); + builder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + EditText profile_name = (EditText) view.findViewById(R.id.profile_name_text); + ((ProfileSettingsActivity) getActivity()).onChangingValues(current_parameter, profile_name.getText().toString()); + } + }); + builder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + return; + } + }); + } else if(current_parameter == "changing_auth_method") { + current_value = ((ProfileSettingsActivity) getActivity()).getCurrentValue(current_parameter); + String[] auth_methods = getResources().getStringArray(R.array.auth_method); + builder.setTitle(R.string.auth_method); + if(current_value.contains("NickServ")) { + builder.setSingleChoiceItems(auth_methods, 1, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int item) { + String value; + if(item == 0) { + value = "Disabled"; + } else { + value = "NickServ"; + } + ((ProfileSettingsActivity) getActivity()).onChangingValues(current_parameter, value); + } + }); + } else { + builder.setSingleChoiceItems(auth_methods, 0, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int item) { + String value; + if(item == 0) { + value = "Disabled"; + } else { + value = "NickServ"; + } + ((ProfileSettingsActivity) getActivity()).onChangingValues(current_parameter, value); + } + }); + } + builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + } + }); + builder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + } + }); + } else if(current_parameter == "changing_realname") { + current_value = ((ProfileSettingsActivity) getActivity()).getCurrentValue(current_parameter); + LayoutInflater inflater = getActivity().getLayoutInflater(); + final View view = inflater.inflate(R.layout.enter_text_activity, null); + builder.setView(view); + builder.setTitle(R.string.enter_the_realname_title); + TextView realname_label = (TextView) view.findViewById(R.id.profile_name_label); + realname_label.setText(R.string.realname); + EditText realname_text = (EditText) view.findViewById(R.id.profile_name_text); + realname_text.setText(current_value); + builder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + EditText profile_name = (EditText) view.findViewById(R.id.profile_name_text); + ((ProfileSettingsActivity) getActivity()).onChangingValues(current_parameter, profile_name.getText().toString()); + } + }); + builder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + return; + } + }); + } else if(current_parameter == "changing_hostname") { + current_value = ((ProfileSettingsActivity) getActivity()).getCurrentValue(current_parameter); + LayoutInflater inflater = getActivity().getLayoutInflater(); + final View view = inflater.inflate(R.layout.enter_text_activity, null); + builder.setView(view); + builder.setTitle(R.string.enter_the_hostname_title); + TextView realname_label = (TextView) view.findViewById(R.id.profile_name_label); + realname_label.setText(R.string.hostname); + EditText realname_text = (EditText) view.findViewById(R.id.profile_name_text); + realname_text.setText(current_value); + builder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + EditText profile_name = (EditText) view.findViewById(R.id.profile_name_text); + ((ProfileSettingsActivity) getActivity()).onChangingValues(current_parameter, profile_name.getText().toString()); + } + }); + builder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + return; + } + }); + } else if(current_parameter == "changing_quitmsg") { + current_value = ((ProfileSettingsActivity) getActivity()).getCurrentValue(current_parameter); + LayoutInflater inflater = getActivity().getLayoutInflater(); + final View view = inflater.inflate(R.layout.enter_text_activity, null); + builder.setView(view); + builder.setTitle(R.string.enter_the_quiting_message); + TextView quitmsgname_label = (TextView) view.findViewById(R.id.profile_name_label); + quitmsgname_label.setText(R.string.quit_message); + EditText quitmsgname_text = (EditText) view.findViewById(R.id.profile_name_text); + quitmsgname_text.setText(current_value); + builder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + EditText profile_name = (EditText) view.findViewById(R.id.profile_name_text); + ((ProfileSettingsActivity) getActivity()).onChangingValues(current_parameter, profile_name.getText().toString()); + } + }); + builder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + return; + } + }); + } + return builder.create(); + } + + private void setLocale(SharedPreferences global_prefs) { + if(global_prefs.getString("language", "OS dependent").contains("Russian")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } + } else if (global_prefs.getString("language", "OS dependent").contains("English")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } + } + } +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/EnterTextDialogFragm3.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/EnterTextDialogFragm3.java new file mode 100644 index 0000000..bb01a9a --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/EnterTextDialogFragm3.java @@ -0,0 +1,90 @@ +package dev.tinelix.irc.android.legacy; + +import android.annotation.SuppressLint; +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.DialogFragment; +import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.EditText; +import android.widget.TextView; + +import java.util.Locale; + +@SuppressLint("NewApi") +public class EnterTextDialogFragm3 extends DialogFragment { + + public String current_parameter; + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + setLocale(global_prefs); + current_parameter = ((CustomNicknamesActivity) getActivity()).getCurrentParameter(); + String current_value; + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + if(current_parameter == "creating_nickname") { + LayoutInflater inflater = getActivity().getLayoutInflater(); + final View view = inflater.inflate(R.layout.enter_text_activity, null); + TextView text_area_title = (TextView) view.findViewById(R.id.profile_name_label); + text_area_title.setText(R.string.your_nickname); + builder.setView(view); + builder.setTitle(R.string.enter_the_nick_title); + builder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + EditText profile_name = (EditText) view.findViewById(R.id.profile_name_text); + ((CustomNicknamesActivity) getActivity()).onCreatingNicknames(current_parameter, profile_name.getText().toString()); + } + }); + builder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + return; + } + }); + }; + return builder.create(); + } + + private void setLocale(SharedPreferences global_prefs) { + if(global_prefs.getString("language", "OS dependent").contains("Russian")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } + } else if (global_prefs.getString("language", "OS dependent").contains("English")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } + } + } +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/IRCClientApp.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/IRCClientApp.java new file mode 100644 index 0000000..e95d0ba --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/IRCClientApp.java @@ -0,0 +1,58 @@ +package dev.tinelix.irc.android.legacy; + +import android.app.Application; +import android.content.Context; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; + +import java.io.File; +import java.util.ArrayList; +import java.util.LinkedList; + +public class IRCClientApp extends Application { + ArrayList profilesList = new ArrayList(); + + public String version = "0.4.0 Beta"; + public String build_date = "2022-05-06"; + + @Override + public void onCreate() { + String package_name = getApplicationContext().getPackageName(); + String profile_path = "/data/data/" + package_name + "/shared_prefs"; + File prefs_directory = new File(profile_path); + File[] prefs_files = prefs_directory.listFiles(); + SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + SharedPreferences.Editor editor = global_prefs.edit(); + if(prefs_files != null) { + String file_extension; + Context context = getApplicationContext(); + for (int i = 0; i < prefs_files.length; i++) { + if (prefs_files[i].getName().substring(0, (int) (prefs_files[i].getName().length() - 4)).startsWith(getApplicationInfo().packageName + "_preferences")) { + } else { + SharedPreferences prefs = context.getSharedPreferences(prefs_files[i].getName().substring(0, (int) (prefs_files[i].getName().length() - 4)), 0); + file_extension = prefs_files[i].getName().substring((int) (prefs_files[i].getName().length() - 4)); + if (file_extension.contains(".xml") && file_extension.length() == 4) { + editor = prefs.edit(); + editor.putBoolean("connected", false); + editor.commit(); + } + } + } + } + editor = global_prefs.edit(); + editor.putBoolean("connected", false); + editor.putBoolean("theme_requires_restart", false); + editor.putBoolean("language_requires_restart", false); + if(global_prefs.contains("theme") == false) { + editor.putString("theme", "Dark"); + } + if(global_prefs.contains("language") == false) { + editor.putString("language", "OS dependent"); + } + if(global_prefs.contains("show_msg_timestamps") == false) { + editor.putBoolean("show_msg_timestamps", false); + } + editor.commit(); + super.onCreate(); + } +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/IRCParser.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/IRCParser.java new file mode 100644 index 0000000..13ec2c4 --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/IRCParser.java @@ -0,0 +1,269 @@ +package dev.tinelix.irc.android.legacy; + +import android.app.PendingIntent; +import android.util.Log; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.concurrent.TimeUnit; + +public class IRCParser { + public String parseString(String raw, boolean showTimestamp) { + String[] array = raw.split(" "); + String[] member_msgs_array = array[0].split("!"); + StringBuilder stringBuilder = new StringBuilder(); + String parsed = new String(); + if(raw.startsWith("PING")) { + Log.w("Tinelix IRC Parser", "PING messages ignored."); + parsed = ""; + } else if(array[1].startsWith("372")) { + for(int index = 3; index < array.length; index++) { + if(index == 3) { + stringBuilder.append(array[index].replace(":","")); + } else { + stringBuilder.append(" " + array[index]); + } + } + parsed = "MOTD: " + stringBuilder.toString(); + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]"); + } else if(array[1].startsWith("371")) { + for(int index = 3; index < array.length; index++) { + if(index == 3) { + stringBuilder.append(array[index].replace(":","")); + } else { + stringBuilder.append(" " + array[index]); + } + } + parsed = "Info: " + stringBuilder.toString(); + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]"); + } else if(array[1].startsWith("671")) { + parsed = array[3] + " using a TLS/SSL connection."; + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]"); + } else if(array[1].startsWith("318")) { + Log.w("Tinelix IRC Parser", "Messages with \"318\" code ignored."); + parsed = ""; + } else if(array[1].startsWith("321")) { + Log.w("Tinelix IRC Parser", "Messages with \"321\" code ignored."); + parsed = ""; + } else if(array[1].startsWith("374")) { + Log.w("Tinelix IRC Parser", "Messages with \"374\" code ignored."); + parsed = ""; + } else if(array[1].startsWith("374")) { + Log.w("Tinelix IRC Parser", "Messages with \"374\" code ignored."); + parsed = ""; + } else if(array[1].startsWith("366")) { + Log.w("Tinelix IRC Parser", "Messages with \"366\" code ignored."); + parsed = ""; + } else if(array[1].startsWith("376")) { + Log.w("Tinelix IRC Parser", "Messages with \"376\" code ignored."); + parsed = ""; + } else if(array[1].startsWith("JOIN")) { + parsed = member_msgs_array[0].replace(":", "") + " joined on the " + array[2].replace(":", "") + " channel."; + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]"); + } else if(array[1].startsWith("PART")) { + parsed = member_msgs_array[0].replace(":", "") + " left the " + array[2].replace(":", "") + " channel."; + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]"); + } else if(array[1].startsWith("QUIT")) { + if(array.length > 3) { + for(int index = 2; index < array.length; index++) { + if(index == 2) { + stringBuilder.append(array[index].substring(1).replace("http//", "http://") + .replace("https//", "https://").replace("ftp//", "ftp://")); + } else { + stringBuilder.append(" " + array[index]); + } + } + parsed = member_msgs_array[0].replace(":", "") + " quited with reason: " + stringBuilder; + } else { + parsed = member_msgs_array[0].replace(":", "") + " quited."; + } + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]"); + } else if(array[1].startsWith("PRIVMSG")) { + for(int index = 3; index < array.length; index++) { + if(index == 3) { + stringBuilder.append(array[index].substring(1).replace("http//", "http://") + .replace("https//", "https://").replace("ftp//", "ftp://")); + } else { + stringBuilder.append(" " + array[index]); + } + } + parsed = member_msgs_array[0].replace(":", "") + ": " + stringBuilder.toString(); + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]"); + } else if(array[1].startsWith("NOTICE")) { + if(array.length > 4) { + for(int index = 3; index < array.length; index++) { + if(index == 3) { + stringBuilder.append(array[index].substring(1).replace("http//", "http://") + .replace("https//", "https://").replace("ftp//", "ftp://")); + } else { + stringBuilder.append(" " + array[index]); + } + } + parsed = member_msgs_array[0].replace(":", "") + " sent a notification: " + stringBuilder; + } + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]"); + } else if(array[1].startsWith("NICK")) { + parsed = member_msgs_array[0].replace(":", "") + " changed nickname to " + array[2].replace(":", ""); + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]"); + } else if(array[1].startsWith("353")) { + if(array.length > 5) { + for (int index = 5; index < array.length; index++) { + if (index == 5) { + stringBuilder.append(array[index].substring(1).replace("http//", "http://") + .replace("https//", "https://").replace("ftp//", "ftp://")); + } else { + stringBuilder.append(", " + array[index]); + } + } + parsed = "Members (" + (int)(array.length - 5) + "): " + stringBuilder; + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]"); + } + } else if(array[1].startsWith("TOPIC")) { + if(array.length > 3) { + for (int index = 3; index < array.length; index++) { + if (index == 3) { + stringBuilder.append(array[index].substring(1).replace("http//", "http://") + .replace("https//", "https://").replace("ftp//", "ftp://")); + } else { + stringBuilder.append(" " + array[index]); + } + } + parsed = "Topic: " + stringBuilder; + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]"); + } + } else if(array[1].startsWith("311")) { + if(array.length > 7) { + for (int index = 7; index < array.length; index++) { + if (index == 7) { + stringBuilder.append(array[index].substring(1).replace("http//", "http://") + .replace("https//", "https://").replace("ftp//", "ftp://")); + } else { + stringBuilder.append(" " + array[index].replace("http//", "http://") + .replace("https//", "https://").replace("ftp//", "ftp://")); + } + } + parsed = array[3] + " (" + array[4] + "@" + array[5] + ")\r\nReal name: " + stringBuilder + "\r\n------------------------------"; + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]"); + } + } else if(array[1].startsWith("319")) { + if(array.length > 4) { + for (int index = 4; index < array.length; index++) { + if (index == 4) { + stringBuilder.append(array[index].substring(1).replace("http//", "http://") + .replace("https//", "https://").replace("ftp//", "ftp://")); + } else { + stringBuilder.append(" " + array[index].replace("http//", "http://") + .replace("https//", "https://").replace("ftp//", "ftp://")); + } + } + parsed = "Mutual channels: " + stringBuilder; + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]"); + } + } else if(array[1].startsWith("317")) { + if(array.length > 4) { + try { + Date idle_time = new Date(TimeUnit.SECONDS.toMillis(Integer.parseInt(array[4]))); + Date logon_time = new Date(TimeUnit.SECONDS.toMillis(Integer.parseInt(array[5]))); + parsed = new SimpleDateFormat("HH:mm:ss").format(idle_time) + " idle, last logon time - " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(logon_time); + } catch(Exception e) { + e.printStackTrace(); + parsed = ""; + } + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]\r\nDate: " + System.currentTimeMillis()); + } + } else if(array[1].startsWith("MODE")) { + if(array.length > 3) { + for (int index = 3; index < array.length; index++) { + if (index == 3) { + stringBuilder.append(array[index].substring(1).replace("http//", "http://") + .replace("https//", "https://").replace("ftp//", "ftp://")); + } else { + stringBuilder.append(" " + array[index]); + } + } + parsed = "Enabled user modes for " + member_msgs_array[0].substring(1) + ": " + stringBuilder; + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]"); + } + } else { + try { + if(array.length > 3) { + for (int index = 3; index < array.length; index++) { + if (index == 3) { + stringBuilder.append(array[index].substring(1).replace("http//", "http://") + .replace("https//", "https://").replace("ftp//", "ftp://")); + } else { + stringBuilder.append(" " + array[index]); + } + } + parsed = "Code " + Integer.parseInt(array[1]) + ": " + stringBuilder.toString(); + } + } catch(NumberFormatException nfe) { + parsed = raw; + } + } + if(showTimestamp == true && parsed.length() > 0 && array[1].startsWith("317") == false && + array[1].startsWith("319") == false && array[1].startsWith("311") == false && array[1].startsWith("TOPIC") == false) { + Date time = new java.util.Date(System.currentTimeMillis()); + parsed = parsed + " (" + new SimpleDateFormat("HH:mm:ss").format(time) + ")"; + } + return parsed; + } + + + + public String getMessageBody(String raw) { + String[] array = raw.split(" "); + String[] member_msgs_array = array[0].split("!"); + StringBuilder stringBuilder = new StringBuilder(); + String parsed = new String(); + if(array[1].startsWith("PRIVMSG")) { + for(int index = 3; index < array.length; index++) { + if(index == 3) { + stringBuilder.append(array[index].substring(1).replace("http//", "http://") + .replace("https//", "https://").replace("ftp//", "ftp://")); + } else { + stringBuilder.append(" " + array[index]); + } + } + parsed = stringBuilder.toString(); + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]"); + } else { + parsed = ""; + } + return parsed; + } + + public String getMessageAuthor(String raw) { + String[] array = raw.split(" "); + String[] member_msgs_array = array[0].split("!"); + StringBuilder stringBuilder = new StringBuilder(); + String parsed = new String(); + if(array[1].startsWith("PRIVMSG")) { + parsed = member_msgs_array[0].substring(1); + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]"); + } else { + parsed = ""; + } + return parsed; + } + + public String getChannel(String raw) { + String[] array = raw.split(" "); + String[] member_msgs_array = array[0].split("!"); + StringBuilder stringBuilder = new StringBuilder(); + String parsed = new String(); + if(array[1].startsWith("JOIN")) { + parsed = array[2].substring(1); + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]"); + } else if(array[1].startsWith("PRIVMSG")) { + parsed = array[2]; + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]"); + } else if(array[1].startsWith("PART")) { + parsed = array[2]; + Log.i("Tinelix IRC Parser", "\r\nDone!\r\n\r\nOriginal string: [" + raw + "]\r\nCode: [" + array[1] + "]"); + } else { + parsed = ""; + } + return parsed; + } +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/MainActivity.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/MainActivity.java new file mode 100644 index 0000000..31fd414 --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/MainActivity.java @@ -0,0 +1,233 @@ +package dev.tinelix.irc.android.legacy; + +import android.app.Activity; +import android.content.Context; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.os.Build; +import android.os.Bundle; + +import android.content.Intent; +import android.preference.PreferenceManager; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.ListView; +import android.widget.TextView; + +import java.util.Locale; + +public class MainActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + if(global_prefs.getBoolean("connected", false) == true) { + finish(); + return; + } + setTitle(R.string.app_name); + setCustomTheme(global_prefs); + setContentView(R.layout.activity_main); + setColorStyle(global_prefs); + String[] mainMenu = getResources().getStringArray(R.array.main_menu_array); + ListView mainMenuList = (ListView) findViewById(R.id.mainmenu); + + ArrayAdapter mainMenuAdapter = new ArrayAdapter(this, + android.R.layout.simple_list_item_1, mainMenu); + + mainMenuList.setAdapter(mainMenuAdapter); + + if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + ImageButton menu_button = (ImageButton) findViewById(R.id.menu_button); + menu_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + openOptionsMenu(); + } + }); + } + + mainMenuList.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + if(i == 0) { + showConnectionManager(); + } else if(i == 1) { + showMainSettings(); + } else if(i == 2) { + showAboutApplication(); + } else if(i == 3) { + finish(); + System.exit(0); + } + } + }); + if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + ImageButton menu_button = (ImageButton) findViewById(R.id.menu_button); + menu_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + openOptionsMenu(); + } + }); + } + + } + + private void showMainSettings() { + Intent intent = new Intent(this, MainSettingsActivity.class); + startActivity(intent); + } + + private void showAboutApplication() { + Intent intent = new Intent(this, AboutApplicationActivity.class); + startActivity(intent); + } + + private void showConnectionManager() { + Intent intent = new Intent(this, ConnectionManagerActivity.class); + startActivity(intent); + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) + { + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.main_menu, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.about_application_item) { + showAboutApplication(); + } + + return super.onOptionsItemSelected(item); + } + + private void setColorStyle(SharedPreferences global_prefs) { + if (global_prefs.getString("theme", "Light").contains("Light")) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.white_75)); + TextView app_title = (TextView) findViewById(R.id.app_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.white_75)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.white_75)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.white)); + ListView main_menu = (ListView) findViewById(R.id.mainmenu); + main_menu.setBackgroundColor(getResources().getColor(R.color.white)); + main_menu.setCacheColorHint(getResources().getColor(R.color.white)); + } else { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.title_v11_transparent)); + TextView app_title = (TextView) findViewById(R.id.app_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + ListView main_menu = (ListView) findViewById(R.id.mainmenu); + main_menu.setBackgroundColor(getResources().getColor(R.color.black)); + main_menu.setCacheColorHint(getResources().getColor(R.color.black)); + } + } + } else { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.title_v11_transparent)); + TextView app_title = (TextView) findViewById(R.id.app_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + ListView main_menu = (ListView) findViewById(R.id.mainmenu); + main_menu.setBackgroundColor(getResources().getColor(R.color.black)); + main_menu.setCacheColorHint(getResources().getColor(R.color.black)); + } else { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.white_75)); + TextView app_title = (TextView) findViewById(R.id.app_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.white_75)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.white_75)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.white)); + ListView main_menu = (ListView) findViewById(R.id.mainmenu); + main_menu.setBackgroundColor(getResources().getColor(R.color.white)); + main_menu.setCacheColorHint(getResources().getColor(R.color.white)); + } + } + } + } + + private void setCustomTheme(SharedPreferences global_prefs) { + if(global_prefs.getString("language", "OS dependent").contains("Russian")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } + } else if (global_prefs.getString("language", "OS dependent").contains("English")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } + } + if (global_prefs.getString("theme", "Light").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + setTheme(R.style.IRCClient_Light); + } else { + setTheme(R.style.IRCClient); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + setTheme(R.style.IRCClient); + } else { + setTheme(R.style.IRCClient_Light); + } + } + } + +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/MainSettingsActivity.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/MainSettingsActivity.java new file mode 100644 index 0000000..bfedb35 --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/MainSettingsActivity.java @@ -0,0 +1,773 @@ +package dev.tinelix.irc.android.legacy; + +import android.Manifest; +import android.app.Activity; +import android.app.AlarmManager; +import android.app.AlertDialog; +import android.app.DialogFragment; +import android.app.PendingIntent; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.content.res.Configuration; +import android.graphics.Typeface; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.os.Environment; +import android.preference.CheckBoxPreference; +import android.preference.Preference; +import android.preference.PreferenceActivity; +import android.preference.PreferenceManager; +import android.provider.Settings; +import android.text.Html; +import android.util.DisplayMetrics; +import android.util.Log; +import android.util.TypedValue; +import android.view.ContextThemeWrapper; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.MenuItem; +import android.view.View; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.SeekBar; +import android.widget.TextView; +import android.widget.Toast; + +import org.w3c.dom.Text; + +import java.io.File; +import java.util.Locale; + +public class MainSettingsActivity extends PreferenceActivity { + + public String package_name; + public String current_parameter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + setCustomTheme(global_prefs); + setColorStyle(global_prefs); + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.main_settings); + setContentView(R.layout.custom_preferences_layout); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + getActionBar().setHomeButtonEnabled(true); + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + getActionBar().setDisplayHomeAsUpEnabled(true); + } else { + TextView app_title = (TextView) findViewById(R.id.app_title_label); + app_title.setText(R.string.settings_title); + } + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + final Preference ui_language = findPreference("interface_language"); + ui_language.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + setResult(Activity.RESULT_OK); + current_parameter = "setting_language"; + final String current_value; + final String[] value = {new String()}; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + DialogFragment setFontSizeDialogFragm = new SettingsItemsDialogFragm(); + setFontSizeDialogFragm.show(getFragmentManager(), "settings_items"); + } else { + current_value = getCurrentValue(current_parameter); + final String[] languages = getResources().getStringArray(R.array.ui_language); + final String[] requires_reboot_app = getResources().getStringArray(R.array.ui_language_app_restart_toast); + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + final AlertDialog.Builder dialogBuilder; + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(MainSettingsActivity.this, R.style.IRCClient_Light)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(MainSettingsActivity.this, R.style.IRCClient)); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(MainSettingsActivity.this, R.style.IRCClient)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(MainSettingsActivity.this, R.style.IRCClient_Light)); + } + } + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder.setTitle(Html.fromHtml("" + getString(R.string.interface_language_item) + "")); + } else { + dialogBuilder.setTitle(Html.fromHtml("" + getString(R.string.interface_language_item) + "")); + } + } else { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder.setTitle(Html.fromHtml("" + getString(R.string.interface_language_item) + "")); + } else { + dialogBuilder.setTitle(Html.fromHtml("" + getString(R.string.interface_language_item) + "")); + } + } + if(current_value.contains("OS dependent")) { + dialogBuilder.setSingleChoiceItems(languages, 0, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int item) { + if(item == 0) { + value[0] = "OS dependent"; + } else if(item == 1) { + value[0] = "English"; + } else { + value[0] = "Russian"; + } + } + }); + } else if(current_value.contains("English")) { + dialogBuilder.setSingleChoiceItems(languages, 1, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int item) { + if(item == 0) { + value[0] = "OS dependent"; + } else if(item == 1) { + value[0] = "English"; + } else { + value[0] = "Russian"; + } + } + }); + } else { + dialogBuilder.setSingleChoiceItems(languages, 2, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int item) { + if(item == 0) { + value[0] = "OS dependent"; + } else if(item == 1) { + value[0] = "English"; + } else { + value[0] = "Russian"; + } + } + }); + } + dialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + onChangingValues(current_parameter, value[0]); + SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + if(global_prefs.getBoolean("connected", false) == false) { + Intent mainActivity = new Intent(getApplicationContext(), this.getClass()); + int pendingIntentId = 1; + PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), pendingIntentId, mainActivity, PendingIntent.FLAG_CANCEL_CURRENT); + AlarmManager mgr = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); + mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, pendingIntent); + System.exit(0); + } else { + if(current_value.contains("Russian")) { + Toast.makeText(getApplicationContext(), requires_reboot_app[1], Toast.LENGTH_LONG).show(); + } else { + Toast.makeText(getApplicationContext(), requires_reboot_app[0], Toast.LENGTH_LONG).show(); + } + } + } + }); + dialogBuilder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + } + }); + AlertDialog alertDialog = dialogBuilder.create(); + alertDialog.getWindow().setGravity(Gravity.BOTTOM); + + alertDialog.show(); + Button dialogButton; + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + customizeDialogStyle(dialogButton, global_prefs, alertDialog); + } + return true; + } + }); + String[] languages = getResources().getStringArray(R.array.ui_language); + if (global_prefs.getBoolean("language_requires_restart", false) == false) { + if (global_prefs.getString("language", "OS dependent").contains("English")) { + ui_language.setSummary(languages[1]); + } else if (global_prefs.getString("language", "OS dependent").contains("Russian")) { + ui_language.setSummary(languages[2]); + } else { + ui_language.setSummary(languages[0]); + } + } else { + ui_language.setSummary(R.string.need_to_restart); + ui_language.setEnabled(false); + } + final Preference app_theme = findPreference("interface_theme"); + final String[] value = {new String()}; + app_theme.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + setResult(Activity.RESULT_OK); + current_parameter = "setting_theme"; + final String current_value; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + DialogFragment setFontSizeDialogFragm = new SettingsItemsDialogFragm(); + setFontSizeDialogFragm.show(getFragmentManager(), "settings_items"); + } else { + current_value = getCurrentValue(current_parameter); + final String[] requires_reboot_app = getResources().getStringArray(R.array.ui_language_app_restart_toast); + final String[] themes = getResources().getStringArray(R.array.themes); + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + final AlertDialog.Builder dialogBuilder; + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(MainSettingsActivity.this, R.style.IRCClient_Light)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(MainSettingsActivity.this, R.style.IRCClient)); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(MainSettingsActivity.this, R.style.IRCClient)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(MainSettingsActivity.this, R.style.IRCClient_Light)); + } + } + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder.setTitle(Html.fromHtml("" + getString(R.string.interface_theme_item) + "")); + } else { + dialogBuilder.setTitle(Html.fromHtml("" + getString(R.string.interface_theme_item) + "")); + } + } else { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder.setTitle(Html.fromHtml("" + getString(R.string.interface_theme_item) + "")); + } else { + dialogBuilder.setTitle(Html.fromHtml("" + getString(R.string.interface_theme_item) + "")); + } + } + if(current_value.contains("Light")) { + dialogBuilder.setSingleChoiceItems(themes, 1, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int item) { + if(item == 0) { + value[0] = "Dark"; + } else { + value[0] = "Light"; + } + } + }); + } else { + dialogBuilder.setSingleChoiceItems(themes, 0, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int item) { + if(item == 0) { + value[0] = "Dark"; + } else { + value[0] = "Light"; + } + } + }); + } + dialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + onChangingValues(current_parameter, value[0]); + if(global_prefs.getBoolean("connected", false) == false) { + Intent mainActivity = new Intent(getApplicationContext(), this.getClass()); + int pendingIntentId = 1; + PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), pendingIntentId, mainActivity, PendingIntent.FLAG_CANCEL_CURRENT); + AlarmManager mgr = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); + mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, pendingIntent); + System.exit(0); + } else { + if(current_value.contains("Russian")) { + Toast.makeText(getApplicationContext(), requires_reboot_app[0], Toast.LENGTH_LONG).show(); + } else { + Toast.makeText(getApplicationContext(), requires_reboot_app[1], Toast.LENGTH_LONG).show(); + } + } + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + if (global_prefs.getString("theme", "Dark").contains("Light")) { + app_theme.setSummary(themes[1]); + } else { + app_theme.setSummary(themes[0]); + } + } else { + app_theme.setSummary(R.string.need_to_restart); + app_theme.setEnabled(false); + } + } + }); + dialogBuilder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + } + }); + AlertDialog alertDialog = dialogBuilder.create(); + alertDialog.getWindow().setGravity(Gravity.BOTTOM); + + alertDialog.show(); + Button dialogButton; + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + customizeDialogStyle(dialogButton, global_prefs, alertDialog); + } + return true; + } + }); + String[] themes = getResources().getStringArray(R.array.themes); + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + if (global_prefs.getString("theme", "Dark").contains("Light")) { + app_theme.setSummary(themes[1]); + } else { + app_theme.setSummary(themes[0]); + } + } else { + app_theme.setSummary(R.string.need_to_restart); + app_theme.setEnabled(false); + } + + Preference setFontSizePref = findPreference("font_size"); + setFontSizePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + setResult(Activity.RESULT_OK); + current_parameter = "setting_fontsize"; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + DialogFragment setFontSizeDialogFragm = new SetFontSizeDialogFragm(); + setFontSizeDialogFragm.show(getFragmentManager(), "set_font_size"); + } else { + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + final AlertDialog.Builder dialogBuilder; + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(MainSettingsActivity.this, R.style.IRCClient_Light)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(MainSettingsActivity.this, R.style.IRCClient)); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(MainSettingsActivity.this, R.style.IRCClient)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(MainSettingsActivity.this, R.style.IRCClient_Light)); + } + } + LayoutInflater inflater = getLayoutInflater(); + final View dialogView = inflater.inflate(R.layout.set_font_size_activity, null); + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + dialogView.setMinimumWidth(metrics.widthPixels); + final SeekBar font_size_seekbar = (SeekBar) dialogView.findViewById(R.id.font_size_seekbar); + final EditText preview_text = (EditText) dialogView.findViewById(R.id.preview_text); + final TextView value_label = (TextView) dialogView.findViewById(R.id.value_label); + dialogBuilder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + SharedPreferences.Editor editor = prefs.edit(); + editor.putInt("font_size", font_size_seekbar.getProgress() + 12); + editor.commit(); + } + }); + dialogBuilder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + return; + } + }); + preview_text.setKeyListener(null); + font_size_seekbar.setMax((60 - 12) / 1); + font_size_seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int i, boolean b) { + preview_text.setTextSize(TypedValue.COMPLEX_UNIT_SP, i + 12); + value_label.setText(getString(R.string.value_in_px, i + 12)); + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + + } + }); + if(prefs.getInt("font_size", 0) < 12) { + float text_size_in_sp = (int) preview_text.getTextSize() / getResources().getDisplayMetrics().scaledDensity; + font_size_seekbar.setProgress((int) text_size_in_sp - 12); + value_label.setText(getString(R.string.value_in_px, (int)text_size_in_sp)); + preview_text.setTextSize(TypedValue.COMPLEX_UNIT_SP, text_size_in_sp); + } else { + font_size_seekbar.setProgress(prefs.getInt("font_size", 0) - 12); + value_label.setText(getString(R.string.value_in_px, prefs.getInt("font_size", 0))); + preview_text.setTextSize(TypedValue.COMPLEX_UNIT_SP, prefs.getInt("font_size", 0)); + } + TextView dialog_title = (TextView) dialogView.findViewById(R.id.dialog_title); + dialog_title.setText(getString(R.string.changing_font_label)); + dialogBuilder.setView(dialogView); + AlertDialog alertDialog = dialogBuilder.create(); + alertDialog.getWindow().setGravity(Gravity.BOTTOM); + + alertDialog.show(); + Button dialogButton; + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + customizeDialogStyle(dialogButton, global_prefs, alertDialog); + } + return true; + } + }); + setFontSizePref.setSummary(getString(R.string.value_in_px, prefs.getInt("font_size", 18))); + + final CheckBoxPreference save_msg_history = (CheckBoxPreference) findPreference("save_msg_history"); + + save_msg_history.setChecked(global_prefs.getBoolean("save_msg_history", false)); + + File directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath()); + if (!directory.canWrite() && !directory.canRead()) { + save_msg_history.setChecked(false); + onChangingBooleanValues("setting_saving_msg_history", false); + save_msg_history.setEnabled(false); + save_msg_history.setSummary(R.string.device_memory_restricted); + } + + save_msg_history.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + if(save_msg_history.isChecked() == true) { + save_msg_history.setSummary(getResources().getString(R.string.saved_messages_history, "Tinelix/IRC Client/Messages Logs")); + } + + current_parameter = "setting_saving_msg_history"; + onChangingBooleanValues(current_parameter, save_msg_history.isChecked()); + return false; + } + }); + Preference debug_logs = findPreference("debug_logs"); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + debug_logs.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + showDebugLogsActivity(); + return false; + } + }); + } + } + + @Override + protected void onResume() { + CheckBoxPreference save_msg_history = (CheckBoxPreference) findPreference("save_msg_history"); + SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(MainSettingsActivity.this); + File directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath()); + if (!directory.canWrite() && !directory.canRead()) { + save_msg_history.setChecked(false); + save_msg_history.setEnabled(false); + save_msg_history.setSummary(R.string.device_memory_restricted); + } else { + save_msg_history.setChecked(global_prefs.getBoolean("save_msg_history", false)); + save_msg_history.setSummary(getResources().getString(R.string.saved_messages_history, "Tinelix/IRC Client/Messages Logs")); + } + super.onResume(); + } + + private void showMissingPermssionDialog() { + AlertDialog dialog; + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(getResources().getString(R.string.allow_permisssion_in_storage_title)); + builder.setMessage(getResources().getString(R.string.allow_permisssion_in_storage)); + builder.setPositiveButton(getResources().getString(R.string.open_button), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + Uri uri = Uri.fromParts("package", getPackageName(), null); + intent.setData(uri); + startActivity(intent); + } + }); + builder.setNegativeButton(getResources().getString(R.string.cancel_button), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + CheckBoxPreference save_msg_history = (CheckBoxPreference) findPreference("save_msg_history"); + save_msg_history.setChecked(false); + onChangingBooleanValues(current_parameter, save_msg_history.isChecked()); + return; + } + }); + dialog = builder.create(); + dialog.show(); + } + + private void showDebugLogsActivity() { + Intent intent = new Intent(this, DebugLogsActivity.class); + startActivity(intent); + } + + public String getCurrentParameter() { + return current_parameter; + } + + public String getCurrentValue(String current_parameter) { + String value; + if(current_parameter == "setting_language") { + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + value = prefs.getString("language", "OS dependent"); + } else if(current_parameter == "setting_theme") { + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + value = prefs.getString("theme", "Dark"); + } else { + value = ""; + } + return value; + } + + public void onChangingValues(String current_parameter, String value) { + if(current_parameter == "setting_language") { + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + SharedPreferences.Editor editor = prefs.edit(); + editor.putString("language", value); + editor.putBoolean("language_requires_restart", true); + editor.commit(); + Preference ui_language = findPreference("interface_language"); + final String[] languages = getResources().getStringArray(R.array.ui_language); + if(prefs.getBoolean("language_requires_restart", false) == false) { + if (prefs.getString("language", "OS dependent").contains("English")) { + ui_language.setSummary(languages[1]); + } else if (prefs.getString("language", "OS dependent").contains("Russian")) { + ui_language.setSummary(languages[2]); + } else { + ui_language.setSummary(languages[0]); + } + } else { + ui_language.setSummary(R.string.need_to_restart); + ui_language.setEnabled(false); + } + } else if(current_parameter == "setting_theme") { + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + SharedPreferences.Editor editor = prefs.edit(); + editor.putString("theme", value); + editor.putBoolean("theme_requires_restart", true); + editor.commit(); + Preference theme = findPreference("interface_theme"); + final String[] themes = getResources().getStringArray(R.array.themes); + if(prefs.getBoolean("theme_requires_restart", false) == false) { + if (prefs.getString("theme", "Dark").contains("Light")) { + theme.setSummary(themes[1]); + } else { + theme.setSummary(themes[0]); + } + } else { + theme.setSummary(R.string.need_to_restart); + theme.setEnabled(false); + } + } + } + + private void onChangingBooleanValues(String current_parameter, boolean value) { + if(current_parameter == "setting_saving_msg_history") { + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + SharedPreferences.Editor editor = prefs.edit(); + editor.putBoolean("save_msg_history", value); + editor.commit(); + } + } + + public void showDebugLogActivity() { + Intent intent = new Intent(this, ConnectionManagerActivity.class); + startActivity(intent); + } + + public void setColorStyle(SharedPreferences global_prefs) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + getListView().setBackgroundColor(getResources().getColor(R.color.white)); + getListView().setCacheColorHint(getResources().getColor(R.color.white)); + } else { + getListView().setBackgroundColor(getResources().getColor(R.color.black)); + getListView().setCacheColorHint(getResources().getColor(R.color.black)); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + getListView().setBackgroundColor(getResources().getColor(R.color.black)); + getListView().setCacheColorHint(getResources().getColor(R.color.black)); + } else { + getListView().setBackgroundColor(getResources().getColor(R.color.white)); + getListView().setCacheColorHint(getResources().getColor(R.color.white)); + } + } + } + } + + private void setCustomTheme(SharedPreferences global_prefs) { + if(global_prefs.getString("language", "OS dependent").contains("Russian")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } + } else if (global_prefs.getString("language", "OS dependent").contains("English")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } + } + if (global_prefs.getString("theme", "Light").contains("Light")) { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + setTheme(R.style.IRCClient_Light); + } else { + setTheme(R.style.IRCClient); + } + } else { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + setTheme(R.style.IRCClient); + } else { + setTheme(R.style.IRCClient_Light); + } + } + } + + private void customizeDialogStyle(Button dialogButton, SharedPreferences global_prefs, AlertDialog alertDialog) { + if(global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } else { + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } else { + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } + } + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + if(id == android.R.id.home) { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) { + onBackPressed(); + } else { + finish(); + } + } + return super.onOptionsItemSelected(item); + } + +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/NotificationActivity.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/NotificationActivity.java new file mode 100644 index 0000000..582ad3a --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/NotificationActivity.java @@ -0,0 +1,52 @@ +package dev.tinelix.irc.android.legacy; + +import android.app.Activity; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.os.Bundle; +import android.preference.PreferenceManager; + +import java.util.Locale; + +public class NotificationActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + if(global_prefs.getString("language", "OS dependent").contains("Russian")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } + } else if (global_prefs.getString("language", "OS dependent").contains("English")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } + } + setContentView(R.layout.notification_activity); + } + +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/Profile.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/Profile.java new file mode 100644 index 0000000..89de209 --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/Profile.java @@ -0,0 +1,18 @@ +package dev.tinelix.irc.android.legacy; + +public class Profile { + + String name; + String server; + int port; + boolean isConnected; + boolean isSelected; + + Profile(String _describe, String _server, int _port, boolean _isConnected, boolean _isSelected) { + name = _describe; + server = _server; + port = _port; + isConnected = _isConnected; + isSelected = _isSelected; + } +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/ProfileAdapter.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/ProfileAdapter.java new file mode 100644 index 0000000..d46f2af --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/ProfileAdapter.java @@ -0,0 +1,144 @@ +package dev.tinelix.irc.android.legacy; + +import android.content.Context; +import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.ListView; +import android.widget.TextView; +import android.app.Activity; +import android.widget.Toast; + +import java.util.ArrayList; + +public class ProfileAdapter extends BaseAdapter { + Context ctx; + LayoutInflater inflater; + ArrayList objects; + + ProfileAdapter(Context context, ArrayList products) { + ctx = context; + objects = products; + inflater = (LayoutInflater) ctx + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + } + + @Override + public int getCount() { + return objects.size(); + } + + @Override + public Object getItem(int position) { + return objects.get(position); + } + + @Override + public long getItemId(int position) { + return position; + } + + Profile getProfile(int position) { + return ((Profile) getItem(position)); + } + + @Override + public View getView(final int position, View convertView, final ViewGroup parent) { + View view = convertView; + if (view == null) { + view = inflater.inflate(R.layout.profile_item, parent, false); + } + + Profile p = getProfile(position); + ((TextView) view.findViewById(R.id.profile_item_label)).setText(p.name); + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(view.getContext()); + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + ((TextView) view.findViewById(R.id.profile_item_label)).setTextColor(view.getResources().getColor(R.color.black)); + } else { + ((TextView) view.findViewById(R.id.profile_item_label)).setTextColor(view.getResources().getColor(R.color.white)); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + ((TextView) view.findViewById(R.id.profile_item_label)).setTextColor(view.getResources().getColor(R.color.white)); + } else { + ((TextView) view.findViewById(R.id.profile_item_label)).setTextColor(view.getResources().getColor(R.color.black)); + } + } + SharedPreferences prefs = view.getContext().getSharedPreferences(p.name, 0); + if(prefs.getBoolean("connected", false) == true) { + view.findViewById(R.id.state_indicator).setVisibility(View.VISIBLE); + ImageButton edit_btn = (ImageButton) view.findViewById(R.id.edit_btn); + edit_btn.setVisibility(View.GONE); + ImageButton delete_btn = (ImageButton) view.findViewById(R.id.delete_btn); + delete_btn.setVisibility(View.GONE); + } else { + view.findViewById(R.id.state_indicator).setVisibility(View.GONE); + } + ((TextView) view.findViewById(R.id.profile_server_label)).setText(p.server + ":" + p.port); + ImageButton edit_btn = (ImageButton) view.findViewById(R.id.edit_btn); + edit_btn.setTag(position); + edit_btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + for (int pos = 0; pos < getCount(); pos++) { + if(pos == position) { + ((Profile) getItem(pos)).isSelected = true; + ((ConnectionManagerActivity) ctx).editProfile(pos); + } else { + ((Profile) getItem(pos)).isSelected = false; + } + } + } + }); + ImageButton delete_btn = (ImageButton) view.findViewById(R.id.delete_btn); + delete_btn.setTag(position); + delete_btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + for (int pos = 0; pos < getCount(); pos++) { + if(pos == position) { + ((Profile) getItem(pos)).isSelected = true; + ((ConnectionManagerActivity) ctx).deleteProfile(pos); + } else { + ((Profile) getItem(pos)).isSelected = false; + } + } + } + }); + ImageButton connect_btn = (ImageButton) view.findViewById(R.id.connect_btn); + connect_btn.setTag(position); + connect_btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + for (int pos = 0; pos < getCount(); pos++) { + if(pos == position) { + ((Profile) getItem(pos)).isSelected = true; + ((Profile) getItem(pos)).isConnected = true; + ((ConnectionManagerActivity) ctx).connectProfile(pos); + } else { + ((Profile) getItem(pos)).isSelected = false; + } + } + } + }); + return view; + } + + public class ViewHolder { + public TextView profile_name; + public TextView server; + } + + +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/ProfileSettingsActivity.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/ProfileSettingsActivity.java new file mode 100644 index 0000000..de1148d --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/ProfileSettingsActivity.java @@ -0,0 +1,1100 @@ +package dev.tinelix.irc.android.legacy; + +import android.app.Activity; +import android.app.AlertDialog; +import android.app.DialogFragment; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.graphics.Typeface; +import android.os.Build; +import android.os.Bundle; +import android.preference.Preference; +import android.preference.PreferenceActivity; +import android.preference.PreferenceManager; +import android.text.Editable; +import android.text.Html; +import android.text.TextWatcher; +import android.util.DisplayMetrics; +import android.util.Log; +import android.view.ContextThemeWrapper; +import android.view.Gravity; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.MenuItem; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.Spinner; +import android.widget.TextView; +import android.widget.Toast; + +import org.w3c.dom.Text; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; + +public class ProfileSettingsActivity extends PreferenceActivity +{ + public String old_profile_name; + public String package_name; + public String current_parameter; + public String auth_method_string; + public String server_name; + public int server_port; + public String realname_string; + public String hostname_string; + public String quitmsg_string; + + @Override + protected void onCreate(Bundle savedInstanceState) + { + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + setCustomTheme(global_prefs); + setColorStyle(global_prefs); + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.profile_settings); + setContentView(R.layout.custom_preferences_layout); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + getActionBar().setHomeButtonEnabled(true); + getActionBar().setTitle(getResources().getString(R.string.connection_manager_title)); + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + getActionBar().setDisplayHomeAsUpEnabled(true); + } else { + TextView app_title = (TextView) findViewById(R.id.app_title_label); + app_title.setText(R.string.connection_manager_title); + } + + if (savedInstanceState == null) { + Bundle extras = getIntent().getExtras(); + if(extras == null) { + old_profile_name = null; + package_name = null; + } else { + old_profile_name = extras.getString("profile_name"); + package_name = extras.getString("package_name"); + } + } else { + old_profile_name = (String) savedInstanceState.getSerializable("profile_name"); + package_name = (String) savedInstanceState.getSerializable("package_name"); + } + final Preference prof_name = (Preference) findPreference("prof_name"); + prof_name.setSummary(old_profile_name); + prof_name.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() + { + public boolean onPreferenceClick(Preference pref) + { + setResult(Activity.RESULT_OK); + current_parameter = "changing_profile_name"; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + DialogFragment enterTextDialogFragm = new EnterTextDialogFragm2(); + enterTextDialogFragm.show(getFragmentManager(), "enter_text_dlg"); + } else { + final AlertDialog.Builder dialogBuilder; + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient_Light)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient)); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient_Light)); + } + } + String old_profile_name = getCurrentValue(current_parameter); + LayoutInflater inflater = getLayoutInflater(); + final View dialogView = inflater.inflate(R.layout.enter_text_activity, null); + final EditText profile_name = (EditText) dialogView.findViewById(R.id.profile_name_text); + profile_name.setText(old_profile_name); + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + dialogView.setMinimumWidth(metrics.widthPixels); + dialogBuilder.setView(dialogView); + dialogBuilder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + EditText profile_name = (EditText) dialogView.findViewById(R.id.profile_name_text); + onChangingValues(current_parameter, profile_name.getText().toString()); + } + }); + dialogBuilder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + + } + }); + TextView dialog_title = (TextView) dialogView.findViewById(R.id.dialog_title); + dialog_title.setText(getString(R.string.enter_the_pfn_title)); + final AlertDialog alertDialog = dialogBuilder.create(); + profile_name.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + if(profile_name.getText().toString().contains("/")) { + profile_name.setError(getResources().getString(R.string.text_field_wrong_characters)); + alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); + } else { + alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); + } + } + + @Override + public void afterTextChanged(Editable editable) { + + } + }); + alertDialog.getWindow().setGravity(Gravity.BOTTOM); + alertDialog.show(); + Button dialogButton = null; + customizeDialogStyle(dialogButton, global_prefs, alertDialog); + } + return true; + } + }); + Preference auth_method = (Preference) findPreference("auth_method"); + auth_method.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() + { + public boolean onPreferenceClick(Preference pref) + { + setResult(Activity.RESULT_OK); + current_parameter = "changing_auth_method"; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + DialogFragment enterTextDialogFragm = new EnterTextDialogFragm2(); + enterTextDialogFragm.show(getFragmentManager(), "enter_text_dlg"); + } else { + final AlertDialog.Builder dialogBuilder; + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient_Light)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient)); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient_Light)); + } + } + String current_value = getCurrentValue(current_parameter); + String[] auth_methods = getResources().getStringArray(R.array.auth_method); + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder.setTitle(Html.fromHtml("" + getString(R.string.auth_method) + "")); + } else { + dialogBuilder.setTitle(Html.fromHtml("" + getString(R.string.auth_method) + "")); + } + } else { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder.setTitle(Html.fromHtml("" + getString(R.string.auth_method) + "")); + } else { + dialogBuilder.setTitle(Html.fromHtml("" + getString(R.string.auth_method) + "")); + } + } + if(current_value.contains("NickServ")) { + dialogBuilder.setSingleChoiceItems(auth_methods, 1, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int item) { + String value; + if(item == 0) { + value = "Disabled"; + } else { + value = "NickServ"; + } + onChangingValues(current_parameter, value); + } + }); + } else { + dialogBuilder.setSingleChoiceItems(auth_methods, 0, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int item) { + String value; + if(item == 0) { + value = "Disabled"; + } else { + value = "NickServ"; + } + onChangingValues(current_parameter, value); + } + }); + } + dialogBuilder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + } + }); + dialogBuilder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + + } + }); + AlertDialog alertDialog = dialogBuilder.create(); + alertDialog.getWindow().setGravity(Gravity.BOTTOM); + alertDialog.show(); + Button dialogButton = null; + customizeDialogStyle(dialogButton, global_prefs, alertDialog); + } + return true; + } + }); + Preference nicknames = (Preference) findPreference("nicknames"); + nicknames.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() + { + public boolean onPreferenceClick(Preference pref) + { + showNicknamesActivity(old_profile_name); + return true; + } + }); + Preference password = (Preference) findPreference("password"); + password.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() + { + public boolean onPreferenceClick(Preference pref) + { + setResult(Activity.RESULT_OK); + current_parameter = "setting_password"; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + DialogFragment enterPasswordDialogFragm = new EnterPasswordDialogFragm(); + enterPasswordDialogFragm.show(getFragmentManager(), "enter_password_dlg"); + } else { + final AlertDialog.Builder dialogBuilder; + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient_Light)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient)); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient_Light)); + } + } + LayoutInflater inflater = getLayoutInflater(); + final View dialogView = inflater.inflate(R.layout.enter_password_activity, null); + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + dialogView.setMinimumWidth(metrics.widthPixels); + dialogBuilder.setView(dialogView); + dialogBuilder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + EditText profile_name = (EditText) dialogView.findViewById(R.id.password_text); + onChangingValues(current_parameter, profile_name.getText().toString()); + } + }); + + dialogBuilder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + + } + }); + TextView dialog_title = (TextView) dialogView.findViewById(R.id.dialog_title); + dialog_title.setText(getString(R.string.enter_the_password_title)); + AlertDialog alertDialog = dialogBuilder.create(); + alertDialog.getWindow().setGravity(Gravity.BOTTOM); + alertDialog.show(); + Button dialogButton = null; + customizeDialogStyle(dialogButton, global_prefs, alertDialog); + } + return true; + } + }); + Preference server_settings = (Preference) findPreference("server_settings"); + server_settings.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() + { + public boolean onPreferenceClick(Preference pref) + { + setResult(Activity.RESULT_OK); + current_parameter = "setting_server"; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + DialogFragment serverSettingsDialogFragm = new ServerSettingsDialogFragm(); + serverSettingsDialogFragm.show(getFragmentManager(), "server_settings_dlg"); + } else { + final AlertDialog.Builder dialogBuilder; + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient_Light)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient)); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient_Light)); + } + } + LayoutInflater inflater = getLayoutInflater(); + final View dialogView = inflater.inflate(R.layout.enter_server_activity, null); + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + dialogView.setMinimumWidth(metrics.widthPixels); + dialogBuilder.setView(dialogView); + final Spinner encoding_spinner = (Spinner) dialogView.findViewById(R.id.encoding_spinner); + final EditText server_name = (EditText) dialogView.findViewById(R.id.server_text); + final EditText port_number = (EditText) dialogView.findViewById(R.id.port_numb); + final CheckBox hide_ip_cb = (CheckBox) dialogView.findViewById(R.id.hide_ip_checkbox); + final CheckBox force_ssl_cb = (CheckBox) dialogView.findViewById(R.id.force_ssl_checkbox); + dialogBuilder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + String[] encoding_array = getResources().getStringArray(R.array.encoding_array); + String encoding = new String(); + String force_ssl = new String(); + if(encoding_spinner.getSelectedItemPosition() == 0) { + encoding = "utf-8"; + } else if(encoding_spinner.getSelectedItemPosition() == 1) { + encoding = "cp866"; + } else if(encoding_spinner.getSelectedItemPosition() == 2) { + encoding = "windows-1251"; + } else if(encoding_spinner.getSelectedItemPosition() == 3) { + encoding = "koi8_r"; + } else if(encoding_spinner.getSelectedItemPosition() == 4) { + encoding = "koi8_u"; + }; + String hide_ip = new String(); + if(hide_ip_cb.isChecked() == true) { + hide_ip = "Enabled"; + } else { + hide_ip = "Disabled"; + } + if(force_ssl_cb.isChecked() == true) { + force_ssl = "Enabled"; + } else { + force_ssl = "Disabled"; + } + onSettingServer(server_name.getText().toString(), + port_number.getText().toString(), encoding, hide_ip, force_ssl); + } + }); + dialogBuilder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + + } + }); + + String[] encoding_array = getResources().getStringArray(R.array.encoding_array); + String server_parameter = new String(); + String current_value = new String(); + server_parameter = "changing_server"; + current_value = getCurrentValue(server_parameter); + final EditText server_text = (EditText) dialogView.findViewById(R.id.server_text); + server_text.setText(current_value); + server_parameter = "changing_port"; + current_value = getCurrentValue(server_parameter); + EditText port_numb = (EditText) dialogView.findViewById(R.id.port_numb); + port_numb.setText(current_value); + server_parameter = "changing_encoding"; + current_value = getCurrentValue(server_parameter); + if(current_value.contains("utf-8")) { + encoding_spinner.setSelection(0); + } else if(current_value.contains("cp866")) { + encoding_spinner.setSelection(1); + } else if(current_value.contains("windows-1251")) { + encoding_spinner.setSelection(2); + } else if(current_value.contains("koi8_r")) { + encoding_spinner.setSelection(3); + } else if(current_value.contains("koi8_u")) { + encoding_spinner.setSelection(4); + } + + server_parameter = "hide_ip"; + current_value = getCurrentValue(server_parameter); + if(current_value.contains("Disabled")) { + hide_ip_cb.setChecked(false); + } else { + hide_ip_cb.setChecked(true); + } + + server_parameter = "force_ssl"; + current_value = getCurrentValue(server_parameter); + if(current_value.contains("Disabled")) { + force_ssl_cb.setChecked(false); + } else { + force_ssl_cb.setChecked(true); + } + + customizeServerSettingsDialog(global_prefs, dialogView); + TextView dialog_title = (TextView) dialogView.findViewById(R.id.dialog_title); + dialog_title.setText(getString(R.string.server_settings)); + Spinner spinner = (Spinner) dialogView.findViewById(R.id.encoding_spinner); + + ArrayList spinnerArray = new ArrayList(); + spinnerArray.clear(); + for (int i = 0; i < 5; i++) { + spinnerArray.add(new CustomSpinnerItem(getResources().getStringArray(R.array.encoding_array)[i])); + } + CustomSpinnerAdapter customSpinnerAdapter = new CustomSpinnerAdapter(dialogView.getContext(), spinnerArray); + spinner.setAdapter(customSpinnerAdapter); + final AlertDialog alertDialog = dialogBuilder.create(); + server_text.addTextChangedListener(new TextWatcher() { + + public void afterTextChanged(Editable s) { } + + public void beforeTextChanged(CharSequence s, int start, int count, int after) {} + + public void onTextChanged(CharSequence s, int start, int before, int count) { + if(server_text.getText().toString().contains(":")) { + server_text.setError(getResources().getString(R.string.text_field_wrong_characters)); + ((AlertDialog) alertDialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); + } else { + ((AlertDialog) alertDialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); + } + } + }); + alertDialog.getWindow().setGravity(Gravity.BOTTOM); + alertDialog.show(); + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + server_name.setTextColor(getResources().getColor(R.color.black)); + port_number.setTextColor(getResources().getColor(R.color.black)); + } else { + server_name.setTextColor(getResources().getColor(R.color.white)); + port_number.setTextColor(getResources().getColor(R.color.white)); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + server_name.setTextColor(getResources().getColor(R.color.white)); + port_number.setTextColor(getResources().getColor(R.color.white)); + } else { + server_name.setTextColor(getResources().getColor(R.color.black)); + port_number.setTextColor(getResources().getColor(R.color.black)); + } + } + if(getResources().getDisplayMetrics().density == 0.75) { + server_name.setPadding(6, 0, 6, 0); + port_number.setPadding(6, 0, 6, 0); + } else { + server_name.setPadding(12, 0, 12, 0); + port_number.setPadding(12, 0, 12, 0); + } + Button dialogButton = null; + customizeDialogStyle(dialogButton, global_prefs, alertDialog); + } + return true; + } + }); + Preference realname = (Preference) findPreference("realname"); + realname.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() + { + public boolean onPreferenceClick(Preference pref) + { + setResult(Activity.RESULT_OK); + current_parameter = "changing_realname"; + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + realname_string = prefs.getString("realname", ""); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + DialogFragment enterTextDialogFragm = new EnterTextDialogFragm2(); + enterTextDialogFragm.show(getFragmentManager(), "enter_text_dlg"); + } else { + final AlertDialog.Builder dialogBuilder; + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient_Light)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient)); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient_Light)); + } + } + LayoutInflater inflater = getLayoutInflater(); + final View dialogView = inflater.inflate(R.layout.enter_text_activity, null); + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + dialogView.setMinimumWidth(metrics.widthPixels); + dialogBuilder.setView(dialogView); + dialogBuilder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + EditText profile_name = (EditText) dialogView.findViewById(R.id.profile_name_text); + onChangingValues(current_parameter, profile_name.getText().toString()); + } + }); + dialogBuilder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + + } + }); + TextView textAreaTitle = (TextView) dialogView.findViewById(R.id.profile_name_label); + TextView dialog_title = (TextView) dialogView.findViewById(R.id.dialog_title); + EditText dialog_value = (EditText) dialogView.findViewById(R.id.profile_name_text); + dialog_value.setText(realname_string); + dialog_title.setText(getString(R.string.enter_the_realname_title)); + AlertDialog alertDialog = dialogBuilder.create(); + alertDialog.getWindow().setGravity(Gravity.BOTTOM); + alertDialog.show(); + Button dialogButton = null; + customizeDialogStyle(dialogButton, global_prefs, alertDialog); + } + return true; + } + }); + Preference hostname = (Preference) findPreference("hostname"); + hostname.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() + { + public boolean onPreferenceClick(Preference pref) + { + setResult(Activity.RESULT_OK); + current_parameter = "changing_hostname"; + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + hostname_string = prefs.getString("hostname", ""); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + DialogFragment enterTextDialogFragm = new EnterTextDialogFragm2(); + enterTextDialogFragm.show(getFragmentManager(), "enter_text_dlg"); + } else { + final AlertDialog.Builder dialogBuilder; + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient_Light)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient)); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient_Light)); + } + } + LayoutInflater inflater = getLayoutInflater(); + final View dialogView = inflater.inflate(R.layout.enter_text_activity, null); + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + dialogView.setMinimumWidth(metrics.widthPixels); + dialogBuilder.setView(dialogView); + dialogBuilder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + EditText profile_name = (EditText) dialogView.findViewById(R.id.profile_name_text); + onChangingValues(current_parameter, profile_name.getText().toString()); + } + }); + dialogBuilder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + + } + }); + TextView textAreaTitle = (TextView) dialogView.findViewById(R.id.profile_name_label); + textAreaTitle.setText(R.string.hostname); + TextView dialog_title = (TextView) dialogView.findViewById(R.id.dialog_title); + dialog_title.setText(getString(R.string.enter_the_hostname_title)); + EditText dialog_value = (EditText) dialogView.findViewById(R.id.profile_name_text); + dialog_value.setText(hostname_string); + AlertDialog alertDialog = dialogBuilder.create(); + alertDialog.getWindow().setGravity(Gravity.BOTTOM); + alertDialog.show(); + Button dialogButton = null; + customizeDialogStyle(dialogButton, global_prefs, alertDialog); + } + return true; + } + }); + Preference quit_msg = (Preference) findPreference("quit_message"); + quit_msg.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() + { + public boolean onPreferenceClick(Preference pref) + { + setResult(Activity.RESULT_OK); + current_parameter = "changing_quitmsg"; + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + quitmsg_string = prefs.getString("quit_message", ""); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + DialogFragment enterTextDialogFragm = new EnterTextDialogFragm2(); + enterTextDialogFragm.show(getFragmentManager(), "enter_text_dlg"); + } else { + final AlertDialog.Builder dialogBuilder; + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient_Light)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient)); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient)); + } else { + dialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(ProfileSettingsActivity.this, R.style.IRCClient_Light)); + } + } + LayoutInflater inflater = getLayoutInflater(); + final View dialogView = inflater.inflate(R.layout.enter_text_activity, null); + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + dialogView.setMinimumWidth(metrics.widthPixels); + dialogBuilder.setView(dialogView); + dialogBuilder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + EditText profile_name = (EditText) dialogView.findViewById(R.id.profile_name_text); + onChangingValues(current_parameter, profile_name.getText().toString()); + } + }); + dialogBuilder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + + } + }); + TextView textAreaTitle = (TextView) dialogView.findViewById(R.id.profile_name_label); + textAreaTitle.setText(R.string.quit_message); + TextView dialog_title = (TextView) dialogView.findViewById(R.id.dialog_title); + dialog_title.setText(getString(R.string.enter_the_quiting_message)); + EditText dialog_value = (EditText) dialogView.findViewById(R.id.profile_name_text); + dialog_value.setText(quitmsg_string); + AlertDialog alertDialog = dialogBuilder.create(); + alertDialog.getWindow().setGravity(Gravity.BOTTOM); + alertDialog.show(); + Button dialogButton = null; + customizeDialogStyle(dialogButton, global_prefs, alertDialog); + } + return true; + } + }); + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + auth_method_string = prefs.getString("auth_method", ""); + if(auth_method_string.contains("NickServ")) { + auth_method.setSummary("NickServ"); + password.setEnabled(true); + } else { + String[] auth_methods = getResources().getStringArray(R.array.auth_method); + auth_method.setSummary(auth_methods[0]); + password.setEnabled(false); + }; + server_name = prefs.getString("server", ""); + server_port = prefs.getInt("port", 0); + if(server_name.length() > 0 && server_port > 0) { + server_settings.setSummary(server_name + ":" + Integer.toString(server_port)); + }; + realname_string = prefs.getString("realname", ""); + hostname_string = prefs.getString("hostname", ""); + quitmsg_string = prefs.getString("quit_message", ""); + realname.setSummary(realname_string); + hostname.setSummary(hostname_string); + quit_msg.setSummary(quitmsg_string); + } + + private void customizeServerSettingsDialog(SharedPreferences global_prefs, View dialogView) { + EditText server_name = (EditText) dialogView.findViewById(R.id.server_text); + EditText port_edit = (EditText) dialogView.findViewById(R.id.port_numb); + Spinner spinner = (Spinner) dialogView.findViewById(R.id.encoding_spinner); + + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + server_name.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_textarea_light)); + server_name.setTextColor(getResources().getColor(R.color.black)); + server_name.setTextAppearance(ProfileSettingsActivity.this, R.style.IRCClient_Light_TextArea); + } else { + server_name.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_textarea)); + server_name.setTextColor(getResources().getColor(R.color.white)); + server_name.setTextAppearance(ProfileSettingsActivity.this, R.style.IRCClient_TextArea); + } + } else { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + server_name.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_textarea)); + server_name.setTextColor(getResources().getColor(R.color.white)); + server_name.setTextAppearance(ProfileSettingsActivity.this, R.style.IRCClient_TextArea); + } else { + server_name.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_textarea_light)); + server_name.setTextColor(getResources().getColor(R.color.black)); + server_name.setTextAppearance(ProfileSettingsActivity.this, R.style.IRCClient_Light_TextArea); + } + } + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + port_edit.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_textarea_light)); + port_edit.setTextColor(getResources().getColor(R.color.black)); + port_edit.setTextAppearance(ProfileSettingsActivity.this, R.style.IRCClient_Light_TextArea); + } else { + port_edit.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_textarea)); + port_edit.setTextColor(getResources().getColor(R.color.white)); + port_edit.setTextAppearance(ProfileSettingsActivity.this, R.style.IRCClient_TextArea); + } + } else { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + port_edit.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_textarea)); + port_edit.setTextColor(getResources().getColor(R.color.white)); + port_edit.setTextAppearance(ProfileSettingsActivity.this, R.style.IRCClient_TextArea); + } else { + port_edit.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_textarea_light)); + port_edit.setTextColor(getResources().getColor(R.color.black)); + port_edit.setTextAppearance(ProfileSettingsActivity.this, R.style.IRCClient_Light_TextArea); + } + } + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + spinner.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_spinner_light)); + } else { + spinner.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_spinner)); + } + } else { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + spinner.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_spinner)); + } else { + spinner.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_spinner_light)); + } + } + } + + private void setCustomTheme(SharedPreferences global_prefs) { + if(global_prefs.getString("language", "OS dependent").contains("Russian")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } + } else if (global_prefs.getString("language", "OS dependent").contains("English")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } + } + if (global_prefs.getString("theme", "Light").contains("Light")) { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + setTheme(R.style.IRCClient_Light); + } else { + setTheme(R.style.IRCClient); + } + } else { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + setTheme(R.style.IRCClient); + } else { + setTheme(R.style.IRCClient_Light); + } + } + } + + private void customizeDialogStyle(Button dialogButton, SharedPreferences global_prefs, AlertDialog alertDialog) { + if(global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } else { + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } else { + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } + } + } + + private void showNicknamesActivity(String profile_name) { + Intent intent = new Intent(this, CustomNicknamesActivity.class); + intent.putExtra("profile_name", profile_name); + startActivity(intent); + } + + public void onChangingValues(String parameter, String value) { + Preference prof_name = (Preference) findPreference("prof_name"); + Preference nicknames = (Preference) findPreference("nicknames"); + if (parameter == "changing_profile_name") { + Context context = getApplicationContext(); + String profile_path = "/data/data/" + package_name + "/shared_prefs/" + old_profile_name + ".xml"; + File file = new File(profile_path); + file.delete(); + SharedPreferences prefs = context.getSharedPreferences(value, 0); + SharedPreferences.Editor editor = prefs.edit(); + editor.putString("name", value); + editor.commit(); + old_profile_name = value; + prof_name.setSummary(old_profile_name); + } else if(parameter == "changing_auth_method") { + Preference auth_method = (Preference) findPreference("auth_method"); + Preference password = (Preference) findPreference("password"); + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + SharedPreferences.Editor editor = prefs.edit(); + String[] auth_methods = getResources().getStringArray(R.array.auth_method); + editor.putString("auth_method", value); + if(value == "Disabled") { + auth_method.setSummary(auth_methods[0]); + password.setEnabled(false); + } else { + auth_method.setSummary(value); + password.setEnabled(true); + } + editor.commit(); + } else if (parameter == "changing_nicknames") { + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + SharedPreferences.Editor editor = prefs.edit(); + editor.putString("nicknames", value); + editor.commit(); + nicknames.setSummary(value); + } else if (parameter == "setting_password") { + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + SharedPreferences.Editor editor = prefs.edit(); + editor.putString("password", value); + editor.commit(); + } else if (parameter == "changing_realname") { + Preference realname = (Preference) findPreference("realname"); + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + SharedPreferences.Editor editor = prefs.edit(); + editor.putString("realname", value); + editor.commit(); + realname.setSummary(value); + } else if (parameter == "changing_hostname") { + Preference hostname = (Preference) findPreference("hostname"); + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + SharedPreferences.Editor editor = prefs.edit(); + editor.putString("hostname", value); + editor.commit(); + hostname.setSummary(value); + } else if (parameter == "changing_quitmsg") { + Preference quit_msg = (Preference) findPreference("quit_message"); + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + SharedPreferences.Editor editor = prefs.edit(); + editor.putString("quit_message", value); + editor.commit(); + quit_msg.setSummary(value); + } + } + + public String getCurrentParameter() { + return current_parameter; + } + + public String getCurrentValue(String parameter) { + String value; + if(parameter == "changing_profile_name") { + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + value = old_profile_name; + } else if(parameter == "changing_auth_method") { + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + value = prefs.getString("auth_method", ""); + } else if(parameter == "changing_realname") { + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + value = prefs.getString("realname", ""); + } else if(parameter == "changing_hostname") { + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + value = prefs.getString("hostname", ""); + } else if(parameter == "changing_server") { + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + value = prefs.getString("server", ""); + } else if(parameter == "changing_port") { + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + value = "" + prefs.getInt("port", 0); + } else if(parameter == "changing_encoding") { + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + value = prefs.getString("encoding", ""); + } else if(parameter == "hide_ip") { + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + value = prefs.getString("hide_ip", ""); + } else if(parameter == "force_ssl") { + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + value = prefs.getString("force_ssl", ""); + } else if(parameter == "changing_quitmsg") { + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + value = prefs.getString("quit_message", ""); + } else { + value = ""; + }; + return value; + } + + public void onSettingServer(String server, String port, String encoding, String hide_ip, String force_ssl) { + Preference server_settings = (Preference) findPreference("server_settings"); + Context context = getApplicationContext(); + SharedPreferences prefs = context.getSharedPreferences(old_profile_name, 0); + SharedPreferences.Editor editor = prefs.edit(); + editor.putString("server", server); + editor.putInt("port", Integer.parseInt(port)); + if(server.length() > 0 && port.length() > 0) { + server_settings.setSummary(server + ":" + port); + } + editor.putString("encoding", encoding); + editor.putString("hide_ip", hide_ip); + editor.putString("force_ssl", force_ssl); + editor.commit(); + } + + public void setColorStyle(SharedPreferences global_prefs) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + getListView().setBackgroundColor(getResources().getColor(R.color.white)); + getListView().setCacheColorHint(getResources().getColor(R.color.white)); + } else { + getListView().setBackgroundColor(getResources().getColor(R.color.black)); + getListView().setCacheColorHint(getResources().getColor(R.color.black)); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + getListView().setBackgroundColor(getResources().getColor(R.color.black)); + getListView().setCacheColorHint(getResources().getColor(R.color.black)); + } else { + getListView().setBackgroundColor(getResources().getColor(R.color.white)); + getListView().setCacheColorHint(getResources().getColor(R.color.white)); + } + } + } + } + + + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) { + if(id == android.R.id.home) { + onBackPressed(); + } + } + return super.onOptionsItemSelected(item); + } +} \ No newline at end of file diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/ServerSettingsDialogFragm.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/ServerSettingsDialogFragm.java new file mode 100644 index 0000000..654ea60 --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/ServerSettingsDialogFragm.java @@ -0,0 +1,196 @@ +package dev.tinelix.irc.android.legacy; + +import android.annotation.SuppressLint; +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.DialogFragment; +import android.content.Context; +import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.graphics.Color; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.text.Editable; +import android.text.Html; +import android.text.SpannableStringBuilder; +import android.text.TextWatcher; +import android.text.method.KeyListener; +import android.text.style.ForegroundColorSpan; +import android.util.Log; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.ArrayAdapter; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.Spinner; +import android.widget.TextView; + +import java.util.Locale; + +@SuppressLint("NewApi") +public class ServerSettingsDialogFragm extends DialogFragment { + + public String current_parameter; + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + setLocale(global_prefs); + current_parameter = ((ProfileSettingsActivity) getActivity()).getCurrentParameter(); + String current_value; + String server_parameter; + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + if(current_parameter == "setting_server") { + LayoutInflater inflater = getActivity().getLayoutInflater(); + final View view = inflater.inflate(R.layout.enter_server_activity, null); + final Spinner encoding_spinner = (Spinner) view.findViewById(R.id.encoding_spinner); + Context context = view.getContext(); + ArrayAdapter adapter = + ArrayAdapter.createFromResource(context, R.array.encoding_array, + android.R.layout.simple_spinner_item); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + encoding_spinner.setAdapter(adapter); + builder.setView(view); + builder.setTitle(R.string.server_settings); + builder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + EditText server_name = (EditText) view.findViewById(R.id.server_text); + EditText port_number = (EditText) view.findViewById(R.id.port_numb); + CheckBox hide_ip_cb = (CheckBox) view.findViewById(R.id.hide_ip_checkbox); + CheckBox force_ssl_cb = (CheckBox) view.findViewById(R.id.force_ssl_checkbox); + String[] encoding_array = getResources().getStringArray(R.array.encoding_array); + String encoding = new String(); + String force_ssl = new String(); + if(encoding_spinner.getSelectedItemPosition() == 0) { + encoding = "utf-8"; + } else if(encoding_spinner.getSelectedItemPosition() == 1) { + encoding = "cp866"; + } else if(encoding_spinner.getSelectedItemPosition() == 2) { + encoding = "windows-1251"; + } else if(encoding_spinner.getSelectedItemPosition() == 3) { + encoding = "koi8_r"; + } else if(encoding_spinner.getSelectedItemPosition() == 4) { + encoding = "koi8_u"; + }; + String hide_ip = new String(); + if(hide_ip_cb.isChecked() == true) { + hide_ip = "Enabled"; + } else { + hide_ip = "Disabled"; + } + if(force_ssl_cb.isChecked() == true) { + force_ssl = "Enabled"; + } else { + force_ssl = "Disabled"; + } + ((ProfileSettingsActivity) getActivity()).onSettingServer(server_name.getText().toString(), + port_number.getText().toString(), encoding, hide_ip, force_ssl); + } + }); + builder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + return; + } + }); + String[] encoding_array = getResources().getStringArray(R.array.encoding_array); + server_parameter = "changing_server"; + current_value = ((ProfileSettingsActivity) getActivity()).getCurrentValue(server_parameter); + final EditText server_text = (EditText) view.findViewById(R.id.server_text); + server_text.setText(current_value); + server_text.addTextChangedListener(new TextWatcher() { + + public void afterTextChanged(Editable s) { } + + public void beforeTextChanged(CharSequence s, int start, int count, int after) {} + + public void onTextChanged(CharSequence s, int start, int before, int count) { + if(s.toString().contains(":")) { + server_text.setError(getResources().getString(R.string.text_field_wrong_characters)); + ((AlertDialog) getDialog()).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); + } else { + ((AlertDialog) getDialog()).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); + } + } + }); + server_parameter = "changing_port"; + current_value = ((ProfileSettingsActivity) getActivity()).getCurrentValue(server_parameter); + EditText port_numb = (EditText) view.findViewById(R.id.port_numb); + port_numb.setText(current_value); + ArrayAdapter encoding_adapter = + ArrayAdapter.createFromResource(view.getContext(), R.array.encoding_array, + android.R.layout.simple_spinner_item); + encoding_spinner.setAdapter(encoding_adapter); + server_parameter = "changing_encoding"; + current_value = ((ProfileSettingsActivity) getActivity()).getCurrentValue(server_parameter); + if(current_value.contains("utf-8")) { + encoding_spinner.setSelection(0); + } else if(current_value.contains("cp866")) { + encoding_spinner.setSelection(1); + } else if(current_value.contains("windows-1251")) { + encoding_spinner.setSelection(2); + } else if(current_value.contains("koi8_r")) { + encoding_spinner.setSelection(3); + } else if(current_value.contains("koi8_u")) { + encoding_spinner.setSelection(4); + } + server_parameter = "hide_ip"; + current_value = ((ProfileSettingsActivity) getActivity()).getCurrentValue(server_parameter); + CheckBox hide_ip_cb = (CheckBox) view.findViewById(R.id.hide_ip_checkbox); + if(current_value.contains("Disabled")) { + hide_ip_cb.setChecked(false); + } else { + hide_ip_cb.setChecked(true); + } + + server_parameter = "force_ssl"; + current_value = ((ProfileSettingsActivity) getActivity()).getCurrentValue(server_parameter); + CheckBox force_ssl_cb = (CheckBox) view.findViewById(R.id.force_ssl_checkbox); + if(current_value.contains("Disabled")) { + force_ssl_cb.setChecked(false); + } else { + force_ssl_cb.setChecked(true); + } + }; + return builder.create(); + } + + private void setLocale(SharedPreferences global_prefs) { + if(global_prefs.getString("language", "OS dependent").contains("Russian")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } + } else if (global_prefs.getString("language", "OS dependent").contains("English")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } + } + } +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/SetFontSizeDialogFragm.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/SetFontSizeDialogFragm.java new file mode 100644 index 0000000..3682b55 --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/SetFontSizeDialogFragm.java @@ -0,0 +1,138 @@ +package dev.tinelix.irc.android.legacy; + +import android.annotation.SuppressLint; +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.DialogFragment; +import android.content.Context; +import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.os.Build; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.util.Log; +import android.util.TypedValue; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.EditText; +import android.widget.SeekBar; +import android.widget.TextView; + +import java.util.Locale; + +@SuppressLint("NewApi") +public class SetFontSizeDialogFragm extends DialogFragment { + public String current_parameter; + + public Dialog onCreateDialog(Bundle savedInstanceState) { + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + setLocale(global_prefs); + current_parameter = ((MainSettingsActivity) getActivity()).getCurrentParameter(); + String current_value; + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + if(current_parameter == "setting_fontsize") { + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + LayoutInflater inflater = getActivity().getLayoutInflater(); + final View view = inflater.inflate(R.layout.set_font_size_activity, null); + final SeekBar font_size_seekbar = (SeekBar) view.findViewById(R.id.font_size_seekbar); + final EditText preview_text = (EditText) view.findViewById(R.id.preview_text); + final TextView value_label = (TextView) view.findViewById(R.id.value_label); + if(global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + preview_text.setTextColor(getResources().getColor(R.color.black)); + } else { + preview_text.setTextColor(getResources().getColor(R.color.white)); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + preview_text.setTextColor(getResources().getColor(R.color.white)); + } else { + preview_text.setTextColor(getResources().getColor(R.color.black)); + } + } + builder.setView(view); + builder.setTitle(R.string.changing_font_label); + builder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + SharedPreferences.Editor editor = prefs.edit(); + editor.putInt("font_size", font_size_seekbar.getProgress() + 12); + editor.commit(); + } + }); + builder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + return; + } + }); + preview_text.setKeyListener(null); + font_size_seekbar.setMax((60 - 12) / 1); + font_size_seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int i, boolean b) { + preview_text.setTextSize(TypedValue.COMPLEX_UNIT_SP, i + 12); + value_label.setText(getString(R.string.value_in_px, i + 12)); + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + + } + }); + if(prefs.getInt("font_size", 0) < 12) { + float text_size_in_sp = (int) preview_text.getTextSize() / getResources().getDisplayMetrics().scaledDensity; + font_size_seekbar.setProgress((int) text_size_in_sp - 12); + value_label.setText(getString(R.string.value_in_px, (int)text_size_in_sp)); + preview_text.setTextSize(TypedValue.COMPLEX_UNIT_SP, text_size_in_sp); + } else { + font_size_seekbar.setProgress(prefs.getInt("font_size", 0) - 12); + value_label.setText(getString(R.string.value_in_px, prefs.getInt("font_size", 0))); + preview_text.setTextSize(TypedValue.COMPLEX_UNIT_SP, prefs.getInt("font_size", 0)); + } + }; + return builder.create(); + } + + private void setLocale(SharedPreferences global_prefs) { + if(global_prefs.getString("language", "OS dependent").contains("Russian")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } + } else if (global_prefs.getString("language", "OS dependent").contains("English")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } + } + } +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/SettingsItemsDialogFragm.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/SettingsItemsDialogFragm.java new file mode 100644 index 0000000..6dfbe12 --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/SettingsItemsDialogFragm.java @@ -0,0 +1,203 @@ +package dev.tinelix.irc.android.legacy; + +import android.annotation.SuppressLint; +import android.app.AlarmManager; +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.DialogFragment; +import android.app.PendingIntent; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.os.Build; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.view.ContextThemeWrapper; +import android.widget.Toast; + +import java.util.Locale; + +@SuppressLint("NewApi") +public class SettingsItemsDialogFragm extends DialogFragment { + public String current_parameter; + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + current_parameter = ((MainSettingsActivity) getActivity()).getCurrentParameter(); + final String current_value; + final String[] value = new String[1]; + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + if(current_parameter == "setting_language") { + current_value = ((MainSettingsActivity) getActivity()).getCurrentValue(current_parameter); + final String[] languages = getResources().getStringArray(R.array.ui_language); + builder.setTitle(R.string.interface_language_item); + if(current_value.contains("OS dependent")) { + builder.setSingleChoiceItems(languages, 0, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int item) { + if(item == 0) { + value[0] = "OS dependent"; + } else if(item == 1) { + value[0] = "English"; + } else { + value[0] = "Russian"; + } + } + }); + } else if(current_value.contains("English")) { + builder.setSingleChoiceItems(languages, 1, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int item) { + if(item == 0) { + value[0] = "OS dependent"; + } else if(item == 1) { + value[0] = "English"; + } else { + value[0] = "Russian"; + } + } + }); + } else { + builder.setSingleChoiceItems(languages, 2, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int item) { + if(item == 0) { + value[0] = "OS dependent"; + } else if(item == 1) { + value[0] = "English"; + } else { + value[0] = "Russian"; + } + } + }); + } + builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + ((MainSettingsActivity) getActivity()).onChangingValues(current_parameter, value[0]); + SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + final String[] requires_reboot_app = getResources().getStringArray(R.array.ui_language_app_restart_toast); + if(global_prefs.getBoolean("connected", false) == false) { + Intent mainActivity = new Intent(getActivity(), this.getClass()); + int pendingIntentId = 1; + PendingIntent pendingIntent; + pendingIntent = PendingIntent.getActivity(getActivity(), pendingIntentId, mainActivity, PendingIntent.FLAG_CANCEL_CURRENT); + AlarmManager mgr = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE); + mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, pendingIntent); + System.exit(0); + } else { + if(current_value.contains("Russian")) { + Toast.makeText(getActivity(), requires_reboot_app[1], Toast.LENGTH_LONG).show(); + } else { + Toast.makeText(getActivity(), requires_reboot_app[0], Toast.LENGTH_LONG).show(); + } + } + } + }); + builder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + } + }); + } else if(current_parameter == "setting_theme") { + current_value = ((MainSettingsActivity) getActivity()).getCurrentValue(current_parameter); + String[] themes = getResources().getStringArray(R.array.themes); + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + builder.setTitle(getString(R.string.interface_theme_item)); + if(current_value.contains("Dark")) { + builder.setSingleChoiceItems(themes, 0, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int item) { + if(item == 0) { + value[0] = "Dark"; + } else { + value[0] = "Light"; + } + } + }); + } else { + builder.setSingleChoiceItems(themes, 1, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int item) { + if(item == 0) { + value[0] = "Dark"; + } else { + value[0] = "Light"; + } + } + }); + } + builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + ((MainSettingsActivity) getActivity()).onChangingValues(current_parameter, value[0]); + SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + final String[] requires_reboot_app = getResources().getStringArray(R.array.ui_language_app_restart_toast); + if(global_prefs.getBoolean("connected", false) == false) { + Intent mainActivity = new Intent(getActivity(), this.getClass()); + int pendingIntentId = 1; + PendingIntent pendingIntent; + pendingIntent = PendingIntent.getActivity(getActivity(), pendingIntentId, mainActivity, PendingIntent.FLAG_CANCEL_CURRENT); + AlarmManager mgr = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE); + mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, pendingIntent); + System.exit(0); + } else { + if(current_value.contains("Russian")) { + Toast.makeText(getActivity(), requires_reboot_app[0], Toast.LENGTH_LONG).show(); + } else { + Toast.makeText(getActivity(), requires_reboot_app[1], Toast.LENGTH_LONG).show(); + } + } + } + }); + builder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + } + }); + } + return builder.create(); + } + + private void setLocale(SharedPreferences global_prefs) { + if(global_prefs.getString("language", "OS dependent").contains("Russian")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } + } else if (global_prefs.getString("language", "OS dependent").contains("English")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } + } + } +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/StatisticsFragm.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/StatisticsFragm.java new file mode 100644 index 0000000..5a15e5f --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/StatisticsFragm.java @@ -0,0 +1,207 @@ +package dev.tinelix.irc.android.legacy; + +import android.annotation.SuppressLint; +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.DialogFragment; +import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.os.Build; +import android.os.Bundle; +import android.os.Handler; +import android.preference.PreferenceManager; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.EditText; +import android.widget.TextView; + +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.util.Locale; +import java.util.Timer; +import java.util.TimerTask; + +@SuppressLint("NewApi") +public class StatisticsFragm extends DialogFragment { + public int sended_bytes; + public int received_bytes; + public int total_bytes; + public Timer statsTimer; + public TextView sended_bytes_label; + public TextView received_bytes_label; + public TextView total_bytes_label; + public View view; + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + setLocale(global_prefs); + sended_bytes = ((ThreadActivity) getActivity()).getSendedBytes(); + received_bytes = ((ThreadActivity) getActivity()).getReceivedBytes(); + total_bytes = sended_bytes + received_bytes; + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + builder.setTitle(R.string.statistics_item); + LayoutInflater inflater = getActivity().getLayoutInflater(); + view = inflater.inflate(R.layout.statistics_activity, null); + builder.setView(view); + sended_bytes_label = (TextView) view.findViewById(R.id.sended_label2); + received_bytes_label = (TextView) view.findViewById(R.id.received_label2); + total_bytes_label = (TextView) view.findViewById(R.id.total_label2); + TextView session_label = (TextView) view.findViewById(R.id.session_label); + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + session_label.setTextColor(getResources().getColor(R.color.black)); + } else { + session_label.setTextColor(getResources().getColor(R.color.white)); + } + } else { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + session_label.setTextColor(getResources().getColor(R.color.white)); + } else { + session_label.setTextColor(getResources().getColor(R.color.black)); + } + } + DecimalFormat dF = new DecimalFormat("#.##"); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { + dF.setRoundingMode(RoundingMode.DOWN); + } + if (sended_bytes > 1073741824) { + String sended_bytes_rounded = dF.format((float)(sended_bytes / 1073741824)); + sended_bytes_label.setText(getString(R.string.gbytes_stats, sended_bytes_rounded)); + } else if(sended_bytes > 1048576) { + String sended_bytes_rounded = dF.format((float)(sended_bytes / 1048576)); + sended_bytes_label.setText(getString(R.string.mbytes_stats, sended_bytes_rounded)); + } else if(sended_bytes > 1024) { + String sended_bytes_rounded = dF.format((float)(sended_bytes / 1024)); + sended_bytes_label.setText(getString(R.string.kbytes_stats, sended_bytes_rounded)); + } else { + sended_bytes_label.setText(getString(R.string.bytes_stats, Integer.toString(sended_bytes))); + } + if (received_bytes > 1073741824) { + String received_bytes_rounded = dF.format((float)(received_bytes / 1073741824)); + received_bytes_label.setText(getString(R.string.gbytes_stats, received_bytes_rounded)); + } else if(received_bytes > 1048576) { + String received_bytes_rounded = dF.format((float)(received_bytes / 1048576)); + received_bytes_label.setText(getString(R.string.mbytes_stats, received_bytes_rounded)); + } else if(received_bytes > 1024) { + String received_bytes_rounded = dF.format((float)(received_bytes / 1024)); + received_bytes_label.setText(getString(R.string.kbytes_stats, received_bytes_rounded)); + } else { + received_bytes_label.setText(getString(R.string.bytes_stats, Integer.toString(received_bytes))); + } + if (total_bytes > 1073741824) { + String total_bytes_rounded = dF.format((float)(total_bytes / 1073741824)); + total_bytes_label.setText(getString(R.string.gbytes_stats, total_bytes_rounded)); + } else if(total_bytes > 1048576) { + String total_bytes_rounded = dF.format((float)(total_bytes / 1048576)); + total_bytes_label.setText(getString(R.string.mbytes_stats, total_bytes_rounded)); + } else if(total_bytes > 1024) { + String total_bytes_rounded = dF.format((float)(total_bytes / 1024)); + total_bytes_label.setText(getString(R.string.kbytes_stats, total_bytes_rounded)); + } else { + total_bytes_label.setText(getString(R.string.bytes_stats, Integer.toString(total_bytes))); + } + final Handler updateHandler = new Handler(); + statsTimer = new Timer(); + statsTimer.schedule(new TimerTask() { + @Override + public void run() { + sended_bytes = ((ThreadActivity) getActivity()).getSendedBytes(); + received_bytes = ((ThreadActivity) getActivity()).getReceivedBytes(); + total_bytes = sended_bytes + received_bytes; + updateHandler.post(new Runnable() { + @Override + public void run() { + DecimalFormat dF = new DecimalFormat("#.##"); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { + dF.setRoundingMode(RoundingMode.DOWN); + } + if (sended_bytes > 1073741824) { + String sended_bytes_rounded = dF.format((float)(sended_bytes / 1073741824)); + sended_bytes_label.setText(getString(R.string.gbytes_stats, sended_bytes_rounded)); + } else if(sended_bytes > 1048576) { + String sended_bytes_rounded = dF.format((float)(sended_bytes / 1048576)); + sended_bytes_label.setText(getString(R.string.mbytes_stats, sended_bytes_rounded)); + } else if(sended_bytes > 1024) { + String sended_bytes_rounded = dF.format((float)(sended_bytes / 1024)); + sended_bytes_label.setText(getString(R.string.kbytes_stats, sended_bytes_rounded)); + } else { + sended_bytes_label.setText(getString(R.string.bytes_stats, Integer.toString(sended_bytes))); + } + if (received_bytes > 1073741824) { + String received_bytes_rounded = dF.format((float)(received_bytes / 1073741824)); + received_bytes_label.setText(getString(R.string.gbytes_stats, received_bytes_rounded)); + } else if(received_bytes > 1048576) { + String received_bytes_rounded = dF.format((float)(received_bytes / 1048576)); + received_bytes_label.setText(getString(R.string.mbytes_stats, received_bytes_rounded)); + } else if(received_bytes > 1024) { + String received_bytes_rounded = dF.format((float)(received_bytes / 1024)); + received_bytes_label.setText(getString(R.string.kbytes_stats, received_bytes_rounded)); + } else { + received_bytes_label.setText(getString(R.string.bytes_stats, Integer.toString(received_bytes))); + } + if (total_bytes > 1073741824) { + String total_bytes_rounded = dF.format((float)(total_bytes / 1073741824)); + total_bytes_label.setText(getString(R.string.gbytes_stats, total_bytes_rounded)); + } else if(total_bytes > 1048576) { + String total_bytes_rounded = dF.format((float)(total_bytes / 1048576)); + total_bytes_label.setText(getString(R.string.mbytes_stats, total_bytes_rounded)); + } else if(total_bytes > 1024) { + String total_bytes_rounded = dF.format((float)(total_bytes / 1024)); + total_bytes_label.setText(getString(R.string.kbytes_stats, total_bytes_rounded)); + } else { + total_bytes_label.setText(getString(R.string.bytes_stats, Integer.toString(total_bytes))); + } + } + }); + } + }, 1000, 1000); + builder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + statsTimer.cancel(); + statsTimer = null; + return; + } + }); + return builder.create(); + } + + private void setLocale(SharedPreferences global_prefs) { + if(global_prefs.getString("language", "OS dependent").contains("Russian")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } + } else if (global_prefs.getString("language", "OS dependent").contains("English")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getActivity().getResources().updateConfiguration(config, + getActivity().getResources().getDisplayMetrics()); + } + } + } + +} diff --git a/android/app/src/main/java/dev/tinelix/irc/android/legacy/ThreadActivity.java b/android/app/src/main/java/dev/tinelix/irc/android/legacy/ThreadActivity.java new file mode 100644 index 0000000..375b607 --- /dev/null +++ b/android/app/src/main/java/dev/tinelix/irc/android/legacy/ThreadActivity.java @@ -0,0 +1,1856 @@ +package dev.tinelix.irc.android.legacy; + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.app.ActivityManager; +import android.app.AlertDialog; +import android.app.DialogFragment; +import android.app.Notification; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.content.res.Configuration; +import android.graphics.Typeface; +import android.os.Build; +import android.os.Bundle; +import android.os.Environment; +import android.os.Handler;import android.preference.PreferenceManager; +import android.text.Editable; +import android.text.Html; +import android.text.InputType; +import android.text.method.KeyListener; +import android.util.DisplayMetrics; +import android.util.Log; +import android.util.TypedValue; +import android.view.ContextMenu; +import android.view.ContextThemeWrapper; +import android.view.Gravity; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowManager; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.FrameLayout; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RemoteViews; +import android.widget.Spinner; +import android.widget.TabHost; +import android.widget.TextView; +import android.widget.Toast; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.math.RoundingMode; +import java.net.ConnectException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.SocketAddress; +import java.net.SocketTimeoutException; +import java.net.UnknownHostException; +import java.nio.channels.IllegalBlockingModeException; +import java.security.KeyStore; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.Timer; +import java.util.TimerTask; +import java.util.zip.Inflater; + +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; + +import static java.lang.System.out; +import static java.lang.Thread.sleep; + +public class ThreadActivity extends Activity { + + public Socket socket; + public SSLSocket sslSocket; + public boolean isConnected; + public InputStream input; + public OutputStream output; + Handler updateConversationHandler; + public String profile_name; + public String server; + public String nicknames; + public String hostname; + public String realname; + public StringBuilder msg; + public int received_bytes; + public int sended_bytes; + public List channelsArray = new ArrayList(); + public List outputMsgArray = new ArrayList(); + public byte[] socket_data_bytes; + public int port; + private EditText socks_msg_text; + public EditText output_msg_text; + public byte[] socket_data = new byte[1<<12]; + public String socket_data_string; + public String raw_socket_data_string; + private Timer timer; + private UpdateUITask updateUITask; + public String state; + public String encoding; + public String channel; + public String current_channel; + public String password; + public String auth_method; + public String hide_ip; + public String quit_msg; + public String force_ssl; + public int sended_bytes_count; + public int received_bytes_count; + public String messageAuthor; + public String messageBody; + public boolean isMentioned; + public String sendingMsgText; + public AlertDialog connectionDialog; + public Date dt; + public boolean autoscroll_needed; + public Menu thread_menu; + public TabHost tabHost; + public List channels_sb = new LinkedList(); + + @SuppressLint("ClickableViewAccessibility") + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + setCustomTheme(global_prefs); + setContentView(R.layout.thread_activity); + setColorStyle(global_prefs); + dt = new Date(System.currentTimeMillis()); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + getActionBar().setHomeButtonEnabled(true); + } + channel = new String(); + current_channel = new String(); + for (int ch_index = 0; ch_index < 128; ch_index++) { + channels_sb.add(ch_index, new StringBuilder()); + } + autoscroll_needed = true; + socks_msg_text = (EditText) findViewById(R.id.sock_msg_text); + socks_msg_text.setKeyListener(null); + socks_msg_text.setLongClickable(true); + socks_msg_text.setTypeface(Typeface.MONOSPACE); + socks_msg_text.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + switch (motionEvent.getAction()) { + case MotionEvent.ACTION_SCROLL: + autoscroll_needed = false; + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + MenuItem go_down = thread_menu.findItem(R.id.go_down_item); + go_down.setVisible(true); + } else { + Button go_down_btn = (Button) findViewById(R.id.go_down_button); + go_down_btn.setVisibility(View.VISIBLE); + } + } + return false; + } + }); + socks_msg_text.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View view) { + autoscroll_needed = false; + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + MenuItem go_down = thread_menu.findItem(R.id.go_down_item); + go_down.setVisible(true); + } else { + Button go_down_btn = (Button) findViewById(R.id.go_down_button); + go_down_btn.setVisibility(View.VISIBLE); + } + Toast.makeText(getApplicationContext(), getResources().getString(R.string.autoscroll_is_disabled), Toast.LENGTH_LONG).show(); + return false; + } + }); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + socks_msg_text.setTextIsSelectable(true); + } + if(global_prefs.getInt("font_size", 0) >= 12) { + socks_msg_text.setTextSize(TypedValue.COMPLEX_UNIT_SP, global_prefs.getInt("font_size", 0)); + } + EditText channel_socks_msg = (EditText) findViewById(R.id.channels_msg_text); + channel_socks_msg.setKeyListener(null); + channel_socks_msg.setLongClickable(true); + channel_socks_msg.setTypeface(Typeface.MONOSPACE); + channel_socks_msg.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + switch (motionEvent.getAction()) { + case MotionEvent.ACTION_SCROLL: + autoscroll_needed = false; + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + MenuItem go_down = thread_menu.findItem(R.id.go_down_item); + go_down.setVisible(true); + } else { + Button go_down_btn = (Button) findViewById(R.id.go_down_button); + go_down_btn.setVisibility(View.VISIBLE); + } + } + return false; + } + }); + channel_socks_msg.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View view) { + autoscroll_needed = false; + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + MenuItem go_down = thread_menu.findItem(R.id.go_down_item); + go_down.setVisible(true); + Toast.makeText(getApplicationContext(), getResources().getString(R.string.autoscroll_is_disabled), Toast.LENGTH_LONG).show(); + } else { + Button go_down_btn = (Button) findViewById(R.id.go_down_button); + go_down_btn.setVisibility(View.VISIBLE); + } + return false; + } + }); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + channel_socks_msg.setTextIsSelectable(true); + } + if(global_prefs.getInt("font_size", 0) >= 12) { + channel_socks_msg.setTextSize(TypedValue.COMPLEX_UNIT_SP, global_prefs.getInt("font_size", 0)); + } + output_msg_text = (EditText) findViewById(R.id.output_msg_text); + Spinner channels_spinner = (Spinner) findViewById(R.id.channels_spinner); + + if (savedInstanceState == null) { + Bundle extras = getIntent().getExtras(); + if(extras == null) { + profile_name = null; + } else { + profile_name = extras.getString("profile_name"); + } + } else { + profile_name = (String) savedInstanceState.getSerializable("profile_name"); + }; + SharedPreferences prefs = getApplicationContext().getSharedPreferences(profile_name, 0); + if (timer != null) { + timer.cancel(); + } + if(profile_name == null) { + socket = null; + finish(); + return; + } + + updateUITask = new UpdateUITask(); + sendingMsgText = new String(); + + final Context context = getApplicationContext(); + server = prefs.getString("server", ""); + port = prefs.getInt("port", 0); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + getActionBar().setSubtitle(server + ":" + port); + } else { + Log.i("Client", "\r\nProfile Info:\r\n\r\nPROFILE NAME: [" + profile_name + "]\r\nSERVER: [" + server + "]\r\nPORT: " + port); + } + if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + TextView app_summary = (TextView) findViewById(R.id.app_summary_text); + app_summary.setText(server + ":" + port); + final Button go_down_btn = (Button) findViewById(R.id.go_down_button); + go_down_btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + autoscroll_needed = true; + if(tabHost.getCurrentTab() == 0) { + socks_msg_text.setSelection(socks_msg_text.getText().length()); + } else if(tabHost.getCurrentTab() == 1) { + EditText channel_socks_msg = (EditText) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_msg_text); + channel_socks_msg.setSelection(channel_socks_msg.getText().length()); + } + go_down_btn.setVisibility(View.GONE); + } + }); + } + nicknames = prefs.getString("nicknames", ""); + auth_method = prefs.getString("auth_method", ""); + password = prefs.getString("password", ""); + hostname = prefs.getString("hostname", ""); + realname = prefs.getString("realname", ""); + encoding = prefs.getString("encoding", ""); + hide_ip = prefs.getString("hide_ip", ""); + quit_msg = prefs.getString("quit_message", ""); + force_ssl = prefs.getString("force_ssl", "Disabled"); + if(hostname.length() <= 2) { + hostname = nicknames.split(", ")[0]; + } + if(realname.length() <= 2) { + realname = "Member"; + } + + tabHost = (TabHost) findViewById(R.id.thread_tabs_host); + tabHost.setup(); + TabHost.TabSpec tabSpec = tabHost.newTabSpec("thread"); + tabSpec.setContent(R.id.thread_tab); + tabSpec.setIndicator(getResources().getString(R.string.thread_category)); + tabHost.addTab(tabSpec); + tabHost.setCurrentTab(0); + tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { + @Override + public void onTabChanged(String s) { + tabHost.setCurrentTab(tabHost.getCurrentTab()); + } + }); + + if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + View view = tabHost.getTabWidget().getChildAt(0); + view.setBackgroundResource(R.drawable.tabwidget); + if (view != null) { + tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = (int) (30 * getResources().getDisplayMetrics().density); + View tabImage = view.findViewById(android.R.id.icon); + if (tabImage != null) { + tabImage.setVisibility(View.GONE); + Log.d("Client", "TabIcon View"); + } else { + Log.e("Client", "TabImage View is null"); + } + TextView tabTitle = (TextView) view.findViewById(android.R.id.title); + if (tabTitle != null) { + Log.d("Client", "TabTitle View"); + tabTitle.setGravity(Gravity.CENTER); + ViewGroup parent = (ViewGroup) tabTitle.getParent(); + parent.removeView(tabTitle); + parent.addView(tabTitle); + ViewGroup.LayoutParams params = tabTitle.getLayoutParams(); + params.height = ViewGroup.LayoutParams.MATCH_PARENT; + } else { + } + } else { + } + } + + tabSpec = tabHost.newTabSpec("thread"); + if(force_ssl.equals("Enabled")) { + new Thread(new sslIrcThread()).start(); + } else { + new Thread(new ircThread()).start(); + } + ImageButton send_btn = (ImageButton) findViewById(R.id.send_button); + send_btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (output_msg_text.getText().toString().length() > 0) { + EditText output_msg_text = (EditText) findViewById(R.id.output_msg_text); + Thread send_msg_thread = new Thread(new SendSocketMsg()); + new Thread(new SendSocketMsg()).start(); + socks_msg_text.setText(socks_msg_text.getText() + "You: " + output_msg_text.getText() + "\r\n"); + socks_msg_text.setSelection(socks_msg_text.getText().length()); + } else { + Toast emptyMessageAttempting = Toast.makeText(context, getString(R.string.empty_message_sending_attempt), Toast.LENGTH_SHORT); + emptyMessageAttempting.show(); + } + } + }); + + if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + ImageButton menu_button = (ImageButton) findViewById(R.id.menu_button); + menu_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + openOptionsMenu(); + } + }); + } + AlertDialog.Builder builder; + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + builder = new AlertDialog.Builder(this); + } else { + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + builder = new AlertDialog.Builder(new ContextThemeWrapper(ThreadActivity.this, R.style.IRCClient_Light)); + } else { + builder = new AlertDialog.Builder(new ContextThemeWrapper(ThreadActivity.this, R.style.IRCClient)); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + builder = new AlertDialog.Builder(new ContextThemeWrapper(ThreadActivity.this, R.style.IRCClient)); + } else { + builder = new AlertDialog.Builder(new ContextThemeWrapper(ThreadActivity.this, R.style.IRCClient_Light)); + } + } + } + LayoutInflater inflater = getLayoutInflater(); + final View dialogView = inflater.inflate(R.layout.progress_activity, null); + if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + dialogView.setMinimumWidth(metrics.widthPixels); + } + TextView progressText = (TextView) dialogView.findViewById(R.id.progress_text); + progressText.setText(getString(R.string.connection_progress, server + ":" + port)); + builder.setView(dialogView); + connectionDialog = builder.create(); + connectionDialog.setCancelable(false); + if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + connectionDialog.getWindow().setGravity(Gravity.BOTTOM); + } + connectionDialog.show(); + if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + Button dialogButton; + dialogButton = connectionDialog.getButton(DialogInterface.BUTTON_POSITIVE); + + if(dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = connectionDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if(dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = connectionDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if(dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } + } + + private void setColorStyle(SharedPreferences global_prefs) { + if (global_prefs.getString("theme", "Light").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + EditText socks_msg_text = (EditText) findViewById(R.id.sock_msg_text); + socks_msg_text.setTextColor(getResources().getColor(R.color.black)); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + LinearLayout app_title_bar = (LinearLayout) findViewById(R.id.app_title_bar); + app_title_bar.setBackgroundColor(getResources().getColor(R.color.white_75)); + TextView app_title = (TextView) findViewById(R.id.app_title_label); + app_title.setBackgroundColor(getResources().getColor(R.color.white_75)); + ImageView app_icon = (ImageView) findViewById(R.id.app_icon_view); + app_icon.setBackgroundColor(getResources().getColor(R.color.white_75)); + LinearLayout activity_ll = (LinearLayout) findViewById(R.id.activity_ll); + activity_ll.setBackgroundColor(getResources().getColor(R.color.white)); + socks_msg_text.setBackgroundColor(getResources().getColor(R.color.white_75)); + EditText sended_msg_area = (EditText) findViewById(R.id.output_msg_text); + sended_msg_area.setTextColor(getResources().getColor(R.color.black)); + Spinner channels_spinner = (Spinner) findViewById(R.id.channels_spinner); + channels_spinner.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_spinner_light)); + } + } + } + } + + @Override + protected void onResume() { + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + if(global_prefs.getInt("font_size", 0) >= 12) { + socks_msg_text.setTextSize(TypedValue.COMPLEX_UNIT_SP, global_prefs.getInt("font_size", 0)); + } + super.onResume(); + } + + @Override + public void onBackPressed() { + AlertDialog alertDialog; + AlertDialog.Builder builder; + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + builder = new AlertDialog.Builder(this); + builder.setTitle(getResources().getString(R.string.quit_session_title)); + builder.setMessage(getResources().getString(R.string.quit_session_msg)); + } else { + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + builder = new AlertDialog.Builder(new ContextThemeWrapper(ThreadActivity.this, R.style.IRCClient_Light)); + builder.setTitle(Html.fromHtml("" + getResources().getString(R.string.quit_session_title) + "")); + builder.setMessage(Html.fromHtml("" + getResources().getString(R.string.quit_session_msg) + "")); + } else { + builder = new AlertDialog.Builder(new ContextThemeWrapper(ThreadActivity.this, R.style.IRCClient)); + builder.setTitle(Html.fromHtml("" + getResources().getString(R.string.quit_session_title) + "")); + builder.setMessage(Html.fromHtml("" + getResources().getString(R.string.quit_session_msg) + "")); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + builder = new AlertDialog.Builder(new ContextThemeWrapper(ThreadActivity.this, R.style.IRCClient)); + builder.setTitle(Html.fromHtml("" + getResources().getString(R.string.quit_session_title) + "")); + builder.setMessage(Html.fromHtml("" + getResources().getString(R.string.quit_session_msg) + "")); + } else { + builder = new AlertDialog.Builder(new ContextThemeWrapper(ThreadActivity.this, R.style.IRCClient_Light)); + builder.setTitle(Html.fromHtml("" + getResources().getString(R.string.quit_session_title) + "")); + builder.setMessage(Html.fromHtml("" + getResources().getString(R.string.quit_session_msg) + "")); + } + } + } + builder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + sendQuitMessage(); + } + }); + builder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + return; + } + }); + alertDialog = builder.create(); + alertDialog.show(); + if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + Button dialogButton = null; + customizeDialogStyle(dialogButton, global_prefs, alertDialog); + } + } + + private void sendQuitMessage() { + if(tabHost.getCurrentTab() == 0) { + output_msg_text.setText("/quit"); + } else { + EditText channel_output_msg = (EditText) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_output_msg_text); + channel_output_msg.setText("/quit"); + } + sendingMsgText = "/quit"; + state = "sending_message"; + new Thread(new SendSocketMsg()).start(); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.thread_menu, menu); + thread_menu = menu; + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.statistics_item) { + showStatisticsDialog(); + return true; + } else if (id == R.id.about_application_item) { + showAboutApplication(); + } else if (id == R.id.connection_manager_item) { + showConnectionManager(); + } else if (id == R.id.settings_item) { + showMainSettings(); + } else if(id == R.id.disconnect_item) { + onBackPressed(); + } else if(id == R.id.go_down_item) { + if(tabHost.getCurrentTab() == 0) { + socks_msg_text.setSelection(socks_msg_text.getText().length()); + } else if(tabHost.getCurrentTab() == 1) { + EditText channel_socks_msg = (EditText) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_msg_text); + channel_socks_msg.setSelection(channel_socks_msg.getText().length()); + } + autoscroll_needed = true; + MenuItem go_down = thread_menu.findItem(R.id.go_down_item); + go_down.setVisible(false); + } + + return super.onOptionsItemSelected(item); + } + + private void showConnectionManager() { + Intent intent = new Intent(ThreadActivity.this, ConnectionManagerActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + } + + private void showAboutApplication() { + Intent intent = new Intent(ThreadActivity.this, AboutApplicationActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + } + + private void showStatisticsDialog() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + DialogFragment statsDialogFragm = new StatisticsFragm(); + statsDialogFragm.show(getFragmentManager(), "stats_dialog"); + } else { + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + AlertDialog.Builder builder; + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + builder = new AlertDialog.Builder(new ContextThemeWrapper(ThreadActivity.this, R.style.IRCClient_Light)); + } else { + builder = new AlertDialog.Builder(new ContextThemeWrapper(ThreadActivity.this, R.style.IRCClient)); + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + builder = new AlertDialog.Builder(new ContextThemeWrapper(ThreadActivity.this, R.style.IRCClient)); + } else { + builder = new AlertDialog.Builder(new ContextThemeWrapper(ThreadActivity.this, R.style.IRCClient_Light)); + } + } + LayoutInflater inflater = getLayoutInflater(); + final View dialogView = inflater.inflate(R.layout.statistics_activity, null); + TextView session_label = (TextView) dialogView.findViewById(R.id.session_label); + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + session_label.setTextColor(getResources().getColor(R.color.black)); + } else { + session_label.setTextColor(getResources().getColor(R.color.white)); + } + } else { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + session_label.setTextColor(getResources().getColor(R.color.white)); + } else { + session_label.setTextColor(getResources().getColor(R.color.black)); + } + } + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + dialogView.setMinimumWidth(metrics.widthPixels); + builder.setView(dialogView); + builder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + + } + }); + sended_bytes = getSendedBytes(); + received_bytes = getReceivedBytes(); + int total_bytes = sended_bytes + received_bytes; + TextView sended_bytes_label = (TextView) dialogView.findViewById(R.id.sended_label2); + TextView received_bytes_label = (TextView) dialogView.findViewById(R.id.received_label2); + TextView total_bytes_label = (TextView) dialogView.findViewById(R.id.total_label2); + TextView dialog_title = (TextView) dialogView.findViewById(R.id.dialog_title); + dialog_title.setText(getString(R.string.statistics_item)); + DecimalFormat dF = new DecimalFormat("#.00"); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { + dF.setRoundingMode(RoundingMode.DOWN); + } + if (sended_bytes > 1073741824) { + String sended_bytes_rounded = dF.format((sended_bytes / 1073741824)); + sended_bytes_label.setText(getString(R.string.gbytes_stats, sended_bytes_rounded)); + } else if(sended_bytes > 1048576) { + String sended_bytes_rounded = dF.format((sended_bytes / 1048576)); + sended_bytes_label.setText(getString(R.string.mbytes_stats, sended_bytes_rounded)); + } else if(sended_bytes > 1024) { + String sended_bytes_rounded = dF.format((sended_bytes / 1024)); + sended_bytes_label.setText(getString(R.string.kbytes_stats, sended_bytes_rounded)); + } else { + sended_bytes_label.setText(getString(R.string.bytes_stats, Integer.toString(sended_bytes))); + } + if (received_bytes > 1073741824) { + String received_bytes_rounded = dF.format((received_bytes / 1073741824)); + received_bytes_label.setText(getString(R.string.gbytes_stats, received_bytes_rounded)); + } else if(received_bytes > 1048576) { + String received_bytes_rounded = dF.format((received_bytes / 1048576)); + received_bytes_label.setText(getString(R.string.mbytes_stats, received_bytes_rounded)); + } else if(received_bytes > 1024) { + String received_bytes_rounded = dF.format((received_bytes / 1024)); + received_bytes_label.setText(getString(R.string.kbytes_stats, received_bytes_rounded)); + } else { + received_bytes_label.setText(getString(R.string.bytes_stats, Integer.toString(received_bytes))); + } + if (total_bytes > 1073741824) { + String total_bytes_rounded = dF.format((total_bytes / 1073741824)); + total_bytes_label.setText(getString(R.string.gbytes_stats, total_bytes_rounded)); + } else if(total_bytes > 1048576) { + String total_bytes_rounded = dF.format((total_bytes / 1048576)); + total_bytes_label.setText(getString(R.string.mbytes_stats, total_bytes_rounded)); + } else if(total_bytes > 1024) { + String total_bytes_rounded = dF.format((total_bytes / 1024)); + total_bytes_label.setText(getString(R.string.kbytes_stats, total_bytes_rounded)); + } else { + total_bytes_label.setText(getString(R.string.bytes_stats, Integer.toString(total_bytes))); + } + AlertDialog statisticsDlg = builder.create(); + statisticsDlg.getWindow().setGravity(Gravity.BOTTOM); + statisticsDlg.show(); + + Button dialogButton = null; + customizeDialogStyle(dialogButton, global_prefs, statisticsDlg); + } + } + + private void setCustomTheme(SharedPreferences global_prefs) { + if(global_prefs.getString("language", "OS dependent").contains("Russian")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } + } else if (global_prefs.getString("language", "OS dependent").contains("English")) { + if(global_prefs.getBoolean("language_requires_restart", false) == false) { + Locale locale = new Locale("en_US"); + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } else { + Locale locale = new Locale("ru"); + Locale.setDefault(locale); + Configuration config = getResources().getConfiguration(); + config.locale = locale; + getResources().updateConfiguration(config, + getApplicationContext().getResources().getDisplayMetrics()); + } + } + if (global_prefs.getString("theme", "Light").contains("Light")) { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + setTheme(R.style.IRCClient_Light); + } else { + setTheme(R.style.IRCClient); + } + } else { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + setTheme(R.style.IRCClient); + } else { + setTheme(R.style.IRCClient_Light); + } + } + } + + private void customizeDialogStyle(Button dialogButton, SharedPreferences global_prefs, AlertDialog alertDialog) { + if(global_prefs.getString("theme", "Dark").contains("Light")) { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } else { + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } + } else { + if(global_prefs.getBoolean("theme_requires_restart", false) == false) { + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.title_v11_full_transparent)); + dialogButton.setTextColor(getResources().getColor(R.color.white)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } else { + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); + + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.black)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + dialogButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + if (dialogButton != null) { + dialogButton.setBackgroundColor(getResources().getColor(R.color.white)); + dialogButton.setTextColor(getResources().getColor(R.color.orange)); + dialogButton.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + } + } + } + } + + private void showMainSettings() { + Intent intent = new Intent(ThreadActivity.this, MainSettingsActivity.class); + startActivity(intent); + } + + @Override + protected void onDestroy() { + if(profile_name != null) { + SharedPreferences prefs = getApplicationContext().getSharedPreferences(profile_name, 0); + SharedPreferences.Editor editor = prefs.edit(); + editor.putBoolean("connected", false); + editor.commit(); + SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + editor = global_prefs.edit(); + editor.putBoolean("connected", false); + editor.commit(); + } + super.onDestroy(); + } + + public int getSendedBytes() { + return sended_bytes_count; + } + + public int getReceivedBytes() { + return received_bytes_count; + } + + class ircThread implements Runnable { + @Override + public void run() { + try { + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + socket = new Socket(); + state = "connecting"; + Log.d("Client", "Getting IP address from " + server + ":" + port + "..."); + InetAddress serverAddr = InetAddress.getByName(server); + SocketAddress socketAddress = new InetSocketAddress(serverAddr, port); + Log.d("Client", "Connecting to " + server + ":" + port + "..."); + socket.connect(socketAddress, 30000); + socket.setKeepAlive(true); + while(state == "connecting") { + if (socket.isConnected()) { + updateUITask.run(); + sleep(50); + } + } + input = socket.getInputStream(); + output = socket.getOutputStream(); + output.write(("USER " + nicknames.split(", ")[0] + " " + + hostname + " " + nicknames.split(", ")[0] + " :" + + realname + "\r\n").getBytes(encoding)); + output.flush(); + sended_bytes_count += ("USER " + nicknames.split(", ")[0] + " " + + hostname + " " + nicknames.split(", ")[0] + " :" + + realname + "\r\n").getBytes(encoding).length; + output.write(("NICK " + nicknames.split(", ")[0] + "\r\n").getBytes(encoding)); + output.flush(); + sended_bytes_count += ("NICK " + nicknames.split(", ")[0] + "\r\n").getBytes(encoding).length; + if(password.length() > 0 && auth_method.startsWith("NickServ")) { + output.write(("NICKSERV identify " + password + "\r\n").getBytes(encoding)); + output.flush(); + sended_bytes_count += ("NICKSERV identify " + password + "\r\n").getBytes(encoding).length; + } + if(hide_ip.startsWith("Enabled")) { + output.write(("MODE " + nicknames.split(", ")[0] + " +x\r\n").getBytes(encoding)); + output.flush(); + sended_bytes_count += ("MODE " + nicknames.split(", ")[0] + " +x\r\n").getBytes(encoding).length; + } + BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream(), encoding)); + String response; + messageAuthor = new String(); + messageBody = new String(); + messageBody = ""; + String nick = nicknames.split(", ")[0]; + IRCParser parser = new IRCParser(); + msg = new StringBuilder(); + while(socket.isConnected() == true) { + if(in.ready() == true) { + sleep(10); + response = in.readLine(); + raw_socket_data_string = response; + received_bytes_count += response.length(); + if (response.startsWith("PING")) { + output.write(("PONG " + response.split(" ")[1]).getBytes(encoding)); + output.flush(); + sended_bytes_count += ("PONG " + response.split(" ")[1]).getBytes(encoding).length; + } + if(response != null) { + String parsedString; + if(global_prefs.getBoolean("show_msg_timestamps", true) == true) { + parsedString = parser.parseString(response, true); + } else { + parsedString = parser.parseString(response, false); + } + messageBody = parser.getMessageBody(response); + messageAuthor = parser.getMessageAuthor(response); + current_channel = parser.getChannel(response); + if(parsedString.length() > 0) { + msg.append(parsedString).append("\n"); + socket_data_string = msg.toString(); + msg.setLength(0); + if(messageBody.contains(nicknames.split(", ")[0])) { + state = "getting_data_with_mention"; + } else { + state = "getting_data"; + } + updateUITask.run(); + }; + } + }; + } + socket.close(); + socket = null; + state = "connection_lost"; + updateUITask.run(); + } catch (UnknownHostException uhEx) { + Log.e("Socket", "UnknownHostException"); + try { + socket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + socket = null; + state = "no_connection"; + updateUITask.run(); + } catch(SocketTimeoutException timeoutEx) { + Log.e("Socket", "SocketTimeoutException"); + try { + socket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + socket = null; + state = "timeout"; + updateUITask.run(); + } catch (IllegalBlockingModeException ibmEx) { + Log.e("Socket", "IllegalBlockingModeException"); + try { + socket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + socket = null; + state = "no_connection"; + updateUITask.run(); + } catch (IllegalArgumentException iaEx) { + Log.e("Socket", "IllegalArgumentException"); + try { + socket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + socket = null; + state = "no_connection"; + updateUITask.run(); + } catch (ConnectException Ex) { + Log.e("Socket", "ConnectException"); + try { + socket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + socket = null; + state = "no_connection"; + updateUITask.run(); + } catch (IOException ioEx) { + ioEx.printStackTrace(); + } catch (Exception ex) { + try { + if(socket != null) { + socket.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + socket = null; + state = "disconnected"; + updateUITask.run(); + } + } + } + + class sslIrcThread implements Runnable { + @Override + public void run() { + try { + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + final TrustManager[] trustAllCerts = new TrustManager[]{ + new X509TrustManager() { + @Override + public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) { + } + + @Override + public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) { + } + + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return new java.security.cert.X509Certificate[]{}; + } + } + }; + + final SSLContext sslContext = SSLContext.getInstance("SSL"); + sslContext.init(null, trustAllCerts, new java.security.SecureRandom()); + SSLSocketFactory ssf = (SSLSocketFactory) sslContext.getSocketFactory(); + Log.d("Client", "Getting IP address from " + server + ":" + port + "..."); + InetAddress serverAddr = InetAddress.getByName(server); + + state = "connecting"; + Log.d("Client", "Connecting to " + server + ":" + port + "... (Secured)"); + SocketAddress socketAddress = new InetSocketAddress(serverAddr, port); + sslSocket = (SSLSocket) ssf.createSocket(serverAddr, port); + + while(state == "connecting") { + if (sslSocket.isConnected()) { + updateUITask.run(); + sleep(50); + } + } + input = sslSocket.getInputStream(); + output = sslSocket.getOutputStream(); + output.write(("USER " + nicknames.split(", ")[0] + " " + + hostname + " " + nicknames.split(", ")[0] + " :" + + realname + "\r\n").getBytes(encoding)); + output.flush(); + sended_bytes_count += ("USER " + nicknames.split(", ")[0] + " " + + hostname + " " + nicknames.split(", ")[0] + " :" + + realname + "\r\n").getBytes(encoding).length; + output.write(("NICK " + nicknames.split(", ")[0] + "\r\n").getBytes(encoding)); + output.flush(); + sended_bytes_count += ("NICK " + nicknames.split(", ")[0] + "\r\n").getBytes(encoding).length; + if(password.length() > 0 && auth_method.startsWith("NickServ")) { + output.write(("NICKSERV identify " + password + "\r\n").getBytes(encoding)); + output.flush(); + sended_bytes_count += ("NICKSERV identify " + password + "\r\n").getBytes(encoding).length; + } + if(hide_ip.startsWith("Enabled")) { + output.write(("MODE " + nicknames.split(", ")[0] + " +x\r\n").getBytes(encoding)); + output.flush(); + sended_bytes_count += ("MODE " + nicknames.split(", ")[0] + " +x\r\n").getBytes(encoding).length; + } + BufferedReader in = new BufferedReader(new InputStreamReader(sslSocket.getInputStream(), encoding)); + String response; + messageAuthor = new String(); + messageBody = new String(); + messageBody = ""; + String nick = nicknames.split(", ")[0]; + IRCParser parser = new IRCParser(); + msg = new StringBuilder(); + while(sslSocket.isConnected() == true) { + sleep(10); + response = in.readLine(); + raw_socket_data_string = response; + received_bytes_count += response.length(); + if (response.startsWith("PING")) { + output.write(("PONG " + response.split(" ")[1]).getBytes(encoding)); + output.flush(); + sended_bytes_count += ("PONG " + response.split(" ")[1]).getBytes(encoding).length; + } + if(response != null) { + String parsedString; + if(global_prefs.getBoolean("show_msg_timestamps", true) == true) { + parsedString = parser.parseString(response, true); + } else { + parsedString = parser.parseString(response, false); + } + messageBody = parser.getMessageBody(response); + messageAuthor = parser.getMessageAuthor(response); + current_channel = parser.getChannel(response); + if(parsedString.length() > 0) { + msg.append(parsedString).append("\n"); + socket_data_string = msg.toString(); + msg.setLength(0); + if(messageBody.contains(nicknames.split(", ")[0])) { + state = "getting_data_with_mention"; + } else { + state = "getting_data"; + } + updateUITask.run(); + }; + } + } + sslSocket.close(); + sslSocket = null; + state = "connection_lost"; + updateUITask.run(); + } catch (UnknownHostException uhEx) { + Log.e("Socket", "UnknownHostException"); + try { + sslSocket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + sslSocket = null; + state = "no_connection"; + updateUITask.run(); + } catch(SocketTimeoutException timeoutEx) { + Log.e("Socket", "SocketTimeoutException"); + try { + sslSocket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + sslSocket = null; + state = "timeout"; + updateUITask.run(); + } catch (IllegalBlockingModeException ibmEx) { + Log.e("Socket", "IllegalBlockingModeException"); + try { + sslSocket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + sslSocket = null; + state = "no_connection"; + updateUITask.run(); + } catch (IllegalArgumentException iaEx) { + Log.e("Socket", "IllegalArgumentException"); + try { + sslSocket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + sslSocket = null; + state = "no_connection"; + updateUITask.run(); + } catch (ConnectException Ex) { + Log.e("Socket", "ConnectException"); + try { + socket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + sslSocket = null; + state = "no_connection"; + updateUITask.run(); + } catch (IOException ioEx) { + ioEx.printStackTrace(); + } catch (Exception ex) { + try { + if(socket != null) { + socket.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + sslSocket = null; + state = "disconnected"; + updateUITask.run(); + } + } + } + + class SendSocketMsg implements Runnable { + @Override + public void run() { + if (socket != null || sslSocket != null) { + state = "sending_message"; + while(state == "sending_message") { + updateUITask.run(); + try { + sleep(50); + state = "finishing_sending_message"; + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + if(sendingMsgText.length() > 0) { + try { + if(sendingMsgText.startsWith("QUIT")) { + Timer shutdownTimer = new Timer(); + shutdownTimer.schedule(new TimerTask() { + @Override + public void run() { + try { + if(force_ssl.equals("Enabled")) { + if (sslSocket != null) { + sslSocket.close(); + sslSocket = null; + } + } else { + if (socket != null) { + socket.close(); + socket = null; + } + } + } catch (IOException e) { + e.printStackTrace(); + } + finish(); + } + }, 1000); + } + if(force_ssl.equals("Enabled")) { + if (sslSocket.isConnected() == true && state == "finishing_sending_message") { + PrintWriter out; + out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(output, encoding))); + Log.i("Client", "Sending message...\r\n\r\nMESSAGE: [" + sendingMsgText.replace("\r", "\\r").replace("\n", "\\n") + "]"); + out.println(new String((sendingMsgText).getBytes(encoding), encoding)); + Log.i("Client", "Clearing output stream..."); + out.flush(); + Log.i("Client", "\r\nSended message!"); + state = "sended_message"; + updateUITask.run(); + } + } else { + if (socket.isConnected() == true && state == "finishing_sending_message") { + PrintWriter out; + out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(output, encoding))); + Log.i("Client", "Sending message...\r\n\r\nMESSAGE: [" + sendingMsgText.replace("\r", "\\r").replace("\n", "\\n") + "]"); + out.println(new String((sendingMsgText).getBytes(encoding), encoding)); + Log.i("Client", "Clearing output stream..."); + out.flush(); + Log.i("Client", "\r\nSended message!"); + state = "sended_message"; + updateUITask.run(); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } else { + Log.e("Socket", "Socket not created"); + } + } + } + + class UpdateUITask extends TimerTask { + @Override + public void run() { + runOnUiThread(new Runnable() { + @Override + public void run() { + if(current_channel.length() > 0 && channelsArray.size() > 0 && tabHost.getTabWidget().getTabCount() > 1) { + socks_msg_text = (EditText) findViewById(R.id.sock_msg_text); + for(int ch_index = 0; ch_index < channelsArray.size(); ch_index++) { + if(channelsArray.get(ch_index).equals(current_channel)) { + View tab = tabHost.getTabWidget().getChildTabViewAt(0); + if(tab == null) { + Log.e("Client", "TabView is null"); + } + socks_msg_text = (EditText) tab.findViewById(R.id.sock_msg_text); + if(socks_msg_text == null) { + socks_msg_text = (EditText) findViewById(R.id.sock_msg_text); + } + } + } + } else { + socks_msg_text = (EditText) findViewById(R.id.sock_msg_text); + } + final SharedPreferences global_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + if(state == "getting_data") { + if(socket_data_string.length() > 0) { + if(global_prefs.getBoolean("save_msg_history", false) == true) { + File directory; + directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "Tinelix"); + if (!directory.exists()) { + directory.mkdirs(); + } + + directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Tinelix", "IRC Client"); + if (!directory.exists()) { + directory.mkdirs(); + } + directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Tinelix/IRC Client", "Messages Logs"); + if (!directory.exists()) { + directory.mkdirs(); + } + + try { + Log.d("App", "Attempting creating log file..."); + File file = new File(directory, "LOG_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(dt) + ".log"); + if (!file.exists()) { + file.createNewFile(); + } + Log.d("App", "Log file created!"); + FileWriter writer = new FileWriter(file); + writer.append(socks_msg_text.getText() + socket_data_string); + writer.flush(); + writer.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + int cursor_pos = socks_msg_text.getSelectionStart(); + int current_ch_index = -1; + for (int ch_index = 0; ch_index < channelsArray.size(); ch_index++) { + if(current_channel.length() > 0 && current_channel.equals(channelsArray.get(ch_index))) { + current_ch_index = ch_index; + } + } + if(current_ch_index > -1 && channels_sb.size() > current_ch_index && channelsArray.size() > current_ch_index) { + channels_sb.get(current_ch_index).append(socket_data_string); + } + if(tabHost.getTabWidget().getTabCount() == 1) { + socks_msg_text.setText(socks_msg_text.getText() + socket_data_string); + } else if(tabHost.getTabWidget().getTabCount() > 1) { + try { + if(current_ch_index > -1) { + Spinner channel_spinner = (Spinner) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_spinner); + if (channel_spinner.getSelectedItemPosition() == current_ch_index) { + EditText channel_socks_msg = (EditText) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_msg_text); + channel_socks_msg.setText(channels_sb.get(current_ch_index)); + } + } else { + socks_msg_text.setText(socks_msg_text.getText() + socket_data_string); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + if(autoscroll_needed == true) { + if(tabHost.getCurrentTab() == 0) { + socks_msg_text.setSelection(socks_msg_text.getText().length()); + } else if(tabHost.getCurrentTab() == 1) { + if(current_ch_index > -1) { + EditText channel_socks_msg = (EditText) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_msg_text); + channel_socks_msg.setSelection(channel_socks_msg.getText().length()); + } else { + socks_msg_text.setSelection(socks_msg_text.getText().length()); + } + + } + } else { + if (tabHost.getCurrentTab() == 0) { + cursor_pos = socks_msg_text.getSelectionStart(); + socks_msg_text.setSelection(socks_msg_text.getSelectionStart()); + } else if (tabHost.getCurrentTab() == 1) { + EditText channel_socks_msg = (EditText) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_msg_text); + cursor_pos = channel_socks_msg.getSelectionStart(); + channel_socks_msg.setSelection(cursor_pos); + } + } + Log.d("Client", "Position 2: " + socks_msg_text.getSelectionStart()); + socket_data_string = ""; + } + } else if(state == "getting_data_with_mention") { + int cursor_pos = socks_msg_text.getSelectionStart(); + int current_ch_index = -1; + if(socket_data_string.length() > 0) { + for (int ch_index = 0; ch_index < channelsArray.size(); ch_index++) { + if(current_channel.length() > 0 && current_channel.equals(channelsArray.get(ch_index))) { + current_ch_index = ch_index; + } + } + if(current_ch_index > -1 && channels_sb.size() > current_ch_index && channelsArray.size() > current_ch_index) { + channels_sb.get(current_ch_index).append(socket_data_string); + } + if(tabHost.getTabWidget().getTabCount() == 1) { + socks_msg_text.setText(socks_msg_text.getText() + socket_data_string); + } else if(tabHost.getTabWidget().getTabCount() > 1) { + try { + if(current_ch_index > -1) { + Spinner channel_spinner = (Spinner) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_spinner); + if (channel_spinner.getSelectedItemPosition() == current_ch_index) { + EditText channel_socks_msg = (EditText) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_msg_text); + channel_socks_msg.setText(channels_sb.get(current_ch_index)); + } + } else { + socks_msg_text.setText(socks_msg_text.getText() + socket_data_string); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + socket_data_string = ""; + Context context = getApplicationContext(); + if(messageBody.length() > 0 && nicknames.split(", ")[0].length() > 0) { + if(global_prefs.getBoolean("save_msg_history", false) == true) { + File directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "Tinelix"); + if (!directory.exists()) { + directory.mkdirs(); + } + + directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Tinelix", "IRC Client"); + if (!directory.exists()) { + directory.mkdirs(); + } + directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Tinelix/IRC Client", "App Logs"); + if (!directory.exists()) { + directory.mkdirs(); + } + + try { + Log.d("App", "Attempting creating log file..."); + File file = new File(directory, "LOG_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(dt) + ".log"); + if (!file.exists()) { + file.createNewFile(); + } + Log.d("App", "Log file created!"); + FileWriter writer = new FileWriter(file); + writer.append(socks_msg_text.getText() + socket_data_string); + writer.flush(); + writer.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + Notification.Builder notificationBuilder = null; + notificationBuilder = new Notification.Builder(context); + notificationBuilder + .setSmallIcon(R.drawable.ic_notification_icon) + .setWhen(System.currentTimeMillis()) + .setContentTitle(getString(R.string.mention_notification_title, messageAuthor)) + .setContentText(messageBody); + notificationManager.notify(1, notificationBuilder.build()); + } else { + Notification notification = new Notification(R.drawable.ic_notification_icon, getString(R.string.mention_notification_title, messageAuthor), System.currentTimeMillis()); + NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.notification_activity); + contentView.setTextViewText(R.id.notification_title, getString(R.string.mention_notification_title, messageAuthor)); + contentView.setTextViewText(R.id.notification_text, messageBody); + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + notification.contentView = contentView; + ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE); + List tasks = am.getRunningTasks(1); + ActivityManager.RunningTaskInfo task = tasks.get(0); // Should be my task + Intent notificationIntent = new Intent(context, ThreadActivity.class); + notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + notificationIntent.setAction(Intent.ACTION_MAIN); + notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); + notification.flags |= Notification.FLAG_AUTO_CANCEL; + PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0); + notification.contentIntent = contentIntent; + notificationManager.notify(R.layout.notification_activity, notification); + } + } + } + } else if(state == "disconnected") { + Toast.makeText(getApplicationContext(), R.string.connection_lost_msg, Toast.LENGTH_SHORT).show(); + socks_msg_text.setSelection(socks_msg_text.getText().length()); + connectionDialog.cancel(); + finish(); + } else if(state == "connection_lost") { + Toast.makeText(getApplicationContext(), R.string.connection_lost_msg, Toast.LENGTH_SHORT).show(); + socks_msg_text.setSelection(socks_msg_text.getText().length()); + connectionDialog.cancel(); + finish(); + } else if(state == "timeout") { + Toast.makeText(getApplicationContext(), R.string.connection_timeout_msg, Toast.LENGTH_SHORT).show(); + socks_msg_text.setSelection(socks_msg_text.getText().length()); + connectionDialog.cancel(); + finish(); + } else if(state == "no_connection") { + Toast.makeText(getApplicationContext(), R.string.no_connection_msg, Toast.LENGTH_SHORT).show(); + socks_msg_text.setSelection(socks_msg_text.getText().length()); + connectionDialog.cancel(); + finish(); + } else if(state == "sending_message") { + if (socket != null || sslSocket != null) { + EditText output_msg_text; + if(tabHost.getCurrentTab() == 1) { + output_msg_text = (EditText) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_output_msg_text); + } else { + output_msg_text = (EditText) findViewById(R.id.output_msg_text); + } + outputMsgArray = new LinkedList(Arrays.asList(output_msg_text.getText().toString().split(" "))); + Log.i("Client", "\r\nSending message...\r\n\r\nMESSAGE: [" + output_msg_text.getText().toString() + "]"); + if (outputMsgArray.get(0).startsWith("/join") && outputMsgArray.size() > 1 && outputMsgArray.get(1).startsWith("#")) { + try { + channelsArray.add(outputMsgArray.get(1)); + sendingMsgText = ("JOIN " + outputMsgArray.get(1) + "\r\n"); + sended_bytes_count += ("JOIN " + outputMsgArray.get(1) + "\r\n").getBytes(encoding).length; + if(tabHost.getTabWidget().getTabCount() < 2) { + TabHost.TabSpec tabSpec = tabHost.newTabSpec("channels"); + tabSpec.setContent(R.id.channels_tab); + tabSpec.setIndicator(getResources().getString(R.string.channels_tab_item)); + tabHost.addTab(tabSpec); + if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + View view = tabHost.getTabWidget().getChildAt(1); + view.setBackgroundResource(R.drawable.tabwidget); + if (view != null) { + Log.d("Client", "TabWidget View"); + tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = (int) (30 * getResources().getDisplayMetrics().density); + View tabImage = view.findViewById(android.R.id.icon); + if (tabImage != null) { + tabImage.setVisibility(View.GONE); + Log.d("Client", "TabIcon View"); + } else { + Log.e("Client", "TabImage View is null"); + } + TextView tabTitle = (TextView) view.findViewById(android.R.id.title); + if (tabTitle != null) { + Log.d("Client", "TabTitle View"); + tabTitle.setGravity(Gravity.CENTER); + ViewGroup parent = (ViewGroup) tabTitle.getParent(); + parent.removeView(tabTitle); + parent.addView(tabTitle); + ViewGroup.LayoutParams params = tabTitle.getLayoutParams(); + params.height = ViewGroup.LayoutParams.MATCH_PARENT; + } else { + Log.e("Client", "TabTitle View is null"); + } + } else { + Log.e("Client", "TabWidget View is null"); + } + } + } + tabHost.setCurrentTab(1); + final Spinner channels_spinner = (Spinner) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_spinner); + final EditText channels_socks_text = (EditText) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_msg_text); + final EditText channels_output_text = (EditText) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_output_msg_text); + if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + channels_spinner.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_spinner_light)); + } else { + channels_spinner.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_spinner)); + } + } else if (global_prefs.getString("theme", "Dark").contains("Dark")) { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + channels_spinner.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_spinner)); + } else { + channels_spinner.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_spinner_light)); + } + } + channels_spinner.setPadding(2, 0, 2, 0); + ArrayList spinnerArray = new ArrayList(); + spinnerArray.clear(); + for (int i = 0; i < channelsArray.size(); i++) { + spinnerArray.add(new CustomSpinnerItem(channelsArray.get(i))); + } + CustomSpinnerAdapter customSpinnerAdapter = new CustomSpinnerAdapter(getApplicationContext(), spinnerArray); + channels_spinner.setAdapter(customSpinnerAdapter); + } else { + ArrayList spinnerArray = new ArrayList(); + spinnerArray.clear(); + for (int i = 0; i < channelsArray.size(); i++) { + spinnerArray.add(new CustomSpinnerItem(channelsArray.get(i))); + } + CustomSpinnerAdapter customSpinnerAdapter = new CustomSpinnerAdapter(getApplicationContext(), spinnerArray); + channels_spinner.setAdapter(customSpinnerAdapter); + } + ImageButton channels_send_btn = (ImageButton) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_send_button); + channels_send_btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (channels_output_text.getText().toString().length() > 0) { + sendingMsgText = channels_output_text.getText().toString(); + Thread send_msg_thread = new Thread(new SendSocketMsg()); + new Thread(new SendSocketMsg()).start(); + channels_socks_text.setText(channels_socks_text.getText() + "You: " + channels_output_text.getText() + "\r\n"); + channels_socks_text.setSelection(channels_socks_text.getText().length()); + channels_sb.get(channels_spinner.getSelectedItemPosition()).append("You: " + channels_output_text.getText() + "\r\n"); + } else { + Toast emptyMessageAttempting = Toast.makeText(getApplicationContext(), getString(R.string.empty_message_sending_attempt), Toast.LENGTH_SHORT); + emptyMessageAttempting.show(); + } + } + }); + channels_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView adapterView, View view, int i, long l) { + try { + channels_socks_text.setText(channels_sb.get(i).toString()); + } catch(IndexOutOfBoundsException ioofe) { + ioofe.printStackTrace(); + } + } + + @Override + public void onNothingSelected(AdapterView adapterView) { + + } + }); + } catch (IOException e) { + e.printStackTrace(); + } + } else if (outputMsgArray.get(0).startsWith("/join") && outputMsgArray.size() > 1 && !outputMsgArray.get(1).startsWith("#")) { + try { + channelsArray.add(outputMsgArray.get(1)); + sendingMsgText = ("JOIN " + outputMsgArray.get(1) + "\r\n"); + sended_bytes_count += ("JOIN " + outputMsgArray.get(1) + "\r\n").getBytes(encoding).length; + if(tabHost.getTabWidget().getTabCount() < 2) { + TabHost.TabSpec tabSpec = tabHost.newTabSpec("channels"); + tabSpec.setContent(R.id.channels_tab); + tabSpec.setIndicator(getResources().getString(R.string.channels_tab_item)); + tabHost.addTab(tabSpec); + if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + View view = tabHost.getTabWidget().getChildAt(1); + view.setBackgroundResource(R.drawable.tabwidget); + if (view != null) { + tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = (int) (30 * getResources().getDisplayMetrics().density); + View tabImage = view.findViewById(android.R.id.icon); + if (tabImage != null) { + tabImage.setVisibility(View.GONE); + Log.d("Client", "TabIcon View"); + } else { + Log.e("Client", "TabImage View is null"); + } + TextView tabTitle = (TextView) view.findViewById(android.R.id.title); + if (tabTitle != null) { + Log.d("Client", "TabTitle View"); + tabTitle.setGravity(Gravity.CENTER); + ViewGroup parent = (ViewGroup) tabTitle.getParent(); + parent.removeView(tabTitle); + parent.addView(tabTitle); + ViewGroup.LayoutParams params = tabTitle.getLayoutParams(); + params.height = ViewGroup.LayoutParams.MATCH_PARENT; + } else { + Log.e("Client", "TabTitle View is null"); + } + } else { + Log.e("Client", "TabWidget View is null"); + } + } + } + tabHost.setCurrentTab(1); + final Spinner channels_spinner = (Spinner) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_spinner); + final EditText channels_socks_text = (EditText) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_msg_text); + final EditText channels_output_text = (EditText) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_output_msg_text); + if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + if (global_prefs.getString("theme", "Dark").contains("Light")) { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + channels_spinner.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_spinner_light)); + } else { + channels_spinner.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_spinner)); + } + } else if (global_prefs.getString("theme", "Dark").contains("Dark")) { + if (global_prefs.getBoolean("theme_requires_restart", false) == false) { + channels_spinner.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_spinner)); + } else { + channels_spinner.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_spinner_light)); + } + } + channels_spinner.setPadding(2, 0, 2, 0); + ArrayList spinnerArray = new ArrayList(); + spinnerArray.clear(); + for (int i = 0; i < channelsArray.size(); i++) { + spinnerArray.add(new CustomSpinnerItem(channelsArray.get(i))); + } + CustomSpinnerAdapter customSpinnerAdapter = new CustomSpinnerAdapter(getApplicationContext(), spinnerArray); + channels_spinner.setAdapter(customSpinnerAdapter); + } else { + ArrayList spinnerArray = new ArrayList(); + spinnerArray.clear(); + for (int i = 0; i < channelsArray.size(); i++) { + spinnerArray.add(new CustomSpinnerItem(channelsArray.get(i))); + } + CustomSpinnerAdapter customSpinnerAdapter = new CustomSpinnerAdapter(getApplicationContext(), spinnerArray); + channels_spinner.setAdapter(customSpinnerAdapter); + } + ImageButton channels_send_btn = (ImageButton) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_send_button); + channels_send_btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (channels_output_text.getText().toString().length() > 0) { + sendingMsgText = channels_output_text.getText().toString(); + Thread send_msg_thread = new Thread(new SendSocketMsg()); + new Thread(new SendSocketMsg()).start(); + channels_socks_text.setText(channels_socks_text.getText() + "You: " + channels_output_text.getText() + "\r\n"); + channels_socks_text.setSelection(channels_socks_text.getText().length()); + channels_sb.get(channels_spinner.getSelectedItemPosition()).append("You: " + channels_output_text.getText() + "\r\n"); + } else { + Toast emptyMessageAttempting = Toast.makeText(getApplicationContext(), getString(R.string.empty_message_sending_attempt), Toast.LENGTH_SHORT); + emptyMessageAttempting.show(); + } + } + }); + channels_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView adapterView, View view, int i, long l) { + try { + channels_socks_text.setText(channels_sb.get(i).toString()); + } catch(IndexOutOfBoundsException ioofe) { + ioofe.printStackTrace(); + } + } + + @Override + public void onNothingSelected(AdapterView adapterView) { + + } + }); + } catch (IOException e) { + e.printStackTrace(); + } + } else if (outputMsgArray.get(0).startsWith("/mode") && outputMsgArray.size() > 1) { + try { + StringBuilder message_sb = new StringBuilder(); + for (int i = 1; i < outputMsgArray.size(); i++) { + if (i < outputMsgArray.size() - 1 && outputMsgArray.get(i).length() > 0) { + message_sb.append(outputMsgArray.get(i)).append(" "); + } else if (outputMsgArray.get(i).length() > 0) { + message_sb.append(outputMsgArray.get(i)); + } + } + sendingMsgText = ("MODE " + message_sb.toString() + "\r\n"); + sended_bytes_count += ("MODE " + message_sb.toString() + "\r\n").getBytes(encoding).length; + } catch (IOException e) { + e.printStackTrace(); + } + } else if (outputMsgArray.get(0).startsWith("/nick") && outputMsgArray.size() > 1) { + try { + sendingMsgText = ("NICK " + outputMsgArray.get(1) + "\r\n"); + sended_bytes_count += ("NICK " + outputMsgArray.get(1) + "\r\n").getBytes(encoding).length; + } catch (IOException e) { + e.printStackTrace(); + } + } else if (outputMsgArray.get(0).startsWith("/quit")) { + try { + sendingMsgText = ("QUIT :" + quit_msg + "\r\n"); + sended_bytes_count += ("QUIT :" + quit_msg + "\r\n").getBytes(encoding).length; + } catch (IOException e) { + e.printStackTrace(); + } + } else if (outputMsgArray.get(0).startsWith("/")) { + try { + StringBuilder message_sb = new StringBuilder(); + for (int i = 0; i < outputMsgArray.size(); i++) { + if (i < outputMsgArray.size() - 1 && outputMsgArray.get(i).length() > 0) { + message_sb.append(outputMsgArray.get(i)).append(" "); + } else if (outputMsgArray.get(i).length() > 0) { + message_sb.append(outputMsgArray.get(i)); + } + } + sendingMsgText = (message_sb.toString().substring(1) + "\r\n"); + sended_bytes_count += (message_sb.toString().substring(1) + "\r\n").getBytes(encoding).length; + } catch (Exception e) { + e.printStackTrace(); + } + } else if (!outputMsgArray.get(0).startsWith("/")) { + try { + if (channelsArray.size() > 0) { + if(tabHost.getCurrentTab() == 1) { + Spinner channels_spinner = (Spinner) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_spinner); + EditText channels_socks_msg = (EditText) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_msg_text); + EditText channels_output_msg = (EditText) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_output_msg_text); + sendingMsgText = ("PRIVMSG " + channelsArray.get(channels_spinner.getSelectedItemPosition()) + " :" + channels_output_msg.getText().toString() + "\r\n"); + sended_bytes_count += ("PRIVMSG " + channelsArray.get(channels_spinner.getSelectedItemPosition()) + " :" + channels_output_msg.getText().toString() + "\r\n").getBytes(encoding).length; + } else { + + } + } + } catch (IOException e) { + e.printStackTrace(); + } + } + if(tabHost.getCurrentTab() == 1) { + output_msg_text.setText(""); + EditText ch_output_msg_text = (EditText) tabHost.getTabContentView().getChildAt(1).findViewById(R.id.channels_output_msg_text); + ch_output_msg_text.setText(""); + } else { + output_msg_text.setText(""); + } + if(global_prefs.getBoolean("save_msg_history", false) == true) { + File directory; + directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "Tinelix"); + if (!directory.exists()) { + directory.mkdirs(); + } + + directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Tinelix", "IRC Client"); + if (!directory.exists()) { + directory.mkdirs(); + } + directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Tinelix/IRC Client", "Messages Logs"); + if (!directory.exists()) { + directory.mkdirs(); + } + + try { + Log.d("App", "Attempting creating log file..."); + File file = new File(directory, "LOG_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(dt) + ".log"); + if (!file.exists()) { + file.createNewFile(); + } + Log.d("App", "Log file created!"); + FileWriter writer = new FileWriter(file); + writer.append(socks_msg_text.getText() + socket_data_string); + writer.flush(); + writer.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } else { + Log.e("Socket", "Socket not created"); + } + } else if(state == "connecting") { + connectionDialog.cancel(); + state = "connected"; + } + } + }); + } + } +} diff --git a/android/app/src/main/res/drawable-anydpi/button_bottom_border.png b/android/app/src/main/res/drawable-anydpi/button_bottom_border.png new file mode 100644 index 0000000..ec3e42e Binary files /dev/null and b/android/app/src/main/res/drawable-anydpi/button_bottom_border.png differ diff --git a/android/app/src/main/res/drawable-hdpi/ic_menu_btn_add.png b/android/app/src/main/res/drawable-hdpi/ic_menu_btn_add.png new file mode 100644 index 0000000..444e8a5 Binary files /dev/null and b/android/app/src/main/res/drawable-hdpi/ic_menu_btn_add.png differ diff --git a/android/app/src/main/res/drawable-hdpi/ic_menu_delete.png b/android/app/src/main/res/drawable-hdpi/ic_menu_delete.png new file mode 100644 index 0000000..24d8f6a Binary files /dev/null and b/android/app/src/main/res/drawable-hdpi/ic_menu_delete.png differ diff --git a/android/app/src/main/res/drawable-hdpi/ic_menu_edit.png b/android/app/src/main/res/drawable-hdpi/ic_menu_edit.png new file mode 100644 index 0000000..9bdba1b Binary files /dev/null and b/android/app/src/main/res/drawable-hdpi/ic_menu_edit.png differ diff --git a/android/app/src/main/res/drawable-hdpi/ic_menu_moreoverflow_normal_holo_dark.png b/android/app/src/main/res/drawable-hdpi/ic_menu_moreoverflow_normal_holo_dark.png new file mode 100644 index 0000000..2abc458 Binary files /dev/null and b/android/app/src/main/res/drawable-hdpi/ic_menu_moreoverflow_normal_holo_dark.png differ diff --git a/android/app/src/main/res/drawable-hdpi/ic_menu_send.png b/android/app/src/main/res/drawable-hdpi/ic_menu_send.png new file mode 100644 index 0000000..d94e692 Binary files /dev/null and b/android/app/src/main/res/drawable-hdpi/ic_menu_send.png differ diff --git a/android/app/src/main/res/drawable-hdpi/ic_notification_icon.png b/android/app/src/main/res/drawable-hdpi/ic_notification_icon.png new file mode 100644 index 0000000..4967c45 Binary files /dev/null and b/android/app/src/main/res/drawable-hdpi/ic_notification_icon.png differ diff --git a/android/app/src/main/res/drawable-hdpi/ic_stat_name.png b/android/app/src/main/res/drawable-hdpi/ic_stat_name.png new file mode 100644 index 0000000..cf6d39f Binary files /dev/null and b/android/app/src/main/res/drawable-hdpi/ic_stat_name.png differ diff --git a/android/app/src/main/res/drawable-ldpi/checkbox_checked.png b/android/app/src/main/res/drawable-ldpi/checkbox_checked.png new file mode 100644 index 0000000..44b36cd Binary files /dev/null and b/android/app/src/main/res/drawable-ldpi/checkbox_checked.png differ diff --git a/android/app/src/main/res/drawable-ldpi/checkbox_checked_disabled.png b/android/app/src/main/res/drawable-ldpi/checkbox_checked_disabled.png new file mode 100644 index 0000000..00dff69 Binary files /dev/null and b/android/app/src/main/res/drawable-ldpi/checkbox_checked_disabled.png differ diff --git a/android/app/src/main/res/drawable-ldpi/checkbox_disabled.png b/android/app/src/main/res/drawable-ldpi/checkbox_disabled.png new file mode 100644 index 0000000..7b14ad9 Binary files /dev/null and b/android/app/src/main/res/drawable-ldpi/checkbox_disabled.png differ diff --git a/android/app/src/main/res/drawable-ldpi/checkbox_unchecked.png b/android/app/src/main/res/drawable-ldpi/checkbox_unchecked.png new file mode 100644 index 0000000..d2525ce Binary files /dev/null and b/android/app/src/main/res/drawable-ldpi/checkbox_unchecked.png differ diff --git a/android/app/src/main/res/drawable-mdpi/ic_menu_btn_add.png b/android/app/src/main/res/drawable-mdpi/ic_menu_btn_add.png new file mode 100644 index 0000000..361c7c4 Binary files /dev/null and b/android/app/src/main/res/drawable-mdpi/ic_menu_btn_add.png differ diff --git a/android/app/src/main/res/drawable-mdpi/ic_menu_delete.png b/android/app/src/main/res/drawable-mdpi/ic_menu_delete.png new file mode 100644 index 0000000..e2c8700 Binary files /dev/null and b/android/app/src/main/res/drawable-mdpi/ic_menu_delete.png differ diff --git a/android/app/src/main/res/drawable-mdpi/ic_menu_edit.png b/android/app/src/main/res/drawable-mdpi/ic_menu_edit.png new file mode 100644 index 0000000..d0314e9 Binary files /dev/null and b/android/app/src/main/res/drawable-mdpi/ic_menu_edit.png differ diff --git a/android/app/src/main/res/drawable-mdpi/ic_menu_moreoverflow_normal_holo_dark.png b/android/app/src/main/res/drawable-mdpi/ic_menu_moreoverflow_normal_holo_dark.png new file mode 100644 index 0000000..ba704b6 Binary files /dev/null and b/android/app/src/main/res/drawable-mdpi/ic_menu_moreoverflow_normal_holo_dark.png differ diff --git a/android/app/src/main/res/drawable-mdpi/ic_menu_send.png b/android/app/src/main/res/drawable-mdpi/ic_menu_send.png new file mode 100644 index 0000000..06b4717 Binary files /dev/null and b/android/app/src/main/res/drawable-mdpi/ic_menu_send.png differ diff --git a/android/app/src/main/res/drawable-mdpi/ic_notification_icon.png b/android/app/src/main/res/drawable-mdpi/ic_notification_icon.png new file mode 100644 index 0000000..c5afcba Binary files /dev/null and b/android/app/src/main/res/drawable-mdpi/ic_notification_icon.png differ diff --git a/android/app/src/main/res/drawable-mdpi/ic_stat_name.png b/android/app/src/main/res/drawable-mdpi/ic_stat_name.png new file mode 100644 index 0000000..fa7096c Binary files /dev/null and b/android/app/src/main/res/drawable-mdpi/ic_stat_name.png differ diff --git a/android/app/src/main/res/drawable-nodpi/checkbox_checked.png b/android/app/src/main/res/drawable-nodpi/checkbox_checked.png new file mode 100644 index 0000000..d414117 Binary files /dev/null and b/android/app/src/main/res/drawable-nodpi/checkbox_checked.png differ diff --git a/android/app/src/main/res/drawable-nodpi/checkbox_checked_disabled.png b/android/app/src/main/res/drawable-nodpi/checkbox_checked_disabled.png new file mode 100644 index 0000000..46c50e9 Binary files /dev/null and b/android/app/src/main/res/drawable-nodpi/checkbox_checked_disabled.png differ diff --git a/android/app/src/main/res/drawable-nodpi/checkbox_disabled.png b/android/app/src/main/res/drawable-nodpi/checkbox_disabled.png new file mode 100644 index 0000000..6f88c9c Binary files /dev/null and b/android/app/src/main/res/drawable-nodpi/checkbox_disabled.png differ diff --git a/android/app/src/main/res/drawable-nodpi/checkbox_unchecked.png b/android/app/src/main/res/drawable-nodpi/checkbox_unchecked.png new file mode 100644 index 0000000..3332669 Binary files /dev/null and b/android/app/src/main/res/drawable-nodpi/checkbox_unchecked.png differ diff --git a/android/app/src/main/res/drawable-nodpi/full_application_icon.png b/android/app/src/main/res/drawable-nodpi/full_application_icon.png new file mode 100644 index 0000000..4615929 Binary files /dev/null and b/android/app/src/main/res/drawable-nodpi/full_application_icon.png differ diff --git a/android/app/src/main/res/drawable-nodpi/spinner_arrow_dialog.png b/android/app/src/main/res/drawable-nodpi/spinner_arrow_dialog.png new file mode 100644 index 0000000..1cecc4f Binary files /dev/null and b/android/app/src/main/res/drawable-nodpi/spinner_arrow_dialog.png differ diff --git a/android/app/src/main/res/drawable-nodpi/spinner_arrow_dialog_hovered.png b/android/app/src/main/res/drawable-nodpi/spinner_arrow_dialog_hovered.png new file mode 100644 index 0000000..aa86c96 Binary files /dev/null and b/android/app/src/main/res/drawable-nodpi/spinner_arrow_dialog_hovered.png differ diff --git a/android/app/src/main/res/drawable-nodpi/spinner_arrow_dialog_light.png b/android/app/src/main/res/drawable-nodpi/spinner_arrow_dialog_light.png new file mode 100644 index 0000000..b25e21b Binary files /dev/null and b/android/app/src/main/res/drawable-nodpi/spinner_arrow_dialog_light.png differ diff --git a/android/app/src/main/res/drawable-nodpi/spinner_arrow_dialog_pressed.png b/android/app/src/main/res/drawable-nodpi/spinner_arrow_dialog_pressed.png new file mode 100644 index 0000000..82c35bc Binary files /dev/null and b/android/app/src/main/res/drawable-nodpi/spinner_arrow_dialog_pressed.png differ diff --git a/android/app/src/main/res/drawable-xhdpi/ic_menu_btn_add.png b/android/app/src/main/res/drawable-xhdpi/ic_menu_btn_add.png new file mode 100644 index 0000000..7d498a9 Binary files /dev/null and b/android/app/src/main/res/drawable-xhdpi/ic_menu_btn_add.png differ diff --git a/android/app/src/main/res/drawable-xhdpi/ic_menu_delete.png b/android/app/src/main/res/drawable-xhdpi/ic_menu_delete.png new file mode 100644 index 0000000..65b9cae Binary files /dev/null and b/android/app/src/main/res/drawable-xhdpi/ic_menu_delete.png differ diff --git a/android/app/src/main/res/drawable-xhdpi/ic_menu_edit.png b/android/app/src/main/res/drawable-xhdpi/ic_menu_edit.png new file mode 100644 index 0000000..fcdd71e Binary files /dev/null and b/android/app/src/main/res/drawable-xhdpi/ic_menu_edit.png differ diff --git a/android/app/src/main/res/drawable-xhdpi/ic_menu_moreoverflow_normal_holo_dark.png b/android/app/src/main/res/drawable-xhdpi/ic_menu_moreoverflow_normal_holo_dark.png new file mode 100644 index 0000000..a92fb1d Binary files /dev/null and b/android/app/src/main/res/drawable-xhdpi/ic_menu_moreoverflow_normal_holo_dark.png differ diff --git a/android/app/src/main/res/drawable-xhdpi/ic_menu_send.png b/android/app/src/main/res/drawable-xhdpi/ic_menu_send.png new file mode 100644 index 0000000..6e5ec78 Binary files /dev/null and b/android/app/src/main/res/drawable-xhdpi/ic_menu_send.png differ diff --git a/android/app/src/main/res/drawable-xhdpi/ic_notification_icon.png b/android/app/src/main/res/drawable-xhdpi/ic_notification_icon.png new file mode 100644 index 0000000..fd58378 Binary files /dev/null and b/android/app/src/main/res/drawable-xhdpi/ic_notification_icon.png differ diff --git a/android/app/src/main/res/drawable-xhdpi/ic_stat_name.png b/android/app/src/main/res/drawable-xhdpi/ic_stat_name.png new file mode 100644 index 0000000..ffe95a3 Binary files /dev/null and b/android/app/src/main/res/drawable-xhdpi/ic_stat_name.png differ diff --git a/android/app/src/main/res/drawable-xxhdpi/ic_notification_icon.png b/android/app/src/main/res/drawable-xxhdpi/ic_notification_icon.png new file mode 100644 index 0000000..1d5a932 Binary files /dev/null and b/android/app/src/main/res/drawable-xxhdpi/ic_notification_icon.png differ diff --git a/android/app/src/main/res/drawable-xxhdpi/ic_stat_name.png b/android/app/src/main/res/drawable-xxhdpi/ic_stat_name.png new file mode 100644 index 0000000..04ba4a3 Binary files /dev/null and b/android/app/src/main/res/drawable-xxhdpi/ic_stat_name.png differ diff --git a/android/app/src/main/res/drawable-xxxhdpi/ic_notification_icon.png b/android/app/src/main/res/drawable-xxxhdpi/ic_notification_icon.png new file mode 100644 index 0000000..c66029f Binary files /dev/null and b/android/app/src/main/res/drawable-xxxhdpi/ic_notification_icon.png differ diff --git a/android/app/src/main/res/drawable-xxxhdpi/ic_stat_name.png b/android/app/src/main/res/drawable-xxxhdpi/ic_stat_name.png new file mode 100644 index 0000000..482376a Binary files /dev/null and b/android/app/src/main/res/drawable-xxxhdpi/ic_stat_name.png differ diff --git a/android/app/src/main/res/drawable/checkbox.xml b/android/app/src/main/res/drawable/checkbox.xml new file mode 100644 index 0000000..bdce318 --- /dev/null +++ b/android/app/src/main/res/drawable/checkbox.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/dialog_spinner.xml b/android/app/src/main/res/drawable/dialog_spinner.xml new file mode 100644 index 0000000..9e46a9b --- /dev/null +++ b/android/app/src/main/res/drawable/dialog_spinner.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/dialog_spinner_light.xml b/android/app/src/main/res/drawable/dialog_spinner_light.xml new file mode 100644 index 0000000..01a9b3b --- /dev/null +++ b/android/app/src/main/res/drawable/dialog_spinner_light.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/dialog_textarea.xml b/android/app/src/main/res/drawable/dialog_textarea.xml new file mode 100644 index 0000000..0cb075c --- /dev/null +++ b/android/app/src/main/res/drawable/dialog_textarea.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/dialog_textarea_light.xml b/android/app/src/main/res/drawable/dialog_textarea_light.xml new file mode 100644 index 0000000..a7faf8a --- /dev/null +++ b/android/app/src/main/res/drawable/dialog_textarea_light.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/successfully_state_shape.xml b/android/app/src/main/res/drawable/successfully_state_shape.xml new file mode 100644 index 0000000..8ca0924 --- /dev/null +++ b/android/app/src/main/res/drawable/successfully_state_shape.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/tabwidget.xml b/android/app/src/main/res/drawable/tabwidget.xml new file mode 100644 index 0000000..df9df9b --- /dev/null +++ b/android/app/src/main/res/drawable/tabwidget.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/tabwidget_default.xml b/android/app/src/main/res/drawable/tabwidget_default.xml new file mode 100644 index 0000000..989948b --- /dev/null +++ b/android/app/src/main/res/drawable/tabwidget_default.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/tabwidget_selected.xml b/android/app/src/main/res/drawable/tabwidget_selected.xml new file mode 100644 index 0000000..5753c6c --- /dev/null +++ b/android/app/src/main/res/drawable/tabwidget_selected.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/app/src/main/res/drawable/textarea.xml b/android/app/src/main/res/drawable/textarea.xml new file mode 100644 index 0000000..12e2e38 --- /dev/null +++ b/android/app/src/main/res/drawable/textarea.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/layout-ldpi/checkbox_prefw.xml b/android/app/src/main/res/layout-ldpi/checkbox_prefw.xml new file mode 100644 index 0000000..fb96fb9 --- /dev/null +++ b/android/app/src/main/res/layout-ldpi/checkbox_prefw.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/layout-v11/about_application_activity.xml b/android/app/src/main/res/layout-v11/about_application_activity.xml new file mode 100644 index 0000000..84cdecd --- /dev/null +++ b/android/app/src/main/res/layout-v11/about_application_activity.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + +