diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..b26bae80
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,12 @@
+# Gradle / Android Studio
+build/
+.idea/
+.gradle/
+*.iml
+signing.gradle
+
+# Android
+local.properties
+
+# Java
+*.class
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 00000000..b2dffe1b
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,6 @@
+[submodule "Plumble/libraries/Jumble"]
+ path = Plumble/libraries/Jumble
+ url = https://www.github.com/Morlunk/Jumble.git
+[submodule "Plumble/libraries/libonionkit"]
+ path = Plumble/libraries/libonionkit
+ url = https://www.github.com/Morlunk/OnionKit.git
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 00000000..94a9ed02
--- /dev/null
+++ b/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/Plumble/build.gradle b/Plumble/build.gradle
new file mode 100644
index 00000000..10fbb0b8
--- /dev/null
+++ b/Plumble/build.gradle
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+
+
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.7.+'
+ }
+}
+apply plugin: 'android'
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ compile project("libraries:Jumble")
+ compile project("libraries:libonionkit")
+ compile 'com.android.support:support-v4:19.0.+'
+ compile 'com.android.support:appcompat-v7:19.0.+'
+ compile 'com.google.guava:guava:15.+'
+}
+
+
+// Keep my credentials private :^)
+signingFile = file 'signing.gradle';
+if(signingFile.exists()) apply from: 'signing.gradle'
+
+android {
+ compileSdkVersion 19
+ buildToolsVersion "19.0.1"
+
+ defaultConfig {
+ minSdkVersion 9
+ targetSdkVersion 19
+ }
+
+ productFlavors {
+ official {
+ packageName "com.morlunk.mumbleclient"
+ }
+
+ jenkins {
+ packageName "com.morlunk.mumbleclient.jenkins"
+ }
+ }
+}
+
+// Add Jumble's built native libs - hack
+tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
+ pkgTask.jniFolders = new HashSet()
+ pkgTask.jniFolders.add(new File(project("libraries:Jumble").buildDir, 'native-libs'))
+}
\ No newline at end of file
diff --git a/Plumble/libraries/Jumble b/Plumble/libraries/Jumble
new file mode 160000
index 00000000..0833aa5a
--- /dev/null
+++ b/Plumble/libraries/Jumble
@@ -0,0 +1 @@
+Subproject commit 0833aa5a494216b652d2e7db911246df91e9ab98
diff --git a/Plumble/libraries/libonionkit b/Plumble/libraries/libonionkit
new file mode 160000
index 00000000..86f8022d
--- /dev/null
+++ b/Plumble/libraries/libonionkit
@@ -0,0 +1 @@
+Subproject commit 86f8022da2d544b19d163c43cf658b6ffe621496
diff --git a/Plumble/src/jenkins/ic_launcher-web.png b/Plumble/src/jenkins/ic_launcher-web.png
new file mode 100644
index 00000000..d7de51d5
Binary files /dev/null and b/Plumble/src/jenkins/ic_launcher-web.png differ
diff --git a/Plumble/src/jenkins/res/drawable-hdpi/ic_launcher.png b/Plumble/src/jenkins/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 00000000..544858c6
Binary files /dev/null and b/Plumble/src/jenkins/res/drawable-hdpi/ic_launcher.png differ
diff --git a/Plumble/src/jenkins/res/drawable-mdpi/ic_launcher.png b/Plumble/src/jenkins/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 00000000..b94d2db2
Binary files /dev/null and b/Plumble/src/jenkins/res/drawable-mdpi/ic_launcher.png differ
diff --git a/Plumble/src/jenkins/res/drawable-xhdpi/ic_launcher.png b/Plumble/src/jenkins/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 00000000..57887534
Binary files /dev/null and b/Plumble/src/jenkins/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/Plumble/src/jenkins/res/drawable-xxhdpi/ic_launcher.png b/Plumble/src/jenkins/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 00000000..acde6b92
Binary files /dev/null and b/Plumble/src/jenkins/res/drawable-xxhdpi/ic_launcher.png differ
diff --git a/Plumble/src/jenkins/res/values/strings.xml b/Plumble/src/jenkins/res/values/strings.xml
new file mode 100644
index 00000000..15733874
--- /dev/null
+++ b/Plumble/src/jenkins/res/values/strings.xml
@@ -0,0 +1,21 @@
+
+
+
+
+ Plumble Nightly
+
\ No newline at end of file
diff --git a/Plumble/src/main/AndroidManifest.xml b/Plumble/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..b9a92a5d
--- /dev/null
+++ b/Plumble/src/main/AndroidManifest.xml
@@ -0,0 +1,86 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/Constants.java b/Plumble/src/main/java/com/morlunk/mumbleclient/Constants.java
new file mode 100644
index 00000000..bf3e4ff6
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/Constants.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient;
+
+public class Constants {
+ public static final String TAG = "Plumble";
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/Settings.java b/Plumble/src/main/java/com/morlunk/mumbleclient/Settings.java
new file mode 100644
index 00000000..4eb7519e
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/Settings.java
@@ -0,0 +1,256 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
+import android.preference.PreferenceManager;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+/**
+ * Singleton settings class for universal access to the app's preferences.
+ * @author morlunk
+ */
+public class Settings {
+ public static final String PREF_CALL_MODE = "callMode";
+ public static final String ARRAY_CALL_MODE_SPEAKER = "speakerphone";
+ public static final String ARRAY_CALL_MODE_VOICE = "voice";
+
+ public static final String PREF_INPUT_METHOD = "audioInputMethod";
+ public static final String ARRAY_INPUT_METHOD_VOICE = "voiceActivity";
+ public static final String ARRAY_INPUT_METHOD_PTT = "ptt";
+ public static final String ARRAY_INPUT_METHOD_CONTINUOUS = "continuous";
+
+ public static final String PREF_THRESHOLD = "vadThreshold";
+ public static final int DEFAULT_THRESHOLD = 50;
+
+ public static final String PREF_PUSH_KEY = "talkKey";
+ public static final Integer DEFAULT_PUSH_KEY = -1;
+
+ public static final String PREF_HOT_CORNER_KEY = "hotCorner";
+ public static final String ARRAY_HOT_CORNER_NONE = "none";
+ public static final String ARRAY_HOT_CORNER_TOP_LEFT = "topLeft";
+ public static final String ARRAY_HOT_CORNER_BOTTOM_LEFT = "bottomLeft";
+ public static final String ARRAY_HOT_CORNER_TOP_RIGHT = "topRight";
+ public static final String ARRAY_HOT_CORNER_BOTTOM_RIGHT = "bottomRight";
+ public static final String DEFAULT_HOT_CORNER = ARRAY_HOT_CORNER_NONE;
+
+ public static final String PREF_PUSH_BUTTON_HIDE_KEY = "hidePtt";
+ public static final Boolean DEFAULT_PUSH_BUTTON_HIDE = false;
+
+ public static final String PREF_PTT_TOGGLE = "togglePtt";
+ public static final Boolean DEFAULT_PTT_TOGGLE = false;
+
+ public static final String PREF_INPUT_QUALITY = "input_quality";
+ public static final String DEFAULT_QUALITY = "48000";
+
+ public static final String PREF_AMPLITUDE_BOOST = "inputVolume";
+ public static final Integer DEFAULT_AMPLITUDE_BOOST = 100;
+
+ public static final String PREF_CHAT_NOTIFY = "chatNotify";
+ public static final Boolean DEFAULT_CHAT_NOTIFY = true;
+
+ public static final String PREF_USE_TTS = "useTts";
+ public static final Boolean DEFAULT_USE_TTS = true;
+
+ public static final String PREF_AUTO_RECONNECT = "autoReconnect";
+ public static final Boolean DEFAULT_AUTO_RECONNECT = true;
+
+ public static final String PREF_THEME = "theme";
+ public static final String ARRAY_THEME_LIGHT = "lightDark";
+ public static final String ARRAY_THEME_DARK = "dark";
+ public static final String ARRAY_THEME_SOLARIZED_LIGHT = "solarizedLight";
+ public static final String ARRAY_THEME_SOLARIZED_DARK = "solarizedDark";
+
+ public static final String PREF_CERT = "certificatePath";
+ public static final String PREF_CERT_PASSWORD = "certificatePassword";
+
+ public static final String PREF_DEFAULT_USERNAME = "defaultUsername";
+ public static final String DEFAULT_DEFAULT_USERNAME = "Plumble_User"; // funny var name
+
+ public static final String PREF_FORCE_TCP = "forceTcp";
+ public static final Boolean DEFAULT_FORCE_TCP = false;
+
+ public static final String PREF_USE_TOR = "useTor";
+ public static final Boolean DEFAULT_USE_TOR = false;
+
+ public static final String PREF_DISABLE_OPUS = "disableOpus";
+ public static final Boolean DEFAULT_DISABLE_OPUS = false;
+
+ public static final String PREF_MUTED = "muted";
+ public static final Boolean DEFAULT_MUTED = false;
+
+ public static final String PREF_DEAFENED = "deafened";
+ public static final Boolean DEFAULT_DEAFENED = false;
+
+ public static final String PREF_FIRST_RUN = "firstRun";
+ public static final Boolean DEFAULT_FIRST_RUN = true;
+
+ private final SharedPreferences preferences;
+
+ private static Settings settings;
+
+ public static Settings getInstance(Context context) {
+ if(settings == null)
+ settings = new Settings(context);
+ return settings;
+ }
+
+ private Settings(Context ctx) {
+ preferences = PreferenceManager.getDefaultSharedPreferences(ctx);
+ }
+
+ public String getInputMethod() {
+ return preferences.getString(PREF_INPUT_METHOD, ARRAY_INPUT_METHOD_VOICE);
+ }
+
+ public String getCallMode() {
+ return preferences.getString(PREF_CALL_MODE, ARRAY_CALL_MODE_SPEAKER);
+ }
+
+ public int getAudioQuality() {
+ return Integer.parseInt(preferences.getString(Settings.PREF_INPUT_QUALITY, DEFAULT_QUALITY));
+ }
+
+ public float getAmplitudeBoostMultiplier() {
+ return (float)preferences.getInt(Settings.PREF_AMPLITUDE_BOOST, DEFAULT_AMPLITUDE_BOOST)/100;
+ }
+
+ public float getDetectionThreshold() {
+ return (float)preferences.getInt(PREF_THRESHOLD, DEFAULT_THRESHOLD)/100;
+ }
+
+ public int getPushToTalkKey() {
+ return preferences.getInt(PREF_PUSH_KEY, DEFAULT_PUSH_KEY);
+ }
+
+ public String getHotCorner() {
+ return preferences.getString(PREF_HOT_CORNER_KEY, DEFAULT_HOT_CORNER);
+ }
+
+ /**
+ * @return the resource ID of the user-defined theme.
+ */
+ public int getTheme() {
+ String theme = preferences.getString(PREF_THEME, ARRAY_THEME_LIGHT);
+ if(ARRAY_THEME_LIGHT.equals(theme))
+ return R.style.Theme_Plumble;
+ else if(ARRAY_THEME_DARK.equals(theme))
+ return R.style.Theme_Plumble_Dark;
+ else if(ARRAY_THEME_SOLARIZED_LIGHT.equals(theme))
+ return R.style.Theme_Plumble_Solarized_Light;
+ else if(ARRAY_THEME_SOLARIZED_DARK.equals(theme))
+ return R.style.Theme_Plumble_Solarized_Dark;
+ return -1;
+ }
+
+ /**
+ * Attempts to read the certificate from the path specified in settings.
+ * @return The parsed bytes of the certificate, or null otherwise.
+ */
+ public byte[] getCertificate() {
+ try {
+ FileInputStream inputStream = new FileInputStream(preferences.getString(PREF_CERT, ""));
+ byte[] buffer = new byte[inputStream.available()];
+ inputStream.read(buffer);
+ return buffer;
+ } catch (FileNotFoundException e) {
+ return null;
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public boolean isUsingCertificate() {
+ return preferences.contains(PREF_CERT);
+ }
+
+ public String getCertificatePassword() {
+ return preferences.getString(PREF_CERT_PASSWORD, "");
+ }
+
+ public String getDefaultUsername() {
+ return preferences.getString(PREF_DEFAULT_USERNAME, DEFAULT_DEFAULT_USERNAME);
+ }
+
+ public boolean isPushToTalkToggle() {
+ return preferences.getBoolean(PREF_PTT_TOGGLE, DEFAULT_PTT_TOGGLE);
+ }
+
+ public boolean isPushToTalkButtonShown() {
+ return !preferences.getBoolean(PREF_PUSH_BUTTON_HIDE_KEY, DEFAULT_PUSH_BUTTON_HIDE);
+ }
+
+ public boolean isChatNotifyEnabled() {
+ return preferences.getBoolean(PREF_CHAT_NOTIFY, DEFAULT_CHAT_NOTIFY);
+ }
+
+ public boolean isTextToSpeechEnabled() {
+ return preferences.getBoolean(PREF_USE_TTS, DEFAULT_USE_TTS);
+ }
+
+ public boolean isAutoReconnectEnabled() {
+ return preferences.getBoolean(PREF_AUTO_RECONNECT, DEFAULT_AUTO_RECONNECT);
+ }
+
+ public boolean isTcpForced() {
+ return preferences.getBoolean(PREF_FORCE_TCP, DEFAULT_FORCE_TCP);
+ }
+
+ public boolean isOpusDisabled() {
+ return preferences.getBoolean(PREF_DISABLE_OPUS, DEFAULT_DISABLE_OPUS);
+ }
+
+ public boolean isTorEnabled() {
+ return preferences.getBoolean(PREF_USE_TOR, DEFAULT_USE_TOR);
+ }
+
+ public boolean isMuted() {
+ return preferences.getBoolean(PREF_MUTED, DEFAULT_MUTED);
+ }
+
+ public boolean isDeafened() {
+ return preferences.getBoolean(PREF_DEAFENED, DEFAULT_DEAFENED);
+ }
+
+ public boolean isFirstRun() {
+ return preferences.getBoolean(PREF_FIRST_RUN, DEFAULT_FIRST_RUN);
+ }
+
+ public void setMutedAndDeafened(boolean muted, boolean deafened) {
+ Editor editor = preferences.edit();
+ editor.putBoolean(PREF_MUTED, muted || deafened);
+ editor.putBoolean(PREF_DEAFENED, deafened);
+ editor.commit();
+ }
+
+ public void setCertificatePath(String path) {
+ Editor editor = preferences.edit();
+ editor.putString(PREF_CERT, path);
+ editor.commit();
+ }
+
+ public void setFirstRun(boolean run) {
+ preferences.edit().putBoolean(PREF_FIRST_RUN, run).commit();
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/app/DrawerAdapter.java b/Plumble/src/main/java/com/morlunk/mumbleclient/app/DrawerAdapter.java
new file mode 100644
index 00000000..159eced7
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/app/DrawerAdapter.java
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.app;
+
+import android.content.Context;
+import android.graphics.PorterDuff;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.morlunk.mumbleclient.R;
+
+/**
+ * Created by andrew on 01/08/13.
+ */
+public class DrawerAdapter extends ArrayAdapter {
+
+ /**
+ * Provides context for the drawer module.
+ */
+ public interface DrawerDataProvider {
+
+ /**
+ * @return true if connected, false otherwise.
+ */
+ public boolean isConnected();
+ /**
+ * @return The name of the connected server. If not connected, then null.
+ */
+ public String getConnectedServerName();
+ }
+
+ // Drawer rows, integer value is id
+ public static final int HEADER_CONNECTED_SERVER = 0;
+ public static final int ITEM_SERVER = 1;
+ public static final int ITEM_INFO = 2;
+ public static final int ITEM_ACCESS_TOKENS = 3;
+ public static final int ITEM_PINNED_CHANNELS = 4;
+ public static final int HEADER_SERVERS = 5;
+ public static final int ITEM_FAVOURITES = 6;
+ public static final int ITEM_LAN = 7;
+ public static final int ITEM_PUBLIC = 8;
+
+ private static final int HEADER_TYPE = 0;
+ private static final int ITEM_TYPE = 1;
+
+ // TODO clean this up.
+
+ public static class DrawerRow {
+ int id;
+ String title;
+
+ private DrawerRow(int id, String title) {
+ this.id = id;
+ this.title = title;
+ }
+ }
+
+ public static class DrawerHeader extends DrawerRow {
+
+ public DrawerHeader(int id, String title) {
+ super(id, title);
+ }
+ }
+
+ public static class DrawerItem extends DrawerRow {
+ int icon;
+
+ public DrawerItem(int id, String title, int icon) {
+ super(id, title);
+ this.icon = icon;
+ }
+ }
+
+ private DrawerDataProvider mProvider;
+
+ public DrawerAdapter(Context context, DrawerDataProvider provider) {
+ super(context, 0);
+ mProvider = provider;
+ add(new DrawerAdapter.DrawerHeader(HEADER_CONNECTED_SERVER, context.getString(R.string.drawer_not_connected)));
+ add(new DrawerAdapter.DrawerItem(ITEM_SERVER, context.getString(R.string.drawer_server), R.drawable.ic_action_channels));
+ add(new DrawerAdapter.DrawerItem(ITEM_INFO, context.getString(R.string.information), R.drawable.ic_action_info_dark));
+ add(new DrawerAdapter.DrawerItem(ITEM_ACCESS_TOKENS, context.getString(R.string.drawer_tokens), R.drawable.ic_action_save));
+ add(new DrawerAdapter.DrawerItem(ITEM_PINNED_CHANNELS, context.getString(R.string.drawer_pinned), R.drawable.ic_action_comment));
+ add(new DrawerAdapter.DrawerHeader(HEADER_SERVERS, context.getString(R.string.drawer_header_servers)));
+ add(new DrawerAdapter.DrawerItem(ITEM_FAVOURITES, context.getString(R.string.drawer_favorites), R.drawable.ic_action_favourite_on));
+ add(new DrawerAdapter.DrawerItem(ITEM_LAN, context.getString(R.string.drawer_lan), R.drawable.ic_action_fullscreen)); // Coming soon, TODO
+ add(new DrawerAdapter.DrawerItem(ITEM_PUBLIC, context.getString(R.string.drawer_public), R.drawable.ic_action_search));
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View v = convertView;
+ int viewType = getItemViewType(position);
+ if(v == null) {
+ if(viewType == HEADER_TYPE)
+ v = LayoutInflater.from(getContext()).inflate(R.layout.list_drawer_header, null, false);
+ else if(viewType == ITEM_TYPE)
+ v = LayoutInflater.from(getContext()).inflate(R.layout.list_drawer_item, null, false);
+
+ }
+
+ if(viewType == HEADER_TYPE) {
+ DrawerHeader header = (DrawerHeader) getItem(position);
+ TextView title = (TextView) v.findViewById(R.id.drawer_header_title);
+
+ switch((int) getItemId(position)) {
+ case HEADER_CONNECTED_SERVER:
+ if(mProvider.isConnected()) {
+ title.setText(mProvider.getConnectedServerName());
+ break;
+ }
+ default:
+ title.setText(header.title);
+ break;
+ }
+ } else if(viewType == ITEM_TYPE) {
+ DrawerItem item = (DrawerItem) getItem(position);
+ TextView title = (TextView) v.findViewById(R.id.drawer_item_title);
+ ImageView icon = (ImageView) v.findViewById(R.id.drawer_item_icon);
+ title.setText(item.title);
+ icon.setImageResource(item.icon);
+
+ boolean enabled = isEnabled(position);
+
+ // Set text and icon color+alpha based on enabled/disabled state
+ int textColor = title.getCurrentTextColor();
+ textColor &= ~(0xFF << 60); // Clear alpha bits
+ textColor |= enabled ? 0xFF << 60 : 0x55 << 60; // Set alpha bits depending on whether the state is enabled or disabled
+ title.setTextColor(textColor);
+ icon.setColorFilter(textColor, PorterDuff.Mode.MULTIPLY);
+
+ }
+
+ return v;
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return getItem(position).id;
+ }
+
+ public DrawerRow getItemWithId(int id) {
+ for(int x=0;x.
+ */
+
+package com.morlunk.mumbleclient.app;
+
+import android.app.AlertDialog;
+import android.app.ProgressDialog;
+import android.content.ComponentName;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
+import android.content.res.Configuration;
+import android.graphics.PorterDuff;
+import android.graphics.drawable.Drawable;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.preference.PreferenceManager;
+import android.support.v4.app.ActionBarDrawerToggle;
+import android.support.v4.app.Fragment;
+import android.support.v4.widget.DrawerLayout;
+import android.support.v7.app.ActionBarActivity;
+import android.view.KeyEvent;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.EditText;
+import android.widget.ListView;
+import android.widget.Toast;
+
+import com.morlunk.jumble.Constants;
+import com.morlunk.jumble.IJumbleService;
+import com.morlunk.jumble.JumbleService;
+import com.morlunk.jumble.model.Server;
+import com.morlunk.jumble.net.JumbleObserver;
+import com.morlunk.mumbleclient.R;
+import com.morlunk.mumbleclient.Settings;
+import com.morlunk.mumbleclient.channel.AccessTokenFragment;
+import com.morlunk.mumbleclient.channel.ChannelFragment;
+import com.morlunk.mumbleclient.channel.ServerInfoFragment;
+import com.morlunk.mumbleclient.db.DatabaseProvider;
+import com.morlunk.mumbleclient.db.PlumbleDatabase;
+import com.morlunk.mumbleclient.db.PlumbleSQLiteDatabase;
+import com.morlunk.mumbleclient.db.PublicServer;
+import com.morlunk.mumbleclient.preference.PlumbleCertificateGenerateTask;
+import com.morlunk.mumbleclient.preference.Preferences;
+import com.morlunk.mumbleclient.servers.PublicServerListFragment;
+import com.morlunk.mumbleclient.servers.ServerEditFragment;
+import com.morlunk.mumbleclient.servers.ServerListFragment;
+import com.morlunk.mumbleclient.service.PlumbleService;
+import com.morlunk.mumbleclient.util.JumbleServiceFragment;
+import com.morlunk.mumbleclient.util.JumbleServiceProvider;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class PlumbleActivity extends ActionBarActivity implements ListView.OnItemClickListener, ServerListFragment.ServerConnectHandler, JumbleServiceProvider, DatabaseProvider, SharedPreferences.OnSharedPreferenceChangeListener, DrawerAdapter.DrawerDataProvider, ServerEditFragment.ServerEditListener {
+
+ /** Broadcasted when the activity gains focus. Used to dismiss chat notifications, bit of a hack. */
+ public static final String ACTION_PLUMBLE_SHOWN = "com.morlunk.mumbleclient.ACTION_PLUMBLE_SHOWN";
+ public static final Pattern MUMBLE_URL_REGEX = Pattern.compile("mumble://((.+)(:.+)?@)?(.+?)(:([0-9]+))?/");
+ public static final int RECONNECT_DELAY = 10000;
+
+ private static final String SAVED_FRAGMENT_TAG = "fragment";
+
+ private IJumbleService mService;
+ private PlumbleDatabase mDatabase;
+ private Settings mSettings;
+
+ private ActionBarDrawerToggle mDrawerToggle;
+ private DrawerLayout mDrawerLayout;
+ private ListView mDrawerList;
+ private DrawerAdapter mDrawerAdapter;
+ private int mActiveFragment;
+
+ private ProgressDialog mConnectingDialog;
+ private AlertDialog mErrorDialog;
+
+ /** List of fragments to be notified about service state changes. */
+ private List mServiceFragments = new ArrayList();
+
+ private ServiceConnection mConnection = new ServiceConnection() {
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ mService = (IJumbleService) service;
+ try {
+ mService.registerObserver(mObserver);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ mDrawerAdapter.notifyDataSetChanged();
+
+ for(JumbleServiceFragment fragment : mServiceFragments)
+ fragment.setServiceBound(true);
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ for(JumbleServiceFragment fragment : mServiceFragments)
+ fragment.setServiceBound(false);
+ }
+ };
+
+ private JumbleObserver mObserver = new JumbleObserver() {
+ @Override
+ public void onConnected() throws RemoteException {
+ loadDrawerFragment(DrawerAdapter.ITEM_SERVER);
+ mDrawerAdapter.notifyDataSetChanged();
+ supportInvalidateOptionsMenu();
+
+ mConnectingDialog.dismiss();
+ if(mErrorDialog != null) mErrorDialog.dismiss();
+ }
+
+ @Override
+ public void onDisconnected() throws RemoteException {
+ // Re-show server list if we're showing a fragment that depends on the service.
+ if(getSupportFragmentManager().findFragmentById(R.id.content_frame) instanceof JumbleServiceFragment) {
+ loadDrawerFragment(DrawerAdapter.ITEM_FAVOURITES);
+ }
+ mDrawerAdapter.notifyDataSetChanged();
+ supportInvalidateOptionsMenu();
+
+ mConnectingDialog.dismiss();
+ }
+
+ @Override
+ public void onConnectionError(String message, boolean reconnecting) throws RemoteException {
+ if(mErrorDialog != null) mErrorDialog.dismiss();
+ mConnectingDialog.dismiss();
+
+ AlertDialog.Builder ab = new AlertDialog.Builder(PlumbleActivity.this);
+ if(!reconnecting) {
+ ab.setTitle(R.string.connectionRefused);
+ ab.setMessage(message);
+ ab.setPositiveButton(android.R.string.ok, null);
+ } else {
+ ab.setTitle(R.string.connectionRefused);
+ ab.setMessage(message+"\n"+getString(R.string.reconnecting, RECONNECT_DELAY/1000));
+ ab.setPositiveButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if(getService() != null) {
+ try {
+ getService().cancelReconnect();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ });
+ }
+ mErrorDialog = ab.show();
+ }
+
+ @Override
+ public void onPermissionDenied(String reason) throws RemoteException {
+ AlertDialog.Builder adb = new AlertDialog.Builder(PlumbleActivity.this);
+ adb.setTitle(R.string.perm_denied);
+ adb.setMessage(reason);
+ adb.show();
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ mSettings = Settings.getInstance(this);
+ setTheme(mSettings.getTheme()); // Set custom theme
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
+ preferences.registerOnSharedPreferenceChangeListener(this);
+
+ mDatabase = new PlumbleSQLiteDatabase(this); // TODO add support for cloud storage
+
+ mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+ mDrawerList = (ListView) findViewById(R.id.left_drawer);
+ mDrawerList.setOnItemClickListener(this);
+ mDrawerAdapter = new DrawerAdapter(this, this);
+ mDrawerList.setAdapter(mDrawerAdapter);
+ mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) {
+ @Override
+ public void onDrawerClosed(View drawerView) {
+ supportInvalidateOptionsMenu();
+ }
+
+ @Override
+ public void onDrawerOpened(View drawerView) {
+ supportInvalidateOptionsMenu();
+ }
+ };
+ mDrawerLayout.setDrawerListener(mDrawerToggle);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setHomeButtonEnabled(true);
+
+ mConnectingDialog = new ProgressDialog(this);
+ mConnectingDialog.setIndeterminate(true);
+ mConnectingDialog.setCancelable(true);
+ mConnectingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ try {
+ mService.disconnect();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ // Restore old fragment or load server list (default)
+ int fragmentId = DrawerAdapter.ITEM_FAVOURITES;
+ if(savedInstanceState != null)
+ fragmentId = savedInstanceState.getInt(SAVED_FRAGMENT_TAG, DrawerAdapter.ITEM_FAVOURITES);
+ loadDrawerFragment(fragmentId);
+
+ // If we're given a Mumble URL to show, open up a server edit fragment.
+ if(getIntent() != null &&
+ Intent.ACTION_VIEW.equals(getIntent().getAction())) {
+ String url = getIntent().getDataString();
+ Matcher matcher = MUMBLE_URL_REGEX.matcher(url);
+ if(!matcher.find()) {
+ Toast.makeText(this, getString(R.string.mumble_url_parse_failed), Toast.LENGTH_LONG).show();
+ return;
+ }
+
+ // Any optional fields that failed to match will return null.
+ final String username = matcher.group(2);
+ final String password = matcher.group(3);
+ final String host = matcher.group(4);
+ final String port = matcher.group(6);
+
+ Server server = new Server(-1, "", host, Integer.valueOf(port), username, password);
+
+ // Open a dialog prompting the user to add the Mumble server.
+ Bundle args = new Bundle();
+ args.putBoolean("save", false);
+ args.putParcelable("server", server);
+ ServerEditFragment fragment = (ServerEditFragment) ServerEditFragment.instantiate(this, ServerEditFragment.class.getName(), args);
+ fragment.show(getSupportFragmentManager(), "url_edit");
+ }
+ if(mSettings.isFirstRun()) showSetupWizard();
+ }
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ mDrawerToggle.syncState();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ Intent connectIntent = new Intent(this, PlumbleService.class);
+ bindService(connectIntent, mConnection, BIND_AUTO_CREATE);
+
+ Intent resumeIntent = new Intent(ACTION_PLUMBLE_SHOWN);
+ sendBroadcast(resumeIntent);
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ if(mService != null)
+ try {
+ mService.unregisterObserver(mObserver);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ unbindService(mConnection);
+ }
+
+ @Override
+ protected void onDestroy() {
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
+ preferences.unregisterOnSharedPreferenceChangeListener(this);
+ super.onDestroy();
+ }
+
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ MenuItem disconnectButton = menu.findItem(R.id.action_disconnect);
+ try {
+ disconnectButton.setVisible(mService != null && mService.isConnected());
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+
+ // Color the action bar icons to the primary text color of the theme, TODO optimize
+ int foregroundColor = getTheme().obtainStyledAttributes(new int[] { android.R.attr.textColorPrimaryInverse }).getColor(0, -1);
+ for(int x=0;x parent, View view, int position, long id) {
+ mDrawerLayout.closeDrawers();
+ loadDrawerFragment((int) id);
+ }
+
+ /**
+ * Shows a nice looking setup wizard to guide the user through the app's settings.
+ * Will do nothing if it isn't the first launch.
+ */
+ private void showSetupWizard() {
+ // Prompt the user to generate a certificate, FIXME
+ if(mSettings.isUsingCertificate()) return;
+ AlertDialog.Builder adb = new AlertDialog.Builder(this);
+ adb.setTitle(R.string.first_run_generate_certificate_title);
+ adb.setMessage(R.string.first_run_generate_certificate);
+ adb.setPositiveButton(R.string.generate, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ PlumbleCertificateGenerateTask generateTask = new PlumbleCertificateGenerateTask(PlumbleActivity.this) {
+ @Override
+ protected void onPostExecute(File result) {
+ super.onPostExecute(result);
+ mSettings.setCertificatePath(result.getAbsolutePath());
+ }
+ };
+ generateTask.execute();
+ }
+ });
+ adb.show();
+ mSettings.setFirstRun(false);
+
+ // TODO: finish wizard
+// Intent intent = new Intent(this, WizardActivity.class);
+// startActivity(intent);
+ }
+
+ /**
+ * Loads a fragment from the drawer.
+ */
+ private void loadDrawerFragment(int fragmentId) {
+ Class extends Fragment> fragmentClass = null;
+ Bundle args = new Bundle();
+ switch (fragmentId) {
+ case DrawerAdapter.ITEM_SERVER:
+ fragmentClass = ChannelFragment.class;
+ break;
+ case DrawerAdapter.ITEM_INFO:
+ fragmentClass = ServerInfoFragment.class;
+ break;
+ case DrawerAdapter.ITEM_ACCESS_TOKENS:
+ fragmentClass = AccessTokenFragment.class;
+ try {
+ args.putLong("server", mService.getConnectedServer().getId());
+ args.putStringArrayList("access_tokens", (ArrayList) mDatabase.getAccessTokens(mService.getConnectedServer().getId()));
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ break;
+ case DrawerAdapter.ITEM_PINNED_CHANNELS:
+ fragmentClass = ChannelFragment.class;
+ args.putBoolean("pinned", true);
+ break;
+ case DrawerAdapter.ITEM_FAVOURITES:
+ fragmentClass = ServerListFragment.class;
+ break;
+ case DrawerAdapter.ITEM_LAN:
+ break;
+ case DrawerAdapter.ITEM_PUBLIC:
+ fragmentClass = PublicServerListFragment.class;
+ break;
+ default:
+ return;
+ }
+ Fragment fragment = Fragment.instantiate(this, fragmentClass.getName(), args);
+ getSupportFragmentManager().beginTransaction()
+ .replace(R.id.content_frame, fragment, fragmentClass.getName())
+ .commit();
+ setTitle(mDrawerAdapter.getItemWithId(fragmentId).title);
+ mActiveFragment = fragmentId;
+ }
+
+ public void connectToServer(final Server server) {
+ // Check if we're already connected to a server; if so, inform user.
+ try {
+ if(mService != null && mService.isConnected()) {
+ AlertDialog.Builder adb = new AlertDialog.Builder(this);
+ adb.setMessage(R.string.reconnect_dialog_message);
+ adb.setPositiveButton(R.string.connect, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ try {
+ // Register an observer to reconnect to the new server once disconnected.
+ mService.registerObserver(new JumbleObserver() {
+ @Override
+ public void onDisconnected() throws RemoteException {
+ connectToServer(server);
+ mService.unregisterObserver(this);
+ }
+ });
+ mService.disconnect();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ adb.setNegativeButton(android.R.string.cancel, null);
+ adb.show();
+ return;
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+
+ mConnectingDialog.setMessage(getString(R.string.connecting_to_server, server.getHost(), server.getPort()));
+ mConnectingDialog.show();
+
+ /* Convert input method defined in settings to an integer format used by Jumble. */
+ int inputMethod = 0;
+ String prefInputMethod = mSettings.getInputMethod();
+ if(Settings.ARRAY_INPUT_METHOD_VOICE.equals(prefInputMethod))
+ inputMethod = Constants.TRANSMIT_VOICE_ACTIVITY;
+ if(Settings.ARRAY_INPUT_METHOD_PTT.equals(prefInputMethod))
+ inputMethod = Constants.TRANSMIT_PUSH_TO_TALK;
+ if(Settings.ARRAY_INPUT_METHOD_CONTINUOUS.equals(prefInputMethod))
+ inputMethod = Constants.TRANSMIT_CONTINUOUS;
+
+ String applicationVersion = "";
+ try {
+ applicationVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
+ } catch (PackageManager.NameNotFoundException e) {
+ e.printStackTrace();
+ }
+
+ Intent connectIntent = new Intent(this, PlumbleService.class);
+ connectIntent.putExtra(JumbleService.EXTRAS_SERVER, server);
+ connectIntent.putExtra(JumbleService.EXTRAS_CLIENT_NAME, getString(R.string.app_name)+" "+applicationVersion);
+ connectIntent.putExtra(JumbleService.EXTRAS_TRANSMIT_MODE, inputMethod);
+ connectIntent.putExtra(JumbleService.EXTRAS_DETECTION_THRESHOLD, mSettings.getDetectionThreshold());
+ connectIntent.putExtra(JumbleService.EXTRAS_CERTIFICATE, mSettings.getCertificate());
+ connectIntent.putExtra(JumbleService.EXTRAS_CERTIFICATE_PASSWORD, mSettings.getCertificatePassword());
+ connectIntent.putExtra(JumbleService.EXTRAS_AUTO_RECONNECT, mSettings.isAutoReconnectEnabled());
+ connectIntent.putExtra(JumbleService.EXTRAS_AUTO_RECONNECT_DELAY, RECONNECT_DELAY);
+ connectIntent.putExtra(JumbleService.EXTRAS_USE_OPUS, !mSettings.isOpusDisabled());
+ connectIntent.putExtra(JumbleService.EXTRAS_INPUT_QUALITY, mSettings.getAudioQuality());
+ connectIntent.putExtra(JumbleService.EXTRAS_FORCE_TCP, mSettings.isTcpForced());
+ connectIntent.putExtra(JumbleService.EXTRAS_USE_TOR, mSettings.isTorEnabled());
+ connectIntent.putStringArrayListExtra(JumbleService.EXTRAS_ACCESS_TOKENS, (ArrayList) mDatabase.getAccessTokens(server.getId()));
+ connectIntent.setAction(JumbleService.ACTION_CONNECT);
+ startService(connectIntent);
+ }
+
+ public void connectToPublicServer(final PublicServer server) {
+ AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
+
+ final Settings settings = Settings.getInstance(this);
+
+ // Allow username entry
+ final EditText usernameField = new EditText(this);
+ usernameField.setHint(settings.getDefaultUsername());
+ alertBuilder.setView(usernameField);
+
+ alertBuilder.setTitle(R.string.connectToServer);
+
+ alertBuilder.setPositiveButton(R.string.connect, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ PublicServer newServer = server;
+ if(!usernameField.getText().toString().equals(""))
+ newServer.setUsername(usernameField.getText().toString());
+ else
+ newServer.setUsername(settings.getDefaultUsername());
+ connectToServer(newServer);
+ }
+ });
+
+ alertBuilder.show();
+ }
+
+ @Override
+ public void serverInfoUpdated() {
+ loadDrawerFragment(DrawerAdapter.ITEM_FAVOURITES);
+ }
+
+ /*
+ * HERE BE IMPLEMENTATIONS
+ */
+
+ @Override
+ public IJumbleService getService() {
+ return mService;
+ }
+
+ @Override
+ public PlumbleDatabase getDatabase() {
+ return mDatabase;
+ }
+
+ @Override
+ public void addServiceFragment(JumbleServiceFragment fragment) {
+ mServiceFragments.add(fragment);
+ }
+
+ @Override
+ public void removeServiceFragment(JumbleServiceFragment fragment) {
+ mServiceFragments.remove(fragment);
+ }
+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ if(Settings.PREF_THEME.equals(key)) {
+ // Recreate activity when theme is changed
+ if(Build.VERSION.SDK_INT >= 11)
+ recreate();
+ else {
+ Intent intent = new Intent(this, PlumbleActivity.class);
+ finish();
+ startActivity(intent);
+ }
+ }
+ }
+
+ @Override
+ public boolean isConnected() {
+ try {
+ return mService != null && mService.isConnected();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ @Override
+ public String getConnectedServerName() {
+ try {
+ if(mService != null && mService.isConnected()) {
+ Server server = mService.getConnectedServer();
+ return server.getName().equals("") ? server.getHost() : server.getName();
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/channel/AccessTokenFragment.java b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/AccessTokenFragment.java
new file mode 100644
index 00000000..a778c73f
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/AccessTokenFragment.java
@@ -0,0 +1,178 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.channel;
+
+import android.app.Activity;
+import android.content.Context;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.view.inputmethod.EditorInfo;
+import android.widget.ArrayAdapter;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.ListView;
+import android.widget.TextView;
+import android.widget.TextView.OnEditorActionListener;
+
+import com.morlunk.mumbleclient.Constants;
+import com.morlunk.mumbleclient.R;
+import com.morlunk.mumbleclient.db.DatabaseProvider;
+import com.morlunk.mumbleclient.util.JumbleServiceFragment;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class AccessTokenFragment extends JumbleServiceFragment {
+
+ public interface AccessTokenListener {
+ public void onAccessTokenAdded(long serverId, String token);
+ public void onAccessTokenRemoved(long serverId, String token);
+ }
+
+ private List mTokens;
+
+ private ListView mTokenList;
+ private TokenAdapter mTokenAdapter;
+ private EditText mTokenField;
+
+ private DatabaseProvider mProvider;
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+
+ mTokens = new ArrayList(getAccessTokens());
+ mTokenAdapter = new TokenAdapter(activity, mTokens);
+
+ try {
+ mProvider = (DatabaseProvider) activity;
+ } catch (ClassCastException e) {
+ throw new ClassCastException(activity.toString() + " must implement DatabaseProvider");
+ }
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_tokens, container, false);
+
+ mTokenList = (ListView) view.findViewById(R.id.tokenList);
+ mTokenList.setAdapter(mTokenAdapter);
+
+ mTokenField = (EditText) view.findViewById(R.id.tokenField);
+ mTokenField.setOnEditorActionListener(new OnEditorActionListener() {
+
+ @Override
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+ if(actionId == EditorInfo.IME_ACTION_SEND) {
+ addToken();
+ return true;
+ }
+ return false;
+ }
+ });
+
+ ImageButton addButton = (ImageButton) view.findViewById(R.id.tokenAddButton);
+ addButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ addToken();
+ }
+ });
+
+ return view;
+ }
+
+ private void addToken() {
+ String tokenText = mTokenField.getText().toString().trim();
+
+ if(tokenText.equals(""))
+ return;
+
+ mTokenField.setText("");
+
+ Log.i(Constants.TAG, "Adding token: "+tokenText);
+
+ mTokens.add(tokenText);
+ mTokenAdapter.notifyDataSetChanged();
+
+ mTokenList.smoothScrollToPosition(mTokens.size() - 1);
+ mProvider.getDatabase().addAccessToken(getServerId(), tokenText);
+ try {
+ getService().sendAccessTokens(mTokens);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private long getServerId() {
+ return getArguments().getLong("server");
+ }
+
+ private List getAccessTokens() {
+ return getArguments().getStringArrayList("access_tokens");
+ }
+
+ private class TokenAdapter extends ArrayAdapter {
+
+ public TokenAdapter(Context context,
+ List objects) {
+ super(context, android.R.layout.simple_list_item_1, objects);
+ }
+
+ @Override
+ public View getView(final int position, View convertView, ViewGroup parent) {
+ View view = convertView;
+ if(convertView == null) {
+ view = getActivity().getLayoutInflater().inflate(R.layout.token_row, null, false);
+ }
+
+ final String token = getItem(position);
+
+ TextView title = (TextView) view.findViewById(R.id.tokenItemTitle);
+ title.setText(token);
+
+ ImageButton deleteButton = (ImageButton) view.findViewById(R.id.tokenItemDelete);
+ deleteButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ mTokens.remove(position);
+ notifyDataSetChanged();
+ mProvider.getDatabase().removeAccessToken(getServerId(), token);
+ try {
+ getService().sendAccessTokens(mTokens);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ return view;
+ }
+
+ }
+
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelAdapter.java b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelAdapter.java
new file mode 100644
index 00000000..a166955c
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelAdapter.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.channel;
+
+import android.content.Context;
+import android.os.RemoteException;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.morlunk.jumble.IJumbleService;
+import com.morlunk.jumble.model.Channel;
+import com.morlunk.jumble.model.User;
+import com.morlunk.mumbleclient.R;
+
+/**
+ * Simple adapter to display the users in a single channel.
+ * Created by andrew on 24/11/13.
+ */
+public class ChannelAdapter extends BaseAdapter {
+
+ private Context mContext;
+ private IJumbleService mService;
+ private Channel mChannel;
+
+ public ChannelAdapter(Context context, IJumbleService service, Channel channel) {
+ mContext = context;
+ mService = service;
+ mChannel = channel;
+ }
+
+ @Override
+ public int getCount() {
+ return mChannel.getUsers().size();
+ }
+
+ @Override
+ public Object getItem(int position) {
+ try {
+ return mService.getUser(mChannel.getUsers().get(position));
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return mChannel.getUsers().get(position);
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View v = convertView;
+ if(v == null) {
+ LayoutInflater layoutInflater = LayoutInflater.from(mContext);
+ v = layoutInflater.inflate(R.layout.overlay_user_row, parent, false);
+ }
+ User user = (User) getItem(position);
+ TextView titleView = (TextView) v.findViewById(R.id.userRowName);
+ titleView.setText(user.getName());
+
+ ImageView state = (ImageView) v.findViewById(R.id.userRowState);
+ if (user.isSelfDeafened())
+ state.setImageResource(R.drawable.ic_deafened);
+ else if (user.isSelfMuted())
+ state.setImageResource(R.drawable.ic_muted);
+ else if (user.isDeafened())
+ state.setImageResource(R.drawable.ic_server_deafened);
+ else if (user.isMuted())
+ state.setImageResource(R.drawable.ic_server_muted);
+ else if (user.isSuppressed())
+ state.setImageResource(R.drawable.ic_suppressed);
+ else
+ if (user.getTalkState() == User.TalkState.TALKING)
+ state.setImageResource(R.drawable.ic_talking_on);
+ else
+ state.setImageResource(R.drawable.ic_talking_off);
+
+ return v;
+ }
+
+ public void setChannel(Channel channel) {
+ mChannel = channel;
+ notifyDataSetChanged();
+ }
+
+ public Channel getChannel() {
+ return mChannel;
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelChatFragment.java b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelChatFragment.java
new file mode 100644
index 00000000..dc942c84
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelChatFragment.java
@@ -0,0 +1,365 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.channel;
+
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.text.Editable;
+import android.text.Html;
+import android.text.TextWatcher;
+import android.text.method.LinkMovementMethod;
+import android.util.Base64;
+import android.util.DisplayMetrics;
+import android.view.Gravity;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.TextView;
+import android.widget.TextView.OnEditorActionListener;
+
+import com.morlunk.jumble.IJumbleObserver;
+import com.morlunk.jumble.IJumbleService;
+import com.morlunk.jumble.model.Channel;
+import com.morlunk.jumble.model.Message;
+import com.morlunk.jumble.model.User;
+import com.morlunk.jumble.net.JumbleObserver;
+import com.morlunk.mumbleclient.R;
+import com.morlunk.mumbleclient.util.JumbleServiceFragment;
+
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class ChannelChatFragment extends JumbleServiceFragment implements ChatTargetProvider.OnChatTargetSelectedListener {
+ private static final Pattern LINK_PATTERN = Pattern.compile("(https?://\\S+)");
+ private static final String CHAT_DATE_FORMAT = "%I:%M %p";
+
+ private IJumbleObserver mServiceObserver = new JumbleObserver() {
+
+ @Override
+ public void onMessageLogged(Message message) throws RemoteException {
+ addChatMessage(message, true);
+ }
+ };
+
+ private ListView mChatList;
+ private ChannelChatAdapter mChatAdapter;
+ private EditText mChatTextEdit;
+ private ImageButton mSendButton;
+ private ChatTargetProvider mTargetProvider;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ try {
+ mTargetProvider = (ChatTargetProvider) getParentFragment();
+ } catch (ClassCastException e) {
+ throw new ClassCastException(getParentFragment().toString()+" must implement ChatTargetProvider");
+ }
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ mTargetProvider.registerChatTargetListener(this);
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mTargetProvider.unregisterChatTargetListener(this);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_chat, container, false);
+ mChatList = (ListView) view.findViewById(R.id.chat_list);
+ mChatTextEdit = (EditText) view.findViewById(R.id.chatTextEdit);
+
+ mSendButton = (ImageButton) view.findViewById(R.id.chatTextSend);
+ mSendButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ try {
+ sendMessage(mChatTextEdit.getText().toString());
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ mChatTextEdit.setText("");
+ }
+ });
+
+ mChatTextEdit.setOnEditorActionListener(new OnEditorActionListener() {
+ @Override
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+ try {
+ sendMessage(v.getText().toString());
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ v.setText("");
+ return true;
+ }
+ });
+
+ mChatTextEdit.addTextChangedListener(new TextWatcher() {
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ mSendButton.setEnabled(mChatTextEdit.getText().length() > 0);
+ }
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+
+ }
+ });
+
+ try {
+ updateChatTargetText(mTargetProvider.getChatTarget());
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ return view;
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ inflater.inflate(R.menu.fragment_chat, menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.menu_clear_chat:
+ clear();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ /**
+ * Adds the passed text to the fragment chat body.
+ * @param message The message to add.
+ * @param scroll Whether to scroll to the bottom after adding the message.
+ */
+ public void addChatMessage(Message message, boolean scroll) {
+ if(mChatAdapter == null) return;
+
+ mChatAdapter.add(message);
+
+ if(scroll) {
+ mChatList.post(new Runnable() {
+
+ @Override
+ public void run() {
+ mChatList.smoothScrollToPosition(mChatAdapter.getCount() - 1);
+ }
+ });
+ }
+ }
+
+ private void sendMessage(String message) throws RemoteException {
+ String formattedMessage = linkifyOutgoingMessage(message);
+ ChatTargetProvider.ChatTarget target = mTargetProvider.getChatTarget();
+ Message responseMessage = null;
+ if(target == null)
+ responseMessage = getService().sendChannelTextMessage(getService().getSessionChannel().getId(), formattedMessage, false);
+ else if(target.getUser() != null)
+ responseMessage = getService().sendUserTextMessage(target.getUser().getSession(), formattedMessage);
+ else if(target.getChannel() != null)
+ responseMessage = getService().sendChannelTextMessage(target.getChannel().getId(), formattedMessage, false);
+ addChatMessage(responseMessage, true);
+ }
+
+ private String linkifyOutgoingMessage(String message) {
+ String formattedBody = message;
+ Matcher matcher = LINK_PATTERN.matcher(formattedBody);
+ formattedBody = matcher.replaceAll("$1");
+ return formattedBody;
+ }
+
+ public void clear() {
+ mChatAdapter.clear();
+ try {
+ getService().clearMessageLog();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Updates hint displaying chat target.
+ */
+ public void updateChatTargetText(ChatTargetProvider.ChatTarget target) throws RemoteException {
+ if(getService() == null) return;
+
+ if(target == null) mChatTextEdit.setHint(getString(R.string.messageToChannel, getService().getSessionChannel().getName()));
+ else if(target.getUser() != null) mChatTextEdit.setHint(getString(R.string.messageToUser, target.getUser().getName()));
+ else if(target.getChannel() != null) mChatTextEdit.setHint(getString(R.string.messageToChannel, target.getChannel().getName()));
+ }
+
+
+ @Override
+ public void onServiceBound(IJumbleService service) {
+ try {
+ mChatAdapter = new ChannelChatAdapter(getActivity(), service, service.getMessageLog());
+ mChatList.setAdapter(mChatAdapter);
+ mChatList.post(new Runnable() {
+ @Override
+ public void run() {
+ mChatList.setSelection(mChatAdapter.getCount() - 1);
+ }
+ });
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public IJumbleObserver getServiceObserver() {
+ return mServiceObserver;
+ }
+
+ @Override
+ public void onChatTargetSelected(ChatTargetProvider.ChatTarget target) {
+ try {
+ updateChatTargetText(target);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static class ChannelChatAdapter extends ArrayAdapter {
+
+ /**
+ * Image getter to read base64 image data from messages.
+ */
+ private Html.ImageGetter mImageGetter = new Html.ImageGetter() {
+
+ @Override
+ public Drawable getDrawable(String source) {
+ try {
+ String decodedSource = URLDecoder.decode(source, "UTF-8"); // Decode from URL encoding
+ String base64 = decodedSource.split(",")[1]; // Take the binary data only, not the img src header
+ byte[] src = Base64.decode(base64, Base64.DEFAULT);
+ Bitmap bmp = BitmapFactory.decodeByteArray(src, 0, src.length);
+ BitmapDrawable drawable = new BitmapDrawable(getContext().getResources(), bmp);
+ DisplayMetrics metrics = getContext().getResources().getDisplayMetrics(); // Use display metrics to scale image to mdpi
+ drawable.setBounds(0, 0, (int)((float)drawable.getIntrinsicWidth()*metrics.density), (int)((float)drawable.getIntrinsicHeight()*metrics.density));
+ return drawable;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+ };
+ private IJumbleService mService;
+
+ public ChannelChatAdapter(Context context, IJumbleService service, List messages) {
+ super(context, 0, new ArrayList(messages));
+ mService = service;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View v = convertView;
+ if(v == null) {
+ v = LayoutInflater.from(getContext()).inflate(R.layout.list_chat_item, parent, false);
+ }
+
+ LinearLayout chatBox = (LinearLayout) v.findViewById(R.id.list_chat_item_box);
+ TextView targetText = (TextView) v.findViewById(R.id.list_chat_item_target);
+ TextView messageText = (TextView) v.findViewById(R.id.list_chat_item_text);
+ TextView timeText = (TextView) v.findViewById(R.id.list_chat_item_time);
+
+ Message message = getItem(position);
+ String targetMessage = null;
+ boolean selfAuthored = false;
+ try {
+ User actor = mService.getUser(message.getActor());
+ selfAuthored = actor != null && actor.getSession() == mService.getSession();
+
+ if(actor != null && (!message.getChannels().isEmpty() || !message.getTrees().isEmpty())) {
+ Channel currentChannel = message.getChannels().get(0);
+ targetMessage = getContext().getString(R.string.chat_message_to, actor.getName(), currentChannel.getName());
+ } else if(actor != null && !message.getUsers().isEmpty()) {
+ User user = message.getUsers().get(0);
+ targetMessage = getContext().getString(R.string.chat_message_to, actor.getName(), user.getName());
+ } else if(actor != null) {
+ targetMessage = actor.getName();
+ } else {
+ targetMessage = getContext().getString(R.string.server);
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+
+ int gravity = selfAuthored ? Gravity.RIGHT : Gravity.LEFT;
+
+ chatBox.setGravity(gravity);
+ targetText.setVisibility(message.getType() == Message.Type.TEXT_MESSAGE ? View.VISIBLE : View.GONE);
+ targetText.setText(targetMessage);
+ messageText.setText(Html.fromHtml(message.getMessage(), mImageGetter, null));
+ messageText.setMovementMethod(LinkMovementMethod.getInstance());
+ messageText.setGravity(gravity);
+ timeText.setText(message.getReceivedTime().format(CHAT_DATE_FORMAT));
+
+ return v;
+ }
+
+ @Override
+ public boolean areAllItemsEnabled() {
+ return false;
+ }
+
+ @Override
+ public boolean isEnabled(int position) {
+ return false; // Makes links clickable.
+ }
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelEditFragment.java b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelEditFragment.java
new file mode 100644
index 00000000..6e0b7d74
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelEditFragment.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.channel;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.support.v4.app.DialogFragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.CheckBox;
+import android.widget.TextView;
+
+import com.morlunk.mumbleclient.R;
+import com.morlunk.mumbleclient.util.JumbleServiceProvider;
+
+/**
+ * Created by andrew on 23/11/13.
+ */
+public class ChannelEditFragment extends DialogFragment {
+
+ private JumbleServiceProvider mServiceProvider;
+ private TextView mNameField;
+ private TextView mDescriptionField;
+ private TextView mPositionField;
+ private CheckBox mTemporaryBox;
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+
+ try {
+ mServiceProvider = (JumbleServiceProvider) activity;
+ } catch (ClassCastException e) {
+ throw new ClassCastException(activity.toString() + " must implement JumbleServiceProvider");
+ }
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ LayoutInflater inflater = LayoutInflater.from(getActivity());
+ View view = inflater.inflate(R.layout.fragment_channel_edit, null, false);
+ mNameField = (TextView) view.findViewById(R.id.channel_edit_name);
+ mDescriptionField = (TextView) view.findViewById(R.id.channel_edit_description);
+ mPositionField = (TextView) view.findViewById(R.id.channel_edit_position);
+ mTemporaryBox = (CheckBox) view.findViewById(R.id.channel_edit_temporary);
+ return new AlertDialog.Builder(getActivity())
+ .setTitle(isAdding() ? R.string.channel_add : R.string.channel_edit)
+ .setView(view)
+ .setPositiveButton(isAdding() ? R.string.add : R.string.save, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ try {
+ if(isAdding()) {
+ mServiceProvider.getService().createChannel(getParent(),
+ mNameField.getText().toString(),
+ mDescriptionField.getText().toString(),
+ Integer.parseInt(mPositionField.getText().toString()), // We can guarantee this to be an int. InputType is numberSigned.
+ mTemporaryBox.isChecked());
+ } else {
+ // TODO
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ })
+ .setNegativeButton(android.R.string.cancel, null)
+ .create();
+ }
+
+ /**
+ * @return true if the user is adding a new channel.
+ */
+ public boolean isAdding() {
+ return getArguments().getBoolean("adding");
+ }
+
+ /**
+ * @return the parent channel that the new channel will be a child of.
+ */
+ public int getParent() {
+ return getArguments().getInt("parent");
+ }
+ /**
+ * @return the channel being updated.
+ */
+ public int getChannel() {
+ return getArguments().getInt("channel");
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelFragment.java b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelFragment.java
new file mode 100644
index 00000000..d377b210
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelFragment.java
@@ -0,0 +1,224 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.channel;
+
+import android.content.SharedPreferences;
+import android.content.res.TypedArray;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.preference.PreferenceManager;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentPagerAdapter;
+import android.support.v4.view.PagerTabStrip;
+import android.support.v4.view.ViewPager;
+import android.util.TypedValue;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+
+import com.morlunk.mumbleclient.R;
+import com.morlunk.mumbleclient.Settings;
+import com.morlunk.mumbleclient.util.JumbleServiceFragment;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Class to encapsulate both a ChannelListFragment and ChannelChatFragment.
+ * Created by andrew on 02/08/13.
+ */
+public class ChannelFragment extends JumbleServiceFragment implements SharedPreferences.OnSharedPreferenceChangeListener, ChatTargetProvider {
+
+ private ViewPager mViewPager;
+ private PagerTabStrip mTabStrip;
+ private Button mTalkButton;
+ private View mTalkView;
+
+ private ChatTarget mChatTarget;
+ /** Chat target listeners, notified when the chat target is changed. */
+ private List mChatTargetListeners = new ArrayList();
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_channel, container, false);
+ mViewPager = (ViewPager) view.findViewById(R.id.channel_view_pager);
+ mTabStrip = (PagerTabStrip) view.findViewById(R.id.channel_tab_strip);
+ if(mTabStrip != null) {
+ int[] attrs = new int[] { R.attr.secondaryBackground, android.R.attr.textColorPrimaryInverse };
+ TypedArray a = getActivity().obtainStyledAttributes(attrs);
+ int titleStripBackground = a.getColor(0, -1);
+ int titleStripColor = a.getColor(1, -1);
+ a.recycle();
+
+ mTabStrip.setTextColor(titleStripColor);
+ mTabStrip.setTabIndicatorColor(titleStripColor);
+ mTabStrip.setBackgroundColor(titleStripBackground);
+ mTabStrip.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
+ }
+
+ final Settings settings = Settings.getInstance(getActivity());
+ mTalkView = view.findViewById(R.id.pushtotalk_view);
+ mTalkButton = (Button) view.findViewById(R.id.pushtotalk);
+ mTalkButton.setOnTouchListener(new View.OnTouchListener() {
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ try {
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ if (!settings.isPushToTalkToggle())
+ getService().setTalkingState(true);
+ else
+ getService().setTalkingState(!getService().isTalking());
+ } else if (event.getAction() == MotionEvent.ACTION_UP) {
+ if (!settings.isPushToTalkToggle())
+ getService().setTalkingState(false);
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+ });
+ configureInput();
+ return view;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
+ preferences.registerOnSharedPreferenceChangeListener(this);
+
+ if(mViewPager != null) { // Phone
+ ChannelFragmentPagerAdapter pagerAdapter = new ChannelFragmentPagerAdapter(getChildFragmentManager());
+ mViewPager.setAdapter(pagerAdapter);
+ } else { // Tablet
+ ChannelListFragment listFragment = new ChannelListFragment();
+ Bundle listArgs = new Bundle();
+ listArgs.putBoolean("pinned", isShowingPinnedChannels());
+ listFragment.setArguments(listArgs);
+ ChannelChatFragment chatFragment = new ChannelChatFragment();
+
+ getChildFragmentManager().beginTransaction()
+ .replace(R.id.list_fragment, listFragment)
+ .replace(R.id.chat_fragment, chatFragment)
+ .commit();
+ }
+ }
+
+ @Override
+ public void onDestroy() {
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
+ preferences.unregisterOnSharedPreferenceChangeListener(this);
+ super.onDestroy();
+ }
+
+ /**
+ * @return true if the channel fragment is set to display only the user's pinned channels.
+ */
+ private boolean isShowingPinnedChannels() {
+ return getArguments() != null &&
+ getArguments().getBoolean("pinned");
+ }
+
+ /**
+ * Configures the fragment in accordance with the user's interface preferences.
+ */
+ private void configureInput() {
+ Settings settings = Settings.getInstance(getActivity());
+ boolean showPttButton = settings.isPushToTalkButtonShown() && settings.getInputMethod().equals(Settings.ARRAY_INPUT_METHOD_PTT);
+ mTalkView.setVisibility(showPttButton ? View.VISIBLE : View.GONE);
+ }
+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ if(Settings.PREF_INPUT_METHOD.equals(key) || Settings.PREF_PUSH_BUTTON_HIDE_KEY.equals(key))
+ configureInput();
+ }
+
+ @Override
+ public ChatTarget getChatTarget() {
+ return mChatTarget;
+ }
+
+ @Override
+ public void setChatTarget(ChatTarget target) {
+ if(target != null && mViewPager != null) {
+ // Scroll to chat pane when a user is selected.
+ mViewPager.setCurrentItem(1, true);
+ }
+ mChatTarget = target;
+ for(OnChatTargetSelectedListener listener : mChatTargetListeners)
+ listener.onChatTargetSelected(target);
+ }
+
+ @Override
+ public void registerChatTargetListener(OnChatTargetSelectedListener listener) {
+ mChatTargetListeners.add(listener);
+ }
+
+ @Override
+ public void unregisterChatTargetListener(OnChatTargetSelectedListener listener) {
+ mChatTargetListeners.remove(listener);
+ }
+
+ private class ChannelFragmentPagerAdapter extends FragmentPagerAdapter {
+
+ public ChannelFragmentPagerAdapter(FragmentManager fm) {
+ super(fm);
+ }
+
+ @Override
+ public Fragment getItem(int i) {
+ Fragment fragment = null;
+ Bundle args = new Bundle();
+ switch (i) {
+ case 0:
+ fragment = new ChannelListFragment();
+ args.putBoolean("pinned", isShowingPinnedChannels());
+ break;
+ case 1:
+ fragment = new ChannelChatFragment();
+ break;
+ }
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @Override
+ public CharSequence getPageTitle(int position) {
+ switch (position) {
+ case 0:
+ return getString(R.string.channel).toUpperCase();
+ case 1:
+ return getString(R.string.chat).toUpperCase();
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ public int getCount() {
+ return 2;
+ }
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelListAdapter.java b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelListAdapter.java
new file mode 100644
index 00000000..a4ea2a16
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelListAdapter.java
@@ -0,0 +1,293 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.channel;
+
+import android.content.Context;
+import android.graphics.Typeface;
+import android.os.RemoteException;
+import android.util.DisplayMetrics;
+import android.util.SparseArray;
+import android.util.TypedValue;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.morlunk.jumble.IJumbleService;
+import com.morlunk.jumble.model.Channel;
+import com.morlunk.jumble.model.User;
+import com.morlunk.mumbleclient.R;
+import com.morlunk.mumbleclient.db.PlumbleDatabase;
+import com.morlunk.mumbleclient.view.PlumbleNestedAdapter;
+import com.morlunk.mumbleclient.view.PlumbleNestedListView;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by andrew on 31/07/13.
+ */
+public class ChannelListAdapter extends PlumbleNestedAdapter {
+
+ /**
+ * Gets called when the channel menu needs to be shown.
+ */
+ public interface ChannelMenuListener {
+ public void showChannelMenu(Channel channel, View anchor);
+ }
+
+ private IJumbleService mService;
+ private PlumbleNestedListView mListView;
+ private ChannelMenuListener mMenuListener;
+ private PlumbleDatabase mDatabase;
+
+ private SparseArray mChannels = new SparseArray();
+ private SparseArray mUsers = new SparseArray();
+ private List mRootChannels = new ArrayList();
+
+ private boolean mShowPinnedOnly;
+
+ public ChannelListAdapter(Context context, PlumbleNestedListView listView, IJumbleService service, PlumbleDatabase database, boolean showPinnedOnly) {
+ super(context);
+ mService = service;
+ mDatabase = database;
+ mListView = listView;
+ mShowPinnedOnly = showPinnedOnly;
+ }
+
+ /**
+ * Fetches a new list of channels from the service.
+ */
+ public void updateChannelList() throws RemoteException {
+ mChannels.clear();
+ mUsers.clear();
+
+ List channels = mService.getChannelList();
+ List users = mService.getUserList();
+ mRootChannels = new ArrayList();
+
+ if(mShowPinnedOnly) {
+ mRootChannels = mDatabase.getPinnedChannels(mService.getConnectedServer().getId());
+ } else {
+ mRootChannels.add(0);
+ }
+
+ for(Channel channel : channels)
+ mChannels.put(channel.getId(), channel);
+ for(User user : users)
+ mUsers.put(user.getSession(), user);
+ }
+
+ public void refreshUser(User user) throws RemoteException {
+ int position = getVisibleFlatChildPosition(user.getSession());
+ if(position < 0)
+ return;
+
+ View userView = mListView.getChildAt(position - mListView.getFirstVisiblePosition());
+
+ // Update comment state TODO reimplement
+// if (user.getComment() != null
+// || user.getCommentHash() != null
+// && !service.isConnectedServerPublic()) {
+// commentsSeen.put(user, database.isCommentSeen(
+// user.name,
+// user.commentHash != null ? user.commentHash
+// .toStringUtf8() : user.comment));
+// }
+
+ if (userView != null && userView.isShown() && userView.getTag() != null && userView.getTag().equals(user))
+ refreshElements(userView, user);
+ }
+
+ public void refreshTalkingState(User user) {
+ int position = getVisibleFlatChildPosition(user.getSession());
+ if(position < 0)
+ return;
+
+ View userView = mListView.getChildAt(position - mListView.getFirstVisiblePosition());
+
+ if (userView != null && userView.isShown() && userView.getTag() != null && userView.getTag().equals(user))
+ refreshTalkingState(userView, user);
+
+ }
+
+ private void refreshElements(final View view, final User user) {
+ TextView name = (TextView) view.findViewById(R.id.userRowName);
+
+ name.setText(user.getName());
+ try {
+ name.setTypeface(null, user.getSession() == mService.getSession() ? Typeface.BOLD : Typeface.NORMAL);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+
+ refreshTalkingState(view, user);
+ }
+
+ private void refreshTalkingState(final View view, final User user) {
+ final ImageView state = (ImageView) view.findViewById(R.id.userRowState);
+
+ if (user.isSelfDeafened())
+ state.setImageResource(R.drawable.ic_deafened);
+ else if (user.isSelfMuted())
+ state.setImageResource(R.drawable.ic_muted);
+ else if (user.isDeafened())
+ state.setImageResource(R.drawable.ic_server_deafened);
+ else if (user.isMuted())
+ state.setImageResource(R.drawable.ic_server_muted);
+ else if (user.isSuppressed())
+ state.setImageResource(R.drawable.ic_suppressed);
+ else
+ if (user.getTalkState() == User.TalkState.TALKING)
+ state.setImageResource(R.drawable.ic_talking_on);
+ else
+ state.setImageResource(R.drawable.ic_talking_off);
+ }
+
+ public void setChannelMenuListener(ChannelMenuListener listener) {
+ mMenuListener = listener;
+ }
+
+ @Override
+ public User getChild(int groupId, int childPosition) {
+ Channel channel = mChannels.get(groupId);
+ int session = channel.getUsers().get(childPosition);
+ return mUsers.get(session);
+ }
+
+ @Override
+ public View getChildView(int groupId, int childPosition, int depth, View v, ViewGroup arg4) {
+ if (v == null) {
+ final LayoutInflater inflater = (LayoutInflater) getContext()
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ v = inflater.inflate(R.layout.channel_user_row, arg4, false);
+ }
+
+ final User user = getChild(groupId, childPosition);
+
+ if(user != null)
+ refreshElements(v, user);
+ v.setTag(user);
+
+ // Pad the view depending on channel's nested level.
+ final View titleView = v.findViewById(R.id.channel_user_row_title);
+ DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
+ float margin = (depth + 1) * TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 25, metrics);
+ titleView.setPadding((int) margin, titleView.getPaddingTop(), titleView.getPaddingRight(), titleView.getPaddingBottom());
+
+ return v;
+ }
+
+ @Override
+ public List getRootIds() {
+ return mRootChannels;
+ }
+
+ @Override
+ public int getGroupCount(int parentId) {
+ if(mShowPinnedOnly) return 0; // No subchannels when using pinned
+ Channel parent = mChannels.get(parentId);
+ return parent.getSubchannels().size();
+ }
+
+ @Override
+ public int getChildCount(int arg0) {
+ Channel channel = mChannels.get(arg0);
+ return channel.getUsers().size();
+ }
+
+ @Override
+ public Channel getGroup(int arg0) {
+ return mChannels.get(arg0);
+ }
+
+ @Override
+ public View getGroupView(final int groupId, int depth, View convertView, ViewGroup parent) {
+ View v = convertView;
+ if (v == null) {
+ final LayoutInflater inflater = (LayoutInflater) getContext()
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ v = inflater.inflate(R.layout.channel_row, parent, false);
+ }
+
+ final Channel channel = mChannels.get(groupId);
+
+ ImageView expandView = (ImageView) v.findViewById(R.id.channel_row_expand);
+ expandView.setImageResource(isGroupExpanded(groupId) ? R.drawable.ic_action_minus_light : R.drawable.ic_action_add_light);
+ expandView.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ if(isGroupExpanded(groupId))
+ collapseGroup(groupId);
+ else
+ expandGroup(groupId);
+ notifyVisibleSetChanged();
+ }
+ });
+
+ TextView nameView = (TextView) v
+ .findViewById(R.id.channel_row_name);
+ TextView countView = (TextView) v.findViewById(R.id.channel_row_count);
+
+ nameView.setText(channel.getName());
+
+ int userCount = channel.getSubchannelUserCount();
+ countView.setText(String.format("%d", userCount));
+ countView.setTextColor(getContext().getResources().getColor(userCount > 0 ? R.color.holo_blue_light : android.R.color.darker_gray));
+
+ ImageView moreView = (ImageView) v.findViewById(R.id.channel_row_more);
+ moreView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if(mMenuListener != null)
+ mMenuListener.showChannelMenu(channel, v);
+ }
+ });
+
+ View channelTitle = v.findViewById(R.id.channel_row_title);
+
+ // Pad the view depending on channel's nested level.
+ DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
+ float margin = depth * TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 25, metrics);
+ channelTitle.setPadding((int) margin, channelTitle.getPaddingTop(), channelTitle.getPaddingRight(),
+ channelTitle.getPaddingBottom());
+
+ return v;
+ }
+
+ @Override
+ public int getGroupId(int parentId, int groupPosition) {
+ Channel parent = mChannels.get(parentId);
+ Channel channel = mChannels.get(parent.getSubchannels().get(groupPosition));
+ return channel.getId();
+ }
+
+ @Override
+ public int getChildId(int groupId, int childPosition) {
+ Channel channel = mChannels.get(groupId);
+ return channel.getUsers().get(childPosition);
+ }
+
+ @Override
+ public boolean isGroupExpandedByDefault(int groupId) {
+ // Return true if there are channels in the chain with more than 0 users.
+ return mChannels.get(groupId).getSubchannelUserCount() > 0;
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelListFragment.java b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelListFragment.java
new file mode 100644
index 00000000..f8d4e5a7
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelListFragment.java
@@ -0,0 +1,847 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.channel;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.ProgressDialog;
+import android.app.SearchManager;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.graphics.PorterDuff;
+import android.graphics.Rect;
+import android.graphics.drawable.ColorDrawable;
+import android.media.AudioManager;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.RemoteException;
+import android.support.v4.view.MenuItemCompat;
+import android.support.v7.widget.PopupMenu;
+import android.support.v7.widget.SearchView;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.EditText;
+import android.widget.GridView;
+import android.widget.ImageView;
+import android.widget.PopupWindow;
+import android.widget.TextView;
+
+import com.morlunk.jumble.IJumbleObserver;
+import com.morlunk.jumble.IJumbleService;
+import com.morlunk.jumble.model.Channel;
+import com.morlunk.jumble.model.User;
+import com.morlunk.jumble.net.JumbleObserver;
+import com.morlunk.jumble.net.Permissions;
+import com.morlunk.mumbleclient.R;
+import com.morlunk.mumbleclient.db.DatabaseProvider;
+import com.morlunk.mumbleclient.util.JumbleServiceFragment;
+import com.morlunk.mumbleclient.view.PlumbleNestedListView;
+import com.morlunk.mumbleclient.view.PlumbleNestedListView.OnNestedChildClickListener;
+import com.morlunk.mumbleclient.view.PlumbleNestedListView.OnNestedGroupClickListener;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ChannelListFragment extends JumbleServiceFragment implements OnNestedChildClickListener, OnNestedGroupClickListener, ChannelListAdapter.ChannelMenuListener, CommentFragment.CommentFragmentListener {
+
+ public static final int KICK_ID = 0,
+ BAN_ID = 1,
+ MUTE_ID = 2,
+ DEAFEN_ID = 3,
+ PRIORITY_ID = 4,
+ LOCAL_MUTE_ID = 5,
+ IGNORE_MESSAGES_ID = 6,
+ CHANGE_COMMENT_ID = 7,
+ VIEW_COMMENT_ID = 8,
+ RESET_COMMENT_ID = 9,
+ SEND_MESSAGE_ID = 10,
+ USER_INFORMATION_ID = 11,
+ REGISTER_ID = 12;
+
+ private IJumbleObserver mServiceObserver = new JumbleObserver() {
+ @Override
+ public void onDisconnected() throws RemoteException {
+ mChannelView.setAdapter(null);
+ }
+
+ @Override
+ public void onUserJoinedChannel(User user, Channel newChannel, Channel oldChannel) throws RemoteException {
+ updateChannelList();
+ if(getService().getSession() == user.getSession()) {
+ scrollToChannel(newChannel.getId());
+ }
+ }
+
+ @Override
+ public void onChannelAdded(Channel channel) throws RemoteException {
+ updateChannelList();
+ }
+
+ @Override
+ public void onChannelRemoved(Channel channel) throws RemoteException {
+ updateChannelList();
+ }
+
+ @Override
+ public void onChannelStateUpdated(Channel channel) throws RemoteException {
+ updateChannel(channel);
+ }
+
+ @Override
+ public void onUserConnected(User user) throws RemoteException {
+ updateChannelList();
+ }
+
+ @Override
+ public void onUserRemoved(User user, String reason) throws RemoteException {
+ removeUser(user);
+ }
+
+ @Override
+ public void onUserStateUpdated(User user) throws RemoteException {
+ updateUser(user);
+ }
+
+ @Override
+ public void onUserTalkStateUpdated(User user) throws RemoteException {
+ updateUserTalking(user);
+ }
+ };
+
+ private BroadcastReceiver mBluetoothReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if(getActivity() != null)
+ getActivity().supportInvalidateOptionsMenu(); // Update bluetooth menu item
+ }
+ };
+
+ private PlumbleNestedListView mChannelView;
+ private ChannelListAdapter mChannelListAdapter;
+ private ChatTargetProvider mTargetProvider;
+ private DatabaseProvider mDatabaseProvider;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ try {
+ mTargetProvider = (ChatTargetProvider) getParentFragment();
+ } catch (ClassCastException e) {
+ throw new ClassCastException(getParentFragment().toString()+" must implement ChatTargetProvider");
+ }
+ try {
+ mDatabaseProvider = (DatabaseProvider) getActivity();
+ } catch (ClassCastException e) {
+ throw new ClassCastException(getActivity().toString()+" must implement DatabaseProvider");
+ }
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_channel_list, container, false);
+
+ // Get the UI views
+ mChannelView = (PlumbleNestedListView) view.findViewById(R.id.channelUsers);
+ mChannelView.setOnChildClickListener(this);
+ mChannelView.setOnGroupClickListener(this);
+
+ return view;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ registerForContextMenu(mChannelView);
+ getActivity().registerReceiver(mBluetoothReceiver, new IntentFilter(AudioManager.ACTION_SCO_AUDIO_STATE_CHANGED));
+ }
+
+ @Override
+ public void onDetach() {
+ getActivity().unregisterReceiver(mBluetoothReceiver);
+ super.onDetach();
+ }
+
+ @Override
+ public IJumbleObserver getServiceObserver() {
+ return mServiceObserver;
+ }
+
+ @Override
+ public void onServiceBound(IJumbleService service) {
+ try {
+ if(mChannelListAdapter == null)
+ setupChannelList();
+ else
+ updateChannelList();
+ scrollToUser(service.getSession());
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onPrepareOptionsMenu(Menu menu) {
+ super.onPrepareOptionsMenu(menu);
+//
+// Mute/deaf opacity conflicts with color drawable mutation
+// MenuItem muteItem = menu.findItem(R.id.menu_mute_button);
+// MenuItem deafenItem = menu.findItem(R.id.menu_deafen_button);
+//
+// try {
+// if(getService() != null && getService().getSessionUser() != null && getService().isConnected()) {
+// User self = getService().getSessionUser();
+// muteItem.getIcon().mutate().setAlpha(self.isSelfMuted() ? 100 : 255);
+// deafenItem.getIcon().mutate().setAlpha(self.isSelfDeafened() ? 100 : 255);
+// }
+// } catch (RemoteException e) {
+// e.printStackTrace();
+// }
+
+ try {
+ if(getService() != null) {
+ MenuItem bluetoothItem = menu.findItem(R.id.menu_bluetooth);
+ bluetoothItem.setChecked(getService().isBluetoothAvailable());
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ inflater.inflate(R.menu.fragment_channel_list, menu);
+
+ MenuItem searchItem = menu.findItem(R.id.menu_search);
+ SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
+ SearchView searchView = (SearchView)MenuItemCompat.getActionView(searchItem);
+ searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ switch (item.getItemId()) {
+ case R.id.menu_mute_button:
+ try {
+ User self = getService().getSessionUser();
+
+ boolean muted = !self.isSelfMuted();
+ boolean deafened = self.isSelfDeafened();
+ deafened &= muted; // Undeafen if mute is off
+ self.setSelfMuted(muted);
+ self.setSelfDeafened(deafened);
+ getService().setSelfMuteDeafState(self.isSelfMuted(), self.isSelfDeafened());
+
+ getActivity().supportInvalidateOptionsMenu();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ return true;
+ case R.id.menu_deafen_button:
+ try {
+ User self = getService().getSessionUser();
+
+ boolean deafened = self.isSelfDeafened();
+ self.setSelfDeafened(!deafened);
+ self.setSelfMuted(!deafened);
+ getService().setSelfMuteDeafState(self.isSelfDeafened(), self.isSelfDeafened());
+
+ getActivity().supportInvalidateOptionsMenu();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ return true;
+ case R.id.menu_search:
+ return false;
+ case R.id.menu_bluetooth:
+ item.setChecked(!item.isChecked());
+ try {
+ getService().setBluetoothEnabled(item.isChecked());
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+
+ private void setupChannelList() throws RemoteException {
+ mChannelListAdapter = new ChannelListAdapter(getActivity(), mChannelView, getService(), mDatabaseProvider.getDatabase(), isShowingPinnedChannels());
+ mChannelListAdapter.setChannelMenuListener(this);
+ mChannelView.setAdapter(mChannelListAdapter);
+ updateChannelList();
+ }
+
+ public void updateChannelList() throws RemoteException {
+ mChannelListAdapter.updateChannelList();
+ mChannelListAdapter.notifyDataSetChanged();
+ }
+
+ public void updateUser(User user) throws RemoteException {
+ mChannelListAdapter.refreshUser(user);
+ }
+
+ public void updateChannel(Channel channel) throws RemoteException {
+ if(channel.getDescription() != null || channel.getDescriptionHash() != null) {
+// TODO reimplement comment caching
+// mChannelListAdapter.commentsSeen.put(channel, mChannelListAdapter.database.isCommentSeen(
+// channel.getName(),
+// channel.getDescriptionHash() != null ? new String(channel.getDescriptionHash()) : channel.getDescription()));
+ }
+ updateChannelList();
+ }
+
+ public void updateUserTalking(User user) {
+ mChannelListAdapter.refreshTalkingState(user);
+ }
+
+ /**
+ * Removes the user from the channel list.
+ *
+ * @param user
+ */
+ public void removeUser(User user) {
+ mChannelListAdapter.notifyDataSetChanged();
+ }
+
+ /**
+ * Scrolls to the passed channel.
+ */
+ public void scrollToChannel(int channelId) {
+ int channelPosition = mChannelListAdapter.getFlatGroupPosition(channelId);
+ mChannelView.smoothScrollToPosition(channelPosition);
+ }
+ /**
+ * Scrolls to the passed user.
+ */
+ public void scrollToUser(int userId) {
+ int userPosition = mChannelListAdapter.getFlatChildPosition(userId);
+ mChannelView.smoothScrollToPosition(userPosition);
+ }
+
+ public void setChatTarget(User chatTarget) {
+ User oldTarget = chatTarget;
+ if (mChannelListAdapter != null) {
+ try {
+ if (oldTarget != null)
+ mChannelListAdapter.refreshUser(oldTarget);
+ mChannelListAdapter.refreshUser(chatTarget);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ @Override
+ public void onNestedChildClick(AdapterView> parent, View view, int groupId, int childPosition) {
+ User user = mChannelListAdapter.getChild(groupId, childPosition);
+ showUserMenu(view, user);
+ }
+
+ @Override
+ public void onNestedGroupClick(AdapterView> parent, View view, int groupId) {
+ try {
+ getService().joinChannel(groupId);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void showChannelMenu(Channel channel, View anchor) {
+ PopupMenu menu = new PopupMenu(getActivity(), anchor);
+ menu.inflate(R.menu.channel_modify_menu);
+ // TODO detect permissions
+ ChannelPopupMenuListener menuListener = new ChannelPopupMenuListener(channel);
+ menu.setOnMenuItemClickListener(menuListener);
+ boolean targeted = mTargetProvider.getChatTarget() != null &&
+ mTargetProvider.getChatTarget().getChannel() != null &&
+ mTargetProvider.getChatTarget().getChannel().getId() == channel.getId();
+ menu.getMenu().findItem(R.id.menu_channel_send_message).setChecked(targeted);
+
+ try {
+ long serverId = getService().getConnectedServer().getId();
+ boolean pinned = mDatabaseProvider.getDatabase().isChannelPinned(serverId, channel.getId());
+ menu.getMenu().findItem(R.id.menu_channel_pin).setChecked(pinned);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+
+ int permissions = channel.getPermissions();
+ menu.getMenu().findItem(R.id.menu_channel_add).setVisible((permissions & (Permissions.MakeChannel | Permissions.MakeTempChannel)) > 0);
+ menu.getMenu().findItem(R.id.menu_channel_edit).setVisible((permissions & Permissions.Write) > 0);
+ menu.getMenu().findItem(R.id.menu_channel_remove).setVisible((permissions & Permissions.Write) > 0);
+
+ menu.show();
+ }
+
+ /**
+ * Slides a PopupWindow containing a user menu underneath the passed view.
+ */
+ public void showUserMenu(final View view, final User user) {
+ LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ final View menuView = inflater.inflate(R.layout.popup_menu, null, false);
+ final GridView menuGrid = (GridView) menuView.findViewById(R.id.user_menu_grid);
+ final PopupWindow popupWindow = new PopupWindow(menuView, view.getMeasuredWidth(), WindowManager.LayoutParams.WRAP_CONTENT, true);
+
+ // Update menu grid when we receive updated permissions.
+ final JumbleObserver observer = new JumbleObserver() {
+ @Override
+ public void onChannelPermissionsUpdated(Channel channel) throws RemoteException {
+ List items = getUserMenu(user);
+ menuGrid.setAdapter(new PopupGridMenuAdapter(getActivity(), items));
+ }
+ };
+
+ try {
+ getService().registerObserver(observer);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+
+ final List menuItems;
+ try {
+ menuItems = getUserMenu(user);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ return;
+ }
+ menuGrid.setAdapter(new PopupGridMenuAdapter(getActivity(), menuItems));
+ menuGrid.setOnItemClickListener(new UserMenuListener(user, popupWindow));
+
+ final Animation slideDown = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_down);
+ final Animation slideUp = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_up);
+ slideUp.setAnimationListener(new Animation.AnimationListener() {
+ @Override public void onAnimationStart(Animation animation) { }
+
+ @Override
+ public void onAnimationEnd(Animation animation) {
+ Handler handler = new Handler();
+ handler.post(new Runnable() {
+ @Override
+ public void run() {
+ popupWindow.dismiss(); // Automatically dismiss when hidden. Do this in main thread to avoid errors.
+ }
+ });
+ }
+ @Override public void onAnimationRepeat(Animation animation) { }
+ });
+
+ popupWindow.setBackgroundDrawable(new ColorDrawable()); // Hack to fix touch events.
+ popupWindow.setAnimationStyle(0); // No animations. We do our own.
+
+ // We do some not-so-nice hacks here. Because we're animating the view inside the PopupWindow and not the window itself, we have to make our own method to dismiss the window when there is an outside touch.
+ popupWindow.setTouchInterceptor(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ Rect rect = new Rect();
+ v.getHitRect(rect);
+ if(event.getAction() == MotionEvent.ACTION_DOWN && !rect.contains((int)event.getX(), (int)event.getY())) {
+ menuView.startAnimation(slideUp); // Dismiss is done after animation, see above.
+ return true;
+ }
+ return false;
+ }
+ });
+
+ // Unregister listener on dismiss
+ popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
+ @Override
+ public void onDismiss() {
+ if(getService() != null)
+ try {
+ getService().unregisterObserver(observer);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ // We only slide down the view inside of the PopupWindow so it clips to the PopupWindow.
+ menuView.startAnimation(slideDown);
+ popupWindow.showAsDropDown(view);
+ }
+
+ /**
+ * Configures the menu for the provided user, enabling allowed features and disabling/hiding others.
+ */
+ private List getUserMenu(User user) throws RemoteException {
+ // TODO: maybe make these all class members, there's no point in re-instantiating every time we want to make a menu.
+ List menuItems = new ArrayList();
+ ChannelMenuItem kickItem = new ChannelMenuItem(KICK_ID, getActivity().getString(R.string.user_menu_kick), R.drawable.ic_action_delete_dark);
+ ChannelMenuItem banItem = new ChannelMenuItem(BAN_ID, getActivity().getString(R.string.user_menu_ban), R.drawable.ic_action_error);
+ ChannelMenuItem muteItem = new ChannelMenuItem(MUTE_ID, getActivity().getString(R.string.user_menu_mute), R.drawable.ic_action_microphone);
+ ChannelMenuItem deafItem = new ChannelMenuItem(DEAFEN_ID, getActivity().getString(R.string.user_menu_deafen), R.drawable.ic_action_headphones);
+ ChannelMenuItem priorityItem = new ChannelMenuItem(PRIORITY_ID, getActivity().getString(R.string.user_menu_priority_speaker), R.drawable.ic_action_audio_on);
+ ChannelMenuItem localMuteItem = new ChannelMenuItem(LOCAL_MUTE_ID, getActivity().getString(R.string.user_menu_local_mute), R.drawable.ic_action_audio_muted);
+ ChannelMenuItem ignoreMessagesItem = new ChannelMenuItem(IGNORE_MESSAGES_ID, getActivity().getString(R.string.user_menu_ignore_messages), R.drawable.ic_action_bad);
+ ChannelMenuItem changeCommentItem = new ChannelMenuItem(CHANGE_COMMENT_ID, getActivity().getString(R.string.user_menu_change_comment), R.drawable.ic_action_edit_dark);
+ ChannelMenuItem viewCommentItem = new ChannelMenuItem(VIEW_COMMENT_ID, getActivity().getString(R.string.user_menu_view_comment), R.drawable.ic_action_comment);
+ ChannelMenuItem resetCommentItem = new ChannelMenuItem(RESET_COMMENT_ID, getActivity().getString(R.string.user_menu_reset_comment), R.drawable.ic_action_comment);
+ ChannelMenuItem informationItem = new ChannelMenuItem(USER_INFORMATION_ID, getActivity().getString(R.string.user_menu_information), R.drawable.ic_action_info_dark);
+ ChannelMenuItem sendMessageItem = new ChannelMenuItem(SEND_MESSAGE_ID, getActivity().getString(R.string.user_menu_send_message), R.drawable.ic_action_chat_dark);
+ ChannelMenuItem registerItem = new ChannelMenuItem(REGISTER_ID, getActivity().getString(R.string.user_menu_register), R.drawable.ic_registered);
+
+ boolean self = user.getSession() == getService().getSession();
+
+ if((getService().getPermissions() & (Permissions.Kick | Permissions.Ban | Permissions.Write)) > 0)
+ menuItems.add(kickItem);
+
+ if((getService().getPermissions() & (Permissions.Ban | Permissions.Write)) > 0)
+ menuItems.add(banItem);
+
+ menuItems.add(muteItem);
+ menuItems.add(deafItem);
+ menuItems.add(priorityItem);
+ menuItems.add(localMuteItem);
+ menuItems.add(ignoreMessagesItem);
+
+ if(self) {
+ menuItems.add(changeCommentItem);
+ } else {
+ menuItems.add(viewCommentItem);
+ menuItems.add(resetCommentItem);
+ }
+
+// menuItems.add(informationItem); TODO
+ menuItems.add(sendMessageItem);
+
+ menuItems.add(registerItem);
+
+ registerItem.enabled = user.getUserId() < 0 && (user.getHash() != null && !user.getHash().isEmpty()) && (getService().getPermissions() & ((self ? Permissions.SelfRegister : Permissions.Register) | Permissions.Write)) > 0; // Enable if we can register, and the user isn't registered.
+ registerItem.title = user.getUserId() < 0 ? getActivity().getString(R.string.user_menu_register) : getActivity().getString(R.string.user_menu_registered); // Say 'registered' if registered.
+
+ Channel channel = getService().getChannel(user.getChannelId());
+ int channelPermissions = channel.getPermissions();
+
+ if(channelPermissions == 0) {
+ getService().requestPermissions(channel.getId());
+ if(channel.getId() == 0)
+ channelPermissions = getService().getPermissions();
+ else
+ channelPermissions = Permissions.All;
+ channel.setPermissions(channelPermissions);
+ }
+
+ muteItem.enabled = ((channelPermissions & (Permissions.Write | Permissions.MuteDeafen)) > 0 && ((user.getSession() != getService().getSession()) || user.isMuted() || user.isSuppressed()));
+ deafItem.enabled = ((channelPermissions & (Permissions.Write | Permissions.MuteDeafen)) > 0 && ((user.getSession() != getService().getSession()) || user.isDeafened()));
+ priorityItem.enabled = ((channelPermissions & (Permissions.Write | Permissions.MuteDeafen)) > 0);
+ sendMessageItem.enabled = ((channelPermissions & (Permissions.Write | Permissions.TextMessage)) > 0);
+ informationItem.enabled = (((getService().getPermissions() & (Permissions.Write | Permissions.Register))) > 0 || (channelPermissions & (Permissions.Write | Permissions.Enter)) > 0 || (user.getSession() == getService().getSession()));
+
+ kickItem.enabled = !self;
+ banItem.enabled = !self;
+ localMuteItem.enabled = !self;
+ ignoreMessagesItem.enabled = !self;
+ resetCommentItem.enabled = user.getCommentHash() != null && !user.getCommentHash().isEmpty() && (getService().getPermissions() & (Permissions.Move | Permissions.Write)) > 0;
+ viewCommentItem.enabled = (user.getComment() != null && !user.getComment().isEmpty()) || (user.getCommentHash() != null && !user.getCommentHash().isEmpty());
+
+ // Highlight toggles
+ muteItem.toggled = user.isMuted();
+ deafItem.toggled = user.isDeafened();
+ priorityItem.toggled = user.isPrioritySpeaker();
+ localMuteItem.toggled = user.isLocalMuted();
+ ignoreMessagesItem.toggled = user.isLocalIgnored();
+ sendMessageItem.toggled = mTargetProvider.getChatTarget() != null && mTargetProvider.getChatTarget().getUser() != null ? mTargetProvider.getChatTarget().getUser().getSession() == user.getSession() : false;
+
+ return menuItems;
+ }
+
+ private boolean isShowingPinnedChannels() {
+ return getArguments().getBoolean("pinned");
+ }
+
+ @Override
+ public void onCommentChanged(int session, String comment) {
+ try {
+ getService().setUserComment(session, comment);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private class ChannelMenuItem {
+ public int id;
+ public String title;
+ public int icon;
+ public boolean enabled = true;
+ public boolean toggled;
+
+ public ChannelMenuItem(int id, String title, int icon) {
+ this.id = id;
+ this.title = title;
+ this.icon = icon;
+ }
+ }
+
+ private class PopupGridMenuAdapter extends ArrayAdapter {
+
+ public PopupGridMenuAdapter(Context context, List items) {
+ super(context, 0, items);
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View v = convertView;
+ if(v == null) {
+ LayoutInflater inflater = LayoutInflater.from(getContext());
+ v = inflater.inflate(R.layout.popup_user_menu_item, parent, false);
+ }
+
+ ImageView icon = (ImageView) v.findViewById(R.id.user_menu_item_icon);
+ TextView title = (TextView) v.findViewById(R.id.user_menu_item_title);
+
+ ChannelMenuItem item = getItem(position);
+
+ icon.setImageResource(item.icon);
+ title.setText(item.title);
+
+ // Retrieve the title color and manipulate it
+ int filterColor = item.toggled ? getResources().getColor(R.color.holo_blue_light) : title.getCurrentTextColor();
+
+ // If the item isn't enabled, dim.
+ if(!item.enabled) {
+ filterColor &= 0x00FFFFFF; // First, remove opacity data.
+ filterColor |= 0x80000000; // Then use an OR operation to apply 50% alpha.
+ }
+
+ // Apply #33b5e5 (R.I.P. #holoyolo) color filter when toggled. Use the title's color (likely ?textColorSecondary) for the icon otherwise. TODO use defined ?highlightColor.
+ icon.setColorFilter(filterColor, PorterDuff.Mode.MULTIPLY);
+ title.setTextColor(filterColor);
+
+ return v;
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return getItem(position).id;
+ }
+
+ @Override
+ public boolean isEnabled(int position) {
+ return getItem(position).enabled;
+ }
+ }
+
+ private class ChannelPopupMenuListener implements PopupMenu.OnMenuItemClickListener {
+
+ private Channel mChannel;
+
+ public ChannelPopupMenuListener(Channel channel) {
+ mChannel = channel;
+ }
+
+ @Override
+ public boolean onMenuItemClick(MenuItem menuItem) {
+ boolean adding = false;
+ switch(menuItem.getItemId()) {
+ case R.id.menu_channel_add:
+ adding = true;
+ case R.id.menu_channel_edit:
+ ChannelEditFragment addFragment = new ChannelEditFragment();
+ Bundle args = new Bundle();
+ if(adding) args.putInt("parent", mChannel.getId());
+ else args.putInt("channel", mChannel.getId());
+ args.putBoolean("adding", adding);
+ addFragment.setArguments(args);
+ addFragment.show(getChildFragmentManager(), "ChannelAdd");
+ return true;
+ case R.id.menu_channel_remove:
+ AlertDialog.Builder adb = new AlertDialog.Builder(getActivity());
+ adb.setTitle(R.string.confirm);
+ adb.setMessage(R.string.confirm_delete_channel);
+ adb.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ try {
+ getService().removeChannel(mChannel.getId());
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ adb.setNegativeButton(android.R.string.cancel, null);
+ adb.show();
+ return true;
+ case R.id.menu_channel_send_message:
+ if(mTargetProvider.getChatTarget() != null &&
+ mTargetProvider.getChatTarget().getChannel() != null &&
+ mTargetProvider.getChatTarget().getChannel().getId() == mChannel.getId())
+ mTargetProvider.setChatTarget(null);
+ else
+ mTargetProvider.setChatTarget(new ChatTargetProvider.ChatTarget(mChannel));
+ return true;
+ case R.id.menu_channel_pin:
+ try {
+ long serverId = getService().getConnectedServer().getId();
+ boolean pinned = mDatabaseProvider.getDatabase().isChannelPinned(serverId, mChannel.getId());
+ if(!pinned) mDatabaseProvider.getDatabase().addPinnedChannel(serverId, mChannel.getId());
+ else mDatabaseProvider.getDatabase().removePinnedChannel(serverId, mChannel.getId());
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ return true;
+ }
+ return false;
+ }
+ }
+
+ private class UserMenuListener implements GridView.OnItemClickListener {
+
+ private User mUser;
+ private PopupWindow mWindow;
+
+ public UserMenuListener(User user, PopupWindow window) {
+ mUser = user;
+ mWindow = window;
+ }
+
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ try {
+ boolean ban = false;
+ switch ((int)id) {
+ case BAN_ID:
+ ban = true;
+ case KICK_ID:
+ AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getActivity());
+ alertBuilder.setTitle(R.string.user_menu_kick);
+ final EditText reasonField = new EditText(getActivity());
+ reasonField.setHint(R.string.hint_reason);
+ alertBuilder.setView(reasonField);
+ final boolean finalBan = ban;
+ alertBuilder.setPositiveButton(R.string.user_menu_kick, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ try {
+ getService().kickBanUser(mUser.getSession(), reasonField.getText().toString(), finalBan);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ alertBuilder.setNegativeButton(android.R.string.cancel, null);
+ alertBuilder.show();
+ break;
+ case MUTE_ID:
+ getService().setMuteDeafState(mUser.getSession(), !mUser.isMuted(), mUser.isDeafened());
+ break;
+ case DEAFEN_ID:
+ getService().setMuteDeafState(mUser.getSession(), mUser.isMuted(), !mUser.isDeafened());
+ break;
+ case PRIORITY_ID:
+ getService().setPrioritySpeaker(mUser.getSession(), !mUser.isPrioritySpeaker());
+ break;
+ case LOCAL_MUTE_ID:
+ mUser.setLocalMuted(!mUser.isLocalMuted());
+ break;
+ case IGNORE_MESSAGES_ID:
+ mUser.setLocalIgnored(!mUser.isLocalIgnored());
+ break;
+ case CHANGE_COMMENT_ID:
+ showUserComment(true);
+ break;
+ case VIEW_COMMENT_ID:
+ showUserComment(false);
+ break;
+ case RESET_COMMENT_ID:
+ new AlertDialog.Builder(getActivity())
+ .setMessage(getString(R.string.confirm_reset_comment, mUser.getName()))
+ .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ try {
+ getService().setUserComment(mUser.getSession(), "");
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ })
+ .setNegativeButton(android.R.string.cancel, null)
+ .show();
+ break;
+ case USER_INFORMATION_ID:
+ break;
+ case SEND_MESSAGE_ID:
+ if(mTargetProvider.getChatTarget() != null &&
+ mTargetProvider.getChatTarget().getUser() != null &&
+ mTargetProvider.getChatTarget().getUser().getSession() == mUser.getSession()) {
+ mTargetProvider.setChatTarget(null); // If selecting the same user, deselect target.
+ } else {
+ ChatTargetProvider.ChatTarget target = new ChatTargetProvider.ChatTarget(mUser);
+ mTargetProvider.setChatTarget(target);
+ }
+ break;
+ case REGISTER_ID:
+ getService().registerUser(mUser.getSession());
+ break;
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+
+ mWindow.dismiss();
+ }
+
+ private void showUserComment(final boolean edit) {
+ if(mUser.getCommentHash() != null && mUser.getComment() == null) {
+ try {
+ final ProgressDialog dialog = ProgressDialog.show(getActivity(), null, getString(R.string.loading), true, true);
+ // Send a RequestBlob to the server to ask for the comment. Register a listener to show the edit dialog when we get the response.
+ getService().registerObserver(new JumbleObserver() {
+ @Override
+ public void onUserStateUpdated(User user) throws RemoteException {
+ if(user.getSession() == mUser.getSession() && user.getComment() != null) {
+ getService().unregisterObserver(this); // TODO if we don't get a response find a way to unregister this anyway
+ dialog.dismiss();
+ showUserComment(edit);
+ }
+ }
+ });
+ getService().requestComment(mUser.getSession());
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+
+ } else {
+ CommentFragment editCommentFragment = CommentFragment.newInstance(mUser.getSession(), mUser.getComment(), edit);
+ editCommentFragment.show(getChildFragmentManager(), CommentFragment.class.getName());
+ }
+ }
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelSearchProvider.java b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelSearchProvider.java
new file mode 100644
index 00000000..5d1ee161
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ChannelSearchProvider.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.channel;
+
+import android.app.SearchManager;
+import android.content.ComponentName;
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.database.Cursor;
+import android.database.MatrixCursor;
+import android.net.Uri;
+import android.os.IBinder;
+import android.os.RemoteException;
+
+import com.morlunk.jumble.IJumbleService;
+import com.morlunk.jumble.model.Channel;
+import com.morlunk.jumble.model.User;
+import com.morlunk.mumbleclient.R;
+import com.morlunk.mumbleclient.service.PlumbleService;
+
+import java.util.List;
+import java.util.Locale;
+
+public class ChannelSearchProvider extends ContentProvider {
+
+ public static final String INTENT_DATA_CHANNEL = "channel";
+ public static final String INTENT_DATA_USER = "user";
+
+ private ServiceConnection conn = new ServiceConnection() {
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ mService = (IJumbleService) service;
+ synchronized (mServiceLock) {
+ mServiceLock.notify();
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ mService = null;
+ }
+ };
+
+ private IJumbleService mService;
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean onCreate() {
+ return true;
+ }
+
+ private Object mServiceLock = new Object();
+
+
+ @Override
+ public Cursor query(Uri uri, String[] projection, String selection,
+ String[] selectionArgs, String sortOrder) {
+
+ // Try to connect to the service. Wait for conn to establish.
+ if(mService == null) {
+ Intent serviceIntent = new Intent(getContext(), PlumbleService.class);
+ getContext().bindService(serviceIntent, conn, 0);
+
+ synchronized (mServiceLock) {
+ try {
+ mServiceLock.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ String query = "";
+ for(int x=0;x channels;
+ List users;
+ try {
+ channels = mService.getChannelList();
+ users = mService.getUserList();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ for(int x=0;x.
+ */
+
+package com.morlunk.mumbleclient.channel;
+
+import com.morlunk.jumble.model.Channel;
+import com.morlunk.jumble.model.User;
+
+public interface ChatTargetProvider {
+
+ /**
+ * Abstraction for user and channel chat targets.
+ */
+ public class ChatTarget {
+ private Channel mChannel;
+ private User mUser;
+
+ public ChatTarget(Channel channel) {
+ mChannel = channel;
+ }
+
+ public ChatTarget(User user) {
+ mUser = user;
+ }
+
+ public Channel getChannel() {
+ return mChannel;
+ }
+
+ public User getUser() {
+ return mUser;
+ }
+ }
+
+ /**
+ * Interface for classes which wish to receive chat target change calls.
+ * Created by andrew on 06/08/13.
+ */
+ public interface OnChatTargetSelectedListener {
+ public void onChatTargetSelected(ChatTarget target);
+ }
+
+ public ChatTarget getChatTarget();
+ public void setChatTarget(ChatTarget target);
+ public void registerChatTargetListener(OnChatTargetSelectedListener listener);
+ public void unregisterChatTargetListener(OnChatTargetSelectedListener listener);
+}
\ No newline at end of file
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/channel/CommentFragment.java b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/CommentFragment.java
new file mode 100644
index 00000000..5351a6ec
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/CommentFragment.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.channel;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.webkit.WebView;
+import android.widget.EditText;
+import android.widget.TabHost;
+
+import com.morlunk.mumbleclient.R;
+
+/**
+ * Fragment to change your comment using basic WYSIWYG tools.
+ * Created by andrew on 10/08/13.
+ */
+public class CommentFragment extends DialogFragment {
+
+ public interface CommentFragmentListener {
+ public void onCommentChanged(int session, String comment);
+ }
+
+ private CommentFragmentListener mListener;
+ private TabHost mTabHost;
+ private WebView mCommentView;
+ private EditText mCommentEdit;
+
+ public static CommentFragment newInstance(int session, String comment, boolean editing) {
+ CommentFragment fragment = new CommentFragment();
+ Bundle args = new Bundle();
+ args.putInt("session", session);
+ args.putString("comment", comment);
+ args.putBoolean("editing", editing);
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ try {
+ mListener = (CommentFragmentListener) getParentFragment();
+ } catch (ClassCastException e) {
+ throw new ClassCastException(getParentFragment().toString() + " must implement CommentFragmentListener");
+ }
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ LayoutInflater inflater = LayoutInflater.from(getActivity());
+ View view = inflater.inflate(R.layout.dialog_comment, null, false);
+
+ mCommentView = (WebView) view.findViewById(R.id.comment_view);
+ mCommentView.loadData(getComment(), "text/html", "UTF-8");
+ mCommentEdit = (EditText) view.findViewById(R.id.comment_edit);
+
+ mTabHost = (TabHost) view.findViewById(R.id.comment_tabhost);
+ mTabHost.setup();
+
+ TabHost.TabSpec viewTab = mTabHost.newTabSpec("View");
+ viewTab.setIndicator(getString(R.string.comment_view));
+ viewTab.setContent(R.id.comment_tab_view);
+
+ TabHost.TabSpec editTab = mTabHost.newTabSpec("Edit");
+ editTab.setIndicator(getString(isEditing() ? R.string.comment_edit_source : R.string.comment_view_source));
+ editTab.setContent(R.id.comment_tab_edit);
+
+ mTabHost.addTab(viewTab);
+ mTabHost.addTab(editTab);
+
+ mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
+ @Override
+ public void onTabChanged(String tabId) {
+ if("View".equals(tabId)) {
+ // When switching back to view tab, update with user's HTML changes.
+ mCommentView.loadData(mCommentEdit.getText().toString(), "text/html", "UTF-8");
+ } else if("Edit".equals(tabId) && "".equals(mCommentEdit.getText().toString())) {
+ // Load edittext content for the first time when the tab is selected, to improve performance with long messages.
+ mCommentEdit.setText(getComment());
+ }
+ }
+ });
+
+ mTabHost.setCurrentTab(isEditing() ? 1 : 0);
+
+ AlertDialog.Builder adb = new AlertDialog.Builder(getActivity());
+ adb.setView(view);
+ if (isEditing()) {
+ adb.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ mListener.onCommentChanged(getSession(), mCommentEdit.getText().toString());
+ }
+ });
+ }
+ adb.setNegativeButton(R.string.close, null);
+ return adb.create();
+ }
+
+ public int getSession() {
+ return getArguments().getInt("session");
+ }
+
+ public String getComment() {
+ return getArguments().getString("comment");
+ }
+
+ public boolean isEditing() {
+ return getArguments().getBoolean("editing");
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ServerInfoFragment.java b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ServerInfoFragment.java
new file mode 100644
index 00000000..fddc1b0d
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/channel/ServerInfoFragment.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.channel;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.RemoteException;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.morlunk.jumble.IJumbleService;
+import com.morlunk.jumble.net.JumbleUDPMessageType;
+import com.morlunk.mumbleclient.R;
+import com.morlunk.mumbleclient.util.JumbleServiceFragment;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * A fragment that displays known information from the remote server.
+ * Created by andrew on 28/08/13.
+ */
+public class ServerInfoFragment extends JumbleServiceFragment {
+
+ private static final int POLL_RATE = 1000;
+
+ private ScheduledExecutorService mExecutorService = Executors.newSingleThreadScheduledExecutor();
+ private Handler mHandler = new Handler(Looper.getMainLooper());
+
+ private TextView mProtocolView;
+ private TextView mOSVersionView;
+ private TextView mTCPLatencyView;
+ private TextView mUDPLatencyView;
+ private TextView mHostView;
+ private TextView mCodecView;
+ private TextView mMaxBandwidthView;
+ private TextView mCurrentBandwidthView;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_server_info, container, false);
+ mProtocolView = (TextView) view.findViewById(R.id.server_info_protocol);
+ mOSVersionView = (TextView) view.findViewById(R.id.server_info_os_version);
+ mTCPLatencyView = (TextView) view.findViewById(R.id.server_info_tcp_latency);
+ mUDPLatencyView = (TextView) view.findViewById(R.id.server_info_udp_latency);
+ mHostView = (TextView) view.findViewById(R.id.server_info_host);
+ mMaxBandwidthView = (TextView) view.findViewById(R.id.server_info_max_bandwidth);
+ mCurrentBandwidthView = (TextView) view.findViewById(R.id.server_info_current_bandwidth);
+ mCodecView = (TextView) view.findViewById(R.id.server_info_codec);
+ return view;
+ }
+
+ /**
+ * Updates the info from the service.
+ */
+ public void updateData() throws RemoteException {
+ if(getService() == null || !getService().isConnected())
+ return;
+
+ mProtocolView.setText(getString(R.string.server_info_protocol, getService().getServerRelease()));
+ mOSVersionView.setText(getString(R.string.server_info_version, getService().getServerOSName(), getService().getServerOSVersion()));
+ mTCPLatencyView.setText(getString(R.string.server_info_latency, (float)getService().getTCPLatency()*Math.pow(10, -3)));
+ mUDPLatencyView.setText(getString(R.string.server_info_latency, (float)getService().getUDPLatency()*Math.pow(10, -3)));
+ mHostView.setText(getString(R.string.server_info_host, getService().getConnectedServer().getHost(), getService().getConnectedServer().getPort()));
+
+ String codecName;
+ JumbleUDPMessageType codecType = JumbleUDPMessageType.values()[getService().getCodec()];
+ switch (codecType) {
+ case UDPVoiceOpus:
+ codecName = "Opus";
+ break;
+ case UDPVoiceCELTBeta:
+ codecName = "CELT 0.11.0";
+ break;
+ case UDPVoiceCELTAlpha:
+ codecName = "CELT 0.7.0";
+ break;
+ case UDPVoiceSpeex:
+ codecName = "Speex";
+ break;
+ default:
+ codecName = "???";
+ }
+
+ mMaxBandwidthView.setText(getString(R.string.server_info_max_bandwidth, (float)getService().getMaxBandwidth()/1000f));
+ mCurrentBandwidthView.setText(getString(R.string.server_info_current_bandwidth, (float)getService().getCurrentBandwidth()/1000f));
+ mCodecView.setText(getString(R.string.server_info_codec, codecName));
+ }
+
+ @Override
+ public void onServiceBound(IJumbleService service) {
+ // wow this is ugly
+ mExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ updateData();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+ }, 0, POLL_RATE, TimeUnit.MILLISECONDS);
+ }
+
+ @Override
+ public void onDestroy() {
+ mExecutorService.shutdownNow();
+ super.onDestroy();
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/db/DatabaseProvider.java b/Plumble/src/main/java/com/morlunk/mumbleclient/db/DatabaseProvider.java
new file mode 100644
index 00000000..31ae9582
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/db/DatabaseProvider.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.db;
+
+/**
+ * Created by andrew on 15/08/13.
+ */
+public interface DatabaseProvider {
+ public PlumbleDatabase getDatabase();
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/db/PlumbleDatabase.java b/Plumble/src/main/java/com/morlunk/mumbleclient/db/PlumbleDatabase.java
new file mode 100644
index 00000000..a7be94c2
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/db/PlumbleDatabase.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.db;
+
+import com.morlunk.jumble.model.Server;
+
+import java.util.List;
+
+/**
+ * An interface for persistent storage services (i.e. databases, cloud) to implement.
+ * Created by andrew on 13/08/13.
+ */
+public interface PlumbleDatabase {
+ public List getServers();
+ public void addServer(Server server);
+ public void updateServer(Server server);
+ public void removeServer(Server server);
+
+ public boolean isCommentSeen(String hash, byte[] commentHash);
+ public void markCommentSeen(String hash, byte[] commentHash);
+
+ public List getPinnedChannels(long serverId);
+ public void addPinnedChannel(long serverId, int channelId);
+ public void removePinnedChannel(long serverId, int channelId);
+ public boolean isChannelPinned(long serverId, int channelId);
+
+ public List getAccessTokens(long serverId);
+ public void addAccessToken(long serverId, String token);
+ public void removeAccessToken(long serverId, String token);
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/db/PlumbleSQLiteDatabase.java b/Plumble/src/main/java/com/morlunk/mumbleclient/db/PlumbleSQLiteDatabase.java
new file mode 100644
index 00000000..db3e0bde
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/db/PlumbleSQLiteDatabase.java
@@ -0,0 +1,277 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.db;
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+import android.util.Log;
+
+import com.morlunk.jumble.model.Server;
+import com.morlunk.mumbleclient.Constants;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PlumbleSQLiteDatabase extends SQLiteOpenHelper implements PlumbleDatabase {
+
+ public static final String DATABASE_NAME = "mumble.db";
+
+ public static final String TABLE_SERVER = "server";
+ public static final String SERVER_ID = "_id";
+ public static final String SERVER_NAME = "name";
+ public static final String SERVER_HOST = "host";
+ public static final String SERVER_PORT = "port";
+ public static final String SERVER_USERNAME = "username";
+ public static final String SERVER_PASSWORD = "password";
+ public static final String TABLE_SERVER_CREATE_SQL = "CREATE TABLE IF NOT EXISTS `" + TABLE_SERVER + "` ("
+ + "`" + SERVER_ID + "` INTEGER PRIMARY KEY AUTOINCREMENT,"
+ + "`" + SERVER_NAME + "` TEXT NOT NULL,"
+ + "`" + SERVER_HOST + "` TEXT NOT NULL,"
+ + "`" + SERVER_PORT + "` INTEGER,"
+ + "`" + SERVER_USERNAME + "` TEXT NOT NULL,"
+ + "`" + SERVER_PASSWORD + "` TEXT"
+ + ");";
+
+ public static final String TABLE_FAVOURITES = "favourites";
+ public static final String FAVOURITES_ID = "_id";
+ public static final String FAVOURITES_CHANNEL = "channel";
+ public static final String FAVOURITES_SERVER = "server";
+ public static final String TABLE_FAVOURITES_CREATE_SQL = "CREATE TABLE IF NOT EXISTS `" + TABLE_FAVOURITES + "` ("
+ + "`" + FAVOURITES_ID + "` INTEGER PRIMARY KEY AUTOINCREMENT,"
+ + "`" + FAVOURITES_CHANNEL + "` TEXT NOT NULL,"
+ + "`" + FAVOURITES_SERVER + "` INTEGER NOT NULL"
+ + ");";
+
+ public static final String TABLE_TOKENS = "tokens";
+ public static final String TOKENS_ID = "_id";
+ public static final String TOKENS_VALUE = "value";
+ public static final String TOKENS_SERVER = "server";
+ public static final String TABLE_TOKENS_CREATE_SQL = "CREATE TABLE IF NOT EXISTS `" + TABLE_TOKENS + "` ("
+ + "`" + TOKENS_ID + "` INTEGER PRIMARY KEY AUTOINCREMENT,"
+ + "`" + TOKENS_VALUE + "` TEXT NOT NULL,"
+ + "`" + TOKENS_SERVER + "` INTEGER NOT NULL"
+ + ");";
+
+ public static final String TABLE_COMMENTS = "comments";
+ public static final String COMMENTS_WHO = "who";
+ public static final String COMMENTS_COMMENT = "comment";
+ public static final String COMMENTS_SEEN = "seen";
+ public static final String TABLE_COMMENTS_CREATE_SQL = "CREATE TABLE IF NOT EXISTS `" + TABLE_COMMENTS + "` ("
+ + "`" + COMMENTS_WHO + "` TEXT NOT NULL,"
+ + "`" + COMMENTS_COMMENT + "` TEXT NOT NULL,"
+ + "`" + COMMENTS_SEEN + "` DATE NOT NULL"
+ + ");";
+
+ public static final Integer PRE_FAVOURITES_DB_VERSION = 2;
+ public static final Integer PRE_TOKENS_DB_VERSION = 3;
+ public static final Integer PRE_COMMENTS_DB_VERSION = 4;
+ public static final Integer CURRENT_DB_VERSION = 5;
+
+ public PlumbleSQLiteDatabase(Context context) {
+ super(context, DATABASE_NAME, null, CURRENT_DB_VERSION);
+ }
+
+ @Override
+ public void onCreate(SQLiteDatabase db) {
+ db.execSQL(TABLE_SERVER_CREATE_SQL);
+ db.execSQL(TABLE_FAVOURITES_CREATE_SQL);
+ db.execSQL(TABLE_TOKENS_CREATE_SQL);
+ db.execSQL(TABLE_COMMENTS_CREATE_SQL);
+ }
+
+ @Override
+ public void onUpgrade(
+ SQLiteDatabase db,
+ int oldVersion,
+ int newVersion) {
+ Log.w(Constants.TAG, "Database upgrade from " + oldVersion + " to " + newVersion);
+ if (oldVersion <= PRE_FAVOURITES_DB_VERSION) {
+ db.execSQL(TABLE_FAVOURITES_CREATE_SQL);
+ }
+
+ if (oldVersion <= PRE_TOKENS_DB_VERSION) {
+ db.execSQL(TABLE_TOKENS_CREATE_SQL);
+ }
+
+ if (oldVersion <= PRE_COMMENTS_DB_VERSION) {
+ db.execSQL(TABLE_COMMENTS_CREATE_SQL);
+ }
+ }
+
+ @Override
+ public List getServers() {
+ Cursor c = getReadableDatabase().query(
+ TABLE_SERVER,
+ new String[]{SERVER_ID, SERVER_NAME, SERVER_HOST,
+ SERVER_PORT, SERVER_USERNAME, SERVER_PASSWORD},
+ null,
+ null,
+ null,
+ null,
+ null);
+
+ List servers = new ArrayList();
+
+ c.moveToFirst();
+ while (!c.isAfterLast()) {
+ Server server = new Server(c.getInt(c.getColumnIndex(SERVER_ID)),
+ c.getString(c.getColumnIndex(SERVER_NAME)),
+ c.getString(c.getColumnIndex(SERVER_HOST)),
+ c.getInt(c.getColumnIndex(SERVER_PORT)),
+ c.getString(c.getColumnIndex(SERVER_USERNAME)),
+ c.getString(c.getColumnIndex(SERVER_PASSWORD)));
+ servers.add(server);
+ c.moveToNext();
+ }
+
+ c.close();
+
+ return servers;
+ }
+
+ @Override
+ public void addServer(Server server) {
+ ContentValues values = new ContentValues();
+ values.put(SERVER_NAME, server.getName());
+ values.put(SERVER_HOST, server.getHost());
+ values.put(SERVER_PORT, server.getPort());
+ values.put(SERVER_USERNAME, server.getUsername());
+ values.put(SERVER_PASSWORD, server.getPassword());
+
+ server.setId(getWritableDatabase().insert(TABLE_SERVER, null, values));
+ }
+
+ @Override
+ public void updateServer(Server server) {
+ ContentValues values = new ContentValues();
+ values.put(SERVER_NAME, server.getName());
+ values.put(SERVER_HOST, server.getHost());
+ values.put(SERVER_PORT, server.getPort());
+ values.put(SERVER_USERNAME, server.getUsername());
+ values.put(SERVER_PASSWORD, server.getPassword());
+ getWritableDatabase().update(
+ TABLE_SERVER,
+ values,
+ SERVER_ID + "=?",
+ new String[]{Long.toString(server.getId())});
+ }
+
+ @Override
+ public void removeServer(Server server) {
+ getWritableDatabase().delete(TABLE_SERVER, SERVER_ID + " = " + server.getId(), null);
+ }
+
+ public List getPinnedChannels(long serverId) {
+
+ final Cursor c = getReadableDatabase().query(
+ TABLE_FAVOURITES,
+ new String[]{FAVOURITES_CHANNEL},
+ FAVOURITES_SERVER + "=?",
+ new String[]{String.valueOf(serverId)},
+ null,
+ null,
+ null);
+
+ List favourites = new ArrayList();
+ c.moveToFirst();
+ while (!c.isAfterLast()) {
+ favourites.add(c.getInt(0));
+ c.moveToNext();
+ }
+
+ c.close();
+
+ return favourites;
+ }
+
+ @Override
+ public void addPinnedChannel(long serverId, int channelId) {
+ ContentValues contentValues = new ContentValues();
+ contentValues.put(FAVOURITES_CHANNEL, channelId);
+ contentValues.put(FAVOURITES_SERVER, serverId);
+ getWritableDatabase().insert(TABLE_FAVOURITES, null, contentValues);
+ }
+
+ @Override
+ public boolean isChannelPinned(long serverId, int channelId) {
+ Cursor c = getReadableDatabase().query(
+ TABLE_FAVOURITES,
+ new String[]{FAVOURITES_CHANNEL},
+ FAVOURITES_SERVER + "=? AND " +
+ FAVOURITES_CHANNEL + "=?",
+ new String[]{String.valueOf(serverId), String.valueOf(channelId)},
+ null,
+ null,
+ null);
+ c.moveToFirst();
+ return !c.isAfterLast();
+ }
+
+ public void removePinnedChannel(long serverId, int channelId) {
+ getWritableDatabase().delete(TABLE_FAVOURITES, "server = ? AND channel = ?", new String[] { Long.toString(serverId), Integer.toString(channelId)});
+ }
+
+ @Override
+ public List getAccessTokens(long serverId) {
+ Cursor cursor = getReadableDatabase().query(TABLE_TOKENS, new String[] { TOKENS_VALUE }, TOKENS_SERVER+"=?", new String[] { String.valueOf(serverId) }, null, null, null);
+ cursor.moveToFirst();
+ List tokens = new ArrayList();
+ while(!cursor.isAfterLast()) {
+ tokens.add(cursor.getString(0));
+ cursor.moveToNext();
+ }
+ cursor.close();
+ return tokens;
+ }
+
+ @Override
+ public void addAccessToken(long serverId, String token) {
+ ContentValues contentValues = new ContentValues();
+ contentValues.put(TOKENS_SERVER, serverId);
+ contentValues.put(TOKENS_VALUE, token);
+ getWritableDatabase().insert(TABLE_TOKENS, null, contentValues);
+ }
+
+ @Override
+ public void removeAccessToken(long serverId, String token) {
+ getWritableDatabase().delete(TABLE_TOKENS, TOKENS_SERVER+"=? AND "+TOKENS_VALUE+"=?", new String[] {String.valueOf(serverId), token });
+ }
+
+ @Override
+ public boolean isCommentSeen(String hash, byte[] commentHash) {
+ Cursor cursor = getReadableDatabase().query(TABLE_COMMENTS,
+ new String[]{COMMENTS_WHO, COMMENTS_COMMENT, COMMENTS_SEEN}, COMMENTS_WHO + "=? AND " + COMMENTS_COMMENT + "=?",
+ new String[]{hash, new String(commentHash)},
+ null, null, null);
+ boolean hasNext = cursor.moveToNext();
+ cursor.close();
+ return hasNext;
+ }
+
+ @Override
+ public void markCommentSeen(String hash, byte[] commentHash) {
+ ContentValues values = new ContentValues();
+ values.put(COMMENTS_WHO, hash);
+ values.put(COMMENTS_COMMENT, commentHash);
+ values.put(COMMENTS_SEEN, "datetime('now')");
+ getWritableDatabase().replace(TABLE_COMMENTS, null, values);
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/db/PublicServer.java b/Plumble/src/main/java/com/morlunk/mumbleclient/db/PublicServer.java
new file mode 100644
index 00000000..3e914000
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/db/PublicServer.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.db;
+
+
+import com.morlunk.jumble.model.Server;
+
+public class PublicServer extends Server {
+
+ private String mCA;
+ private String mContinentCode;
+ private String mCountry;
+ private String mCountryCode;
+ private String mRegion;
+ private String mUrl;
+
+ public PublicServer(String name, String ca, String continentCode, String country, String countryCode, String ip, Integer port, String region, String url) {
+ super(-1, name, ip, port, "", "");
+ mCA = ca;
+ mContinentCode = continentCode;
+ mCountry = country;
+ mCountryCode = countryCode;
+ mRegion = region;
+ mUrl = url;
+ }
+
+ public String getCA() {
+ return mCA;
+ }
+
+ public String getContinentCode() {
+ return mContinentCode;
+ }
+
+ public String getCountry() {
+ return mCountry;
+ }
+
+ public String getCountryCode() {
+ return mCountryCode;
+ }
+
+ public String getRegion() {
+ return mRegion;
+ }
+
+ public String getUrl() {
+ return mUrl;
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/preference/KeySelectDialogPreference.java b/Plumble/src/main/java/com/morlunk/mumbleclient/preference/KeySelectDialogPreference.java
new file mode 100644
index 00000000..fac62e61
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/preference/KeySelectDialogPreference.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.preference;
+
+import android.annotation.TargetApi;
+import android.app.AlertDialog.Builder;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
+import android.content.DialogInterface.OnKeyListener;
+import android.preference.DialogPreference;
+import android.util.AttributeSet;
+import android.util.TypedValue;
+import android.view.Gravity;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup.LayoutParams;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.morlunk.mumbleclient.R;
+
+public class KeySelectDialogPreference extends DialogPreference implements OnKeyListener {
+
+ //private static final String ANDROID_NAMESPACE = "http://schemas.android.com/apk/res/android";
+
+ private TextView valueTextView;
+ private int keyCode;
+
+ public KeySelectDialogPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onPrepareDialogBuilder(Builder builder) {
+ super.onPrepareDialogBuilder(builder);
+
+ builder.setOnKeyListener(this);
+ builder.setNeutralButton(R.string.reset_key, new OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ keyCode = 0;
+ valueTextView.setText("No Key");
+ }
+ });
+ }
+
+ @Override
+ protected View onCreateDialogView() {
+ LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
+ LinearLayout layout = new LinearLayout(getContext());
+ layout.setOrientation(LinearLayout.VERTICAL);
+ layout.setPadding(6,6,6,6);
+
+ TextView promptTextView = new TextView(getContext());
+ promptTextView.setText(R.string.pressKey);
+ promptTextView.setGravity(Gravity.CENTER_HORIZONTAL);
+
+ valueTextView = new TextView(getContext());
+ valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
+ valueTextView.setGravity(Gravity.CENTER_HORIZONTAL);
+ valueTextView.setPadding(0, 12, 0, 12);
+
+ TextView alertTextView = new TextView(getContext());
+ alertTextView.setText(R.string.pressKeyInfo);
+ alertTextView.setGravity(Gravity.CENTER_HORIZONTAL);
+ alertTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
+
+ layout.addView(promptTextView, params);
+ layout.addView(valueTextView, params);
+ layout.addView(alertTextView);
+
+ return layout;
+ }
+
+ @Override
+ protected void onSetInitialValue(boolean restorePersistedValue,
+ Object defaultValue) {
+ super.onSetInitialValue(restorePersistedValue, defaultValue);
+ if(restorePersistedValue) {
+ keyCode = getPersistedInt(0);
+ } else {
+ keyCode = (Integer)defaultValue;
+ }
+ }
+
+ @Override
+ protected void onDialogClosed(boolean positiveResult) {
+ if(positiveResult) {
+ persistInt(keyCode);
+ }
+
+ super.onDialogClosed(positiveResult);
+ }
+
+ @TargetApi(12)
+ @Override
+ protected void onBindDialogView(View view) {
+ super.onBindDialogView(view);
+ if(keyCode == 0) {
+ valueTextView.setText("No Key");
+ } else {
+ if(android.os.Build.VERSION.SDK_INT >= 12) {
+ valueTextView.setText(KeyEvent.keyCodeToString(keyCode));
+ } else {
+ valueTextView.setText("Key code: "+keyCode);
+ }
+ }
+ }
+
+ @TargetApi(12)
+ @Override
+ public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
+ if(keyCode != KeyEvent.KEYCODE_BACK) {
+ this.keyCode = keyCode;
+
+ if(android.os.Build.VERSION.SDK_INT >= 12) {
+ valueTextView.setText(KeyEvent.keyCodeToString(keyCode));
+ } else {
+ valueTextView.setText("Key code: "+keyCode);
+ }
+ } else {
+ dialog.dismiss();
+ }
+ return true;
+ }
+
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/preference/PlumbleCertificateGenerateTask.java b/Plumble/src/main/java/com/morlunk/mumbleclient/preference/PlumbleCertificateGenerateTask.java
new file mode 100644
index 00000000..8a94d36e
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/preference/PlumbleCertificateGenerateTask.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.preference;
+
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnCancelListener;
+import android.os.AsyncTask;
+import android.widget.Toast;
+
+import com.morlunk.mumbleclient.R;
+
+import java.io.File;
+
+public class PlumbleCertificateGenerateTask extends AsyncTask {
+
+ private Context context;
+ private ProgressDialog loadingDialog;
+
+ public PlumbleCertificateGenerateTask(Context context) {
+ this.context = context;
+ }
+
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+
+ loadingDialog = new ProgressDialog(context);
+ loadingDialog.setIndeterminate(true);
+ loadingDialog.setMessage(context.getString(R.string.generateCertProgress));
+ loadingDialog.setOnCancelListener(new OnCancelListener() {
+
+ @Override
+ public void onCancel(DialogInterface arg0) {
+ cancel(true);
+
+ }
+ });
+ loadingDialog.show();
+ }
+ @Override
+ protected File doInBackground(Void... params) {
+ try {
+ File certificate = PlumbleCertificateManager.generateCertificate();
+ return certificate;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ @Override
+ protected void onPostExecute(File result) {
+ super.onPostExecute(result);
+ if(result != null) {
+ Toast.makeText(context, context.getString(R.string.generateCertSuccess, result.getName()), Toast.LENGTH_SHORT).show();
+ } else {
+ Toast.makeText(context, R.string.generateCertFailure, Toast.LENGTH_SHORT).show();
+ }
+
+ loadingDialog.dismiss();
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/preference/PlumbleCertificateManager.java b/Plumble/src/main/java/com/morlunk/mumbleclient/preference/PlumbleCertificateManager.java
new file mode 100644
index 00000000..d7cb8847
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/preference/PlumbleCertificateManager.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.preference;
+
+import android.os.Environment;
+
+import com.morlunk.jumble.net.JumbleCertificateGenerator;
+
+import org.spongycastle.operator.OperatorCreationException;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.cert.CertificateException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+
+public class PlumbleCertificateManager {
+
+ private static final String PLUMBLE_CERTIFICATE_FOLDER = "Plumble";
+ private static final String PLUMBLE_CERTIFICATE_FORMAT = "plumble-%d.p12";
+ private static final String PLUMBLE_CERTIFICATE_EXTENSION = "p12";
+
+ /**
+ * Generates a new X.509 passwordless certificate in PKCS12 format for connection to a Mumble server.
+ * This certificate is stored in the {@value #PLUMBLE_CERTIFICATE_FOLDER} folder on the external storage, in the format {@value #PLUMBLE_CERTIFICATE_FORMAT} where the timestamp is substituted in.
+ * @return The path of the generated certificate if the operation was a success. Otherwise, null.
+ */
+ public static File generateCertificate() throws NoSuchAlgorithmException, OperatorCreationException, CertificateException, KeyStoreException, NoSuchProviderException, IOException {
+ File certificateDirectory = getCertificateDirectory();
+
+ String certificateName = String.format(Locale.US, PLUMBLE_CERTIFICATE_FORMAT, System.currentTimeMillis() / 1000L);
+ File certificateFile = new File(certificateDirectory, certificateName);
+ FileOutputStream outputStream = new FileOutputStream(certificateFile);
+ JumbleCertificateGenerator.generateCertificate(outputStream);
+ return certificateFile;
+ }
+
+ /**
+ * Returns a list of certificates in the {@value #PLUMBLE_CERTIFICATE_FOLDER} folder on external storage, ending with {@value #PLUMBLE_CERTIFICATE_EXTENSION}.
+ * @return A list of {@link File} objects containing certificates.
+ */
+ public static List getAvailableCertificates() {
+ File certificateDirectory = getCertificateDirectory();
+
+ File[] p12Files = certificateDirectory.listFiles(new FileFilter() {
+ @Override
+ public boolean accept(File pathname) {
+ return pathname.getName().endsWith(PLUMBLE_CERTIFICATE_EXTENSION);
+ }
+ });
+
+ return Arrays.asList(p12Files);
+ }
+
+ /**
+ * Returns the certificate directory, {@value #PLUMBLE_CERTIFICATE_FOLDER}, on external storage.
+ * Will create if does not exist, and throw an assert if the external storage is not mounted.
+ * @return The {@link File} object of the directory.
+ */
+ public static File getCertificateDirectory() {
+ assert Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
+ File certificateDirectory = new File(Environment.getExternalStorageDirectory(), PLUMBLE_CERTIFICATE_FOLDER);
+ if(!certificateDirectory.exists())
+ certificateDirectory.mkdir();
+ return certificateDirectory;
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/preference/Preferences.java b/Plumble/src/main/java/com/morlunk/mumbleclient/preference/Preferences.java
new file mode 100644
index 00000000..f0dd95a0
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/preference/Preferences.java
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.preference;
+
+import android.annotation.TargetApi;
+import android.media.AudioFormat;
+import android.media.AudioRecord;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Environment;
+import android.preference.ListPreference;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceClickListener;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceCategory;
+import android.preference.PreferenceFragment;
+import android.preference.PreferenceScreen;
+
+import com.morlunk.mumbleclient.R;
+import com.morlunk.mumbleclient.Settings;
+
+import java.io.File;
+import java.util.List;
+
+import info.guardianproject.onionkit.ui.OrbotHelper;
+
+public class Preferences extends PreferenceActivity {
+
+ public static final String ACTION_PREFS_GENERAL = "com.morlunk.mumbleclient.app.PREFS_GENERAL";
+ public static final String ACTION_PREFS_AUTHENTICATION = "com.morlunk.mumbleclient.app.PREFS_AUTHENTICATION";
+ public static final String ACTION_PREFS_AUDIO = "com.morlunk.mumbleclient.app.PREFS_AUDIO";
+ public static final String ACTION_PREFS_APPEARANCE = "com.morlunk.mumbleclient.app.PREFS_APPEARANCE";
+ public static final String ACTION_PREFS_ABOUT = "com.morlunk.mumbleclient.app.PREFS_ABOUT";
+
+ private static final String CERTIFICATE_GENERATE_KEY = "certificateGenerate";
+ private static final String CERTIFICATE_PATH_KEY = "certificatePath";
+ private static final String USE_TOR_KEY = "useTor";
+
+ @Override
+ protected void onCreate(final Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // Legacy preference section handling
+
+ String action = getIntent().getAction();
+ if (action != null) {
+ if (ACTION_PREFS_GENERAL.equals(action)) {
+ addPreferencesFromResource(R.xml.settings_general);
+ configureOrbotPreferences(getPreferenceScreen());
+ } else if (ACTION_PREFS_AUTHENTICATION.equals(action)) {
+ addPreferencesFromResource(R.xml.settings_authentication);
+ configureCertificatePreferences(getPreferenceScreen());
+ } else if (ACTION_PREFS_AUDIO.equals(action)) {
+ addPreferencesFromResource(R.xml.settings_audio);
+ configureAudioPreferences(getPreferenceScreen());
+ } else if (ACTION_PREFS_APPEARANCE.equals(action)) {
+ addPreferencesFromResource(R.xml.settings_appearance);
+ } else if (ACTION_PREFS_ABOUT.equals(action)) {
+ addPreferencesFromResource(R.xml.settings_about);
+ }
+ } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
+ addPreferencesFromResource(R.xml.preference_headers_legacy);
+ }
+ }
+
+ @Override
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+ public void onBuildHeaders(List target) {
+ loadHeadersFromResource(R.xml.preference_headers, target);
+ }
+
+ @Override
+ protected boolean isValidFragment(String fragmentName) {
+ return PlumblePreferenceFragment.class.getName().equals(fragmentName);
+ }
+
+ private static void configureCertificatePreferences(PreferenceScreen screen) {
+ final Preference certificateGeneratePreference = screen.findPreference(CERTIFICATE_GENERATE_KEY);
+ final ListPreference certificatePathPreference = (ListPreference) screen.findPreference(CERTIFICATE_PATH_KEY);
+
+ certificateGeneratePreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ generateCertificate(certificatePathPreference);
+ return true;
+ }
+ });
+
+ // Make sure media is mounted, otherwise do not allow certificate loading.
+ if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
+ try {
+ updateCertificatePath(certificatePathPreference);
+ } catch (NullPointerException exception) {
+ certificatePathPreference.setEnabled(false);
+ certificatePathPreference.setSummary(R.string.externalStorageUnavailable);
+ }
+ } else {
+ certificatePathPreference.setEnabled(false);
+ certificatePathPreference.setSummary(R.string.externalStorageUnavailable);
+ }
+ }
+
+ private static void configureOrbotPreferences(PreferenceScreen screen) {
+ OrbotHelper orbotHelper = new OrbotHelper(screen.getContext());
+ Preference useOrbotPreference = screen.findPreference(USE_TOR_KEY);
+ useOrbotPreference.setEnabled(orbotHelper.isOrbotInstalled());
+ }
+
+ private static void configureAudioPreferences(final PreferenceScreen screen) {
+ ListPreference inputPreference = (ListPreference) screen.findPreference(Settings.PREF_INPUT_METHOD);
+ inputPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ updateAudioDependents(screen, (String) newValue);
+ return true;
+ }
+ });
+
+ // Scan each bitrate and determine if the device supports it
+ ListPreference inputQualityPreference = (ListPreference) screen.findPreference(Settings.PREF_INPUT_QUALITY);
+ String[] bitrateNames = new String[inputQualityPreference.getEntries().length];
+ for(int x=0;x 0;
+ bitrateNames[x] = bitrate+"Hz" + (supported ? "" : " (unsupported)");
+ }
+ inputQualityPreference.setEntries(bitrateNames);
+
+ updateAudioDependents(screen, inputPreference.getValue());
+ }
+
+ private static void updateAudioDependents(PreferenceScreen screen, String inputMethod) {
+ PreferenceCategory pttCategory = (PreferenceCategory) screen.findPreference("ptt_settings");
+ PreferenceCategory vadCategory = (PreferenceCategory) screen.findPreference("vad_settings");
+ pttCategory.setEnabled(Settings.ARRAY_INPUT_METHOD_PTT.equals(inputMethod));
+ vadCategory.setEnabled(Settings.ARRAY_INPUT_METHOD_VOICE.equals(inputMethod));
+ }
+
+ /**
+ * Updates the passed preference with the certificate paths found on external storage.
+ *
+ * @param preference The ListPreference to update.
+ */
+ private static void updateCertificatePath(ListPreference preference) throws NullPointerException {
+ List certificateFiles = PlumbleCertificateManager.getAvailableCertificates();
+
+ // Get arrays of certificate paths and names.
+ String[] certificateNames = new String[certificateFiles.size() + 1]; // Extra space for 'None' option
+ String[] certificatePaths = new String[certificateFiles.size() + 1];
+ for (int x = 0; x < certificateFiles.size(); x++) {
+ certificateNames[x] = certificateFiles.get(x).getName();
+ certificatePaths[x] = certificateFiles.get(x).getAbsolutePath();
+ }
+
+ certificateNames[certificateNames.length - 1] = preference.getContext().getString(R.string.noCert);
+ certificatePaths[certificatePaths.length - 1] = "";
+
+ preference.setEntries(certificateNames);
+ preference.setEntryValues(certificatePaths);
+ }
+
+ /**
+ * Generates a new certificate and sets it as active.
+ *
+ * @param certificateList If passed, will update the list of certificates available. Messy.
+ */
+ private static void generateCertificate(final ListPreference certificateList) {
+ PlumbleCertificateGenerateTask generateTask = new PlumbleCertificateGenerateTask(certificateList.getContext()) {
+ @Override
+ protected void onPostExecute(File result) {
+ super.onPostExecute(result);
+
+ if (result != null) {
+ updateCertificatePath(certificateList); // Update cert path after
+ certificateList.setValue(result.getAbsolutePath());
+ }
+ }
+ };
+ generateTask.execute();
+ }
+
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+ public static class PlumblePreferenceFragment extends PreferenceFragment {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ String section = getArguments().getString("settings");
+ if ("general".equals(section)) {
+ addPreferencesFromResource(R.xml.settings_general);
+ configureOrbotPreferences(getPreferenceScreen());
+ } else if ("authentication".equals(section)) {
+ addPreferencesFromResource(R.xml.settings_authentication);
+ configureCertificatePreferences(getPreferenceScreen());
+ } else if ("audio".equals(section)) {
+ addPreferencesFromResource(R.xml.settings_audio);
+ configureAudioPreferences(getPreferenceScreen());
+ } else if ("appearance".equals(section)) {
+ addPreferencesFromResource(R.xml.settings_appearance);
+ } else if ("about".equals(section)) {
+ addPreferencesFromResource(R.xml.settings_about);
+ }
+ }
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/preference/SeekBarDialogPreference.java b/Plumble/src/main/java/com/morlunk/mumbleclient/preference/SeekBarDialogPreference.java
new file mode 100644
index 00000000..caf17a47
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/preference/SeekBarDialogPreference.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+/* The following code was written by Matthew Wiggins
+ * and is released under the Apache 2.0 license
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * I added some extra functionality like a multiplier + better persistence.
+ * - Andrew Comminos
+ */
+package com.morlunk.mumbleclient.preference;
+
+import android.content.Context;
+import android.preference.DialogPreference;
+import android.util.AttributeSet;
+import android.view.Gravity;
+import android.view.View;
+import android.widget.LinearLayout;
+import android.widget.SeekBar;
+import android.widget.TextView;
+
+
+public class SeekBarDialogPreference extends DialogPreference implements SeekBar.OnSeekBarChangeListener {
+ private static final String androidns = "http://schemas.android.com/apk/res/android";
+ private SeekBar mSeekBar;
+ private TextView mSplashText, mValueText;
+ private Context mContext;
+ private String mDialogMessage, mSuffix;
+ private int mDefault, mMax, mValue, mMultiplier = 0;
+
+ public SeekBarDialogPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mContext = context;
+
+ mDialogMessage = attrs.getAttributeValue(androidns, "dialogMessage");
+ mSuffix = attrs.getAttributeValue(androidns, "text");
+ mDefault = attrs.getAttributeIntValue(androidns, "defaultValue", 0);
+ mMax = attrs.getAttributeIntValue(androidns, "max", 100);
+ mMultiplier = attrs.getAttributeIntValue(null, "multiplier", 1);
+
+ }
+
+ @Override
+ protected View onCreateDialogView() {
+ LinearLayout.LayoutParams params;
+ LinearLayout layout = new LinearLayout(mContext);
+ layout.setOrientation(LinearLayout.VERTICAL);
+ layout.setPadding(6, 6, 6, 6);
+
+ mSplashText = new TextView(mContext);
+ if (mDialogMessage != null)
+ mSplashText.setText(mDialogMessage);
+ layout.addView(mSplashText);
+
+ mValueText = new TextView(mContext);
+ mValueText.setGravity(Gravity.CENTER_HORIZONTAL);
+ mValueText.setTextSize(18);
+ params = new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.MATCH_PARENT,
+ LinearLayout.LayoutParams.WRAP_CONTENT);
+ layout.addView(mValueText, params);
+
+ mSeekBar = new SeekBar(mContext);
+ mSeekBar.setOnSeekBarChangeListener(this);
+ layout.addView(mSeekBar, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
+
+ if (shouldPersist())
+ mValue = getPersistedInt(-1) != -1 ? getPersistedInt(mDefault) / mMultiplier : getPersistedInt(mDefault);
+
+ mSeekBar.setMax(mMax);
+ mSeekBar.setProgress(mValue);
+ return layout;
+ }
+
+ @Override
+ protected void onBindDialogView(View v) {
+ super.onBindDialogView(v);
+ mSeekBar.setMax(mMax);
+ mSeekBar.setProgress(mValue);
+ }
+
+ @Override
+ protected void onSetInitialValue(boolean restore, Object defaultValue) {
+ super.onSetInitialValue(restore, defaultValue);
+ if (restore)
+ mValue = shouldPersist() ? getPersistedInt(mDefault) / mMultiplier : 0;
+ else
+ mValue = (Integer) defaultValue / mMultiplier;
+ }
+
+ public void onProgressChanged(SeekBar seek, int value, boolean fromTouch) {
+ String t = String.valueOf(value * mMultiplier);
+ mValueText.setText(mSuffix == null ? t : t.concat(mSuffix));
+ }
+
+ public void onStartTrackingTouch(SeekBar seek) {
+ }
+
+ public void onStopTrackingTouch(SeekBar seek) {
+ }
+
+ /* (non-Javadoc)
+ * @see android.preference.DialogPreference#onDialogClosed(boolean)
+ */
+ @Override
+ protected void onDialogClosed(boolean positiveResult) {
+ super.onDialogClosed(positiveResult);
+ if (positiveResult && shouldPersist()) {
+ persistInt(mSeekBar.getProgress() * mMultiplier);
+ }
+ }
+
+ public int getMax() {
+ return mMax;
+ }
+
+ public void setMax(int max) {
+ mMax = max;
+ }
+
+ public int getProgress() {
+ return mValue;
+ }
+
+ public void setProgress(int progress) {
+ mValue = progress;
+ if (mSeekBar != null)
+ mSeekBar.setProgress(progress);
+ }
+}
\ No newline at end of file
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/servers/PublicServerListFragment.java b/Plumble/src/main/java/com/morlunk/mumbleclient/servers/PublicServerListFragment.java
new file mode 100644
index 00000000..8b486915
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/servers/PublicServerListFragment.java
@@ -0,0 +1,663 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.servers;
+
+import android.annotation.SuppressLint;
+import android.annotation.TargetApi;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.os.AsyncTask;
+import android.os.Build;
+import android.os.Build.VERSION;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.util.Log;
+import android.util.Xml;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.view.inputmethod.EditorInfo;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.EditText;
+import android.widget.GridView;
+import android.widget.ImageView;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+import android.widget.TextView.OnEditorActionListener;
+import android.widget.Toast;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import com.morlunk.mumbleclient.Constants;
+import com.morlunk.mumbleclient.R;
+import com.morlunk.mumbleclient.Settings;
+import com.morlunk.mumbleclient.db.DatabaseProvider;
+import com.morlunk.mumbleclient.db.PublicServer;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * Displays a list of public servers that can be connected to, sorted, and favourited.
+ * @author morlunk
+ *
+ */
+public class PublicServerListFragment extends Fragment implements OnItemClickListener {
+
+ public static final int MAX_ACTIVE_PINGS = 50;
+
+ private ServerListFragment.ServerConnectHandler mConnectHandler;
+ private DatabaseProvider mDatabaseProvider;
+ private List mServers;
+ private GridView mServerGrid;
+ private ProgressBar mServerProgress;
+ private PublicServerAdapter mServerAdapter;
+ private int mActivePingCount = 0;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+
+ try {
+ mConnectHandler = (ServerListFragment.ServerConnectHandler)activity;
+ mDatabaseProvider = (DatabaseProvider) activity;
+ } catch (ClassCastException e) {
+ throw new ClassCastException(activity.toString()+" must implement ServerConnectHandler and DatabaseProvider!");
+ }
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ fillPublicList();
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_public_server_list, container, false);
+ mServerGrid = (GridView) view.findViewById(R.id.server_list_grid);
+ mServerGrid.setOnItemClickListener(this);
+ if(mServerAdapter != null)
+ mServerGrid.setAdapter(mServerAdapter);
+ mServerProgress = (ProgressBar) view.findViewById(R.id.serverProgress);
+ mServerProgress.setVisibility(mServerAdapter == null ? View.VISIBLE : View.GONE);
+ return view;
+ }
+
+ @Override
+ public void onPrepareOptionsMenu(Menu menu) {
+ super.onPrepareOptionsMenu(menu);
+ menu.findItem(R.id.menu_match_server).setVisible(VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB); // Executors only supported on Honeycomb +
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ super.onCreateOptionsMenu(menu, inflater);
+ inflater.inflate(R.menu.fragment_public_server_list, menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (isFilled()) {
+ switch(item.getItemId()) {
+ case R.id.menu_match_server:
+ showMatchDialog();
+ break;
+ case R.id.menu_sort_server_item:
+ showSortDialog();
+ return true;
+ case R.id.menu_search_server_item:
+ showFilterDialog();
+ return true;
+ }
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ public void setServers(List servers) {
+ mServers = servers;
+ mServerProgress.setVisibility(View.GONE);
+ mServerAdapter = new PublicServerAdapter(getActivity(), servers);
+ mServerGrid.setAdapter(mServerAdapter);
+ }
+
+ public boolean isFilled() {
+ return mServerAdapter != null;
+ }
+
+ private void showMatchDialog() {
+ AlertDialog.Builder adb = new AlertDialog.Builder(getActivity());
+ adb.setTitle(R.string.server_match);
+ adb.setMessage(R.string.server_match_description);
+ adb.setPositiveButton(R.string.search, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ findOptimalServer();
+ }
+ });
+ adb.setNegativeButton(android.R.string.cancel, null);
+ adb.show();
+ }
+
+ private void findOptimalServer() {
+ MatchServerTask matchServerTask = new MatchServerTask();
+ matchServerTask.execute(Locale.getDefault().getCountry());
+ }
+
+ private void showSortDialog() {
+ AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getActivity());
+ alertBuilder.setTitle(R.string.sortBy);
+ alertBuilder.setItems(new String[] { getString(R.string.name), getString(R.string.country)}, new SortClickListener());
+ alertBuilder.show();
+ }
+
+ private void showFilterDialog() {
+ View dialogView = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.dialog_server_search, null);
+ final EditText nameText = (EditText) dialogView.findViewById(R.id.server_search_name);
+ final EditText countryText = (EditText) dialogView.findViewById(R.id.server_search_country);
+
+ final AlertDialog dlg = new AlertDialog.Builder(getActivity()).
+ setTitle(R.string.search).
+ setView(dialogView).
+ setPositiveButton(R.string.search, new DialogInterface.OnClickListener() {
+ public void onClick(final DialogInterface dialog, final int which)
+ {
+ String queryName = nameText.getText().toString().toUpperCase(Locale.US);
+ String queryCountry = countryText.getText().toString().toUpperCase(Locale.US);
+ mServerAdapter.filter(queryName, queryCountry);
+ dialog.dismiss();
+ }
+ }).create();
+
+ nameText.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
+ nameText.setOnEditorActionListener(new OnEditorActionListener() {
+ @Override
+ public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event)
+ {
+ String queryName = nameText.getText().toString().toUpperCase(Locale.US);
+ String queryCountry = countryText.getText().toString().toUpperCase(Locale.US);
+ mServerAdapter.filter(queryName, queryCountry);
+ dlg.dismiss();
+ return true;
+ }
+ });
+
+ countryText.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
+ countryText.setOnEditorActionListener(new OnEditorActionListener() {
+ @Override
+ public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event)
+ {
+ String queryName = nameText.getText().toString().toUpperCase(Locale.US);
+ String queryCountry = countryText.getText().toString().toUpperCase(Locale.US);
+ mServerAdapter.filter(queryName, queryCountry);
+ dlg.dismiss();
+ return true;
+ }
+ });
+
+ // Show keyboard automatically
+ nameText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
+ @Override
+ public void onFocusChange(View v, boolean hasFocus) {
+ if (hasFocus) {
+ dlg.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+ }
+ }
+ });
+
+ dlg.show();
+ }
+
+ @Override
+ public void onItemClick(AdapterView> arg0, View arg1, int arg2, long arg3) {
+ mConnectHandler.connectToPublicServer(mServerAdapter.getItem(arg2));
+ }
+
+ private class PublicServerAdapter extends ArrayAdapter {
+ private Map infoResponses = new HashMap();
+ private List originalServers;
+
+ private boolean mLightTheme;
+
+ public PublicServerAdapter(Context context, List servers) {
+ super(context, android.R.id.text1, servers);
+ originalServers = new ArrayList(servers);
+ mLightTheme = R.style.Theme_Plumble == Settings.getInstance(context).getTheme();
+ }
+
+ public void filter(String queryName, String queryCountry) {
+ clear();
+
+ for(PublicServer server : originalServers) {
+ String serverName = server.getName() != null ? server.getName().toUpperCase(Locale.US) : "";
+ String serverCountry = server.getCountry() != null ? server.getCountry().toUpperCase(Locale.US) : "";
+
+ if(serverName.contains(queryName) && serverCountry.contains(queryCountry))
+ add(server);
+ }
+ }
+
+ @SuppressLint("NewApi")
+ @Override
+ public final View getView(
+ final int position,
+ final View v,
+ final ViewGroup parent) {
+ View view = v;
+
+ if(v == null) {
+ LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ view = inflater.inflate(R.layout.public_server_list_row, parent, false);
+ }
+
+ final PublicServer server = getItem(position);
+ view.setTag(server);
+
+ TextView nameText = (TextView) view.findViewById(R.id.server_row_name);
+ TextView addressText = (TextView) view.findViewById(R.id.server_row_address);
+
+ if(server.getName().equals("")) {
+ nameText.setText(server.getHost());
+ } else {
+ nameText.setText(server.getName());
+ }
+
+ addressText.setText(server.getHost()+":"+server.getPort());
+
+ TextView locationText = (TextView) view.findViewById(R.id.server_row_location);
+ locationText.setText(server.getCountry());
+
+ // Ping server if available
+ if(!infoResponses.containsKey(server) && mActivePingCount < MAX_ACTIVE_PINGS) {
+ mActivePingCount++;
+ final View serverView = view; // Create final instance of view for use in asynctask
+ ServerInfoTask task = new ServerInfoTask() {
+ protected void onPostExecute(ServerInfoResponse result) {
+ super.onPostExecute(result);
+ infoResponses.put(server, result);
+ if(serverView != null && serverView.isShown() && serverView.getTag() == server)
+ updateInfoResponseView(serverView, server);
+ mActivePingCount--;
+ Log.d(Constants.TAG, "DEBUG: Servers remaining in queue: "+ mActivePingCount);
+ };
+ };
+
+ // Execute on parallel threads if API >= 11. RACE CAR THREADING, WOOOOOOOOOOOOOOOOOOOOOO
+ if(VERSION.SDK_INT >= 11)
+ task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, server);
+ else
+ task.execute(server);
+ }
+
+ ImageView favoriteButton = (ImageView)view.findViewById(R.id.server_row_favorite);
+
+ favoriteButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getContext());
+
+ Settings settings = Settings.getInstance(getActivity());
+
+ // Allow username entry
+ final EditText usernameField = new EditText(getContext());
+ usernameField.setHint(settings.getDefaultUsername());
+ alertBuilder.setView(usernameField);
+
+ alertBuilder.setTitle(R.string.addFavorite);
+
+ alertBuilder.setPositiveButton(R.string.add, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ String username = usernameField.getText().toString();
+ if(username.equals(""))
+ server.setUsername(usernameField.getHint().toString());
+
+ mDatabaseProvider.getDatabase().addServer(server);
+ }
+ });
+
+ alertBuilder.show();
+ }
+
+ });
+
+ updateInfoResponseView(view, server);
+
+ return view;
+ }
+
+ private void updateInfoResponseView(View view, PublicServer server) {
+ ServerInfoResponse infoResponse = infoResponses.get(server);
+ // If there is a null value for the server info (rather than none at all), the request must have failed.
+ boolean requestExists = infoResponse != null;
+ boolean requestFailure = infoResponse != null && infoResponse.isDummy();
+
+ TextView serverVersionText = (TextView) view.findViewById(R.id.server_row_version_status);
+ TextView serverUsersText = (TextView) view.findViewById(R.id.server_row_usercount);
+ ProgressBar serverInfoProgressBar = (ProgressBar) view.findViewById(R.id.server_row_ping_progress);
+
+ serverVersionText.setVisibility(!requestFailure && !requestExists ? View.INVISIBLE : View.VISIBLE);
+ serverUsersText.setVisibility(!requestFailure && !requestExists ? View.INVISIBLE : View.VISIBLE);
+ serverInfoProgressBar.setVisibility(!requestExists ? View.VISIBLE : View.INVISIBLE);
+
+ if(infoResponse != null && !requestFailure) {
+ serverVersionText.setText(getResources().getString(R.string.online)+" ("+infoResponse.getVersionString()+")");
+ serverUsersText.setText(infoResponse.getCurrentUsers()+"/"+infoResponse.getMaximumUsers());
+ } else if(requestFailure) {
+ serverVersionText.setText(R.string.offline);
+ serverUsersText.setText("");
+ } else {
+ serverVersionText.setText(R.string.noServerInfo);
+ }
+ }
+ }
+
+ private void fillPublicList() {
+ new PublicServerFetchTask() {
+ protected void onPostExecute(List result) {
+ super.onPostExecute(result);
+
+ if (result == null) {
+ // Handle error
+ Toast.makeText(getActivity(), R.string.error_fetching_servers, Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ if(isVisible()) // Prevents NPEs when fragment is detached.
+ setServers(result);
+ };
+ }.execute();
+ }
+
+ private class SortClickListener implements DialogInterface.OnClickListener {
+
+ private static final int SORT_NAME = 0;
+ private static final int SORT_COUNTRY = 1;
+
+ private Comparator nameComparator = new Comparator() {
+ @Override
+ public int compare(PublicServer lhs, PublicServer rhs) {
+ return lhs.getName().compareTo(rhs.getName());
+ }
+ };
+
+ private Comparator countryComparator = new Comparator() {
+ @Override
+ public int compare(PublicServer lhs, PublicServer rhs) {
+ if(rhs.getCountry() == null) return -1;
+ else if(lhs.getCountry() == null) return 1;
+ return lhs.getCountry().compareTo(rhs.getCountry());
+ }
+ };
+
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ ArrayAdapter arrayAdapter = mServerAdapter;
+ if(which == SORT_NAME) {
+ arrayAdapter.sort(nameComparator);
+ } else if(which == SORT_COUNTRY) {
+ arrayAdapter.sort(countryComparator);
+ }
+ }
+ }
+
+ private class PublicServerFetchTask extends AsyncTask> {
+
+ private static final String MUMBLE_PUBLIC_URL = "http://www.mumble.info/list2.cgi";
+
+ @Override
+ protected List doInBackground(Void... params) {
+ try {
+ // Fetch XML from server
+ URL url = new URL(MUMBLE_PUBLIC_URL);
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod("GET");
+ connection.addRequestProperty("version", com.morlunk.jumble.Constants.PROTOCOL_STRING);
+ connection.connect();
+ InputStream stream = connection.getInputStream();
+
+ XmlPullParser parser = Xml.newPullParser();
+ parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
+ parser.setInput(stream, "UTF-8");
+ parser.nextTag();
+
+ List serverList = new ArrayList();
+
+ parser.require(XmlPullParser.START_TAG, null, "servers");
+ while(parser.next() != XmlPullParser.END_TAG) {
+ if (parser.getEventType() != XmlPullParser.START_TAG) {
+ continue;
+ }
+
+ serverList.add(readEntry(parser));
+ }
+ parser.require(XmlPullParser.END_TAG, null, "servers");
+
+ return serverList;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private PublicServer readEntry(XmlPullParser parser) throws XmlPullParserException, IOException {
+ String name = parser.getAttributeValue(null, "name");
+ String ca = parser.getAttributeValue(null, "ca");
+ String continentCode = parser.getAttributeValue(null, "continent_code");
+ String country = parser.getAttributeValue(null, "country");
+ String countryCode = parser.getAttributeValue(null, "country_code");
+ String ip = parser.getAttributeValue(null, "ip");
+ String port = parser.getAttributeValue(null, "port");
+ String region = parser.getAttributeValue(null, "region");
+ String url = parser.getAttributeValue(null, "url");
+
+ parser.nextTag();
+
+ PublicServer server = new PublicServer(name, ca, continentCode, country, countryCode, ip, Integer.parseInt(port), region, url);
+
+ return server;
+ }
+ }
+
+ /**
+ * Finds an empty server in the user's country code with low latency.
+ * By default, it will show a ProgressDialog while it performs this and an AlertDialog allowing the user to connect.
+ */
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+ private class MatchServerTask extends AsyncTask {
+
+ /**
+ * Query until we find up to SEARCH_RANGE empty servers that meet the zero user and location requirements.
+ * Once we have that, then we'll sort them based on latency.
+ * TODO make this a user-changeable option.
+ */
+ public static final int SEARCH_RANGE = 20;
+
+ private Comparator mLatencyComparator = new Comparator() {
+ @Override
+ public int compare(ServerInfoResponse lhs, ServerInfoResponse rhs) {
+ return lhs.getLatency() == rhs.getLatency() ? 0 :
+ lhs.getLatency() < rhs.getLatency() ? -1 : 1;
+ }
+ };
+
+ private class MatchServerInfoTask extends ServerInfoTask {
+ @Override
+ protected void onPostExecute(ServerInfoResponse serverInfoResponse) {
+ mResponseCount++;
+ if(serverInfoResponse == null) {
+ // TODO handle bad responses
+ } else if(serverInfoResponse.getCurrentUsers() == 0 &&
+ serverInfoResponse.getVersion() == com.morlunk.jumble.Constants.PROTOCOL_VERSION) {
+ mGoodResponses.add(serverInfoResponse);
+ }
+
+ // Once we have a good sample of results, shut down the ping threads.
+ if(mResponseCount >= mResponsesToSend) {
+ synchronized (mLock) {
+ mLock.notify();
+ }
+ mPingExecutor.shutdownNow();
+ }
+ }
+
+ }
+
+ private ExecutorService mPingExecutor = Executors.newFixedThreadPool(5); // Run 5 concurrent pings at a time
+ private Object mLock = new Object();
+
+ private List mGoodResponses = Collections.synchronizedList(new ArrayList());
+ private volatile int mResponseCount = 0;
+ private int mResponsesToSend = SEARCH_RANGE;
+
+ private ProgressDialog mProgressDialog;
+
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ mProgressDialog = ProgressDialog.show(getActivity(), null, getString(R.string.server_match_progress));
+ mProgressDialog.setCancelable(true);
+ mProgressDialog.setCanceledOnTouchOutside(true);
+ mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ cancel(true);
+ }
+ });
+ }
+
+ @Override
+ protected ServerInfoResponse doInBackground(String... params) {
+ final String country = params.length > 0 ? params[0] : null; // If a country is provided, search within country
+
+ Collection servers;
+ if(country != null)
+ servers = Collections2.filter(mServers, new Predicate() {
+ @Override
+ public boolean apply(PublicServer publicServer) {
+ return country.equals(publicServer.getCountryCode());
+ }
+ });
+ else
+ servers = mServers;
+
+ // For countries with 0 servers, immediately return null.
+ if(servers.size() == 0)
+ return null;
+
+ // If there are less servers than the value of our range, deal with it.
+ mResponsesToSend = Math.min(SEARCH_RANGE, servers.size());
+
+ Iterator iterator = servers.iterator();
+ while(iterator.hasNext() && mGoodResponses.size() < mResponsesToSend) {
+ PublicServer server = (PublicServer) iterator.next();
+ new MatchServerInfoTask().executeOnExecutor(mPingExecutor, server);
+ }
+ try {
+ synchronized (mLock) {
+ mLock.wait();
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ Collections.sort(mGoodResponses, mLatencyComparator);
+
+ if(mGoodResponses.size() > 0)
+ return mGoodResponses.get(0);
+ else
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(ServerInfoResponse response) {
+ super.onPostExecute(response);
+ final PublicServer publicServer = response == null ? null : (PublicServer) response.getServer();
+ mProgressDialog.hide();
+
+ AlertDialog.Builder adb = new AlertDialog.Builder(getActivity());
+ if(publicServer != null) {
+ adb.setTitle(R.string.server_match_found);
+ adb.setMessage(getString(R.string.server_match_info,
+ publicServer.getName(),
+ publicServer.getHost(),
+ publicServer.getPort(),
+ response.getCurrentUsers(),
+ response.getMaximumUsers(),
+ response.getVersionString(),
+ publicServer.getCountry(),
+ response.getLatency()));
+ adb.setPositiveButton(R.string.connect, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ mConnectHandler.connectToPublicServer(publicServer);
+ }
+ });
+ } else {
+ adb.setTitle(R.string.server_match_not_found);
+ adb.setMessage(R.string.server_match_expand_country);
+ adb.setPositiveButton(R.string.expand, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ MatchServerTask matchTask = new MatchServerTask();
+ matchTask.execute();
+ }
+ });
+ }
+ adb.setNegativeButton(android.R.string.cancel, null);
+ adb.show();
+ }
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/servers/ServerEditFragment.java b/Plumble/src/main/java/com/morlunk/mumbleclient/servers/ServerEditFragment.java
new file mode 100644
index 00000000..f09e404a
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/servers/ServerEditFragment.java
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.servers;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnCancelListener;
+import android.content.DialogInterface.OnClickListener;
+import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import com.morlunk.jumble.Constants;
+import com.morlunk.jumble.model.Server;
+import com.morlunk.mumbleclient.R;
+import com.morlunk.mumbleclient.Settings;
+import com.morlunk.mumbleclient.db.DatabaseProvider;
+
+public class ServerEditFragment extends DialogFragment {
+
+ public interface ServerEditListener {
+ public void serverInfoUpdated();
+ public void connectToServer(Server server);
+ }
+
+ private TextView mNameTitle;
+ private EditText mNameEdit;
+ private EditText mHostEdit;
+ private EditText mPortEdit;
+ private EditText mUsernameEdit;
+ private EditText mPasswordEdit;
+
+ private ServerEditListener mListener;
+ private DatabaseProvider mDatabaseProvider;
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+
+ try {
+ mDatabaseProvider = (DatabaseProvider) activity;
+ mListener = (ServerEditListener) activity;
+ } catch (ClassCastException e) {
+ throw new ClassCastException(activity.toString()+" must implement DatabaseProvider and ServerEditListener!");
+ }
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getActivity());
+
+ Settings settings = Settings.getInstance(getActivity());
+
+ View view = inflater.inflate(R.layout.dialog_server_edit, null, false);
+ alertBuilder.setView(view);
+
+ mNameTitle = (TextView) view.findViewById(R.id.server_edit_name_title);
+ mNameEdit = (EditText) view.findViewById(R.id.server_edit_name);
+ mHostEdit = (EditText) view.findViewById(R.id.server_edit_host);
+ mPortEdit = (EditText) view.findViewById(R.id.server_edit_port);
+ mUsernameEdit = (EditText) view.findViewById(R.id.server_edit_username);
+ mUsernameEdit.setHint(settings.getDefaultUsername());
+ mPasswordEdit = (EditText) view.findViewById(R.id.server_edit_password);
+ if (getServer() != null) {
+ Server oldServer = getServer();
+ mNameEdit.setText(oldServer.getName());
+ mHostEdit.setText(oldServer.getHost());
+ mPortEdit.setText(String.valueOf(oldServer.getPort()));
+ mUsernameEdit.setText(oldServer.getUsername());
+ mPasswordEdit.setText(oldServer.getPassword());
+ }
+
+ if(!shouldSave()) {
+ mNameTitle.setVisibility(View.GONE);
+ mNameEdit.setVisibility(View.GONE);
+ }
+
+ int actionTitle;
+ if(shouldSave() && getServer() == null) {
+ actionTitle = R.string.add;
+ } else if(shouldSave()) {
+ actionTitle = R.string.save;
+ } else {
+ actionTitle = R.string.connect;
+ }
+
+ alertBuilder.setPositiveButton(actionTitle, new OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Server server = createServer(shouldSave());
+
+ // If we're not committing this server, connect immediately.
+ if(!shouldSave()) mListener.connectToServer(server);
+
+ dismiss();
+ }
+ });
+
+ alertBuilder.setNegativeButton(android.R.string.cancel, new OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dismiss();
+ }
+ });
+
+ alertBuilder.setOnCancelListener(new OnCancelListener() {
+
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ dismiss();
+ }
+ });
+
+ return alertBuilder.create();
+ }
+
+ private boolean shouldSave() {
+ return getArguments() == null || getArguments().getBoolean("save", true);
+ }
+
+ private Server getServer() {
+ return getArguments() != null ? (Server) getArguments().getParcelable("server") : null;
+ }
+
+ /**
+ * Creates or updates a server with the information in this fragment.
+ * @param shouldCommit Whether to commit the created service to the DB.
+ * @return The new or updated server.
+ */
+ public Server createServer(boolean shouldCommit) {
+ String name = (mNameEdit).getText().toString().trim();
+ String host = (mHostEdit).getText().toString().trim();
+
+ int port;
+ try {
+ port = Integer.parseInt((mPortEdit).getText().toString());
+ } catch (final NumberFormatException ex) {
+ port = Constants.DEFAULT_PORT;
+ }
+
+ String username = (mUsernameEdit).getText().toString().trim();
+ String password = mPasswordEdit.getText().toString();
+
+ if(username.equals(""))
+ username = mUsernameEdit.getHint().toString();
+
+ Server server;
+
+ if (getServer() != null) {
+ server = getServer();
+ server.setName(name);
+ server.setHost(host);
+ server.setPort(port);
+ server.setUsername(username);
+ server.setPassword(password);
+ if(shouldCommit) mDatabaseProvider.getDatabase().updateServer(server);
+ } else {
+ server = new Server(-1, name, host, port, username, password);
+ if(shouldCommit) mDatabaseProvider.getDatabase().addServer(server);
+ }
+
+ if(shouldCommit) mListener.serverInfoUpdated();
+
+ return server;
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/servers/ServerInfoResponse.java b/Plumble/src/main/java/com/morlunk/mumbleclient/servers/ServerInfoResponse.java
new file mode 100644
index 00000000..96611351
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/servers/ServerInfoResponse.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.servers;
+
+import com.morlunk.jumble.model.Server;
+
+import java.nio.ByteBuffer;
+
+/**
+ * Response from server pings.
+ * @see http://mumble.sourceforge.net/Protocol
+ * @author morlunk
+ */
+public class ServerInfoResponse {
+
+ private long mIdentifier;
+ private int mVersion;
+ private int mCurrentUsers;
+ private int mMaximumUsers;
+ private int mAllowedBandwidth;
+ private int mLatency;
+ private Server mServer;
+
+ /**
+ * Whether or not this server info response represents a failure to retrieve a response. Used to efficiently denote failed responses.
+ */
+ private boolean mDummy = false;
+
+ /**
+ * Creates a ServerInfoResponse object with the bytes obtained from the server.
+ * @param response The response to the UDP pings sent by the server.
+ * @see http://mumble.sourceforge.net/Protocol
+ */
+ public ServerInfoResponse(Server server, byte[] response, int latency) {
+ ByteBuffer buffer = ByteBuffer.wrap(response);
+ mVersion = buffer.getInt();
+ mIdentifier = buffer.getLong();
+ mCurrentUsers = buffer.getInt();
+ mMaximumUsers = buffer.getInt();
+ mAllowedBandwidth = buffer.getInt();
+ mLatency = latency;
+ mServer = server;
+ }
+
+ /**
+ * Instantiating a ServerInfoResponse with no data will cause it to be considered a 'dummy' response by its handler.
+ */
+ public ServerInfoResponse() {
+ this.mDummy = true;
+ }
+
+ public long getIdentifier() {
+ return mIdentifier;
+ }
+
+ public int getVersion() {
+ return mVersion;
+ }
+
+ public String getVersionString() {
+ byte[] versionBytes = ByteBuffer.allocate(4).putInt(mVersion).array();
+ return String.format("%d.%d.%d", (int)versionBytes[1], (int)versionBytes[2], (int)versionBytes[3]);
+ }
+
+ public int getCurrentUsers() {
+ return mCurrentUsers;
+ }
+
+ public int getMaximumUsers() {
+ return mMaximumUsers;
+ }
+
+ public int getAllowedBandwidth() {
+ return mAllowedBandwidth;
+ }
+
+ public int getLatency() {
+ return mLatency;
+ }
+
+ public Server getServer() {
+ return mServer;
+ }
+
+ public boolean isDummy() {
+ return mDummy;
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/servers/ServerInfoTask.java b/Plumble/src/main/java/com/morlunk/mumbleclient/servers/ServerInfoTask.java
new file mode 100644
index 00000000..059102bd
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/servers/ServerInfoTask.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.servers;
+
+import android.os.AsyncTask;
+import android.util.Log;
+
+import com.morlunk.jumble.model.Server;
+import com.morlunk.mumbleclient.Constants;
+
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.InetAddress;
+import java.nio.ByteBuffer;
+
+/**
+ * Pings the requested server and returns a ServerInfoResponse.
+ * Will return a 'dummy' ServerInfoResponse in the case of failure.
+ * @author morlunk
+ *
+ */
+public class ServerInfoTask extends AsyncTask {
+
+ private Server server;
+
+ @Override
+ protected ServerInfoResponse doInBackground(Server... params) {
+ server = params[0];
+ try {
+ InetAddress host = InetAddress.getByName(server.getHost());
+
+ // Create ping message
+ ByteBuffer buffer = ByteBuffer.allocate(12);
+ buffer.putInt(0); // Request type
+ buffer.putLong(server.getId()); // Identifier
+ DatagramPacket requestPacket = new DatagramPacket(buffer.array(), 12, host, server.getPort());
+
+ // Send packet and wait for response
+ DatagramSocket socket = new DatagramSocket();
+ socket.setSoTimeout(1000);
+ socket.setReceiveBufferSize(1024);
+
+ long startTime = System.nanoTime();
+
+ socket.send(requestPacket);
+
+ byte[] responseBuffer = new byte[24];
+ DatagramPacket responsePacket = new DatagramPacket(responseBuffer, responseBuffer.length);
+ socket.receive(responsePacket);
+
+ int latencyInMs = (int) ((System.nanoTime()-startTime)/1000000);
+
+ ServerInfoResponse response = new ServerInfoResponse(server, responseBuffer, latencyInMs);
+
+ Log.i(Constants.TAG, "DEBUG: Server version: "+response.getVersionString()+"\nUsers: "+response.getCurrentUsers()+"/"+response.getMaximumUsers());
+
+ return response;
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return new ServerInfoResponse(); // Return dummy in case of failure
+ }
+
+}
\ No newline at end of file
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/servers/ServerListFragment.java b/Plumble/src/main/java/com/morlunk/mumbleclient/servers/ServerListFragment.java
new file mode 100644
index 00000000..ea3bae5d
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/servers/ServerListFragment.java
@@ -0,0 +1,295 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.servers;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v7.widget.PopupMenu;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.GridView;
+import android.widget.ImageView;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+
+import com.morlunk.jumble.model.Server;
+import com.morlunk.mumbleclient.R;
+import com.morlunk.mumbleclient.Settings;
+import com.morlunk.mumbleclient.db.DatabaseProvider;
+import com.morlunk.mumbleclient.db.PublicServer;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Displays a list of servers, and allows the user to connect and edit them.
+ * @author morlunk
+ *
+ */
+public class ServerListFragment extends Fragment implements OnItemClickListener {
+
+ public interface ServerConnectHandler {
+ public void connectToServer(Server server);
+ public void connectToPublicServer(PublicServer server);
+ }
+
+ private ServerConnectHandler mConnectHandler;
+ private DatabaseProvider mDatabaseProvider;
+ private GridView mServerGrid;
+ private ServerAdapter mServerAdapter;
+ private Map mInfoResponses = new HashMap();
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+
+ try {
+ mConnectHandler = (ServerConnectHandler)activity;
+ mDatabaseProvider = (DatabaseProvider) activity;
+ } catch (ClassCastException e) {
+ throw new ClassCastException(activity.toString()+" must implement ServerConnectHandler!");
+ }
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_server_list, container, false);
+ mServerGrid = (GridView) view.findViewById(R.id.server_list_grid);
+ mServerGrid.setOnItemClickListener(this);
+ mServerGrid.setEmptyView(view.findViewById(R.id.server_list_grid_empty));
+ registerForContextMenu(mServerGrid);
+ return view;
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ super.onCreateOptionsMenu(menu, inflater);
+ inflater.inflate(R.menu.fragment_server_list, menu);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ updateServers();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if(item.getItemId() == R.id.menu_add_server_item) {
+ addServer();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ private void addServer() {
+ ServerEditFragment infoDialog = new ServerEditFragment();
+ infoDialog.show(getFragmentManager(), "serverInfo");
+ }
+
+ private void editServer(Server server) {
+ ServerEditFragment infoDialog = new ServerEditFragment();
+ Bundle args = new Bundle();
+ args.putParcelable("server", server);
+ infoDialog.setArguments(args);
+ infoDialog.show(getFragmentManager(), "serverInfo");
+ }
+
+ private void shareServer(Server server) {
+ // Build Mumble server URL
+ String serverUrl = "mumble://"+server.getHost()+":"+server.getPort()+"/";
+
+ Intent intent = new Intent();
+ intent.setAction(Intent.ACTION_SEND);
+ intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.shareMessage, serverUrl));
+ intent.setType("text/plain");
+ startActivity(intent);
+ }
+
+ private void deleteServer(final Server server) {
+ AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getActivity());
+ alertBuilder.setMessage(R.string.confirm_delete_server);
+ alertBuilder.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ mDatabaseProvider.getDatabase().removeServer(server);
+ mServerAdapter.remove(server);
+ }
+ });
+ alertBuilder.setNegativeButton(android.R.string.cancel, null);
+ alertBuilder.show();
+ }
+
+ public void updateServers() {
+ List servers = getServers();
+ mServerAdapter = new ServerAdapter(getActivity(), servers);
+ mServerGrid.setAdapter(mServerAdapter);
+
+ for(final Server server : servers) {
+ new ServerInfoTask() {
+ protected void onPostExecute(ServerInfoResponse result) {
+ super.onPostExecute(result);
+ mInfoResponses.put(server, result);
+ mServerAdapter.notifyDataSetChanged();
+ };
+ }.execute(server);
+ }
+ }
+
+
+
+ public List getServers() {
+ List servers = mDatabaseProvider.getDatabase().getServers();
+ return servers;
+ }
+
+ @Override
+ public void onItemClick(AdapterView> arg0, View arg1, int arg2, long arg3) {
+ mConnectHandler.connectToServer(mServerAdapter.getItem(arg2));
+ }
+
+ private class ServerAdapter extends ArrayAdapter {
+
+ private boolean mLightTheme;
+
+ public ServerAdapter(Context context, List servers) {
+ super(context, android.R.id.text1, servers);
+ mLightTheme = R.style.Theme_Plumble == Settings.getInstance(context).getTheme();
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return getItem(position).getId();
+ }
+
+ @Override
+ public final View getView(
+ final int position,
+ final View v,
+ final ViewGroup parent) {
+ View view = v;
+
+ if(v == null) {
+ LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ view = inflater.inflate(R.layout.server_list_row, parent, false);
+
+ }
+
+ final Server server = getItem(position);
+
+ ServerInfoResponse infoResponse = mInfoResponses.get(server);
+ // If there is a null value for the server info (rather than none at all), the request must have failed.
+ boolean requestExists = infoResponse != null;
+ boolean requestFailure = infoResponse != null && infoResponse.isDummy();
+
+ TextView nameText = (TextView) view.findViewById(R.id.server_row_name);
+ TextView userText = (TextView) view.findViewById(R.id.server_row_user);
+ TextView addressText = (TextView) view.findViewById(R.id.server_row_address);
+
+ if(server.getName().equals("")) {
+ nameText.setText(server.getHost());
+ } else {
+ nameText.setText(server.getName());
+ }
+
+ userText.setText(server.getUsername());
+ addressText.setText(server.getHost()+":"+server.getPort());
+
+ ImageView moreButton = (ImageView) view.findViewById(R.id.server_row_more);
+ moreButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ PopupMenu popupMenu = new PopupMenu(getContext(), v);
+ MenuInflater inflater = popupMenu.getMenuInflater();
+ inflater.inflate(R.menu.popup_server_row, popupMenu.getMenu());
+ ServerPopupMenuItemClickListener listener = new ServerPopupMenuItemClickListener(server);
+ popupMenu.setOnMenuItemClickListener(listener);
+ popupMenu.show();
+ }
+ });
+
+ TextView serverVersionText = (TextView) view.findViewById(R.id.server_row_version_status);
+ TextView serverLatencyText = (TextView) view.findViewById(R.id.server_row_latency);
+ TextView serverUsersText = (TextView) view.findViewById(R.id.server_row_usercount);
+ ProgressBar serverInfoProgressBar = (ProgressBar) view.findViewById(R.id.server_row_ping_progress);
+
+ serverVersionText.setVisibility(!requestExists ? View.INVISIBLE : View.VISIBLE);
+ serverUsersText.setVisibility(!requestExists ? View.INVISIBLE : View.VISIBLE);
+ serverLatencyText.setVisibility(!requestExists ? View.INVISIBLE : View.VISIBLE);
+ serverInfoProgressBar.setVisibility(!requestExists ? View.VISIBLE : View.INVISIBLE);
+
+ if(infoResponse != null && !requestFailure) {
+ serverVersionText.setText(getResources().getString(R.string.online)+" ("+infoResponse.getVersionString()+")");
+ serverUsersText.setText(infoResponse.getCurrentUsers()+"/"+infoResponse.getMaximumUsers());
+ serverLatencyText.setText(infoResponse.getLatency()+"ms");
+ } else if(requestFailure) {
+ serverVersionText.setText(R.string.offline);
+ serverUsersText.setText("");
+ serverLatencyText.setText("");
+ }
+
+ return view;
+ }
+ }
+
+ private class ServerPopupMenuItemClickListener implements PopupMenu.OnMenuItemClickListener {
+
+ private Server server;
+
+ public ServerPopupMenuItemClickListener(Server server) {
+ this.server = server;
+ }
+
+ public boolean onMenuItemClick(android.view.MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.menu_edit_item:
+ editServer(server);
+ return true;
+ case R.id.menu_share_item:
+ shareServer(server);
+ return true;
+ case R.id.menu_delete_item:
+ deleteServer(server);
+ return true;
+ }
+ return false;
+ }
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/service/PlumbleOverlay.java b/Plumble/src/main/java/com/morlunk/mumbleclient/service/PlumbleOverlay.java
new file mode 100644
index 00000000..9b4ead8b
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/service/PlumbleOverlay.java
@@ -0,0 +1,230 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.service;
+
+import android.content.Context;
+import android.graphics.PixelFormat;
+import android.os.RemoteException;
+import android.util.DisplayMetrics;
+import android.view.Gravity;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.ImageView;
+import android.widget.ListView;
+
+import com.morlunk.jumble.model.Channel;
+import com.morlunk.jumble.model.User;
+import com.morlunk.jumble.net.JumbleObserver;
+import com.morlunk.mumbleclient.R;
+import com.morlunk.mumbleclient.channel.ChannelAdapter;
+
+/**
+ * An onscreen interactive overlay displaying the users in the current channel.
+ * Created by andrew on 26/09/13.
+ */
+public class PlumbleOverlay {
+
+ public static final int DEFAULT_WIDTH = 200;
+ public static final int DEFAULT_HEIGHT = 240;
+
+ private JumbleObserver mObserver = new JumbleObserver() {
+ @Override
+ public void onUserTalkStateUpdated(User user) throws RemoteException {
+ mChannelAdapter.notifyDataSetChanged();
+ }
+
+ @Override
+ public void onUserStateUpdated(User user) throws RemoteException {
+ if(user.getChannelId() == mService.getBinder().getSessionChannel().getId())
+ mChannelAdapter.notifyDataSetChanged();
+ }
+
+ @Override
+ public void onUserJoinedChannel(User user, Channel newChannel, Channel oldChannel) throws RemoteException {
+ if(user.getSession() == mService.getSession()) // Session user has changed channels
+ mChannelAdapter.setChannel(mService.getBinder().getSessionChannel());
+ else if(newChannel.getId() == mService.getBinder().getSessionChannel().getId() ||
+ oldChannel.getId() == mService.getBinder().getSessionChannel().getId())
+ mChannelAdapter.notifyDataSetChanged();
+ }
+ };
+
+ private View mOverlayView;
+ private ListView mOverlayList;
+ private ChannelAdapter mChannelAdapter;
+ private ImageView mTalkButton;
+// private ImageView mToggleButton;
+ private ImageView mCloseButton;
+ private ImageView mDragButton;
+ private View mTitleView;
+ private WindowManager.LayoutParams mOverlayParams;
+ private boolean mShown = false;
+// private boolean mShowChat = false;
+
+ private PlumbleService mService;
+
+ public PlumbleOverlay(PlumbleService service) {
+ mService = service;
+ mOverlayView = View.inflate(service, R.layout.overlay, null);
+ mTalkButton = (ImageView) mOverlayView.findViewById(R.id.overlay_talk);
+ mDragButton = (ImageView) mOverlayView.findViewById(R.id.overlay_drag);
+ mCloseButton = (ImageView) mOverlayView.findViewById(R.id.overlay_close);
+// mToggleButton = (ImageView) mOverlayView.findViewById(R.id.overlay_mode_toggle);
+ mTitleView = mOverlayView.findViewById(R.id.overlay_title);
+ mOverlayList = (ListView) mOverlayView.findViewById(R.id.overlay_list);
+
+ mTitleView.setOnTouchListener(new View.OnTouchListener() {
+ private final WindowManager mWindowManager = (WindowManager) mService.getSystemService(Context.WINDOW_SERVICE);
+ private float mInitialX;
+ private float mInitialY;
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ if(MotionEvent.ACTION_DOWN == event.getAction()) {
+ mInitialX = event.getRawX() - mOverlayParams.x;
+ mInitialY = event.getRawY() - mOverlayParams.y;
+ }
+ else if(MotionEvent.ACTION_MOVE == event.getAction()) {
+ mOverlayParams.x = (int) (event.getRawX() - mInitialX);
+ mOverlayParams.y = (int) (event.getRawY() - mInitialY);
+ mWindowManager.updateViewLayout(mOverlayView, mOverlayParams);
+ }
+ return true;
+ }
+ });
+
+ mDragButton.setOnTouchListener(new View.OnTouchListener() {
+
+ private final WindowManager mWindowManager = (WindowManager) mService.getSystemService(Context.WINDOW_SERVICE);
+ private float mInitialX;
+ private float mInitialY;
+ private float mInitialWidth;
+ private float mInitialHeight;
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ mInitialX = event.getRawX();
+ mInitialY = event.getRawY();
+ mInitialWidth = mOverlayView.getWidth();
+ mInitialHeight = mOverlayView.getHeight();
+ return true;
+ case MotionEvent.ACTION_MOVE:
+ mOverlayParams.width = (int) (mInitialWidth + (event.getRawX() - mInitialX));
+ mOverlayParams.height = (int) (mInitialHeight + (event.getRawY() - mInitialY));
+ mWindowManager.updateViewLayout(mOverlayView, mOverlayParams);
+ return true;
+ }
+ return false;
+ }
+ });
+
+ /*
+ mToggleButton.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ mShowChat = !mShowChat;
+ // TODO implement chat
+ if(mShowChat) {
+
+ } else {
+
+ }
+ }
+ });
+ */
+
+ mTalkButton.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ if(MotionEvent.ACTION_DOWN == event.getAction()) {
+ try {
+ mService.getBinder().setTalkingState(true);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ } else if(MotionEvent.ACTION_UP == event.getAction()) {
+ try {
+ mService.getBinder().setTalkingState(false);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ return false;
+ }
+ });
+
+ mCloseButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ hide();
+ }
+ });
+
+ DisplayMetrics metrics = mService.getResources().getDisplayMetrics();
+ mOverlayParams = new WindowManager.LayoutParams((int)(DEFAULT_WIDTH*metrics.density),
+ (int)(DEFAULT_HEIGHT*metrics.density),
+ WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
+ WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
+ | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
+ | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
+ PixelFormat.TRANSLUCENT);
+ mOverlayParams.gravity = Gravity.TOP | Gravity.LEFT;
+ mOverlayParams.windowAnimations = android.R.style.Animation_Dialog;
+ }
+
+ public boolean isShown() {
+ return mShown;
+ }
+
+ public void show() {
+ if(mShown)
+ return;
+ mShown = true;
+ try {
+ mChannelAdapter = new ChannelAdapter(mService, mService.getBinder(), mService.getBinder().getSessionChannel());
+ mOverlayList.setAdapter(mChannelAdapter);
+ mService.getBinder().registerObserver(mObserver);
+ WindowManager windowManager = (WindowManager) mService.getSystemService(Context.WINDOW_SERVICE);
+ windowManager.addView(mOverlayView, mOverlayParams);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void hide() {
+ if(!mShown)
+ return;
+ mShown = false;
+ try {
+ mService.getBinder().unregisterObserver(mObserver);
+ mOverlayList.setAdapter(null);
+ WindowManager windowManager = (WindowManager) mService.getSystemService(Context.WINDOW_SERVICE);
+ windowManager.removeView(mOverlayView);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/service/PlumbleService.java b/Plumble/src/main/java/com/morlunk/mumbleclient/service/PlumbleService.java
new file mode 100644
index 00000000..892a8c85
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/service/PlumbleService.java
@@ -0,0 +1,467 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.service;
+
+import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.SharedPreferences;
+import android.graphics.PixelFormat;
+import android.os.RemoteException;
+import android.preference.PreferenceManager;
+import android.speech.tts.TextToSpeech;
+import android.support.v4.app.NotificationCompat;
+import android.view.Gravity;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.WindowManager;
+
+import com.morlunk.jumble.Constants;
+import com.morlunk.jumble.JumbleService;
+import com.morlunk.jumble.model.Message;
+import com.morlunk.jumble.model.User;
+import com.morlunk.jumble.net.JumbleObserver;
+import com.morlunk.mumbleclient.R;
+import com.morlunk.mumbleclient.Settings;
+import com.morlunk.mumbleclient.app.PlumbleActivity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * An extension of the Jumble service with some added Plumble-exclusive non-standard Mumble features.
+ * Created by andrew on 28/07/13.
+ */
+public class PlumbleService extends JumbleService implements SharedPreferences.OnSharedPreferenceChangeListener {
+
+ public static final int TTS_THRESHOLD = 250; // Maximum number of characters to read
+
+ public static final String BROADCAST_MUTE = "broadcast_mute";
+ public static final String BROADCAST_DEAFEN = "broadcast_deafen";
+ public static final String BROADCAST_TOGGLE_OVERLAY = "broadcast_toggle_overlay";
+
+ public static final int STATUS_NOTIFICATION_ID = 1;
+
+ private NotificationCompat.Builder mStatusNotificationBuilder;
+ /** A list of messages to be displayed in the chat notification. Should be cleared when notification pressed. */
+ private List mUnreadMessages = new ArrayList();
+
+ private Settings mSettings;
+ private boolean mHotCornerEnabled;
+ /** The view representing the hot corner. */
+ private View mHotCornerView;
+ /** The overlay that's shown when talking using a hot corner. */
+ private View mHotCornerOverlay;
+ /** Channel view overlay. */
+ private PlumbleOverlay mChannelOverlay;
+
+ private TextToSpeech mTTS;
+ private TextToSpeech.OnInitListener mTTSInitListener = new TextToSpeech.OnInitListener() {
+ @Override
+ public void onInit(int status) {
+ if(status == TextToSpeech.ERROR)
+ logWarning(getString(R.string.tts_failed));
+ }
+ };
+
+ private BroadcastReceiver mNotificationReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ try {
+ if(BROADCAST_MUTE.equals(intent.getAction())) {
+ User user = getBinder().getSessionUser();
+ boolean muted = !user.isSelfMuted();
+ boolean deafened = user.isSelfDeafened();
+ deafened &= muted;
+ getBinder().setSelfMuteDeafState(muted, deafened);
+ } else if(BROADCAST_DEAFEN.equals(intent.getAction())) {
+ User user = getBinder().getSessionUser();
+ getBinder().setSelfMuteDeafState(!user.isSelfDeafened(), !user.isSelfDeafened());
+ } else if(BROADCAST_TOGGLE_OVERLAY.equals(intent.getAction())) {
+ if(!mChannelOverlay.isShown())
+ mChannelOverlay.show();
+ else
+ mChannelOverlay.hide();
+ } else if(PlumbleActivity.ACTION_PLUMBLE_SHOWN.equals(intent.getAction())) {
+ if(getBinder().isConnected()) {
+ mUnreadMessages.clear();
+ updateNotificationState();
+ }
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ };
+
+ private JumbleObserver mObserver = new JumbleObserver() {
+
+ @Override
+ public void onConnectionError(String message, boolean reconnecting) throws RemoteException {
+ String tickerMessage = null;
+ if(reconnecting) tickerMessage += "\n"+getString(R.string.reconnecting, PlumbleActivity.RECONNECT_DELAY/1000);
+ else tickerMessage = getString(R.string.plumbleDisconnected);
+ updateNotificationTicker(tickerMessage);
+ updateNotificationState();
+ if(!reconnecting) hideNotification();
+ }
+
+ @Override
+ public void onUserStateUpdated(User user) throws RemoteException {
+ if(user.getSession() == getSession()) {
+ mSettings.setMutedAndDeafened(user.isSelfMuted(), user.isSelfDeafened()); // Update settings mute/deafen state
+ updateNotificationState();
+ }
+ }
+
+ @Override
+ public void onMessageLogged(Message message) throws RemoteException {
+ // Strip all HTML tags.
+ String strippedMessage = message.getMessage().replaceAll("<[^>]*>", "");
+
+ // Only read text messages. TODO: make this an option.
+ if(message.getType() == Message.Type.TEXT_MESSAGE) {
+ User actor = getBinder().getUser(message.getActor());
+ String actorName = actor != null ? actor.getName() : getString(R.string.server);
+
+ String formattedMessage = actorName + ": " + strippedMessage;
+ mUnreadMessages.add(formattedMessage);
+
+ if(mSettings.isChatNotifyEnabled()) {
+ // Set the ticker to be the last message received
+ mStatusNotificationBuilder.setTicker(mUnreadMessages.get(mUnreadMessages.size() - 1));
+ updateNotificationState();
+ }
+
+ // Read if TTS is enabled, the message is less than threshold, is a text message, and not deafened
+ if(mSettings.isTextToSpeechEnabled() &&
+ mTTS != null &&
+ message.getType() == Message.Type.TEXT_MESSAGE &&
+ strippedMessage.length() <= TTS_THRESHOLD &&
+ !getBinder().getSessionUser().isSelfDeafened()) {
+ mTTS.speak(formattedMessage, TextToSpeech.QUEUE_ADD, null);
+ }
+ }
+ }
+
+ @Override
+ public void onPermissionDenied(String reason) throws RemoteException {
+ if(!mSettings.isChatNotifyEnabled()) return;
+ updateNotificationTicker(reason);
+ }
+ };
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ // Register for notification actions
+ IntentFilter notificationIntentFilter = new IntentFilter();
+ notificationIntentFilter.addAction(BROADCAST_MUTE);
+ notificationIntentFilter.addAction(BROADCAST_DEAFEN);
+ notificationIntentFilter.addAction(BROADCAST_TOGGLE_OVERLAY);
+ notificationIntentFilter.addAction(PlumbleActivity.ACTION_PLUMBLE_SHOWN);
+ registerReceiver(mNotificationReceiver, notificationIntentFilter);
+
+ try {
+ getBinder().registerObserver(mObserver);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+
+ // Register for preference changes
+ mSettings = Settings.getInstance(this);
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
+ preferences.registerOnSharedPreferenceChangeListener(this);
+
+ // Instantiate overlay view
+ mChannelOverlay = new PlumbleOverlay(this);
+
+ // Set up TTS
+ if(mSettings.isTextToSpeechEnabled())
+ mTTS = new TextToSpeech(this, mTTSInitListener);
+ }
+
+ @Override
+ public void connect() {
+ super.connect();
+ createNotification(); // TODO: move this to a better place!
+ }
+
+ @Override
+ public void onDestroy() {
+ stopForeground(true);
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
+ preferences.unregisterOnSharedPreferenceChangeListener(this);
+ unregisterReceiver(mNotificationReceiver);
+ try {
+ getBinder().unregisterObserver(mObserver);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ if(mTTS != null) mTTS.shutdown();
+ super.onDestroy();
+ }
+
+ @Override
+ public void onConnectionEstablished() {
+ super.onConnectionEstablished();
+ updateNotificationTicker(getString(R.string.plumbleConnected));
+ try {
+ // Restore mute/deafen state
+ Settings settings = Settings.getInstance(this);
+ User sessionUser = getBinder().getSessionUser();
+ if(sessionUser.isSelfMuted() != settings.isMuted() ||
+ sessionUser.isSelfDeafened() != settings.isDeafened())
+ getBinder().setSelfMuteDeafState(settings.isMuted(), settings.isDeafened());
+
+ // Update setting-dependent connection properties
+ configureHotCorner();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onConnectionDisconnected() {
+ super.onConnectionDisconnected();
+ // Remove overlay if present.
+ mChannelOverlay.hide();
+
+ // Remove hot corner if present.
+ if(mHotCornerView != null) {
+ WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
+ try {
+ windowManager.removeView(mHotCornerView);
+ windowManager.removeView(mHotCornerOverlay);
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ }
+ mHotCornerEnabled = false;
+ }
+
+ try {
+ if(!getBinder().isReconnecting()) hideNotification();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Sets up or updates the hot corner with the latest values from settings.
+ */
+ public void configureHotCorner() {
+ // Hot corner configuration
+ String hotCorner = mSettings.getHotCorner();
+ final WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
+ if(!Settings.ARRAY_HOT_CORNER_NONE.equals(hotCorner) && isConnected()) {
+ final WindowManager.LayoutParams cornerParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,
+ WindowManager.LayoutParams.WRAP_CONTENT,
+ WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
+ WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
+ PixelFormat.TRANSLUCENT);
+
+ if(Settings.ARRAY_HOT_CORNER_TOP_LEFT.equals(hotCorner))
+ cornerParams.gravity = Gravity.TOP | Gravity.LEFT;
+ else if(Settings.ARRAY_HOT_CORNER_TOP_RIGHT.equals(hotCorner))
+ cornerParams.gravity = Gravity.TOP | Gravity.RIGHT;
+ else if(Settings.ARRAY_HOT_CORNER_BOTTOM_LEFT.equals(hotCorner))
+ cornerParams.gravity = Gravity.BOTTOM | Gravity.LEFT;
+ else if(Settings.ARRAY_HOT_CORNER_BOTTOM_RIGHT.equals(hotCorner))
+ cornerParams.gravity = Gravity.BOTTOM | Gravity.RIGHT;
+
+ final WindowManager.LayoutParams overlayParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,
+ WindowManager.LayoutParams.WRAP_CONTENT,
+ WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
+ WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
+ PixelFormat.TRANSLUCENT);
+ overlayParams.gravity = Gravity.CENTER | Gravity.BOTTOM;
+
+ if(mHotCornerEnabled) {
+ windowManager.updateViewLayout(mHotCornerView, cornerParams);
+ windowManager.updateViewLayout(mHotCornerOverlay, overlayParams);
+ } else {
+ mHotCornerView = View.inflate(this, R.layout.ptt_corner, null);
+ mHotCornerOverlay = View.inflate(this, R.layout.ptt_overlay, null);
+ mHotCornerOverlay.setVisibility(View.GONE);
+
+ mHotCornerView.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ try {
+ if(MotionEvent.ACTION_DOWN == event.getAction()) {
+ mHotCornerOverlay.setVisibility(View.VISIBLE);
+ if(mSettings.isPushToTalkToggle()) {
+ boolean newState = !getBinder().isTalking();
+ getBinder().setTalkingState(newState);
+ mHotCornerOverlay.setVisibility(newState ? View.VISIBLE : View.GONE);
+ } else {
+ getBinder().setTalkingState(true);
+ mHotCornerOverlay.setVisibility(View.VISIBLE);
+ }
+ return true;
+ } else if(MotionEvent.ACTION_UP == event.getAction()) {
+ if(!mSettings.isPushToTalkToggle()) {
+ mHotCornerOverlay.setVisibility(View.GONE);
+ getBinder().setTalkingState(false);
+ }
+ return true;
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+ });
+
+ windowManager.addView(mHotCornerView, cornerParams);
+ windowManager.addView(mHotCornerOverlay, overlayParams);
+
+ mHotCornerEnabled = true;
+ }
+ } else if(mHotCornerEnabled) {
+ windowManager.removeView(mHotCornerView);
+ windowManager.removeView(mHotCornerOverlay);
+ mHotCornerEnabled = false;
+ }
+ }
+
+ /**
+ * Called when the user makes a change to their preferences. Should update all preferences relevant to the service.
+ */
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ if(Settings.PREF_INPUT_METHOD.equals(key)) {
+ /* Convert input method defined in settings to an integer format used by Jumble. */
+ int inputMethod = 0;
+ String prefInputMethod = mSettings.getInputMethod();
+ if(Settings.ARRAY_INPUT_METHOD_VOICE.equals(prefInputMethod))
+ inputMethod = Constants.TRANSMIT_VOICE_ACTIVITY;
+ if(Settings.ARRAY_INPUT_METHOD_PTT.equals(prefInputMethod))
+ inputMethod = Constants.TRANSMIT_PUSH_TO_TALK;
+ if(Settings.ARRAY_INPUT_METHOD_CONTINUOUS.equals(prefInputMethod))
+ inputMethod = Constants.TRANSMIT_CONTINUOUS;
+ try {
+ getBinder().setTransmitMode(inputMethod);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ else if(Settings.PREF_THRESHOLD.equals(key))
+ try {
+ getBinder().setVADThreshold(mSettings.getDetectionThreshold());
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ else if(Settings.PREF_HOT_CORNER_KEY.equals(key))
+ configureHotCorner();
+ else if(Settings.PREF_USE_TTS.equals(key)) {
+ if(mTTS == null && mSettings.isTextToSpeechEnabled())
+ mTTS = new TextToSpeech(this, mTTSInitListener);
+ else if(mTTS != null && !mSettings.isTextToSpeechEnabled()) {
+ mTTS.shutdown();
+ mTTS = null;
+ }
+ }
+ }
+
+ /**
+ * Creates a new NotificationCompat.Builder configured for the service, and shows it.
+ */
+ public void createNotification() {
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
+ builder.setSmallIcon(R.drawable.ic_stat_notify);
+ builder.setTicker(getResources().getString(R.string.plumbleConnecting));
+ builder.setContentTitle(getResources().getString(R.string.app_name));
+ builder.setContentText(getResources().getString(R.string.connected));
+ builder.setPriority(NotificationCompat.PRIORITY_HIGH);
+ builder.setOngoing(true);
+
+ // Add notification triggers
+ Intent muteIntent = new Intent(BROADCAST_MUTE);
+ Intent deafenIntent = new Intent(BROADCAST_DEAFEN);
+ Intent overlayIntent = new Intent(BROADCAST_TOGGLE_OVERLAY);
+
+ builder.addAction(R.drawable.ic_action_microphone,
+ getString(R.string.mute), PendingIntent.getBroadcast(this, 1,
+ muteIntent, PendingIntent.FLAG_CANCEL_CURRENT));
+ builder.addAction(R.drawable.ic_action_audio_on,
+ getString(R.string.deafen), PendingIntent.getBroadcast(this, 1,
+ deafenIntent, PendingIntent.FLAG_CANCEL_CURRENT));
+ builder.addAction(R.drawable.ic_action_channels,
+ getString(R.string.overlay), PendingIntent.getBroadcast(this, 2,
+ overlayIntent, PendingIntent.FLAG_CANCEL_CURRENT));
+
+ Intent channelListIntent = new Intent(this, PlumbleActivity.class);
+
+ PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, channelListIntent, 0);
+
+ builder.setContentIntent(pendingIntent);
+
+ mStatusNotificationBuilder = builder;
+ startForeground(STATUS_NOTIFICATION_ID, builder.build());
+ }
+
+ /**
+ * Updates the status notification with unread messages (if applicable), or status updates.
+ */
+ public void updateNotificationState() {
+ if(mStatusNotificationBuilder == null) return;
+ String contentText;
+ if(isConnected()) {
+ User currentUser = getUserHandler().getUser(getSession());
+ if(currentUser.isSelfMuted() && currentUser.isSelfDeafened())
+ contentText = getString(R.string.status_notify_muted_and_deafened);
+ else if(currentUser.isSelfMuted())
+ contentText = getString(R.string.status_notify_muted);
+ else
+ contentText = getString(R.string.connected);
+ } else {
+ contentText = getString(R.string.disconnected);
+ }
+
+ try {
+ if(getBinder().isReconnecting()) contentText = getString(R.string.reconnecting, PlumbleActivity.RECONNECT_DELAY/1000);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+
+ if(!mUnreadMessages.isEmpty() && isConnected()) {
+ NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
+ for(String message : mUnreadMessages)
+ inboxStyle.addLine(message);
+ mStatusNotificationBuilder.setStyle(inboxStyle);
+ } else {
+ mStatusNotificationBuilder.setStyle(null);
+ }
+
+ mStatusNotificationBuilder.setContentText(contentText);
+ startForeground(STATUS_NOTIFICATION_ID, mStatusNotificationBuilder.build());
+ }
+
+ public void updateNotificationTicker(String message) {
+ if(mStatusNotificationBuilder == null) return;
+ mStatusNotificationBuilder.setTicker(message);
+ startForeground(STATUS_NOTIFICATION_ID, mStatusNotificationBuilder.build());
+ }
+
+ public void hideNotification() {
+ stopForeground(true);
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/util/JumbleServiceFragment.java b/Plumble/src/main/java/com/morlunk/mumbleclient/util/JumbleServiceFragment.java
new file mode 100644
index 00000000..64eced39
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/util/JumbleServiceFragment.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.util;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.support.v4.app.Fragment;
+
+import com.morlunk.jumble.IJumbleObserver;
+import com.morlunk.jumble.IJumbleService;
+
+/**
+ * Fragment class intended to make binding the Jumble service to fragments easier.
+ * Created by andrew on 04/08/13.
+ */
+public abstract class JumbleServiceFragment extends Fragment {
+
+ private JumbleServiceProvider mServiceProvider;
+
+ /** State boolean to make sure we don't double initialize a fragment once a service has been bound. */
+ private boolean mBound;
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+
+ try {
+ mServiceProvider = (JumbleServiceProvider) activity;
+ } catch (ClassCastException e) {
+ throw new ClassCastException(activity.toString() + " must implement JumbleServiceProvider");
+ }
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ mServiceProvider.addServiceFragment(this);
+ if(mServiceProvider.getService() != null && !mBound)
+ onServiceAttached(mServiceProvider.getService());
+ }
+
+ @Override
+ public void onDestroy() {
+ mServiceProvider.removeServiceFragment(this);
+ if(mServiceProvider.getService() != null && mBound)
+ onServiceDetached(mServiceProvider.getService());
+ super.onDestroy();
+ }
+
+ /** The definitive place where data from the service will be used to initialize the fragment. Only called once per bind, whether the fragment loads first or the service. */
+ public void onServiceBound(IJumbleService service) { }
+
+ /** If implemented, will register the returned observer to the service upon binding. */
+ public IJumbleObserver getServiceObserver() {
+ return null;
+ }
+
+ private void onServiceAttached(IJumbleService service) {
+ mBound = true;
+ try {
+ if(getServiceObserver() != null)
+ service.registerObserver(getServiceObserver());
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+
+ onServiceBound(service);
+ }
+
+ private void onServiceDetached(IJumbleService service) {
+ mBound = false;
+ try {
+ if(getServiceObserver() != null)
+ service.unregisterObserver(getServiceObserver());
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ public void setServiceBound(boolean bound) {
+ if(bound && !mBound)
+ onServiceAttached(mServiceProvider.getService());
+ else if(mBound && !bound)
+ onServiceDetached(mServiceProvider.getService());
+ }
+
+ public IJumbleService getService() {
+ return mServiceProvider.getService();
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/util/JumbleServiceProvider.java b/Plumble/src/main/java/com/morlunk/mumbleclient/util/JumbleServiceProvider.java
new file mode 100644
index 00000000..b9209e45
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/util/JumbleServiceProvider.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.util;
+
+import com.morlunk.jumble.IJumbleService;
+
+/**
+ * Created by andrew on 03/08/13.
+ */
+public interface JumbleServiceProvider {
+ public IJumbleService getService();
+ public void addServiceFragment(JumbleServiceFragment fragment);
+ public void removeServiceFragment(JumbleServiceFragment fragment);
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/view/PlumbleNestedAdapter.java b/Plumble/src/main/java/com/morlunk/mumbleclient/view/PlumbleNestedAdapter.java
new file mode 100644
index 00000000..85d94ab6
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/view/PlumbleNestedAdapter.java
@@ -0,0 +1,272 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.view;
+
+import android.content.Context;
+import android.util.Log;
+import android.util.SparseBooleanArray;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ListAdapter;
+
+import com.morlunk.mumbleclient.Constants;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Adapter for PlumbleNestedListView that is designed to hold a channel hierarchy.
+ * The reason group ID is so essential instead of having an implementation-side position is to better abstract the hierarchy, which is messy and confusing.
+ * @param The group class.
+ * @param The child class.
+ */
+public abstract class PlumbleNestedAdapter extends BaseAdapter implements ListAdapter {
+
+ protected enum NestMetadataType {
+ META_TYPE_GROUP,
+ META_TYPE_ITEM
+ }
+
+ protected class NestPositionMetadata {
+ NestMetadataType type;
+ NestPositionMetadata parent;
+ int id;
+ int childPosition;
+ int depth;
+ }
+
+ private Context mContext;
+
+ /**
+ * Metadata representations
+ */
+ protected List mFlatMeta = new ArrayList();
+ protected List mVisibleMeta = new ArrayList();
+ protected SparseBooleanArray mExpandedGroups = new SparseBooleanArray();
+
+ public abstract View getGroupView(int groupId, int depth, View convertView, ViewGroup parent);
+ public abstract View getChildView(int groupId, int childPosition, int depth, View convertView, ViewGroup parent);
+
+ public abstract List getRootIds();
+
+ public abstract int getGroupCount(int parentId);
+ public abstract int getGroupId(int parentId, int groupPosition);
+ public abstract int getChildCount(int groupId);
+ public abstract int getChildId(int groupId, int childPosition);
+
+ public C getChild(int groupId, int childPosition) { return null; };
+ public G getGroup(int groupId) { return null; };
+ public boolean isGroupExpandedByDefault(int groupId) { return false; };
+
+ public PlumbleNestedAdapter(Context context) {
+ mContext = context;
+ }
+
+ private final void buildFlatMetadata() {
+ List metadata = new ArrayList();
+ // Start with root element(s), them populate downwards.
+ for(int rootId : getRootIds()) {
+ mExpandedGroups.put(rootId, true); // Always expand root
+ NestPositionMetadata root = new NestPositionMetadata();
+ root.id = rootId;
+ root.type = NestMetadataType.META_TYPE_GROUP;
+ populateHierarchy(root, metadata);
+ }
+ mFlatMeta = metadata;
+ }
+
+ /**
+ * Recursively flatten the channel hierarchy, including both subchannels and users.
+ * @param parent
+ * @param metaList
+ */
+ private void populateHierarchy(NestPositionMetadata parent, final List metaList) {
+ metaList.add(parent);
+
+ int childCount = getChildCount(parent.id);
+ for(int x=0;x.
+ */
+
+package com.morlunk.mumbleclient.view;
+
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ListView;
+
+import com.morlunk.mumbleclient.view.PlumbleNestedAdapter.NestMetadataType;
+import com.morlunk.mumbleclient.view.PlumbleNestedAdapter.NestPositionMetadata;
+
+public class PlumbleNestedListView extends ListView implements OnItemClickListener {
+
+ public interface OnNestedChildClickListener {
+ public void onNestedChildClick(AdapterView> parent, View view, int groupId, int childPosition);
+ }
+ public interface OnNestedGroupClickListener {
+ public void onNestedGroupClick(AdapterView> parent, View view, int groupId);
+ }
+
+ private PlumbleNestedAdapter mNestedAdapter;
+ private OnNestedChildClickListener mChildClickListener;
+ private OnNestedGroupClickListener mGroupClickListener;
+
+ //private boolean mMaintainPosition;
+
+ public PlumbleNestedListView(Context context) {
+ this(context, null);
+ }
+
+ public PlumbleNestedListView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ setOnItemClickListener(this);
+ /*
+ TypedArray array = context.getTheme().obtainStyledAttributes(attrs, R.styleable.PlumbleNestedListView, 0, 0);
+ try {
+ mMaintainPosition = array.getBoolean(R.styleable.PlumbleNestedListView_maintainPosition, false);
+ } finally {
+ array.recycle();
+ }
+ */
+ }
+
+ public void setAdapter(PlumbleNestedAdapter adapter) {
+ super.setAdapter(adapter);
+ mNestedAdapter = adapter;
+ }
+
+ public void expandGroup(int groupId) {
+ mNestedAdapter.expandGroup(groupId);
+ }
+
+ public void collapseGroup(int groupId) {
+ mNestedAdapter.collapseGroup(groupId);
+ }
+
+ public OnNestedChildClickListener getOnChildClickListener() {
+ return mChildClickListener;
+ }
+
+ public void setOnChildClickListener(
+ OnNestedChildClickListener mChildClickListener) {
+ this.mChildClickListener = mChildClickListener;
+ }
+
+ public OnNestedGroupClickListener getOnGroupClickListener() {
+ return mGroupClickListener;
+ }
+
+ public void setOnGroupClickListener(
+ OnNestedGroupClickListener mGroupClickListener) {
+ this.mGroupClickListener = mGroupClickListener;
+ }
+
+ @Override
+ public void setOnItemClickListener(OnItemClickListener listener) {
+ if(listener != this)
+ throw new RuntimeException(
+ "For PlumbleNestedListView, please use the child and group equivalents of setOnItemClickListener.");
+ super.setOnItemClickListener(listener);
+ }
+
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position,
+ long id) {
+ NestPositionMetadata metadata = (NestPositionMetadata) mNestedAdapter.mVisibleMeta.get(position);
+ if(metadata.type == NestMetadataType.META_TYPE_GROUP && mGroupClickListener != null) {
+ mGroupClickListener.onNestedGroupClick(parent, view, metadata.id);
+ } else if(metadata.type == NestMetadataType.META_TYPE_ITEM && mChildClickListener != null)
+ mChildClickListener.onNestedChildClick(parent, view, metadata.parent.id, metadata.childPosition);
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/wizard/WizardActivity.java b/Plumble/src/main/java/com/morlunk/mumbleclient/wizard/WizardActivity.java
new file mode 100644
index 00000000..00188b03
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/wizard/WizardActivity.java
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.wizard;
+
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentPagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.support.v7.app.ActionBarActivity;
+import android.view.View;
+import android.widget.Button;
+
+import com.morlunk.mumbleclient.R;
+import com.morlunk.mumbleclient.Settings;
+
+/**
+ * A simple activity_wizard providing an easy to use interface for configuring useful settings.
+ * Created by andrew on 01/11/13.
+ */
+public class WizardActivity extends ActionBarActivity implements WizardNavigation {
+ private Settings mSettings;
+ private ViewPager mViewPager;
+ private WizardPagerAdapter mPagerAdapter;
+ private ViewPager.OnPageChangeListener mPageListener = new ViewPager.OnPageChangeListener() {
+ @Override
+ public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
+
+ }
+
+ @Override
+ public void onPageScrollStateChanged(int state) {
+
+ }
+
+ @Override
+ public void onPageSelected(int position) {
+ updateNavigationButtons(position);
+ setTitle(mPagerAdapter.getPageTitle(position));
+ }
+ };
+ private Button mBackButton;
+ private Button mNextButton;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_wizard);
+
+ getSupportActionBar().setDisplayShowHomeEnabled(false);
+
+ mSettings = Settings.getInstance(this);
+ mViewPager = (ViewPager) findViewById(R.id.wizard_pager);
+ mPagerAdapter = new WizardPagerAdapter(getSupportFragmentManager());
+ mViewPager.setAdapter(mPagerAdapter);
+ mViewPager.setOnPageChangeListener(mPageListener);
+ mBackButton = (Button) findViewById(R.id.wizard_back_button);
+ mNextButton = (Button) findViewById(R.id.wizard_next_button);
+
+ mBackButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ back();
+ }
+ });
+ mNextButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ next();
+ }
+ });
+
+ updateNavigationButtons(0);
+ setTitle(mPagerAdapter.getPageTitle(0));
+ }
+
+ @Override
+ public void onBackPressed() {
+ back();
+ }
+
+ private void updateNavigationButtons(int pagerPosition) {
+ mBackButton.setText(pagerPosition == 0 ? R.string.wizard_cancel : R.string.wizard_back);
+ mNextButton.setText(pagerPosition == mPagerAdapter.getCount() - 1 ? R.string.wizard_finish : R.string.wizard_next);
+ }
+
+ private void showConfirmQuitDialog() {
+ new AlertDialog.Builder(this)
+ .setMessage(R.string.wizard_confirm_close)
+ .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ mSettings.setFirstRun(false); // Mark in settings never to run this wizard again
+ finish();
+ }
+ }).setNegativeButton(android.R.string.cancel, null)
+ .show();
+ }
+
+ @Override
+ public void next() {
+ if (mViewPager.getCurrentItem() == (mPagerAdapter.getCount() - 1)) {
+ mSettings.setFirstRun(false); // Mark in settings never to run this wizard again
+ finish();
+ } else
+ mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1, true);
+ }
+
+ @Override
+ public void back() {
+ if(mViewPager.getCurrentItem() == 0)
+ showConfirmQuitDialog(); // If cancel is pressed at the beginning of the pager, prompt the user to quit.
+ else
+ mViewPager.setCurrentItem(mViewPager.getCurrentItem()-1, true);
+ }
+
+ private class WizardPagerAdapter extends FragmentPagerAdapter {
+
+ private final Class extends Fragment> WIZARD_FRAGMENTS[] = new Class[] {
+ WizardWelcomeFragment.class,
+ WizardCertificateFragment.class,
+ WizardAudioFragment.class,
+ WizardCertificateFragment.class
+ };
+
+ public WizardPagerAdapter(FragmentManager fm) {
+ super(fm);
+ }
+
+ @Override
+ public Fragment getItem(int i) {
+ return Fragment.instantiate(WizardActivity.this, WIZARD_FRAGMENTS[i].getName());
+ }
+
+ @Override
+ public CharSequence getPageTitle(int position) {
+ switch (position) {
+ case 0:
+ return getString(R.string.wizard_welcome_title);
+ case 1:
+ return getString(R.string.wizard_certificate_title);
+ case 2:
+ return getString(R.string.wizard_audio_title);
+ case 3:
+ return getString(R.string.wizard_general_title);
+ }
+ return null;
+ }
+
+ @Override
+ public int getCount() {
+ return WIZARD_FRAGMENTS.length;
+ }
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/wizard/WizardAudioFragment.java b/Plumble/src/main/java/com/morlunk/mumbleclient/wizard/WizardAudioFragment.java
new file mode 100644
index 00000000..1150da44
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/wizard/WizardAudioFragment.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.wizard;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.Spinner;
+import android.widget.SpinnerAdapter;
+import android.widget.TextView;
+
+import com.morlunk.mumbleclient.R;
+
+/**
+ * Created by andrew on 04/11/13.
+ */
+public class WizardAudioFragment extends Fragment {
+
+ private Spinner mInputSpinner;
+ private AudioInputSpinnerAdapter mSpinnerAdapter;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_wizard_audio, container, false);
+ mSpinnerAdapter = new AudioInputSpinnerAdapter();
+ mInputSpinner = (Spinner) view.findViewById(R.id.wizard_audio_input_spinner);
+ mInputSpinner.setAdapter(mSpinnerAdapter);
+ return view;
+ }
+
+ private class AudioInputSpinnerAdapter extends BaseAdapter implements SpinnerAdapter {
+
+ @Override
+ public int getCount() {
+ return 3;
+ }
+
+ @Override
+ public Object getItem(int position) {
+ switch (position) {
+ case 0:
+ return "Voice Activity";
+ case 1:
+ return "Push to Talk";
+ case 2:
+ return "Continuous";
+ }
+ return null;
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View view = convertView;
+ if(view == null) {
+ LayoutInflater inflater = getActivity().getLayoutInflater();
+ view = inflater.inflate(android.R.layout.simple_spinner_item, parent, false);
+ }
+ TextView textView = (TextView) view.findViewById(android.R.id.text1);
+ textView.setText((CharSequence) getItem(position));
+ return view;
+ }
+
+ @Override
+ public View getDropDownView(int position, View convertView, ViewGroup parent) {
+ View view = convertView;
+ if(view == null) {
+ LayoutInflater inflater = getActivity().getLayoutInflater();
+ view = inflater.inflate(android.R.layout.simple_spinner_dropdown_item, parent, false);
+ }
+ TextView textView = (TextView) view.findViewById(android.R.id.text1);
+ textView.setText((CharSequence) getItem(position));
+ return view;
+ }
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/wizard/WizardCertificateFragment.java b/Plumble/src/main/java/com/morlunk/mumbleclient/wizard/WizardCertificateFragment.java
new file mode 100644
index 00000000..fb2edc5b
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/wizard/WizardCertificateFragment.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.wizard;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+
+import com.morlunk.mumbleclient.R;
+import com.morlunk.mumbleclient.Settings;
+import com.morlunk.mumbleclient.preference.PlumbleCertificateGenerateTask;
+
+import java.io.File;
+
+/**
+ * Created by andrew on 02/11/13.
+ */
+public class WizardCertificateFragment extends Fragment {
+
+ private Button mGenerateButton;
+ private WizardNavigation mNavigation;
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ try {
+ mNavigation = (WizardNavigation) activity;
+ } catch (ClassCastException e) {
+ throw new RuntimeException(activity.getClass().getName()+" must implement WizardNavigation!");
+ }
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_wizard_certificate, container, false);
+ mGenerateButton = (Button) view.findViewById(R.id.wizard_certificate_generate);
+ mGenerateButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ generateCertificate();
+ }
+ });
+ return view;
+ }
+
+ private void generateCertificate() {
+ final Settings settings = Settings.getInstance(getActivity());
+ PlumbleCertificateGenerateTask task = new PlumbleCertificateGenerateTask(getActivity()) {
+ @Override
+ protected void onPostExecute(File result) {
+ super.onPostExecute(result);
+ settings.setCertificatePath(result.getAbsolutePath());
+ mGenerateButton.setEnabled(false);
+ mNavigation.next();
+ }
+ };
+ task.execute();
+ }
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/wizard/WizardNavigation.java b/Plumble/src/main/java/com/morlunk/mumbleclient/wizard/WizardNavigation.java
new file mode 100644
index 00000000..eeb4b291
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/wizard/WizardNavigation.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.wizard;
+
+/**
+ * Created by andrew on 04/11/13.
+ */
+public interface WizardNavigation {
+ public void back();
+ public void next();
+}
diff --git a/Plumble/src/main/java/com/morlunk/mumbleclient/wizard/WizardWelcomeFragment.java b/Plumble/src/main/java/com/morlunk/mumbleclient/wizard/WizardWelcomeFragment.java
new file mode 100644
index 00000000..a86e0f6b
--- /dev/null
+++ b/Plumble/src/main/java/com/morlunk/mumbleclient/wizard/WizardWelcomeFragment.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+package com.morlunk.mumbleclient.wizard;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.morlunk.mumbleclient.R;
+
+/**
+ * Created by andrew on 03/11/13.
+ */
+public class WizardWelcomeFragment extends Fragment {
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.fragment_wizard_welcome, container, false);
+ }
+}
diff --git a/Plumble/src/main/res/anim/fade_in.xml b/Plumble/src/main/res/anim/fade_in.xml
new file mode 100644
index 00000000..61209250
--- /dev/null
+++ b/Plumble/src/main/res/anim/fade_in.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/anim/fade_out.xml b/Plumble/src/main/res/anim/fade_out.xml
new file mode 100644
index 00000000..a46bf5f9
--- /dev/null
+++ b/Plumble/src/main/res/anim/fade_out.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/anim/slide_down.xml b/Plumble/src/main/res/anim/slide_down.xml
new file mode 100644
index 00000000..dea32727
--- /dev/null
+++ b/Plumble/src/main/res/anim/slide_down.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/anim/slide_up.xml b/Plumble/src/main/res/anim/slide_up.xml
new file mode 100644
index 00000000..836ec33d
--- /dev/null
+++ b/Plumble/src/main/res/anim/slide_up.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/drawable-hdpi/drawer_shadow.9.png b/Plumble/src/main/res/drawable-hdpi/drawer_shadow.9.png
new file mode 100644
index 00000000..224cc4ff
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/drawer_shadow.9.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_add_dark.png b/Plumble/src/main/res/drawable-hdpi/ic_action_add_dark.png
new file mode 100644
index 00000000..241bf6ae
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_add_dark.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_add_light.png b/Plumble/src/main/res/drawable-hdpi/ic_action_add_light.png
new file mode 100644
index 00000000..f8768f00
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_add_light.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_audio_muted.png b/Plumble/src/main/res/drawable-hdpi/ic_action_audio_muted.png
new file mode 100644
index 00000000..e8848aa7
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_audio_muted.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_audio_muted_active.png b/Plumble/src/main/res/drawable-hdpi/ic_action_audio_muted_active.png
new file mode 100644
index 00000000..44c694cb
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_audio_muted_active.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_audio_on.png b/Plumble/src/main/res/drawable-hdpi/ic_action_audio_on.png
new file mode 100644
index 00000000..2f3bfce4
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_audio_on.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_audio_on_active.png b/Plumble/src/main/res/drawable-hdpi/ic_action_audio_on_active.png
new file mode 100644
index 00000000..c39ae3e2
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_audio_on_active.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_audio_on_dark.png b/Plumble/src/main/res/drawable-hdpi/ic_action_audio_on_dark.png
new file mode 100644
index 00000000..0ab30d17
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_audio_on_dark.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_channels.png b/Plumble/src/main/res/drawable-hdpi/ic_action_channels.png
new file mode 100644
index 00000000..ba6ddab9
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_channels.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_chat_active.png b/Plumble/src/main/res/drawable-hdpi/ic_action_chat_active.png
new file mode 100644
index 00000000..37ea30a6
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_chat_active.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_chat_dark.png b/Plumble/src/main/res/drawable-hdpi/ic_action_chat_dark.png
new file mode 100644
index 00000000..0ab86538
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_chat_dark.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_chat_light.png b/Plumble/src/main/res/drawable-hdpi/ic_action_chat_light.png
new file mode 100644
index 00000000..7bc0d5fd
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_chat_light.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_comment.png b/Plumble/src/main/res/drawable-hdpi/ic_action_comment.png
new file mode 100644
index 00000000..baefb3db
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_comment.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_comment_active.png b/Plumble/src/main/res/drawable-hdpi/ic_action_comment_active.png
new file mode 100644
index 00000000..08914407
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_comment_active.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_delete_dark.png b/Plumble/src/main/res/drawable-hdpi/ic_action_delete_dark.png
new file mode 100644
index 00000000..ccff1597
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_delete_dark.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_delete_light.png b/Plumble/src/main/res/drawable-hdpi/ic_action_delete_light.png
new file mode 100644
index 00000000..098082cc
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_delete_light.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_drag_handle.png b/Plumble/src/main/res/drawable-hdpi/ic_action_drag_handle.png
new file mode 100644
index 00000000..106edfb3
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_drag_handle.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_edit_dark.png b/Plumble/src/main/res/drawable-hdpi/ic_action_edit_dark.png
new file mode 100644
index 00000000..cc89d2d2
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_edit_dark.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_edit_light.png b/Plumble/src/main/res/drawable-hdpi/ic_action_edit_light.png
new file mode 100644
index 00000000..c08565ef
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_edit_light.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_favorite_dark.png b/Plumble/src/main/res/drawable-hdpi/ic_action_favorite_dark.png
new file mode 100644
index 00000000..f0708a45
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_favorite_dark.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_favourite_off.png b/Plumble/src/main/res/drawable-hdpi/ic_action_favourite_off.png
new file mode 100644
index 00000000..ab5f3850
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_favourite_off.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_favourite_on.png b/Plumble/src/main/res/drawable-hdpi/ic_action_favourite_on.png
new file mode 100644
index 00000000..196a1826
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_favourite_on.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_fullscreen.png b/Plumble/src/main/res/drawable-hdpi/ic_action_fullscreen.png
new file mode 100644
index 00000000..52601b03
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_fullscreen.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_headphones.png b/Plumble/src/main/res/drawable-hdpi/ic_action_headphones.png
new file mode 100644
index 00000000..9eab1f4d
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_headphones.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_headphones_deafened.png b/Plumble/src/main/res/drawable-hdpi/ic_action_headphones_deafened.png
new file mode 100644
index 00000000..ba92ec53
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_headphones_deafened.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_info_dark.png b/Plumble/src/main/res/drawable-hdpi/ic_action_info_dark.png
new file mode 100644
index 00000000..840034d4
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_info_dark.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_info_light.png b/Plumble/src/main/res/drawable-hdpi/ic_action_info_light.png
new file mode 100644
index 00000000..c60544c7
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_info_light.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_microphone.png b/Plumble/src/main/res/drawable-hdpi/ic_action_microphone.png
new file mode 100644
index 00000000..732157d1
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_microphone.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_microphone_dark.png b/Plumble/src/main/res/drawable-hdpi/ic_action_microphone_dark.png
new file mode 100644
index 00000000..eae90e3f
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_microphone_dark.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_microphone_muted.png b/Plumble/src/main/res/drawable-hdpi/ic_action_microphone_muted.png
new file mode 100644
index 00000000..109c095f
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_microphone_muted.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_minus_light.png b/Plumble/src/main/res/drawable-hdpi/ic_action_minus_light.png
new file mode 100644
index 00000000..840d4be8
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_minus_light.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_more.png b/Plumble/src/main/res/drawable-hdpi/ic_action_more.png
new file mode 100644
index 00000000..0f24645b
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_more.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_save.png b/Plumble/src/main/res/drawable-hdpi/ic_action_save.png
new file mode 100644
index 00000000..d48ecd54
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_save.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_search.png b/Plumble/src/main/res/drawable-hdpi/ic_action_search.png
new file mode 100644
index 00000000..df138725
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_search.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_send.png b/Plumble/src/main/res/drawable-hdpi/ic_action_send.png
new file mode 100644
index 00000000..5b971a0f
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_send.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_settings.png b/Plumble/src/main/res/drawable-hdpi/ic_action_settings.png
new file mode 100644
index 00000000..e37e41c0
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_settings.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_sort.png b/Plumble/src/main/res/drawable-hdpi/ic_action_sort.png
new file mode 100644
index 00000000..c787c1d0
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_sort.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_unfullscreen.png b/Plumble/src/main/res/drawable-hdpi/ic_action_unfullscreen.png
new file mode 100644
index 00000000..30da6c46
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_unfullscreen.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_action_user_dark.png b/Plumble/src/main/res/drawable-hdpi/ic_action_user_dark.png
new file mode 100644
index 00000000..0997e31d
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_action_user_dark.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_carriage_return.png b/Plumble/src/main/res/drawable-hdpi/ic_carriage_return.png
new file mode 100644
index 00000000..b011d74e
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_carriage_return.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_comment.png b/Plumble/src/main/res/drawable-hdpi/ic_comment.png
new file mode 100644
index 00000000..11e7fb89
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_comment.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_comment_seen.png b/Plumble/src/main/res/drawable-hdpi/ic_comment_seen.png
new file mode 100644
index 00000000..9021dfdc
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_comment_seen.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_deafened.png b/Plumble/src/main/res/drawable-hdpi/ic_deafened.png
new file mode 100644
index 00000000..e081794b
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_deafened.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_drawer.png b/Plumble/src/main/res/drawable-hdpi/ic_drawer.png
new file mode 100644
index 00000000..ff7b1def
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_drawer.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_launcher.png b/Plumble/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 00000000..5de2b030
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_launcher.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_menu_moreoverflow_card_dark_normal.png b/Plumble/src/main/res/drawable-hdpi/ic_menu_moreoverflow_card_dark_normal.png
new file mode 100644
index 00000000..96477765
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_menu_moreoverflow_card_dark_normal.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_menu_moreoverflow_card_dark_pressed.png b/Plumble/src/main/res/drawable-hdpi/ic_menu_moreoverflow_card_dark_pressed.png
new file mode 100644
index 00000000..93c653ae
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_menu_moreoverflow_card_dark_pressed.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_microphone_muted_strike.png b/Plumble/src/main/res/drawable-hdpi/ic_microphone_muted_strike.png
new file mode 100644
index 00000000..bae4745d
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_microphone_muted_strike.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_muted.png b/Plumble/src/main/res/drawable-hdpi/ic_muted.png
new file mode 100644
index 00000000..7b515d3f
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_muted.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_muted_local.png b/Plumble/src/main/res/drawable-hdpi/ic_muted_local.png
new file mode 100644
index 00000000..fc0a5e48
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_muted_local.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_registered.png b/Plumble/src/main/res/drawable-hdpi/ic_registered.png
new file mode 100644
index 00000000..2aa17ddd
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_registered.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_server_deafened.png b/Plumble/src/main/res/drawable-hdpi/ic_server_deafened.png
new file mode 100644
index 00000000..1edb7b80
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_server_deafened.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_server_light.png b/Plumble/src/main/res/drawable-hdpi/ic_server_light.png
new file mode 100644
index 00000000..2c728eeb
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_server_light.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_server_location.png b/Plumble/src/main/res/drawable-hdpi/ic_server_location.png
new file mode 100644
index 00000000..0d0333b5
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_server_location.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_server_muted.png b/Plumble/src/main/res/drawable-hdpi/ic_server_muted.png
new file mode 100644
index 00000000..03142f6a
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_server_muted.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_stat_notify.png b/Plumble/src/main/res/drawable-hdpi/ic_stat_notify.png
new file mode 100644
index 00000000..e8b31656
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_stat_notify.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_stat_notify_active.png b/Plumble/src/main/res/drawable-hdpi/ic_stat_notify_active.png
new file mode 100644
index 00000000..bad6c708
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_stat_notify_active.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_suppressed.png b/Plumble/src/main/res/drawable-hdpi/ic_suppressed.png
new file mode 100644
index 00000000..50022768
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_suppressed.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_talking_off.png b/Plumble/src/main/res/drawable-hdpi/ic_talking_off.png
new file mode 100644
index 00000000..e910b5b7
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_talking_off.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_talking_on.png b/Plumble/src/main/res/drawable-hdpi/ic_talking_on.png
new file mode 100644
index 00000000..0a992dba
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_talking_on.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_up_arrow.png b/Plumble/src/main/res/drawable-hdpi/ic_up_arrow.png
new file mode 100644
index 00000000..bd405bad
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_up_arrow.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/ic_user_light.png b/Plumble/src/main/res/drawable-hdpi/ic_user_light.png
new file mode 100644
index 00000000..29b1f049
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/ic_user_light.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/list_longpressed.9.png b/Plumble/src/main/res/drawable-hdpi/list_longpressed.9.png
new file mode 100644
index 00000000..4ea7afa0
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/list_longpressed.9.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/list_pressed.9.png b/Plumble/src/main/res/drawable-hdpi/list_pressed.9.png
new file mode 100644
index 00000000..5654cd69
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/list_pressed.9.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/list_selector_disabled.9.png b/Plumble/src/main/res/drawable-hdpi/list_selector_disabled.9.png
new file mode 100644
index 00000000..ca8e9a27
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/list_selector_disabled.9.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/list_selector_focused.9.png b/Plumble/src/main/res/drawable-hdpi/list_selector_focused.9.png
new file mode 100644
index 00000000..99bb246c
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/list_selector_focused.9.png differ
diff --git a/Plumble/src/main/res/drawable-hdpi/server_card.9.png b/Plumble/src/main/res/drawable-hdpi/server_card.9.png
new file mode 100644
index 00000000..0be425af
Binary files /dev/null and b/Plumble/src/main/res/drawable-hdpi/server_card.9.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/drawer_shadow.9.png b/Plumble/src/main/res/drawable-mdpi/drawer_shadow.9.png
new file mode 100644
index 00000000..3797f99c
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/drawer_shadow.9.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_add_dark.png b/Plumble/src/main/res/drawable-mdpi/ic_action_add_dark.png
new file mode 100644
index 00000000..e1e1ffc1
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_add_dark.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_add_light.png b/Plumble/src/main/res/drawable-mdpi/ic_action_add_light.png
new file mode 100644
index 00000000..e796e50d
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_add_light.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_audio_muted.png b/Plumble/src/main/res/drawable-mdpi/ic_action_audio_muted.png
new file mode 100644
index 00000000..a1d9bc6b
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_audio_muted.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_audio_muted_active.png b/Plumble/src/main/res/drawable-mdpi/ic_action_audio_muted_active.png
new file mode 100644
index 00000000..25775c9a
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_audio_muted_active.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_audio_on.png b/Plumble/src/main/res/drawable-mdpi/ic_action_audio_on.png
new file mode 100644
index 00000000..4232a002
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_audio_on.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_audio_on_active.png b/Plumble/src/main/res/drawable-mdpi/ic_action_audio_on_active.png
new file mode 100644
index 00000000..04f384ce
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_audio_on_active.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_audio_on_dark.png b/Plumble/src/main/res/drawable-mdpi/ic_action_audio_on_dark.png
new file mode 100644
index 00000000..bf9361ce
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_audio_on_dark.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_channels.png b/Plumble/src/main/res/drawable-mdpi/ic_action_channels.png
new file mode 100644
index 00000000..d2f3af56
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_channels.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_chat_active.png b/Plumble/src/main/res/drawable-mdpi/ic_action_chat_active.png
new file mode 100644
index 00000000..c2480f60
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_chat_active.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_chat_dark.png b/Plumble/src/main/res/drawable-mdpi/ic_action_chat_dark.png
new file mode 100644
index 00000000..f2bb3e07
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_chat_dark.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_chat_light.png b/Plumble/src/main/res/drawable-mdpi/ic_action_chat_light.png
new file mode 100644
index 00000000..7f6977d6
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_chat_light.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_comment.png b/Plumble/src/main/res/drawable-mdpi/ic_action_comment.png
new file mode 100644
index 00000000..726c602f
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_comment.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_comment_active.png b/Plumble/src/main/res/drawable-mdpi/ic_action_comment_active.png
new file mode 100644
index 00000000..5f95dbb8
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_comment_active.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_delete_dark.png b/Plumble/src/main/res/drawable-mdpi/ic_action_delete_dark.png
new file mode 100644
index 00000000..ffa1d924
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_delete_dark.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_delete_light.png b/Plumble/src/main/res/drawable-mdpi/ic_action_delete_light.png
new file mode 100644
index 00000000..349b21b4
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_delete_light.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_drag_handle.png b/Plumble/src/main/res/drawable-mdpi/ic_action_drag_handle.png
new file mode 100644
index 00000000..f037f6fe
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_drag_handle.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_edit_dark.png b/Plumble/src/main/res/drawable-mdpi/ic_action_edit_dark.png
new file mode 100644
index 00000000..f37fdf92
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_edit_dark.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_edit_light.png b/Plumble/src/main/res/drawable-mdpi/ic_action_edit_light.png
new file mode 100644
index 00000000..be73cbf5
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_edit_light.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_favorite_dark.png b/Plumble/src/main/res/drawable-mdpi/ic_action_favorite_dark.png
new file mode 100644
index 00000000..1bb0d85a
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_favorite_dark.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_favourite_off.png b/Plumble/src/main/res/drawable-mdpi/ic_action_favourite_off.png
new file mode 100644
index 00000000..819dde10
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_favourite_off.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_favourite_on.png b/Plumble/src/main/res/drawable-mdpi/ic_action_favourite_on.png
new file mode 100644
index 00000000..02a84aa8
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_favourite_on.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_fullscreen.png b/Plumble/src/main/res/drawable-mdpi/ic_action_fullscreen.png
new file mode 100644
index 00000000..6fdcd5fc
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_fullscreen.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_headphones.png b/Plumble/src/main/res/drawable-mdpi/ic_action_headphones.png
new file mode 100644
index 00000000..acbe9f66
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_headphones.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_headphones_deafened.png b/Plumble/src/main/res/drawable-mdpi/ic_action_headphones_deafened.png
new file mode 100644
index 00000000..b6d8c2a9
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_headphones_deafened.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_info_dark.png b/Plumble/src/main/res/drawable-mdpi/ic_action_info_dark.png
new file mode 100644
index 00000000..a5dba6dd
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_info_dark.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_info_light.png b/Plumble/src/main/res/drawable-mdpi/ic_action_info_light.png
new file mode 100644
index 00000000..cac2039d
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_info_light.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_microphone.png b/Plumble/src/main/res/drawable-mdpi/ic_action_microphone.png
new file mode 100644
index 00000000..e605b532
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_microphone.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_microphone_dark.png b/Plumble/src/main/res/drawable-mdpi/ic_action_microphone_dark.png
new file mode 100644
index 00000000..7f15433f
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_microphone_dark.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_microphone_muted.png b/Plumble/src/main/res/drawable-mdpi/ic_action_microphone_muted.png
new file mode 100644
index 00000000..40e5474d
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_microphone_muted.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_minus_light.png b/Plumble/src/main/res/drawable-mdpi/ic_action_minus_light.png
new file mode 100644
index 00000000..464d99b9
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_minus_light.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_more.png b/Plumble/src/main/res/drawable-mdpi/ic_action_more.png
new file mode 100644
index 00000000..2be1fe83
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_more.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_save.png b/Plumble/src/main/res/drawable-mdpi/ic_action_save.png
new file mode 100644
index 00000000..6f1e97cb
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_save.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_search.png b/Plumble/src/main/res/drawable-mdpi/ic_action_search.png
new file mode 100644
index 00000000..9ba0abde
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_search.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_send.png b/Plumble/src/main/res/drawable-mdpi/ic_action_send.png
new file mode 100644
index 00000000..8ee25f4f
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_send.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_settings.png b/Plumble/src/main/res/drawable-mdpi/ic_action_settings.png
new file mode 100644
index 00000000..d7b21c9d
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_settings.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_sort.png b/Plumble/src/main/res/drawable-mdpi/ic_action_sort.png
new file mode 100644
index 00000000..5398e417
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_sort.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_unfullscreen.png b/Plumble/src/main/res/drawable-mdpi/ic_action_unfullscreen.png
new file mode 100644
index 00000000..909a0b2b
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_unfullscreen.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_action_user_dark.png b/Plumble/src/main/res/drawable-mdpi/ic_action_user_dark.png
new file mode 100644
index 00000000..b1f8be1b
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_action_user_dark.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_carriage_return.png b/Plumble/src/main/res/drawable-mdpi/ic_carriage_return.png
new file mode 100644
index 00000000..1de712c9
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_carriage_return.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_comment.png b/Plumble/src/main/res/drawable-mdpi/ic_comment.png
new file mode 100644
index 00000000..14e5544f
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_comment.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_comment_seen.png b/Plumble/src/main/res/drawable-mdpi/ic_comment_seen.png
new file mode 100644
index 00000000..dbcc531a
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_comment_seen.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_deafened.png b/Plumble/src/main/res/drawable-mdpi/ic_deafened.png
new file mode 100644
index 00000000..ef808c4b
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_deafened.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_drawer.png b/Plumble/src/main/res/drawable-mdpi/ic_drawer.png
new file mode 100644
index 00000000..fb681ba2
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_drawer.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_launcher.png b/Plumble/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 00000000..90e32e57
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_launcher.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_menu_moreoverflow_card_dark_normal.png b/Plumble/src/main/res/drawable-mdpi/ic_menu_moreoverflow_card_dark_normal.png
new file mode 100644
index 00000000..7b03a2ea
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_menu_moreoverflow_card_dark_normal.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_menu_moreoverflow_card_dark_pressed.png b/Plumble/src/main/res/drawable-mdpi/ic_menu_moreoverflow_card_dark_pressed.png
new file mode 100644
index 00000000..e666a9e0
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_menu_moreoverflow_card_dark_pressed.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_microphone_muted_strike.png b/Plumble/src/main/res/drawable-mdpi/ic_microphone_muted_strike.png
new file mode 100644
index 00000000..217e6ff1
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_microphone_muted_strike.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_muted.png b/Plumble/src/main/res/drawable-mdpi/ic_muted.png
new file mode 100644
index 00000000..2f098953
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_muted.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_muted_local.png b/Plumble/src/main/res/drawable-mdpi/ic_muted_local.png
new file mode 100644
index 00000000..3375db12
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_muted_local.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_registered.png b/Plumble/src/main/res/drawable-mdpi/ic_registered.png
new file mode 100644
index 00000000..64fb5500
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_registered.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_server_deafened.png b/Plumble/src/main/res/drawable-mdpi/ic_server_deafened.png
new file mode 100644
index 00000000..b8773c5f
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_server_deafened.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_server_light.png b/Plumble/src/main/res/drawable-mdpi/ic_server_light.png
new file mode 100644
index 00000000..f86a46e7
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_server_light.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_server_location.png b/Plumble/src/main/res/drawable-mdpi/ic_server_location.png
new file mode 100644
index 00000000..846b3234
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_server_location.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_server_muted.png b/Plumble/src/main/res/drawable-mdpi/ic_server_muted.png
new file mode 100644
index 00000000..602fd9b7
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_server_muted.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_stat_notify.png b/Plumble/src/main/res/drawable-mdpi/ic_stat_notify.png
new file mode 100644
index 00000000..5e35380b
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_stat_notify.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_stat_notify_active.png b/Plumble/src/main/res/drawable-mdpi/ic_stat_notify_active.png
new file mode 100644
index 00000000..3d6d834b
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_stat_notify_active.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_suppressed.png b/Plumble/src/main/res/drawable-mdpi/ic_suppressed.png
new file mode 100644
index 00000000..4ece694a
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_suppressed.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_talking_off.png b/Plumble/src/main/res/drawable-mdpi/ic_talking_off.png
new file mode 100644
index 00000000..ce34ac1a
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_talking_off.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_talking_on.png b/Plumble/src/main/res/drawable-mdpi/ic_talking_on.png
new file mode 100644
index 00000000..ea8ec5d4
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_talking_on.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_up_arrow.png b/Plumble/src/main/res/drawable-mdpi/ic_up_arrow.png
new file mode 100644
index 00000000..6673c7ae
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_up_arrow.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/ic_user_light.png b/Plumble/src/main/res/drawable-mdpi/ic_user_light.png
new file mode 100644
index 00000000..38da41b1
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/ic_user_light.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/list_longpressed.9.png b/Plumble/src/main/res/drawable-mdpi/list_longpressed.9.png
new file mode 100644
index 00000000..3bf8e036
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/list_longpressed.9.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/list_pressed.9.png b/Plumble/src/main/res/drawable-mdpi/list_pressed.9.png
new file mode 100644
index 00000000..6e77525d
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/list_pressed.9.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/list_selector_disabled.9.png b/Plumble/src/main/res/drawable-mdpi/list_selector_disabled.9.png
new file mode 100644
index 00000000..42cb6463
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/list_selector_disabled.9.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/list_selector_focused.9.png b/Plumble/src/main/res/drawable-mdpi/list_selector_focused.9.png
new file mode 100644
index 00000000..d799fbfb
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/list_selector_focused.9.png differ
diff --git a/Plumble/src/main/res/drawable-mdpi/server_card.9.png b/Plumble/src/main/res/drawable-mdpi/server_card.9.png
new file mode 100644
index 00000000..f5a02971
Binary files /dev/null and b/Plumble/src/main/res/drawable-mdpi/server_card.9.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/drawer_shadow.9.png b/Plumble/src/main/res/drawable-xhdpi/drawer_shadow.9.png
new file mode 100644
index 00000000..fa3d853e
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/drawer_shadow.9.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_add_dark.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_add_dark.png
new file mode 100644
index 00000000..23b9a1c1
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_add_dark.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_add_light.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_add_light.png
new file mode 100644
index 00000000..9b48a63d
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_add_light.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_audio_muted.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_audio_muted.png
new file mode 100644
index 00000000..67bc8203
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_audio_muted.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_audio_muted_active.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_audio_muted_active.png
new file mode 100644
index 00000000..f4e3e1ca
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_audio_muted_active.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_audio_on.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_audio_on.png
new file mode 100644
index 00000000..dfd2b33c
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_audio_on.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_audio_on_active.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_audio_on_active.png
new file mode 100644
index 00000000..e88c6a97
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_audio_on_active.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_audio_on_dark.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_audio_on_dark.png
new file mode 100644
index 00000000..777fab84
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_audio_on_dark.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_bad.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_bad.png
new file mode 100644
index 00000000..931a4c54
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_bad.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_channels.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_channels.png
new file mode 100644
index 00000000..95708234
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_channels.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_chat_active.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_chat_active.png
new file mode 100644
index 00000000..b7d96502
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_chat_active.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_chat_dark.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_chat_dark.png
new file mode 100644
index 00000000..be04b06e
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_chat_dark.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_chat_light.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_chat_light.png
new file mode 100644
index 00000000..3f58695c
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_chat_light.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_comment.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_comment.png
new file mode 100644
index 00000000..6111cabf
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_comment.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_comment_active.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_comment_active.png
new file mode 100644
index 00000000..10b9a0c5
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_comment_active.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_delete_dark.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_delete_dark.png
new file mode 100644
index 00000000..f391760e
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_delete_dark.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_delete_light.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_delete_light.png
new file mode 100644
index 00000000..ca7d159f
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_delete_light.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_drag_handle.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_drag_handle.png
new file mode 100644
index 00000000..722dfd7d
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_drag_handle.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_edit_dark.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_edit_dark.png
new file mode 100644
index 00000000..4215579a
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_edit_dark.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_edit_light.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_edit_light.png
new file mode 100644
index 00000000..1ead8fc3
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_edit_light.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_error.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_error.png
new file mode 100644
index 00000000..aeb96b06
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_error.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_favorite_dark.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_favorite_dark.png
new file mode 100644
index 00000000..e6acafd4
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_favorite_dark.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_favourite_off.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_favourite_off.png
new file mode 100644
index 00000000..3c618a12
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_favourite_off.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_favourite_on.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_favourite_on.png
new file mode 100644
index 00000000..7576cc1e
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_favourite_on.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_fullscreen.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_fullscreen.png
new file mode 100644
index 00000000..791240fd
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_fullscreen.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_info_dark.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_info_dark.png
new file mode 100644
index 00000000..4ee903f0
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_info_dark.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_info_light.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_info_light.png
new file mode 100644
index 00000000..2641f142
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_info_light.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_match.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_match.png
new file mode 100644
index 00000000..52ca8ab7
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_match.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_microphone.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_microphone.png
new file mode 100644
index 00000000..1909d192
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_microphone.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_microphone_dark.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_microphone_dark.png
new file mode 100644
index 00000000..2f5a1e27
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_microphone_dark.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_microphone_muted.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_microphone_muted.png
new file mode 100644
index 00000000..46ae4fd4
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_microphone_muted.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_minus_light.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_minus_light.png
new file mode 100644
index 00000000..e63dfc9c
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_minus_light.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_more.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_more.png
new file mode 100644
index 00000000..930ca8d9
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_more.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_save.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_save.png
new file mode 100644
index 00000000..27206025
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_save.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_search.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_search.png
new file mode 100644
index 00000000..d699c6b3
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_search.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_send.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_send.png
new file mode 100644
index 00000000..0c870d2c
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_send.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_settings.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_settings.png
new file mode 100644
index 00000000..09b01483
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_settings.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_sort.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_sort.png
new file mode 100644
index 00000000..cb2dff32
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_sort.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_unfullscreen.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_unfullscreen.png
new file mode 100644
index 00000000..741774be
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_unfullscreen.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_action_user_dark.png b/Plumble/src/main/res/drawable-xhdpi/ic_action_user_dark.png
new file mode 100644
index 00000000..46ef148d
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_action_user_dark.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_carriage_return.png b/Plumble/src/main/res/drawable-xhdpi/ic_carriage_return.png
new file mode 100644
index 00000000..83727737
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_carriage_return.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_comment.png b/Plumble/src/main/res/drawable-xhdpi/ic_comment.png
new file mode 100644
index 00000000..54531724
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_comment.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_comment_seen.png b/Plumble/src/main/res/drawable-xhdpi/ic_comment_seen.png
new file mode 100644
index 00000000..dbaba1d4
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_comment_seen.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_deafened.png b/Plumble/src/main/res/drawable-xhdpi/ic_deafened.png
new file mode 100644
index 00000000..7a0f9da5
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_deafened.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_drawer.png b/Plumble/src/main/res/drawable-xhdpi/ic_drawer.png
new file mode 100644
index 00000000..b9bc3d70
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_drawer.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_launcher.png b/Plumble/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 00000000..f1c4de92
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_menu_moreoverflow_card_dark_normal.png b/Plumble/src/main/res/drawable-xhdpi/ic_menu_moreoverflow_card_dark_normal.png
new file mode 100644
index 00000000..7a2c7f1b
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_menu_moreoverflow_card_dark_normal.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_menu_moreoverflow_card_dark_pressed.png b/Plumble/src/main/res/drawable-xhdpi/ic_menu_moreoverflow_card_dark_pressed.png
new file mode 100644
index 00000000..910dc20d
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_menu_moreoverflow_card_dark_pressed.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_microphone_muted_strike.png b/Plumble/src/main/res/drawable-xhdpi/ic_microphone_muted_strike.png
new file mode 100644
index 00000000..a8348e85
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_microphone_muted_strike.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_muted.png b/Plumble/src/main/res/drawable-xhdpi/ic_muted.png
new file mode 100644
index 00000000..2108be32
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_muted.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_muted_local.png b/Plumble/src/main/res/drawable-xhdpi/ic_muted_local.png
new file mode 100644
index 00000000..6539d053
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_muted_local.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_registered.png b/Plumble/src/main/res/drawable-xhdpi/ic_registered.png
new file mode 100644
index 00000000..cfb4933a
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_registered.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_server_deafened.png b/Plumble/src/main/res/drawable-xhdpi/ic_server_deafened.png
new file mode 100644
index 00000000..e0f11d55
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_server_deafened.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_server_light.png b/Plumble/src/main/res/drawable-xhdpi/ic_server_light.png
new file mode 100644
index 00000000..1f7df20f
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_server_light.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_server_location.png b/Plumble/src/main/res/drawable-xhdpi/ic_server_location.png
new file mode 100644
index 00000000..e01c5c61
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_server_location.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_server_muted.png b/Plumble/src/main/res/drawable-xhdpi/ic_server_muted.png
new file mode 100644
index 00000000..3238d9b9
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_server_muted.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_stat_notify.png b/Plumble/src/main/res/drawable-xhdpi/ic_stat_notify.png
new file mode 100644
index 00000000..7f7a9a68
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_stat_notify.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_stat_notify_active.png b/Plumble/src/main/res/drawable-xhdpi/ic_stat_notify_active.png
new file mode 100644
index 00000000..50776a1b
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_stat_notify_active.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_suppressed.png b/Plumble/src/main/res/drawable-xhdpi/ic_suppressed.png
new file mode 100644
index 00000000..bf639621
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_suppressed.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_talking_off.png b/Plumble/src/main/res/drawable-xhdpi/ic_talking_off.png
new file mode 100644
index 00000000..e9bf6e20
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_talking_off.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_talking_on.png b/Plumble/src/main/res/drawable-xhdpi/ic_talking_on.png
new file mode 100644
index 00000000..fe129ba3
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_talking_on.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_up_arrow.png b/Plumble/src/main/res/drawable-xhdpi/ic_up_arrow.png
new file mode 100644
index 00000000..be6a7688
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_up_arrow.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/ic_user_light.png b/Plumble/src/main/res/drawable-xhdpi/ic_user_light.png
new file mode 100644
index 00000000..dad3ea99
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/ic_user_light.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/list_longpressed.9.png b/Plumble/src/main/res/drawable-xhdpi/list_longpressed.9.png
new file mode 100644
index 00000000..eda10e61
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/list_longpressed.9.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/list_pressed.9.png b/Plumble/src/main/res/drawable-xhdpi/list_pressed.9.png
new file mode 100644
index 00000000..e4b33935
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/list_pressed.9.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/list_selector_disabled.9.png b/Plumble/src/main/res/drawable-xhdpi/list_selector_disabled.9.png
new file mode 100644
index 00000000..c6a7d4d8
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/list_selector_disabled.9.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/list_selector_focused.9.png b/Plumble/src/main/res/drawable-xhdpi/list_selector_focused.9.png
new file mode 100644
index 00000000..7ea2b211
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/list_selector_focused.9.png differ
diff --git a/Plumble/src/main/res/drawable-xhdpi/server_card.9.png b/Plumble/src/main/res/drawable-xhdpi/server_card.9.png
new file mode 100644
index 00000000..7810a68f
Binary files /dev/null and b/Plumble/src/main/res/drawable-xhdpi/server_card.9.png differ
diff --git a/Plumble/src/main/res/drawable-xxhdpi/ic_action_drag_handle.png b/Plumble/src/main/res/drawable-xxhdpi/ic_action_drag_handle.png
new file mode 100644
index 00000000..cd975b44
Binary files /dev/null and b/Plumble/src/main/res/drawable-xxhdpi/ic_action_drag_handle.png differ
diff --git a/Plumble/src/main/res/drawable-xxhdpi/ic_action_microphone_dark.png b/Plumble/src/main/res/drawable-xxhdpi/ic_action_microphone_dark.png
new file mode 100644
index 00000000..ea7abd08
Binary files /dev/null and b/Plumble/src/main/res/drawable-xxhdpi/ic_action_microphone_dark.png differ
diff --git a/Plumble/src/main/res/drawable-xxhdpi/ic_launcher.png b/Plumble/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 00000000..735da524
Binary files /dev/null and b/Plumble/src/main/res/drawable-xxhdpi/ic_launcher.png differ
diff --git a/Plumble/src/main/res/drawable/card_background.xml b/Plumble/src/main/res/drawable/card_background.xml
new file mode 100644
index 00000000..3f142fb2
--- /dev/null
+++ b/Plumble/src/main/res/drawable/card_background.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/drawable/ic_card_overflow.xml b/Plumble/src/main/res/drawable/ic_card_overflow.xml
new file mode 100644
index 00000000..8caf1360
--- /dev/null
+++ b/Plumble/src/main/res/drawable/ic_card_overflow.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/drawable/ic_stat_notify.png b/Plumble/src/main/res/drawable/ic_stat_notify.png
new file mode 100644
index 00000000..d9d8ba1b
Binary files /dev/null and b/Plumble/src/main/res/drawable/ic_stat_notify.png differ
diff --git a/Plumble/src/main/res/drawable/list_selector_transition.xml b/Plumble/src/main/res/drawable/list_selector_transition.xml
new file mode 100644
index 00000000..d968e748
--- /dev/null
+++ b/Plumble/src/main/res/drawable/list_selector_transition.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
diff --git a/Plumble/src/main/res/drawable/overlay_background.xml b/Plumble/src/main/res/drawable/overlay_background.xml
new file mode 100644
index 00000000..97b87dbb
--- /dev/null
+++ b/Plumble/src/main/res/drawable/overlay_background.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/drawable/popup_menu_item_background.xml b/Plumble/src/main/res/drawable/popup_menu_item_background.xml
new file mode 100644
index 00000000..1818fbd0
--- /dev/null
+++ b/Plumble/src/main/res/drawable/popup_menu_item_background.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/drawable/ptt_indicator_background.xml b/Plumble/src/main/res/drawable/ptt_indicator_background.xml
new file mode 100644
index 00000000..ae1b88dd
--- /dev/null
+++ b/Plumble/src/main/res/drawable/ptt_indicator_background.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/drawable/selectable_background.xml b/Plumble/src/main/res/drawable/selectable_background.xml
new file mode 100644
index 00000000..5f07d7f5
--- /dev/null
+++ b/Plumble/src/main/res/drawable/selectable_background.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout-sw600dp-v11/fragment_channel.xml b/Plumble/src/main/res/layout-sw600dp-v11/fragment_channel.xml
new file mode 100644
index 00000000..7db80789
--- /dev/null
+++ b/Plumble/src/main/res/layout-sw600dp-v11/fragment_channel.xml
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout-sw720dp-v11/fragment_channel.xml b/Plumble/src/main/res/layout-sw720dp-v11/fragment_channel.xml
new file mode 100644
index 00000000..c4349c06
--- /dev/null
+++ b/Plumble/src/main/res/layout-sw720dp-v11/fragment_channel.xml
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/activity_main.xml b/Plumble/src/main/res/layout/activity_main.xml
new file mode 100644
index 00000000..c91a4069
--- /dev/null
+++ b/Plumble/src/main/res/layout/activity_main.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/activity_wizard.xml b/Plumble/src/main/res/layout/activity_wizard.xml
new file mode 100644
index 00000000..433b40dd
--- /dev/null
+++ b/Plumble/src/main/res/layout/activity_wizard.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/channel_row.xml b/Plumble/src/main/res/layout/channel_row.xml
new file mode 100644
index 00000000..0e58969e
--- /dev/null
+++ b/Plumble/src/main/res/layout/channel_row.xml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/channel_user_row.xml b/Plumble/src/main/res/layout/channel_user_row.xml
new file mode 100644
index 00000000..5e18a2f0
--- /dev/null
+++ b/Plumble/src/main/res/layout/channel_user_row.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/dialog_comment.xml b/Plumble/src/main/res/layout/dialog_comment.xml
new file mode 100644
index 00000000..f6b3cdca
--- /dev/null
+++ b/Plumble/src/main/res/layout/dialog_comment.xml
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/dialog_server_edit.xml b/Plumble/src/main/res/layout/dialog_server_edit.xml
new file mode 100644
index 00000000..f69305fa
--- /dev/null
+++ b/Plumble/src/main/res/layout/dialog_server_edit.xml
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Plumble/src/main/res/layout/dialog_server_search.xml b/Plumble/src/main/res/layout/dialog_server_search.xml
new file mode 100644
index 00000000..85f7db0c
--- /dev/null
+++ b/Plumble/src/main/res/layout/dialog_server_search.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/fragment_channel.xml b/Plumble/src/main/res/layout/fragment_channel.xml
new file mode 100644
index 00000000..026b5837
--- /dev/null
+++ b/Plumble/src/main/res/layout/fragment_channel.xml
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/fragment_channel_edit.xml b/Plumble/src/main/res/layout/fragment_channel_edit.xml
new file mode 100644
index 00000000..6fd20b4d
--- /dev/null
+++ b/Plumble/src/main/res/layout/fragment_channel_edit.xml
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/fragment_channel_list.xml b/Plumble/src/main/res/layout/fragment_channel_list.xml
new file mode 100644
index 00000000..dddf2c29
--- /dev/null
+++ b/Plumble/src/main/res/layout/fragment_channel_list.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
diff --git a/Plumble/src/main/res/layout/fragment_chat.xml b/Plumble/src/main/res/layout/fragment_chat.xml
new file mode 100644
index 00000000..2c403616
--- /dev/null
+++ b/Plumble/src/main/res/layout/fragment_chat.xml
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Plumble/src/main/res/layout/fragment_public_server_list.xml b/Plumble/src/main/res/layout/fragment_public_server_list.xml
new file mode 100644
index 00000000..99ba180b
--- /dev/null
+++ b/Plumble/src/main/res/layout/fragment_public_server_list.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
diff --git a/Plumble/src/main/res/layout/fragment_server_info.xml b/Plumble/src/main/res/layout/fragment_server_info.xml
new file mode 100644
index 00000000..8ca73cb8
--- /dev/null
+++ b/Plumble/src/main/res/layout/fragment_server_info.xml
@@ -0,0 +1,139 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Plumble/src/main/res/layout/fragment_server_list.xml b/Plumble/src/main/res/layout/fragment_server_list.xml
new file mode 100644
index 00000000..6b2864d1
--- /dev/null
+++ b/Plumble/src/main/res/layout/fragment_server_list.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
diff --git a/Plumble/src/main/res/layout/fragment_tokens.xml b/Plumble/src/main/res/layout/fragment_tokens.xml
new file mode 100644
index 00000000..751dc72d
--- /dev/null
+++ b/Plumble/src/main/res/layout/fragment_tokens.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/fragment_wizard_audio.xml b/Plumble/src/main/res/layout/fragment_wizard_audio.xml
new file mode 100644
index 00000000..a297c67a
--- /dev/null
+++ b/Plumble/src/main/res/layout/fragment_wizard_audio.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/fragment_wizard_certificate.xml b/Plumble/src/main/res/layout/fragment_wizard_certificate.xml
new file mode 100644
index 00000000..85384b64
--- /dev/null
+++ b/Plumble/src/main/res/layout/fragment_wizard_certificate.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/fragment_wizard_welcome.xml b/Plumble/src/main/res/layout/fragment_wizard_welcome.xml
new file mode 100644
index 00000000..4807ec0c
--- /dev/null
+++ b/Plumble/src/main/res/layout/fragment_wizard_welcome.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/list_chat_item.xml b/Plumble/src/main/res/layout/list_chat_item.xml
new file mode 100644
index 00000000..5c7e72cb
--- /dev/null
+++ b/Plumble/src/main/res/layout/list_chat_item.xml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/list_drawer_header.xml b/Plumble/src/main/res/layout/list_drawer_header.xml
new file mode 100644
index 00000000..ad5cec57
--- /dev/null
+++ b/Plumble/src/main/res/layout/list_drawer_header.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/list_drawer_item.xml b/Plumble/src/main/res/layout/list_drawer_item.xml
new file mode 100644
index 00000000..ae57032f
--- /dev/null
+++ b/Plumble/src/main/res/layout/list_drawer_item.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/nested_dropdown_item.xml b/Plumble/src/main/res/layout/nested_dropdown_item.xml
new file mode 100644
index 00000000..bd35aca1
--- /dev/null
+++ b/Plumble/src/main/res/layout/nested_dropdown_item.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/overlay.xml b/Plumble/src/main/res/layout/overlay.xml
new file mode 100644
index 00000000..7c8f5834
--- /dev/null
+++ b/Plumble/src/main/res/layout/overlay.xml
@@ -0,0 +1,110 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/overlay_user_row.xml b/Plumble/src/main/res/layout/overlay_user_row.xml
new file mode 100644
index 00000000..24bc8750
--- /dev/null
+++ b/Plumble/src/main/res/layout/overlay_user_row.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/popup_menu.xml b/Plumble/src/main/res/layout/popup_menu.xml
new file mode 100644
index 00000000..40e4d89e
--- /dev/null
+++ b/Plumble/src/main/res/layout/popup_menu.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/popup_user_menu_item.xml b/Plumble/src/main/res/layout/popup_user_menu_item.xml
new file mode 100644
index 00000000..b82c149d
--- /dev/null
+++ b/Plumble/src/main/res/layout/popup_user_menu_item.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/ptt_corner.xml b/Plumble/src/main/res/layout/ptt_corner.xml
new file mode 100644
index 00000000..1bf4b2dd
--- /dev/null
+++ b/Plumble/src/main/res/layout/ptt_corner.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/ptt_overlay.xml b/Plumble/src/main/res/layout/ptt_overlay.xml
new file mode 100644
index 00000000..8dacc0ea
--- /dev/null
+++ b/Plumble/src/main/res/layout/ptt_overlay.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/public_server_list_row.xml b/Plumble/src/main/res/layout/public_server_list_row.xml
new file mode 100644
index 00000000..22a24e2d
--- /dev/null
+++ b/Plumble/src/main/res/layout/public_server_list_row.xml
@@ -0,0 +1,141 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/server_list_row.xml b/Plumble/src/main/res/layout/server_list_row.xml
new file mode 100644
index 00000000..8c8e54c4
--- /dev/null
+++ b/Plumble/src/main/res/layout/server_list_row.xml
@@ -0,0 +1,161 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/layout/token_row.xml b/Plumble/src/main/res/layout/token_row.xml
new file mode 100644
index 00000000..7a380f91
--- /dev/null
+++ b/Plumble/src/main/res/layout/token_row.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/menu/activity_server_info.xml b/Plumble/src/main/res/menu/activity_server_info.xml
new file mode 100644
index 00000000..7630e42c
--- /dev/null
+++ b/Plumble/src/main/res/menu/activity_server_info.xml
@@ -0,0 +1,24 @@
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/menu/activity_server_list.xml b/Plumble/src/main/res/menu/activity_server_list.xml
new file mode 100644
index 00000000..7b943a04
--- /dev/null
+++ b/Plumble/src/main/res/menu/activity_server_list.xml
@@ -0,0 +1,21 @@
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/menu/channel_list_context.xml b/Plumble/src/main/res/menu/channel_list_context.xml
new file mode 100644
index 00000000..44edbab8
--- /dev/null
+++ b/Plumble/src/main/res/menu/channel_list_context.xml
@@ -0,0 +1,23 @@
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/menu/channel_list_menu.xml b/Plumble/src/main/res/menu/channel_list_menu.xml
new file mode 100644
index 00000000..efd30e9a
--- /dev/null
+++ b/Plumble/src/main/res/menu/channel_list_menu.xml
@@ -0,0 +1,25 @@
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/menu/channel_modify_menu.xml b/Plumble/src/main/res/menu/channel_modify_menu.xml
new file mode 100644
index 00000000..2486c2ff
--- /dev/null
+++ b/Plumble/src/main/res/menu/channel_modify_menu.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/menu/fragment_channel_list.xml b/Plumble/src/main/res/menu/fragment_channel_list.xml
new file mode 100644
index 00000000..10819bae
--- /dev/null
+++ b/Plumble/src/main/res/menu/fragment_channel_list.xml
@@ -0,0 +1,24 @@
+
+
+
diff --git a/Plumble/src/main/res/menu/fragment_chat.xml b/Plumble/src/main/res/menu/fragment_chat.xml
new file mode 100644
index 00000000..32124a4b
--- /dev/null
+++ b/Plumble/src/main/res/menu/fragment_chat.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/menu/fragment_public_server_list.xml b/Plumble/src/main/res/menu/fragment_public_server_list.xml
new file mode 100644
index 00000000..5dcf24e6
--- /dev/null
+++ b/Plumble/src/main/res/menu/fragment_public_server_list.xml
@@ -0,0 +1,26 @@
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/menu/fragment_server_list.xml b/Plumble/src/main/res/menu/fragment_server_list.xml
new file mode 100644
index 00000000..c6d3f58b
--- /dev/null
+++ b/Plumble/src/main/res/menu/fragment_server_list.xml
@@ -0,0 +1,22 @@
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/menu/plumble.xml b/Plumble/src/main/res/menu/plumble.xml
new file mode 100644
index 00000000..821edd02
--- /dev/null
+++ b/Plumble/src/main/res/menu/plumble.xml
@@ -0,0 +1,26 @@
+
+
+
diff --git a/Plumble/src/main/res/menu/popup_server_row.xml b/Plumble/src/main/res/menu/popup_server_row.xml
new file mode 100644
index 00000000..b3c0d5f9
--- /dev/null
+++ b/Plumble/src/main/res/menu/popup_server_row.xml
@@ -0,0 +1,25 @@
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/values-de/preference.xml b/Plumble/src/main/res/values-de/preference.xml
new file mode 100644
index 00000000..6c18e634
--- /dev/null
+++ b/Plumble/src/main/res/values-de/preference.xml
@@ -0,0 +1,134 @@
+
+
+
+
+
+
+ - Sprachaktivierung
+ - zum Sprechen drücken
+ - Continuous
+
+
+
+ - voiceActivity
+ - ptt
+ - continuous
+
+
+
+ - Hell-Dunkel
+ - Dunkel
+
+
+
+ - lightDark
+ - dark
+
+
+
+ - Freisprechen
+ - Telefonanruf
+
+
+
+ - speakerphone
+ - voice
+
+
+
+ - Keine
+ - Oben Links
+ - Unten Links
+ - Oben Rechts
+ - Unten Rechts
+
+
+
+ - none
+ - topLeft
+ - bottomLeft
+ - topRight
+ - bottomRight
+
+
+
+ - Niedrig
+ - Mittel
+ - Höher
+ - Sehr hoch
+
+
+
+ - 30
+ - 35
+ - 40
+ - 50
+
+
+ Authentifizierung
+ Zertifikatsdatei
+ Das gewünschte P12 Zertifikats aus dem \"Plumble\" Verzeichnis auf dem externen Speicher.
+ Zertifikatspasswort
+ Das Passwort für dein PKCS12 Zertifikat. (optional)
+ Audioeingabe
+ Wann Sprache übertragen werden soll.
+ Eingabemethode
+ Gesprächsmodus
+ Der Gesprächsmodus von Plumble: Entweder wie bei einem Telefonanruf oder bei Freisprechen verhalten.
+ Signalwerterkennung
+ Der minimalste benötigte Ausschlag, um als Sprache erkannt zu werden (nur bei Sprachaktivierung).
+ Sprechtaste
+ Eine Hardwaretaste für die Sprachaktivierung. (optional)
+ Bildschirmecke als Sprechtaste
+ Eine festgelegte Ecke des Bildschirms die beim drücken als Sprechtaste genutzt wird.
+ Aussehen
+ Das Erscheinungsbild der Kanalansicht.
+ Erscheinungsbild
+ Erweiterte Audioeigenschaften
+ Erzwinge TCP
+ Es wird ausschließlich TCP benutzt und UDP wird abgeschaltet.
+ Audio Qualität
+ Kein Zertifikat
+ Zeilenhöhe in Kanalauswahl
+ Legt die Höhe einer Zeile in der Kanalauswahl fest.
+ Kanäle in der Auswahl einfärben
+ Hauptkanäle werden gelb, benutzte Kanäle cyan und stark genutzte Kanäle in Rot dargestellt.
+ Limit für zweite Farbe
+ Wenn diese Anzahl Benutzer erreicht ist, wird der Kanal in der Kanalauswahl Rot dargestellt.
+ Chat Mitteilung
+ Zeige eine Mitteilung wenn ein Benutzer im Chat schreibt.
+ Zertifikat erzeugen
+ Erzeugt ein self-signed Plumble Zertifikat. Empfohlen für unerfahrene Benutzer.
+ Push to Talk Einstellungen
+ Konfigurieren von Push to Talk falls eingeschaltet.
+ Einstellunge Sprachaktivierung
+ Konfiguration der Sprachaktivierung falls eingeschaltet.
+ Audio Ausgabe
+ Opus Codec deaktivieren
+ Opus unterstüzung für Mumble 1.2.4 Server deaktivieren. Hilfreich bei Schwierigkeiten mit dem Ton auf Mumble 1.2.4 Servern.
+ Verstecke die Push to Talk Taste
+ Versteckt die Push to Talk Taste. Nützlich bei Verwendung von Bildschirmecken oder Hardwaretasten zur Sprachaktivierung.
+ Text-zu-Sprache
+ Aktiviert Text-zu-Sprache für eingehende Nachrichten.
+ Push to Talk Taste feststellen
+ Die Sprachübertragung wird beim drücken der Push to Talk Taste dauerhaft aktiviert/deaktiviert.
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/values-de/strings.xml b/Plumble/src/main/res/values-de/strings.xml
new file mode 100644
index 00000000..b046ec16
--- /dev/null
+++ b/Plumble/src/main/res/values-de/strings.xml
@@ -0,0 +1,142 @@
+
+
+
+
+
+ Räume
+ keine Server hinzugefügt
+ Server hinzufügen
+ Passwort (Optional)
+ Benutzername
+ Port
+ Adresse
+ Beschriftung (Optional)
+ Plumble
+ Empfänger
+ Empfänger wählen
+ 64738
+ Chat
+ Raum
+ Hallo Welt!
+ Einstellungen
+ Drücke eine Hardwaretaste für die Sprachaktivierung (PTT).
+ Hinweis: Aufgrund der Limitierungen von Android muss die App geöffnet sein, um eine Hardwaretaste für die Sprachaktivierung (PTT) zu nutzen.
+ Sprechen
+ Stumm stellen
+ Taub stellen
+ Verbindung trennen
+ Bist du dir sicher, dass du die Verbindung zu Mumble trennen möchtest?
+ Speichern
+ Hinzufügen
+ Einstellungen
+ lokale Stummschaltung wechseln
+ Chat
+ Zugriff verboten!
+ Verbindung abgelehnt
+ Bist du dir sicher, dass du diesen Server löschen möchtest?
+ Getrennt
+ Kicked vom Server. Grund: %s
+ Lade...
+ Keine Hardware Taste
+ Externer Speicher nicht verfügbar, kann Zertifikat nicht laden
+ Die Audio Bitrate die Plumble zu nutzen versuchen wird.
+ Favorit hinzufügen
+ Favorit entfernen
+ View Favorites
+ Favoriten
+ Favorit entfernt.
+ Favorit zugefügt.
+ Keine Favoriten gespeichert.
+ Access Tokens
+ Access Token hinzufügen
+ (checkbox setzen zum einrasten der Taste)
+ Neue Mitteilung
+ General
+ Zertifikat erzeugen
+ Dein Zertifikat wurde gesetzt und gespeichert unter %s!
+ Zertifikat konnte nicht erzeugt werden.
+ Erzeuge Zertifikat...
+ Suche Kanal
+ Kanalsuche
+ Leider kann auf deinem Gerät der Proximity Sensor nicht genutzt werden um den Standby zu verhindern. Bitte ändere den Modus zu \'Freisprechen\'.
+ Aufnahmelautstärke Boost
+ Schnelle Verbindung
+ Verbinden
+ Verbindung zum Server
+ Bearbeiten
+ Löschen
+ Erneut versuchen
+ Schreibe Mitteilung an \'%s\'
+ Schreibe Mitteilung an Kanal \'%s\'
+ Online
+ Offline
+ Chatverlauf löschen
+ Verbunden
+ Plumble ist Verbunden
+ Verbindung zum Server wurde unterbrochen.
+ Wiederaufnehmen
+ Kanal
+ Server
+ An %1$s: %2$s
+ %1$s wurde von %3$s aus %2$s verschoben.
+ Stumm und taub.
+ Stumm.
+ Nicht stumm.
+ Nicht stumm und nicht taub.
+ %s ist nun stumm und taub.
+ %s ist nun stumm.
+ %s ist nicht mehr stumm.
+ %s ist nicht mehr stumm und nicht mehr taub.
+ %s ist verbunden.
+ %s hat den Server verlassen.
+ Unbekannt
+ FAVORITEN
+ LAN
+ INTERNET - ÖFFENTLICH
+ Ping
+ Sortierung
+ Sortieren nach…
+ Name
+ Land
+ Teilen
+ Trete diesem Server mit Plumble bei %s
+ Pingen um Informationen abzurufen
+ Stumm und taub.
+ Stumm.
+ Kommentar
+ Schließen
+ Empfangen…
+ Name
+ Land
+ Diese Einstellung kann nicht geändert werden, solange du mit einem Server verbunden bist.
+ Vollbild
+ Chat
+ Kanal
+ Bitte warten, die Liste der öffentlichen Server wird abgerufen.
+ Informationen
+ Registrieren
+ Benutzerkontrolle
+ Registrationsanfrage gesendet
+ Fehler beim Abrufen der Serverliste!\nÜberprüfe deine Internetverbindung.
+ Diese Funktion ist demnächst verfügbar.
+ CHAT
+ STUMM STELLEN
+ STUMM
+ KOMMENTAR
+ REGISTRIERT
+
diff --git a/Plumble/src/main/res/values-large/dimens.xml b/Plumble/src/main/res/values-large/dimens.xml
new file mode 100644
index 00000000..06a6d2d1
--- /dev/null
+++ b/Plumble/src/main/res/values-large/dimens.xml
@@ -0,0 +1,24 @@
+
+
+
+
+ 8dp
+ 16dp
+ 16dp
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/values-pl/preference.xml b/Plumble/src/main/res/values-pl/preference.xml
new file mode 100644
index 00000000..8111b376
--- /dev/null
+++ b/Plumble/src/main/res/values-pl/preference.xml
@@ -0,0 +1,134 @@
+
+
+
+
+
+
+ - Aktywacja głosowa
+ - Aktywacja przyciskiem
+ - Continuous
+
+
+
+ - voiceActivity
+ - ptt
+ - continuous
+
+
+
+ - Jasny
+ - Ciemny
+
+
+
+ - lightDark
+ - dark
+
+
+
+ - Głośnik
+ - Słuchawka
+
+
+
+ - speakerphone
+ - voice
+
+
+
+ - Żaden
+ - Lewy górny
+ - Lewy dolny
+ - Prawy górny
+ - Prawy dolny
+
+
+
+ - none
+ - topLeft
+ - bottomLeft
+ - topRight
+ - bottomRight
+
+
+
+ - Wąski
+ - Średni
+ - Większy
+ - Bardzo duży
+
+
+
+ - 30
+ - 35
+ - 40
+ - 50
+
+
+ Uwierzytelnianie
+ Plik certyfikatu
+ Wybór certyfikatu P12, znajdującego się w katalogu \"Plumble\" w pamięci zewnętrznej.
+ Hasło certyfikatu
+ Hasło do twojego certyfikatu PKCS12. (Opcjonalne)
+ Wejście Dźwięku
+ Wybór między trybami aktywacji.
+ Tryb aktywacji
+ Tryb wyjścia dźwięku
+ Wybór między głośnikiem a słuchawką.
+ Próg detekcji
+ Minimalna amplituda głosu wymagana by został wykryty (dotyczy wyłącznie aktywacji głosowej).
+ Aktywacja przyciskiem
+ Wybór sprzętowego przycisku do aktywacji transmisji. (Opcjonalny)
+ Gorące narożniki
+ Określa róg ekranu, który będzie służył do aktywacji przyciskiem w całym systemie Android.
+ Wygląd
+ Wygląd listy kanałów.
+ Motyw
+ Zaawansowane Ustawienia Dźwięku
+ Wymuś TCP
+ Definiuje czy wymuszać połączenie TCP (wyłącza UDP).
+ Jakość dźwięku
+ Brak certyfikatu
+ Wysokość wiersza kanałów
+ Wysokość wiersza listy wyboru kanału.
+ Koloruj kanały
+ Włącza i wyłącza kolorowanie wyróżniające główne oraz aktywne kanały.
+ Próg alternatywnego koloru
+ Jeżeli liczba użytkowników przekroczy ustaloną wartość, kanał zostanie oznaczony kolorem czerwonym.
+ Powiadomienia czatu
+ Wyświetlaj powiadomienia, gdy ktoś napisze wiadomość.
+ Generowanie certyfikatu
+ Generuje nowy własnoręcznie podpisany certyfikat Plumble. Zalecane dla początkujących.
+ Konfiguracja aktywacji przyciskiem
+ Konfiguracja aktywacji przyciskiem, gdy jest włączona.
+ Konfiguracja aktywacji głosowej
+ Konfiguracja aktywacji głosowej, gdy jest włączona.
+ Wyjście Dźwięku
+ Wyłącz kodek Opus
+ Wyłącza wsparcie kodeka Opus dla serwerów w wersji 1.2.4. Zaznacz jeżeli masz problemy z dźwiękiem na serwerach w wersji 1.2.4.
+ Ukryj przycisk aktywacji przyciskiem
+ Ukrywa przycisk aktywacji przyciskiem. Ukryj go jeżeli korzystasz ze sprzętowego przycisku lub gorących narożników.
+ Tekst-Na-Mowę
+ Aktywuje Tekst-Na-Mowę dla przychdzących wiadomości.
+ Przycisk aktywacji jako przełącznik
+ Naciśnięcie przycisku aktywacji powoduje ciągłe nadawanie do czasu ponownego jego naciśnięcia.
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/values-pl/strings.xml b/Plumble/src/main/res/values-pl/strings.xml
new file mode 100644
index 00000000..781c8607
--- /dev/null
+++ b/Plumble/src/main/res/values-pl/strings.xml
@@ -0,0 +1,142 @@
+
+
+
+
+
+ Kanały
+ Żaden serwer nie został dodany.\nNaciśnij przycisk \'Dodaj\', aby dodać serwer.
+ Dodaj serwer
+ Hasło (Opcjonalne)
+ Nazwa użytkownika
+ Port
+ Adres (IP lub domena)
+ Etykieta
+ Plumble
+ Odbiorca
+ Wybierz odbiorcę
+ 64738
+ Czat
+ Kanał
+ Witaj Świecie!
+ Ustawienia
+ Naciśnij sprzętowy przycisk by go wybrać.
+ Uwaga: Ze względu na ograniczenia w systemie Android aplikacja musi być otwarta, aby można było używać sprzętowego przycisku.
+ Aktywacja przyciskiem
+ Wycisz
+ Ogłusz
+ Rozłącz
+ Na pewno chcesz się rozłączyć?
+ Zapisz
+ Dodaj
+ Konfiguracja
+ Przełącz lokalne wyciszenie
+ Czat
+ Brak dostępu!
+ Połączenie Odrzucone
+ Usunąć ten serwer?
+ Rozłączono
+ Zostałeś wykopany z serwera z powodu: %s
+ Ładowanie…
+ Resetuj
+ Pamięć zewnętrzna jest niedostępna, nie można załadować certyfikatu
+ Bitrate dźwięku, którego będzie używał Plumble (w kbit/s)
+ Dodaj do ulubionych
+ Usuń z ulubionych
+ Ulubione
+ Ulubione
+ Usunięto z ulubionych
+ Dodano do ulubionych
+ Brak ulubionych kanałów
+ Hasła dostępu
+ Dodaj hasło dostępu
+ (zaznacz, aby przełączać)
+ Nowa wiadomość
+ Ogólne
+ Generuj certyfikat
+ Twój certyfikat został utworzony i zapisany jako %s!
+ Generowanie certyfikatu nie powiodło się.
+ Trwa generowanie certyfikatu…
+ Szukaj
+ Wyszukiwanie kanału
+ Niestety, Plumble nie jest w stanie zapewnić obsługi sensora zbliżeniowego w twoim urządzeniu. Proszę zmienić tryb wyjścia dźwięku na głośnik.
+ Opcja pozwala na regulację poziomu głośności mikrofonu.
+ Szybkie połączenie
+ Połącz
+ Połącz do serwera
+ Edytuj
+ Usuń
+ Ponów
+ Wiadomość do: \'%s\'
+ Wiadomość do kanału \'%s\'
+ Online
+ Offline
+ Wyczyść czat
+ Połączony
+ Plumble - Połączono
+ Utracono połączenie z serwerem.
+ Wznów
+ Kanał
+ Serwer
+ Do %1$s: %2$s
+ %1$s został przeniesiony z kanału %2$s przez %3$s.
+ Ogłuszono oraz wyciszono mikrofon.
+ Wyciszono mikrofon.
+ Wyłączono wyciszenie mikrofonu.
+ Wyłączono ogłuszenie oraz wyciszenie mikrofonu.
+ %s jest teraz ogłuszony oraz wyciszony.
+ %s jest teraz wyciszony.
+ %s nie jest już wyciszony.
+ %s nie jest już ogłuszony.
+ %s połączony.
+ %s rozłączony.
+ Nieznany
+ ULUBIONE
+ LAN
+ SERWERY PUBLICZNE
+ Ping
+ Sortuj
+ Sortuj po…
+ Nazwie
+ Kraju
+ Udostępnij
+ Dołącz na ten serwer z Plumble! %s
+ Użyj Ping, aby zebrać informacje
+ Ogłuszony oraz wyciszony mikrofon.
+ Wyciszony mikrofon
+ Komentarz
+ Zamknij
+ Trwa pobieranie…
+ Nazwa
+ Kraj
+ Ta opcja nie może zostać zmieniona podczas połączenia z serwerem.
+ Pełny ekran
+ Czat
+ Kanał
+ Proszę czekać, trwa pobieranie listy publicznych serwerów.
+ Informacje
+ Rejestracja
+ Kontrola użytkownika
+ Wysłano żądanie rejestracji
+ Wystąpił błąd podczas pobierania publicznej listy serwerów!\nSprawdź swoje połączenie z internetem.
+ Funkcja będzie dostępna wkrótce.
+ CZAT
+ WYCISZ
+ WYCISZONY
+ KOMENTARZ
+ ZAREJESTROWANY
+
diff --git a/Plumble/src/main/res/values-sw600dp/dimens.xml b/Plumble/src/main/res/values-sw600dp/dimens.xml
new file mode 100644
index 00000000..03745c15
--- /dev/null
+++ b/Plumble/src/main/res/values-sw600dp/dimens.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
diff --git a/Plumble/src/main/res/values-sw720dp-land/dimens.xml b/Plumble/src/main/res/values-sw720dp-land/dimens.xml
new file mode 100644
index 00000000..be006cdc
--- /dev/null
+++ b/Plumble/src/main/res/values-sw720dp-land/dimens.xml
@@ -0,0 +1,22 @@
+
+
+
+
+ 128dp
+
diff --git a/Plumble/src/main/res/values-v11/styles.xml b/Plumble/src/main/res/values-v11/styles.xml
new file mode 100644
index 00000000..358ed74e
--- /dev/null
+++ b/Plumble/src/main/res/values-v11/styles.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/values/attrs.xml b/Plumble/src/main/res/values/attrs.xml
new file mode 100644
index 00000000..47fc86fc
--- /dev/null
+++ b/Plumble/src/main/res/values/attrs.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/values/colors.xml b/Plumble/src/main/res/values/colors.xml
new file mode 100644
index 00000000..47b34365
--- /dev/null
+++ b/Plumble/src/main/res/values/colors.xml
@@ -0,0 +1,56 @@
+
+
+
+
+ #d3d3d3
+ #555555
+
+ #555555
+ #66000000
+
+
+ #ff33b5e5
+
+ #ff99cc00
+
+ #ffff4444
+
+ #ff0099cc
+
+ #ff669900
+
+ #ffcc0000
+
+ #ffaa66cc
+
+ #ffffbb33
+
+ #ffff8800
+
+ #ff00ddff
+
+
+ #002b36
+ #073642
+ #586e75
+ #657b83
+ #839496
+ #93a1a1
+ #eee8d5
+ #fdf6e3
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/values/dimens.xml b/Plumble/src/main/res/values/dimens.xml
new file mode 100644
index 00000000..2bd8285c
--- /dev/null
+++ b/Plumble/src/main/res/values/dimens.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+ 8dp
+ 8dp
+ 16dp
+ 16dp
+ 16dp
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/values/preference.xml b/Plumble/src/main/res/values/preference.xml
new file mode 100644
index 00000000..b16e5482
--- /dev/null
+++ b/Plumble/src/main/res/values/preference.xml
@@ -0,0 +1,182 @@
+
+
+
+
+
+
+ - Voice Activity
+ - Push to Talk
+ - Continuous
+
+
+
+ - voiceActivity
+ - ptt
+ - continuous
+
+
+
+
+ - 128000Hz (experimental)
+ - 96000Hz (experimental)
+ - 72000Hz (experimental)
+
+ - 48000Hz
+ - 44100Hz
+ - 22050Hz
+ - 16000Hz
+ - 11025Hz
+ - 8000Hz
+
+
+
+
+ - 128000
+ - 96000
+ - 72000
+
+ - 48000
+ - 44100
+ - 22050
+ - 16000
+ - 11025
+ - 8000
+
+
+
+ - Light
+ - Dark
+ - Solarized Light
+ - Solarized Dark
+
+
+
+ - lightDark
+ - dark
+ - solarizedLight
+ - solarizedDark
+
+
+
+ - Speakerphone
+ - Voice Call
+
+
+
+ - speakerphone
+ - voice
+
+
+
+ - None
+ - Top Left
+ - Bottom Left
+ - Top Right
+ - Bottom Right
+
+
+
+ - none
+ - topLeft
+ - bottomLeft
+ - topRight
+ - bottomRight
+
+
+ Authentication
+ Manage and create certificates
+ Certificate File
+ The path of the P12 certificate you wish to use, placed in the \"Plumble\" folder on external storage.
+ Certificate Password
+ The password for your PKCS12 certificate. (optional)
+ Audio Input
+ The way audio is sent to the server.
+ Input Method
+ Microphone Volume
+ Microphone volume multiplier used to artificially normalize audio.
+ Call Mode
+ The call mode of Plumble, whether to act as a voice call or speakerphone.
+ Detection Threshold
+ The minimum amplitude required for voice to be detected (only applicable for voice activity).
+ Push to Talk Key
+ A hardware key to bind to Push to Talk.
+ Push to Talk Hot Corner
+ A specified corner of the screen that, when pressed down, will push to talk throughout Android.
+ General
+ Adjust general settings
+ Appearance
+ Tweak the app\'s visuals
+ The app-wide theme.
+ Theme
+ Advanced
+ Force TCP
+ Whether to force TCP (disable UDP) communications.
+ Audio
+ Adjust audio input and output
+ Input Quality
+ No Certificate
+ Channel Row Height
+ The height of a row in channel selection.
+ Colorize channels
+ Whether to use color to highlight root channels and active channels.
+ Secondary Color Threshold
+ If this number of users is reached in a channel, the channel name appears red.
+ Chat Notifications
+ Show notifications when a user posts in chat.
+ Default Username
+ The default username to use when connecting to servers.
+ Plumble_User
+ Generate Certificate
+ Generates a new self-signed Plumble certificate. Recommended for beginners.
+ Push to Talk Settings
+ Configure Push to Talk if it is enabled.
+ Voice Activity Settings
+ Configure Voice Activity if it is enabled.
+ Audio Output
+ Disable Opus Codec
+ Disable Opus support for Mumble 1.2.4 servers.
+ Hide Push to Talk Button
+ Hides the push to talk button when in push to talk mode. Useful if you use hot corners or a hardware key exclusively.
+ Text-to-Speech
+ Enable Text-to-Speech for incoming messages.
+ Toggle Push to Talk
+ Toggles push to talk on and off when pressed.
+ Auto Reconnect
+ Automatically try to re-establish a connection when the server connection is lost.
+ Connect via Tor
+ Requires Orbot app
+
+
+ About
+ Legal and acknowledgments
+ Copyright © Andrew Comminos 2013
+ Acknowledgments
+ See who contributed to Plumble
+ https://raw.github.com/Morlunk/Plumble/master/THANKS
+ Licenses
+ GNU General Public License v3.0
+ https://www.gnu.org/copyleft/gpl.html
+ Apache License Version 2.0
+ https://www.apache.org/licenses/LICENSE-2.0.html
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/values/strings.xml b/Plumble/src/main/res/values/strings.xml
new file mode 100644
index 00000000..b3009b16
--- /dev/null
+++ b/Plumble/src/main/res/values/strings.xml
@@ -0,0 +1,228 @@
+
+
+
+
+
+ Plumble
+ Channels
+ No servers added.\nPress the \'add\' button on the action bar to begin.
+ Add Server
+ Password
+ Username
+ Port
+ Address
+ Label
+ Connecting
+ Connecting to %1$s:%2$s
+ 64738
+ Chat
+ Channel
+ Settings
+ Press a hardware key to bind to push-to-talk.
+ Note: due to limitations in Android, the app must be open to use hardware key push to talk.
+ PUSH TO TALK
+ Mute
+ Deafen
+ Disconnect
+ Are you sure you want to disconnect from Mumble?
+ Save
+ Add
+ Preferences
+ Toggle Local Mute
+ Chat
+ Permission denied!
+ Connection Refused
+ Are you sure you want to delete this server?
+ Are you sure you want to delete this channel?
+ Disconnected
+ Kicked from server.\nReason: %s
+ Loading…
+ Reset Key
+ External storage unavailable, cannot load certificate
+ The preferred audio bitrate. Not all bitrates are supported by all devices.
+ Add Favorite
+ Remove Favorite
+ View Favorites
+ Favorites
+ Favorite removed.
+ Favorite added.
+ No favorited channels.
+ Access Tokens
+ Add Access Token
+ (tick checkbox to enable toggle)
+ New message
+ Generate Certificate
+ Your certificate has been set and saved as %s!
+ Failed to generate certificate.
+ Generating certificate…
+ Search
+ Search channels and users
+ Unfortunately, it doesn\'t look like we can provide proximity sensor wake lock support for your device. Please change the call mode to speakerphone.
+ Bluetooth
+ Recording Volume Boost
+ Quick Connect
+ Connect
+ Connect to Server
+ Edit
+ Remove
+ Delete
+ Retry
+ Type message to user \'%s\'
+ Type message to channel \'%s\' here
+ Online
+ Offline
+ Clear Chat
+ Connected
+ Plumble Connected
+ Plumble Connecting
+ Plumble Disconnected
+ Lost connection to the server.
+ Resume
+ Channel
+ User
+ Server
+ %1$s moved in from %2$s by %3$s.
+ Muted and deafened.
+ Muted.
+ Unmuted.
+ Unmuted and undeafened.
+ %s is now muted and deafened.
+ %s is now muted.
+ %s is now unmuted.
+ %s is now unmuted and undeafened.
+ %s connected.
+ %s disconnected.
+ Unknown
+ Favourites
+ LAN
+ Public Internet
+ Ping
+ Sort
+ Sort by…
+ Name
+ Country
+ Share
+ Description
+ Join this Mumble server with Plumble! %s
+ Ping to fetch info
+ Muted and deafened.
+ Muted.
+ Comment
+ Close
+ Retrieving…
+ Name
+ Country
+ This setting cannot be changed while connected to a server.
+ Fullscreen
+ Chat
+ Channel
+ Please wait, fetching list of public servers.
+ Information
+ Register Self
+ User Control
+ Sent registration request
+ Error fetching servers!\nCheck your internet connection.
+ This feature is coming soon.
+ %d users
+ Reconnecting in %d seconds.
+ Tap to reconnect
+ Overlay
+ Reason
+ Push to Talk
+ Simply press this button down to talk. Double-tap to toggle it.
+ Welcome to Plumble
+ To begin, add a favourite server by pressing the add button on the action bar.
+ Switching Between Views
+ Switch between the chat and channel views by using the buttons in the top left, or swiping.
+ Settings
+ Reconnect
+ You are already connected to a server. Connect to this server instead?
+ Are you sure you want to reset the comment of user %s?
+ Confirm
+ Expand
+ Temporary
+ Position
+ Edit Channel
+ Add Channel
+ TTS failed to initialize
+ Failed to parse Mumble URL!
+ Welcome to Plumble!
+ Generating a certificate is highly recommended, and necessary for connection to some servers.
+ Generate
+
+
+ Open Drawer
+ Close Drawer
+ Not Connected
+ Server
+ Information
+ Access Tokens
+ Pinned Channels
+ Servers
+ Favorites
+ LAN
+ Public Servers
+
+
+ (Tree)
+ (Channel)
+ %1$s → %2$s
+
+
+ Admin
+ Kick
+ Ban
+ Mute
+ Deafen
+ Priority Speaker
+ Local Mute
+ Ignore Messages
+ Change Comment
+ View Comment
+ Reset Comment
+ Send Message
+ Information
+ Register
+ Registered
+
+
+ Pin
+
+
+ DISPLAY
+ EDIT SOURCE
+ VIEW SOURCE
+
+
+ Protocol %s.
+ %1$s (%2$s)
+ %.2f ms latency
+ Remote host %1$s (port %2$d)
+ Codec: %s
+ Maximum %.1f kbit/s
+ Current %.1f kbit/s
+
+
+ Find Server
+ Finding a server...
+ Server found
+ Couldn\'t find server
+ Couldn\'t find any optimal servers in your country. Expand search worldwide?
+ Name: %1$s\nHost: %2$s:%3$d\nUsers: %4$d / %5$d\nVersion: %6$s \nCountry: %7$s \nLatency: %8$d ms
+ Plumble can automatically find you an empty server, optimizing based on the server\'s location, version, and latency.
+
diff --git a/Plumble/src/main/res/values/styles.xml b/Plumble/src/main/res/values/styles.xml
new file mode 100644
index 00000000..9e3ba470
--- /dev/null
+++ b/Plumble/src/main/res/values/styles.xml
@@ -0,0 +1,110 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/values/wizard.xml b/Plumble/src/main/res/values/wizard.xml
new file mode 100644
index 00000000..8bb94f95
--- /dev/null
+++ b/Plumble/src/main/res/values/wizard.xml
@@ -0,0 +1,37 @@
+
+
+
+
+ Next
+ Back
+ Cancel
+ Finish
+ Are you sure you wish to quit the setup wizard? You can resume it at any time in the app\'s settings.
+
+
+ Welcome to Plumble
+
+
+ Create a Certificate
+
+
+ Setup Audio
+
+
+ Useful Options
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/xml/preference_headers.xml b/Plumble/src/main/res/xml/preference_headers.xml
new file mode 100644
index 00000000..3c015f4b
--- /dev/null
+++ b/Plumble/src/main/res/xml/preference_headers.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/xml/preference_headers_legacy.xml b/Plumble/src/main/res/xml/preference_headers_legacy.xml
new file mode 100644
index 00000000..a3f42089
--- /dev/null
+++ b/Plumble/src/main/res/xml/preference_headers_legacy.xml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/xml/searchable.xml b/Plumble/src/main/res/xml/searchable.xml
new file mode 100644
index 00000000..46425935
--- /dev/null
+++ b/Plumble/src/main/res/xml/searchable.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/xml/settings_about.xml b/Plumble/src/main/res/xml/settings_about.xml
new file mode 100644
index 00000000..8ffa0231
--- /dev/null
+++ b/Plumble/src/main/res/xml/settings_about.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/xml/settings_appearance.xml b/Plumble/src/main/res/xml/settings_appearance.xml
new file mode 100644
index 00000000..449fbab7
--- /dev/null
+++ b/Plumble/src/main/res/xml/settings_appearance.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/xml/settings_audio.xml b/Plumble/src/main/res/xml/settings_audio.xml
new file mode 100644
index 00000000..5429b1a1
--- /dev/null
+++ b/Plumble/src/main/res/xml/settings_audio.xml
@@ -0,0 +1,102 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/xml/settings_authentication.xml b/Plumble/src/main/res/xml/settings_authentication.xml
new file mode 100644
index 00000000..d474e4cc
--- /dev/null
+++ b/Plumble/src/main/res/xml/settings_authentication.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plumble/src/main/res/xml/settings_general.xml b/Plumble/src/main/res/xml/settings_general.xml
new file mode 100644
index 00000000..0c5678a6
--- /dev/null
+++ b/Plumble/src/main/res/xml/settings_general.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 3f2f9bde..81f5e671 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
Plumble
=======
-This is a placeholder for the source of Plumble 3.x.
+Plumble is a robust GPLv3 Mumble client for Android that uses the Jumble protocol implementation.
You can find legacy Plumble code and issues at https://www.github.com/Morlunk/Plumble-Legacy/.
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 00000000..e8f2ec9c
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+
+
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000..8c0fb64a
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..b64d1e90
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,23 @@
+#
+# Copyright (C) 2014 Andrew Comminos
+#
+# 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 .
+#
+
+#Sat Jan 25 18:17:19 PST 2014
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-all.zip
diff --git a/gradlew b/gradlew
new file mode 100755
index 00000000..91a7e269
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 00000000..aec99730
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 00000000..046fe598
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2014 Andrew Comminos
+ *
+ * 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 .
+ */
+
+
+
+include ':Plumble',':Plumble:libraries:libonionkit',':Plumble:libraries:Jumble'
\ No newline at end of file