diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 00000000..c65825e3 --- /dev/null +++ b/LICENSE.txt @@ -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. + + {one line to give the program's name and a brief idea of what it does.} + Copyright (C) {year} {name of author} + + 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: + + {project} Copyright (C) {year} {fullname} + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md index 0ac21ef0..ac549eb7 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,17 @@ [![Code Climate](https://codeclimate.com/github/davidmigloz/go-bees/badges/gpa.svg)](https://codeclimate.com/github/davidmigloz/go-bees) [![Dependency Status](https://www.versioneye.com/user/projects/57f7b19e823b88004e06ad33/badge.svg?style=flat-square)](https://www.versioneye.com/user/projects/57f7b19e823b88004e06ad33) [![Documentation Status](https://readthedocs.org/projects/go-bees/badge/?version=develop)](http://go-bees.readthedocs.io/es/develop/?badge=develop) + +## License + +Copyright (c) 2016 - 2017 David Miguel Lozano + +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 +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. \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 07e9d400..410847bc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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 . + */ + apply plugin: 'com.android.application' apply plugin: 'jacoco-android' apply plugin: 'realm-android' @@ -10,8 +28,8 @@ android { applicationId "com.davidmiguel.gobees" minSdkVersion 19 targetSdkVersion 25 - versionCode 5 - versionName "v0.5" + versionCode 6 + versionName "v0.6" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } diff --git a/app/src/androidTest/java/com/davidmiguel/gobees/apiaries/ApiariesScreenTest.java b/app/src/androidTest/java/com/davidmiguel/gobees/apiaries/ApiariesScreenTest.java index 6ee5e41e..9888cd5d 100644 --- a/app/src/androidTest/java/com/davidmiguel/gobees/apiaries/ApiariesScreenTest.java +++ b/app/src/androidTest/java/com/davidmiguel/gobees/apiaries/ApiariesScreenTest.java @@ -1,3 +1,20 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package com.davidmiguel.gobees.apiaries; import android.support.test.rule.ActivityTestRule; diff --git a/app/src/main/java/com/davidmiguel/gobees/GoBeesApp.java b/app/src/main/java/com/davidmiguel/gobees/GoBeesApp.java index 2edb45a3..5b26f71d 100644 --- a/app/src/main/java/com/davidmiguel/gobees/GoBeesApp.java +++ b/app/src/main/java/com/davidmiguel/gobees/GoBeesApp.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees; import android.app.Application; diff --git a/app/src/main/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryActivity.java b/app/src/main/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryActivity.java index 5a9ccb8a..7edd47dd 100644 --- a/app/src/main/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryActivity.java +++ b/app/src/main/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryActivity.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.addeditapiary; import android.os.Bundle; diff --git a/app/src/main/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryContract.java b/app/src/main/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryContract.java index 541e331c..0c3dfe10 100644 --- a/app/src/main/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryContract.java +++ b/app/src/main/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryContract.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.addeditapiary; import android.content.Context; @@ -72,6 +90,11 @@ interface View extends BaseView { * @return if the permission is granted. */ boolean checkLocationPermission(); + + /** + * Closes / hides soft Android keyboard. + */ + void closeKeyboard(); } interface Presenter extends BasePresenter { diff --git a/app/src/main/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryFragment.java b/app/src/main/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryFragment.java index 855b7a7d..7e09bcd6 100644 --- a/app/src/main/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryFragment.java +++ b/app/src/main/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryFragment.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.addeditapiary; import android.app.Activity; @@ -19,6 +37,7 @@ import android.widget.Toast; import com.davidmiguel.gobees.R; +import com.davidmiguel.gobees.utils.AndroidUtils; import rebus.permissionutils.AskagainCallback; import rebus.permissionutils.PermissionEnum; @@ -208,6 +227,11 @@ public void result(boolean allPermissionsGranted) { return false; } + @Override + public void closeKeyboard() { + AndroidUtils.closeKeyboard(getActivity()); + } + @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { diff --git a/app/src/main/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryPresenter.java b/app/src/main/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryPresenter.java index 4f4fae09..ef843280 100644 --- a/app/src/main/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryPresenter.java +++ b/app/src/main/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryPresenter.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.addeditapiary; import android.content.Context; @@ -125,12 +143,16 @@ public void onDataNotAvailable() { @Override public void onSuccess() { + // Close keyboard + view.closeKeyboard(); // Apiary saved successfully -> go back to apiaries activity view.showApiariesList(); } @Override public void onFailure() { + // Close keyboard + view.closeKeyboard(); // Error saving apiaries view.showSaveApiaryError(); } diff --git a/app/src/main/java/com/davidmiguel/gobees/addeditapiary/LocationService.java b/app/src/main/java/com/davidmiguel/gobees/addeditapiary/LocationService.java index ae9fa196..c44b8a6a 100644 --- a/app/src/main/java/com/davidmiguel/gobees/addeditapiary/LocationService.java +++ b/app/src/main/java/com/davidmiguel/gobees/addeditapiary/LocationService.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.addeditapiary; import android.content.Context; diff --git a/app/src/main/java/com/davidmiguel/gobees/addedithive/AddEditHiveActivity.java b/app/src/main/java/com/davidmiguel/gobees/addedithive/AddEditHiveActivity.java index 8d53c922..220207f3 100644 --- a/app/src/main/java/com/davidmiguel/gobees/addedithive/AddEditHiveActivity.java +++ b/app/src/main/java/com/davidmiguel/gobees/addedithive/AddEditHiveActivity.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.addedithive; import android.os.Bundle; diff --git a/app/src/main/java/com/davidmiguel/gobees/addedithive/AddEditHiveContract.java b/app/src/main/java/com/davidmiguel/gobees/addedithive/AddEditHiveContract.java index 6fb4146f..ff58f194 100644 --- a/app/src/main/java/com/davidmiguel/gobees/addedithive/AddEditHiveContract.java +++ b/app/src/main/java/com/davidmiguel/gobees/addedithive/AddEditHiveContract.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.addedithive; import com.davidmiguel.gobees.utils.BasePresenter; @@ -38,6 +56,11 @@ interface View extends BaseView { * @param notes hive notes. */ void setNotes(String notes); + + /** + * Closes / hides soft Android keyboard. + */ + void closeKeyboard(); } interface Presenter extends BasePresenter { diff --git a/app/src/main/java/com/davidmiguel/gobees/addedithive/AddEditHiveFragment.java b/app/src/main/java/com/davidmiguel/gobees/addedithive/AddEditHiveFragment.java index cc6ba955..b3723303 100644 --- a/app/src/main/java/com/davidmiguel/gobees/addedithive/AddEditHiveFragment.java +++ b/app/src/main/java/com/davidmiguel/gobees/addedithive/AddEditHiveFragment.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.addedithive; import android.app.Activity; @@ -10,9 +28,11 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.inputmethod.InputMethodManager; import android.widget.TextView; import com.davidmiguel.gobees.R; +import com.davidmiguel.gobees.utils.AndroidUtils; import static com.google.common.base.Preconditions.checkNotNull; @@ -99,6 +119,11 @@ public void setNotes(String notes) { notesTextView.setText(notes); } + @Override + public void closeKeyboard() { + AndroidUtils.closeKeyboard(getActivity()); + } + @Override public void setPresenter(@NonNull AddEditHiveContract.Presenter presenter) { this.presenter = checkNotNull(presenter); diff --git a/app/src/main/java/com/davidmiguel/gobees/addedithive/AddEditHivePresenter.java b/app/src/main/java/com/davidmiguel/gobees/addedithive/AddEditHivePresenter.java index 3c7d5d89..dd2b9b24 100644 --- a/app/src/main/java/com/davidmiguel/gobees/addedithive/AddEditHivePresenter.java +++ b/app/src/main/java/com/davidmiguel/gobees/addedithive/AddEditHivePresenter.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.addedithive; import com.davidmiguel.gobees.data.model.Hive; @@ -6,6 +24,8 @@ import com.davidmiguel.gobees.data.source.GoBeesDataSource.GetNextHiveIdCallback; import com.davidmiguel.gobees.data.source.cache.GoBeesRepository; +import java.util.Date; + /** * Listens to user actions from the UI AddEditHiveFragment, retrieves the data and updates the * UI as required. @@ -77,12 +97,16 @@ public void onDataNotAvailable() { @Override public void onSuccess() { + // Close keyboard + view.closeKeyboard(); // Apiary saved successfully -> go back to apiaries activity view.showHivesList(); } @Override public void onFailure() { + // Close keyboard + view.closeKeyboard(); // Error saving apiaries view.showSaveHiveError(); } @@ -126,7 +150,7 @@ private void updateHive(String name, String notes) { } /** - * aves (or update) the hive. + * Saves (or update) the hive. * * @param hiveId hive id. * @param name hive name. @@ -139,6 +163,8 @@ private void saveHive(long hiveId, String name, String notes) { hive.setName(name); // Set notes hive.setNotes(notes); + // Set last revision (now) + hive.setLastRevision(new Date()); // Save it if it is correct if (hive.isValidHive()) { goBeesRepository.saveHive(apiaryId, hive, this); diff --git a/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesActivity.java b/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesActivity.java index 68a87a5f..e651b6c4 100644 --- a/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesActivity.java +++ b/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesActivity.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.apiaries; import android.content.Context; diff --git a/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesAdapter.java b/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesAdapter.java index adcd3ffe..32274ace 100644 --- a/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesAdapter.java +++ b/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesAdapter.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.apiaries; import android.content.Context; diff --git a/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesContract.java b/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesContract.java index 4117a321..f0959719 100644 --- a/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesContract.java +++ b/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesContract.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.apiaries; import android.support.annotation.NonNull; diff --git a/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesFragment.java b/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesFragment.java index 53a905de..8b8f0161 100644 --- a/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesFragment.java +++ b/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesFragment.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.apiaries; import android.content.Intent; diff --git a/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesPresenter.java b/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesPresenter.java index 0543475b..f0999cb0 100644 --- a/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesPresenter.java +++ b/app/src/main/java/com/davidmiguel/gobees/apiaries/ApiariesPresenter.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.apiaries; import android.app.Activity; diff --git a/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryActivity.java b/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryActivity.java index 30440f1e..9bd95bc9 100644 --- a/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryActivity.java +++ b/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryActivity.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.apiary; import android.os.Bundle; @@ -65,7 +83,7 @@ protected void onCreate(Bundle savedInstanceState) { goBeesRepository.openDb(); // Create the presenter - new ApiaryPresenter(goBeesRepository, apiaryHivesFragment, apiaryId); + new ApiaryPresenter(goBeesRepository, apiaryHivesFragment, apiaryInfoFragment, apiaryId); } @Override diff --git a/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryContract.java b/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryContract.java index 960fcbbe..a5790eae 100644 --- a/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryContract.java +++ b/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryContract.java @@ -1,11 +1,31 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.apiary; import android.support.annotation.NonNull; +import com.davidmiguel.gobees.data.model.Apiary; import com.davidmiguel.gobees.data.model.Hive; import com.davidmiguel.gobees.utils.BasePresenter; import com.davidmiguel.gobees.utils.BaseView; +import java.util.Date; import java.util.List; /** @@ -13,7 +33,7 @@ */ interface ApiaryContract { - interface View extends BaseView { + interface ApiaryHivesView extends BaseView { /** * Displays or hide loading indicator. @@ -78,6 +98,31 @@ interface View extends BaseView { void showTitle(@NonNull String title); } + interface ApiaryInfoView extends BaseView { + + /** + * Displays or hide loading indicator. + * + * @param active true or false. + */ + void setLoadingIndicator(final boolean active); + + /** + * Shows the hive info. + * + * @param apiary apiary to show. + * @param lastRevisionDate apiary last revision. + */ + void showInfo(Apiary apiary, Date lastRevisionDate); + + /** + * Shows apiary location on a map. + * + * @param apiary apiary to show. + */ + void openMap(Apiary apiary); + } + interface Presenter extends BasePresenter { /** @@ -89,11 +134,11 @@ interface Presenter extends BasePresenter { void result(int requestCode, int resultCode); /** - * Load hives from repository. + * Load apiary info and its hives from repository. * * @param forceUpdate force cache update. */ - void loadHives(boolean forceUpdate); + void loadData(boolean forceUpdate); /** * Orders to open activity to add or edit a hive. @@ -115,5 +160,10 @@ interface Presenter extends BasePresenter { * @param hive hive to delete. */ void deleteHive(@NonNull Hive hive); + + /** + * Called when the user clicks the map icon (to show the apiary on a map). + */ + void onOpenMapClicked(); } } diff --git a/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryHivesFragment.java b/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryHivesFragment.java index 1398e610..c3af4e99 100644 --- a/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryHivesFragment.java +++ b/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryHivesFragment.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.apiary; import android.content.Intent; @@ -39,7 +57,7 @@ * Display a list of hives. */ public class ApiaryHivesFragment extends Fragment - implements BaseTabFragment, ApiaryContract.View, HivesAdapter.HiveItemListener { + implements BaseTabFragment, ApiaryContract.ApiaryHivesView, HivesAdapter.HiveItemListener { public static final String ARGUMENT_APIARY_ID = "APIARY_ID"; @@ -47,6 +65,7 @@ public class ApiaryHivesFragment extends Fragment private HivesAdapter listAdapter; private View noHivesView; private LinearLayout hivesView; + private FloatingActionButton fab; /** * Get ApiaryHivesFragment instance. @@ -85,8 +104,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, noHivesView = root.findViewById(R.id.no_hives); // Set up floating action button - FloatingActionButton fab = - (FloatingActionButton) getActivity().findViewById(R.id.fab_add_hive); + fab = (FloatingActionButton) getActivity().findViewById(R.id.fab_add_hive); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -108,7 +126,7 @@ public void onClick(View view) { swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { - presenter.loadHives(false); + presenter.loadData(false); } }); @@ -124,6 +142,14 @@ public void onResume() { presenter.start(); } + @Override + public void setUserVisibleHint(boolean isVisibleToUser) { + super.setUserVisibleHint(isVisibleToUser); + if (isVisibleToUser && isResumed()) { + fab.setVisibility(View.VISIBLE); + } + } + @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.apiary_frag_menu, menu); @@ -136,7 +162,7 @@ public boolean onOptionsItemSelected(MenuItem item) { NavUtils.navigateUpFromSameTask(getActivity()); return true; case R.id.menu_refresh: - presenter.loadHives(true); + presenter.loadData(true); break; } return true; diff --git a/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryInfoFragment.java b/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryInfoFragment.java index 8413b151..05d9c171 100644 --- a/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryInfoFragment.java +++ b/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryInfoFragment.java @@ -1,20 +1,79 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.apiary; +import android.content.Intent; +import android.net.Uri; import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.design.widget.FloatingActionButton; import android.support.v4.app.Fragment; +import android.support.v4.content.ContextCompat; +import android.support.v4.widget.SwipeRefreshLayout; +import android.support.v7.widget.CardView; +import android.text.format.DateUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.ScrollView; import android.widget.TextView; import com.davidmiguel.gobees.R; +import com.davidmiguel.gobees.data.model.Apiary; import com.davidmiguel.gobees.utils.BaseTabFragment; +import com.davidmiguel.gobees.utils.ScrollChildSwipeRefreshLayout; +import com.davidmiguel.gobees.utils.WeatherUtils; +import com.google.common.base.Strings; + +import java.util.Date; +import java.util.Locale; + +import static com.google.common.base.Preconditions.checkNotNull; /** * Display apiary info. - * TODO */ -public class ApiaryInfoFragment extends Fragment implements BaseTabFragment { +public class ApiaryInfoFragment extends Fragment + implements BaseTabFragment, ApiaryContract.ApiaryInfoView { + + private ApiaryContract.Presenter presenter; + private FloatingActionButton fab; + + private TextView location; + private ImageView map; + private TextView numHives; + private TextView lastRevision; + private TextView notes; + + private CardView weatherCard; + private ImageView weatherIcon; + private TextView temperature; + private TextView city; + private TextView condition; + private TextView humidity; + private TextView pressure; + private TextView wind; + private TextView rain; + private TextView snow; + private TextView updated; + public static ApiaryInfoFragment newInstance() { return new ApiaryInfoFragment(); @@ -28,14 +87,179 @@ public void onCreate(Bundle savedInstanceState) { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.apiary_info_frag, container, false); - TextView textView = (TextView) view; - textView.setText("Fragment #INFO"); - return view; + View root = inflater.inflate(R.layout.apiary_info_frag, container, false); + + // Set up view + ScrollView info = (ScrollView) root.findViewById(R.id.info); + + location = (TextView) root.findViewById(R.id.location); + map = (ImageView) root.findViewById(R.id.map_icon); + numHives = (TextView) root.findViewById(R.id.num_hives); + lastRevision = (TextView) root.findViewById(R.id.last_revision); + notes = (TextView) root.findViewById(R.id.notes_content); + + weatherCard = (CardView) root.findViewById(R.id.weather_card); + weatherIcon = (ImageView) root.findViewById(R.id.weather_icon); + temperature = (TextView) root.findViewById(R.id.temperature); + city = (TextView) root.findViewById(R.id.city); + condition = (TextView) root.findViewById(R.id.condition); + humidity = (TextView) root.findViewById(R.id.humidity); + pressure = (TextView) root.findViewById(R.id.pressure); + wind = (TextView) root.findViewById(R.id.wind); + rain = (TextView) root.findViewById(R.id.rain); + snow = (TextView) root.findViewById(R.id.snow); + updated = (TextView) root.findViewById(R.id.updated); + + // Set map intent + map.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + presenter.onOpenMapClicked(); + } + }); + + // Set up floating action button + fab = (FloatingActionButton) getActivity().findViewById(R.id.fab_add_hive); + + // Set up progress indicator + final ScrollChildSwipeRefreshLayout swipeRefreshLayout = + (ScrollChildSwipeRefreshLayout) root.findViewById(R.id.refresh_layout); + swipeRefreshLayout.setColorSchemeColors( + ContextCompat.getColor(getActivity(), R.color.colorPrimary), + ContextCompat.getColor(getActivity(), R.color.colorAccent), + ContextCompat.getColor(getActivity(), R.color.colorPrimaryDark) + ); + + // Set the scrolling view in the custom SwipeRefreshLayout + swipeRefreshLayout.setScrollUpChild(info); + swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + presenter.loadData(false); + } + }); + return root; + } + + @Override + public void onResume() { + super.onResume(); + // Reset map icon color + map.setColorFilter(ContextCompat.getColor(getContext(), R.color.colorAccent)); + } + + @Override + public void setUserVisibleHint(boolean isVisibleToUser) { + super.setUserVisibleHint(isVisibleToUser); + if (isVisibleToUser && isResumed()) { + fab.setVisibility(View.GONE); + } } @Override public int getTabName() { return R.string.apiary_info_tab; } + + @Override + public void setLoadingIndicator(final boolean active) { + if (getView() == null) { + return; + } + final SwipeRefreshLayout srl = + (SwipeRefreshLayout) getView().findViewById(R.id.refresh_layout); + // Make sure setRefreshing() is called after the layout is done with everything else + srl.post(new Runnable() { + @Override + public void run() { + srl.setRefreshing(active); + } + }); + } + + @SuppressWarnings("ConstantConditions") + @Override + public void showInfo(Apiary apiary, Date lastRevisionDate) { + // GENERAL INFO + // Location + String latLetter = (apiary.getLocationLat() > 0) ? "N" : "S"; + String lonLetter = (apiary.getLocationLong() > 0) ? "E" : "W"; + location.setText(apiary.getLocationLat() + latLetter + " / " + + apiary.getLocationLong() + lonLetter); + // Num hives + int num = apiary.getHives().size(); + numHives.setText(getResources().getQuantityString(R.plurals.num_hives_plurals, num, num)); + // Last revision + lastRevision.setText(DateUtils.getRelativeTimeSpanString(lastRevisionDate.getTime(), + (new Date()).getTime(), DateUtils.MINUTE_IN_MILLIS)); + // Notes + if (Strings.isNullOrEmpty(apiary.getNotes())) { + notes.setText(getString(R.string.no_notes)); + } else { + notes.setText(apiary.getNotes()); + } + + // WEATHER + // Hide card if no weather data exists + if (apiary.getCurrentWeather() == null) { + weatherCard.setVisibility(View.GONE); + return; + } + // Weather Icon + String iconId = apiary.getCurrentWeather().getWeatherConditionIcon(); + weatherIcon.setImageResource(WeatherUtils.getWeatherIconResourceId(iconId)); + // Temperature + double temp = apiary.getCurrentWeather().getTemperature(); + temperature.setText(WeatherUtils.formatTemperature(getContext(), temp)); + // City + String cityName = apiary.getCurrentWeather().getCityName(); + city.setText(cityName); + // Weather condition + String weatherCondition = WeatherUtils.getStringForWeatherCondition(getContext(), + apiary.getCurrentWeather().getWeatherCondition()); + condition.setText(weatherCondition); + // Humidity + double hum = apiary.getCurrentWeather().getHumidity(); + humidity.setText(WeatherUtils.formatHumidity(getContext(), hum)); + // Pressure + double pre = apiary.getCurrentWeather().getPressure(); + pressure.setText(WeatherUtils.formatPressure(getContext(), pre)); + // Wind + double windSpeed = apiary.getCurrentWeather().getWindSpeed(); + double windDegrees = apiary.getCurrentWeather().getWindDegrees(); + wind.setText(WeatherUtils.formatWind(getContext(), windSpeed, windDegrees)); + // Rain + double rainVol = apiary.getCurrentWeather().getRain(); + rain.setText(WeatherUtils.formatRainSnow(getContext(), rainVol)); + // Snow + double snowVol = apiary.getCurrentWeather().getSnow(); + snow.setText(WeatherUtils.formatRainSnow(getContext(), snowVol)); + // Last update + String date = (String) DateUtils.getRelativeTimeSpanString(apiary.getCurrentWeather() + .getTimestamp().getTime(), (new Date()).getTime(), DateUtils.MINUTE_IN_MILLIS); + updated.setText(date); + } + + @Override + public void openMap(Apiary apiary) { + if (apiary.hasLocation()) { + // Change icon color + map.setColorFilter(ContextCompat.getColor(getContext(), R.color.colorPrimaryDark)); + // Open map + String uri = String.format(Locale.ENGLISH, "geo:%f,%f", + apiary.getLocationLat(), apiary.getLocationLong()); + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); + getContext().startActivity(intent); + } + } + + @Override + public void setPresenter(@NonNull ApiaryContract.Presenter presenter) { + this.presenter = checkNotNull(presenter); + } + + @Override + public boolean isActive() { + return isAdded(); + } } diff --git a/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryPresenter.java b/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryPresenter.java index b8863e43..c93b29df 100644 --- a/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryPresenter.java +++ b/app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryPresenter.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.apiary; import android.app.Activity; @@ -9,6 +27,8 @@ import com.davidmiguel.gobees.data.source.GoBeesDataSource; import com.davidmiguel.gobees.data.source.cache.GoBeesRepository; +import java.util.Date; + /** * Listens to user actions from the UI ApiaryHivesFragment, retrieves the data and updates the * UI as required. @@ -16,19 +36,24 @@ class ApiaryPresenter implements ApiaryContract.Presenter { private GoBeesRepository goBeesRepository; - private ApiaryContract.View view; + private ApiaryContract.ApiaryHivesView apiaryHivesView; + private ApiaryContract.ApiaryInfoView apiaryInfoView; /** * Force update the first time. */ private boolean firstLoad = true; private long apiaryId; + private Apiary apiary; - ApiaryPresenter(GoBeesRepository goBeesRepository, ApiaryContract.View view, - long apiaryId) { + ApiaryPresenter(GoBeesRepository goBeesRepository, + ApiaryContract.ApiaryHivesView apiaryHivesView, + ApiaryContract.ApiaryInfoView apiaryInfoView, long apiaryId) { this.goBeesRepository = goBeesRepository; - this.view = view; - this.view.setPresenter(this); + this.apiaryHivesView = apiaryHivesView; + this.apiaryHivesView.setPresenter(this); + this.apiaryInfoView = apiaryInfoView; + apiaryInfoView.setPresenter(this); this.apiaryId = apiaryId; } @@ -36,18 +61,17 @@ class ApiaryPresenter implements ApiaryContract.Presenter { public void result(int requestCode, int resultCode) { // If a hive was successfully added, show snackbar if (AddEditApiaryActivity.REQUEST_ADD_APIARY == requestCode && Activity.RESULT_OK == resultCode) { - view.showSuccessfullySavedMessage(); + apiaryHivesView.showSuccessfullySavedMessage(); } - // TODO show error message if it fails } @Override - public void loadHives(boolean forceUpdate) { + public void loadData(boolean forceUpdate) { // Force update the first time forceUpdate = forceUpdate || firstLoad; firstLoad = false; // Show progress indicator - view.setLoadingIndicator(true); + apiaryHivesView.setLoadingIndicator(true); // Refresh data if needed if (forceUpdate) { goBeesRepository.refreshHives(apiaryId); @@ -56,79 +80,102 @@ public void loadHives(boolean forceUpdate) { goBeesRepository.getApiary(apiaryId, new GoBeesDataSource.GetApiaryCallback() { @Override public void onApiaryLoaded(Apiary apiary) { + // Save apiary + ApiaryPresenter.this.apiary = apiary; // The view may not be able to handle UI updates anymore - if (!view.isActive()) { + if (!apiaryHivesView.isActive() && !apiaryInfoView.isActive()) { return; } // Hide progress indicator - view.setLoadingIndicator(false); + apiaryHivesView.setLoadingIndicator(false); + apiaryInfoView.setLoadingIndicator(false); // Set apiary name as title - view.showTitle(apiary.getName()); + apiaryHivesView.showTitle(apiary.getName()); // Process hives if (apiary.getHives() == null || apiary.getHives().isEmpty()) { // Show a message indicating there are no hives - view.showNoHives(); + apiaryHivesView.showNoHives(); } else { // Show the list of hives - view.showHives(apiary.getHives()); + apiaryHivesView.showHives(apiary.getHives()); } + // Show apiary info + apiaryInfoView.showInfo(apiary, getApiaryLastRevision()); } @Override public void onDataNotAvailable() { // The view may not be able to handle UI updates anymore - if (!view.isActive()) { + if (!apiaryHivesView.isActive() && !apiaryInfoView.isActive()) { return; } - view.showLoadingHivesError(); + // Hide progress indicator + apiaryHivesView.setLoadingIndicator(false); + apiaryInfoView.setLoadingIndicator(false); + // Show error + apiaryHivesView.showLoadingHivesError(); } }); } @Override public void addEditHive(long hiveId) { - view.showAddEditHive(apiaryId, hiveId); + apiaryHivesView.showAddEditHive(apiaryId, hiveId); } @Override public void openHiveDetail(@NonNull Hive requestedHive) { - view.showHiveDetail(apiaryId, requestedHive.getId()); + apiaryHivesView.showHiveDetail(apiaryId, requestedHive.getId()); } @Override public void deleteHive(@NonNull Hive hive) { // Show progress indicator - view.setLoadingIndicator(true); + apiaryHivesView.setLoadingIndicator(true); // Delete hive goBeesRepository.deleteHive(hive.getId(), new GoBeesDataSource.TaskCallback() { @Override public void onSuccess() { // The view may not be able to handle UI updates anymore - if (!view.isActive()) { + if (!apiaryHivesView.isActive()) { return; } // Refresh recordings - loadHives(true); + loadData(true); // Show success message - view.showSuccessfullyDeletedMessage(); + apiaryHivesView.showSuccessfullyDeletedMessage(); } @Override public void onFailure() { // The view may not be able to handle UI updates anymore - if (!view.isActive()) { + if (!apiaryHivesView.isActive()) { return; } // Hide progress indicator - view.setLoadingIndicator(false); + apiaryHivesView.setLoadingIndicator(false); // Show error - view.showDeletedErrorMessage(); + apiaryHivesView.showDeletedErrorMessage(); } }); } + @Override + public void onOpenMapClicked() { + apiaryInfoView.openMap(apiary); + } + @Override public void start() { - loadHives(false); + loadData(false); + } + + /** + * Gets apiary last revision. + * + * @return last revision date. + */ + private Date getApiaryLastRevision() { + return goBeesRepository.getApiaryLastRevision(apiaryId); } } diff --git a/app/src/main/java/com/davidmiguel/gobees/apiary/HivesAdapter.java b/app/src/main/java/com/davidmiguel/gobees/apiary/HivesAdapter.java index d7023358..f1cc78a7 100644 --- a/app/src/main/java/com/davidmiguel/gobees/apiary/HivesAdapter.java +++ b/app/src/main/java/com/davidmiguel/gobees/apiary/HivesAdapter.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.apiary; import android.graphics.Color; @@ -5,6 +23,7 @@ import android.support.annotation.NonNull; import android.support.v7.widget.CardView; import android.support.v7.widget.RecyclerView; +import android.text.format.DateUtils; import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.MenuInflater; @@ -19,6 +38,7 @@ import com.davidmiguel.gobees.utils.BaseViewHolder; import com.davidmiguel.gobees.utils.ItemTouchHelperViewHolder; +import java.util.Date; import java.util.List; import static com.google.common.base.Preconditions.checkNotNull; @@ -79,6 +99,7 @@ class ViewHolder extends RecyclerView.ViewHolder private View viewHolder; private CardView card; private TextView hiveName; + private TextView lastRevision; private ImageView moreIcon; private Drawable background; @@ -90,6 +111,7 @@ class ViewHolder extends RecyclerView.ViewHolder viewHolder = itemView; card = (CardView) itemView.findViewById(R.id.card); hiveName = (TextView) itemView.findViewById(R.id.hive_name); + lastRevision = (TextView) itemView.findViewById(R.id.last_revision); moreIcon = (ImageView) itemView.findViewById(R.id.more_icon); // Set listeners @@ -108,6 +130,8 @@ public void onClick(View view) { public void bind(@NonNull Hive hive) { hiveName.setText(hive.getName()); + lastRevision.setText(DateUtils.getRelativeTimeSpanString(hive.getLastRevision().getTime(), + (new Date()).getTime(), DateUtils.MINUTE_IN_MILLIS)); } @Override diff --git a/app/src/main/java/com/davidmiguel/gobees/camera/AndroidCamera.java b/app/src/main/java/com/davidmiguel/gobees/camera/AndroidCamera.java index c580e934..057e1d43 100644 --- a/app/src/main/java/com/davidmiguel/gobees/camera/AndroidCamera.java +++ b/app/src/main/java/com/davidmiguel/gobees/camera/AndroidCamera.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.camera; /** diff --git a/app/src/main/java/com/davidmiguel/gobees/camera/AndroidCameraImpl.java b/app/src/main/java/com/davidmiguel/gobees/camera/AndroidCameraImpl.java index 1f1cef61..301af6dd 100644 --- a/app/src/main/java/com/davidmiguel/gobees/camera/AndroidCameraImpl.java +++ b/app/src/main/java/com/davidmiguel/gobees/camera/AndroidCameraImpl.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.camera; import android.graphics.SurfaceTexture; diff --git a/app/src/main/java/com/davidmiguel/gobees/camera/AndroidCameraListener.java b/app/src/main/java/com/davidmiguel/gobees/camera/AndroidCameraListener.java index 47bf8be6..a5bd4244 100644 --- a/app/src/main/java/com/davidmiguel/gobees/camera/AndroidCameraListener.java +++ b/app/src/main/java/com/davidmiguel/gobees/camera/AndroidCameraListener.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.camera; /** diff --git a/app/src/main/java/com/davidmiguel/gobees/camera/CameraFrame.java b/app/src/main/java/com/davidmiguel/gobees/camera/CameraFrame.java index 4c7810aa..8aab5c29 100644 --- a/app/src/main/java/com/davidmiguel/gobees/camera/CameraFrame.java +++ b/app/src/main/java/com/davidmiguel/gobees/camera/CameraFrame.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.camera; import org.opencv.core.Mat; diff --git a/app/src/main/java/com/davidmiguel/gobees/camera/CameraHandlerThread.java b/app/src/main/java/com/davidmiguel/gobees/camera/CameraHandlerThread.java index 19287b64..ec8c7ab5 100644 --- a/app/src/main/java/com/davidmiguel/gobees/camera/CameraHandlerThread.java +++ b/app/src/main/java/com/davidmiguel/gobees/camera/CameraHandlerThread.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.camera; import android.os.Handler; diff --git a/app/src/main/java/com/davidmiguel/gobees/camera/CameraView.java b/app/src/main/java/com/davidmiguel/gobees/camera/CameraView.java index 9d837145..b59ee3e6 100644 --- a/app/src/main/java/com/davidmiguel/gobees/camera/CameraView.java +++ b/app/src/main/java/com/davidmiguel/gobees/camera/CameraView.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.camera; import android.content.Context; diff --git a/app/src/main/java/com/davidmiguel/gobees/camera/PreviewSizeComparator.java b/app/src/main/java/com/davidmiguel/gobees/camera/PreviewSizeComparator.java index 9e348870..dc5621f7 100644 --- a/app/src/main/java/com/davidmiguel/gobees/camera/PreviewSizeComparator.java +++ b/app/src/main/java/com/davidmiguel/gobees/camera/PreviewSizeComparator.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.camera; import android.hardware.Camera; diff --git a/app/src/main/java/com/davidmiguel/gobees/data/model/Apiary.java b/app/src/main/java/com/davidmiguel/gobees/data/model/Apiary.java index 14f640cd..3a89ffab 100644 --- a/app/src/main/java/com/davidmiguel/gobees/data/model/Apiary.java +++ b/app/src/main/java/com/davidmiguel/gobees/data/model/Apiary.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.data.model; import android.support.annotation.NonNull; diff --git a/app/src/main/java/com/davidmiguel/gobees/data/model/Hive.java b/app/src/main/java/com/davidmiguel/gobees/data/model/Hive.java index 21856212..949e08c0 100644 --- a/app/src/main/java/com/davidmiguel/gobees/data/model/Hive.java +++ b/app/src/main/java/com/davidmiguel/gobees/data/model/Hive.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.data.model; import android.support.annotation.NonNull; @@ -6,6 +24,7 @@ import com.google.common.base.Objects; import com.google.common.base.Strings; +import java.util.Date; import java.util.List; import io.realm.RealmList; @@ -41,6 +60,13 @@ public class Hive extends RealmObject { @Nullable private String notes; + /** + * Last revision of the hive. (Last date when some event related with the hive happened + * (the hive was created, modified, a new recording was added...). + */ + @Required + private Date lastRevision; + /** * List of records of the hive. */ @@ -60,11 +86,12 @@ public Hive() { } public Hive(long id, String name, @Nullable String imageUrl, - @Nullable String notes, @Nullable RealmList records) { + @Nullable String notes, Date lastRevision, @Nullable RealmList records) { this.id = id; this.name = name; this.imageUrl = imageUrl; this.notes = notes; + this.lastRevision = lastRevision; this.records = records; } @@ -102,6 +129,14 @@ public void setNotes(@Nullable String notes) { this.notes = notes; } + public Date getLastRevision() { + return lastRevision; + } + + public void setLastRevision(Date lastRevision) { + this.lastRevision = lastRevision; + } + @Nullable public RealmList getRecords() { return records; diff --git a/app/src/main/java/com/davidmiguel/gobees/data/model/MeteoRecord.java b/app/src/main/java/com/davidmiguel/gobees/data/model/MeteoRecord.java index a0fbefc3..09ae3999 100644 --- a/app/src/main/java/com/davidmiguel/gobees/data/model/MeteoRecord.java +++ b/app/src/main/java/com/davidmiguel/gobees/data/model/MeteoRecord.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.data.model; import android.support.annotation.Nullable; @@ -56,7 +74,7 @@ public class MeteoRecord extends RealmObject { private double temperatureMax; /** - * Pressure, e.g: 1023. + * Pressure in hPa, e.g: 1023. */ private int pressure; diff --git a/app/src/main/java/com/davidmiguel/gobees/data/model/Record.java b/app/src/main/java/com/davidmiguel/gobees/data/model/Record.java index 8d9c6abd..1d1f09dd 100644 --- a/app/src/main/java/com/davidmiguel/gobees/data/model/Record.java +++ b/app/src/main/java/com/davidmiguel/gobees/data/model/Record.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.data.model; import android.support.annotation.NonNull; diff --git a/app/src/main/java/com/davidmiguel/gobees/data/model/Recording.java b/app/src/main/java/com/davidmiguel/gobees/data/model/Recording.java index 107b219c..77f3e877 100644 --- a/app/src/main/java/com/davidmiguel/gobees/data/model/Recording.java +++ b/app/src/main/java/com/davidmiguel/gobees/data/model/Recording.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.data.model; import java.util.Date; diff --git a/app/src/main/java/com/davidmiguel/gobees/data/model/mothers/ApiaryMother.java b/app/src/main/java/com/davidmiguel/gobees/data/model/mothers/ApiaryMother.java index 463f2354..91375374 100644 --- a/app/src/main/java/com/davidmiguel/gobees/data/model/mothers/ApiaryMother.java +++ b/app/src/main/java/com/davidmiguel/gobees/data/model/mothers/ApiaryMother.java @@ -1,9 +1,31 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.data.model.mothers; +import android.location.Location; + import com.davidmiguel.gobees.data.model.Apiary; import com.davidmiguel.gobees.data.model.Hive; import com.davidmiguel.gobees.data.model.MeteoRecord; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -20,12 +42,15 @@ public class ApiaryMother { private static final String NAME_PREFIX = "Apiary"; private static final int MAX_ID = 1000; private static final int NUM_HIVES = 6; + private static final double LAT = 42.352083; + private static final double LON = -3.697586; + private long id; private String name; private String imageUrl; - private Double locationLong; private Double locationLat; + private Double locationLong; private String notes; private RealmList hives; private MeteoRecord currentWeather; @@ -67,11 +92,18 @@ public static Apiary newDefaultApiary(int numHives) { } private void setValues(int numHives) { + // Generate id Random r = new Random(System.nanoTime()); id = r.nextInt(MAX_ID); + // Generate name name = NAME_PREFIX + " " + id; + // Generate hives List generatedHives = generateHives(numHives); hives = new RealmList<>(generatedHives.toArray(new Hive[generatedHives.size()])); + // Generate location + Location location = getRandomNearLocation(LAT, LON); + locationLat = location.getLatitude(); + locationLong = location.getLongitude(); } private ApiaryMother withName(String name) { @@ -85,8 +117,8 @@ private ApiaryMother withNotes(String notes) { } private Apiary build() { - return new Apiary(id, name, imageUrl, locationLong, - locationLat, notes, hives, currentWeather, meteoRecords); + return new Apiary(id, name, imageUrl, locationLat, locationLong, + notes, hives, currentWeather, meteoRecords); } private List generateHives(int num) { @@ -96,4 +128,23 @@ private List generateHives(int num) { } return hives; } + + /** + * Generate random location. + * + * @param latitude center latitude. + * @param longitude center longitude. + * @return random location. + */ + private Location getRandomNearLocation(double latitude, double longitude) { + Random random = new Random(); + double lat = new BigDecimal(latitude + random.nextInt(100) / 100d) + .setScale(7, RoundingMode.HALF_UP).doubleValue(); + double lon = new BigDecimal(longitude + random.nextInt(100) / 100d) + .setScale(7, RoundingMode.HALF_UP).doubleValue(); + Location location = new Location(""); + location.setLatitude(lat); + location.setLongitude(lon); + return location; + } } \ No newline at end of file diff --git a/app/src/main/java/com/davidmiguel/gobees/data/model/mothers/HiveMother.java b/app/src/main/java/com/davidmiguel/gobees/data/model/mothers/HiveMother.java index a7dcdb03..6128dc59 100644 --- a/app/src/main/java/com/davidmiguel/gobees/data/model/mothers/HiveMother.java +++ b/app/src/main/java/com/davidmiguel/gobees/data/model/mothers/HiveMother.java @@ -1,8 +1,27 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.data.model.mothers; import com.davidmiguel.gobees.data.model.Hive; import com.davidmiguel.gobees.data.model.Record; +import java.util.Date; import java.util.Random; import io.realm.RealmList; @@ -39,6 +58,7 @@ private static HiveMother newHive() { /** * Generate a hive. + * * @return hive. */ public static Hive newDefaultHive() { @@ -56,6 +76,6 @@ private HiveMother withNotes(String notes) { } private Hive build() { - return new Hive(id, name, imageUrl, notes, records); + return new Hive(id, name, imageUrl, notes, new Date(), records); } } \ No newline at end of file diff --git a/app/src/main/java/com/davidmiguel/gobees/data/model/mothers/RecordMother.java b/app/src/main/java/com/davidmiguel/gobees/data/model/mothers/RecordMother.java index ebfc985d..ec2689ee 100644 --- a/app/src/main/java/com/davidmiguel/gobees/data/model/mothers/RecordMother.java +++ b/app/src/main/java/com/davidmiguel/gobees/data/model/mothers/RecordMother.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.data.model.mothers; import com.davidmiguel.gobees.data.model.Record; diff --git a/app/src/main/java/com/davidmiguel/gobees/data/model/mothers/RecordingMother.java b/app/src/main/java/com/davidmiguel/gobees/data/model/mothers/RecordingMother.java index 32df261b..e5635fab 100644 --- a/app/src/main/java/com/davidmiguel/gobees/data/model/mothers/RecordingMother.java +++ b/app/src/main/java/com/davidmiguel/gobees/data/model/mothers/RecordingMother.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.data.model.mothers; import com.davidmiguel.gobees.data.model.Record; diff --git a/app/src/main/java/com/davidmiguel/gobees/data/source/GoBeesDataSource.java b/app/src/main/java/com/davidmiguel/gobees/data/source/GoBeesDataSource.java index cd7bebbd..e929014c 100644 --- a/app/src/main/java/com/davidmiguel/gobees/data/source/GoBeesDataSource.java +++ b/app/src/main/java/com/davidmiguel/gobees/data/source/GoBeesDataSource.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.data.source; import android.support.annotation.NonNull; @@ -90,6 +108,14 @@ public interface GoBeesDataSource { */ void getNextApiaryId(@NonNull GetNextApiaryIdCallback callback); + /** + * Gets the last date when apiary info was updated. + * + * @param apiaryId apiary id. + * @return apiary last revision date. + */ + Date getApiaryLastRevision(long apiaryId); + /** * Gets all hives. * Note: don't modify the Hive objects. diff --git a/app/src/main/java/com/davidmiguel/gobees/data/source/cache/GoBeesRepository.java b/app/src/main/java/com/davidmiguel/gobees/data/source/cache/GoBeesRepository.java index bf36f231..3eefb1fd 100644 --- a/app/src/main/java/com/davidmiguel/gobees/data/source/cache/GoBeesRepository.java +++ b/app/src/main/java/com/davidmiguel/gobees/data/source/cache/GoBeesRepository.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.data.source.cache; import android.support.annotation.NonNull; @@ -62,8 +80,9 @@ private GoBeesRepository(GoBeesDataSource goBeesDataSource, /** * Get GoBeesRepository instance. + * * @param apiariesLocalDataSource local data source. - * @param weatherDataSource weather data source. + * @param weatherDataSource weather data source. * @return GoBeesRepository instace. */ public static GoBeesRepository getInstance(GoBeesDataSource apiariesLocalDataSource, @@ -184,6 +203,11 @@ public void getNextApiaryId(@NonNull GetNextApiaryIdCallback callback) { goBeesDataSource.getNextApiaryId(callback); } + @Override + public Date getApiaryLastRevision(long apiaryId) { + return goBeesDataSource.getApiaryLastRevision(apiaryId); + } + @SuppressWarnings("ConstantConditions") @Override public void getHives(long apiaryId, @NonNull GetHivesCallback callback) { diff --git a/app/src/main/java/com/davidmiguel/gobees/data/source/local/DataGenerator.java b/app/src/main/java/com/davidmiguel/gobees/data/source/local/DataGenerator.java index 12493a25..57e8081f 100644 --- a/app/src/main/java/com/davidmiguel/gobees/data/source/local/DataGenerator.java +++ b/app/src/main/java/com/davidmiguel/gobees/data/source/local/DataGenerator.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.data.source.local; import com.davidmiguel.gobees.data.model.Apiary; diff --git a/app/src/main/java/com/davidmiguel/gobees/data/source/local/GoBeesDbConfig.java b/app/src/main/java/com/davidmiguel/gobees/data/source/local/GoBeesDbConfig.java index 54313e07..9774ca1e 100644 --- a/app/src/main/java/com/davidmiguel/gobees/data/source/local/GoBeesDbConfig.java +++ b/app/src/main/java/com/davidmiguel/gobees/data/source/local/GoBeesDbConfig.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.data.source.local; import io.realm.RealmConfiguration; diff --git a/app/src/main/java/com/davidmiguel/gobees/data/source/local/GoBeesLocalDataSource.java b/app/src/main/java/com/davidmiguel/gobees/data/source/local/GoBeesLocalDataSource.java index a5890df1..b3b5b925 100644 --- a/app/src/main/java/com/davidmiguel/gobees/data/source/local/GoBeesLocalDataSource.java +++ b/app/src/main/java/com/davidmiguel/gobees/data/source/local/GoBeesLocalDataSource.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.data.source.local; import android.support.annotation.NonNull; @@ -160,6 +178,15 @@ public void getNextApiaryId(@NonNull GetNextApiaryIdCallback callback) { callback.onNextApiaryIdLoaded(nextId != null ? nextId.longValue() + 1 : 0); } + @Override + public Date getApiaryLastRevision(long apiaryId) { + // Get apiary + Apiary apiary = realm.where(Apiary.class).equalTo("id", apiaryId).findFirst(); + // Get last revision date from all hives + return apiary.getHives() == null + ? null : apiary.getHives().where().maximumDate("lastRevision"); + } + @SuppressWarnings("ConstantConditions") @Override public void getHives(long apiaryId, @NonNull GetHivesCallback callback) { @@ -329,6 +356,8 @@ public void execute(Realm realm) { // Add to hive Hive hive = realm.where(Hive.class).equalTo("id", hiveId).findFirst(); hive.addRecords(records); + // Update last revision date (now) + hive.setLastRevision(new Date()); } }); callback.onSuccess(); diff --git a/app/src/main/java/com/davidmiguel/gobees/data/source/network/NetworkUtils.java b/app/src/main/java/com/davidmiguel/gobees/data/source/network/NetworkUtils.java index 501116c9..46dd2700 100644 --- a/app/src/main/java/com/davidmiguel/gobees/data/source/network/NetworkUtils.java +++ b/app/src/main/java/com/davidmiguel/gobees/data/source/network/NetworkUtils.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.data.source.network; import android.net.Uri; diff --git a/app/src/main/java/com/davidmiguel/gobees/data/source/network/OpenWeatherMapUtils.java b/app/src/main/java/com/davidmiguel/gobees/data/source/network/OpenWeatherMapUtils.java index 7b5b440c..da3778c9 100644 --- a/app/src/main/java/com/davidmiguel/gobees/data/source/network/OpenWeatherMapUtils.java +++ b/app/src/main/java/com/davidmiguel/gobees/data/source/network/OpenWeatherMapUtils.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.data.source.network; import com.davidmiguel.gobees.data.model.MeteoRecord; diff --git a/app/src/main/java/com/davidmiguel/gobees/data/source/network/WeatherDataSource.java b/app/src/main/java/com/davidmiguel/gobees/data/source/network/WeatherDataSource.java index 9fdc0e12..6cc13eff 100644 --- a/app/src/main/java/com/davidmiguel/gobees/data/source/network/WeatherDataSource.java +++ b/app/src/main/java/com/davidmiguel/gobees/data/source/network/WeatherDataSource.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.data.source.network; import android.os.AsyncTask; diff --git a/app/src/main/java/com/davidmiguel/gobees/data/source/preferences/GoBeesPreferences.java b/app/src/main/java/com/davidmiguel/gobees/data/source/preferences/GoBeesPreferences.java index 77856896..a7e815c0 100644 --- a/app/src/main/java/com/davidmiguel/gobees/data/source/preferences/GoBeesPreferences.java +++ b/app/src/main/java/com/davidmiguel/gobees/data/source/preferences/GoBeesPreferences.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.data.source.preferences; import android.content.Context; @@ -20,10 +38,10 @@ public class GoBeesPreferences { public static boolean isMetric(Context context) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); - String keyForUnits = context.getString(R.string.pref_temp_units_key); - String defaultUnits = context.getString(R.string.pref_temp_units_metric); + String keyForUnits = context.getString(R.string.pref_weather_units_key); + String defaultUnits = context.getString(R.string.pref_weather_units_metric); String preferredUnits = sp.getString(keyForUnits, defaultUnits); - String metric = context.getString(R.string.pref_temp_units_metric); + String metric = context.getString(R.string.pref_weather_units_metric); return metric.equals(preferredUnits); } diff --git a/app/src/main/java/com/davidmiguel/gobees/hive/HiveActivity.java b/app/src/main/java/com/davidmiguel/gobees/hive/HiveActivity.java index 7ca59d6a..ee9f416d 100644 --- a/app/src/main/java/com/davidmiguel/gobees/hive/HiveActivity.java +++ b/app/src/main/java/com/davidmiguel/gobees/hive/HiveActivity.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.hive; import android.os.Bundle; @@ -76,8 +94,8 @@ protected void onCreate(Bundle savedInstanceState) { goBeesRepository.openDb(); // Create the presenter - new HivePresenter(goBeesRepository, (HiveContract.View) hiveRecordingsFragment, - apiaryId, hiveId); + new HivePresenter(goBeesRepository, (HiveContract.HiveRecordingsView) + hiveRecordingsFragment, hiveInfoFragment, apiaryId, hiveId); } @Override diff --git a/app/src/main/java/com/davidmiguel/gobees/hive/HiveContract.java b/app/src/main/java/com/davidmiguel/gobees/hive/HiveContract.java index 2f03c6cf..22d6f35c 100644 --- a/app/src/main/java/com/davidmiguel/gobees/hive/HiveContract.java +++ b/app/src/main/java/com/davidmiguel/gobees/hive/HiveContract.java @@ -1,8 +1,27 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.hive; import android.content.Intent; import android.support.annotation.NonNull; +import com.davidmiguel.gobees.data.model.Hive; import com.davidmiguel.gobees.data.model.Recording; import com.davidmiguel.gobees.utils.BasePresenter; import com.davidmiguel.gobees.utils.BaseView; @@ -15,7 +34,7 @@ */ interface HiveContract { - interface View extends BaseView { + interface HiveRecordingsView extends BaseView { /** * Displays or hide loading indicator. @@ -98,6 +117,23 @@ interface View extends BaseView { boolean checkCameraPermission(); } + interface HiveInfoView extends BaseView { + + /** + * Displays or hide loading indicator. + * + * @param active true or false. + */ + void setLoadingIndicator(final boolean active); + + /** + * Shows the hive info. + * + * @param hive hive to show. + */ + void showInfo(Hive hive); + } + interface Presenter extends BasePresenter { /** @@ -110,11 +146,11 @@ interface Presenter extends BasePresenter { void result(int requestCode, int resultCode, Intent data); /** - * Load recordings from repository. + * Load hive info and its recordings from repository. * * @param forceUpdate force cache update. */ - void loadRecordings(boolean forceUpdate); + void loadData(boolean forceUpdate); /** * Orders to open activity to record a hive. diff --git a/app/src/main/java/com/davidmiguel/gobees/hive/HiveInfoFragment.java b/app/src/main/java/com/davidmiguel/gobees/hive/HiveInfoFragment.java index 9d3472b0..6f8a8852 100644 --- a/app/src/main/java/com/davidmiguel/gobees/hive/HiveInfoFragment.java +++ b/app/src/main/java/com/davidmiguel/gobees/hive/HiveInfoFragment.java @@ -1,20 +1,57 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.hive; import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.design.widget.FloatingActionButton; import android.support.v4.app.Fragment; +import android.support.v4.content.ContextCompat; +import android.support.v4.widget.SwipeRefreshLayout; +import android.support.v7.widget.CardView; +import android.text.format.DateUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.LinearLayout; import android.widget.TextView; import com.davidmiguel.gobees.R; +import com.davidmiguel.gobees.data.model.Hive; import com.davidmiguel.gobees.utils.BaseTabFragment; +import com.davidmiguel.gobees.utils.ScrollChildSwipeRefreshLayout; +import com.google.common.base.Strings; + +import java.util.Date; + +import static com.google.common.base.Preconditions.checkNotNull; /** * Displays hive info. - * // TODO */ -public class HiveInfoFragment extends Fragment implements BaseTabFragment { +public class HiveInfoFragment extends Fragment + implements BaseTabFragment, HiveContract.HiveInfoView { + + private HiveContract.Presenter presenter; + private FloatingActionButton fab; + private TextView lastRevision; + private TextView notes; public static HiveInfoFragment newInstance() { return new HiveInfoFragment(); @@ -28,14 +65,85 @@ public void onCreate(Bundle savedInstanceState) { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.apiary_info_frag, container, false); - TextView textView = (TextView) view; - textView.setText("Fragment #INFO"); - return view; + View root = inflater.inflate(R.layout.hive_info_frag, container, false); + + // Set up view + LinearLayout info = (LinearLayout) root.findViewById(R.id.info); + lastRevision = (TextView) root.findViewById(R.id.last_revision); + notes = (TextView) root.findViewById(R.id.notes_content); + + // Set up floating action button + fab = (FloatingActionButton) getActivity().findViewById(R.id.fab_new_recording); + + // Set up progress indicator + final ScrollChildSwipeRefreshLayout swipeRefreshLayout = + (ScrollChildSwipeRefreshLayout) root.findViewById(R.id.refresh_layout); + swipeRefreshLayout.setColorSchemeColors( + ContextCompat.getColor(getActivity(), R.color.colorPrimary), + ContextCompat.getColor(getActivity(), R.color.colorAccent), + ContextCompat.getColor(getActivity(), R.color.colorPrimaryDark) + ); + + // Set the scrolling view in the custom SwipeRefreshLayout + swipeRefreshLayout.setScrollUpChild(info); + swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + presenter.loadData(false); + } + }); + return root; + } + + @Override + public void setUserVisibleHint(boolean isVisibleToUser) { + super.setUserVisibleHint(isVisibleToUser); + if (isVisibleToUser && isResumed()) { + fab.setVisibility(View.GONE); + } } @Override public int getTabName() { return R.string.hive_info_tab; } + + @Override + public void setLoadingIndicator(final boolean active) { + if (getView() == null) { + return; + } + final SwipeRefreshLayout srl = + (SwipeRefreshLayout) getView().findViewById(R.id.refresh_layout); + // Make sure setRefreshing() is called after the layout is done with everything else + srl.post(new Runnable() { + @Override + public void run() { + srl.setRefreshing(active); + } + }); + } + + @Override + public void showInfo(Hive hive) { + // Last revision + lastRevision.setText(DateUtils.getRelativeTimeSpanString(hive.getLastRevision().getTime(), + (new Date()).getTime(), DateUtils.MINUTE_IN_MILLIS)); + // Notes + if (Strings.isNullOrEmpty(hive.getNotes())) { + notes.setText(getString(R.string.no_notes)); + } else { + notes.setText(hive.getNotes()); + } + } + + @Override + public void setPresenter(@NonNull HiveContract.Presenter presenter) { + this.presenter = checkNotNull(presenter); + } + + @Override + public boolean isActive() { + return isAdded(); + } } diff --git a/app/src/main/java/com/davidmiguel/gobees/hive/HivePresenter.java b/app/src/main/java/com/davidmiguel/gobees/hive/HivePresenter.java index 40789f78..c8d91491 100644 --- a/app/src/main/java/com/davidmiguel/gobees/hive/HivePresenter.java +++ b/app/src/main/java/com/davidmiguel/gobees/hive/HivePresenter.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.hive; import android.app.Activity; @@ -17,7 +35,8 @@ class HivePresenter implements HiveContract.Presenter { private GoBeesRepository goBeesRepository; - private HiveContract.View view; + private HiveContract.HiveRecordingsView hiveRecordingsView; + private HiveContract.HiveInfoView hiveInfoView; /** * Force update the first time. @@ -26,11 +45,15 @@ class HivePresenter implements HiveContract.Presenter { private long apiaryId; private long hiveId; - HivePresenter(GoBeesRepository goBeesRepository, HiveContract.View view, + HivePresenter(GoBeesRepository goBeesRepository, + HiveContract.HiveRecordingsView hiveRecordingsView, + HiveContract.HiveInfoView hiveInfoView, long apiaryId, long hiveId) { this.goBeesRepository = goBeesRepository; - this.view = view; - this.view.setPresenter(this); + this.hiveRecordingsView = hiveRecordingsView; + this.hiveRecordingsView.setPresenter(this); + this.hiveInfoView = hiveInfoView; + this.hiveInfoView.setPresenter(this); this.apiaryId = apiaryId; this.hiveId = hiveId; } @@ -41,34 +64,34 @@ public void result(int requestCode, int resultCode, Intent data) { if (MonitoringActivity.REQUEST_MONITORING == requestCode) { if (resultCode == Activity.RESULT_OK) { // Refresh recordings - loadRecordings(true); + loadData(true); // Show message - view.showSuccessfullySavedMessage(); + hiveRecordingsView.showSuccessfullySavedMessage(); } else if (resultCode == Activity.RESULT_CANCELED && data != null) { // Get error type int error = data.getIntExtra(HiveRecordingsFragment.ARGUMENT_MONITORING_ERROR, -1); // Show error message switch (error) { case HiveRecordingsFragment.ERROR_RECORDING_TOO_SHORT: - view.showRecordingTooShortErrorMessage(); + hiveRecordingsView.showRecordingTooShortErrorMessage(); break; case HiveRecordingsFragment.ERROR_SAVING_RECORDING: - view.showSaveErrorMessage(); + hiveRecordingsView.showSaveErrorMessage(); break; default: - view.showSaveErrorMessage(); + hiveRecordingsView.showSaveErrorMessage(); } } } } @Override - public void loadRecordings(boolean forceUpdate) { + public void loadData(boolean forceUpdate) { // Force update the first time forceUpdate = forceUpdate || firstLoad; firstLoad = false; // Show progress indicator - view.setLoadingIndicator(true); + hiveRecordingsView.setLoadingIndicator(true); // Refresh data if needed if (forceUpdate) { goBeesRepository.refreshRecordings(hiveId); @@ -78,84 +101,88 @@ public void loadRecordings(boolean forceUpdate) { @Override public void onHiveLoaded(Hive hive) { - // The view may not be able to handle UI updates anymore - if (!view.isActive()) { + // The hiveRecordingsView may not be able to handle UI updates anymore + if (!hiveRecordingsView.isActive() && !hiveInfoView.isActive()) { return; } // Hide progress indicator - view.setLoadingIndicator(false); + hiveRecordingsView.setLoadingIndicator(false); + hiveInfoView.setLoadingIndicator(false); // Set hive name as title - view.showTitle(hive.getName()); + hiveRecordingsView.showTitle(hive.getName()); // Process recordings if (hive.getRecordings().isEmpty()) { // Show a message indicating there are no recordings - view.showNoRecordings(); + hiveRecordingsView.showNoRecordings(); } else { // Show the list of recordings - view.showRecordings(hive.getRecordings()); + hiveRecordingsView.showRecordings(hive.getRecordings()); } + // Show hive info + hiveInfoView.showInfo(hive); } @Override public void onDataNotAvailable() { - // The view may not be able to handle UI updates anymore - if (!view.isActive()) { + // The hiveRecordingsView may not be able to handle UI updates anymore + if (!hiveRecordingsView.isActive() || !hiveInfoView.isActive()) { return; } // Hide progress indicator - view.setLoadingIndicator(false); + hiveRecordingsView.setLoadingIndicator(false); + hiveInfoView.setLoadingIndicator(false); // Show error - view.showLoadingRecordingsError(); + hiveRecordingsView.showLoadingRecordingsError(); } }); } @Override public void startNewRecording() { - if (view.checkCameraPermission()) { - view.startNewRecording(apiaryId, hiveId); + if (hiveRecordingsView.checkCameraPermission()) { + hiveRecordingsView.startNewRecording(apiaryId, hiveId); } } @Override public void openRecordingsDetail(@NonNull Recording recording) { - view.showRecordingDetail(apiaryId, hiveId, recording.getDate()); + hiveRecordingsView.showRecordingDetail(apiaryId, hiveId, recording.getDate()); } @Override public void deleteRecording(@NonNull Recording recording) { // Show progress indicator - view.setLoadingIndicator(true); + hiveRecordingsView.setLoadingIndicator(true); // Delete recording goBeesRepository.deleteRecording(hiveId, recording, new GoBeesDataSource.TaskCallback() { @Override public void onSuccess() { - // The view may not be able to handle UI updates anymore - if (!view.isActive()) { + // The hiveRecordingsView may not be able to handle UI updates anymore + if (!hiveRecordingsView.isActive()) { return; } // Refresh recordings - loadRecordings(true); + loadData(true); // Show success message - view.showSuccessfullyDeletedMessage(); + hiveRecordingsView.showSuccessfullyDeletedMessage(); } @Override public void onFailure() { - // The view may not be able to handle UI updates anymore - if (!view.isActive()) { + // The hiveRecordingsView may not be able to handle UI updates anymore + if (!hiveRecordingsView.isActive()) { return; } // Hide progress indicator - view.setLoadingIndicator(false); + hiveRecordingsView.setLoadingIndicator(false); // Show error - view.showDeletedErrorMessage(); + hiveRecordingsView.showDeletedErrorMessage(); } }); } @Override public void start() { - loadRecordings(false); + loadData(false); } } diff --git a/app/src/main/java/com/davidmiguel/gobees/hive/HiveRecordingsFragment.java b/app/src/main/java/com/davidmiguel/gobees/hive/HiveRecordingsFragment.java index ffee444e..847b5b5b 100644 --- a/app/src/main/java/com/davidmiguel/gobees/hive/HiveRecordingsFragment.java +++ b/app/src/main/java/com/davidmiguel/gobees/hive/HiveRecordingsFragment.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.hive; import android.content.DialogInterface; @@ -49,7 +67,7 @@ * Dispaly a list of recordings. */ public class HiveRecordingsFragment extends Fragment - implements BaseTabFragment, HiveContract.View, RecordingsAdapter.RecordingItemListener { + implements BaseTabFragment, HiveContract.HiveRecordingsView, RecordingsAdapter.RecordingItemListener { public static final String ARGUMENT_APIARY_ID = "APIARY_ID"; public static final String ARGUMENT_HIVE_ID = "HIVE_ID"; @@ -61,6 +79,7 @@ public class HiveRecordingsFragment extends Fragment private RecordingsAdapter listAdapter; private View noRecordingsView; private LinearLayout hivesView; + private FloatingActionButton fab; public HiveRecordingsFragment() { // Requires empty public constructor @@ -94,8 +113,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, noRecordingsView = root.findViewById(R.id.no_recordings); // Set up floating action button - FloatingActionButton fab = - (FloatingActionButton) getActivity().findViewById(R.id.fab_new_recording); + fab = (FloatingActionButton) getActivity().findViewById(R.id.fab_new_recording); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -117,7 +135,7 @@ public void onClick(View v) { swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { - presenter.loadRecordings(false); + presenter.loadData(false); } }); @@ -133,6 +151,14 @@ public void onResume() { presenter.start(); } + @Override + public void setUserVisibleHint(boolean isVisibleToUser) { + super.setUserVisibleHint(isVisibleToUser); + if (isVisibleToUser && isResumed()) { + fab.setVisibility(View.VISIBLE); + } + } + @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.hive_frag_menu, menu); @@ -145,7 +171,7 @@ public boolean onOptionsItemSelected(MenuItem item) { NavUtils.navigateUpFromSameTask(getActivity()); return true; case R.id.menu_refresh: - presenter.loadRecordings(true); + presenter.loadData(true); break; } return true; diff --git a/app/src/main/java/com/davidmiguel/gobees/hive/RecordingsAdapter.java b/app/src/main/java/com/davidmiguel/gobees/hive/RecordingsAdapter.java index cc28c640..e037b280 100644 --- a/app/src/main/java/com/davidmiguel/gobees/hive/RecordingsAdapter.java +++ b/app/src/main/java/com/davidmiguel/gobees/hive/RecordingsAdapter.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.hive; import android.content.Context; diff --git a/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringActivity.java b/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringActivity.java index 026135b9..c69b5c5f 100644 --- a/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringActivity.java +++ b/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringActivity.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.monitoring; import android.os.Bundle; diff --git a/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringContract.java b/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringContract.java index 3f4a63c6..4d812668 100644 --- a/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringContract.java +++ b/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringContract.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.monitoring; import com.davidmiguel.gobees.utils.BasePresenter; diff --git a/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringFragment.java b/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringFragment.java index 35cc51ef..2f20850a 100644 --- a/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringFragment.java +++ b/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringFragment.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.monitoring; import android.app.Activity; diff --git a/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringPresenter.java b/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringPresenter.java index d1143790..99c6ac93 100644 --- a/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringPresenter.java +++ b/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringPresenter.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.monitoring; import com.davidmiguel.gobees.video.BeesCounter; diff --git a/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringService.java b/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringService.java index 9f865748..de659bef 100644 --- a/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringService.java +++ b/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringService.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.monitoring; import android.app.Notification; diff --git a/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringSettings.java b/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringSettings.java index fcd32121..aecd3f72 100644 --- a/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringSettings.java +++ b/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringSettings.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.monitoring; import com.davidmiguel.gobees.video.BeesCounter; diff --git a/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringSettingsFragment.java b/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringSettingsFragment.java index bcfa25c8..35284920 100644 --- a/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringSettingsFragment.java +++ b/app/src/main/java/com/davidmiguel/gobees/monitoring/MonitoringSettingsFragment.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.monitoring; import android.os.Bundle; diff --git a/app/src/main/java/com/davidmiguel/gobees/recording/BeesMarkerView.java b/app/src/main/java/com/davidmiguel/gobees/recording/BeesMarkerView.java index efddf39a..a7fecce4 100644 --- a/app/src/main/java/com/davidmiguel/gobees/recording/BeesMarkerView.java +++ b/app/src/main/java/com/davidmiguel/gobees/recording/BeesMarkerView.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.recording; import android.content.Context; diff --git a/app/src/main/java/com/davidmiguel/gobees/recording/RecordingActivity.java b/app/src/main/java/com/davidmiguel/gobees/recording/RecordingActivity.java index 7cdd618b..5fcd1c0f 100644 --- a/app/src/main/java/com/davidmiguel/gobees/recording/RecordingActivity.java +++ b/app/src/main/java/com/davidmiguel/gobees/recording/RecordingActivity.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.recording; import android.os.Bundle; diff --git a/app/src/main/java/com/davidmiguel/gobees/recording/RecordingContract.java b/app/src/main/java/com/davidmiguel/gobees/recording/RecordingContract.java index f80ade8a..61c174c2 100644 --- a/app/src/main/java/com/davidmiguel/gobees/recording/RecordingContract.java +++ b/app/src/main/java/com/davidmiguel/gobees/recording/RecordingContract.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.recording; import android.support.annotation.NonNull; diff --git a/app/src/main/java/com/davidmiguel/gobees/recording/RecordingFragment.java b/app/src/main/java/com/davidmiguel/gobees/recording/RecordingFragment.java index 34dbd480..2497c328 100644 --- a/app/src/main/java/com/davidmiguel/gobees/recording/RecordingFragment.java +++ b/app/src/main/java/com/davidmiguel/gobees/recording/RecordingFragment.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.recording; import android.graphics.Color; diff --git a/app/src/main/java/com/davidmiguel/gobees/recording/RecordingPresenter.java b/app/src/main/java/com/davidmiguel/gobees/recording/RecordingPresenter.java index 4a925c7b..6186e94b 100644 --- a/app/src/main/java/com/davidmiguel/gobees/recording/RecordingPresenter.java +++ b/app/src/main/java/com/davidmiguel/gobees/recording/RecordingPresenter.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.recording; import com.davidmiguel.gobees.data.model.Recording; diff --git a/app/src/main/java/com/davidmiguel/gobees/settings/SettingsActivity.java b/app/src/main/java/com/davidmiguel/gobees/settings/SettingsActivity.java index d89efafd..96bd3ed8 100644 --- a/app/src/main/java/com/davidmiguel/gobees/settings/SettingsActivity.java +++ b/app/src/main/java/com/davidmiguel/gobees/settings/SettingsActivity.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.settings; import android.os.Bundle; diff --git a/app/src/main/java/com/davidmiguel/gobees/settings/SettingsFragment.java b/app/src/main/java/com/davidmiguel/gobees/settings/SettingsFragment.java index ee9dc759..97986dcd 100644 --- a/app/src/main/java/com/davidmiguel/gobees/settings/SettingsFragment.java +++ b/app/src/main/java/com/davidmiguel/gobees/settings/SettingsFragment.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.settings; import android.os.Bundle; @@ -28,7 +46,7 @@ public void onCreate(Bundle savedInstanceState) { // For all preferences, attach an OnPreferenceChangeListener so the UI summary can be // updated when the preference changes - bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_temp_units_key))); + bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_weather_units_key))); } /** diff --git a/app/src/main/java/com/davidmiguel/gobees/utils/ActivityUtils.java b/app/src/main/java/com/davidmiguel/gobees/utils/ActivityUtils.java index df0ea6d0..e92edd39 100644 --- a/app/src/main/java/com/davidmiguel/gobees/utils/ActivityUtils.java +++ b/app/src/main/java/com/davidmiguel/gobees/utils/ActivityUtils.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.utils; import android.support.annotation.NonNull; diff --git a/app/src/main/java/com/davidmiguel/gobees/utils/AndroidUtils.java b/app/src/main/java/com/davidmiguel/gobees/utils/AndroidUtils.java new file mode 100644 index 00000000..03275683 --- /dev/null +++ b/app/src/main/java/com/davidmiguel/gobees/utils/AndroidUtils.java @@ -0,0 +1,44 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.utils; + +import android.app.Activity; +import android.content.Context; +import android.view.View; +import android.view.inputmethod.InputMethodManager; + +/** + * Android related utilities. + */ +public class AndroidUtils { + + /** + * Closes / hides soft Android keyboard. + * + * @param activity current activity. + */ + public static void closeKeyboard(Activity activity) { + View view = activity.getCurrentFocus(); + if (view != null) { + InputMethodManager imm = + (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } + } +} diff --git a/app/src/main/java/com/davidmiguel/gobees/utils/BackClickHelperFragment.java b/app/src/main/java/com/davidmiguel/gobees/utils/BackClickHelperFragment.java index 398d09bf..0033abdc 100644 --- a/app/src/main/java/com/davidmiguel/gobees/utils/BackClickHelperFragment.java +++ b/app/src/main/java/com/davidmiguel/gobees/utils/BackClickHelperFragment.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.utils; /** diff --git a/app/src/main/java/com/davidmiguel/gobees/utils/BasePresenter.java b/app/src/main/java/com/davidmiguel/gobees/utils/BasePresenter.java index 5db65e22..e82ebb31 100644 --- a/app/src/main/java/com/davidmiguel/gobees/utils/BasePresenter.java +++ b/app/src/main/java/com/davidmiguel/gobees/utils/BasePresenter.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.utils; public interface BasePresenter { diff --git a/app/src/main/java/com/davidmiguel/gobees/utils/BaseTabFragment.java b/app/src/main/java/com/davidmiguel/gobees/utils/BaseTabFragment.java index 4b18915a..a33a3ed0 100644 --- a/app/src/main/java/com/davidmiguel/gobees/utils/BaseTabFragment.java +++ b/app/src/main/java/com/davidmiguel/gobees/utils/BaseTabFragment.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.utils; /** diff --git a/app/src/main/java/com/davidmiguel/gobees/utils/BaseView.java b/app/src/main/java/com/davidmiguel/gobees/utils/BaseView.java index 9601c7cc..9c0d8c0d 100644 --- a/app/src/main/java/com/davidmiguel/gobees/utils/BaseView.java +++ b/app/src/main/java/com/davidmiguel/gobees/utils/BaseView.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.utils; import android.support.annotation.NonNull; diff --git a/app/src/main/java/com/davidmiguel/gobees/utils/BaseViewHolder.java b/app/src/main/java/com/davidmiguel/gobees/utils/BaseViewHolder.java index d943c3cd..b93577c1 100644 --- a/app/src/main/java/com/davidmiguel/gobees/utils/BaseViewHolder.java +++ b/app/src/main/java/com/davidmiguel/gobees/utils/BaseViewHolder.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.utils; import android.support.annotation.NonNull; diff --git a/app/src/main/java/com/davidmiguel/gobees/utils/DateTimeUtils.java b/app/src/main/java/com/davidmiguel/gobees/utils/DateTimeUtils.java index a390ba9b..1b1f37a8 100644 --- a/app/src/main/java/com/davidmiguel/gobees/utils/DateTimeUtils.java +++ b/app/src/main/java/com/davidmiguel/gobees/utils/DateTimeUtils.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.utils; import java.util.Calendar; diff --git a/app/src/main/java/com/davidmiguel/gobees/utils/HourAxisValueFormatter.java b/app/src/main/java/com/davidmiguel/gobees/utils/HourAxisValueFormatter.java index e5434979..7c60d29d 100644 --- a/app/src/main/java/com/davidmiguel/gobees/utils/HourAxisValueFormatter.java +++ b/app/src/main/java/com/davidmiguel/gobees/utils/HourAxisValueFormatter.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.utils; import com.github.mikephil.charting.components.AxisBase; diff --git a/app/src/main/java/com/davidmiguel/gobees/utils/ItemTouchHelperViewHolder.java b/app/src/main/java/com/davidmiguel/gobees/utils/ItemTouchHelperViewHolder.java index d79a762e..c9b34142 100644 --- a/app/src/main/java/com/davidmiguel/gobees/utils/ItemTouchHelperViewHolder.java +++ b/app/src/main/java/com/davidmiguel/gobees/utils/ItemTouchHelperViewHolder.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.utils; /** diff --git a/app/src/main/java/com/davidmiguel/gobees/utils/RainValueFormatter.java b/app/src/main/java/com/davidmiguel/gobees/utils/RainValueFormatter.java index c17f064a..803895fd 100644 --- a/app/src/main/java/com/davidmiguel/gobees/utils/RainValueFormatter.java +++ b/app/src/main/java/com/davidmiguel/gobees/utils/RainValueFormatter.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.utils; import com.github.mikephil.charting.data.Entry; diff --git a/app/src/main/java/com/davidmiguel/gobees/utils/StringUtils.java b/app/src/main/java/com/davidmiguel/gobees/utils/StringUtils.java index 16e1921d..91501165 100644 --- a/app/src/main/java/com/davidmiguel/gobees/utils/StringUtils.java +++ b/app/src/main/java/com/davidmiguel/gobees/utils/StringUtils.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.utils; /** diff --git a/app/src/main/java/com/davidmiguel/gobees/utils/TabsFragmentPagerAdapter.java b/app/src/main/java/com/davidmiguel/gobees/utils/TabsFragmentPagerAdapter.java index 42b370b5..1418ee88 100644 --- a/app/src/main/java/com/davidmiguel/gobees/utils/TabsFragmentPagerAdapter.java +++ b/app/src/main/java/com/davidmiguel/gobees/utils/TabsFragmentPagerAdapter.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.utils; import android.content.Context; diff --git a/app/src/main/java/com/davidmiguel/gobees/utils/TempValueFormatter.java b/app/src/main/java/com/davidmiguel/gobees/utils/TempValueFormatter.java index 8b6910fe..4f3b8e00 100644 --- a/app/src/main/java/com/davidmiguel/gobees/utils/TempValueFormatter.java +++ b/app/src/main/java/com/davidmiguel/gobees/utils/TempValueFormatter.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.utils; import com.github.mikephil.charting.components.AxisBase; diff --git a/app/src/main/java/com/davidmiguel/gobees/utils/WeatherUtils.java b/app/src/main/java/com/davidmiguel/gobees/utils/WeatherUtils.java index 1e522c61..7ccb63be 100644 --- a/app/src/main/java/com/davidmiguel/gobees/utils/WeatherUtils.java +++ b/app/src/main/java/com/davidmiguel/gobees/utils/WeatherUtils.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.utils; import android.content.Context; @@ -43,11 +61,87 @@ public static String formatTemperature(Context context, double temperature) { return String.format(context.getString(temperatureFormatResourceId), temperature); } + /** + * Format humidity. + * + * @param context Android Context to access preferences and resources. + * @param humidity Percentage of humidity, e.g: 18. + * @return Formatted humidity String in the following form: "18%" + */ + public static String formatHumidity(Context context, double humidity) { + int humidityFormatResourceId = R.string.format_humidity_percentage; + return String.format(context.getString(humidityFormatResourceId), humidity); + } + + /** + * Format pressure. + * + * @param context Android Context to access preferences and resources. + * @param pressure Percentage of pressure, e.g: 1024. + * @return Formatted pressure String in the following form: "18 hPa" + */ + public static String formatPressure(Context context, double pressure) { + int pressureFormatResourceId = R.string.format_pressure_hpa; + return String.format(context.getString(pressureFormatResourceId), pressure); + } + + /** + * This method uses the wind direction in degrees to determine compass direction as a + * String. (eg NW) The method will return the wind String in the following form: "2 km/h SW" + * + * @param context Android Context to access preferences and resources + * @param windSpeed Wind speed in kilometers / hour + * @param degrees Degrees as measured on a compass, NOT temperature degrees! + * See https://www.mathsisfun.com/geometry/degrees.html + * @return Wind String in the following form: "2 km/h SW" + */ + public static String formatWind(Context context, double windSpeed, double degrees) { + int windFormat = R.string.format_wind_kmh; + + if (!GoBeesPreferences.isMetric(context)) { + windFormat = R.string.format_wind_mph; + windSpeed = .621371192237334f * windSpeed; + } + + String direction = ""; + if (degrees >= 337.5 || degrees < 22.5) { + direction = "N"; + } else if (degrees >= 22.5 && degrees < 67.5) { + direction = "NE"; + } else if (degrees >= 67.5 && degrees < 112.5) { + direction = "E"; + } else if (degrees >= 112.5 && degrees < 157.5) { + direction = "SE"; + } else if (degrees >= 157.5 && degrees < 202.5) { + direction = "S"; + } else if (degrees >= 202.5 && degrees < 247.5) { + direction = "SW"; + } else if (degrees >= 247.5 && degrees < 292.5) { + direction = "W"; + } else if (degrees >= 292.5 && degrees < 337.5) { + direction = "NW"; + } + + return String.format(context.getString(windFormat), windSpeed, direction); + } + + /** + * Format rain/snow. + * + * @param context Android Context to access preferences and resources. + * @param volume Rain volume (mm), e.g: 3.25. + * @return Formatted rain/snow String in the following form: "0.1 mm" + */ + public static String formatRainSnow(Context context, double volume) { + int rainSnowFormatResourceId = R.string.format_rain_snow_mm; + return String.format(context.getString(rainSnowFormatResourceId), volume); + } + /** * Helper method to provide the icon resource id according to the weather condition id returned * by the OpenWeatherMap call. * - * @param weatherIconId from OpenWeatherMap API response + * @param weatherIconId from OpenWeatherMap API response. * See http://openweathermap.org/weather-conditions for a list of all IDs. * @return resource id for the corresponding icon. day_clear_sky if no relation is found. */ @@ -88,6 +182,237 @@ public static int getWeatherIconResourceId(String weatherIconId) { } } + /** + * Helper method to provide the string according to the weather + * condition id returned by the OpenWeatherMap call. + * + * @param context Android context. + * @param weatherId from OpenWeatherMap API response. + * See http://openweathermap.org/weather-conditions for a list of all IDs + * @return String for the weather condition, condition_unknown if no relation is found. + */ + public static String getStringForWeatherCondition(Context context, int weatherId) { + int stringId; + switch (weatherId) { + case 200: + stringId = R.string.condition_200; + break; + case 201: + stringId = R.string.condition_201; + break; + case 202: + stringId = R.string.condition_202; + break; + case 210: + stringId = R.string.condition_210; + break; + case 211: + stringId = R.string.condition_211; + break; + case 212: + stringId = R.string.condition_212; + break; + case 221: + stringId = R.string.condition_221; + break; + case 230: + stringId = R.string.condition_230; + break; + case 231: + stringId = R.string.condition_231; + break; + case 232: + stringId = R.string.condition_232; + break; + case 300: + stringId = R.string.condition_300; + break; + case 301: + stringId = R.string.condition_301; + break; + case 302: + stringId = R.string.condition_302; + break; + case 310: + stringId = R.string.condition_310; + break; + case 311: + stringId = R.string.condition_311; + break; + case 312: + stringId = R.string.condition_312; + break; + case 313: + stringId = R.string.condition_313; + break; + case 314: + stringId = R.string.condition_314; + break; + case 321: + stringId = R.string.condition_321; + break; + case 500: + stringId = R.string.condition_500; + break; + case 501: + stringId = R.string.condition_501; + break; + case 502: + stringId = R.string.condition_502; + break; + case 503: + stringId = R.string.condition_503; + break; + case 504: + stringId = R.string.condition_504; + break; + case 511: + stringId = R.string.condition_511; + break; + case 520: + stringId = R.string.condition_520; + break; + case 531: + stringId = R.string.condition_531; + break; + case 600: + stringId = R.string.condition_600; + break; + case 601: + stringId = R.string.condition_601; + break; + case 602: + stringId = R.string.condition_602; + break; + case 611: + stringId = R.string.condition_611; + break; + case 612: + stringId = R.string.condition_612; + break; + case 615: + stringId = R.string.condition_615; + break; + case 616: + stringId = R.string.condition_616; + break; + case 620: + stringId = R.string.condition_620; + break; + case 621: + stringId = R.string.condition_621; + break; + case 622: + stringId = R.string.condition_622; + break; + case 701: + stringId = R.string.condition_701; + break; + case 711: + stringId = R.string.condition_711; + break; + case 721: + stringId = R.string.condition_721; + break; + case 731: + stringId = R.string.condition_731; + break; + case 741: + stringId = R.string.condition_741; + break; + case 751: + stringId = R.string.condition_751; + break; + case 761: + stringId = R.string.condition_761; + break; + case 762: + stringId = R.string.condition_762; + break; + case 771: + stringId = R.string.condition_771; + break; + case 781: + stringId = R.string.condition_781; + break; + case 800: + stringId = R.string.condition_800; + break; + case 801: + stringId = R.string.condition_801; + break; + case 802: + stringId = R.string.condition_802; + break; + case 803: + stringId = R.string.condition_803; + break; + case 804: + stringId = R.string.condition_804; + break; + case 900: + stringId = R.string.condition_900; + break; + case 901: + stringId = R.string.condition_901; + break; + case 902: + stringId = R.string.condition_902; + break; + case 903: + stringId = R.string.condition_903; + break; + case 904: + stringId = R.string.condition_904; + break; + case 905: + stringId = R.string.condition_905; + break; + case 906: + stringId = R.string.condition_906; + break; + case 951: + stringId = R.string.condition_951; + break; + case 952: + stringId = R.string.condition_952; + break; + case 953: + stringId = R.string.condition_953; + break; + case 954: + stringId = R.string.condition_954; + break; + case 955: + stringId = R.string.condition_955; + break; + case 956: + stringId = R.string.condition_956; + break; + case 957: + stringId = R.string.condition_957; + break; + case 958: + stringId = R.string.condition_958; + break; + case 959: + stringId = R.string.condition_959; + break; + case 960: + stringId = R.string.condition_960; + break; + case 961: + stringId = R.string.condition_961; + break; + case 962: + stringId = R.string.condition_962; + break; + default: + return context.getString(R.string.condition_unknown, weatherId); + } + return context.getString(stringId); + } + /** * Convert dp to pixels. * diff --git a/app/src/main/java/com/davidmiguel/gobees/utils/WindValueFormatter.java b/app/src/main/java/com/davidmiguel/gobees/utils/WindValueFormatter.java index 52d5a0df..655b086c 100644 --- a/app/src/main/java/com/davidmiguel/gobees/utils/WindValueFormatter.java +++ b/app/src/main/java/com/davidmiguel/gobees/utils/WindValueFormatter.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.utils; import com.github.mikephil.charting.data.Entry; diff --git a/app/src/main/java/com/davidmiguel/gobees/video/BeesCounter.java b/app/src/main/java/com/davidmiguel/gobees/video/BeesCounter.java index 23171e48..efd44798 100644 --- a/app/src/main/java/com/davidmiguel/gobees/video/BeesCounter.java +++ b/app/src/main/java/com/davidmiguel/gobees/video/BeesCounter.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.video; import org.opencv.core.Mat; diff --git a/app/src/main/java/com/davidmiguel/gobees/video/ContourBeesCounter.java b/app/src/main/java/com/davidmiguel/gobees/video/ContourBeesCounter.java index 3855bdf3..7dbc11f6 100644 --- a/app/src/main/java/com/davidmiguel/gobees/video/ContourBeesCounter.java +++ b/app/src/main/java/com/davidmiguel/gobees/video/ContourBeesCounter.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.video; import android.support.annotation.NonNull; diff --git a/app/src/main/java/com/davidmiguel/gobees/video/processors/BackgroundSubtractor.java b/app/src/main/java/com/davidmiguel/gobees/video/processors/BackgroundSubtractor.java index 43b70eb1..44ed9824 100644 --- a/app/src/main/java/com/davidmiguel/gobees/video/processors/BackgroundSubtractor.java +++ b/app/src/main/java/com/davidmiguel/gobees/video/processors/BackgroundSubtractor.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.video.processors; import android.support.annotation.NonNull; diff --git a/app/src/main/java/com/davidmiguel/gobees/video/processors/Blur.java b/app/src/main/java/com/davidmiguel/gobees/video/processors/Blur.java index af19570d..d452287c 100644 --- a/app/src/main/java/com/davidmiguel/gobees/video/processors/Blur.java +++ b/app/src/main/java/com/davidmiguel/gobees/video/processors/Blur.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.video.processors; import android.support.annotation.NonNull; diff --git a/app/src/main/java/com/davidmiguel/gobees/video/processors/ContoursFinder.java b/app/src/main/java/com/davidmiguel/gobees/video/processors/ContoursFinder.java index c5b4970e..494dbf22 100644 --- a/app/src/main/java/com/davidmiguel/gobees/video/processors/ContoursFinder.java +++ b/app/src/main/java/com/davidmiguel/gobees/video/processors/ContoursFinder.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.video.processors; import android.support.annotation.NonNull; diff --git a/app/src/main/java/com/davidmiguel/gobees/video/processors/Morphology.java b/app/src/main/java/com/davidmiguel/gobees/video/processors/Morphology.java index 99b187e9..e004d64d 100644 --- a/app/src/main/java/com/davidmiguel/gobees/video/processors/Morphology.java +++ b/app/src/main/java/com/davidmiguel/gobees/video/processors/Morphology.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.video.processors; import android.support.annotation.NonNull; diff --git a/app/src/main/java/com/davidmiguel/gobees/video/processors/VideoProcessor.java b/app/src/main/java/com/davidmiguel/gobees/video/processors/VideoProcessor.java index b3dc22f4..e7a03b45 100644 --- a/app/src/main/java/com/davidmiguel/gobees/video/processors/VideoProcessor.java +++ b/app/src/main/java/com/davidmiguel/gobees/video/processors/VideoProcessor.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees.video.processors; import org.opencv.core.Mat; diff --git a/app/src/main/res/drawable-anydpi/ic_edit.xml b/app/src/main/res/drawable-anydpi/ic_edit.xml new file mode 100644 index 00000000..43489826 --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_edit.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable-anydpi/ic_my_location.xml b/app/src/main/res/drawable-anydpi/ic_get_location.xml similarity index 100% rename from app/src/main/res/drawable-anydpi/ic_my_location.xml rename to app/src/main/res/drawable-anydpi/ic_get_location.xml diff --git a/app/src/main/res/drawable-anydpi/ic_location.xml b/app/src/main/res/drawable-anydpi/ic_location.xml new file mode 100644 index 00000000..3da94f6c --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_location.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable-anydpi/ic_map.xml b/app/src/main/res/drawable-anydpi/ic_map.xml new file mode 100644 index 00000000..7bdf181b --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_map.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable-anydpi/ic_notes.xml b/app/src/main/res/drawable-anydpi/ic_notes.xml new file mode 100644 index 00000000..f12fd414 --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_notes.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/addeditapiary_act.xml b/app/src/main/res/layout/addeditapiary_act.xml index d6d5feff..174ba498 100644 --- a/app/src/main/res/layout/addeditapiary_act.xml +++ b/app/src/main/res/layout/addeditapiary_act.xml @@ -1,5 +1,23 @@ + + + + @@ -46,7 +64,7 @@ android:layout_gravity="center" android:adjustViewBounds="false" android:contentDescription="@string/gps_location_icon" - android:src="@drawable/ic_my_location" + android:src="@drawable/ic_get_location" android:tint="@color/colorAccent"/> diff --git a/app/src/main/res/layout/addedithive_act.xml b/app/src/main/res/layout/addedithive_act.xml index a8af73db..84bae4ff 100644 --- a/app/src/main/res/layout/addedithive_act.xml +++ b/app/src/main/res/layout/addedithive_act.xml @@ -1,5 +1,23 @@ + + + + diff --git a/app/src/main/res/layout/apiaries_act.xml b/app/src/main/res/layout/apiaries_act.xml index e126795f..788e0c30 100644 --- a/app/src/main/res/layout/apiaries_act.xml +++ b/app/src/main/res/layout/apiaries_act.xml @@ -1,5 +1,23 @@ + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/hive_act.xml b/app/src/main/res/layout/hive_act.xml index fb52272a..3ed0fb26 100644 --- a/app/src/main/res/layout/hive_act.xml +++ b/app/src/main/res/layout/hive_act.xml @@ -1,5 +1,23 @@ + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/hive_recordings_frag.xml b/app/src/main/res/layout/hive_recordings_frag.xml index abe06ee5..e8af97a8 100644 --- a/app/src/main/res/layout/hive_recordings_frag.xml +++ b/app/src/main/res/layout/hive_recordings_frag.xml @@ -1,5 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . + --> + + @@ -6,12 +24,12 @@ - @string/pref_temp_units_label_metric - @string/pref_temp_units_label_imperial + @string/pref_weather_units_label_metric + @string/pref_weather_units_label_imperial - @string/pref_temp_units_metric - @string/pref_temp_units_imperial + @string/pref_weather_units_metric + @string/pref_weather_units_imperial diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index dcc319db..ecf932d4 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,4 +1,22 @@ + + #FFC107 diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 1eb32b1c..0efc7f62 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -1,3 +1,21 @@ + + 16dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9d7ce2f9..1bee2f61 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,4 +1,22 @@ + + @@ -11,20 +29,10 @@ GoBees logo Refresh - - Temperature - - Rain - - Wind Edit Delete - - %1.0f\u00B0C - - %1.0f\u00B0F Permission denied @@ -34,6 +42,138 @@ The app does not have permissions to use this feature. + + + + + + + Condition + + Temperature + + Humidity + + Pressure + + Wind + + Rain + + Snow + + \?\u00B0C + + \?% + + \? hPa + + \? km/h + + \? mm + + %1.0f\u00B0C + + %1.0f\u00B0F + + %1.0f%% + + %1.0f hPa + + + %1$1.0f km/h - + %2$s + + + + %1$1.0f mph - + %2$s + + + %1.2f mm + + Updated + + \? days ago + + OpenWeatherMap.org + + Thunderstorm with light rain + Thunderstorm with rain + Thunderstorm with heavy rain + Light thunderstorm + Thunderstorm + Heavy thunderstorm + Ragged thunderstorm + Thunderstorm with light drizzle + Thunderstorm with drizzle + Thunderstorm with heavy drizzle + Light intensity drizzle + Drizzle + Heavy drizzle + Light drizzle rain + Drizzle rain + Heavy drizzle rain + Shower rain and drizzle + Heavy shower rain and drizzle + Shower drizzle + Light rain + Moderate rain + Heavy rain + Very heavy rain + Extreme rain + Freezing rain + Light shower rain + Shower rain + Heavy shower rain + Ragged shower rain + Light snow + Snow + Heavy snow + Sleet + Shower sleet + Light rain and snow + Rain and snow + Light shower snow + Shower snow + Heavy shower snow + Mist + Smoke + Haze + Sand, dust whirls + Fog + Sand + Dust + Volcanic ash + Squalls + Tornado + Clear sky + Mostly clear + Scattered clouds + Broken clouds + Overcast clouds + Tornado + Tropical storm + Hurricane + Cold + Hot + Windy + Hail + Calm + Light breeze + Gentle breeze + Moderate breeze + Fresh breeze + Strong breeze + High wind + Gale + Severe gale + Storm + Violent storm + Hurricane + Unknown (%1$d) + + @@ -52,6 +192,12 @@ Settings icon Get GPS location + + Location + + Map + + Number of hives @@ -64,14 +210,10 @@ - - Number of hives My apiary 0 - - 10\u00B0C Error while loading apiaries. @@ -128,7 +270,7 @@ My hive - 10 days ago + \? days ago Error while loading hives. @@ -139,10 +281,24 @@ Hive deleted! Error while deleting hive. - + Last revision icon + + Notes Hive logo + + No hives + + + No hives + 1 hive + %d hives + + + No location + + Burgos @@ -192,6 +348,13 @@ Without this permission the app is unable to monitor the flight activity of your hive. Are you sure you want to deny this permission? + + Notes… + + No notes + + General info + @@ -345,17 +508,17 @@ Weather weather - - Temperature Units - - Metric (\u00B0C) - - Imperial (\u00B0F) - - units - - metric - - imperial + + Weather Units + + Metric (\u00B0C, km/h…) + + Imperial (\u00B0F, mph…) + + units + + metric + + imperial diff --git a/app/src/main/res/xml/general_settings.xml b/app/src/main/res/xml/general_settings.xml index 2a4ee9ef..d61df029 100644 --- a/app/src/main/res/xml/general_settings.xml +++ b/app/src/main/res/xml/general_settings.xml @@ -1,14 +1,32 @@ + + + android:key="@string/pref_weather_units_key" + android:title="@string/pref_weather_units_label"/> \ No newline at end of file diff --git a/app/src/main/res/xml/monitoring_settings.xml b/app/src/main/res/xml/monitoring_settings.xml index 285807d6..c1b074b3 100644 --- a/app/src/main/res/xml/monitoring_settings.xml +++ b/app/src/main/res/xml/monitoring_settings.xml @@ -1,4 +1,22 @@ + + diff --git a/app/src/mock/java/com/davidmiguel/gobees/Injection.java b/app/src/mock/java/com/davidmiguel/gobees/Injection.java index 70edd504..52c3c600 100644 --- a/app/src/mock/java/com/davidmiguel/gobees/Injection.java +++ b/app/src/mock/java/com/davidmiguel/gobees/Injection.java @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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.davidmiguel.gobees; import com.davidmiguel.gobees.data.source.cache.GoBeesRepository; diff --git a/app/src/test/java/com/davidmiguel/gobees/TestUtils.java b/app/src/test/java/com/davidmiguel/gobees/TestUtils.java index 52c941dd..cdf70e00 100644 --- a/app/src/test/java/com/davidmiguel/gobees/TestUtils.java +++ b/app/src/test/java/com/davidmiguel/gobees/TestUtils.java @@ -1,3 +1,20 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package com.davidmiguel.gobees; import org.opencv.core.Core; diff --git a/app/src/test/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryPresenterTest.java b/app/src/test/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryPresenterTest.java index 00c8f593..a0d0fec4 100644 --- a/app/src/test/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryPresenterTest.java +++ b/app/src/test/java/com/davidmiguel/gobees/addeditapiary/AddEditApiaryPresenterTest.java @@ -1,3 +1,20 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package com.davidmiguel.gobees.addeditapiary; import com.davidmiguel.gobees.data.model.Apiary; diff --git a/app/src/test/java/com/davidmiguel/gobees/addedithive/AddEditHivePresenterTest.java b/app/src/test/java/com/davidmiguel/gobees/addedithive/AddEditHivePresenterTest.java index 1c718ff7..e028cd8f 100644 --- a/app/src/test/java/com/davidmiguel/gobees/addedithive/AddEditHivePresenterTest.java +++ b/app/src/test/java/com/davidmiguel/gobees/addedithive/AddEditHivePresenterTest.java @@ -1,3 +1,20 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package com.davidmiguel.gobees.addedithive; import com.davidmiguel.gobees.data.model.Hive; diff --git a/app/src/test/java/com/davidmiguel/gobees/apiaries/ApiariesPresenterTest.java b/app/src/test/java/com/davidmiguel/gobees/apiaries/ApiariesPresenterTest.java index 93096faa..33312906 100644 --- a/app/src/test/java/com/davidmiguel/gobees/apiaries/ApiariesPresenterTest.java +++ b/app/src/test/java/com/davidmiguel/gobees/apiaries/ApiariesPresenterTest.java @@ -1,3 +1,20 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package com.davidmiguel.gobees.apiaries; import com.davidmiguel.gobees.data.model.Apiary; diff --git a/app/src/test/java/com/davidmiguel/gobees/apiary/ApiaryPresenterTest.java b/app/src/test/java/com/davidmiguel/gobees/apiary/ApiaryPresenterTest.java index 9dfd0627..cddb8882 100644 --- a/app/src/test/java/com/davidmiguel/gobees/apiary/ApiaryPresenterTest.java +++ b/app/src/test/java/com/davidmiguel/gobees/apiary/ApiaryPresenterTest.java @@ -1,3 +1,20 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package com.davidmiguel.gobees.apiary; import com.davidmiguel.gobees.data.model.Apiary; @@ -34,7 +51,10 @@ public class ApiaryPresenterTest { private GoBeesRepository goBeesRepository; @Mock - private ApiaryContract.View hivesView; + private ApiaryContract.ApiaryHivesView apiaryHivesView; + + @Mock + private ApiaryContract.ApiaryInfoView apiaryInfoView; private ApiaryPresenter apiaryPresenter; @@ -50,10 +70,11 @@ public void setupHivesPresenter() { MockitoAnnotations.initMocks(this); // Get a reference to the class under test - apiaryPresenter = new ApiaryPresenter(goBeesRepository, hivesView, APIARY_ID); + apiaryPresenter = new ApiaryPresenter(goBeesRepository, + apiaryHivesView, apiaryInfoView, APIARY_ID); // The presenter won't update the view unless it's active - when(hivesView.isActive()).thenReturn(true); + when(apiaryHivesView.isActive()).thenReturn(true); // Create 3 hives APIARY = ApiaryMother.newDefaultApiary(NUM_BEES); @@ -64,19 +85,19 @@ public void setupHivesPresenter() { public void loadHives_showHivesIntoView() { // Given an initialized ApiaryPresenter // When loading of hives of apiary 1 is requested - apiaryPresenter.loadHives(true); + apiaryPresenter.loadData(true); // Callback is captured and invoked with stubbed hives verify(goBeesRepository).getApiary(anyLong(), getApiaryCallbackArgumentCaptor.capture()); getApiaryCallbackArgumentCaptor.getValue().onApiaryLoaded(APIARY); // Then progress indicator is shown - InOrder inOrder = inOrder(hivesView); - inOrder.verify(hivesView).setLoadingIndicator(true); + InOrder inOrder = inOrder(apiaryHivesView); + inOrder.verify(apiaryHivesView).setLoadingIndicator(true); // Then progress indicator is hidden and all hives are shown in UI - inOrder.verify(hivesView).setLoadingIndicator(false); + inOrder.verify(apiaryHivesView).setLoadingIndicator(false); ArgumentCaptor showHivesArgumentCaptor = ArgumentCaptor.forClass(List.class); - verify(hivesView).showHives(showHivesArgumentCaptor.capture()); + verify(apiaryHivesView).showHives(showHivesArgumentCaptor.capture()); // Assert that the number of hives shown is the expected assertTrue(showHivesArgumentCaptor.getValue().size() == APIARY.getHives().size()); } diff --git a/app/src/test/java/com/davidmiguel/gobees/data/source/cache/GoBeesRepositoryTest.java b/app/src/test/java/com/davidmiguel/gobees/data/source/cache/GoBeesRepositoryTest.java index 9623838b..05e92c70 100644 --- a/app/src/test/java/com/davidmiguel/gobees/data/source/cache/GoBeesRepositoryTest.java +++ b/app/src/test/java/com/davidmiguel/gobees/data/source/cache/GoBeesRepositoryTest.java @@ -1,3 +1,20 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package com.davidmiguel.gobees.data.source.cache; import com.davidmiguel.gobees.data.model.Apiary; diff --git a/app/src/test/java/com/davidmiguel/gobees/data/source/network/OpenWeatherMapUtilsTest.java b/app/src/test/java/com/davidmiguel/gobees/data/source/network/OpenWeatherMapUtilsTest.java index c5d82c39..c28a9a27 100644 --- a/app/src/test/java/com/davidmiguel/gobees/data/source/network/OpenWeatherMapUtilsTest.java +++ b/app/src/test/java/com/davidmiguel/gobees/data/source/network/OpenWeatherMapUtilsTest.java @@ -1,3 +1,20 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package com.davidmiguel.gobees.data.source.network; import com.davidmiguel.gobees.data.model.MeteoRecord; diff --git a/app/src/test/java/com/davidmiguel/gobees/hive/HivePresenterTest.java b/app/src/test/java/com/davidmiguel/gobees/hive/HivePresenterTest.java index 58d14f57..bf898b7e 100644 --- a/app/src/test/java/com/davidmiguel/gobees/hive/HivePresenterTest.java +++ b/app/src/test/java/com/davidmiguel/gobees/hive/HivePresenterTest.java @@ -1,3 +1,20 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package com.davidmiguel.gobees.hive; import com.davidmiguel.gobees.data.model.Hive; @@ -34,7 +51,10 @@ public class HivePresenterTest { private GoBeesRepository goBeesRepository; @Mock - private HiveContract.View hiveView; + private HiveContract.HiveRecordingsView hiveRecordingsView; + + @Mock + private HiveContract.HiveInfoView hiveInfoView; private HivePresenter hivePresenter; @@ -54,10 +74,11 @@ public void setupHivesPresenter() { RecordingMother.newDefaultRecording())); // Get a reference to the class under test - hivePresenter = new HivePresenter(goBeesRepository, hiveView, 0,HIVE.getId()); + hivePresenter = new HivePresenter(goBeesRepository, + hiveRecordingsView, hiveInfoView, 0, HIVE.getId()); // The presenter won't update the view unless it's active - when(hiveView.isActive()).thenReturn(true); + when(hiveRecordingsView.isActive()).thenReturn(true); } @SuppressWarnings("unchecked") @@ -65,19 +86,20 @@ public void setupHivesPresenter() { public void loadRecordings_showRecordingsIntoView() { // Given an initialized HivePresenter // When loading of recordings is requested - hivePresenter.loadRecordings(true); + hivePresenter.loadData(true); // Callback is captured and invoked with stubbed hives verify(goBeesRepository).getHiveWithRecordings(anyLong(), getHiveCallbackArgumentCaptor.capture()); getHiveCallbackArgumentCaptor.getValue().onHiveLoaded(HIVE); // Then progress indicator is shown - InOrder inOrder = inOrder(hiveView); - inOrder.verify(hiveView).setLoadingIndicator(true); + InOrder inOrder = inOrder(hiveRecordingsView); + inOrder.verify(hiveRecordingsView).setLoadingIndicator(true); // Then progress indicator is hidden and all hives are shown in UI - inOrder.verify(hiveView).setLoadingIndicator(false); + inOrder.verify(hiveRecordingsView).isActive(); + inOrder.verify(hiveRecordingsView).setLoadingIndicator(false); ArgumentCaptor showRecordingsArgumentCaptor = ArgumentCaptor.forClass(List.class); - verify(hiveView).showRecordings(showRecordingsArgumentCaptor.capture()); + verify(hiveRecordingsView).showRecordings(showRecordingsArgumentCaptor.capture()); // Assert that the number of hives shown is the expected assertTrue(showRecordingsArgumentCaptor.getValue().size() == HIVE.getRecordings().size()); } diff --git a/app/src/test/java/com/davidmiguel/gobees/recording/RecordingPresenterTest.java b/app/src/test/java/com/davidmiguel/gobees/recording/RecordingPresenterTest.java index 8ce4d753..e7ba307d 100644 --- a/app/src/test/java/com/davidmiguel/gobees/recording/RecordingPresenterTest.java +++ b/app/src/test/java/com/davidmiguel/gobees/recording/RecordingPresenterTest.java @@ -1,3 +1,20 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package com.davidmiguel.gobees.recording; import com.davidmiguel.gobees.data.model.Recording; diff --git a/app/src/test/java/com/davidmiguel/gobees/utils/DateTimeUtilsTest.java b/app/src/test/java/com/davidmiguel/gobees/utils/DateTimeUtilsTest.java index 0b9efc41..20d837a7 100644 --- a/app/src/test/java/com/davidmiguel/gobees/utils/DateTimeUtilsTest.java +++ b/app/src/test/java/com/davidmiguel/gobees/utils/DateTimeUtilsTest.java @@ -1,3 +1,20 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package com.davidmiguel.gobees.utils; import org.junit.Before; diff --git a/app/src/test/java/com/davidmiguel/gobees/utils/HourAxisValueFormatterTest.java b/app/src/test/java/com/davidmiguel/gobees/utils/HourAxisValueFormatterTest.java index 09644974..acda56c7 100644 --- a/app/src/test/java/com/davidmiguel/gobees/utils/HourAxisValueFormatterTest.java +++ b/app/src/test/java/com/davidmiguel/gobees/utils/HourAxisValueFormatterTest.java @@ -1,3 +1,20 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package com.davidmiguel.gobees.utils; import org.junit.Test; diff --git a/app/src/test/java/com/davidmiguel/gobees/utils/StringUtilsTest.java b/app/src/test/java/com/davidmiguel/gobees/utils/StringUtilsTest.java index 0bd600e8..893b4cb9 100644 --- a/app/src/test/java/com/davidmiguel/gobees/utils/StringUtilsTest.java +++ b/app/src/test/java/com/davidmiguel/gobees/utils/StringUtilsTest.java @@ -1,3 +1,20 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package com.davidmiguel.gobees.utils; import org.junit.Test; diff --git a/app/src/test/java/com/davidmiguel/gobees/video/ContourBeesCounterTest.java b/app/src/test/java/com/davidmiguel/gobees/video/ContourBeesCounterTest.java index 8013a199..09ffbab3 100644 --- a/app/src/test/java/com/davidmiguel/gobees/video/ContourBeesCounterTest.java +++ b/app/src/test/java/com/davidmiguel/gobees/video/ContourBeesCounterTest.java @@ -1,3 +1,20 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package com.davidmiguel.gobees.video; import android.annotation.SuppressLint; diff --git a/app/src/test/java/com/davidmiguel/gobees/video/OpenCvBaseTest.java b/app/src/test/java/com/davidmiguel/gobees/video/OpenCvBaseTest.java index da9aedaa..0c89ad73 100644 --- a/app/src/test/java/com/davidmiguel/gobees/video/OpenCvBaseTest.java +++ b/app/src/test/java/com/davidmiguel/gobees/video/OpenCvBaseTest.java @@ -1,3 +1,20 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package com.davidmiguel.gobees.video; import org.opencv.core.Core; diff --git a/app/src/test/java/com/davidmiguel/gobees/video/processors/ProcessorsTest.java b/app/src/test/java/com/davidmiguel/gobees/video/processors/ProcessorsTest.java index b771565f..75d3f0bf 100644 --- a/app/src/test/java/com/davidmiguel/gobees/video/processors/ProcessorsTest.java +++ b/app/src/test/java/com/davidmiguel/gobees/video/processors/ProcessorsTest.java @@ -1,3 +1,20 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package com.davidmiguel.gobees.video.processors; import com.davidmiguel.gobees.video.OpenCvBaseTest; diff --git a/build.gradle b/build.gradle index b87f9163..2d36dda4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,21 @@ +/* + * GoBees + * Copyright (c) 2016 - 2017 David Miguel Lozano + * + * 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 + * 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. buildscript { diff --git a/docs/img/licenses_compatibility.docx b/docs/img/licenses_compatibility.docx new file mode 100644 index 00000000..0d9cd99a Binary files /dev/null and b/docs/img/licenses_compatibility.docx differ diff --git a/docs/img/licenses_compatibility.png b/docs/img/licenses_compatibility.png new file mode 100644 index 00000000..15a9ba57 Binary files /dev/null and b/docs/img/licenses_compatibility.png differ diff --git a/docs/latex/bibliografia.bib b/docs/latex/bibliografia.bib index e85aa629..22faaac3 100644 --- a/docs/latex/bibliografia.bib +++ b/docs/latex/bibliografia.bib @@ -333,4 +333,4 @@ @misc{ opencv:contours year = "2016", url = {http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_imgproc/py_contours/py_table_of_contents_contours/py_table_of_contents_contours.html}, note = "[Online; Accedido 19-Octubre-2016]" -} \ No newline at end of file +} diff --git a/docs/latex/bibliografiaAnexos.bib b/docs/latex/bibliografiaAnexos.bib index e69de29b..7a1ec71f 100644 --- a/docs/latex/bibliografiaAnexos.bib +++ b/docs/latex/bibliografiaAnexos.bib @@ -0,0 +1,31 @@ +@misc{ wiki:licencia, + author = "Wikipedia", + title = "Licencia --- Wikipedia{,} The Free Encyclopedia", + year = "2016", + url = {https://es.wikipedia.org/w/index.php?title=Licencia&oldid=94243114}, + note = "[Online; Accedido 07-Enero-2017]" +} + +@misc{ license:gplv3, + author = "Free Software Foundation", + title = "GNU General Public License v3.0", + year = "2007", + url = {https://www.gnu.org/licenses/gpl-3.0.txt}, + note = "[Online; Accedido 07-Enero-2017]" +} + +@misc{ license:epl, + author = "Eclipse Foundation", + title = "Eclipse Public License (EPL)", + year = "2004", + url = {https://www.eclipse.org/legal/epl-v10.html}, + note = "[Online; Accedido 07-Enero-2017]" +} + +@misc{ license:ccby4, + author = "Creative Commons", + title = "Attribution 4.0 International (CC BY 4.0)", + year = "2016", + url = {https://creativecommons.org/licenses/by/4.0/}, + note = "[Online; Accedido 07-Enero-2017]" +} \ No newline at end of file diff --git a/docs/rst/anexos/A_PlanProyecto.rst b/docs/rst/anexos/A_PlanProyecto.rst index f51718d9..6edf9a4b 100644 --- a/docs/rst/anexos/A_PlanProyecto.rst +++ b/docs/rst/anexos/A_PlanProyecto.rst @@ -361,7 +361,226 @@ Estudio de viabilidad --------------------- Viabilidad económica --------------------- +~~~~~~~~~~~~~~~~~~~~ + +TODO Viabilidad legal ----------------- +~~~~~~~~~~~~~~~~ + +En esta sección se discutirán los temas relacionados con las licencias. +Tanto del propio *software*, como de su documentación, imágenes y +vídeos. + +"En Derecho, una licencia es un contrato mediante el cual una persona +recibe de otra el derecho de uso, de copia, de distribución, de estudio +y de modificación (en el caso del *Software* Libre) de varios de sus +bienes, normalmente de carácter no tangible o intelectual, pudiendo +darse a cambio del pago de un monto determinado por el uso de los +mismos." [wiki:licencia]_ + +Software +^^^^^^^^ + +En primer lugar, vamos a analizar cuál sería la licencia más conveniente +para nuestro proyecto. Por un lado, somos nosotros los que podemos +elegir qué derechos queremos proporcionar a los usuarios y cuáles no. +Sin embargo, estamos limitados por los derechos que nos conceden a +nosotros las licencias de las dependencias utilizadas en el proyecto. + +A continuación, se muestran las licencias de las dependencias usadas. + ++----------------+---------+----------------------------------------------+----------+ +| Dependencia | Versión | Descripción | Licencia | ++================+=========+==============================================+==========+ +| Android | 25.1.0 | Biblioteca de compatibilidad de Android. | Apache | +| Support | | | v2.0 | +| Library | | | | ++----------------+---------+----------------------------------------------+----------+ +| OpenCV | 3.1.0 | Biblioteca de visión artificial. | BSD | ++----------------+---------+----------------------------------------------+----------+ +| Google Play | 10.0.1 | Biblioteca que proporciona acceso a | Apache | +| Services | | diferentes servicios, entre ellos, | v2.0 | +| | | localización. | | ++----------------+---------+----------------------------------------------+----------+ +| Guava | 20.0 | Conjunto de bibliotecas comunes para Java. | Apache | +| | | | v2.0 | ++----------------+---------+----------------------------------------------+----------+ +| RoundedImageVi | 2.3.0 | Componente para mostrar imágenes redondeadas | Apache | +| ew | | en Android. | v2.0 | ++----------------+---------+----------------------------------------------+----------+ +| MPAndroidChart | 3.0.1 | Biblioteca de gráficos para Android. | Apache | +| | | | v2.0 | ++----------------+---------+----------------------------------------------+----------+ +| VNTNumberPicker| 1.0.0 | Componente para seleccionar valores | Apache | +| Preference | | numéricos. | v2.0 | ++----------------+---------+----------------------------------------------+----------+ +| Permission | 1.0.6 | Biblioteca que facilita la gestión de | MIT | +| Utils | | permisos en tiempo de ejecución. | | ++----------------+---------+----------------------------------------------+----------+ +| JUnit | 4.12 | Framework para *testing* unitario en Java. | EPL | ++----------------+---------+----------------------------------------------+----------+ +| Mockito | 2.0.2 | Framework para *mocking* en Java. | MIT | ++----------------+---------+----------------------------------------------+----------+ +| SLF4J | 1.7.21 | API para *logging* en Java. | MIT | +| | | | | ++----------------+---------+----------------------------------------------+----------+ +| Apache Log4j | 1.7.21 | Biblioteca para *logging* en Java. | Apache | +| | | | v2.0 | ++----------------+---------+----------------------------------------------+----------+ +| Android JSON | 20160810| Biblioteca para trabajar con JSON. | Apache | +| | | | v2.0 | ++----------------+---------+----------------------------------------------+----------+ +| Espresso | 2.2.2 | Framework de *testing* para Android. | Apache | +| | | | v2.0 | ++----------------+---------+----------------------------------------------+----------+ + +Por lo tanto, tenemos que escoger una licencia para nuestro proyecto que +sea compatible con Apache v2.0, BSD, MIT y EPL. En el siguiente gráfico +mostramos la compatibilidad entre estas licencias, así como su grado de +permisividad. + +.. figure:: https://cloud.githubusercontent.com/assets/6546265/21730744/6bc30c16-d451-11e6-9c6a-dfae7ba3348d.png + :alt: licenses\_compatibility + +Podemos observar que la licencia más restrictiva (en el sentido de +obligaciones a cumplir) es la *Eclipse Public License* que posee la +librería JUnit. + +La forma de monetización del proyecto se realizará mediante +suscripciones a una plataforma *cloud* que permitirá la sincronización +entre varios dispositivos, entre otras funcionalidades. Por lo tanto, la +liberación del código del proyecto no pone en peligro su monetización, +sino todo lo contrario, abre la puerta a que la comunidad *Open Source* +aporte valor adicional a nuestro proyecto. El permitir la distribución +de la app libremente y de forma gratuita también nos es beneficioso, ya +que aumenta las posibilidades de recibir nuevas suscripciones de +usuarios. Y por último, no nos importaría que otras empresas se basaran +en nuestro código fuente para desarrollar sus productos, siempre los +liberaran bajo una licencia de código abierto para que nosotros también +pudiéramos aprovechar las mejoras que hubieran realizado. + +Teniendo en cuenta todo lo anterior, la licencia que más se ajusta a +nuestras pretensiones es la *GNU General Public License v3.0*, que, de +forma resumida, establece lo siguiente: [license:gplv3]_ + ++--------------------+------------------------------------------+----------------------------------+ +| Derechos | Condiciones | Limitaciones | ++====================+==========================================+==================================+ +| Uso comercial. | Liberar código fuente. | Limitación de responsabilidad. | ++--------------------+------------------------------------------+----------------------------------+ +| Distribución. | Nota sobre la licencia y copyright. | Sin garantías. | ++--------------------+------------------------------------------+----------------------------------+ +| Modificación. | Modificaciones bajo la misma licencia. | | ++--------------------+------------------------------------------+----------------------------------+ +| Uso de patentes. | Indicar modificaciones realizadas. | | ++--------------------+------------------------------------------+----------------------------------+ +| Uso privado. | | | ++--------------------+------------------------------------------+----------------------------------+ + +Sin embargo, GPL v3.0 no es compatible con la licencia EPL que posee +JUnit. Ya que, la EPL requiere que "cualquier distribución del trabajo +conceda a todos los destinatarios una licencia para las patentes que +pudieran tener que cubrir las modificaciones que han hecho" [license:epl]_. Esto supone +que los destinatarios pueden añadir una restricción adicional, hecho que +prohíbe rotundamente GPL: "[que el distribuidor] no imponga ninguna +restricción más sobre el ejercicio de los derechos concedidos a los +beneficiarios" [license:gplv3]_. + +Tras analizar otras licencias alternativas, no se ha encontrado ninguna +compatible con EPL y, a la vez, con nuestras pretensiones. Por lo que +finalmente se ha tomado la decisión de utilizar dos licencias para el +código fuente del proyecto. Por un lado, todo el código fuente de la +aplicación se ha licenciado bajo GPL v3.0. Mientras que el código fuente +de testeo, que hace uso de código licenciado bajo EPL (JUnit), se ha +liberado bajo licencia Apache v2.0, la cual sí que es compatible con +EPL. + +Documentación +^^^^^^^^^^^^^ + +Aunque se puede utilizar también la licencia GPL v3.0 para licenciar la +documentación, no es lo más recomendable. Ya que contiene numerosas +cláusulas que solo tienen sentido cuando se habla de código fuente. Por +ejemplo, si alguien quisiese distribuir una copia de la documentación de +forma impresa, estaría obligado a proporcionar también una copia del +código fuente. + +Por lo que se ha decido utilizar una licencia *Creative Commons*, las +cuales están más enfocadas a licenciar este tipo de material. En +concreto, se ha elegido la *Creative Commons Attribution 4.0 +International* (CC-BY-4.0). Que establece lo siguiente: [license:ccby4]_ + ++--------------+---------------------------+-------------------------------------+ +| Derechos | Condiciones | Limitaciones | ++==============+===========================+=====================================+ +| Uso | Nota sobre la licencia y | Limitación de responsabilidad. | +| comercial. | copyright. | | ++--------------+---------------------------+-------------------------------------+ +| Distribución.| Indicar modificaciones | Sin garantías. | +| | realizadas. | | ++--------------+---------------------------+-------------------------------------+ +| Modificación.| | No proporciona derechos sobre | +| | | marcas registradas. | ++--------------+---------------------------+-------------------------------------+ +| Uso privado. | | No proporciona derechos sobre | +| | | patentes. | ++--------------+---------------------------+-------------------------------------+ + +Imágenes y vídeos +^^^^^^^^^^^^^^^^^ + +En la documentación no se ha utilizado ninguna imagen de terceros, todas +las imágenes son propias del proyecto y cuentan con la misma licencia +que la documentación (CC-BY-4.0). + +El *dataset* de vídeos de prueba también se encuentra bajo la misma +licencia. + +Por otro lado, en la aplicación se han utilizado dos fuentes de +imágenes de terceros: + ++-------------------------+-----------------------------------------+---------------+ +| Fuente | Descripción | Licencia | ++=========================+=========================================+===============+ +| Material design icons | Conjunto de iconos oficial de Google. | Apache v2.0 | ++-------------------------+-----------------------------------------+---------------+ +| Simple Weather Icons | Conjunto de iconos meteorológicos. | Apache v2.0 | ++-------------------------+-----------------------------------------+---------------+ + +Aunque ambos autores renuncian a la obligación de especificar +explícitamente su autoría, se les ha mencionado en la sección "Licencias +de software libre" de la aplicación. + +El resto de imágenes y gráficos utilizados son de autoría propia y se +distribuyen también bajo CC-BY-4.0.3. + +Resumen +^^^^^^^ + +En la siguiente tabla se resumen las licencias que posee el proyecto. + ++-----------------------+---------------+ +| Recurso | Licencia | ++=======================+===============+ +| Código fuente app | GPLv3 | ++-----------------------+---------------+ +| Código fuente tests | Apache v2.0 | ++-----------------------+---------------+ +| Documentación | CC-BY-4.0 | ++-----------------------+---------------+ +| Imágenes | CC-BY-4.0 | ++-----------------------+---------------+ +| Vídeos | CC-BY-4.0 | ++-----------------------+---------------+ + +.. References + +.. [wiki:licencia] + https://es.wikipedia.org/w/index.php?title=Licencia&oldid=94243114 +.. [license:gplv3] + https://www.gnu.org/licenses/gpl-3.0.txt +.. [license:epl] + https://www.eclipse.org/legal/epl-v10.html +.. [license:ccby4] + https://creativecommons.org/licenses/by/4.0 diff --git a/docs/rst/conf.py b/docs/rst/conf.py index bae38cfa..6caa87b4 100644 --- a/docs/rst/conf.py +++ b/docs/rst/conf.py @@ -45,7 +45,7 @@ # General information about the project. project = u'GoBees' -copyright = u'2016, David Miguel Lozano' +copyright = u'2016, David Miguel Lozano (CC BY 4.0)' author = u'David Miguel Lozano' # The version info for the project you're documenting, acts as replacement for