diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..22d862d5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,187 @@
+
+# Created by https://www.gitignore.io/api/android,androidstudio
+# Edit at https://www.gitignore.io/?templates=android,androidstudio
+
+### Android ###
+# Built application files
+*.apk
+*.ap_
+*.aab
+
+# Files for the ART/Dalvik VM
+*.dex
+
+# Java class files
+*.class
+
+# Generated files
+bin/
+gen/
+out/
+
+# Gradle files
+.gradle/
+build/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Log Files
+*.log
+
+# Android Studio Navigation editor temp files
+.navigation/
+
+# Android Studio captures folder
+captures/
+
+# IntelliJ
+*.iml
+.idea/*
+.idea/workspace.xml
+.idea/tasks.xml
+.idea/gradle.xml
+.idea/assetWizardSettings.xml
+.idea/dictionaries
+.idea/libraries
+.idea/caches
+
+# Keystore files
+# Uncomment the following lines if you do not want to check your keystore files in.
+#*.jks
+#*.keystore
+
+# External native build folder generated in Android Studio 2.2 and later
+.externalNativeBuild
+
+# Google Services (e.g. APIs or Firebase)
+google-services.json
+
+# Freeline
+freeline.py
+freeline/
+freeline_project_description.json
+
+# fastlane
+fastlane/report.xml
+fastlane/Preview.html
+fastlane/screenshots
+fastlane/test_output
+fastlane/readme.md
+
+### Android Patch ###
+gen-external-apklibs
+
+### AndroidStudio ###
+# Covers files to be ignored for android development using Android Studio.
+
+# Built application files
+
+# Files for the ART/Dalvik VM
+
+# Java class files
+
+# Generated files
+
+# Gradle files
+.gradle
+
+# Signing files
+.signing/
+
+# Local configuration file (sdk path, etc)
+
+# Proguard folder generated by Eclipse
+
+# Log Files
+
+# Android Studio
+/*/build/
+/*/local.properties
+/*/out
+/*/*/build
+/*/*/production
+*.ipr
+*~
+*.swp
+
+# Android Patch
+
+# External native build folder generated in Android Studio 2.2 and later
+
+# NDK
+obj/
+
+# IntelliJ IDEA
+*.iws
+/out/
+
+# User-specific configurations
+.idea/caches/
+.idea/libraries/
+.idea/shelf/
+.idea/.name
+.idea/compiler.xml
+.idea/copyright/profiles_settings.xml
+.idea/encodings.xml
+.idea/misc.xml
+.idea/modules.xml
+.idea/scopes/scope_settings.xml
+.idea/vcs.xml
+.idea/jsLibraryMappings.xml
+.idea/datasources.xml
+.idea/dataSources.ids
+.idea/sqlDataSources.xml
+.idea/dynamic.xml
+.idea/uiDesigner.xml
+
+# OS-specific files
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+ehthumbs.db
+Thumbs.db
+
+# Legacy Eclipse project files
+.classpath
+.project
+.cproject
+.settings/
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.war
+*.ear
+
+# virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml)
+hs_err_pid*
+
+## Plugin-specific files:
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Mongo Explorer plugin
+.idea/mongoSettings.xml
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
+### AndroidStudio Patch ###
+
+!/gradle/wrapper/gradle-wrapper.jar
+
+# End of https://www.gitignore.io/api/android,androidstudio
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 00000000..1549dbe8
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,2 @@
+# Changelog
+[Check out the release notes](https://gitlab.com/mmarif4u/gitnex/releases)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 00000000..34dd43ad
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,31 @@
+# Contributing to GitNex
+
+Please take a few minutes to read this document to make the process of contribution more easy and healthy for all involved.
+
+## Merge Requests
+Patches, enhancements, features are always welcome. The MR should focus on the scope of work and avoid many unnecessary commits. Please provide as much detail and context as possible to explain the work submitted.
+
+Please ask if you are not sure about the scope of work to be submitted to avoid waste of time spent on the work.
+
+**How to submit MR**
+Fork this repository. Pull the forked repository from your namespace to your local machine. Create new branch and work on the bug/feature/enhancement you would like to submit. Push it to your forked version. From there create Merge Request(MR) against **master** branch.
+
+**IMPORTANT:** By submitting MR, you agree to allow GitNex to license your work under the same license as that used by GitNex.
+
+## Issues and Reports
+*1st of please be polite and gentle while commenting or creating new issue to maintain a healthy environment.*
+
+Before creating an issue please take a moment and search the repository issues(open/closed) to avoid duplicate issues either it's a bug or feature.
+
+In case you want to submit a bug report, please provide as much details as possible to better debug the problem. The important part is how to reproduce the bug and steps to reproduce are appreciated.
+
+**Note:** Please contact the project directly via email(gitnex@swatian.com) if have to share sensitive and security related details.
+
+## Translation
+Help us translate GitNex to your native language.
+
+Take a look [here](https://gitlab.com/mmarif4u/gitnex/blob/master/app/src/main/res/values/strings.xml) for strings, please ignore the lines with `translatable="false"`. It is recommended to create a Merge Request with your changes.
+
+Check the structure of other languages for example [French](https://gitlab.com/mmarif4u/gitnex/blob/master/app/src/main/res/values-fr/strings.xml).
+
+**Note:** Crowdin support will be added soon.
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index 80150269..48136103 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,626 +1,674 @@
-GNU GENERAL PUBLIC LICENSE
-
-Version 3, 29 June 2007
-
-Copyright © 2007 Free Software Foundation, Inc.
-
-Everyone is permitted to copy and distribute verbatim copies of this license
-document, but changing it is not allowed.
-
-Preamble
-
-The GNU General Public License is a free, copyleft license for software and
-other kinds of works.
-
-The licenses for most software and other practical works are designed to take
-away your freedom to share and change the works. By contrast, the GNU General
-Public License is intended to guarantee your freedom to share and change all
-versions of a program--to make sure it remains free software for all its users.
-We, the Free Software Foundation, use the GNU General Public License for most
-of our software; it applies also to any other work released this way by its
-authors. You can apply it to your programs, too.
-
-When we speak of free software, we are referring to freedom, not price. Our
-General Public Licenses are designed to make sure that you have the freedom
-to distribute copies of free software (and charge for them if you wish), that
-you receive source code or can get it if you want it, that you can change
-the software or use pieces of it in new free programs, and that you know you
-can do these things.
-
-To protect your rights, we need to prevent others from denying you these rights
-or asking you to surrender the rights. Therefore, you have certain responsibilities
-if you distribute copies of the software, or if you modify it: responsibilities
-to respect the freedom of others.
-
-For example, if you distribute copies of such a program, whether gratis or
-for a fee, you must pass on to the recipients the same freedoms that you received.
-You must make sure that they, too, receive or can get the source code. And
-you must show them these terms so they know their rights.
-
-Developers that use the GNU GPL protect your rights with two steps: (1) assert
-copyright on the software, and (2) offer you this License giving you legal
-permission to copy, distribute and/or modify it.
-
-For the developers' and authors' protection, the GPL clearly explains that
-there is no warranty for this free software. For both users' and authors'
-sake, the GPL requires that modified versions be marked as changed, so that
-their problems will not be attributed erroneously to authors of previous versions.
-
-Some devices are designed to deny users access to install or run modified
-versions of the software inside them, although the manufacturer can do so.
-This is fundamentally incompatible with the aim of protecting users' freedom
-to change the software. The systematic pattern of such abuse occurs in the
-area of products for individuals to use, which is precisely where it is most
-unacceptable. Therefore, we have designed this version of the GPL to prohibit
-the practice for those products. If such problems arise substantially in other
-domains, we stand ready to extend this provision to those domains in future
-versions of the GPL, as needed to protect the freedom of users.
-
-Finally, every program is threatened constantly by software patents. States
-should not allow patents to restrict development and use of software on general-purpose
-computers, but in those that do, we wish to avoid the special danger that
-patents applied to a free program could make it effectively proprietary. To
-prevent this, the GPL assures that patents cannot be used to render the program
-non-free.
-
-The precise terms and conditions for copying, distribution and modification
-follow.
-
-TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
-"Copyright" also means copyright-like laws that apply to other kinds of works,
-such as semiconductor masks.
-
-"The Program" refers to any copyrightable work licensed under this License.
-Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals
-or organizations.
-
-To "modify" a work means to copy from or adapt all or part of the work in
-a fashion requiring copyright permission, other than the making of an exact
-copy. The resulting work is called a "modified version" of the earlier work
-or a work "based on" the earlier work.
-
-A "covered work" means either the unmodified Program or a work based on the
-Program.
-
-To "propagate" a work means to do anything with it that, without permission,
-would make you directly or secondarily liable for infringement under applicable
-copyright law, except executing it on a computer or modifying a private copy.
-Propagation includes copying, distribution (with or without modification),
-making available to the public, and in some countries other activities as
-well.
-
-To "convey" a work means any kind of propagation that enables other parties
-to make or receive copies. Mere interaction with a user through a computer
-network, with no transfer of a copy, is not conveying.
-
-An interactive user interface displays "Appropriate Legal Notices" to the
-extent that it includes a convenient and prominently visible feature that
-(1) displays an appropriate copyright notice, and (2) tells the user that
-there is no warranty for the work (except to the extent that warranties are
-provided), that licensees may convey the work under this License, and how
-to view a copy of this License. If the interface presents a list of user commands
-or options, such as a menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
-The "source code" for a work means the preferred form of the work for making
-modifications to it. "Object code" means any non-source form of a work.
-
-A "Standard Interface" means an interface that either is an official standard
-defined by a recognized standards body, or, in the case of interfaces specified
-for a particular programming language, one that is widely used among developers
-working in that language.
-
-The "System Libraries" of an executable work include anything, other than
-the work as a whole, that (a) is included in the normal form of packaging
-a Major Component, but which is not part of that Major Component, and (b)
-serves only to enable use of the work with that Major Component, or to implement
-a Standard Interface for which an implementation is available to the public
-in source code form. A "Major Component", in this context, means a major essential
-component (kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to produce
-the work, or an object code interpreter used to run it.
-
-The "Corresponding Source" for a work in object code form means all the source
-code needed to generate, install, and (for an executable work) run the object
-code and to modify the work, including scripts to control those activities.
-However, it does not include the work's System Libraries, or general-purpose
-tools or generally available free programs which are used unmodified in performing
-those activities but which are not part of the work. For example, Corresponding
-Source includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically linked
-subprograms that the work is specifically designed to require, such as by
-intimate data communication or control flow between those subprograms and
-other parts of the work.
-
-The Corresponding Source need not include anything that users can regenerate
-automatically from other parts of the Corresponding Source.
-
- The Corresponding Source for a work in source code form is that same work.
-
- 2. Basic Permissions.
-
-All rights granted under this License are granted for the term of copyright
-on the Program, and are irrevocable provided the stated conditions are met.
-This License explicitly affirms your unlimited permission to run the unmodified
-Program. The output from running a covered work is covered by this License
-only if the output, given its content, constitutes a covered work. This License
-acknowledges your rights of fair use or other equivalent, as provided by copyright
-law.
-
-You may make, run and propagate covered works that you do not convey, without
-conditions so long as your license otherwise remains in force. You may convey
-covered works to others for the sole purpose of having them make modifications
-exclusively for you, or provide you with facilities for running those works,
-provided that you comply with the terms of this License in conveying all material
-for which you do not control copyright. Those thus making or running the covered
-works for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of your copyrighted
-material outside their relationship with you.
-
-Conveying under any other circumstances is permitted solely under the conditions
-stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
-No covered work shall be deemed part of an effective technological measure
-under any applicable law fulfilling obligations under article 11 of the WIPO
-copyright treaty adopted on 20 December 1996, or similar laws prohibiting
-or restricting circumvention of such measures.
-
-When you convey a covered work, you waive any legal power to forbid circumvention
-of technological measures to the extent such circumvention is effected by
-exercising rights under this License with respect to the covered work, and
-you disclaim any intention to limit operation or modification of the work
-as a means of enforcing, against the work's users, your or third parties'
-legal rights to forbid circumvention of technological measures.
-
- 4. Conveying Verbatim Copies.
-
-You may convey verbatim copies of the Program's source code as you receive
-it, in any medium, provided that you conspicuously and appropriately publish
-on each copy an appropriate copyright notice; keep intact all notices stating
-that this License and any non-permissive terms added in accord with section
-7 apply to the code; keep intact all notices of the absence of any warranty;
-and give all recipients a copy of this License along with the Program.
-
-You may charge any price or no price for each copy that you convey, and you
-may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
-You may convey a work based on the Program, or the modifications to produce
-it from the Program, in the form of source code under the terms of section
-4, provided that you also meet all of these conditions:
-
-a) The work must carry prominent notices stating that you modified it, and
-giving a relevant date.
-
-b) The work must carry prominent notices stating that it is released under
-this License and any conditions added under section 7. This requirement modifies
-the requirement in section 4 to "keep intact all notices".
-
-c) You must license the entire work, as a whole, under this License to anyone
-who comes into possession of a copy. This License will therefore apply, along
-with any applicable section 7 additional terms, to the whole of the work,
-and all its parts, regardless of how they are packaged. This License gives
-no permission to license the work in any other way, but it does not invalidate
-such permission if you have separately received it.
-
-d) If the work has interactive user interfaces, each must display Appropriate
-Legal Notices; however, if the Program has interactive interfaces that do
-not display Appropriate Legal Notices, your work need not make them do so.
-
-A compilation of a covered work with other separate and independent works,
-which are not by their nature extensions of the covered work, and which are
-not combined with it such as to form a larger program, in or on a volume of
-a storage or distribution medium, is called an "aggregate" if the compilation
-and its resulting copyright are not used to limit the access or legal rights
-of the compilation's users beyond what the individual works permit. Inclusion
-of a covered work in an aggregate does not cause this License to apply to
-the other parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
-You may convey a covered work in object code form under the terms of sections
-4 and 5, provided that you also convey the machine-readable Corresponding
-Source under the terms of this License, in one of these ways:
-
-a) Convey the object code in, or embodied in, a physical product (including
-a physical distribution medium), accompanied by the Corresponding Source fixed
-on a durable physical medium customarily used for software interchange.
-
-b) Convey the object code in, or embodied in, a physical product (including
-a physical distribution medium), accompanied by a written offer, valid for
-at least three years and valid for as long as you offer spare parts or customer
-support for that product model, to give anyone who possesses the object code
-either (1) a copy of the Corresponding Source for all the software in the
-product that is covered by this License, on a durable physical medium customarily
-used for software interchange, for a price no more than your reasonable cost
-of physically performing this conveying of source, or (2) access to copy the
-Corresponding Source from a network server at no charge.
-
-c) Convey individual copies of the object code with a copy of the written
-offer to provide the Corresponding Source. This alternative is allowed only
-occasionally and noncommercially, and only if you received the object code
-with such an offer, in accord with subsection 6b.
-
-d) Convey the object code by offering access from a designated place (gratis
-or for a charge), and offer equivalent access to the Corresponding Source
-in the same way through the same place at no further charge. You need not
-require recipients to copy the Corresponding Source along with the object
-code. If the place to copy the object code is a network server, the Corresponding
-Source may be on a different server (operated by you or a third party) that
-supports equivalent copying facilities, provided you maintain clear directions
-next to the object code saying where to find the Corresponding Source. Regardless
-of what server hosts the Corresponding Source, you remain obligated to ensure
-that it is available for as long as needed to satisfy these requirements.
-
-e) Convey the object code using peer-to-peer transmission, provided you inform
-other peers where the object code and Corresponding Source of the work are
-being offered to the general public at no charge under subsection 6d.
-
-A separable portion of the object code, whose source code is excluded from
-the Corresponding Source as a System Library, need not be included in conveying
-the object code work.
-
-A "User Product" is either (1) a "consumer product", which means any tangible
-personal property which is normally used for personal, family, or household
-purposes, or (2) anything designed or sold for incorporation into a dwelling.
-In determining whether a product is a consumer product, doubtful cases shall
-be resolved in favor of coverage. For a particular product received by a particular
-user, "normally used" refers to a typical or common use of that class of product,
-regardless of the status of the particular user or of the way in which the
-particular user actually uses, or expects or is expected to use, the product.
-A product is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent the
-only significant mode of use of the product.
-
-"Installation Information" for a User Product means any methods, procedures,
-authorization keys, or other information required to install and execute modified
-versions of a covered work in that User Product from a modified version of
-its Corresponding Source. The information must suffice to ensure that the
-continued functioning of the modified object code is in no case prevented
-or interfered with solely because modification has been made.
-
-If you convey an object code work under this section in, or with, or specifically
-for use in, a User Product, and the conveying occurs as part of a transaction
-in which the right of possession and use of the User Product is transferred
-to the recipient in perpetuity or for a fixed term (regardless of how the
-transaction is characterized), the Corresponding Source conveyed under this
-section must be accompanied by the Installation Information. But this requirement
-does not apply if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has been installed
-in ROM).
-
-The requirement to provide Installation Information does not include a requirement
-to continue to provide support service, warranty, or updates for a work that
-has been modified or installed by the recipient, or for the User Product in
-which it has been modified or installed. Access to a network may be denied
-when the modification itself materially and adversely affects the operation
-of the network or violates the rules and protocols for communication across
-the network.
-
-Corresponding Source conveyed, and Installation Information provided, in accord
-with this section must be in a format that is publicly documented (and with
-an implementation available to the public in source code form), and must require
-no special password or key for unpacking, reading or copying.
-
- 7. Additional Terms.
-
-"Additional permissions" are terms that supplement the terms of this License
-by making exceptions from one or more of its conditions. Additional permissions
-that are applicable to the entire Program shall be treated as though they
-were included in this License, to the extent that they are valid under applicable
-law. If additional permissions apply only to part of the Program, that part
-may be used separately under those permissions, but the entire Program remains
-governed by this License without regard to the additional permissions.
-
-When you convey a copy of a covered work, you may at your option remove any
-additional permissions from that copy, or from any part of it. (Additional
-permissions may be written to require their own removal in certain cases when
-you modify the work.) You may place additional permissions on material, added
-by you to a covered work, for which you have or can give appropriate copyright
-permission.
-
-Notwithstanding any other provision of this License, for material you add
-to a covered work, you may (if authorized by the copyright holders of that
-material) supplement the terms of this License with terms:
-
-a) Disclaiming warranty or limiting liability differently from the terms of
-sections 15 and 16 of this License; or
-
-b) Requiring preservation of specified reasonable legal notices or author
-attributions in that material or in the Appropriate Legal Notices displayed
-by works containing it; or
-
-c) Prohibiting misrepresentation of the origin of that material, or requiring
-that modified versions of such material be marked in reasonable ways as different
-from the original version; or
-
-d) Limiting the use for publicity purposes of names of licensors or authors
-of the material; or
-
-e) Declining to grant rights under trademark law for use of some trade names,
-trademarks, or service marks; or
-
-f) Requiring indemnification of licensors and authors of that material by
-anyone who conveys the material (or modified versions of it) with contractual
-assumptions of liability to the recipient, for any liability that these contractual
-assumptions directly impose on those licensors and authors.
-
-All other non-permissive additional terms are considered "further restrictions"
-within the meaning of section 10. If the Program as you received it, or any
-part of it, contains a notice stating that it is governed by this License
-along with a term that is a further restriction, you may remove that term.
-If a license document contains a further restriction but permits relicensing
-or conveying under this License, you may add to a covered work material governed
-by the terms of that license document, provided that the further restriction
-does not survive such relicensing or conveying.
-
-If you add terms to a covered work in accord with this section, you must place,
-in the relevant source files, a statement of the additional terms that apply
-to those files, or a notice indicating where to find the applicable terms.
-
-Additional terms, permissive or non-permissive, may be stated in the form
-of a separately written license, or stated as exceptions; the above requirements
-apply either way.
-
- 8. Termination.
-
-You may not propagate or modify a covered work except as expressly provided
-under this License. Any attempt otherwise to propagate or modify it is void,
-and will automatically terminate your rights under this License (including
-any patent licenses granted under the third paragraph of section 11).
-
-However, if you cease all violation of this License, then your license from
-a particular copyright holder is reinstated (a) provisionally, unless and
-until the copyright holder explicitly and finally terminates your license,
-and (b) permanently, if the copyright holder fails to notify you of the violation
-by some reasonable means prior to 60 days after the cessation.
-
-Moreover, your license from a particular copyright holder is reinstated permanently
-if the copyright holder notifies you of the violation by some reasonable means,
-this is the first time you have received notice of violation of this License
-(for any work) from that copyright holder, and you cure the violation prior
-to 30 days after your receipt of the notice.
-
-Termination of your rights under this section does not terminate the licenses
-of parties who have received copies or rights from you under this License.
-If your rights have been terminated and not permanently reinstated, you do
-not qualify to receive new licenses for the same material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
-You are not required to accept this License in order to receive or run a copy
-of the Program. Ancillary propagation of a covered work occurring solely as
-a consequence of using peer-to-peer transmission to receive a copy likewise
-does not require acceptance. However, nothing other than this License grants
-you permission to propagate or modify any covered work. These actions infringe
-copyright if you do not accept this License. Therefore, by modifying or propagating
-a covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
-Each time you convey a covered work, the recipient automatically receives
-a license from the original licensors, to run, modify and propagate that work,
-subject to this License. You are not responsible for enforcing compliance
-by third parties with this License.
-
-An "entity transaction" is a transaction transferring control of an organization,
-or substantially all assets of one, or subdividing an organization, or merging
-organizations. If propagation of a covered work results from an entity transaction,
-each party to that transaction who receives a copy of the work also receives
-whatever licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the Corresponding
-Source of the work from the predecessor in interest, if the predecessor has
-it or can get it with reasonable efforts.
-
-You may not impose any further restrictions on the exercise of the rights
-granted or affirmed under this License. For example, you may not impose a
-license fee, royalty, or other charge for exercise of rights granted under
-this License, and you may not initiate litigation (including a cross-claim
-or counterclaim in a lawsuit) alleging that any patent claim is infringed
-by making, using, selling, offering for sale, or importing the Program or
-any portion of it.
-
- 11. Patents.
-
-A "contributor" is a copyright holder who authorizes use under this License
-of the Program or a work on which the Program is based. The work thus licensed
-is called the contributor's "contributor version".
-
-A contributor's "essential patent claims" are all patent claims owned or controlled
-by the contributor, whether already acquired or hereafter acquired, that would
-be infringed by some manner, permitted by this License, of making, using,
-or selling its contributor version, but do not include claims that would be
-infringed only as a consequence of further modification of the contributor
-version. For purposes of this definition, "control" includes the right to
-grant patent sublicenses in a manner consistent with the requirements of this
-License.
-
-Each contributor grants you a non-exclusive, worldwide, royalty-free patent
-license under the contributor's essential patent claims, to make, use, sell,
-offer for sale, import and otherwise run, modify and propagate the contents
-of its contributor version.
-
-In the following three paragraphs, a "patent license" is any express agreement
-or commitment, however denominated, not to enforce a patent (such as an express
-permission to practice a patent or covenant not to sue for patent infringement).
-To "grant" such a patent license to a party means to make such an agreement
-or commitment not to enforce a patent against the party.
-
-If you convey a covered work, knowingly relying on a patent license, and the
-Corresponding Source of the work is not available for anyone to copy, free
-of charge and under the terms of this License, through a publicly available
-network server or other readily accessible means, then you must either (1)
-cause the Corresponding Source to be so available, or (2) arrange to deprive
-yourself of the benefit of the patent license for this particular work, or
-(3) arrange, in a manner consistent with the requirements of this License,
-to extend the patent license to downstream recipients. "Knowingly relying"
-means you have actual knowledge that, but for the patent license, your conveying
-the covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that country
-that you have reason to believe are valid.
-
-If, pursuant to or in connection with a single transaction or arrangement,
-you convey, or propagate by procuring conveyance of, a covered work, and grant
-a patent license to some of the parties receiving the covered work authorizing
-them to use, propagate, modify or convey a specific copy of the covered work,
-then the patent license you grant is automatically extended to all recipients
-of the covered work and works based on it.
-
-A patent license is "discriminatory" if it does not include within the scope
-of its coverage, prohibits the exercise of, or is conditioned on the non-exercise
-of one or more of the rights that are specifically granted under this License.
-You may not convey a covered work if you are a party to an arrangement with
-a third party that is in the business of distributing software, under which
-you make payment to the third party based on the extent of your activity of
-conveying the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory patent
-license (a) in connection with copies of the covered work conveyed by you
-(or copies made from those copies), or (b) primarily for and in connection
-with specific products or compilations that contain the covered work, unless
-you entered into that arrangement, or that patent license was granted, prior
-to 28 March 2007.
-
-Nothing in this License shall be construed as excluding or limiting any implied
-license or other defenses to infringement that may otherwise be available
-to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
-If conditions are imposed on you (whether by court order, agreement or otherwise)
-that contradict the conditions of this License, they do not excuse you from
-the conditions of this License. If you cannot convey a covered work so as
-to satisfy simultaneously your obligations under this License and any other
-pertinent obligations, then as a consequence you may not convey it at all.
-For example, if you agree to terms that obligate you to collect a royalty
-for further conveying from those to whom you convey the Program, the only
-way you could satisfy both those terms and this License would be to refrain
-entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
-Notwithstanding any other provision of this License, you have permission to
-link or combine any covered work with a work licensed under version 3 of the
-GNU Affero General Public License into a single combined work, and to convey
-the resulting work. The terms of this License will continue to apply to the
-part which is the covered work, but the special requirements of the GNU Affero
-General Public License, section 13, concerning interaction through a network
-will apply to the combination as such.
-
- 14. Revised Versions of this License.
-
-The Free Software Foundation may publish revised and/or new versions of the
-GNU General Public License from time to time. Such new versions will be similar
-in spirit to the present version, but may differ in detail to address new
-problems or concerns.
-
-Each version is given a distinguishing version number. If the Program specifies
-that a certain numbered version of the GNU General Public License "or any
-later version" applies to it, you have the option of following the terms and
-conditions either of that numbered version or of any later version published
-by the Free Software Foundation. If the Program does not specify a version
-number of the GNU General Public License, you may choose any version ever
-published by the Free Software Foundation.
-
-If the Program specifies that a proxy can decide which future versions of
-the GNU General Public License can be used, that proxy's public statement
-of acceptance of a version permanently authorizes you to choose that version
-for the Program.
-
-Later license versions may give you additional or different permissions. However,
-no additional obligations are imposed on any author or copyright holder as
-a result of your choosing to follow a later version.
-
- 15. Disclaimer of Warranty.
-
-THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
-LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
-EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM
-PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
-CORRECTION.
-
- 16. Limitation of Liability.
-
-IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
-ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM
-AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
-INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO
-USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
-INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
-PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
-PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
-If the disclaimer of warranty and limitation of liability provided above cannot
-be given local legal effect according to their terms, reviewing courts shall
-apply local law that most closely approximates an absolute waiver of all civil
-liability in connection with the Program, unless a warranty or assumption
-of liability accompanies a copy of the Program in return for a fee. END OF
-TERMS AND CONDITIONS
-
-How to Apply These Terms to Your New Programs
-
-If you develop a new program, and you want it to be of the greatest possible
-use to the public, the best way to achieve this is to make it free software
-which everyone can redistribute and change under these terms.
-
-To do so, attach the following notices to the program. It is safest to attach
-them to the start of each source file to most effectively state the exclusion
-of warranty; and each file should have at least the "copyright" line and a
-pointer to where the full notice is found.
-
-
-
-Copyright (C)
-
-This program is free software: you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free Software
-Foundation, either version 3 of the License, or (at your option) any later
-version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along with
-this program. If not, see .
+ 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.
+
+ Mastalab is a Mastodon client for Android devices
+ Copyright (C) 2017 Thomas Schneider
+
+ 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:
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
- Copyright (C)
-
-This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-
-This is free software, and you are welcome to redistribute it under certain
-conditions; type `show c' for details.
+ Mastalab Copyright (C) 2017 Thomas Schneider
+ 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".
+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 .
+ 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 .
+ 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 f5bbb300..c765185b 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,71 @@
-# GitNex
+[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
-Android client for Gitea
\ No newline at end of file
+[](https://www.patreon.com/mmarif) [](https://liberapay.com/mmarif/donate)
+
+# GitNex - Android client for Gitea
+
+GitNex is a free, open-source Android client for Git repository management tool Gitea. Gitea is a community managed fork of Gogs, lightweight code hosting solution written in Go.
+
+GitNex is licensed under GPLv3 License. See the LICENSE file for the full license text.
+No trackers are used and source code is available here for anyone to audit.
+
+## Downloads
+[](https://f-droid.org/en/packages/org.mian.gitnex/) [](https://play.google.com/store/apps/details?id=org.mian.gitnex) [Download APK](https://gitlab.com/mmarif4u/gitnex/releases)
+
+## Note about Gitea version
+Please make sure that you are on Gitea **1.7.x** stable release or later. Below this may not work as one would expect because of the newly added objects to the API at later versions. Please consider updating your Gitea server.
+
+Check the versions [compatibility page](https://gitlab.com/mmarif4u/gitnex/wikis/Compatibility) which lists all the supported versions with compatibility ratio.
+
+## Build from source
+Option 1 - Download the source code, open it in Android Studio and build it there.
+
+Option 2 - Open terminal(Linux) and cd to the project dir. Run `./gradlew build`.
+
+## Features
+- My Repositories
+- Repositories list
+- Organizations list
+- Create repository
+- Create organization
+- Issues list
+- [MANY MORE](https://gitlab.com/mmarif4u/gitnex/wikis/Features)
+
+## Contributing
+[CONTRIBUTING](https://gitlab.com/mmarif4u/gitnex/blob/master/CONTRIBUTING.md)
+
+## Screenshots:
+[Screenshots](https://gitlab.com/mmarif4u/gitnex/wikis/Screenshots)
+
+## FAQ
+[Faq](https://gitlab.com/mmarif4u/gitnex/wikis/FAQ)
+
+## Links
+[Website](https://gitnex.com)
+
+[Wiki](https://gitlab.com/mmarif4u/gitnex/wikis/home)
+
+[Website Repository](https://gitlab.com/mmarif4u/gitnex-website)
+
+[Troubleshoot Guide](https://gitlab.com/mmarif4u/gitnex/wikis/Troubleshoot-Guide)
+
+[How to](https://gitlab.com/mmarif4u/gitnex/wikis/home#how-to)
+
+## Thanks
+Thanks to all the open source libraries, contributors and donators.
+
+Open source libraries
+- Retrofit
+- Gson
+- Okhttp
+- ViHtarb/tooltip
+- Picasso
+- Markwon
+- Prettytime
+- Amulyakhare/textdrawable
+- Vdurmont/emoji-java
+- Abumoallim/android-multi-select-dialog
+- Pes/materialcolorpicker
+- Hendraanggrian/socialview
+
+[Follow me on Fediverse - mastodon.social/@mmarif](https://mastodon.social/@mmarif)
diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 00000000..796b96d1
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 00000000..f22a26bd
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,67 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 28
+ defaultConfig {
+ applicationId "org.mian.gitnex"
+ minSdkVersion 21
+ targetSdkVersion 28
+ versionCode 45
+ versionName "1.5.0"
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+ lintOptions {
+ //checkReleaseBuilds false
+ abortOnError false
+ }
+}
+
+dependencies {
+ def lifecycle_version = "2.2.0-alpha01"
+ final def markwon_version = "3.0.0"
+
+ implementation fileTree(include: ['*.jar'], dir: 'libs')
+ implementation 'androidx.appcompat:appcompat:1.1.0-alpha05'
+ implementation 'com.google.android.material:material:1.1.0-alpha06'
+ implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+ implementation 'androidx.legacy:legacy-support-v4:1.0.0'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'androidx.test:runner:1.1.1'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
+ implementation 'com.github.vihtarb:tooltip:0.2.0'
+ implementation 'com.squareup.okhttp3:okhttp:3.12.1'
+ implementation 'com.google.code.gson:gson:2.8.5'
+ implementation 'com.squareup.picasso:picasso:2.71828'
+ implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
+ implementation 'com.squareup.retrofit2:retrofit:2.5.0'
+ implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
+ implementation 'com.squareup.retrofit2:converter-scalars:2.5.0'
+ implementation 'com.squareup.okhttp3:logging-interceptor:3.12.1'
+ implementation 'org.ocpsoft.prettytime:prettytime:4.0.1.Final'
+ implementation "com.vdurmont:emoji-java:4.0.0"
+ implementation "com.pes.materialcolorpicker:library:1.2.5"
+
+ implementation "ru.noties.markwon:core:$markwon_version"
+ implementation "ru.noties.markwon:ext-strikethrough:$markwon_version"
+ implementation "ru.noties.markwon:ext-tables:$markwon_version"
+ implementation "ru.noties.markwon:ext-tasklist:$markwon_version"
+ implementation "ru.noties.markwon:syntax-highlight:$markwon_version"
+ implementation "ru.noties.markwon:image-okhttp:$markwon_version"
+ implementation "ru.noties.markwon:html:$markwon_version"
+ implementation "ru.noties.markwon:recycler:$markwon_version"
+ implementation "ru.noties.markwon:recycler-table:$markwon_version"
+ implementation "ru.noties.markwon:image-gif:$markwon_version"
+ implementation "ru.noties.markwon:image-svg:$markwon_version"
+
+ implementation "com.hendraanggrian.appcompat:socialview:0.2"
+ implementation "com.hendraanggrian.appcompat:socialview-commons:0.2"
+
+ implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
+ implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
+}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 00000000..f1b42451
--- /dev/null
+++ b/app/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..ea556b0b
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/app_logo-web.png b/app/src/main/app_logo-web.png
new file mode 100644
index 00000000..68a598c8
Binary files /dev/null and b/app/src/main/app_logo-web.png differ
diff --git a/app/src/main/java/org/mian/gitnex/actions/CollaboratorActions.java b/app/src/main/java/org/mian/gitnex/actions/CollaboratorActions.java
new file mode 100644
index 00000000..c9e4f142
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/actions/CollaboratorActions.java
@@ -0,0 +1,161 @@
+package org.mian.gitnex.actions;
+
+import android.content.Context;
+import android.util.Log;
+import org.mian.gitnex.R;
+import org.mian.gitnex.activities.AddCollaboratorToRepositoryActivity;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.helpers.AlertDialogs;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.helpers.Toasty;
+import org.mian.gitnex.models.Collaborators;
+import org.mian.gitnex.models.Permission;
+import org.mian.gitnex.util.TinyDB;
+import androidx.annotation.NonNull;
+import retrofit2.Call;
+import retrofit2.Callback;
+
+/**
+ * Author M M Arif
+ */
+
+public class CollaboratorActions {
+
+ public static void deleteCollaborator(final Context context, final String searchKeyword, String userName) {
+
+ final TinyDB tinyDb = new TinyDB(context);
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+
+ Call call;
+
+ call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .deleteCollaborator(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, userName);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ if(response.isSuccessful()) {
+ if(response.code() == 204) {
+
+ Toasty.info(context, context.getString(R.string.removeCollaboratorToastText));
+ ((AddCollaboratorToRepositoryActivity)context).finish();
+ //Log.i("addCollaboratorSearch", addCollaboratorSearch.getText().toString());
+ //tinyDb.putBoolean("updateDataSet", true);
+ //AddCollaboratorToRepositoryActivity usersSearchData = new AddCollaboratorToRepositoryActivity();
+ //usersSearchData.loadUserSearchList(instanceUrl, instanceToken, searchKeyword, context);
+
+ }
+ }
+ else if(response.code() == 401) {
+
+ AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ context.getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ context.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ context.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else if(response.code() == 403) {
+
+ Toasty.info(context, context.getString(R.string.authorizeError));
+
+ }
+ else if(response.code() == 404) {
+
+ Toasty.info(context, context.getString(R.string.apiNotFound));
+
+ }
+ else {
+
+ Toasty.info(context, context.getString(R.string.genericError));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+ });
+
+ }
+
+ public static void addCollaborator(final Context context, String permission, String userName) {
+
+ final TinyDB tinyDb = new TinyDB(context);
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+
+ Permission permissionString = new Permission(permission);
+ Call call;
+
+ call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .addCollaborator(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, userName, permissionString);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ if(response.isSuccessful()) {
+ if(response.code() == 204) {
+
+ Toasty.info(context, context.getString(R.string.addCollaboratorToastText));
+ ((AddCollaboratorToRepositoryActivity)context).finish();
+ //AddCollaboratorToRepositoryActivity usersSearchData = new AddCollaboratorToRepositoryActivity();
+ //usersSearchData.loadUserSearchList(instanceUrl, instanceToken, searchKeyword, context);
+
+ }
+ }
+ else if(response.code() == 401) {
+
+ AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ context.getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ context.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ context.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else if(response.code() == 403) {
+
+ Toasty.info(context, context.getString(R.string.authorizeError));
+
+ }
+ else if(response.code() == 404) {
+
+ Toasty.info(context, context.getString(R.string.apiNotFound));
+
+ }
+ else {
+
+ Toasty.info(context, context.getString(R.string.genericError));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+ });
+
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/actions/IssueActions.java b/app/src/main/java/org/mian/gitnex/actions/IssueActions.java
new file mode 100644
index 00000000..35170172
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/actions/IssueActions.java
@@ -0,0 +1,164 @@
+package org.mian.gitnex.actions;
+
+import android.content.Context;
+import android.util.Log;
+import com.google.gson.JsonElement;
+import org.mian.gitnex.R;
+import org.mian.gitnex.activities.ReplyToIssueActivity;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.helpers.AlertDialogs;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.helpers.Toasty;
+import org.mian.gitnex.models.UpdateIssueState;
+import org.mian.gitnex.models.IssueComments;
+import org.mian.gitnex.util.TinyDB;
+import androidx.annotation.NonNull;
+import retrofit2.Call;
+import retrofit2.Callback;
+
+/**
+ * Author M M Arif
+ */
+
+public class IssueActions {
+
+ public static void editIssueComment(final Context context, final int commentId, final String commentBody) {
+
+ final TinyDB tinyDb = new TinyDB(context);
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+
+ IssueComments commentBodyJson = new IssueComments(commentBody);
+ Call call;
+
+ call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .patchIssueComment(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, commentId, commentBodyJson);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ if(response.isSuccessful()) {
+ if(response.code() == 200) {
+
+ tinyDb.putBoolean("commentEdited", true);
+ Toasty.info(context, context.getString(R.string.editCommentUpdatedText));
+ ((ReplyToIssueActivity)context).finish();
+
+ }
+ }
+ else if(response.code() == 401) {
+
+ AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ context.getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ context.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ context.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else if(response.code() == 403) {
+
+ Toasty.info(context, context.getString(R.string.authorizeError));
+
+ }
+ else if(response.code() == 404) {
+
+ Toasty.info(context, context.getString(R.string.apiNotFound));
+
+ }
+ else {
+
+ Toasty.info(context, context.getString(R.string.genericError));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+ });
+
+ }
+
+ public static void closeReopenIssue(final Context context, final int issueIndex, final String issueState) {
+
+ final TinyDB tinyDb = new TinyDB(context);
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+
+ UpdateIssueState issueStatJson = new UpdateIssueState(issueState);
+ Call call;
+
+ call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .closeReopenIssue(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueStatJson);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ if(response.isSuccessful()) {
+ if(response.code() == 201) {
+
+ tinyDb.putBoolean("resumeIssues", true);
+ tinyDb.putBoolean("resumeClosedIssues", true);
+ if(issueState.equals("closed")) {
+ Toasty.info(context, context.getString(R.string.issueStateClosed));
+ }
+ else if(issueState.equals("open")) {
+ Toasty.info(context, context.getString(R.string.issueStateReopened));
+ }
+
+ }
+ }
+ else if(response.code() == 401) {
+
+ AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ context.getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ context.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ context.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else if(response.code() == 403) {
+
+ Toasty.info(context, context.getString(R.string.authorizeError));
+
+ }
+ else if(response.code() == 404) {
+
+ Toasty.info(context, context.getString(R.string.apiNotFound));
+
+ }
+ else {
+
+ Toasty.info(context, context.getString(R.string.genericError));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+ });
+
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/AddCollaboratorToRepositoryActivity.java b/app/src/main/java/org/mian/gitnex/activities/AddCollaboratorToRepositoryActivity.java
new file mode 100644
index 00000000..572c4701
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/AddCollaboratorToRepositoryActivity.java
@@ -0,0 +1,144 @@
+package org.mian.gitnex.activities;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.DividerItemDecoration;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+import android.content.Context;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.inputmethod.EditorInfo;
+import android.widget.ImageView;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+import org.mian.gitnex.R;
+import org.mian.gitnex.adapters.UserSearchAdapter;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.models.UserSearch;
+import org.mian.gitnex.models.UserInfo;
+import org.mian.gitnex.util.AppUtil;
+import org.mian.gitnex.util.TinyDB;
+import java.util.List;
+
+/**
+ * Author M M Arif
+ */
+
+public class AddCollaboratorToRepositoryActivity extends AppCompatActivity {
+
+ private View.OnClickListener onClickListener;
+ final Context ctx = this;
+ private TextView addCollaboratorSearch;
+ private TextView noData;
+ private ProgressBar mProgressBar;
+
+ private RecyclerView mRecyclerView;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_add_collaborator_to_repository);
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+
+ ImageView closeActivity = findViewById(R.id.close);
+ addCollaboratorSearch = findViewById(R.id.addCollaboratorSearch);
+ mRecyclerView = findViewById(R.id.recyclerViewUserSearch);
+ mProgressBar = findViewById(R.id.progress_bar);
+ noData = findViewById(R.id.noData);
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+
+ addCollaboratorSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+ @Override
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+ if (actionId == EditorInfo.IME_ACTION_SEND) {
+ if(!addCollaboratorSearch.getText().toString().equals("")) {
+ loadUserSearchList(instanceUrl, instanceToken, addCollaboratorSearch.getText().toString(), getApplicationContext(), loginUid);
+ }
+ }
+ return false;
+ }
+ });
+
+ }
+
+ public void loadUserSearchList(String instanceUrl, String token, String searchKeyword, final Context context, String loginUid) {
+
+ Call call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getUserBySearch(Authorization.returnAuthentication(getApplicationContext(), loginUid, token), searchKeyword, 10);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull Response response) {
+
+ if (response.isSuccessful()) {
+ assert response.body() != null;
+ getUsersList(response.body().getData(), context);
+ } else {
+ Log.i("onResponse", String.valueOf(response.code()));
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.i("onFailure", t.getMessage());
+ }
+
+ });
+ }
+
+ private void getUsersList(List dataList, Context context) {
+
+ UserSearchAdapter adapter = new UserSearchAdapter(dataList, context);
+
+ mRecyclerView.setHasFixedSize(true);
+ mRecyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
+ DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
+ DividerItemDecoration.VERTICAL);
+ mRecyclerView.addItemDecoration(dividerItemDecoration);
+
+ mProgressBar.setVisibility(View.VISIBLE);
+
+ if(adapter.getItemCount() > 0) {
+ mRecyclerView.setAdapter(adapter);
+ noData.setVisibility(View.GONE);
+ mProgressBar.setVisibility(View.GONE);
+ }
+ else {
+ noData.setVisibility(View.VISIBLE);
+ mProgressBar.setVisibility(View.GONE);
+ }
+
+ }
+
+ private void initCloseListener() {
+ onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ };
+ }
+
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/AddRemoveAssigneesActivity.java b/app/src/main/java/org/mian/gitnex/activities/AddRemoveAssigneesActivity.java
new file mode 100644
index 00000000..9c443528
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/AddRemoveAssigneesActivity.java
@@ -0,0 +1,290 @@
+package org.mian.gitnex.activities;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import android.content.Context;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.Window;
+import com.google.gson.JsonElement;
+import org.mian.gitnex.R;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.helpers.AlertDialogs;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.helpers.MultiSelectDialog;
+import org.mian.gitnex.helpers.Toasty;
+import org.mian.gitnex.models.Collaborators;
+import org.mian.gitnex.models.Issues;
+import org.mian.gitnex.models.MultiSelectModel;
+import org.mian.gitnex.models.UpdateIssueAssignee;
+import org.mian.gitnex.util.TinyDB;
+import java.util.ArrayList;
+import java.util.List;
+import retrofit2.Call;
+import retrofit2.Callback;
+
+/**
+ * Author M M Arif
+ */
+
+public class AddRemoveAssigneesActivity extends AppCompatActivity {
+
+ private ArrayList listOfCollaborators = new ArrayList<>();
+ private ArrayList issueAssigneesIds = new ArrayList<>();
+ private Boolean assigneesFlag = false;
+ private MultiSelectDialog multiSelectDialogAssignees;
+ final Context ctx = this;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
+ setContentView(R.layout.activity_add_remove_assignees);
+
+ getWindow().getDecorView().setBackground(new ColorDrawable(Color.TRANSPARENT));
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+ final int issueIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
+
+ getAssignees(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
+
+ }
+
+ private void getAssignees(final String instanceUrl, final String instanceToken, final String repoOwner, final String repoName, final int issueIndex, final String loginUid) {
+
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+
+ Call> call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
+
+ call.enqueue(new Callback>() {
+
+ @Override
+ public void onResponse(@NonNull final Call> call, @NonNull final retrofit2.Response> response) {
+
+ if(response.isSuccessful()) {
+ if(response.code() == 200) {
+
+ final List collaboratorsList_ = response.body();
+
+ assert collaboratorsList_ != null;
+ if(collaboratorsList_.size() > 0) {
+ for (int i = 0; i < collaboratorsList_.size(); i++) {
+
+ listOfCollaborators.add(new MultiSelectModel(collaboratorsList_.get(i).getId(), collaboratorsList_.get(i).getUsername().trim()));
+
+ }
+ }
+
+ // get current issue assignees
+ Call callSingleIssueAssignees = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getIssueByIndex(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
+
+ callSingleIssueAssignees.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ if(response.code() == 200) {
+
+ Issues issueAssigneesList = response.body();
+
+ assert issueAssigneesList != null;
+ if (issueAssigneesList.getAssignees() != null) {
+ if (issueAssigneesList.getAssignees().size() > 0) {
+ for (int i = 0; i < issueAssigneesList.getAssignees().size(); i++) {
+
+ issueAssigneesIds.add(issueAssigneesList.getAssignees().get(i).getId());
+
+ if(issueAssigneesList.getAssignees().get(i).getUsername().equals(loginUid)) {
+ listOfCollaborators.add(new MultiSelectModel(issueAssigneesList.getAssignees().get(i).getId(), issueAssigneesList.getAssignees().get(i).getUsername().trim()));
+ }
+
+ }
+ assigneesFlag = true;
+ }
+ }
+ else {
+ listOfCollaborators.add(new MultiSelectModel(tinyDb.getInt("userId"), loginUid));
+ }
+
+ if(assigneesFlag) {
+
+ multiSelectDialogAssignees = new MultiSelectDialog()
+ .title(getResources().getString(R.string.newIssueSelectAssigneesListTitle))
+ .titleSize(25)
+ .positiveText(getResources().getString(R.string.saveButton))
+ .negativeText(getResources().getString(R.string.cancelButton))
+ .setMinSelectionLimit(0)
+ .preSelectIDsList(issueAssigneesIds)
+ .setMaxSelectionLimit(listOfCollaborators.size())
+ .multiSelectList(listOfCollaborators)
+ .onSubmit(new MultiSelectDialog.SubmitCallbackListener() {
+ @Override
+ public void onSelected(ArrayList selectedIds, ArrayList selectedNames, String dataString) {
+
+ Log.i("selectedNames", String.valueOf(selectedNames));
+
+ updateIssueAssignees(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, loginUid, issueIndex, selectedNames);
+ tinyDb.putBoolean("singleIssueUpdate", true);
+ CloseActivity();
+ }
+
+ @Override
+ public void onCancel() {
+ CloseActivity();
+ }
+ });
+
+ }
+ else {
+
+ multiSelectDialogAssignees = new MultiSelectDialog()
+ .title(getResources().getString(R.string.newIssueSelectAssigneesListTitle))
+ .titleSize(25)
+ .positiveText(getResources().getString(R.string.saveButton))
+ .negativeText(getResources().getString(R.string.cancelButton))
+ .setMinSelectionLimit(0)
+ .setMaxSelectionLimit(listOfCollaborators.size())
+ .multiSelectList(listOfCollaborators)
+ .onSubmit(new MultiSelectDialog.SubmitCallbackListener() {
+ @Override
+ public void onSelected(ArrayList selectedIds, ArrayList selectedNames, String dataString) {
+
+ updateIssueAssignees(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, loginUid, issueIndex, selectedNames);
+ tinyDb.putBoolean("singleIssueUpdate", true);
+ CloseActivity();
+
+ }
+
+ @Override
+ public void onCancel() {
+ CloseActivity();
+ }
+ });
+
+ }
+
+ multiSelectDialogAssignees.show(getSupportFragmentManager(), "issueMultiSelectDialog");
+
+ }
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+
+ });
+ // get current issue assignees
+
+ }
+ else if(response.code() == 401) {
+
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else if(response.code() == 403) {
+
+ Toasty.info(ctx, ctx.getString(R.string.authorizeError));
+
+ }
+ else if(response.code() == 404) {
+
+ Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
+
+ }
+ else {
+
+ Toasty.info(getApplicationContext(), getString(R.string.genericError));
+
+ }
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call> call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+ });
+
+ }
+
+ private void CloseActivity() {
+ this.finish();
+ }
+
+ private void updateIssueAssignees(final String instanceUrl, final String instanceToken, String repoOwner, String repoName, String loginUid, int issueIndex, List issueAssigneesList) {
+
+ UpdateIssueAssignee updateAssigneeJson = new UpdateIssueAssignee(issueAssigneesList);
+
+ Call call3;
+
+ call3 = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .patchIssueAssignee(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, updateAssigneeJson);
+
+ call3.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response2) {
+
+ if(response2.code() == 201) {
+
+ Toasty.info(ctx, ctx.getString(R.string.assigneesUpdated));
+
+ }
+ else if(response2.code() == 401) {
+
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else if(response2.code() == 403) {
+
+ Toasty.info(ctx, ctx.getString(R.string.authorizeError));
+
+ }
+ else if(response2.code() == 404) {
+
+ Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
+
+ }
+ else {
+
+ Toasty.info(getApplicationContext(), getString(R.string.genericError));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+ });
+
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/AddRemoveLabelsActivity.java b/app/src/main/java/org/mian/gitnex/activities/AddRemoveLabelsActivity.java
new file mode 100644
index 00000000..3f3a338a
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/AddRemoveLabelsActivity.java
@@ -0,0 +1,303 @@
+package org.mian.gitnex.activities;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import retrofit2.Call;
+import retrofit2.Callback;
+import android.content.Context;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.Window;
+import com.google.gson.JsonElement;
+import org.mian.gitnex.R;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.helpers.AlertDialogs;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.helpers.MultiSelectDialog;
+import org.mian.gitnex.helpers.Toasty;
+import org.mian.gitnex.models.Labels;
+import org.mian.gitnex.models.MultiSelectModel;
+import org.mian.gitnex.util.TinyDB;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Author M M Arif
+ */
+
+public class AddRemoveLabelsActivity extends AppCompatActivity {
+
+ private ArrayList listOfLabels = new ArrayList<>();
+ private ArrayList issueLabelIds = new ArrayList<>();
+ private Boolean labelsFlag = false;
+ private MultiSelectDialog multiSelectDialogLabels;
+ final Context ctx = this;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
+ setContentView(R.layout.activity_add_remove_labels);
+
+ getWindow().getDecorView().setBackground(new ColorDrawable(Color.TRANSPARENT));
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+ final int issueIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
+
+ getLabels(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
+
+ }
+
+ private void getLabels(final String instanceUrl, final String instanceToken, final String repoOwner, final String repoName, final int issueIndex, final String loginUid) {
+
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+
+ Call> call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getlabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
+
+ call.enqueue(new Callback>() {
+
+ @Override
+ public void onResponse(@NonNull Call> call, @NonNull retrofit2.Response> response) {
+
+ if(response.isSuccessful()) {
+ if(response.code() == 200) {
+
+ List labelsList_ = response.body();
+
+ assert labelsList_ != null;
+ if(labelsList_.size() > 0) {
+ for (int i = 0; i < labelsList_.size(); i++) {
+
+ listOfLabels.add(new MultiSelectModel(labelsList_.get(i).getId(), labelsList_.get(i).getName().trim()));
+
+ }
+ }
+
+ // get current issue labels
+ Call> callSingleIssueLabels = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getIssueLabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
+
+ callSingleIssueLabels.enqueue(new Callback>() {
+
+ @Override
+ public void onResponse(@NonNull Call> call, @NonNull retrofit2.Response> response) {
+
+ if(response.code() == 200) {
+
+ List issueLabelsList = response.body();
+
+ assert issueLabelsList != null;
+ if(issueLabelsList.size() > 0) {
+ for (int i = 0; i < issueLabelsList.size(); i++) {
+
+ issueLabelIds.add(issueLabelsList.get(i).getId());
+
+ }
+ labelsFlag = true;
+ }
+
+ if(labelsFlag) {
+
+ multiSelectDialogLabels = new MultiSelectDialog()
+ .title(getResources().getString(R.string.newIssueSelectLabelsListTitle))
+ .titleSize(25)
+ .positiveText(getResources().getString(R.string.saveButton))
+ .negativeText(getResources().getString(R.string.cancelButton))
+ .setMinSelectionLimit(0)
+ .preSelectIDsList(issueLabelIds)
+ .setMaxSelectionLimit(listOfLabels.size())
+ .multiSelectList(listOfLabels)
+ .onSubmit(new MultiSelectDialog.SubmitCallbackListener() {
+ @Override
+ public void onSelected(ArrayList selectedIds, ArrayList selectedNames, String dataString) {
+
+ String labelIds = selectedIds.toString();
+ int[] integers;
+ if (selectedIds.size() > 0) {
+
+ String[] items = labelIds.replaceAll("\\[", "").replaceAll("\\]", "").replaceAll("\\s", "").split(",");
+ integers = new int[items.length];
+ for (int i = 0; i < integers.length; i++) {
+ integers[i] = Integer.parseInt(items[i]);
+ }
+
+ }
+ else {
+ integers = new int[0];
+ }
+
+ updateIssueLabels(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, integers, loginUid);
+ tinyDb.putBoolean("singleIssueUpdate", true);
+ CloseActivity();
+ }
+
+ @Override
+ public void onCancel() {
+ CloseActivity();
+ }
+ });
+
+ }
+ else {
+
+ multiSelectDialogLabels = new MultiSelectDialog()
+ .title(getResources().getString(R.string.newIssueSelectLabelsListTitle))
+ .titleSize(25)
+ .positiveText(getResources().getString(R.string.saveButton))
+ .negativeText(getResources().getString(R.string.cancelButton))
+ .setMinSelectionLimit(0)
+ .setMaxSelectionLimit(listOfLabels.size())
+ .multiSelectList(listOfLabels)
+ .onSubmit(new MultiSelectDialog.SubmitCallbackListener() {
+ @Override
+ public void onSelected(ArrayList selectedIds, ArrayList selectedNames, String dataString) {
+
+ String labelIds = selectedIds.toString();
+ int[] integers;
+ if (selectedIds.size() > 0) {
+
+ String[] items = labelIds.replaceAll("\\[", "").replaceAll("\\]", "").replaceAll("\\s", "").split(",");
+ integers = new int[items.length];
+ for (int i = 0; i < integers.length; i++) {
+ integers[i] = Integer.parseInt(items[i]);
+ }
+
+ }
+ else {
+ integers = new int[0];
+ }
+
+ updateIssueLabels(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, integers, loginUid);
+ tinyDb.putBoolean("singleIssueUpdate", true);
+ CloseActivity();
+
+ }
+
+ @Override
+ public void onCancel() {
+ CloseActivity();
+ }
+ });
+
+ }
+
+ multiSelectDialogLabels.show(getSupportFragmentManager(), "issueMultiSelectDialog");
+
+ }
+ }
+
+ @Override
+ public void onFailure(@NonNull Call> call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+
+ });
+ // get current issue labels
+
+ }
+ else if(response.code() == 401) {
+
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else if(response.code() == 403) {
+
+ Toasty.info(ctx, ctx.getString(R.string.authorizeError));
+
+ }
+ else if(response.code() == 404) {
+
+ Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
+
+ }
+ else {
+
+ Toasty.info(getApplicationContext(), getString(R.string.genericError));
+
+ }
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call> call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+ });
+
+ }
+
+ private void updateIssueLabels(final String instanceUrl, final String instanceToken, String repoOwner, String repoName, int issueIndex, int[] issueLabels, String loginUid) {
+
+ Labels patchIssueLabels = new Labels(issueLabels);
+
+ Call call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .updateIssueLabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, patchIssueLabels);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ if(response.code() == 200) {
+
+ Toasty.info(ctx, ctx.getString(R.string.labelsUpdated));
+
+ }
+ else if(response.code() == 401) {
+
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else if(response.code() == 403) {
+
+ Toasty.info(ctx, ctx.getString(R.string.authorizeError));
+
+ }
+ else if(response.code() == 404) {
+
+ Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
+
+ }
+ else {
+
+ Toasty.info(getApplicationContext(), getString(R.string.genericError));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+ });
+
+ }
+
+ private void CloseActivity() {
+ this.finish();
+ }
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/AdminGetUsersActivity.java b/app/src/main/java/org/mian/gitnex/activities/AdminGetUsersActivity.java
new file mode 100644
index 00000000..ca82dbe8
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/AdminGetUsersActivity.java
@@ -0,0 +1,200 @@
+package org.mian.gitnex.activities;
+
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+import androidx.lifecycle.Observer;
+import androidx.lifecycle.ViewModelProviders;
+import androidx.recyclerview.widget.DividerItemDecoration;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.inputmethod.EditorInfo;
+import android.widget.ImageView;
+import android.widget.TextView;
+import org.mian.gitnex.R;
+import org.mian.gitnex.adapters.AdminGetUsersAdapter;
+import org.mian.gitnex.fragments.AdminUsersBottomSheetFragment;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.models.UserInfo;
+import org.mian.gitnex.util.AppUtil;
+import org.mian.gitnex.util.TinyDB;
+import org.mian.gitnex.viewmodels.AdminGetUsersViewModel;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Author M M Arif
+ */
+
+public class AdminGetUsersActivity extends AppCompatActivity implements AdminUsersBottomSheetFragment.BottomSheetListener {
+
+ private View.OnClickListener onClickListener;
+ final Context ctx = this;
+ private AdminGetUsersAdapter adapter;
+ private RecyclerView mRecyclerView;
+ private TextView noDataUsers;
+ private Boolean searchFilter = false;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_admin_get_users);
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+
+ ImageView closeActivity = findViewById(R.id.close);
+ noDataUsers = findViewById(R.id.noDataUsers);
+ mRecyclerView = findViewById(R.id.recyclerView);
+
+ final SwipeRefreshLayout swipeRefresh = findViewById(R.id.pullToRefresh);
+
+ Toolbar toolbar = findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+
+ mRecyclerView.setHasFixedSize(true);
+ mRecyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
+
+ DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
+ DividerItemDecoration.VERTICAL);
+ mRecyclerView.addItemDecoration(dividerItemDecoration);
+
+ swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+ @Override
+ public void onRefresh() {
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ swipeRefresh.setRefreshing(false);
+ AdminGetUsersViewModel.loadUsersList(getApplicationContext(), instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken));
+ }
+ }, 500);
+ }
+ });
+
+ fetchDataAsync(getApplicationContext(), instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken));
+
+ }
+
+ private void fetchDataAsync(Context ctx, String instanceUrl, String instanceToken) {
+
+ AdminGetUsersViewModel usersModel = ViewModelProviders.of(this).get(AdminGetUsersViewModel.class);
+
+ usersModel.getUsersList(ctx, instanceUrl, instanceToken).observe(this, new Observer>() {
+ @Override
+ public void onChanged(@Nullable List usersListMain) {
+ adapter = new AdminGetUsersAdapter(getApplicationContext(), usersListMain);
+ if(adapter.getItemCount() > 0) {
+ mRecyclerView.setVisibility(View.VISIBLE);
+ mRecyclerView.setAdapter(adapter);
+ noDataUsers.setVisibility(View.GONE);
+ searchFilter = true;
+ }
+ else {
+ //adapter.notifyDataSetChanged();
+ //mRecyclerView.setAdapter(adapter);
+ mRecyclerView.setVisibility(View.GONE);
+ noDataUsers.setVisibility(View.VISIBLE);
+ }
+ }
+ });
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(final Menu menu) {
+
+ final MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.generic_nav_dotted_menu, menu);
+
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ if(searchFilter) {
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(Objects.requireNonNull(getApplicationContext()));
+
+ inflater.inflate(R.menu.search_menu, menu);
+
+ MenuItem searchItem = menu.findItem(R.id.action_search);
+ androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
+ searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
+
+ if(!connToInternet) {
+ return;
+ }
+
+ searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
+ @Override
+ public boolean onQueryTextSubmit(String query) {
+ return true;
+ }
+
+ @Override
+ public boolean onQueryTextChange(String newText) {
+ adapter.getFilter().filter(newText);
+ return false;
+ }
+ });
+ }
+ }
+ }, 500);
+
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ int id = item.getItemId();
+
+ switch (id) {
+ case android.R.id.home:
+ finish();
+ return true;
+ case R.id.genericMenu:
+ AdminUsersBottomSheetFragment bottomSheet = new AdminUsersBottomSheetFragment();
+ bottomSheet.show(getSupportFragmentManager(), "usersBottomSheet");
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+
+ }
+
+ @Override
+ public void onButtonClicked(String text) {
+
+ switch (text) {
+ case "newUser":
+ startActivity(new Intent(AdminGetUsersActivity.this, CreateNewUserActivity.class));
+ break;
+ }
+
+ }
+
+ private void initCloseListener() {
+ onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ };
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/CreateIssueActivity.java b/app/src/main/java/org/mian/gitnex/activities/CreateIssueActivity.java
new file mode 100644
index 00000000..4bfbbd3e
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/CreateIssueActivity.java
@@ -0,0 +1,575 @@
+package org.mian.gitnex.activities;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+import android.app.DatePickerDialog;
+import android.content.Context;
+import android.graphics.PorterDuff;
+import android.graphics.drawable.GradientDrawable;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.DatePicker;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.Spinner;
+import android.widget.TextView;
+import com.google.gson.JsonElement;
+import com.hendraanggrian.appcompat.socialview.Mention;
+import com.hendraanggrian.appcompat.widget.MentionArrayAdapter;
+import com.hendraanggrian.appcompat.widget.SocialAutoCompleteTextView;
+import org.mian.gitnex.R;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.helpers.AlertDialogs;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.helpers.MultiSelectDialog;
+import org.mian.gitnex.models.Collaborators;
+import org.mian.gitnex.models.CreateIssue;
+import org.mian.gitnex.models.Labels;
+import org.mian.gitnex.models.Milestones;
+import org.mian.gitnex.models.MultiSelectModel;
+import org.mian.gitnex.util.AppUtil;
+import org.mian.gitnex.util.TinyDB;
+import org.mian.gitnex.helpers.Toasty;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.List;
+
+/**
+ * Author M M Arif
+ */
+
+public class CreateIssueActivity extends AppCompatActivity implements View.OnClickListener {
+
+ private View.OnClickListener onClickListener;
+ MultiSelectDialog multiSelectDialog;
+ MultiSelectDialog multiSelectDialogLabels;
+ private TextView assigneesList;
+ private TextView newIssueLabels;
+ private TextView newIssueDueDate;
+ private Spinner newIssueMilestoneSpinner;
+ private EditText newIssueTitle;
+ private SocialAutoCompleteTextView newIssueDescription;
+ private Button createNewIssueButton;
+ private TextView labelsIdHolder;
+ private boolean assigneesFlag;
+ private boolean labelsFlag;
+ final Context ctx = this;
+
+ List milestonesList = new ArrayList<>();
+ ArrayList listOfAssignees = new ArrayList<>();
+ ArrayList listOfLabels= new ArrayList<>();
+ private ArrayAdapter defaultMentionAdapter;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_create_issue);
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+
+ ImageView closeActivity = findViewById(R.id.close);
+ assigneesList = findViewById(R.id.newIssueAssigneesList);
+ newIssueLabels = findViewById(R.id.newIssueLabels);
+ newIssueDueDate = findViewById(R.id.newIssueDueDate);
+ createNewIssueButton = findViewById(R.id.createNewIssueButton);
+ newIssueTitle = findViewById(R.id.newIssueTitle);
+ newIssueDescription = findViewById(R.id.newIssueDescription);
+ labelsIdHolder = findViewById(R.id.labelsIdHolder);
+
+ defaultMentionAdapter = new MentionArrayAdapter<>(this);
+ loadCollaboratorsList();
+
+ newIssueDescription.setMentionAdapter(defaultMentionAdapter);
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+
+ assigneesList.setOnClickListener(this);
+ newIssueLabels.setOnClickListener(this);
+ newIssueDueDate.setOnClickListener(this);
+
+ newIssueMilestoneSpinner = findViewById(R.id.newIssueMilestoneSpinner);
+ newIssueMilestoneSpinner.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
+ getMilestones(instanceUrl, instanceToken, repoOwner, repoName, loginUid);
+
+ getLabels(instanceUrl, instanceToken, repoOwner, repoName, loginUid);
+ getCollaborators(instanceUrl, instanceToken, repoOwner, repoName, loginUid);
+
+ disableProcessButton();
+
+ if(!connToInternet) {
+
+ createNewIssueButton.setEnabled(false);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.hintColor));
+ createNewIssueButton.setBackground(shape);
+
+ } else {
+
+ createNewIssueButton.setOnClickListener(this);
+
+ }
+
+ }
+
+ private void processNewIssue() {
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+
+ Milestones mModel = (Milestones) newIssueMilestoneSpinner.getSelectedItem();
+
+ int newIssueMilestoneIdForm = mModel.getId();
+ String newIssueTitleForm = newIssueTitle.getText().toString();
+ String newIssueDescriptionForm = newIssueDescription.getText().toString();
+ String newIssueAssigneesListForm = assigneesList.getText().toString();
+ //String newIssueLabelsForm = newIssueLabels.getText().toString();
+ String newIssueDueDateForm = newIssueDueDate.getText().toString();
+ String newIssueLabelsIdHolderForm = labelsIdHolder.getText().toString();
+
+ if(!connToInternet) {
+
+ Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
+ return;
+
+ }
+
+ if (newIssueTitleForm.equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.issueTitleEmpty));
+ return;
+
+ }
+
+ /*if (newIssueDescriptionForm.equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.issueDescriptionEmpty));
+ return;
+
+ }*/
+
+ if (newIssueDueDateForm.equals("")) {
+ newIssueDueDateForm = null;
+ } else {
+ newIssueDueDateForm = (AppUtil.customDateCombine(AppUtil.customDateFormat(newIssueDueDateForm)));
+ }
+
+ List newIssueAssigneesListForm_ = new ArrayList<>(Arrays.asList(newIssueAssigneesListForm.split(",")));
+
+ for (int i = 0; i < newIssueAssigneesListForm_.size(); i++) {
+ newIssueAssigneesListForm_.set(i, newIssueAssigneesListForm_.get(i).trim());
+ }
+
+ int[] integers;
+ if (!newIssueLabelsIdHolderForm.equals("")) {
+
+ String[] items = newIssueLabelsIdHolderForm.replaceAll("\\[", "").replaceAll("\\]", "").replaceAll("\\s", "").split(",");
+ integers = new int[items.length];
+ for (int i = 0; i < integers.length; i++) {
+ integers[i] = Integer.parseInt(items[i]);
+ }
+
+ }
+ else {
+ integers = new int[0];
+ }
+
+ //Log.i("FormData", String.valueOf(newIssueLabelsForm));
+ disableProcessButton();
+ createNewIssueFunc(instanceUrl, instanceToken, repoOwner, repoName, loginUid, newIssueDescriptionForm, newIssueDueDateForm, newIssueMilestoneIdForm, newIssueTitleForm, newIssueAssigneesListForm_, integers);
+
+ }
+
+ public void loadCollaboratorsList() {
+
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+
+ Call> call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
+
+ call.enqueue(new Callback>() {
+
+ @Override
+ public void onResponse(@NonNull Call> call, @NonNull Response> response) {
+
+ if (response.isSuccessful()) {
+
+ assert response.body() != null;
+ String fullName = "";
+ for (int i = 0; i < response.body().size(); i++) {
+ if(!response.body().get(i).getFull_name().equals("")) {
+ fullName = response.body().get(i).getFull_name();
+ }
+ defaultMentionAdapter.add(
+ new Mention(response.body().get(i).getUsername(), fullName, response.body().get(i).getAvatar_url()));
+ }
+
+ } else {
+
+ Log.i("onResponse", String.valueOf(response.code()));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call> call, @NonNull Throwable t) {
+ Log.i("onFailure", t.getMessage());
+ }
+
+ });
+ }
+
+ private void createNewIssueFunc(final String instanceUrl, final String instanceToken, String repoOwner, String repoName, String loginUid, String newIssueDescriptionForm, String newIssueDueDateForm, int newIssueMilestoneIdForm, String newIssueTitleForm, List newIssueAssigneesListForm, int[] newIssueLabelsForm) {
+
+ CreateIssue createNewIssueJson = new CreateIssue(loginUid, newIssueDescriptionForm, false, newIssueDueDateForm, newIssueMilestoneIdForm, newIssueTitleForm, newIssueAssigneesListForm, newIssueLabelsForm);
+
+ Call call3;
+
+ call3 = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .createNewIssue(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, createNewIssueJson);
+
+ call3.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response2) {
+
+ if(response2.isSuccessful()) {
+ if(response2.code() == 201) {
+
+ //Log.i("isSuccessful1", String.valueOf(response2.body()));
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ tinyDb.putBoolean("resumeIssues", true);
+
+ Toasty.info(getApplicationContext(), getString(R.string.issueCreated));
+ enableProcessButton();
+ finish();
+
+ }
+
+ }
+ else if(response2.code() == 401) {
+
+ enableProcessButton();
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else {
+
+ Toasty.info(getApplicationContext(), getString(R.string.issueCreatedError));
+ enableProcessButton();
+ //Log.i("isSuccessful2", String.valueOf(response2.body()));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ enableProcessButton();
+ }
+ });
+
+ }
+
+ private void initCloseListener() {
+ onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ };
+ }
+
+ private void getMilestones(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
+
+ Call> call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getMilestones(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
+
+ call.enqueue(new Callback>() {
+
+ @Override
+ public void onResponse(@NonNull Call> call, @NonNull retrofit2.Response> response) {
+
+ if(response.isSuccessful()) {
+ if(response.code() == 200) {
+
+ List milestonesList_ = response.body();
+
+ milestonesList.add(new Milestones(0,"No milestone"));
+ assert milestonesList_ != null;
+ if(milestonesList_.size() > 0) {
+ for (int i = 0; i < milestonesList_.size(); i++) {
+
+ //String mStone = getString(R.string.spinnerMilestoneText, milestonesList_.get(i).getTitle(), milestonesList_.get(i).getState());
+ if(milestonesList_.get(i).getState().equals(getString(R.string.issueStatusOpen))) {
+ Milestones data = new Milestones(
+ milestonesList_.get(i).getId(),
+ milestonesList_.get(i).getTitle()
+ );
+ milestonesList.add(data);
+ }
+
+ }
+ }
+
+ ArrayAdapter adapter = new ArrayAdapter<>(getApplicationContext(),
+ R.layout.spinner_item, milestonesList);
+
+ adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
+ newIssueMilestoneSpinner.setAdapter(adapter);
+ enableProcessButton();
+
+ }
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call> call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+ });
+
+ }
+
+ private void getCollaborators(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
+
+ Call> call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
+
+ call.enqueue(new Callback>() {
+
+ @Override
+ public void onResponse(@NonNull Call> call, @NonNull retrofit2.Response> response) {
+
+ if(response.isSuccessful()) {
+ if(response.code() == 200) {
+
+ List assigneesList_ = response.body();
+
+ assert assigneesList_ != null;
+ if(assigneesList_.size() > 0) {
+ for (int i = 0; i < assigneesList_.size(); i++) {
+
+ /*String assigneesCopy;
+ if(!assigneesList_.get(i).getFull_name().equals("")) {
+ assigneesCopy = getString(R.string.dialogAssignessText, assigneesList_.get(i).getFull_name(), assigneesList_.get(i).getLogin());
+ }
+ else {
+ assigneesCopy = assigneesList_.get(i).getLogin();
+ }*/
+ listOfAssignees.add(new MultiSelectModel(assigneesList_.get(i).getId(), assigneesList_.get(i).getLogin().trim()));
+
+ }
+ assigneesFlag = true;
+ }
+
+ multiSelectDialog = new MultiSelectDialog()
+ .title(getResources().getString(R.string.newIssueSelectAssigneesListTitle))
+ .titleSize(25)
+ .positiveText(getResources().getString(R.string.okButton))
+ .negativeText(getResources().getString(R.string.cancelButton))
+ .setMinSelectionLimit(0)
+ .setMaxSelectionLimit(listOfAssignees.size())
+ .multiSelectList(listOfAssignees)
+ .onSubmit(new MultiSelectDialog.SubmitCallbackListener() {
+ @Override
+ public void onSelected(ArrayList selectedIds, ArrayList selectedNames, String dataString) {
+
+ assigneesList.setText(dataString);
+
+ }
+
+ @Override
+ public void onCancel() {
+ //Log.d("multiSelect","Dialog cancelled");
+
+ }
+ });
+
+ }
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call> call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+ });
+
+ }
+
+ private void getLabels(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
+
+ Call> call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getlabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
+
+ call.enqueue(new Callback>() {
+
+ @Override
+ public void onResponse(@NonNull Call> call, @NonNull retrofit2.Response> response) {
+
+ if(response.isSuccessful()) {
+ if(response.code() == 200) {
+
+ List labelsList_ = response.body();
+
+ assert labelsList_ != null;
+ if(labelsList_.size() > 0) {
+ for (int i = 0; i < labelsList_.size(); i++) {
+
+ listOfLabels.add(new MultiSelectModel(labelsList_.get(i).getId(), labelsList_.get(i).getName().trim()));
+
+ }
+ labelsFlag = true;
+ }
+
+ multiSelectDialogLabels = new MultiSelectDialog()
+ .title(getResources().getString(R.string.newIssueSelectLabelsListTitle))
+ .titleSize(25)
+ .positiveText(getResources().getString(R.string.okButton))
+ .negativeText(getResources().getString(R.string.cancelButton))
+ .setMinSelectionLimit(0)
+ .setMaxSelectionLimit(listOfLabels.size())
+ .multiSelectList(listOfLabels)
+ .onSubmit(new MultiSelectDialog.SubmitCallbackListener() {
+ @Override
+ public void onSelected(ArrayList selectedIds, ArrayList selectedNames, String dataString) {
+
+ newIssueLabels.setText(dataString.trim());
+ labelsIdHolder.setText(selectedIds.toString());
+
+ }
+
+ @Override
+ public void onCancel() {
+ //Log.d("multiSelect","Dialog cancelled");
+
+ }
+ });
+
+ }
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call> call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+ });
+
+ }
+
+ @Override
+ public void onClick(View v) {
+ if (v == assigneesList) {
+ if(assigneesFlag) {
+ multiSelectDialog.show(getSupportFragmentManager(), "multiSelectDialog");
+ }
+ else {
+ Toasty.info(getApplicationContext(), getResources().getString(R.string.noAssigneesFound));
+ }
+ }
+ else if (v == newIssueLabels) {
+ if(labelsFlag) {
+ multiSelectDialogLabels.show(getSupportFragmentManager(), "multiSelectDialogLabels");
+ }
+ else {
+ Toasty.info(getApplicationContext(), getResources().getString(R.string.noLabelsFound));
+ }
+ }
+ else if (v == newIssueDueDate) {
+
+ final Calendar c = Calendar.getInstance();
+ int mYear = c.get(Calendar.YEAR);
+ final int mMonth = c.get(Calendar.MONTH);
+ final int mDay = c.get(Calendar.DAY_OF_MONTH);
+
+ DatePickerDialog datePickerDialog = new DatePickerDialog(this,
+ new DatePickerDialog.OnDateSetListener() {
+
+ @Override
+ public void onDateSet(DatePicker view, int year,
+ int monthOfYear, int dayOfMonth) {
+
+ newIssueDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth));
+
+ }
+ }, mYear, mMonth, mDay);
+ datePickerDialog.show();
+ }
+ else if(v == createNewIssueButton) {
+ processNewIssue();
+ }
+
+ }
+
+ private void disableProcessButton() {
+
+ createNewIssueButton.setEnabled(false);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.hintColor));
+ createNewIssueButton.setBackground(shape);
+
+ }
+
+ private void enableProcessButton() {
+
+ createNewIssueButton.setEnabled(true);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.btnBackground));
+ createNewIssueButton.setBackground(shape);
+
+ }
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/CreateLabelActivity.java b/app/src/main/java/org/mian/gitnex/activities/CreateLabelActivity.java
new file mode 100644
index 00000000..67d94e00
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/CreateLabelActivity.java
@@ -0,0 +1,435 @@
+package org.mian.gitnex.activities;
+
+import androidx.annotation.ColorInt;
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.content.ContextCompat;
+import retrofit2.Call;
+import retrofit2.Callback;
+import android.content.Context;
+import android.graphics.Color;
+import android.graphics.drawable.GradientDrawable;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.TextView;
+import com.pes.androidmaterialcolorpickerdialog.ColorPicker;
+import com.pes.androidmaterialcolorpickerdialog.ColorPickerCallback;
+import org.mian.gitnex.R;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.helpers.AlertDialogs;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.helpers.Toasty;
+import org.mian.gitnex.models.CreateLabel;
+import org.mian.gitnex.models.Labels;
+import org.mian.gitnex.util.AppUtil;
+import org.mian.gitnex.util.TinyDB;
+import org.mian.gitnex.viewmodels.LabelsViewModel;
+
+/**
+ * Author M M Arif
+ */
+
+public class CreateLabelActivity extends AppCompatActivity {
+
+ private View.OnClickListener onClickListener;
+ private TextView colorPicker;
+ private EditText labelName;
+ private Button createLabelButton;
+ final Context ctx = this;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_create_label);
+
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+
+ if(getIntent().getStringExtra("labelAction") != null && getIntent().getStringExtra("labelAction").equals("delete")) {
+
+ deleteLabel(instanceUrl, instanceToken, repoOwner, repoName, Integer.valueOf(getIntent().getStringExtra("labelId")), loginUid);
+ finish();
+ return;
+
+ }
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+
+ ImageView closeActivity = findViewById(R.id.close);
+ colorPicker = findViewById(R.id.colorPicker);
+ labelName = findViewById(R.id.labelName);
+ createLabelButton = findViewById(R.id.createLabelButton);
+
+ final ColorPicker cp = new ColorPicker(CreateLabelActivity.this, 235, 113, 33);
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+ colorPicker.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ cp.show();
+ }
+ });
+
+ cp.setCallback(new ColorPickerCallback() {
+ @Override
+ public void onColorChosen(@ColorInt int color) {
+
+ //Log.i("#Hex no alpha", String.format("#%06X", (0xFFFFFF & color)));
+ colorPicker.setBackgroundColor(color);
+ tinyDb.putString("labelColor", String.format("#%06X", (0xFFFFFF & color)));
+ cp.dismiss();
+
+ }
+ });
+
+ if(getIntent().getStringExtra("labelAction") != null && getIntent().getStringExtra("labelAction").equals("edit")) {
+
+ labelName.setText(getIntent().getStringExtra("labelTitle"));
+ int labelColor_ = Color.parseColor("#" + getIntent().getStringExtra("labelColor"));
+ colorPicker.setBackgroundColor(labelColor_);
+ tinyDb.putString("labelColorDefault", "#" + getIntent().getStringExtra("labelColor"));
+
+ TextView toolbar_title = findViewById(R.id.toolbar_title);
+ toolbar_title.setText(getResources().getString(R.string.pageTitleLabelUpdate));
+ createLabelButton.setText(getResources().getString(R.string.newUpdateButtonCopy));
+
+ createLabelButton.setOnClickListener(updateLabelListener);
+
+ return;
+
+ }
+
+ if(!connToInternet) {
+
+ createLabelButton.setEnabled(false);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.hintColor));
+ createLabelButton.setBackground(shape);
+
+ } else {
+
+ createLabelButton.setOnClickListener(createLabelListener);
+
+ }
+
+ }
+
+ private View.OnClickListener createLabelListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ processCreateLabel();
+ }
+ };
+
+ private View.OnClickListener updateLabelListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ processUpdateLabel();
+ }
+ };
+
+ private void processUpdateLabel() {
+
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+ AppUtil appUtil = new AppUtil();
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+
+ String updateLabelName = labelName.getText().toString();
+
+ String updateLabelColor;
+ if(tinyDb.getString("labelColor").isEmpty()) {
+ updateLabelColor = tinyDb.getString("labelColorDefault");
+ }
+ else {
+ updateLabelColor = tinyDb.getString("labelColor");
+ }
+
+ if(!connToInternet) {
+
+ Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
+ return;
+
+ }
+
+ if(updateLabelName.equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.labelEmptyError));
+ return;
+
+ }
+
+ if(!appUtil.checkStrings(updateLabelName)) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.labelNameError));
+ return;
+
+ }
+
+ disableProcessButton();
+ patchLabel(instanceUrl, instanceToken, repoOwner, repoName, updateLabelName, updateLabelColor, Integer.valueOf(getIntent().getStringExtra("labelId")), loginUid);
+
+ }
+
+ private void processCreateLabel() {
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+ AppUtil appUtil = new AppUtil();
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+
+ String newLabelName = labelName.getText().toString();
+ String newLabelColor;
+ if(tinyDb.getString("labelColor").isEmpty()) {
+ newLabelColor = String.format("#%06X", (0xFFFFFF & ContextCompat.getColor(getApplicationContext(), R.color.releasePre)));
+ }
+ else {
+ newLabelColor = tinyDb.getString("labelColor");
+ }
+
+ if(!connToInternet) {
+
+ Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
+ return;
+
+ }
+
+ if(newLabelName.equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.labelEmptyError));
+ return;
+
+ }
+
+ if(!appUtil.checkStrings(newLabelName)) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.labelNameError));
+ return;
+
+ }
+
+ disableProcessButton();
+ createNewLabel(instanceUrl, instanceToken, repoOwner, repoName, newLabelName, newLabelColor, loginUid);
+
+ }
+
+ private void createNewLabel(final String instanceUrl, final String instanceToken, String repoOwner, String repoName, String newLabelName, String newLabelColor, String loginUid) {
+
+ CreateLabel createLabelFunc = new CreateLabel(newLabelName, newLabelColor);
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+
+ Call call;
+
+ call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .createLabel(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, createLabelFunc);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ if(response.code() == 201) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.labelCreated));
+ tinyDb.putString("labelColor", "");
+ tinyDb.putBoolean("labelsRefresh", true);
+ finish();
+
+ }
+ else if(response.code() == 401) {
+
+ enableProcessButton();
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else {
+
+ enableProcessButton();
+ tinyDb.putString("labelColor", "");
+ Toasty.info(getApplicationContext(), getString(R.string.labelGeneralError));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ tinyDb.putString("labelColor", "");
+ Log.e("onFailure", t.toString());
+ enableProcessButton();
+ }
+ });
+
+ }
+
+ private void patchLabel(final String instanceUrl, final String instanceToken, String repoOwner, String repoName, String updateLabelName, String updateLabelColor, int labelId, String loginUid) {
+
+ CreateLabel createLabelFunc = new CreateLabel(updateLabelName, updateLabelColor);
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+
+ Call call;
+
+ call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .patchLabel(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, labelId, createLabelFunc);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ if(response.isSuccessful()) {
+ if(response.code() == 200) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.labelUpdated));
+ tinyDb.putString("labelColor", "");
+ tinyDb.putBoolean("labelsRefresh", true);
+ tinyDb.putString("labelColorDefault", "");
+ getIntent().removeExtra("labelAction");
+ getIntent().removeExtra("labelId");
+ getIntent().removeExtra("labelTitle");
+ getIntent().removeExtra("labelColor");
+ finish();
+
+ }
+ }
+ else if(response.code() == 401) {
+
+ enableProcessButton();
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else {
+
+ enableProcessButton();
+ tinyDb.putString("labelColor", "");
+ tinyDb.putString("labelColorDefault", "");
+ Toasty.info(getApplicationContext(), getString(R.string.labelGeneralError));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ tinyDb.putString("labelColor", "");
+ tinyDb.putString("labelColorDefault", "");
+ Log.e("onFailure", t.toString());
+ enableProcessButton();
+ }
+ });
+
+ }
+
+ private void initCloseListener() {
+ onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ getIntent().removeExtra("labelAction");
+ getIntent().removeExtra("labelId");
+ getIntent().removeExtra("labelTitle");
+ getIntent().removeExtra("labelColor");
+ finish();
+ }
+ };
+ }
+
+ private void deleteLabel(final String instanceUrl, final String instanceToken, final String repoOwner, final String repoName, int labelId, String loginUid) {
+
+ Call call;
+
+ call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .deleteLabel(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, labelId);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ if(response.isSuccessful()) {
+ if(response.code() == 204) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.labelDeleteText));
+ LabelsViewModel.loadLabelsList(instanceUrl, instanceToken, repoOwner, repoName);
+ getIntent().removeExtra("labelAction");
+ getIntent().removeExtra("labelId");
+
+ }
+ }
+ else if(response.code() == 401) {
+
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else {
+
+ Toasty.info(getApplicationContext(), getString(R.string.labelDeleteErrorText));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+ });
+
+ }
+
+ private void disableProcessButton() {
+
+ createLabelButton.setEnabled(false);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.hintColor));
+ createLabelButton.setBackground(shape);
+
+ }
+
+ private void enableProcessButton() {
+
+ createLabelButton.setEnabled(true);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.btnBackground));
+ createLabelButton.setBackground(shape);
+
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/org/mian/gitnex/activities/CreateNewUserActivity.java b/app/src/main/java/org/mian/gitnex/activities/CreateNewUserActivity.java
new file mode 100644
index 00000000..bfefc150
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/CreateNewUserActivity.java
@@ -0,0 +1,226 @@
+package org.mian.gitnex.activities;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import retrofit2.Call;
+import retrofit2.Callback;
+import android.content.Context;
+import android.graphics.drawable.GradientDrawable;
+import android.os.Bundle;
+import android.util.Log;
+import android.util.Patterns;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+import org.mian.gitnex.R;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.helpers.AlertDialogs;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.helpers.Toasty;
+import org.mian.gitnex.models.UserInfo;
+import org.mian.gitnex.util.AppUtil;
+import org.mian.gitnex.util.TinyDB;
+
+/**
+ * Author M M Arif
+ */
+
+public class CreateNewUserActivity extends AppCompatActivity {
+
+ private View.OnClickListener onClickListener;
+ private EditText fullName;
+ private EditText userUserName;
+ private EditText userEmail;
+ private EditText userPassword;
+ private Button createUserButton;
+ final Context ctx = this;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_create_new_user);
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+
+ ImageView closeActivity = findViewById(R.id.close);
+ createUserButton = findViewById(R.id.createUserButton);
+ fullName = findViewById(R.id.fullName);
+ userUserName = findViewById(R.id.userUserName);
+ userEmail = findViewById(R.id.userEmail);
+ userPassword = findViewById(R.id.userPassword);
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+
+ if(!connToInternet) {
+
+ disableProcessButton();
+
+ } else {
+
+ createUserButton.setOnClickListener(createNewUserListener);
+
+ }
+
+ }
+
+ private void processCreateNewUser() {
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+ AppUtil appUtil = new AppUtil();
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+
+ String newFullName = fullName.getText().toString().trim();
+ String newUserName = userUserName.getText().toString().trim();
+ String newUserEmail = userEmail.getText().toString().trim();
+ String newUserPassword = userPassword.getText().toString();
+
+ if(!connToInternet) {
+
+ Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
+ return;
+
+ }
+
+ if(newFullName.equals("") || newUserName.equals("") | newUserEmail.equals("") || newUserPassword.equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.emptyFields));
+ return;
+
+ }
+
+ if(!appUtil.checkStrings(newFullName)) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.userInvalidFullName));
+ return;
+
+ }
+
+ if(!appUtil.checkStringsWithAlphaNumeric(newUserName)) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.userInvalidUserName));
+ return;
+
+ }
+
+ if(!Patterns.EMAIL_ADDRESS.matcher(newUserEmail).matches()) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.userInvalidEmail));
+ return;
+
+ }
+
+ disableProcessButton();
+ createNewUser(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), newFullName, newUserName, newUserEmail, newUserPassword);
+
+ }
+
+ private void createNewUser(final String instanceUrl, final String instanceToken, String newFullName, String newUserName, String newUserEmail, String newUserPassword) {
+
+ UserInfo createUser = new UserInfo(newUserEmail, newFullName, newUserName, newUserPassword, newUserName, 0, true);
+
+ Call call;
+
+ call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .createNewUser(instanceToken, createUser);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ if(response.code() == 201) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.userCreatedText));
+ enableProcessButton();
+ finish();
+
+ }
+ else if(response.code() == 401) {
+
+ enableProcessButton();
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else if(response.code() == 403) {
+
+ enableProcessButton();
+ Toasty.info(ctx, ctx.getString(R.string.authorizeError));
+
+ }
+ else if(response.code() == 404) {
+
+ enableProcessButton();
+ Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
+
+ }
+ else if(response.code() == 422) {
+
+ enableProcessButton();
+ Toasty.info(ctx, ctx.getString(R.string.userExistsError));
+
+ }
+ else {
+
+ enableProcessButton();
+ Toasty.info(getApplicationContext(), getString(R.string.genericError));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ enableProcessButton();
+ }
+ });
+
+ }
+
+ private View.OnClickListener createNewUserListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ processCreateNewUser();
+ }
+ };
+
+ private void initCloseListener() {
+ onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ };
+ }
+
+ private void disableProcessButton() {
+
+ createUserButton.setEnabled(false);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.hintColor));
+ createUserButton.setBackground(shape);
+
+ }
+
+ private void enableProcessButton() {
+
+ createUserButton.setEnabled(true);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.btnBackground));
+ createUserButton.setBackground(shape);
+
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/CreateReleaseActivity.java b/app/src/main/java/org/mian/gitnex/activities/CreateReleaseActivity.java
new file mode 100644
index 00000000..f1a6935f
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/CreateReleaseActivity.java
@@ -0,0 +1,310 @@
+package org.mian.gitnex.activities;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import retrofit2.Call;
+import retrofit2.Callback;
+import android.content.Context;
+import android.graphics.PorterDuff;
+import android.graphics.drawable.GradientDrawable;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.Spinner;
+import org.mian.gitnex.R;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.helpers.AlertDialogs;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.helpers.Toasty;
+import org.mian.gitnex.models.Branches;
+import org.mian.gitnex.models.Releases;
+import org.mian.gitnex.util.AppUtil;
+import org.mian.gitnex.util.TinyDB;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Author M M Arif
+ */
+
+public class CreateReleaseActivity extends AppCompatActivity {
+
+ private View.OnClickListener onClickListener;
+ public ImageView closeActivity;
+ private EditText releaseTagName;
+ private Spinner releaseBranch;
+ private EditText releaseTitle;
+ private EditText releaseContent;
+ private CheckBox releaseType;
+ private CheckBox releaseDraft;
+ private Button createNewRelease;
+ final Context ctx = this;
+
+ List branchesList = new ArrayList<>();
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_create_release);
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+
+ closeActivity = findViewById(R.id.close);
+ releaseTagName = findViewById(R.id.releaseTagName);
+ releaseTitle = findViewById(R.id.releaseTitle);
+ releaseContent = findViewById(R.id.releaseContent);
+ releaseType = findViewById(R.id.releaseType);
+ releaseDraft = findViewById(R.id.releaseDraft);
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+
+ releaseBranch = findViewById(R.id.releaseBranch);
+ releaseBranch.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
+ getBranches(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
+ releaseBranch.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView> parent, View view, int position, long id) {
+ Branches branch = (Branches) parent.getSelectedItem();
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> parent) {
+
+ }
+ });
+
+ createNewRelease = findViewById(R.id.createNewRelease);
+ disableProcessButton();
+
+ if(!connToInternet) {
+
+ disableProcessButton();
+
+ } else {
+
+ createNewRelease.setOnClickListener(createReleaseListener);
+
+ }
+
+ }
+
+ private View.OnClickListener createReleaseListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ processNewRelease();
+ }
+ };
+
+ private void processNewRelease() {
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+
+ String newReleaseTagName = releaseTagName.getText().toString();
+ String newReleaseTitle = releaseTitle.getText().toString();
+ String newReleaseContent = releaseContent.getText().toString();
+ String newReleaseBranch = releaseBranch.getSelectedItem().toString();
+ boolean newReleaseType = releaseType.isChecked();
+ boolean newReleaseDraft = releaseDraft.isChecked();
+
+ if(!connToInternet) {
+
+ Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
+ return;
+
+ }
+
+ if(newReleaseTagName.equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.tagNameErrorEmpty));
+ return;
+
+ }
+
+ if(newReleaseTitle.equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.titleErrorEmpty));
+ return;
+
+ }
+
+ disableProcessButton();
+ createNewReleaseFunc(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, newReleaseTagName, newReleaseTitle, newReleaseContent, newReleaseBranch, newReleaseType, newReleaseDraft);
+
+ }
+
+ private void createNewReleaseFunc(final String instanceUrl, final String token, String repoOwner, String repoName, String newReleaseTagName, String newReleaseTitle, String newReleaseContent, String newReleaseBranch, boolean newReleaseType, boolean newReleaseDraft) {
+
+ Releases createReleaseJson = new Releases(newReleaseContent, newReleaseDraft, newReleaseTitle, newReleaseType, newReleaseTagName, newReleaseBranch);
+
+ Call call;
+
+ call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .createNewRelease(token, repoOwner, repoName, createReleaseJson);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ if (response.code() == 201) {
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ tinyDb.putBoolean("updateReleases", true);
+ Toasty.info(getApplicationContext(), getString(R.string.releaseCreatedText));
+ enableProcessButton();
+ finish();
+
+ }
+ else if(response.code() == 401) {
+
+ enableProcessButton();
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else if(response.code() == 403) {
+
+ enableProcessButton();
+ Toasty.info(ctx, ctx.getString(R.string.authorizeError));
+
+ }
+ else if(response.code() == 404) {
+
+ enableProcessButton();
+ Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
+
+ }
+ else {
+
+ enableProcessButton();
+ Toasty.info(ctx, ctx.getString(R.string.genericError));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ enableProcessButton();
+ }
+ });
+
+ }
+
+ private void getBranches(String instanceUrl, String instanceToken, final String repoOwner, final String repoName) {
+
+ Call> call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getBranches(instanceToken, repoOwner, repoName);
+
+ call.enqueue(new Callback>() {
+
+ @Override
+ public void onResponse(@NonNull Call> call, @NonNull retrofit2.Response> response) {
+
+ if(response.isSuccessful()) {
+ if(response.code() == 200) {
+
+ List branchesList_ = response.body();
+
+ assert branchesList_ != null;
+ if(branchesList_.size() > 0) {
+ for (int i = 0; i < branchesList_.size(); i++) {
+
+ Branches data = new Branches(
+ branchesList_.get(i).getName()
+ );
+ branchesList.add(data);
+
+ }
+ }
+
+ ArrayAdapter adapter = new ArrayAdapter<>(getApplicationContext(),
+ R.layout.spinner_item, branchesList);
+
+ adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
+ releaseBranch.setAdapter(adapter);
+ enableProcessButton();
+
+ }
+ }
+ else if(response.code() == 401) {
+
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call> call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+ });
+
+ }
+
+ private void initCloseListener() {
+ onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ };
+ }
+
+ private void disableProcessButton() {
+
+ createNewRelease.setEnabled(false);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.hintColor));
+ createNewRelease.setBackground(shape);
+
+ }
+
+ private void enableProcessButton() {
+
+ createNewRelease.setEnabled(true);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.btnBackground));
+ createNewRelease.setBackground(shape);
+
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/CreateTeamByOrgActivity.java b/app/src/main/java/org/mian/gitnex/activities/CreateTeamByOrgActivity.java
new file mode 100644
index 00000000..339c7581
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/CreateTeamByOrgActivity.java
@@ -0,0 +1,378 @@
+package org.mian.gitnex.activities;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatActivity;
+import retrofit2.Call;
+import retrofit2.Callback;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.graphics.drawable.GradientDrawable;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+import org.mian.gitnex.R;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.helpers.AlertDialogs;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.helpers.Toasty;
+import org.mian.gitnex.models.Teams;
+import org.mian.gitnex.util.AppUtil;
+import org.mian.gitnex.util.TinyDB;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import android.util.Log;
+
+/**
+ * Author M M Arif
+ */
+
+public class CreateTeamByOrgActivity extends AppCompatActivity implements View.OnClickListener {
+
+ final Context ctx = CreateTeamByOrgActivity.this;
+ private View.OnClickListener onClickListener;
+ private TextView teamName;
+ private TextView teamDesc;
+ private TextView teamPermission;
+ private TextView teamPermissionDetail;
+ private TextView teamAccessControls;
+ private TextView teamAccessControlsArray;
+ private Button createTeamButton;
+ private String[] permissionList = {"Read", "Write", "Admin"};
+ public int permissionSelectedChoice = -1;
+
+ private String[] accessControlsList = new String[] {
+ "Code",
+ "Issues",
+ "Pull Request",
+ "Releases",
+ "Wiki",
+ "External Wiki",
+ "External Issues"
+ };
+
+ private List pushAccessList;
+
+ private boolean[] selectedAccessControlsTrueFalse = new boolean[]{
+ false,
+ false,
+ false,
+ false,
+ false,
+ false,
+ false
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_create_team_by_org);
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+
+ ImageView closeActivity = findViewById(R.id.close);
+ teamName = findViewById(R.id.teamName);
+ teamDesc = findViewById(R.id.teamDesc);
+ teamPermission = findViewById(R.id.teamPermission);
+ teamPermissionDetail = findViewById(R.id.teamPermissionDetail);
+ teamAccessControls = findViewById(R.id.teamAccessControls);
+ teamAccessControlsArray = findViewById(R.id.teamAccessControlsArray);
+ createTeamButton = findViewById(R.id.createTeamButton);
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+
+ teamPermission.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+
+ AlertDialog.Builder pBuilder = new AlertDialog.Builder(ctx, R.style.confirmDialog);
+
+ pBuilder.setTitle(R.string.newTeamPermission);
+ if(permissionSelectedChoice != -1) {
+ pBuilder.setCancelable(true);
+ }
+ else {
+ pBuilder.setCancelable(false);
+ }
+ pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+
+ permissionSelectedChoice = i;
+ teamPermission.setText(permissionList[i]);
+
+ if(permissionList[i].equals("Read")) {
+ teamPermissionDetail.setVisibility(View.VISIBLE);
+ teamPermissionDetail.setText(R.string.newTeamPermissionRead);
+ }
+ else if(permissionList[i].equals("Write")) {
+ teamPermissionDetail.setVisibility(View.VISIBLE);
+ teamPermissionDetail.setText(R.string.newTeamPermissionWrite);
+ }
+ else if(permissionList[i].equals("Admin")) {
+ teamPermissionDetail.setVisibility(View.VISIBLE);
+ teamPermissionDetail.setText(R.string.newTeamPermissionAdmin);
+ }
+ else {
+ teamPermissionDetail.setVisibility(View.GONE);
+ }
+
+ dialogInterface.dismiss();
+
+ }
+ });
+
+ AlertDialog pDialog = pBuilder.create();
+ pDialog.show();
+
+ }
+ });
+
+
+ teamAccessControls.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+
+ teamAccessControls.setText("");
+ teamAccessControlsArray.setText("");
+ pushAccessList = Arrays.asList(accessControlsList);
+
+ AlertDialog.Builder aDialogBuilder = new AlertDialog.Builder(ctx, R.style.confirmDialog);
+
+ aDialogBuilder.setMultiChoiceItems(accessControlsList, selectedAccessControlsTrueFalse, new DialogInterface.OnMultiChoiceClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which, boolean isChecked) {
+
+ }
+
+ })
+ .setCancelable(false)
+ .setTitle(R.string.newTeamAccessControls)
+ .setPositiveButton(R.string.okButton, new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+
+ int selectedVal = 0;
+ while(selectedVal < selectedAccessControlsTrueFalse.length)
+ {
+ boolean value = selectedAccessControlsTrueFalse[selectedVal];
+
+ String repoCode = "";
+ if(selectedVal == 0) {
+ repoCode = "repo.code";
+ }
+ if(selectedVal == 1) {
+ repoCode = "repo.issues";
+ }
+ if(selectedVal == 2) {
+ repoCode = "repo.pulls";
+ }
+ if(selectedVal == 3) {
+ repoCode = "repo.releases";
+ }
+ if(selectedVal == 4) {
+ repoCode = "repo.wiki";
+ }
+ if(selectedVal == 5) {
+ repoCode = "repo.ext_wiki";
+ }
+ if(selectedVal == 6) {
+ repoCode = "repo.ext_issues";
+ }
+
+ if(value){
+ teamAccessControls.setText(getString(R.string.newTeamPermissionValues, teamAccessControls.getText(), pushAccessList.get(selectedVal)));
+ teamAccessControlsArray.setText(getString(R.string.newTeamPermissionValuesFinal, teamAccessControlsArray.getText(), repoCode));
+ }
+
+ selectedVal++;
+ }
+
+ String data = String.valueOf(teamAccessControls.getText());
+ if(!data.equals("")) {
+ teamAccessControls.setText(data.substring(0, data.length() - 2));
+ }
+
+ String dataArray = String.valueOf(teamAccessControlsArray.getText());
+ if(!dataArray.equals("")) {
+ teamAccessControlsArray.setText(dataArray.substring(0, dataArray.length() - 2));
+ }
+ //Log.i("orgName", String.valueOf(teamAccessControlsArray.getText()));
+
+ }
+
+
+ });
+
+ AlertDialog aDialog = aDialogBuilder.create();
+ aDialog.show();
+ }
+ });
+
+ createTeamButton.setEnabled(false);
+
+ if(!connToInternet) {
+
+ createTeamButton.setEnabled(false);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.hintColor));
+ createTeamButton.setBackground(shape);
+
+ } else {
+
+ createTeamButton.setEnabled(true);
+ createTeamButton.setOnClickListener(this);
+
+ }
+
+ }
+
+ private void processCreateTeam() {
+
+ AppUtil appUtil = new AppUtil();
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+ final String orgName = tinyDb.getString("orgName");;
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+ String newTeamName = teamName.getText().toString();
+ String newTeamDesc = teamDesc.getText().toString();
+ String newTeamPermission = teamPermission.getText().toString().toLowerCase();
+ String newTeamAccessControls = teamAccessControlsArray.getText().toString();
+
+ if(!connToInternet) {
+
+ Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
+ return;
+
+ }
+
+ if (newTeamName.equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.teamNameEmpty));
+ return;
+
+ }
+
+ if(!appUtil.checkStringsWithAlphaNumericDashDotUnderscore(newTeamName)) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.teamNameError));
+ return;
+
+ }
+
+ if(!newTeamDesc.equals("")) {
+
+ if(!appUtil.checkStrings(newTeamDesc)) {
+ Toasty.info(getApplicationContext(), getString(R.string.teamDescError));
+ return;
+ }
+
+ if(newTeamDesc.length() > 100) {
+ Toasty.info(getApplicationContext(), getString(R.string.teamDescLimit));
+ return;
+ }
+
+ }
+
+ if (newTeamPermission.equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.teamPermissionEmpty));
+ return;
+
+ }
+
+ List newTeamAccessControls_ = new ArrayList<>(Arrays.asList(newTeamAccessControls.split(",")));
+
+ for (int i = 0; i < newTeamAccessControls_.size(); i++) {
+ newTeamAccessControls_.set(i, newTeamAccessControls_.get(i).trim());
+ }
+
+ createNewTeamCall(instanceUrl, instanceToken, orgName, newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls_, loginUid);
+
+ }
+
+ private void createNewTeamCall(final String instanceUrl, final String instanceToken, String orgName, String newTeamName, String newTeamDesc, String newTeamPermission, List newTeamAccessControls, String loginUid) {
+
+ Teams createNewTeamJson = new Teams(newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls);
+
+ Call call3;
+
+ call3 = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .createTeamsByOrg(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), orgName, createNewTeamJson);
+
+ call3.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response2) {
+
+ if(response2.isSuccessful()) {
+ if(response2.code() == 201) {
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ tinyDb.putBoolean("resumeTeams", true);
+
+ Toasty.info(getApplicationContext(), getString(R.string.teamCreated));
+ finish();
+
+ }
+
+ }
+ else if(response2.code() == 404) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.apiNotFound));
+
+ }
+ else if(response2.code() == 401) {
+
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else {
+
+ Toasty.info(getApplicationContext(), getString(R.string.teamCreatedError));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+ });
+
+ }
+
+ @Override
+ public void onClick(View v) {
+ if(v == createTeamButton) {
+ processCreateTeam();
+ }
+
+ }
+
+ private void initCloseListener() {
+ onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ };
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/CreditsActivity.java b/app/src/main/java/org/mian/gitnex/activities/CreditsActivity.java
new file mode 100644
index 00000000..37e3ebee
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/CreditsActivity.java
@@ -0,0 +1,43 @@
+package org.mian.gitnex.activities;
+
+import androidx.appcompat.app.AppCompatActivity;
+import android.os.Bundle;
+import android.text.method.LinkMovementMethod;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+import org.mian.gitnex.R;
+
+/**
+ * Author M M Arif
+ */
+
+public class CreditsActivity extends AppCompatActivity {
+
+ private View.OnClickListener onClickListener;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_credits);
+
+ TextView creditKasun = findViewById(R.id.creditKasun);
+ ImageView closeActivity = findViewById(R.id.close);
+
+ creditKasun.setMovementMethod(LinkMovementMethod.getInstance());
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+
+ }
+
+ private void initCloseListener() {
+ onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ };
+ }
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/EditIssueActivity.java b/app/src/main/java/org/mian/gitnex/activities/EditIssueActivity.java
new file mode 100644
index 00000000..4852754a
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/EditIssueActivity.java
@@ -0,0 +1,367 @@
+package org.mian.gitnex.activities;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+import android.annotation.SuppressLint;
+import android.app.DatePickerDialog;
+import android.content.Context;
+import android.graphics.drawable.GradientDrawable;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.DatePicker;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.Spinner;
+import android.widget.TextView;
+import com.google.gson.JsonElement;
+import com.hendraanggrian.appcompat.socialview.Mention;
+import com.hendraanggrian.appcompat.widget.MentionArrayAdapter;
+import com.hendraanggrian.appcompat.widget.SocialAutoCompleteTextView;
+import org.mian.gitnex.R;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.helpers.AlertDialogs;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.helpers.Toasty;
+import org.mian.gitnex.models.Collaborators;
+import org.mian.gitnex.models.CreateIssue;
+import org.mian.gitnex.models.Issues;
+import org.mian.gitnex.util.AppUtil;
+import org.mian.gitnex.util.TinyDB;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.List;
+
+/**
+ * Author M M Arif
+ */
+
+public class EditIssueActivity extends AppCompatActivity implements View.OnClickListener {
+
+ final Context ctx = this;
+ private View.OnClickListener onClickListener;
+
+ private EditText editIssueTitle;
+ private SocialAutoCompleteTextView editIssueDescription;
+ private TextView editIssueDueDate;
+ private Button editIssueButton;
+ private Spinner editIssueMilestoneSpinner;
+
+ private ArrayAdapter defaultMentionAdapter;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_edit_issue);
+
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+ final int issueIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
+
+ ImageView closeActivity = findViewById(R.id.close);
+ editIssueButton = findViewById(R.id.editIssueButton);
+ TextView toolbar_title = findViewById(R.id.toolbar_title);
+ editIssueTitle = findViewById(R.id.editIssueTitle);
+ editIssueDescription = findViewById(R.id.editIssueDescription);
+ editIssueDueDate = findViewById(R.id.editIssueDueDate);
+
+ defaultMentionAdapter = new MentionArrayAdapter<>(this);
+ loadCollaboratorsList();
+
+ editIssueDescription.setMentionAdapter(defaultMentionAdapter);
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+
+ editIssueDueDate.setOnClickListener(this);
+ editIssueButton.setOnClickListener(this);
+
+ if(!tinyDb.getString("issueNumber").isEmpty()) {
+ toolbar_title.setText(getString(R.string.editIssueNavHeader, String.valueOf(issueIndex)));
+ }
+
+ disableProcessButton();
+ getIssue(instanceUrl, instanceToken, loginUid, repoOwner, repoName, issueIndex);
+
+
+ }
+
+ public void loadCollaboratorsList() {
+
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+
+ Call> call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
+
+ call.enqueue(new Callback>() {
+
+ @Override
+ public void onResponse(@NonNull Call> call, @NonNull Response> response) {
+
+ if (response.isSuccessful()) {
+
+ assert response.body() != null;
+ String fullName = "";
+ for (int i = 0; i < response.body().size(); i++) {
+ if(!response.body().get(i).getFull_name().equals("")) {
+ fullName = response.body().get(i).getFull_name();
+ }
+ defaultMentionAdapter.add(
+ new Mention(response.body().get(i).getUsername(), fullName, response.body().get(i).getAvatar_url()));
+ }
+
+ } else {
+
+ Log.i("onResponse", String.valueOf(response.code()));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call> call, @NonNull Throwable t) {
+ Log.i("onFailure", t.getMessage());
+ }
+
+ });
+ }
+
+ private void initCloseListener() {
+ onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ };
+ }
+
+ private void processEditIssue() {
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+ final int issueIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
+
+
+ String editIssueTitleForm = editIssueTitle.getText().toString();
+ String editIssueDescriptionForm = editIssueDescription.getText().toString();
+ String editIssueDueDateForm = editIssueDueDate.getText().toString();
+
+ if(!connToInternet) {
+
+ Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
+ return;
+
+ }
+
+ if (editIssueTitleForm.equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.issueTitleEmpty));
+ return;
+
+ }
+
+ /*if (editIssueDescriptionForm.equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.issueDescriptionEmpty));
+ return;
+
+ }*/
+
+ if (editIssueDueDateForm.equals("")) {
+ editIssueDueDateForm = null;
+ } else {
+ editIssueDueDateForm = (AppUtil.customDateCombine(AppUtil.customDateFormat(editIssueDueDateForm)));
+ }
+
+ //Log.i("editIssueDueDateForm", String.valueOf(editIssueDueDateForm));
+ disableProcessButton();
+ editIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid, editIssueTitleForm, editIssueDescriptionForm, editIssueDueDateForm);
+
+ }
+
+ private void editIssue(String instanceUrl, String instanceToken, String repoOwner, String repoName, int issueIndex, String loginUid, String title, String description, String dueDate) {
+
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+
+ CreateIssue issueData = new CreateIssue(title, description, dueDate);
+
+ Call call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .patchIssue(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, issueData);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ if(response.code() == 201) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.editIssueSuccessMessage));
+ tinyDb.putBoolean("issueEdited", true);
+ tinyDb.putBoolean("resumeIssues", true);
+ finish();
+
+ }
+ else if(response.code() == 401) {
+
+ enableProcessButton();
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else {
+
+ enableProcessButton();
+ Toasty.info(getApplicationContext(), getString(R.string.genericError));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ enableProcessButton();
+ }
+ });
+
+ }
+
+
+ @Override
+ public void onClick(View v) {
+
+ if (v == editIssueDueDate) {
+
+ final Calendar c = Calendar.getInstance();
+ int mYear = c.get(Calendar.YEAR);
+ final int mMonth = c.get(Calendar.MONTH);
+ final int mDay = c.get(Calendar.DAY_OF_MONTH);
+
+ DatePickerDialog datePickerDialog = new DatePickerDialog(this,
+ new DatePickerDialog.OnDateSetListener() {
+
+ @Override
+ public void onDateSet(DatePicker view, int year,
+ int monthOfYear, int dayOfMonth) {
+
+ editIssueDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth));
+
+ }
+ }, mYear, mMonth, mDay);
+ datePickerDialog.show();
+
+ }
+ else if(v == editIssueButton) {
+ processEditIssue();
+ }
+
+ }
+
+ private void getIssue(String instanceUrl, String instanceToken, String loginUid, String repoOwner, String repoName, int issueIndex) {
+
+ Call call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getIssueByIndex(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ if(response.code() == 200) {
+
+ assert response.body() != null;
+ editIssueTitle.setText(response.body().getTitle());
+ editIssueDescription.setText(response.body().getBody());
+
+ if(response.body().getDue_date() != null) {
+
+ @SuppressLint("SimpleDateFormat") DateFormat formatter = new SimpleDateFormat("yyyy-M-dd");
+ String dueDate = formatter.format(response.body().getDue_date());
+ editIssueDueDate.setText(dueDate);
+
+ }
+ enableProcessButton();
+
+ }
+ else if(response.code() == 401) {
+
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else {
+
+ Toasty.info(getApplicationContext(), getString(R.string.genericError));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+ });
+
+ }
+
+ private void disableProcessButton() {
+
+ editIssueButton.setEnabled(false);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.hintColor));
+ editIssueButton.setBackground(shape);
+
+ }
+
+ private void enableProcessButton() {
+
+ editIssueButton.setEnabled(true);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.btnBackground));
+ editIssueButton.setBackground(shape);
+
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java b/app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java
new file mode 100644
index 00000000..c6a2ae11
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java
@@ -0,0 +1,501 @@
+package org.mian.gitnex.activities;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+import androidx.lifecycle.Observer;
+import androidx.lifecycle.ViewModelProviders;
+import androidx.recyclerview.widget.DividerItemDecoration;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
+import okhttp3.OkHttpClient;
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+import ru.noties.markwon.AbstractMarkwonPlugin;
+import ru.noties.markwon.Markwon;
+import ru.noties.markwon.core.CorePlugin;
+import ru.noties.markwon.core.MarkwonTheme;
+import ru.noties.markwon.ext.strikethrough.StrikethroughPlugin;
+import ru.noties.markwon.ext.tables.TablePlugin;
+import ru.noties.markwon.ext.tasklist.TaskListPlugin;
+import ru.noties.markwon.html.HtmlPlugin;
+import ru.noties.markwon.image.ImagesPlugin;
+import ru.noties.markwon.image.gif.GifPlugin;
+import ru.noties.markwon.image.okhttp.OkHttpImagesPlugin;
+import android.content.Context;
+import android.graphics.Color;
+import android.graphics.Typeface;
+import android.os.Bundle;
+import android.os.Handler;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.HorizontalScrollView;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.ScrollView;
+import android.widget.TextView;
+import com.amulyakhare.textdrawable.TextDrawable;
+import com.squareup.picasso.Picasso;
+import com.vdurmont.emoji.EmojiParser;
+import org.mian.gitnex.R;
+import org.mian.gitnex.adapters.IssueCommentsAdapter;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.fragments.SingleIssueBottomSheetFragment;
+import org.mian.gitnex.helpers.AlertDialogs;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.helpers.TimeHelper;
+import org.mian.gitnex.helpers.UserMentions;
+import org.mian.gitnex.models.IssueComments;
+import org.mian.gitnex.models.Issues;
+import org.mian.gitnex.helpers.ColorInverter;
+import org.mian.gitnex.helpers.RoundedTransformation;
+import org.mian.gitnex.util.TinyDB;
+import org.mian.gitnex.helpers.ClickListener;
+import org.mian.gitnex.viewmodels.IssueCommentsViewModel;
+import org.ocpsoft.prettytime.PrettyTime;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.List;
+import java.util.Locale;
+import java.util.Objects;
+
+/**
+ * Author M M Arif
+ */
+
+public class IssueDetailActivity extends AppCompatActivity {
+
+ public ImageView closeActivity;
+ private View.OnClickListener onClickListener;
+ private IssueCommentsAdapter adapter;
+ private RecyclerView mRecyclerView;
+ private ImageView assigneeAvatar;
+ private TextView issueTitle;
+ private TextView issueDescription;
+ private TextView issueMilestone;
+ private TextView issueDueDate;
+ private TextView issueCreatedTime;
+ private HorizontalScrollView labelsScrollView;
+ private HorizontalScrollView assigneesScrollView;
+ private ScrollView scrollViewComments;
+ private TextView issueModified;
+ final Context ctx = this;
+ private LinearLayout labelsLayout;
+ private LinearLayout assigneesLayout;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_issue_detail);
+
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+ final int issueIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
+
+ final SwipeRefreshLayout swipeRefresh = findViewById(R.id.pullToRefresh);
+
+ closeActivity = findViewById(R.id.close);
+ assigneeAvatar = findViewById(R.id.assigneeAvatar);
+ issueTitle = findViewById(R.id.issueTitle);
+ issueDescription = findViewById(R.id.issueDescription);
+ issueMilestone = findViewById(R.id.issueMilestone);
+ issueDueDate = findViewById(R.id.issueDueDate);
+ issueCreatedTime = findViewById(R.id.issueCreatedTime);
+ labelsScrollView = findViewById(R.id.labelsScrollView);
+ assigneesScrollView = findViewById(R.id.assigneesScrollView);
+ scrollViewComments = findViewById(R.id.scrollViewComments);
+ issueModified = findViewById(R.id.issueModified);
+ labelsLayout = findViewById(R.id.frameLabels);
+ assigneesLayout = findViewById(R.id.frameAssignees);
+
+ Toolbar toolbar = findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+ Objects.requireNonNull(getSupportActionBar()).setTitle(repoName);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(false);
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+
+ mRecyclerView = findViewById(R.id.recyclerView);
+ mRecyclerView.setHasFixedSize(true);
+ mRecyclerView.setNestedScrollingEnabled(false);
+ mRecyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
+
+ DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
+ DividerItemDecoration.VERTICAL);
+ mRecyclerView.addItemDecoration(dividerItemDecoration);
+
+ swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+ @Override
+ public void onRefresh() {
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ swipeRefresh.setRefreshing(false);
+ IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
+ }
+ }, 500);
+ }
+ });
+
+ getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
+ fetchDataAsync(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.generic_nav_dotted_menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ int id = item.getItemId();
+
+ switch (id) {
+ case android.R.id.home:
+ finish();
+ return true;
+ case R.id.genericMenu:
+ SingleIssueBottomSheetFragment bottomSheet = new SingleIssueBottomSheetFragment();
+ bottomSheet.show(getSupportFragmentManager(), "singleIssueBottomSheet");
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+ final int issueIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
+
+ if(tinyDb.getBoolean("commentPosted")) {
+ scrollViewComments.post(new Runnable() {
+ @Override
+ public void run() {
+ IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
+
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ scrollViewComments.fullScroll(ScrollView.FOCUS_DOWN);
+ }
+ }, 1000);
+
+ tinyDb.putBoolean("commentPosted", false);
+ }
+ });
+ }
+
+ if(tinyDb.getBoolean("commentEdited")) {
+ scrollViewComments.post(new Runnable() {
+ @Override
+ public void run() {
+ IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
+ tinyDb.putBoolean("commentEdited", false);
+ }
+ });
+ }
+
+ if(tinyDb.getBoolean("singleIssueUpdate")) {
+
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ assigneesLayout.removeAllViews();
+ labelsLayout.removeAllViews();
+ getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
+ tinyDb.putBoolean("singleIssueUpdate", false);
+ }
+ }, 500);
+
+ }
+
+ if(tinyDb.getBoolean("issueEdited")) {
+
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ assigneesLayout.removeAllViews();
+ labelsLayout.removeAllViews();
+ getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
+ tinyDb.putBoolean("issueEdited", false);
+ }
+ }, 500);
+
+ }
+
+ }
+
+ private void fetchDataAsync(String instanceUrl, String instanceToken, String owner, String repo, int index, String loginUid) {
+
+ IssueCommentsViewModel issueCommentsModel = ViewModelProviders.of(this).get(IssueCommentsViewModel.class);
+
+ issueCommentsModel.getIssueCommentList(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), owner, repo, index).observe(this, new Observer>() {
+ @Override
+ public void onChanged(@Nullable List issueCommentsMain) {
+ adapter = new IssueCommentsAdapter(getApplicationContext(), issueCommentsMain);
+ mRecyclerView.setAdapter(adapter);
+ }
+ });
+
+ }
+
+ private void getSingleIssue(String instanceUrl, String instanceToken, String repoOwner, String repoName, int issueIndex, String loginUid) {
+
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+ Call call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getIssueByIndex(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull Response response) {
+
+ if (response.isSuccessful()) {
+ if (response.code() == 200) {
+
+ Issues singleIssue = response.body();
+ assert singleIssue != null;
+
+ final Markwon markwon = Markwon.builder(Objects.requireNonNull(getApplicationContext()))
+ .usePlugin(CorePlugin.create())
+ .usePlugin(OkHttpImagesPlugin.create(new OkHttpClient()))
+ .usePlugin(ImagesPlugin.createWithAssets(getApplicationContext()))
+ .usePlugin(new AbstractMarkwonPlugin() {
+ @Override
+ public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
+ builder
+ .codeTextColor(tinyDb.getInt("codeBlockColor"))
+ .codeBackgroundColor(tinyDb.getInt("codeBlockBackground"))
+ .linkColor(getApplicationContext().getResources().getColor(R.color.lightBlue));
+ }
+ })
+ .usePlugin(TablePlugin.create(getApplicationContext()))
+ .usePlugin(TaskListPlugin.create(getApplicationContext()))
+ .usePlugin(HtmlPlugin.create())
+ .usePlugin(GifPlugin.create())
+ .usePlugin(StrikethroughPlugin.create())
+ .build();
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String locale = tinyDb.getString("locale");
+ final String timeFormat = tinyDb.getString("dateFormat");
+ tinyDb.putString("issueState", singleIssue.getState());
+ tinyDb.putString("issueTitle", singleIssue.getTitle());
+
+ Picasso.get().load(singleIssue.getUser().getAvatar_url()).transform(new RoundedTransformation(100, 0)).resize(200, 200).centerCrop().into(assigneeAvatar);
+ issueTitle.setText(getString(R.string.issueTitleWithId, singleIssue.getNumber(), singleIssue.getTitle()));
+ String cleanIssueDescription = singleIssue.getBody().trim();
+ final CharSequence bodyWithMD = markwon.toMarkdown(EmojiParser.parseToUnicode(cleanIssueDescription));
+ issueDescription.setText(UserMentions.UserMentionsFunc(getApplicationContext(), bodyWithMD, cleanIssueDescription));
+
+ RelativeLayout.LayoutParams paramsDesc = (RelativeLayout.LayoutParams)issueDescription.getLayoutParams();
+
+ LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(80, 80);
+ params1.setMargins(15, 0, 0, 0);
+
+ if(singleIssue.getAssignees() != null) {
+ assigneesScrollView.setVisibility(View.VISIBLE);
+ for (int i = 0; i < singleIssue.getAssignees().size(); i++) {
+
+ ImageView assigneesView = new ImageView(getApplicationContext());
+
+ Picasso.get().load(singleIssue.getAssignees().get(i).getAvatar_url()).transform(new RoundedTransformation(100, 0)).resize(80, 80).centerCrop().into(assigneesView);
+
+ assigneesLayout.addView(assigneesView);
+ assigneesView.setLayoutParams(params1);
+ if (!singleIssue.getAssignees().get(i).getFull_name().equals("")) {
+ assigneesView.setOnClickListener(new ClickListener(getString(R.string.assignedTo, singleIssue.getAssignees().get(i).getFull_name()), getApplicationContext()));
+ } else {
+ assigneesView.setOnClickListener(new ClickListener(getString(R.string.assignedTo, singleIssue.getAssignees().get(i).getLogin()), getApplicationContext()));
+ }
+
+ }
+ }
+ else {
+ assigneesScrollView.setVisibility(View.GONE);
+ }
+
+ LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+ params.setMargins(0, 0, 15, 0);
+
+ if(singleIssue.getLabels() != null) {
+ labelsScrollView.setVisibility(View.VISIBLE);
+ int width = 33;
+ for (int i = 0; i < singleIssue.getLabels().size(); i++) {
+
+ String labelColor = singleIssue.getLabels().get(i).getColor();
+ String labelName = singleIssue.getLabels().get(i).getName();
+ int color = Color.parseColor("#" + labelColor);
+
+ ImageView labelsView = new ImageView(getApplicationContext());
+ labelsLayout.setOrientation(LinearLayout.HORIZONTAL);
+ labelsLayout.setGravity(Gravity.START | Gravity.TOP);
+ labelsView.setLayoutParams(params);
+
+ TextDrawable drawable = TextDrawable.builder()
+ .beginConfig()
+ .useFont(Typeface.DEFAULT)
+ .textColor(new ColorInverter().getContrastColor(color))
+ .fontSize(36)
+ .width((width * labelName.length()) - ((width / 4) * labelName.length()))
+ .height(60)
+ .endConfig()
+ .buildRoundRect(labelName, color, 8);
+ labelsView.setImageDrawable(drawable);
+
+ labelsLayout.addView(labelsView);
+
+ }
+ }
+ else {
+ labelsScrollView.setVisibility(View.GONE);
+ }
+
+ if(singleIssue.getDue_date() != null) {
+
+ if (timeFormat.equals("normal") || timeFormat.equals("pretty")) {
+ DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", new Locale(locale));
+ String dueDate = formatter.format(singleIssue.getDue_date());
+ issueDueDate.setText(getString(R.string.dueDate, dueDate));
+ issueDueDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getDue_date()), getApplicationContext()));
+ } else if (timeFormat.equals("normal1")) {
+ DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", new Locale(locale));
+ String dueDate = formatter.format(singleIssue.getDue_date());
+ issueDueDate.setText(getString(R.string.dueDate, dueDate));
+ }
+
+ }
+ else {
+
+ issueDueDate.setVisibility(View.GONE);
+ }
+
+ String edited;
+
+ if(!singleIssue.getUpdated_at().equals(singleIssue.getCreated_at())) {
+ edited = getString(R.string.colorfulBulletSpan) + getString(R.string.modifiedText);
+ issueModified.setVisibility(View.VISIBLE);
+ issueModified.setText(edited);
+ issueModified.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getUpdated_at()), ctx));
+ }
+ else {
+ issueModified.setVisibility(View.INVISIBLE);
+ }
+
+ if((singleIssue.getDue_date() == null && singleIssue.getMilestone() == null) && singleIssue.getAssignees() != null) {
+ paramsDesc.setMargins(0, 35, 0, 0);
+ issueDescription.setLayoutParams(paramsDesc);
+ }
+ else if(singleIssue.getDue_date() == null && singleIssue.getMilestone() == null) {
+ paramsDesc.setMargins(0, 55, 0, 0);
+ issueDescription.setLayoutParams(paramsDesc);
+ }
+ else if(singleIssue.getAssignees() == null) {
+ paramsDesc.setMargins(0, 35, 0, 0);
+ issueDescription.setLayoutParams(paramsDesc);
+ }
+ else {
+ paramsDesc.setMargins(0, 15, 0, 0);
+ issueDescription.setLayoutParams(paramsDesc);
+ }
+
+ switch (timeFormat) {
+ case "pretty": {
+ PrettyTime prettyTime = new PrettyTime(new Locale(locale));
+ String createdTime = prettyTime.format(singleIssue.getCreated_at());
+ issueCreatedTime.setText(getString(R.string.createdTime, createdTime));
+ issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getCreated_at()), getApplicationContext()));
+ break;
+ }
+ case "normal": {
+ DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
+ String createdTime = formatter.format(singleIssue.getCreated_at());
+ issueCreatedTime.setText(getString(R.string.createdTime, createdTime));
+ break;
+ }
+ case "normal1": {
+ DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
+ String createdTime = formatter.format(singleIssue.getCreated_at());
+ issueCreatedTime.setText(getString(R.string.createdTime, createdTime));
+ break;
+ }
+ }
+
+ if(singleIssue.getMilestone() != null) {
+ issueMilestone.setText(getString(R.string.issueMilestone, singleIssue.getMilestone().getTitle()));
+ }
+ else {
+ issueMilestone.setVisibility(View.GONE);
+ }
+
+ if (!singleIssue.getUser().getFull_name().equals("")) {
+ assigneeAvatar.setOnClickListener(new ClickListener(getApplicationContext().getResources().getString(R.string.issueCreator) + singleIssue.getUser().getFull_name(), getApplicationContext()));
+ } else {
+ assigneeAvatar.setOnClickListener(new ClickListener(getApplicationContext().getResources().getString(R.string.issueCreator) + singleIssue.getUser().getLogin(), getApplicationContext()));
+ }
+
+ }
+
+ }
+ else if(response.code() == 401) {
+
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+ });
+
+ }
+
+ private void initCloseListener() {
+ onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ };
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java b/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
new file mode 100644
index 00000000..9974ad53
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
@@ -0,0 +1,436 @@
+package org.mian.gitnex.activities;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import android.content.res.Resources;
+import android.graphics.drawable.GradientDrawable;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.Spinner;
+import android.widget.TextView;
+import com.tooltip.Tooltip;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.helpers.Toasty;
+import org.mian.gitnex.models.UserTokens;
+import org.mian.gitnex.util.AppUtil;
+import org.mian.gitnex.R;
+import org.mian.gitnex.util.TinyDB;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+import java.util.Objects;
+import okhttp3.Credentials;
+import okhttp3.Headers;
+import retrofit2.Call;
+import retrofit2.Callback;
+
+/**
+ * Author M M Arif
+ */
+
+public class LoginActivity extends AppCompatActivity implements View.OnClickListener {
+
+ private Button login_button;
+ private EditText instance_url, login_uid, login_passwd, otpCode;
+ private Spinner protocolSpinner;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_login);
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+
+ login_button = findViewById(R.id.login_button);
+ instance_url = findViewById(R.id.instance_url);
+ login_uid = findViewById(R.id.login_uid);
+ login_passwd = findViewById(R.id.login_passwd);
+ otpCode = findViewById(R.id.otpCode);
+ ImageView info_button = findViewById(R.id.info);
+ final TextView viewTextGiteaVersion = findViewById(R.id.appVersion);
+ protocolSpinner = findViewById(R.id.httpsSpinner);
+
+ viewTextGiteaVersion.setText(AppUtil.getAppVersion(getApplicationContext()));
+
+ Resources res = getResources();
+ String[] allProtocols = res.getStringArray(R.array.protocolValues);
+
+ final ArrayAdapter adapterProtocols = new ArrayAdapter(Objects.requireNonNull(getApplicationContext()),
+ R.layout.spinner_item, allProtocols);
+
+ adapterProtocols.setDropDownViewResource(R.layout.spinner_dropdown_item);
+ protocolSpinner.setAdapter(adapterProtocols);
+
+ protocolSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ public void onItemSelected(AdapterView> parent, View view, int pos, long id) {
+
+ String value = getResources().getStringArray(R.array.protocolValues)[pos];
+ if(value.toLowerCase().equals("http")) {
+ Toasty.info(getApplicationContext(), getResources().getString(R.string.protocolError));
+ }
+
+ }
+ public void onNothingSelected(AdapterView> parent) {
+ }
+ });
+
+ info_button.setOnClickListener(infoListener);
+
+ if(!connToInternet) {
+
+ Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
+ return;
+
+ }
+
+ //login_button.setOnClickListener(this);
+ if(!tinyDb.getString("instanceUrlRaw").isEmpty()) {
+ instance_url.setText(tinyDb.getString("instanceUrlRaw"));
+ }
+ if(!tinyDb.getString("loginUid").isEmpty()) {
+ login_uid.setText(tinyDb.getString("loginUid"));
+ }
+
+ if(tinyDb.getBoolean("loggedInMode")) {
+
+ startActivity(new Intent(LoginActivity.this, MainActivity.class));
+ finish();
+
+ }
+
+ login_button.setOnClickListener(loginListener);
+
+ }
+
+ @Override
+ public void onClick(View v) {
+
+ switch(v.getId()) {
+
+ case R.id.login_button:
+ login();
+ break;
+ default:
+
+ }
+
+ }
+
+ private View.OnClickListener loginListener = new View.OnClickListener() {
+ public void onClick(View v) {
+
+ disableProcessButton();
+ login_button.setText(R.string.processingText);
+ login();
+
+ }
+ };
+
+ private View.OnClickListener infoListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ new Tooltip.Builder(v)
+ .setText(R.string.urlInfoTooltip)
+ .setTextColor(getResources().getColor(R.color.white))
+ .setBackgroundColor(getResources().getColor(R.color.tooltipBackground))
+ .setCancelable(true)
+ .setDismissOnClick(true)
+ .setPadding(30)
+ .setCornerRadius(R.dimen.tooltipCornor)
+ .setGravity(Gravity.BOTTOM)
+ .show();
+ }
+ };
+
+ @SuppressLint("ResourceAsColor")
+ private void login() {
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ AppUtil appUtil = new AppUtil();
+ boolean connToInternet = AppUtil.haveNetworkConnection(LoginActivity.this);
+
+ String instanceUrl = instance_url.getText().toString().trim();
+ String loginUid = login_uid.getText().toString();
+ String loginPass = login_passwd.getText().toString();
+ String protocol = protocolSpinner.getSelectedItem().toString();
+ String loginOTP_ = otpCode.getText().toString().trim();
+
+ if(instanceUrl.contains("@")) {
+
+ String[] urlForHttpAuth = instanceUrl.split("@");
+
+ tinyDb.putString("basicAuthPassword", loginPass);
+ tinyDb.putBoolean("basicAuthFlag", true);
+
+ instanceUrl = urlForHttpAuth[1];
+ loginUid = urlForHttpAuth[0];
+
+ }
+
+ String instanceHost;
+ if(AppUtil.httpCheck(instanceUrl)) {
+
+ URI uri = null;
+ try {
+ uri = new URI(instanceUrl);
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+ assert uri != null;
+ instanceHost = uri.getHost();
+
+ }
+ else {
+ instanceHost = instanceUrl;
+ }
+
+ if(protocol.toLowerCase().equals("https")) {
+ instanceUrl = "https://" + instanceHost + "/api/v1/";
+ }
+ else {
+ instanceUrl = "http://" + instanceHost + "/api/v1/";
+ }
+
+ tinyDb.putString("instanceUrlRaw", instanceHost);
+ tinyDb.putString("loginUid", loginUid);
+ tinyDb.putString("instanceUrl", instanceUrl);
+
+ if(connToInternet) {
+
+ if(instance_url.getText().toString().equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.emptyFieldURL));
+ enableProcessButton();
+ login_button.setText(R.string.btnLogin);
+ return;
+
+ }
+ if(loginUid.equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.emptyFieldUsername));
+ enableProcessButton();
+ login_button.setText(R.string.btnLogin);
+ return;
+
+ }
+ if(login_passwd.getText().toString().equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.emptyFieldPassword));
+ enableProcessButton();
+ login_button.setText(R.string.btnLogin);
+ return;
+
+ }
+
+ int loginOTP = 0;
+ if(loginOTP_.length() == 6) {
+
+ if(appUtil.checkIntegers(loginOTP_)) {
+
+ loginOTP = Integer.valueOf(loginOTP_);
+ }
+ else {
+
+ Toasty.info(getApplicationContext(), getString(R.string.loginOTPTypeError));
+ enableProcessButton();
+ login_button.setText(R.string.btnLogin);
+ return;
+
+ }
+
+ }
+
+ letTheUserIn(instanceUrl, loginUid, loginPass, loginOTP);
+
+ }
+ else {
+
+ Toasty.info(getApplicationContext(), getString(R.string.checkNetConnection));
+
+ }
+
+ }
+
+ private void letTheUserIn(final String instanceUrl, final String loginUid, final String loginPass, final int loginOTP) {
+
+ final String credential = Credentials.basic(loginUid, loginPass);
+
+ Call> call;
+ if(loginOTP != 0) {
+ call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getUserTokensWithOTP(credential, loginOTP, loginUid);
+ }
+ else {
+ call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getUserTokens(credential, loginUid);
+ }
+
+ call.enqueue(new Callback>() {
+
+ @Override
+ public void onResponse(@NonNull Call> call, @NonNull retrofit2.Response> response) {
+
+ List userTokens = response.body();
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+ Headers responseHeaders = response.headers();
+
+ if (response.isSuccessful()) {
+
+ if (response.code() == 200) {
+
+ boolean setTokenFlag = false;
+
+ assert userTokens != null;
+ if (userTokens.size() > 0) {
+ for (int i = 0; i < userTokens.size(); i++) {
+ if (userTokens.get(i).getSha1().equals(tinyDb.getString(loginUid + "-token"))) {
+ setTokenFlag = true;
+ break;
+ }
+ //Log.i("Tokens: ", userTokens.get(i).getSha1());
+ }
+ }
+
+ if(tinyDb.getString(loginUid + "-token").isEmpty() || !setTokenFlag) {
+
+ UserTokens createUserToken = new UserTokens("gitnex-app-token");
+
+ Call callCreateToken;
+ if(loginOTP != 0) {
+ callCreateToken = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .createNewTokenWithOTP(credential, loginOTP, loginUid, createUserToken);
+ }
+ else {
+ callCreateToken = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .createNewToken(credential, loginUid, createUserToken);
+ }
+
+ callCreateToken.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call callCreateToken, @NonNull retrofit2.Response responseCreate) {
+
+ if (responseCreate.isSuccessful()) {
+
+ if(responseCreate.code() == 201) {
+
+ UserTokens newToken = responseCreate.body();
+ assert newToken != null;
+ //Log.i("Tokens-NEW", "new:" + newToken.getSha1());
+
+ if (!newToken.getSha1().equals("")) {
+
+ tinyDb.remove("loginPass");
+ tinyDb.putBoolean("loggedInMode", true);
+ tinyDb.putString(loginUid + "-token", newToken.getSha1());
+ //Log.i("Tokens", "new:" + newToken.getSha1() + " old:" + tinyDb.getString(loginUid + "-token"));
+
+ startActivity(new Intent(LoginActivity.this, MainActivity.class));
+ finish();
+
+ }
+
+ }
+
+ }
+ else if(responseCreate.code() == 500) {
+
+ String toastError = getResources().getString(R.string.genericApiStatusError) + String.valueOf(responseCreate.code());
+ Toasty.info(getApplicationContext(), toastError);
+ enableProcessButton();
+ login_button.setText(R.string.btnLogin);
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call createUserToken, Throwable t) {
+
+ }
+
+ });
+ }
+ else {
+
+ //Log.i("Current Token", tinyDb.getString(loginUid + "-token"));
+ tinyDb.putBoolean("loggedInMode", true);
+ startActivity(new Intent(LoginActivity.this, MainActivity.class));
+ finish();
+
+ }
+
+ }
+
+ }
+ else if(response.code() == 500) {
+
+ String toastError = getResources().getString(R.string.genericApiStatusError) + String.valueOf(response.code());
+ Toasty.info(getApplicationContext(), toastError);
+ enableProcessButton();
+ login_button.setText(R.string.btnLogin);
+
+ }
+ else {
+
+ String toastError = getResources().getString(R.string.genericApiStatusError) + String.valueOf(response.code());
+ //Log.i("error message else4", String.valueOf(response.code()));
+
+ Toasty.info(getApplicationContext(), toastError);
+ enableProcessButton();
+ login_button.setText(R.string.btnLogin);
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call> call, @NonNull Throwable t) {
+ Log.e("onFailure-login", t.toString());
+ Toasty.info(getApplicationContext(), getResources().getString(R.string.malformedJson));
+ enableProcessButton();
+ login_button.setText(R.string.btnLogin);
+ }
+ });
+
+ }
+
+ private void disableProcessButton() {
+
+ login_button.setEnabled(false);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.hintColor));
+ login_button.setBackground(shape);
+
+ }
+
+ private void enableProcessButton() {
+
+ login_button.setEnabled(true);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.btnBackground));
+ login_button.setBackground(shape);
+
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/MainActivity.java b/app/src/main/java/org/mian/gitnex/activities/MainActivity.java
new file mode 100644
index 00000000..8dfba64f
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/MainActivity.java
@@ -0,0 +1,411 @@
+package org.mian.gitnex.activities;
+
+import android.content.ActivityNotFoundException;
+import android.content.Context;
+import android.content.Intent;
+import androidx.annotation.NonNull;
+import com.google.android.material.navigation.NavigationView;
+import androidx.core.view.GravityCompat;
+import androidx.drawerlayout.widget.DrawerLayout;
+import androidx.appcompat.app.ActionBarDrawerToggle;
+import androidx.appcompat.app.AppCompatActivity;
+import android.net.Uri;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+import com.squareup.picasso.NetworkPolicy;
+import com.squareup.picasso.Picasso;
+import org.mian.gitnex.R;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.fragments.AboutFragment;
+import org.mian.gitnex.fragments.MyRepositoriesFragment;
+import org.mian.gitnex.fragments.NavSubMenuBottomSheetFragment;
+import org.mian.gitnex.fragments.OrganizationsFragment;
+import org.mian.gitnex.fragments.SettingsFragment;
+import org.mian.gitnex.fragments.StarredRepositoriesFragment;
+import org.mian.gitnex.helpers.AlertDialogs;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.helpers.Toasty;
+import org.mian.gitnex.models.UserInfo;
+import org.mian.gitnex.util.AppUtil;
+import org.mian.gitnex.helpers.RoundedTransformation;
+import org.mian.gitnex.util.TinyDB;
+import org.mian.gitnex.fragments.ProfileFragment;
+import org.mian.gitnex.fragments.RepositoriesFragment;
+import java.util.Objects;
+import retrofit2.Call;
+import retrofit2.Callback;
+
+/**
+ * Author M M Arif
+ */
+
+public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
+
+ private DrawerLayout drawer;
+ private TextView userFullName;
+ private TextView userEmail;
+ private ImageView userAvatar;
+ final Context ctx = this;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+ tinyDb.putBoolean("noConnection", false);
+ //userAvatar = findViewById(R.id.userAvatar);
+
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+
+ if(tinyDb.getString("dateFormat").isEmpty()) {
+ tinyDb.putString("dateFormat", "pretty");
+ }
+
+ if(tinyDb.getString("codeBlockStr").isEmpty()) {
+ tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorLightGreen));
+ tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
+ }
+
+ if(tinyDb.getString("enableCounterIssueBadgeInit").isEmpty()) {
+ tinyDb.putBoolean("enableCounterIssueBadge", true);
+ }
+
+ if(tinyDb.getString("homeScreenStr").isEmpty()) {
+ tinyDb.putInt("homeScreenId", 0);
+ }
+
+ String appLocale = tinyDb.getString("locale");
+ AppUtil.setAppLocale(getResources(), appLocale);
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ if(!tinyDb.getBoolean("loggedInMode")) {
+ logout();
+ return;
+ }
+
+ androidx.appcompat.widget.Toolbar toolbar = findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ drawer = findViewById(R.id.drawer_layout);
+ NavigationView navigationView = findViewById(R.id.nav_view);
+ navigationView.setNavigationItemSelectedListener(this);
+ final View hView = navigationView.getHeaderView(0);
+
+ ImageView navSubMenu = hView.findViewById(R.id.navSubMenu);
+ navSubMenu.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ NavSubMenuBottomSheetFragment bottomSheet = new NavSubMenuBottomSheetFragment();
+ bottomSheet.show(getSupportFragmentManager(), "adminMenuBottomSheet");
+ }
+ });
+
+ ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
+ R.string.navigation_drawer_open, R.string.navigation_drawer_close);
+ toggle.getDrawerArrowDrawable().setColor(getResources().getColor(R.color.white));
+ drawer.addDrawerListener(toggle);
+
+ drawer.addDrawerListener(new DrawerLayout.DrawerListener() {
+
+ @Override
+ public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
+
+ }
+
+ @Override
+ public void onDrawerOpened(@NonNull View drawerView) {
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+ if(!connToInternet) {
+
+ if(!tinyDb.getBoolean("noConnection")) {
+ Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
+ }
+
+ tinyDb.putBoolean("noConnection", true);
+
+ String userEmailNav = tinyDb.getString("userEmail");
+ String userFullNameNav = tinyDb.getString("userFullname");
+ String userAvatarNav = tinyDb.getString("userAvatar");
+
+ userEmail = hView.findViewById(R.id.userEmail);
+ if (!userEmailNav.equals("")) {
+ userEmail.setText(userEmailNav);
+ }
+
+ userFullName = hView.findViewById(R.id.userFullname);
+ if (!userFullNameNav.equals("")) {
+ userFullName.setText(userFullNameNav);
+ }
+
+ userAvatar = hView.findViewById(R.id.userAvatar);
+ if (!userAvatarNav.equals("")) {
+ Picasso.get().load(userAvatarNav).networkPolicy(NetworkPolicy.OFFLINE).transform(new RoundedTransformation(100, 0)).resize(180, 180).centerCrop().into(userAvatar);
+ }
+
+ } else {
+
+ displayUserInfo(instanceUrl, instanceToken, loginUid);
+ tinyDb.putBoolean("noConnection", false);
+
+ }
+
+ }
+
+ @Override
+ public void onDrawerClosed(@NonNull View drawerView) {
+ // Called when a drawer has settled in a completely closed state.
+ }
+
+ @Override
+ public void onDrawerStateChanged(int newState) {
+ // Called when the drawer motion state changes. The new state will be one of STATE_IDLE, STATE_DRAGGING or STATE_SETTLING.
+ }
+ });
+
+ toggle.syncState();
+
+ if(savedInstanceState == null) {
+ if(tinyDb.getInt("homeScreenId") == 0) {
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
+ new MyRepositoriesFragment()).commit();
+ navigationView.setCheckedItem(R.id.nav_home);
+ }
+ else if(tinyDb.getInt("homeScreenId") == 1) {
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
+ new StarredRepositoriesFragment()).commit();
+ navigationView.setCheckedItem(R.id.nav_starred_repos);
+ }
+ else if(tinyDb.getInt("homeScreenId") == 2) {
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
+ new OrganizationsFragment()).commit();
+ navigationView.setCheckedItem(R.id.nav_organizations);
+ }
+ else if(tinyDb.getInt("homeScreenId") == 3) {
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
+ new RepositoriesFragment()).commit();
+ navigationView.setCheckedItem(R.id.nav_repositories);
+ }
+ else if(tinyDb.getInt("homeScreenId") == 4) {
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
+ new ProfileFragment()).commit();
+ navigationView.setCheckedItem(R.id.nav_profile);
+ }
+ else {
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
+ new MyRepositoriesFragment()).commit();
+ navigationView.setCheckedItem(R.id.nav_home);
+ }
+ }
+
+ if(!connToInternet) {
+
+ if(!tinyDb.getBoolean("noConnection")) {
+ Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
+ }
+
+ tinyDb.putBoolean("noConnection", true);
+
+ } else {
+
+ displayUserInfo(instanceUrl, instanceToken, loginUid);
+ tinyDb.putBoolean("noConnection", false);
+
+ }
+
+ }
+
+ public void setActionBarTitle (@NonNull String title) {
+ Objects.requireNonNull(getSupportActionBar()).setTitle(title);
+ }
+
+ @Override
+ public void onBackPressed() {
+
+ if(drawer.isDrawerOpen(GravityCompat.START)) {
+ drawer.closeDrawer(GravityCompat.START);
+ }
+ else {
+ super.onBackPressed();
+ }
+
+ }
+
+ @Override
+ public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
+
+ switch (menuItem.getItemId()) {
+ case R.id.nav_home:
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
+ new MyRepositoriesFragment()).commit();
+ break;
+ case R.id.nav_organizations:
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
+ new OrganizationsFragment()).commit();
+ break;
+ case R.id.nav_profile:
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
+ new ProfileFragment()).commit();
+ break;
+ case R.id.nav_repositories:
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
+ new RepositoriesFragment()).commit();
+ break;
+ case R.id.nav_settings:
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
+ new SettingsFragment()).commit();
+ break;
+ case R.id.nav_logout:
+ logout();
+ overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
+ break;
+ case R.id.nav_about:
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
+ new AboutFragment()).commit();
+ break;
+ case R.id.nav_rate_app:
+ rateThisApp();
+ break;
+ case R.id.nav_starred_repos:
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
+ new StarredRepositoriesFragment()).commit();
+ break;
+ }
+
+ drawer.closeDrawer(GravityCompat.START);
+ return true;
+ }
+
+ public void rateThisApp() {
+ try {
+ startActivity(new Intent(Intent.ACTION_VIEW,
+ Uri.parse("market://details?id=" + getPackageName())));
+ } catch (ActivityNotFoundException e) {
+ startActivity(new Intent(Intent.ACTION_VIEW,
+ Uri.parse("https://play.google.com/store/apps/details?id=" + getPackageName())));
+ }
+ }
+
+ public void logout() {
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ tinyDb.putBoolean("loggedInMode", false);
+ tinyDb.remove("basicAuthPassword");
+ tinyDb.putBoolean("basicAuthFlag", false);
+ //tinyDb.clear();
+ finish();
+ startActivity(new Intent(MainActivity.this, LoginActivity.class));
+
+ }
+
+ private void displayUserInfo(String instanceUrl, String token, String loginUid) {
+
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+
+ Call call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getUserInfo(Authorization.returnAuthentication(getApplicationContext(), loginUid, token));
+
+ NavigationView navigationView = findViewById(R.id.nav_view);
+ final View hView = navigationView.getHeaderView(0);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ UserInfo userDetails = response.body();
+
+ if (response.isSuccessful()) {
+
+ if (response.code() == 200) {
+
+ assert userDetails != null;
+ tinyDb.putString("userLogin", userDetails.getLogin());
+ tinyDb.putInt("userId", userDetails.getId());
+ if(!userDetails.getFullname().equals("")) {
+ tinyDb.putString("userFullname", userDetails.getFullname());
+ }
+ else {
+ tinyDb.putString("userFullname", "...");
+ }
+
+ tinyDb.putString("userEmail", userDetails.getEmail());
+ tinyDb.putString("userAvatar", userDetails.getAvatar());
+ if(userDetails.getLang() != null) {
+ tinyDb.putString("userLang", userDetails.getLang());
+ }
+ else
+ {
+ tinyDb.putString("userLang", "...");
+ }
+
+ userAvatar = hView.findViewById(R.id.userAvatar);
+ if (!Objects.requireNonNull(userDetails).getAvatar().equals("")) {
+ Picasso.get().load(userDetails.getAvatar()).transform(new RoundedTransformation(100, 0)).resize(180, 180).centerCrop().into(userAvatar);
+ } else {
+ userAvatar.setImageResource(R.mipmap.ic_launcher_round);
+ }
+
+ userFullName = hView.findViewById(R.id.userFullname);
+ if (!userDetails.getFullname().equals("")) {
+ userFullName.setText(userDetails.getFullname());
+ } else if (!userDetails.getLogin().equals("")) {
+ userFullName.setText(userDetails.getLogin());
+ } else {
+ userFullName.setText("...");
+ }
+
+ userEmail = hView.findViewById(R.id.userEmail);
+ if (!userDetails.getEmail().equals("")) {
+ userEmail.setText(userDetails.getEmail());
+ } else {
+ userEmail.setText("...");
+ }
+
+ userAvatar.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
+ new ProfileFragment()).commit();
+ drawer.closeDrawers();
+ }
+ });
+
+ }
+
+ }
+ else if(response.code() == 401) {
+
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else {
+
+ String toastError = getResources().getString(R.string.genericApiStatusError) + String.valueOf(response.code());
+ Toasty.info(getApplicationContext(), toastError);
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+ });
+
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/NewMilestoneActivity.java b/app/src/main/java/org/mian/gitnex/activities/NewMilestoneActivity.java
new file mode 100644
index 00000000..73f3c974
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/NewMilestoneActivity.java
@@ -0,0 +1,242 @@
+package org.mian.gitnex.activities;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import retrofit2.Call;
+import retrofit2.Callback;
+import android.app.DatePickerDialog;
+import android.content.Context;
+import android.graphics.drawable.GradientDrawable;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.DatePicker;
+import android.widget.EditText;
+import android.widget.ImageView;
+import org.mian.gitnex.R;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.helpers.AlertDialogs;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.helpers.Toasty;
+import org.mian.gitnex.models.Milestones;
+import org.mian.gitnex.util.AppUtil;
+import org.mian.gitnex.util.TinyDB;
+import java.util.Calendar;
+
+/**
+ * Author M M Arif
+ */
+
+public class NewMilestoneActivity extends AppCompatActivity implements View.OnClickListener {
+
+ private EditText milestoneDueDate;
+ private View.OnClickListener onClickListener;
+ private EditText milestoneTitle;
+ private EditText milestoneDescription;
+ private Button createNewMilestoneButton;
+ final Context ctx = this;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_new_milestone);
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+
+ milestoneDueDate = findViewById(R.id.milestoneDueDate);
+ ImageView closeActivity = findViewById(R.id.close);
+ createNewMilestoneButton = findViewById(R.id.createNewMilestoneButton);
+ milestoneTitle = findViewById(R.id.milestoneTitle);
+ milestoneDescription = findViewById(R.id.milestoneDescription);
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+ milestoneDueDate.setOnClickListener(this);
+
+ if(!connToInternet) {
+
+ createNewMilestoneButton.setEnabled(false);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.hintColor));
+ createNewMilestoneButton.setBackground(shape);
+
+ } else {
+
+ createNewMilestoneButton.setOnClickListener(createMilestoneListener);
+
+ }
+
+ }
+
+ private View.OnClickListener createMilestoneListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ processNewMilestone();
+ }
+ };
+
+ private void processNewMilestone() {
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+ AppUtil appUtil = new AppUtil();
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+ //String appLocale = tinyDb.getString("locale");
+
+ String newMilestoneTitle = milestoneTitle.getText().toString();
+ String newMilestoneDescription = milestoneDescription.getText().toString();
+ String newMilestoneDueDate = milestoneDueDate.getText().toString();
+
+ if(!connToInternet) {
+
+ Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
+ return;
+
+ }
+
+ if(newMilestoneTitle.equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.milestoneNameErrorEmpty));
+ return;
+
+ }
+
+ if(!newMilestoneDescription.equals("")) {
+ if (appUtil.charactersLength(newMilestoneDescription) > 255) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.milestoneDescError));
+ return;
+
+ }
+ }
+
+ if(newMilestoneDueDate.equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.milestoneDateEmpty));
+ return;
+
+ }
+
+ disableProcessButton();
+ String finalMilestoneDueDate = (AppUtil.customDateCombine(AppUtil.customDateFormat(newMilestoneDueDate)));
+ createNewMilestone(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, newMilestoneTitle, newMilestoneDescription, finalMilestoneDueDate);
+
+ }
+
+ private void createNewMilestone(final String instanceUrl, final String token, String repoOwner, String repoName, String newMilestoneTitle, String newMilestoneDescription, String newMilestoneDueDate) {
+
+ Milestones createMilestone = new Milestones(newMilestoneDescription, newMilestoneTitle, newMilestoneDueDate);
+
+ Call call;
+
+ call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .createMilestone(token, repoOwner, repoName, createMilestone);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ if(response.isSuccessful()) {
+ if(response.code() == 201) {
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ tinyDb.putBoolean("milestoneCreated", true);
+ Toasty.info(getApplicationContext(), getString(R.string.milestoneCreated));
+ enableProcessButton();
+ finish();
+
+ }
+ }
+ else if(response.code() == 401) {
+
+ enableProcessButton();
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else {
+
+ enableProcessButton();
+ Toasty.info(getApplicationContext(), getString(R.string.milestoneCreatedError));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ enableProcessButton();
+ }
+ });
+
+ }
+
+ @Override
+ public void onClick(View v) {
+
+ if (v == milestoneDueDate) {
+
+ final Calendar c = Calendar.getInstance();
+ int mYear = c.get(Calendar.YEAR);
+ final int mMonth = c.get(Calendar.MONTH);
+ final int mDay = c.get(Calendar.DAY_OF_MONTH);
+
+ DatePickerDialog datePickerDialog = new DatePickerDialog(this,
+ new DatePickerDialog.OnDateSetListener() {
+
+ @Override
+ public void onDateSet(DatePicker view, int year,
+ int monthOfYear, int dayOfMonth) {
+
+ milestoneDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth));
+
+ }
+ }, mYear, mMonth, mDay);
+ datePickerDialog.show();
+ }
+
+ }
+
+ private void initCloseListener() {
+ onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ };
+ }
+
+ private void disableProcessButton() {
+
+ createNewMilestoneButton.setEnabled(false);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.hintColor));
+ createNewMilestoneButton.setBackground(shape);
+
+ }
+
+ private void enableProcessButton() {
+
+ createNewMilestoneButton.setEnabled(true);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.btnBackground));
+ createNewMilestoneButton.setBackground(shape);
+
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/NewOrganizationActivity.java b/app/src/main/java/org/mian/gitnex/activities/NewOrganizationActivity.java
new file mode 100644
index 00000000..d3b9e2b0
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/NewOrganizationActivity.java
@@ -0,0 +1,220 @@
+package org.mian.gitnex.activities;
+
+import android.content.Context;
+import android.graphics.drawable.GradientDrawable;
+import android.os.Bundle;
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+import org.mian.gitnex.R;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.helpers.AlertDialogs;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.helpers.Toasty;
+import org.mian.gitnex.models.UserOrganizations;
+import org.mian.gitnex.util.AppUtil;
+import org.mian.gitnex.util.TinyDB;
+import retrofit2.Call;
+import retrofit2.Callback;
+
+/**
+ * Author M M Arif
+ */
+
+public class NewOrganizationActivity extends AppCompatActivity {
+
+ public ImageView closeActivity;
+ private View.OnClickListener onClickListener;
+ private Button createOrganizationButton;
+
+ private EditText orgName;
+ private EditText orgDesc;
+ final Context ctx = this;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_new_organization);
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+
+ closeActivity = findViewById(R.id.close);
+ orgName = findViewById(R.id.newOrganizationName);
+ orgDesc = findViewById(R.id.newOrganizationDescription);
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+
+ createOrganizationButton = findViewById(R.id.createNewOrganizationButton);
+
+ if(!connToInternet) {
+
+ createOrganizationButton.setEnabled(false);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.hintColor));
+ createOrganizationButton.setBackground(shape);
+
+ } else {
+
+ createOrganizationButton.setOnClickListener(createOrgListener);
+
+ }
+
+ }
+
+ private void initCloseListener() {
+ onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ };
+ }
+
+ private View.OnClickListener createOrgListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ processNewOrganization();
+ }
+ };
+
+ private void processNewOrganization() {
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+ AppUtil appUtil = new AppUtil();
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+
+ String newOrgName = orgName.getText().toString();
+ String newOrgDesc = orgDesc.getText().toString();
+
+ if(!connToInternet) {
+
+ Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
+ return;
+
+ }
+
+ if(!newOrgDesc.equals("")) {
+ if (appUtil.charactersLength(newOrgDesc) > 255) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.orgDescError));
+ return;
+
+ }
+ }
+
+ if(newOrgName.equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.orgNameErrorEmpty));
+
+ }
+ else if(!appUtil.checkStrings(newOrgName)) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.orgNameErrorInvalid));
+
+ }
+ else {
+
+ disableProcessButton();
+ createNewOrganization(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), newOrgName, newOrgDesc);
+
+ }
+
+ }
+
+ private void createNewOrganization(final String instanceUrl, final String token, String orgName, String orgDesc) {
+
+ UserOrganizations createOrganization = new UserOrganizations(orgName, null, orgDesc, null, null);
+
+ Call call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .createNewOrganization(token, createOrganization);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ if(response.code() == 201) {
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ tinyDb.putBoolean("orgCreated", true);
+ enableProcessButton();
+ Toasty.info(getApplicationContext(), getString(R.string.orgCreated));
+ finish();
+
+ }
+ else if(response.code() == 401) {
+
+ enableProcessButton();
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else if(response.code() == 409) {
+
+ enableProcessButton();
+ Toasty.info(getApplicationContext(), getString(R.string.orgExistsError));
+
+ }
+ else if(response.code() == 422) {
+
+ enableProcessButton();
+ Toasty.info(getApplicationContext(), getString(R.string.orgExistsError));
+
+ }
+ else {
+
+ if(response.code() == 404) {
+ enableProcessButton();
+ Toasty.info(getApplicationContext(), getString(R.string.apiNotFound));
+ }
+ else {
+ enableProcessButton();
+ Toasty.info(getApplicationContext(), getString(R.string.orgCreatedError));
+ }
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ enableProcessButton();
+ }
+ });
+
+ }
+
+ private void disableProcessButton() {
+
+ createOrganizationButton.setEnabled(false);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.hintColor));
+ createOrganizationButton.setBackground(shape);
+
+ }
+
+ private void enableProcessButton() {
+
+ createOrganizationButton.setEnabled(true);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.btnBackground));
+ createOrganizationButton.setBackground(shape);
+
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/NewRepoActivity.java b/app/src/main/java/org/mian/gitnex/activities/NewRepoActivity.java
new file mode 100644
index 00000000..28676c12
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/NewRepoActivity.java
@@ -0,0 +1,314 @@
+package org.mian.gitnex.activities;
+
+import android.content.Context;
+import android.graphics.PorterDuff;
+import android.graphics.drawable.GradientDrawable;
+import android.os.Bundle;
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import android.util.Log;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.Spinner;
+import org.mian.gitnex.R;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.helpers.AlertDialogs;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.helpers.Toasty;
+import org.mian.gitnex.models.OrgOwner;
+import org.mian.gitnex.models.OrganizationRepository;
+import org.mian.gitnex.util.AppUtil;
+import org.mian.gitnex.util.TinyDB;
+import java.util.ArrayList;
+import java.util.List;
+import retrofit2.Call;
+import retrofit2.Callback;
+
+/**
+ * Author M M Arif
+ */
+
+public class NewRepoActivity extends AppCompatActivity {
+
+ public ImageView closeActivity;
+ private View.OnClickListener onClickListener;
+ private Spinner spinner;
+ private Button createRepo;
+ private EditText repoName;
+ private EditText repoDesc;
+ private CheckBox repoAccess;
+ final Context ctx = this;
+
+ List orgsList = new ArrayList<>();
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_new_repo);
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String userLogin = tinyDb.getString("userLogin");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+
+ closeActivity = findViewById(R.id.close);
+ repoName = findViewById(R.id.newRepoName);
+ repoDesc = findViewById(R.id.newRepoDescription);
+ repoAccess = findViewById(R.id.newRepoPrivate);
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+
+ spinner = findViewById(R.id.ownerSpinner);
+ spinner.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
+ getOrgs(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), userLogin);
+ spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView> parent, View view, int position, long id) {
+ OrgOwner user = (OrgOwner) parent.getSelectedItem();
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> parent) {
+
+ }
+ });
+
+ createRepo = findViewById(R.id.createNewRepoButton);
+ disableProcessButton();
+
+ if(!connToInternet) {
+
+ disableProcessButton();
+
+ }
+ else {
+
+ createRepo.setOnClickListener(createRepoListener);
+
+ }
+
+ }
+
+ private View.OnClickListener createRepoListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ processNewRepo();
+ }
+ };
+
+ private void processNewRepo() {
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+ AppUtil appUtil = new AppUtil();
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+
+ String newRepoName = repoName.getText().toString();
+ String newRepoDesc = repoDesc.getText().toString();
+ String repoOwner = spinner.getSelectedItem().toString();
+ boolean newRepoAccess = repoAccess.isChecked();
+
+ if(!connToInternet) {
+
+ Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
+ return;
+
+ }
+
+ if(!newRepoDesc.equals("")) {
+ if (appUtil.charactersLength(newRepoDesc) > 255) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.repoDescError));
+ return;
+
+ }
+ }
+
+ if(newRepoName.equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.repoNameErrorEmpty));
+
+ }
+ else if(!appUtil.checkStrings(newRepoName)) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.repoNameErrorInvalid));
+
+ }
+ else {
+
+ //Log.i("repoOwner", String.valueOf(repoOwner));
+ disableProcessButton();
+ createNewRepository(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), loginUid, newRepoName, newRepoDesc, repoOwner, newRepoAccess);
+
+ }
+
+ }
+
+ private void createNewRepository(final String instanceUrl, final String token, String loginUid, String repoName, String repoDesc, String repoOwner, boolean isPrivate) {
+
+ OrganizationRepository createRepository = new OrganizationRepository(true, repoDesc, null, null, repoName, isPrivate, "Default");
+
+ Call call;
+ if(repoOwner.equals(loginUid)) {
+
+ call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .createNewUserRepository(token, createRepository);
+
+ }
+ else {
+
+ call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .createNewUserOrgRepository(token, repoOwner, createRepository);
+
+ }
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ if(response.code() == 201) {
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ tinyDb.putBoolean("repoCreated", true);
+ Toasty.info(getApplicationContext(), getString(R.string.repoCreated));
+ enableProcessButton();
+ finish();
+ }
+ else if(response.code() == 401) {
+
+ enableProcessButton();
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else if(response.code() == 409) {
+
+ enableProcessButton();
+ Toasty.info(getApplicationContext(), getString(R.string.repoExistsError));
+
+ }
+ else {
+
+ enableProcessButton();
+ Toasty.info(getApplicationContext(), getString(R.string.repoCreatedError));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ enableProcessButton();
+ }
+ });
+
+ }
+
+ private void getOrgs(String instanceUrl, String instanceToken, final String userLogin) {
+
+ Call> call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getOrgOwners(instanceToken);
+
+ call.enqueue(new Callback>() {
+
+ @Override
+ public void onResponse(@NonNull Call> call, @NonNull retrofit2.Response> response) {
+
+ if(response.isSuccessful()) {
+ if(response.code() == 200) {
+
+ List orgsList_ = response.body();
+
+ orgsList.add(new OrgOwner(userLogin));
+ assert orgsList_ != null;
+ if(orgsList_.size() > 0) {
+ for (int i = 0; i < orgsList_.size(); i++) {
+
+ OrgOwner data = new OrgOwner(
+ orgsList_.get(i).getUsername()
+ );
+ orgsList.add(data);
+
+ }
+ }
+
+ ArrayAdapter adapter = new ArrayAdapter<>(getApplicationContext(),
+ R.layout.spinner_item, orgsList);
+
+ adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
+ spinner.setAdapter(adapter);
+ enableProcessButton();
+
+ }
+ }
+ else if(response.code() == 401) {
+
+ enableProcessButton();
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call> call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ enableProcessButton();
+ }
+ });
+
+ }
+
+ private void initCloseListener() {
+ onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ };
+ }
+
+ private void disableProcessButton() {
+
+ createRepo.setEnabled(false);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.hintColor));
+ createRepo.setBackground(shape);
+
+ }
+
+ private void enableProcessButton() {
+
+ createRepo.setEnabled(true);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.btnBackground));
+ createRepo.setBackground(shape);
+
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/OrgDetailActivity.java b/app/src/main/java/org/mian/gitnex/activities/OrgDetailActivity.java
new file mode 100644
index 00000000..749431b8
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/OrgDetailActivity.java
@@ -0,0 +1,134 @@
+package org.mian.gitnex.activities;
+
+import com.google.android.material.tabs.TabLayout;
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentPagerAdapter;
+import androidx.viewpager.widget.ViewPager;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import org.mian.gitnex.R;
+import org.mian.gitnex.fragments.MembersByOrgFragment;
+import org.mian.gitnex.fragments.OrgBottomSheetFragment;
+import org.mian.gitnex.fragments.OrganizationInfoFragment;
+import org.mian.gitnex.fragments.RepositoriesByOrgFragment;
+import org.mian.gitnex.fragments.TeamsByOrgFragment;
+import org.mian.gitnex.util.TinyDB;
+import java.util.Objects;
+
+/**
+ * Author M M Arif
+ */
+
+public class OrgDetailActivity extends AppCompatActivity implements OrgBottomSheetFragment.BottomSheetListener {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_org_detail);
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ String orgName = tinyDb.getString("orgName");
+
+ Toolbar toolbar = findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+ Objects.requireNonNull(getSupportActionBar()).setTitle(orgName);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+
+ OrgDetailActivity.SectionsPagerAdapter mSectionsPagerAdapter = new OrgDetailActivity.SectionsPagerAdapter(getSupportFragmentManager());
+
+ ViewPager mViewPager = findViewById(R.id.container);
+ mViewPager.setAdapter(mSectionsPagerAdapter);
+
+ TabLayout tabLayout = findViewById(R.id.tabs);
+
+ mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
+ tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
+
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.repo_dotted_menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ int id = item.getItemId();
+
+ switch (id) {
+ case android.R.id.home:
+ finish();
+ return true;
+ case R.id.repoMenu:
+ OrgBottomSheetFragment bottomSheet = new OrgBottomSheetFragment();
+ bottomSheet.show(getSupportFragmentManager(), "orgBottomSheet");
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+
+ }
+
+ @Override
+ public void onButtonClicked(String text) {
+
+ switch (text) {
+ case "team":
+ startActivity(new Intent(OrgDetailActivity.this, CreateTeamByOrgActivity.class));
+ break;
+ }
+ //Log.i("clicked", text);
+
+ }
+
+ public class SectionsPagerAdapter extends FragmentPagerAdapter {
+
+ SectionsPagerAdapter(FragmentManager fm) {
+ super(fm);
+ }
+
+ @NonNull
+ @Override
+ public Fragment getItem(int position) {
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ String orgName;
+ if(getIntent().getStringExtra("orgName") != null || !getIntent().getStringExtra("orgName").equals("")) {
+ orgName = getIntent().getStringExtra("orgName");
+ }
+ else {
+ orgName = tinyDb.getString("orgName");
+ }
+
+ Fragment fragment = null;
+ switch (position) {
+ case 0: // info
+ return OrganizationInfoFragment.newInstance(orgName);
+ case 1: // repos
+ return RepositoriesByOrgFragment.newInstance(orgName);
+ case 2: // teams
+ return TeamsByOrgFragment.newInstance(orgName);
+ case 3: // members
+ return MembersByOrgFragment.newInstance(orgName);
+ }
+ return fragment;
+
+ }
+
+ @Override
+ public int getCount() {
+ return 4;
+ }
+ }
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/OrgTeamMembersActivity.java b/app/src/main/java/org/mian/gitnex/activities/OrgTeamMembersActivity.java
new file mode 100644
index 00000000..a55d65ff
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/OrgTeamMembersActivity.java
@@ -0,0 +1,102 @@
+package org.mian.gitnex.activities;
+
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.lifecycle.Observer;
+import androidx.lifecycle.ViewModelProviders;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.GridView;
+import android.widget.ImageView;
+import android.widget.TextView;
+import org.mian.gitnex.R;
+import org.mian.gitnex.adapters.TeamMembersByOrgAdapter;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.models.UserInfo;
+import org.mian.gitnex.util.TinyDB;
+import org.mian.gitnex.viewmodels.TeamMembersByOrgViewModel;
+import java.util.List;
+
+/**
+ * Author M M Arif
+ */
+
+public class OrgTeamMembersActivity extends AppCompatActivity {
+
+ private TextView noDataMembers;
+ private View.OnClickListener onClickListener;
+ private TeamMembersByOrgAdapter adapter;
+ private GridView mGridView;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_org_team_members);
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+
+ ImageView closeActivity = findViewById(R.id.close);
+ TextView toolbarTitle = findViewById(R.id.toolbar_title);
+ noDataMembers = findViewById(R.id.noDataMembers);
+ mGridView = findViewById(R.id.gridView);
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+
+ if(getIntent().getStringExtra("teamTitle") != null && !getIntent().getStringExtra("teamTitle").equals("")) {
+ toolbarTitle.setText(getIntent().getStringExtra("teamTitle"));
+ }
+ else {
+ toolbarTitle.setText(R.string.orgTeamMembers);
+ }
+
+ String teamId;
+ if(getIntent().getStringExtra("teamId") != null && !getIntent().getStringExtra("teamId").equals("")){
+ teamId = getIntent().getStringExtra("teamId");
+ }
+ else {
+ teamId = "0";
+ }
+
+ getIntent().getStringExtra("teamId");
+ Log.i("teamId", getIntent().getStringExtra("teamId"));
+
+ fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), Integer.valueOf(teamId));
+
+ }
+
+ private void fetchDataAsync(String instanceUrl, String instanceToken, int teamId) {
+
+ TeamMembersByOrgViewModel teamMembersModel = ViewModelProviders.of(this).get(TeamMembersByOrgViewModel.class);
+
+ teamMembersModel.getMembersByOrgList(instanceUrl, instanceToken, teamId).observe(this, new Observer>() {
+ @Override
+ public void onChanged(@Nullable List teamMembersListMain) {
+ adapter = new TeamMembersByOrgAdapter(getApplicationContext(), teamMembersListMain);
+ if(adapter.getCount() > 0) {
+ mGridView.setAdapter(adapter);
+ noDataMembers.setVisibility(View.GONE);
+ }
+ else {
+ adapter.notifyDataSetChanged();
+ mGridView.setAdapter(adapter);
+ noDataMembers.setVisibility(View.VISIBLE);
+ }
+ }
+ });
+
+ }
+
+ private void initCloseListener() {
+ onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ };
+ }
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/ProfileEmailActivity.java b/app/src/main/java/org/mian/gitnex/activities/ProfileEmailActivity.java
new file mode 100644
index 00000000..dd41e550
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/ProfileEmailActivity.java
@@ -0,0 +1,208 @@
+package org.mian.gitnex.activities;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import retrofit2.Call;
+import retrofit2.Callback;
+import android.content.Context;
+import android.graphics.drawable.GradientDrawable;
+import android.os.Bundle;
+import android.util.Log;
+import android.util.Patterns;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+import com.google.gson.JsonElement;
+import org.mian.gitnex.R;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.helpers.AlertDialogs;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.helpers.Toasty;
+import org.mian.gitnex.models.AddEmail;
+import org.mian.gitnex.util.AppUtil;
+import org.mian.gitnex.util.TinyDB;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Author M M Arif
+ */
+
+public class ProfileEmailActivity extends AppCompatActivity {
+
+ private View.OnClickListener onClickListener;
+ private EditText userEmail;
+ final Context ctx = this;
+ private Button addEmailButton;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_profile_email);
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+
+ ImageView closeActivity = findViewById(R.id.close);
+ userEmail = findViewById(R.id.userEmail);
+ addEmailButton = findViewById(R.id.addEmailButton);
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+
+ if(!connToInternet) {
+
+ disableProcessButton();
+
+ } else {
+
+ addEmailButton.setOnClickListener(addEmailListener);
+
+ }
+
+ }
+
+ private View.OnClickListener addEmailListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ processAddNewEmail();
+ }
+ };
+
+ private void processAddNewEmail() {
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+
+ String newUserEmail = userEmail.getText().toString().trim();
+
+ if(!connToInternet) {
+
+ Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
+ return;
+
+ }
+
+ if(newUserEmail.equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.emailErrorEmpty));
+ return;
+
+ }
+ else if(!Patterns.EMAIL_ADDRESS.matcher(newUserEmail).matches()) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.emailErrorInvalid));
+ return;
+
+ }
+
+ List newEmailList = new ArrayList<>(Arrays.asList(newUserEmail.split(",")));
+
+ disableProcessButton();
+ addNewEmail(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), newEmailList);
+
+ }
+
+ private void addNewEmail(final String instanceUrl, final String token, List newUserEmail) {
+
+ AddEmail addEmailFunc = new AddEmail(newUserEmail);
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+
+ Call call;
+
+ call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .addNewEmail(token, addEmailFunc);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ if(response.code() == 201) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.emailAddedText));
+ tinyDb.putBoolean("emailsRefresh", true);
+ enableProcessButton();
+ finish();
+
+ }
+ else if(response.code() == 401) {
+
+ enableProcessButton();
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else if(response.code() == 403) {
+
+ enableProcessButton();
+ Toasty.info(ctx, ctx.getString(R.string.authorizeError));
+
+ }
+ else if(response.code() == 404) {
+
+ enableProcessButton();
+ Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
+
+ }
+ else if(response.code() == 422) {
+
+ enableProcessButton();
+ Toasty.info(ctx, ctx.getString(R.string.emailErrorInUse));
+
+ }
+ else {
+
+ enableProcessButton();
+ Toasty.info(getApplicationContext(), getString(R.string.labelGeneralError));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ enableProcessButton();
+ }
+ });
+
+ }
+
+ private void initCloseListener() {
+ onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ };
+ }
+
+ private void disableProcessButton() {
+
+ addEmailButton.setEnabled(false);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.hintColor));
+ addEmailButton.setBackground(shape);
+
+ }
+
+ private void enableProcessButton() {
+
+ addEmailButton.setEnabled(true);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.btnBackground));
+ addEmailButton.setBackground(shape);
+
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java b/app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
new file mode 100644
index 00000000..24045905
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
@@ -0,0 +1,278 @@
+package org.mian.gitnex.activities;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+import android.content.Context;
+import android.graphics.drawable.GradientDrawable;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+import com.hendraanggrian.appcompat.socialview.Mention;
+import com.hendraanggrian.appcompat.widget.MentionArrayAdapter;
+import com.hendraanggrian.appcompat.widget.SocialAutoCompleteTextView;
+import org.mian.gitnex.R;
+import org.mian.gitnex.actions.IssueActions;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.helpers.AlertDialogs;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.helpers.Toasty;
+import org.mian.gitnex.models.Collaborators;
+import org.mian.gitnex.models.Issues;
+import org.mian.gitnex.util.AppUtil;
+import org.mian.gitnex.util.TinyDB;
+import java.util.List;
+
+/**
+ * Author M M Arif
+ */
+
+public class ReplyToIssueActivity extends AppCompatActivity {
+
+ public ImageView closeActivity;
+ private View.OnClickListener onClickListener;
+
+ final Context ctx = this;
+
+ private SocialAutoCompleteTextView addComment;
+ private ArrayAdapter defaultMentionAdapter;
+ private Button replyButton;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_reply_to_issue);
+
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+
+ addComment = findViewById(R.id.addComment);
+ addComment.setShowSoftInputOnFocus(true);
+
+ defaultMentionAdapter = new MentionArrayAdapter<>(this);
+ loadCollaboratorsList();
+
+ addComment.setMentionAdapter(defaultMentionAdapter);
+
+ closeActivity = findViewById(R.id.close);
+ TextView toolbar_title = findViewById(R.id.toolbar_title);
+
+ if(!tinyDb.getString("issueTitle").isEmpty()) {
+ toolbar_title.setText(tinyDb.getString("issueTitle"));
+ }
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+
+ replyButton = findViewById(R.id.replyButton);
+
+ if(getIntent().getStringExtra("commentAction") != null && getIntent().getStringExtra("commentAction").equals("edit")) {
+
+ addComment.setText(getIntent().getStringExtra("commentBody"));
+ final String commentId = getIntent().getStringExtra("commentId");
+
+ toolbar_title.setText(getResources().getString(R.string.editCommentTitle));
+ replyButton.setText(getResources().getString(R.string.editCommentButtonText));
+
+ replyButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ IssueActions.editIssueComment(ctx, Integer.valueOf(commentId), addComment.getText().toString());
+ }
+
+ });
+
+ return;
+
+ }
+
+ if(!connToInternet) {
+
+ disableProcessButton();
+
+ } else {
+
+ replyButton.setOnClickListener(replyToIssue);
+
+ }
+
+ }
+
+ public void loadCollaboratorsList() {
+
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+
+ Call> call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
+
+ call.enqueue(new Callback>() {
+
+ @Override
+ public void onResponse(@NonNull Call> call, @NonNull Response> response) {
+
+ if (response.isSuccessful()) {
+
+ assert response.body() != null;
+ String fullName = "";
+ for (int i = 0; i < response.body().size(); i++) {
+ if(!response.body().get(i).getFull_name().equals("")) {
+ fullName = response.body().get(i).getFull_name();
+ }
+ defaultMentionAdapter.add(
+ new Mention(response.body().get(i).getUsername(), fullName, response.body().get(i).getAvatar_url()));
+ }
+
+ } else {
+
+ Log.i("onResponse", String.valueOf(response.code()));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call> call, @NonNull Throwable t) {
+ Log.i("onFailure", t.getMessage());
+ }
+
+ });
+ }
+
+ private void initCloseListener() {
+ onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ };
+ }
+
+ private View.OnClickListener replyToIssue = new View.OnClickListener() {
+ public void onClick(View v) {
+ processNewCommentReply();
+ }
+ };
+
+ private void processNewCommentReply() {
+
+ String newReplyDT = addComment.getText().toString();
+ boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
+
+ if(!connToInternet) {
+
+ Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
+ return;
+
+ }
+
+ if(newReplyDT.equals("")) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.commentEmptyError));
+
+ }
+ else {
+
+ disableProcessButton();
+ replyComment(newReplyDT);
+
+ }
+
+ }
+
+ private void replyComment(String newReplyDT) {
+
+ final TinyDB tinyDb = new TinyDB(getApplicationContext());
+
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+ final int issueIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
+
+ Issues issueComment = new Issues(newReplyDT);
+
+ Call call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .replyCommentToIssue(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, issueComment);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ if(response.code() == 201) {
+
+ Toasty.info(getApplicationContext(), getString(R.string.commentSuccess));
+ tinyDb.putBoolean("commentPosted", true);
+ tinyDb.putBoolean("resumeIssues", true);
+ finish();
+
+ }
+ else if(response.code() == 401) {
+
+ enableProcessButton();
+ AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
+ getResources().getString(R.string.alertDialogTokenRevokedMessage),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
+ getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
+
+ }
+ else {
+
+ enableProcessButton();
+ Toasty.info(getApplicationContext(), getString(R.string.commentError));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ enableProcessButton();
+ }
+ });
+
+ }
+
+ private void disableProcessButton() {
+
+ replyButton.setEnabled(false);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.hintColor));
+ replyButton.setBackground(shape);
+
+ }
+
+ private void enableProcessButton() {
+
+ replyButton.setEnabled(true);
+ GradientDrawable shape = new GradientDrawable();
+ shape.setCornerRadius( 8 );
+ shape.setColor(getResources().getColor(R.color.btnBackground));
+ replyButton.setBackground(shape);
+
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java b/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java
new file mode 100644
index 00000000..0a42adcd
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java
@@ -0,0 +1,245 @@
+package org.mian.gitnex.activities;
+
+import com.google.android.material.tabs.TabLayout;
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentStatePagerAdapter;
+import androidx.viewpager.widget.ViewPager;
+import retrofit2.Call;
+import retrofit2.Callback;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.TextView;
+import org.mian.gitnex.R;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.fragments.BranchesFragment;
+import org.mian.gitnex.fragments.ClosedIssuesFragment;
+import org.mian.gitnex.fragments.CollaboratorsFragment;
+import org.mian.gitnex.fragments.IssuesFragment;
+import org.mian.gitnex.fragments.LabelsFragment;
+import org.mian.gitnex.fragments.MilestonesFragment;
+import org.mian.gitnex.fragments.ReleasesFragment;
+import org.mian.gitnex.fragments.RepoBottomSheetFragment;
+import org.mian.gitnex.fragments.RepoInfoFragment;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.models.UserRepositories;
+import org.mian.gitnex.util.AppUtil;
+import org.mian.gitnex.util.TinyDB;
+import java.util.Objects;
+
+/**
+ * Author M M Arif
+ */
+
+public class RepoDetailActivity extends AppCompatActivity implements RepoBottomSheetFragment.BottomSheetListener {
+
+ private TextView textViewBadge;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_repo_detail);
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ String repoName1 = parts[1];
+
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String repoOwner = parts[0];
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+
+ String appLocale = tinyDb.getString("locale");
+ AppUtil.setAppLocale(getResources(), appLocale);
+
+ Toolbar toolbar = findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+ Objects.requireNonNull(getSupportActionBar()).setTitle(repoName1);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+
+ SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
+
+ ViewPager mViewPager = findViewById(R.id.container);
+ mViewPager.setAdapter(mSectionsPagerAdapter);
+
+ TabLayout tabLayout = findViewById(R.id.tabs);
+
+ mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
+ tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
+
+ if(tinyDb.getBoolean("enableCounterIssueBadge")) {
+
+ View tabHeader = LayoutInflater.from(this).inflate(R.layout.badge, null);
+ textViewBadge = tabHeader.findViewById(R.id.counterBadge);
+ if(!tinyDb.getString("issuesCounter").isEmpty()) {
+ getRepoInfo(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName1);
+ }
+ Objects.requireNonNull(tabLayout.getTabAt(1)).setCustomView(tabHeader);
+
+ }
+ }
+
+ @Override
+ public void onResume() {
+
+ super.onResume();
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+
+ if(tinyDb.getBoolean("enableCounterIssueBadge")) {
+ getRepoInfo(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
+ }
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.repo_dotted_menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ int id = item.getItemId();
+
+ switch (id) {
+ case android.R.id.home:
+ finish();
+ return true;
+ case R.id.repoMenu:
+ RepoBottomSheetFragment bottomSheet = new RepoBottomSheetFragment();
+ bottomSheet.show(getSupportFragmentManager(), "repoBottomSheet");
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+
+ }
+
+ @Override
+ public void onButtonClicked(String text) {
+
+ switch (text) {
+ case "label":
+ startActivity(new Intent(RepoDetailActivity.this, CreateLabelActivity.class));
+ break;
+ case "newIssue":
+ startActivity(new Intent(RepoDetailActivity.this, CreateIssueActivity.class));
+ break;
+ case "newMilestone":
+ startActivity(new Intent(RepoDetailActivity.this, NewMilestoneActivity.class));
+ break;
+ case "addCollaborator":
+ startActivity(new Intent(RepoDetailActivity.this, AddCollaboratorToRepositoryActivity.class));
+ break;
+ case "createRelease":
+ startActivity(new Intent(RepoDetailActivity.this, CreateReleaseActivity.class));
+ break;
+ }
+
+ }
+
+ public class SectionsPagerAdapter extends FragmentStatePagerAdapter {
+
+ SectionsPagerAdapter(FragmentManager fm) {
+ super(fm);
+ }
+
+ @NonNull
+ @Override
+ public Fragment getItem(int position) {
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ String repoOwner = parts[0];
+ String repoName = parts[1];
+
+ Fragment fragment = null;
+ switch (position) {
+ case 0: // information
+ return RepoInfoFragment.newInstance(repoOwner, repoName);
+ case 1: // issues
+ fragment = new IssuesFragment();
+ break;
+ case 2: // closed issues
+ fragment = new ClosedIssuesFragment();
+ break;
+ case 3: // milestones
+ return MilestonesFragment.newInstance(repoOwner, repoName);
+ case 4: // labels
+ return LabelsFragment.newInstance(repoOwner, repoName);
+ case 5: // branches
+ return BranchesFragment.newInstance(repoOwner, repoName);
+ case 6: // releases
+ return ReleasesFragment.newInstance(repoOwner, repoName);
+ case 7: // collaborators
+ return CollaboratorsFragment.newInstance(repoOwner, repoName);
+ }
+ return fragment;
+ }
+
+ @Override
+ public int getCount() {
+ return 8;
+ }
+
+ }
+
+ private void getRepoInfo(String instanceUrl, String token, final String owner, String repo) {
+
+ Call call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getUserRepository(token, owner, repo);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ UserRepositories repoInfo = response.body();
+
+ if (response.isSuccessful()) {
+
+ if (response.code() == 200) {
+
+ assert repoInfo != null;
+ textViewBadge.setText(repoInfo.getOpen_issues_count());
+
+ }
+
+ }
+ else {
+ Log.e("onFailure", String.valueOf(response.code()));
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+ });
+
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/activities/SponsorsActivity.java b/app/src/main/java/org/mian/gitnex/activities/SponsorsActivity.java
new file mode 100644
index 00000000..cb058a2f
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/SponsorsActivity.java
@@ -0,0 +1,37 @@
+package org.mian.gitnex.activities;
+
+import androidx.appcompat.app.AppCompatActivity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.ImageView;
+import org.mian.gitnex.R;
+
+/**
+ * Author M M Arif
+ */
+
+public class SponsorsActivity extends AppCompatActivity {
+
+ private View.OnClickListener onClickListener;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_sponsors);
+
+ ImageView closeActivity = findViewById(R.id.close);
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+ }
+
+ private void initCloseListener() {
+ onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ };
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/adapters/AdminGetUsersAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/AdminGetUsersAdapter.java
new file mode 100644
index 00000000..f8e2c433
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/adapters/AdminGetUsersAdapter.java
@@ -0,0 +1,145 @@
+package org.mian.gitnex.adapters;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Filter;
+import android.widget.Filterable;
+import android.widget.ImageView;
+import android.widget.TextView;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+import com.amulyakhare.textdrawable.TextDrawable;
+import com.squareup.picasso.Picasso;
+import org.mian.gitnex.R;
+import org.mian.gitnex.helpers.RoundedTransformation;
+import org.mian.gitnex.models.UserInfo;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Author M M Arif
+ */
+
+public class AdminGetUsersAdapter extends RecyclerView.Adapter implements Filterable {
+
+ private List usersList;
+ private Context mCtx;
+ private List usersListFull;
+
+ static class UsersViewHolder extends RecyclerView.ViewHolder {
+
+ private ImageView userAvatar;
+ private TextView userFullName;
+ private TextView userEmail;
+ private ImageView userRole;
+ private TextView userName;
+
+ private UsersViewHolder(View itemView) {
+ super(itemView);
+
+ userAvatar = itemView.findViewById(R.id.userAvatar);
+ userFullName = itemView.findViewById(R.id.userFullName);
+ userName = itemView.findViewById(R.id.userName);
+ userEmail = itemView.findViewById(R.id.userEmail);
+ userRole = itemView.findViewById(R.id.userRole);
+
+ }
+ }
+
+ public AdminGetUsersAdapter(Context mCtx, List