├── .coafile ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.MD ├── .gitignore ├── .travis.yml ├── Addy.apk ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── google-services.json ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── reverieworks │ │ └── addy │ │ └── ExampleInstrumentedTest.java │ ├── debug │ └── res │ │ └── values │ │ └── google_maps_api.xml │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── fonts │ │ │ └── fontawesome-webfont.ttf │ ├── ic_launcher-web.png │ ├── ic_launcher_logo-web.png │ ├── ic_launcher_logo_png-web.png │ ├── java │ │ └── reverieworks │ │ │ └── addy │ │ │ ├── Abstract │ │ │ └── PermissionUtils.java │ │ │ ├── Activity │ │ │ ├── ACodeJSON.java │ │ │ ├── Homepage.java │ │ │ ├── MapsActivity.java │ │ │ ├── PlacesAPIActivity.java │ │ │ ├── RegistrationActivity.java │ │ │ └── WelcomeActivity.java │ │ │ └── Fragment │ │ │ ├── SignIn.java │ │ │ └── SignUp.java │ └── res │ │ ├── drawable │ │ ├── facebook_logo.png │ │ ├── google_logo.png │ │ ├── ic_menu_camera.xml │ │ ├── ic_menu_gallery.xml │ │ ├── ic_menu_manage.xml │ │ ├── ic_menu_send.xml │ │ ├── ic_menu_share.xml │ │ ├── ic_menu_slideshow.xml │ │ ├── image_button.xml │ │ ├── logo_addy_wp.png │ │ ├── side_nav_bar.xml │ │ └── twitter_logo.png │ │ ├── layout │ │ ├── activity_homepage.xml │ │ ├── activity_maps.xml │ │ ├── activity_maps_main.xml │ │ ├── activity_places_api.xml │ │ ├── activity_registration.xml │ │ ├── activity_welcome.xml │ │ ├── app_bar_homepage.xml │ │ ├── content_homepage.xml │ │ ├── dialog_layout.xml │ │ ├── fragment_sign_in.xml │ │ ├── fragment_sign_up.xml │ │ └── nav_header_homepage.xml │ │ ├── menu │ │ ├── activity_homepage_drawer.xml │ │ ├── homepage.xml │ │ └── maps_menu.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_logo.png │ │ └── ic_launcher_logo_png.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_logo.png │ │ └── ic_launcher_logo_png.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_logo.png │ │ └── ic_launcher_logo_png.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_logo.png │ │ └── ic_launcher_logo_png.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_logo.png │ │ └── ic_launcher_logo_png.png │ │ ├── values-v21 │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ ├── release │ └── res │ │ └── values │ │ └── google_maps_api.xml │ └── test │ └── java │ └── reverieworks │ └── addy │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── logo.png └── settings.gradle /.coafile: -------------------------------------------------------------------------------- 1 | [default] 2 | bears = InvalidLinkBear, coalaBear, FilenameBear 3 | files = **.xml, **.java, **.md 4 | 5 | [java] 6 | bears = CheckstyleBear, JavaPMDBear 7 | files = **.java 8 | 9 | [markdown] 10 | bears = MarkdownBear, TextLintBear 11 | files = **.md 12 | 13 | [xml] 14 | bears = XMLBear 15 | files = **.xml -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @yashovardhanagrawal @reverie-ss -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | ### Overview Description 8 | 9 | # Steps to Reproduce 10 | - 11 | - 12 | - 13 | 14 | # Actual Results 15 | 16 | # Expected Results 17 | 18 | # Reproducibility 19 | 20 | # Additional Information: 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.MD: -------------------------------------------------------------------------------- 1 | 7 | 8 | #### Checklist (Mandatory) 9 | 10 | - [ ] My branch is up-to-date with the Upstream `master` branch. 11 | - [ ] I have added necessary documentation (if appropriate) 12 | - [ ] I read the [commit guidelines](http://addy.wiki/commit-guidelines) and I've followed 13 | them. 14 | - [ ] I have tested the code locally 15 | 16 | **Changes proposed in this pull request** 17 | - 18 | - 19 | - 20 | 21 | **Screenshots (if appropriate)** 22 | 23 | **Link to live demo (if appropriate):** 24 | 25 | 26 | 27 | Fixes # 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/gradle.xml 40 | .idea/dictionaries 41 | .idea/libraries 42 | .idea/compiler.xml 43 | .idea/copyright/profiles_settings.xml 44 | .idea/misc.xml 45 | .idea/modules.xml 46 | .idea/vcs.xml 47 | 48 | # Keystore files 49 | *.jks 50 | 51 | # External native build folder generated in Android Studio 2.2 and later 52 | .externalNativeBuild 53 | 54 | # Google Services (e.g. APIs or Firebase) 55 | google-services.json 56 | 57 | # Freeline 58 | freeline.py 59 | freeline/ 60 | freeline_project_description.json 61 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | android: 2 | components: 3 | # Update Android SDK Tools 4 | - tools 5 | 6 | - build-tools-23.0.1 7 | - android-23 8 | 9 | # Support library 10 | - extra-android-support 11 | - extra-android-m2repository 12 | script: 13 | - chmod +x ./gradlew 14 | -------------------------------------------------------------------------------- /Addy.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/addy-org/Addy-Android/e9440e650d442d1fc50caf96b0a9c34496ccd77a/Addy.apk -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## 1. Purpose 2 | 3 | A primary goal of Addy is to be inclusive of the largest number of contributors, with the most varied and diverse backgrounds possible. As such, we are committed to providing a friendly, safe and welcoming environment for all, regardless of gender, sexual orientation, ability, ethnicity, socioeconomic status, and religion (or lack thereof). 4 | 5 | This code of conduct outlines our expectations for all those who participate in our community, as well as the consequences for unacceptable behaviour. 6 | 7 | We invite all those who participate in Addy to help us create safe and positive experiences for everyone. 8 | 9 | ## 2. Open Source Citizenship 10 | 11 | A supplemental goal of this Code of Conduct is to increase open source citizenship by encouraging participants to recognise and strengthen the relationships between our actions and their effects on our community. 12 | 13 | Communities mirror the societies in which they exist and positive action is essential to counteract the many forms of inequality and abuses of power that exist in society. 14 | 15 | If you see someone who is making an extra effort to ensure our community is welcoming, friendly, and encourages all participants to contribute to the fullest extent, we want to know. 16 | 17 | ## 3. Expected Behaviour 18 | 19 | The following behaviour is expected and requested of all community members: 20 | 21 | - Participate in an authentic and active way. In doing so, you contribute to the health and longevity of this community. 22 | - Exercise consideration and respect in your speech and actions. 23 | - Attempt collaboration before a conflict. 24 | - Refrain from demeaning, discriminatory, or harassing behaviour and speech. 25 | - Be mindful of your surroundings and of your fellow participants. Alert community leaders if you notice a dangerous situation, someone in distress, or violations of this Code of Conduct, even if they seem inconsequential. 26 | - Remember that community event venues may be shared with members of the public; please be respectful to all patrons of these locations. 27 | 28 | ## 4. Unacceptable Behaviour 29 | 30 | The following behaviours are considered harassment and are unacceptable within our community: 31 | 32 | - Violence, threats of violence or violent language directed against another person. 33 | - Sexist, racist, homophobic, transphobic, ableist or otherwise discriminatory jokes and language. 34 | - Posting or displaying sexually explicit or violent material. 35 | - Posting or threatening to post other people’s personally identifying information ("doxing"). 36 | - Personal insults, particularly those related to gender, sexual orientation, race, religion, or disability. 37 | - Inappropriate photography or recording. 38 | - Inappropriate physical contact. You should have someone’s consent before touching them. 39 | - Unwelcome sexual attention. This includes sexualised comments or jokes; inappropriate touching, groping, and unwelcome sexual advances. 40 | - Deliberate intimidation, stalking or following (online or in person). 41 | - Advocating for, or encouraging, any of the above behaviours. 42 | - Sustained disruption of community events, including talks and presentations. 43 | 44 | ## 5. Consequences of Unacceptable Behaviour 45 | 46 | Unacceptable behaviour from any community member, including sponsors and those with decision-making authority, will not be tolerated. 47 | 48 | Anyone asked to stop unacceptable behaviour is expected to comply immediately. 49 | 50 | If a community member engages in unacceptable behaviour, the community organisers may take any action they deem appropriate, up to and including a temporary ban or permanent expulsion from the community without warning (and without refund in the case of a paid event). 51 | 52 | ## 6. Reporting Guidelines 53 | 54 | If you are subject to or witness unacceptable behaviour, or have any other concerns, please notify a community organiser as soon as possible. 55 | 56 | 57 | Additionally, community organisers are available to help community members engage with local law enforcement or to otherwise help those experiencing unacceptable behaviour feel safe. In the context of in-person events, organisers will also provide escorts as desired by the person experiencing distress. 58 | 59 | ## 7. Addressing Grievances 60 | 61 | If you feel you have been falsely or unfairly accused of violating this Code of Conduct, you should notify Addy with a concise description of your grievance. Your grievance will be handled in accordance with our existing governing policies. 62 | 63 | ## 8. Scope 64 | 65 | We expect all community participants (contributors, paid or otherwise; sponsors; and other guests) to abide by this Code of Conduct in all community venues–online and in-person–as well as in all one-on-one communications pertaining to community business. 66 | 67 | This code of conduct and its related procedures also applies to unacceptable behaviour occurring outside the scope of community activities when such behaviour has the potential to adversely affect the safety and well-being of community members. 68 | 69 | ## 9. Contact info 70 | 71 | Gitter Chatroom: 72 | 73 | Mailing List: 74 | 75 | You can find the community maintainers [here](https://github.com/orgs/addy-org/teams/maintainers) 76 | 77 | 78 | *// Retrieved on November 22, 2016 from [http://citizencodeofconduct.org/](http://citizencodeofconduct.org/)* 79 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Introduction 2 | 3 | You can contribute to *@addy-org* by opening a Pull Request. 4 | 5 | If your are new to git or GitHub, the following articles may help you: 6 | 7 | * See [Using Pull Requests](https://help.github.com/articles/using-pull-requests) for more information about Pull Requests. 8 | 9 | * See [Fork A Repo](https://help.github.com/forking/) for an introduction to forking a repository and creating branches. 10 | 11 | * See [Git tutorial](https://addy.wiki/git-tutorial) for better understanding of the concept of git & GitHub 12 | 13 | ## Setting up user information 14 | 15 | Please have git setup with consistent user information before sending a patch. Preferably with your real name and a working email address. 16 | 17 | For quick reference, here are the relevant git commands: 18 | 19 | ```bash 20 | git config --global user.name "Your Name Comes Here" 21 | git config --global user.email you@yourdomain.example.com 22 | ``` 23 | 24 | ## Fixing a bug 25 | 26 | Write a test case *before* fixing the bug (so that you will know that the test case catches the bug). For applications without a test suite in the git repository, it would be appreciated if you provide a small code sample in the commit message or email a module that will provoke the failure. 27 | 28 | ## Adding a new feature 29 | 30 | * It is important to write a [good commit message](https://addy.wiki/commit-guidelines) explaining **why** the feature is needed. We prefer that the information is in the commit message, so that anyone that want to know two years later why a particular feature can easily find out. *It does no harm to provide the same information in the pull request*. 31 | 32 | * With few exceptions, it is mandatory to write a new test case that tests the feature. The test case is needed to ensure that the features does not stop working in the future. 33 | 34 | * If you are implementing a new feature, also update the **documentation** to describe the feature. 35 | 36 | * Make sure that the new feature builds and works on all major platforms. 37 | 38 | * Make sure the patch does not break backward compatibility. In general, we only break backward compatibility in major releases and only for a very good reason and usually after first deprecating the feature one or two releases beforehand. 39 | 40 | ## Before you submit your pull request 41 | 42 | - Make sure existing test cases don't fail. It is not necessary to run all tests (that would take many hours), but you should at least run the tests for the application you have changed. 43 | 44 | - Make sure that your branch contains clean commits: 45 | - Follow the guidelines for [writing good commit messages](https://addy.wiki/commit-guidelines). 46 | - Make separate commits for separate changes. If you cannot describe what the commit does in one sentence, it is probably a mix of changes and should be separated into several commits. 47 | - Use `git rebase` if you need to resolve merge conflicts or include the latest changes. 48 | - Check for unnecessary whitespace before committing with `git diff --check`. 49 | 50 | - Check your coding style: 51 | - Make sure your changes follow the coding and indentation style of the code surrounding your changes. 52 | - Do not commit commented-out code or files that are no longer needed. Remove the code or the files. 53 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {2017} {Addy-Smart-Addresses} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Addy Addy-Android 2 | 3 | [![Join the chat at https://gitter.im/addy-org/Addy-Android](https://badges.gitter.im/addy-org/Addy-Android.svg)](https://gitter.im/addy-org/Addy-Android?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 4 | [![Build Status](https://travis-ci.org/addy-org/Addy-Android.svg?branch=master)](https://travis-ci.org/addy-org/Addy-Android) 5 | 6 | Like you have an Email ID, for addresses you have Addy! An app that changes the whole addressing system of the world, reducing the hassle of remembering the old, long addresses. Your 'Addy' is a 7 digit unique code that points to your location on the basis of its latitudinal and longitudinal position, giving you all the information of the place and the way to approach it using the mighty Google Maps. It is so accurate that every building of the world has been assigned a different Addy with a minimum distance of 11.132m. 7 | 8 | ## Tech Stack 9 | 10 | - XML 11 | - Java 12 | - RestDB 13 | - Firebase 14 | - Google Maps Geocoder and Places API 15 | 16 | ## Gitter Channel 17 | 18 | 19 | 20 | ## Contribution Guidelines 21 | 22 | 23 | 24 | ## Getting Started with Contributing: 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "reverieworks.addy" 8 | minSdkVersion 22 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | multiDexEnabled true 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | compile fileTree(dir: 'libs', include: ['*.jar']) 25 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 26 | exclude group: 'com.android.support', module: 'support-annotations' 27 | }) 28 | 29 | compile 'com.android.support:appcompat-v7:25.1.0' 30 | compile 'com.android.support:design:25.1.0' 31 | compile 'com.android.support:support-v4:25.1.0' 32 | compile 'com.google.firebase:firebase-auth:10.0.1' 33 | compile 'com.google.android.gms:play-services-auth:10.0.1' 34 | compile 'com.google.android.gms:play-services:10.0.1' 35 | compile 'com.facebook.android:facebook-android-sdk:[4,5)' 36 | compile 'com.android.support:multidex:1.0.1' 37 | testCompile 'junit:junit:4.12' 38 | } 39 | apply plugin: 'com.google.gms.google-services' -------------------------------------------------------------------------------- /app/google-services.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_info": { 3 | "project_number": "842939912941", 4 | "firebase_url": "https://addy-c36e3.firebaseio.com", 5 | "project_id": "addy-c36e3", 6 | "storage_bucket": "addy-c36e3.appspot.com" 7 | }, 8 | "client": [ 9 | { 10 | "client_info": { 11 | "mobilesdk_app_id": "1:842939912941:android:e1520c0e6095ac6b", 12 | "android_client_info": { 13 | "package_name": "reverieworks.addy" 14 | } 15 | }, 16 | "oauth_client": [ 17 | { 18 | "client_id": "842939912941-m3l98863indp32tpfbds59renvcvf3tg.apps.googleusercontent.com", 19 | "client_type": 3 20 | } 21 | ], 22 | "api_key": [ 23 | { 24 | "current_key": "AIzaSyBJZuzOsHKY3MqpViduSy3dQ5tqXouQ7bY" 25 | } 26 | ], 27 | "services": { 28 | "analytics_service": { 29 | "status": 1 30 | }, 31 | "appinvite_service": { 32 | "status": 1, 33 | "other_platform_oauth_client": [] 34 | }, 35 | "ads_service": { 36 | "status": 2 37 | } 38 | } 39 | } 40 | ], 41 | "configuration_version": "1" 42 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\user\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/reverieworks/addy/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package reverieworks.addy; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("reverieworks.addy", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/debug/res/values/google_maps_api.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 19 | 20 | AIzaSyDVa2TOGPv-jIQdhSkXJJIZIqXndqnBq64 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | 20 | 21 | 29 | 32 | 35 | 36 | 40 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 55 | 59 | 60 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /app/src/main/assets/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/addy-org/Addy-Android/e9440e650d442d1fc50caf96b0a9c34496ccd77a/app/src/main/assets/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/addy-org/Addy-Android/e9440e650d442d1fc50caf96b0a9c34496ccd77a/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /app/src/main/ic_launcher_logo-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/addy-org/Addy-Android/e9440e650d442d1fc50caf96b0a9c34496ccd77a/app/src/main/ic_launcher_logo-web.png -------------------------------------------------------------------------------- /app/src/main/ic_launcher_logo_png-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/addy-org/Addy-Android/e9440e650d442d1fc50caf96b0a9c34496ccd77a/app/src/main/ic_launcher_logo_png-web.png -------------------------------------------------------------------------------- /app/src/main/java/reverieworks/addy/Abstract/PermissionUtils.java: -------------------------------------------------------------------------------- 1 | package reverieworks.addy.Abstract; 2 | 3 | /** 4 | * Created by reverie on 3/24/2017. 5 | */ 6 | 7 | import android.Manifest; 8 | import android.app.AlertDialog; 9 | import android.app.Dialog; 10 | import android.content.DialogInterface; 11 | import android.content.pm.PackageManager; 12 | import android.os.Bundle; 13 | import android.support.v4.app.ActivityCompat; 14 | import android.support.v4.app.DialogFragment; 15 | import android.support.v7.app.AppCompatActivity; 16 | import android.widget.Toast; 17 | /** 18 | * Utility class for access to runtime permissions. 19 | */ 20 | public abstract class PermissionUtils { 21 | 22 | /** 23 | * Requests the fine location permission. If a rationale with an additional explanation should 24 | * be shown to the user, displays a dialog that triggers the request. 25 | */ 26 | public static void requestPermissionMultiple(AppCompatActivity activity, int requestId, 27 | String permission, boolean finishActivity) { 28 | if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) { 29 | // Display a dialog with rationale. 30 | PermissionUtils.RationaleDialog.newInstance(requestId, finishActivity) 31 | .show(activity.getSupportFragmentManager(), "dialog"); 32 | } else { 33 | // Location permission has not been granted yet, request it. 34 | ActivityCompat.requestPermissions(activity, new String[]{permission}, requestId); 35 | 36 | } 37 | } 38 | public static void requestPermission(AppCompatActivity activity, int requestId, 39 | String permission, boolean finishActivity) { 40 | if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) { 41 | // Display a dialog with rationale. 42 | PermissionUtils.RationaleDialog.newInstance(requestId, finishActivity) 43 | .show(activity.getSupportFragmentManager(), "dialog"); 44 | } else { 45 | // Location permission has not been granted yet, request it. 46 | ActivityCompat.requestPermissions(activity, new String[]{permission}, requestId); 47 | 48 | } 49 | } 50 | 51 | /** 52 | * Checks if the result contains a {@link PackageManager#PERMISSION_GRANTED} result for a 53 | * permission from a runtime permissions request. 54 | * 55 | * @see android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback 56 | */ 57 | public static boolean isPermissionGranted(String[] grantPermissions, int[] grantResults, 58 | String permission) { 59 | for (int i = 0; i < grantPermissions.length; i++) { 60 | if (permission.equals(grantPermissions[i])) { 61 | return grantResults[i] == PackageManager.PERMISSION_GRANTED; 62 | } 63 | } 64 | return false; 65 | } 66 | 67 | /** 68 | * A dialog that displays a permission denied message. 69 | */ 70 | public static class PermissionDeniedDialog extends DialogFragment { 71 | 72 | private static final String ARGUMENT_FINISH_ACTIVITY = "finish"; 73 | 74 | private boolean mFinishActivity = false; 75 | 76 | /** 77 | * Creates a new instance of this dialog and optionally finishes the calling Activity 78 | * when the 'Ok' button is clicked. 79 | */ 80 | public static PermissionDeniedDialog newInstance(boolean finishActivity) { 81 | Bundle arguments = new Bundle(); 82 | arguments.putBoolean(ARGUMENT_FINISH_ACTIVITY, finishActivity); 83 | 84 | PermissionDeniedDialog dialog = new PermissionDeniedDialog(); 85 | dialog.setArguments(arguments); 86 | return dialog; 87 | } 88 | 89 | @Override 90 | public Dialog onCreateDialog(Bundle savedInstanceState) { 91 | mFinishActivity = getArguments().getBoolean(ARGUMENT_FINISH_ACTIVITY); 92 | 93 | return new AlertDialog.Builder(getActivity()) 94 | .setMessage("Location Permission Denied") 95 | .setPositiveButton(android.R.string.ok, null) 96 | .create(); 97 | } 98 | 99 | @Override 100 | public void onDismiss(DialogInterface dialog) { 101 | super.onDismiss(dialog); 102 | if (mFinishActivity) { 103 | Toast.makeText(getActivity(),"Dismiss", 104 | Toast.LENGTH_SHORT).show(); 105 | getActivity().finish(); 106 | } 107 | } 108 | } 109 | 110 | /** 111 | * A dialog that explains the use of the location permission and requests the necessary 112 | * permission. 113 | *

114 | * The activity should implement 115 | * {@link android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback} 116 | * to handle permit or denial of this permission request. 117 | */ 118 | public static class RationaleDialog extends DialogFragment { 119 | 120 | private static final String ARGUMENT_PERMISSION_REQUEST_CODE = "requestCode"; 121 | 122 | private static final String ARGUMENT_FINISH_ACTIVITY = "finish"; 123 | 124 | private boolean mFinishActivity = false; 125 | private String message; 126 | 127 | /** 128 | * Creates a new instance of a dialog displaying the rationale for the use of the location 129 | * permission. 130 | *

131 | * The permission is requested after clicking 'ok'. 132 | * 133 | * @param requestCode Id of the request that is used to request the permission. It is 134 | * returned to the 135 | * {@link android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback}. 136 | * @param finishActivity Whether the calling Activity should be finished if the dialog is 137 | * cancelled. 138 | */ 139 | public static RationaleDialog newInstance(int requestCode, boolean finishActivity) { 140 | Bundle arguments = new Bundle(); 141 | arguments.putInt(ARGUMENT_PERMISSION_REQUEST_CODE, requestCode); 142 | arguments.putBoolean(ARGUMENT_FINISH_ACTIVITY, finishActivity); 143 | RationaleDialog dialog = new RationaleDialog(); 144 | dialog.setArguments(arguments); 145 | return dialog; 146 | } 147 | /* 148 | * 1000 - Homepage Location Service 149 | * 1 - Request Blood Location Service 150 | *4000- 151 | * */ 152 | 153 | private static final int WRITE_EXTERNAL_STORAGE_AND_CAMERA_REQUEST_CODE = 5000; 154 | private static final int WRITE_EXTERNAL_STORAGE_REQUEST_CODE = 3000; 155 | private static final int CAMERA_REQUEST_CODE = 4000; 156 | @Override 157 | public Dialog onCreateDialog(Bundle savedInstanceState) { 158 | Bundle arguments = getArguments(); 159 | final int requestCode = arguments.getInt(ARGUMENT_PERMISSION_REQUEST_CODE); 160 | mFinishActivity = arguments.getBoolean(ARGUMENT_FINISH_ACTIVITY); 161 | 162 | if(requestCode == 1000){ 163 | message = "Permission required to update your location"; 164 | }else if(requestCode == 1){ 165 | message = "Permission Required To Search Donors"; 166 | }else if(requestCode == 3000 || requestCode == 5000){ 167 | message = "Permission Required To Update Data"; 168 | }else if(requestCode == 4000){ 169 | message = "Permission Required To Upload Profile Picture"; 170 | }else if(requestCode == 5000){ 171 | message = "Permission Required To Call Hospital"; 172 | } 173 | return new AlertDialog.Builder(getActivity()) 174 | .setMessage(message) 175 | .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { 176 | @Override 177 | public void onClick(DialogInterface dialog, int which) { 178 | // After click on Ok, request the permission. 179 | 180 | if(requestCode == 1000){ 181 | ActivityCompat.requestPermissions(getActivity(), 182 | new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, 183 | requestCode); 184 | }else if(requestCode == 1){ 185 | ActivityCompat.requestPermissions(getActivity(), 186 | new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, 187 | requestCode); 188 | }else if(requestCode == 3000 || requestCode == 5000){ 189 | ActivityCompat.requestPermissions(getActivity(), 190 | new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, 191 | requestCode); 192 | }else if(requestCode == 4000){ 193 | ActivityCompat.requestPermissions(getActivity(), 194 | new String[]{android.Manifest.permission.CAMERA}, 195 | requestCode); 196 | }else if(requestCode == 5000){ 197 | ActivityCompat.requestPermissions(getActivity(), 198 | new String[]{Manifest.permission.CALL_PHONE}, 199 | requestCode); 200 | } 201 | // Do not finish the Activity while requesting permission. 202 | mFinishActivity = false; 203 | } 204 | }) 205 | .setNegativeButton(android.R.string.cancel, null) 206 | .create(); 207 | } 208 | 209 | @Override 210 | public void onDismiss(DialogInterface dialog) { 211 | super.onDismiss(dialog); 212 | if (mFinishActivity) { 213 | Toast.makeText(getActivity(), 214 | "Permission Denied", 215 | Toast.LENGTH_SHORT) 216 | .show(); 217 | getActivity().finish(); 218 | } 219 | } 220 | } 221 | } -------------------------------------------------------------------------------- /app/src/main/java/reverieworks/addy/Activity/ACodeJSON.java: -------------------------------------------------------------------------------- 1 | package reverieworks.addy.Activity; 2 | 3 | /** 4 | * Created by user on 3/25/2017. 5 | */ 6 | 7 | public class ACodeJSON 8 | { 9 | private String Acode; 10 | 11 | private String _id; 12 | 13 | private String UserName; 14 | 15 | private String Special_Name; 16 | 17 | public String getAcode () 18 | { 19 | return Acode; 20 | } 21 | 22 | public void setAcode (String Acode) 23 | { 24 | this.Acode = Acode; 25 | } 26 | 27 | public String get_id () 28 | { 29 | return _id; 30 | } 31 | 32 | public void set_id (String _id) 33 | { 34 | this._id = _id; 35 | } 36 | 37 | public String getUserName () 38 | { 39 | return UserName; 40 | } 41 | 42 | public void setUserName (String UserName) 43 | { 44 | this.UserName = UserName; 45 | } 46 | 47 | public String getSpecial_Name () 48 | { 49 | return Special_Name; 50 | } 51 | 52 | public void setSpecial_Name (String Special_Name) 53 | { 54 | this.Special_Name = Special_Name; 55 | } 56 | 57 | @Override 58 | public String toString() 59 | { 60 | return "ClassPojo [Acode = "+Acode+", _id = "+_id+", UserName = "+UserName+", Special_Name = "+Special_Name+"]"; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/reverieworks/addy/Activity/Homepage.java: -------------------------------------------------------------------------------- 1 | package reverieworks.addy.Activity; 2 | 3 | import android.os.Bundle; 4 | import android.support.design.widget.FloatingActionButton; 5 | import android.support.design.widget.NavigationView; 6 | import android.support.design.widget.Snackbar; 7 | import android.support.v4.view.GravityCompat; 8 | import android.support.v4.view.ViewPager; 9 | import android.support.v4.widget.DrawerLayout; 10 | import android.support.v7.app.ActionBarDrawerToggle; 11 | import android.support.v7.app.AppCompatActivity; 12 | import android.support.v7.widget.Toolbar; 13 | import android.view.Menu; 14 | import android.view.MenuItem; 15 | import android.view.View; 16 | 17 | import reverieworks.addy.R; 18 | 19 | public class Homepage extends AppCompatActivity 20 | implements NavigationView.OnNavigationItemSelectedListener { 21 | 22 | private ViewPager viewPager; 23 | 24 | @Override 25 | protected void onCreate(Bundle savedInstanceState) { 26 | super.onCreate(savedInstanceState); 27 | setContentView(R.layout.activity_homepage); 28 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 29 | setSupportActionBar(toolbar); 30 | 31 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 32 | fab.setOnClickListener(new View.OnClickListener() { 33 | @Override 34 | public void onClick(View view) { 35 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) 36 | .setAction("Action", null).show(); 37 | } 38 | }); 39 | 40 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 41 | ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( 42 | this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); 43 | drawer.setDrawerListener(toggle); 44 | toggle.syncState(); 45 | 46 | NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); 47 | navigationView.setNavigationItemSelectedListener(this); 48 | 49 | 50 | } 51 | 52 | 53 | @Override 54 | public void onBackPressed() { 55 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 56 | if (drawer.isDrawerOpen(GravityCompat.START)) { 57 | drawer.closeDrawer(GravityCompat.START); 58 | } else { 59 | super.onBackPressed(); 60 | } 61 | } 62 | 63 | @Override 64 | public boolean onCreateOptionsMenu(Menu menu) { 65 | // Inflate the menu; this adds items to the action bar if it is present. 66 | getMenuInflater().inflate(R.menu.homepage, menu); 67 | return true; 68 | } 69 | 70 | @Override 71 | public boolean onOptionsItemSelected(MenuItem item) { 72 | // Handle action bar item clicks here. The action bar will 73 | // automatically handle clicks on the Home/Up button, so long 74 | // as you specify a parent activity in AndroidManifest.xml. 75 | int id = item.getItemId(); 76 | 77 | //noinspection SimplifiableIfStatement 78 | if (id == R.id.action_settings) { 79 | return true; 80 | } 81 | 82 | return super.onOptionsItemSelected(item); 83 | } 84 | 85 | @SuppressWarnings("StatementWithEmptyBody") 86 | @Override 87 | public boolean onNavigationItemSelected(MenuItem item) { 88 | // Handle navigation view item clicks here. 89 | int id = item.getItemId(); 90 | 91 | if (id == R.id.nav_camera) { 92 | // Handle the camera action 93 | } else if (id == R.id.nav_gallery) { 94 | 95 | } else if (id == R.id.nav_slideshow) { 96 | 97 | } else if (id == R.id.nav_manage) { 98 | 99 | } else if (id == R.id.nav_share) { 100 | 101 | } else if (id == R.id.nav_send) { 102 | 103 | } 104 | 105 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 106 | drawer.closeDrawer(GravityCompat.START); 107 | return true; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /app/src/main/java/reverieworks/addy/Activity/MapsActivity.java: -------------------------------------------------------------------------------- 1 | package reverieworks.addy.Activity; 2 | 3 | import android.Manifest; 4 | import android.app.Activity; 5 | import android.app.ProgressDialog; 6 | import android.content.Context; 7 | import android.content.DialogInterface; 8 | import android.content.Intent; 9 | import android.content.IntentSender; 10 | import android.content.pm.PackageManager; 11 | import android.location.Location; 12 | import android.location.LocationManager; 13 | import android.net.ConnectivityManager; 14 | import android.net.NetworkInfo; 15 | import android.os.AsyncTask; 16 | import android.os.Build; 17 | import android.os.Bundle; 18 | import android.support.annotation.NonNull; 19 | import android.support.annotation.Nullable; 20 | import android.support.design.widget.NavigationView; 21 | import android.support.v4.app.ActivityCompat; 22 | import android.support.v4.content.ContextCompat; 23 | import android.support.v4.widget.DrawerLayout; 24 | import android.support.v7.app.AlertDialog; 25 | import android.support.v7.app.AppCompatActivity; 26 | import android.util.Log; 27 | import android.view.LayoutInflater; 28 | import android.view.Menu; 29 | import android.view.MenuItem; 30 | import android.view.View; 31 | import android.widget.Button; 32 | import android.widget.EditText; 33 | import android.widget.ProgressBar; 34 | import android.widget.SearchView; 35 | import android.widget.Toast; 36 | 37 | import com.google.android.gms.common.ConnectionResult; 38 | import com.google.android.gms.common.GooglePlayServicesNotAvailableException; 39 | import com.google.android.gms.common.GooglePlayServicesRepairableException; 40 | import com.google.android.gms.common.api.GoogleApiClient; 41 | import com.google.android.gms.common.api.PendingResult; 42 | import com.google.android.gms.common.api.ResultCallback; 43 | import com.google.android.gms.common.api.Status; 44 | import com.google.android.gms.location.LocationListener; 45 | import com.google.android.gms.location.LocationRequest; 46 | import com.google.android.gms.location.LocationServices; 47 | import com.google.android.gms.location.LocationSettingsRequest; 48 | import com.google.android.gms.location.LocationSettingsResult; 49 | import com.google.android.gms.location.LocationSettingsStatusCodes; 50 | import com.google.android.gms.location.places.Place; 51 | import com.google.android.gms.location.places.ui.PlaceAutocomplete; 52 | import com.google.android.gms.maps.CameraUpdate; 53 | import com.google.android.gms.maps.CameraUpdateFactory; 54 | import com.google.android.gms.maps.GoogleMap; 55 | import com.google.android.gms.maps.OnMapReadyCallback; 56 | import com.google.android.gms.maps.SupportMapFragment; 57 | import com.google.android.gms.maps.model.LatLng; 58 | import com.google.android.gms.maps.model.LatLngBounds; 59 | import com.google.android.gms.maps.model.Marker; 60 | import com.google.android.gms.maps.model.MarkerOptions; 61 | 62 | import org.json.JSONArray; 63 | import org.json.JSONException; 64 | import org.json.JSONObject; 65 | import org.json.JSONTokener; 66 | 67 | import java.io.BufferedReader; 68 | import java.io.DataOutputStream; 69 | import java.io.IOException; 70 | import java.io.InputStream; 71 | import java.io.InputStreamReader; 72 | import java.net.HttpURLConnection; 73 | import java.net.URL; 74 | 75 | import reverieworks.addy.R; 76 | 77 | import static reverieworks.addy.R.id.map; 78 | 79 | public class MapsActivity extends AppCompatActivity implements 80 | GoogleMap.OnMyLocationButtonClickListener, 81 | OnMapReadyCallback, 82 | ActivityCompat.OnRequestPermissionsResultCallback, 83 | GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, GoogleMap.OnMarkerClickListener { 84 | 85 | private static final int REQUEST_CHECK_SETTINGS = 1000; 86 | private static final int PLACE_AUTOCOMPLETE_REQUEST_CODE = 1; 87 | private static final String TAG = "MaspActivity"; 88 | private GoogleMap mMap; 89 | private LocationManager mLocationManager; 90 | private Location mLastLocation; 91 | private GoogleApiClient mGoogleApiClient; 92 | private String receive_current_latitude; 93 | private String receive_current_longitude; 94 | private Button button_searchByPlaces; 95 | private Button button_searchByACode; 96 | private SearchView searchView; 97 | private NavigationView navigationView; 98 | private DrawerLayout drawer; 99 | private ProgressBar progressBar; 100 | private ProgressDialog progressDialog; 101 | private String latlng; 102 | 103 | @Override 104 | protected void onCreate(Bundle savedInstanceState) { 105 | super.onCreate(savedInstanceState); 106 | setContentView(R.layout.activity_maps_main); 107 | 108 | assert getSupportActionBar() != null; 109 | { 110 | getSupportActionBar().setTitle("Addy"); 111 | } 112 | 113 | //progressbar 114 | progressDialog = new ProgressDialog(this); 115 | progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); 116 | progressDialog.setCanceledOnTouchOutside(false); 117 | 118 | // Create an instance of GoogleAPIClient. To get current location 119 | if (mGoogleApiClient == null) { 120 | mGoogleApiClient = new GoogleApiClient.Builder(this) 121 | .addConnectionCallbacks(this) 122 | .addOnConnectionFailedListener(this) 123 | .addApi(LocationServices.API) 124 | .build(); 125 | } 126 | 127 | // Obtain the SupportMapFragment and get notified when the map is ready to be used. 128 | SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() 129 | .findFragmentById(map); 130 | mapFragment.getMapAsync(this); 131 | 132 | button_searchByACode = (Button) findViewById(R.id.button_SearchByACode); 133 | button_searchByACode.setOnClickListener(new View.OnClickListener() { 134 | @Override 135 | public void onClick(View v) { 136 | 137 | Context context = MapsActivity.this; 138 | LayoutInflater li = LayoutInflater.from(context); 139 | View promptsView = li.inflate(R.layout.dialog_layout, null); 140 | 141 | AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( 142 | context); 143 | 144 | // set prompts.xml to alertdialog builder 145 | alertDialogBuilder.setView(promptsView); 146 | 147 | final EditText userInput = (EditText) promptsView 148 | .findViewById(R.id.editTextDialogUserInput); 149 | 150 | // set dialog message 151 | alertDialogBuilder 152 | .setCancelable(false) 153 | .setPositiveButton("OK", 154 | new DialogInterface.OnClickListener() { 155 | public void onClick(DialogInterface dialog, int id) { 156 | // get user input and set it to result 157 | // edit text 158 | Toast.makeText(getApplicationContext(), userInput.getText(), Toast.LENGTH_LONG).show(); 159 | if (isLegalACodeCustomName(userInput.getText().toString())) 160 | new GetACodeFromCustomName().execute(userInput.getText().toString()); 161 | else { 162 | 163 | 164 | String latlng2 = convertback(userInput.getText().toString()); 165 | String[] latlong = latlng2.split(","); 166 | double latitude = Double.parseDouble(latlong[0]); 167 | double longitude = Double.parseDouble(latlong[1]); 168 | LatLng location = new LatLng(latitude, longitude); 169 | createMarker(userInput.getText().toString(),location,latitude,longitude); 170 | } 171 | } 172 | }) 173 | .setNegativeButton("Cancel", 174 | new DialogInterface.OnClickListener() { 175 | public void onClick(DialogInterface dialog, int id) { 176 | dialog.cancel(); 177 | } 178 | }); 179 | 180 | // create alert dialog 181 | AlertDialog alertDialog = alertDialogBuilder.create(); 182 | 183 | // show it 184 | alertDialog.show(); 185 | } 186 | }); 187 | 188 | button_searchByPlaces = (Button) findViewById(R.id.button_SearchByPlace); 189 | button_searchByPlaces.setOnClickListener(new View.OnClickListener() { 190 | @Override 191 | public void onClick(View v) { 192 | 193 | try { 194 | 195 | Intent intent = 196 | new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_FULLSCREEN) 197 | .build(MapsActivity.this); 198 | startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE); 199 | } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) { 200 | // TODO: Handle the error. 201 | } 202 | } 203 | }); 204 | /* 205 | 206 | 207 | ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.openDrawer, R.string.closeDrawer) { 208 | 209 | @Override 210 | public void onDrawerClosed(View drawerView) { 211 | // Code here will be triggered once the drawer closes as we dont want anything to happen so we leave this blank 212 | super.onDrawerClosed(drawerView); 213 | } 214 | 215 | @Override 216 | public void onDrawerOpened(View drawerView) { 217 | // Code here will be triggered once the drawer open as we dont want anything to happen so we leave this blank 218 | super.onDrawerOpened(drawerView); 219 | } 220 | }; 221 | 222 | //Setting the actionbarToggle to drawer layout 223 | drawer.setDrawerListener(actionBarDrawerToggle); 224 | 225 | //calling sync state is necessary or else your hamburger icon wont show up 226 | actionBarDrawerToggle.syncState(); 227 | } 228 | 229 | */ 230 | 231 | } 232 | 233 | 234 | public boolean isLegalACodeCustomName(String acode) { 235 | 236 | for (int i = 0; i < acode.length(); i++) 237 | if (acode.charAt(0) >= 97 && acode.charAt(0) <= 122) 238 | return true; 239 | return false; 240 | 241 | } 242 | 243 | class GetACodeFromCustomName extends AsyncTask { 244 | 245 | int responseCode; 246 | String JsonResponse; 247 | 248 | protected void onPreExecute() { 249 | 250 | progressDialog.setMessage("Searching..."); 251 | progressDialog.show(); 252 | } 253 | 254 | @Override 255 | protected String doInBackground(String... params) { 256 | String data_value = params[0]; 257 | HttpURLConnection urlConnection = null; 258 | BufferedReader reader = null; 259 | try { 260 | 261 | URL url = new URL("https://addydatabase-a4e8.restdb.io/rest/addydata?q={\"Special_Name\":\"" + data_value + "\"}"); 262 | urlConnection = (HttpURLConnection) url.openConnection(); 263 | Log.d(TAG, "Connected To : " + String.valueOf(url)); 264 | //set headers 265 | urlConnection.setRequestMethod("GET"); 266 | urlConnection.setRequestProperty("x-apikey", "0e835d0ce5cc81e9ae08fb1f7ac2392ad04ee"); 267 | urlConnection.setRequestProperty("cache-control", "no-cache"); 268 | urlConnection.setRequestProperty("Content-Type", "application/json"); 269 | urlConnection.connect(); 270 | //0 271 | //get response code 272 | responseCode = urlConnection.getResponseCode(); 273 | android.util.Log.e(TAG, "ResponseMessage " + urlConnection.getResponseMessage() + " ; ResponseCode " + urlConnection.getResponseCode()); 274 | 275 | InputStream inputStream = urlConnection.getInputStream(); 276 | //input stream 277 | StringBuilder buffer = new StringBuilder(); 278 | if (inputStream == null) { 279 | // Nothing to do. 280 | // android.util.Log.e(TAG, "InputStream Is Null"); 281 | return null; 282 | 283 | } 284 | reader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); 285 | 286 | String inputLine; 287 | while ((inputLine = reader.readLine()) != null) 288 | buffer.append(inputLine).append("\n"); 289 | 290 | if (buffer.length() == 0) { 291 | //android.util.Log.e(TAG, "Stream was empty. No point in parsing."); 292 | return null; 293 | } else { 294 | 295 | JsonResponse = buffer.toString(); 296 | //response data 297 | //android.util.Log.i(TAG, "doInBackGround() " + JsonResponse); 298 | return JsonResponse; 299 | } 300 | 301 | } catch (IOException e) { 302 | e.printStackTrace(); 303 | } finally { 304 | if (urlConnection != null) { 305 | urlConnection.disconnect(); 306 | } 307 | if (reader != null) { 308 | try { 309 | reader.close(); 310 | } catch (final IOException e) { 311 | android.util.Log.e(TAG, "Error closing stream", e); 312 | } 313 | } 314 | } 315 | return null; 316 | } 317 | 318 | protected void onPostExecute(String data) { 319 | 320 | //android.util.Log.i(TAG, "no return"); 321 | if (data == null) { 322 | android.util.Log.e(TAG, "Error Null"); 323 | } 324 | progressDialog.dismiss(); 325 | String message_alertBox; 326 | String title_alertBox; 327 | 328 | Log.e("TAG1", data); 329 | LatLngBounds.Builder latlng = new LatLngBounds.Builder(); 330 | 331 | if (responseCode == 200) { 332 | 333 | android.util.Log.i(TAG, "Response Code = 200.... " + data); 334 | 335 | try { 336 | android.util.Log.e(TAG, "Inside try"); 337 | 338 | //if(data_currentRadius == null) 339 | 340 | //Convert String to JSON Data 341 | JSONArray jsonObject_mainArray = (JSONArray) new JSONTokener(data).nextValue(); 342 | JSONObject jsonObject_main = jsonObject_mainArray.getJSONObject(0); 343 | ACodeJSON object; 344 | 345 | 346 | String latlng2 = convertback(jsonObject_main.getString("Acode")); 347 | String[] latlong = latlng2.split(","); 348 | double latitude = Double.parseDouble(latlong[0]); 349 | double longitude = Double.parseDouble(latlong[1]); 350 | LatLng location = new LatLng(latitude, longitude); 351 | createMarker(jsonObject_main.getString("Acode"),location,latitude,longitude); 352 | 353 | Log.e("TAG", latlng2); 354 | 355 | //if(jsonObject.getString()) 356 | 357 | 358 | } catch (JSONException e) { 359 | // Log.e(TAG, "ERROR PARSING DATA"); 360 | e.printStackTrace(); 361 | } 362 | return; 363 | 364 | } else if (responseCode == 401) { 365 | message_alertBox = "Internal Server Error"; 366 | title_alertBox = "Error"; 367 | //android.util.Log.e(TAG, "Response Code = 401"); 368 | } else { 369 | // android.util.Log.e(TAG, "JSON Response returns =" + data); 370 | title_alertBox = "Failed"; 371 | message_alertBox = "Some Error Occured"; 372 | } 373 | 374 | //android.util.Log.i("INFO", "data" + data); 375 | 376 | showMessageDialog(title_alertBox, message_alertBox); 377 | } 378 | } 379 | 380 | private void createMarker(String acode, LatLng location, double latitude, double longitude) { 381 | Marker mMarker = null; 382 | if (acode!= null) { 383 | 384 | mMap.setOnMarkerClickListener(this); 385 | mMap.addMarker(new MarkerOptions().position(new LatLng(latitude,longitude)).anchor(0.5f, 0.5f).title(acode)); 386 | //mMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.pegman)); 387 | 388 | CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(latitude,longitude), 10); 389 | mMap.animateCamera(cameraUpdate); 390 | 391 | } 392 | } 393 | 394 | 395 | class SendCustomName extends AsyncTask { 396 | 397 | int responseCode; 398 | String JsonResponse; 399 | 400 | protected void onPreExecute() { 401 | 402 | progressDialog.setMessage("Sending custom name..."); 403 | progressDialog.show(); 404 | } 405 | 406 | @Override 407 | protected String doInBackground(String... params) { 408 | 409 | String special_name = params[0]; 410 | String acode = params[1]; 411 | 412 | HttpURLConnection urlConnection = null; 413 | BufferedReader reader = null; 414 | try { 415 | URL url = new URL("https://addydatabase-a4e8.restdb.io/rest/addydata"); 416 | urlConnection = (HttpURLConnection) url.openConnection(); 417 | 418 | JSONObject JSON_Main = new JSONObject(); 419 | 420 | try { 421 | 422 | JSON_Main.put("UserName", "username"); 423 | JSON_Main.put("Acode",acode); 424 | JSON_Main.put("Special_Name",special_name); 425 | //JSON_Main.put() 426 | // Log.e(TAG, JSON_Main.toString()); 427 | 428 | } catch (JSONException e) { 429 | e.printStackTrace(); 430 | } 431 | //set headers 432 | 433 | urlConnection.setRequestMethod("POST"); 434 | urlConnection.setRequestProperty("x-apikey","0e835d0ce5cc81e9ae08fb1f7ac2392ad04ee"); 435 | urlConnection.setRequestProperty("cache-control","no-cache"); 436 | urlConnection.setRequestProperty("CONTENT-TYPE","application/json"); 437 | urlConnection.connect(); 438 | 439 | //set headers and method 440 | DataOutputStream writer = new DataOutputStream(urlConnection.getOutputStream()); 441 | Log.i(TAG, JSON_Main.toString()); 442 | writer.writeBytes(JSON_Main.toString()); 443 | // json data 444 | android.util.Log.e(TAG, "ResponseMessage " + urlConnection.getResponseMessage() + "ResponseCode " + urlConnection.getResponseCode()); 445 | responseCode = urlConnection.getResponseCode(); 446 | writer.flush(); 447 | writer.close(); 448 | 449 | InputStream inputStream = urlConnection.getInputStream(); 450 | //input stream 451 | StringBuilder buffer = new StringBuilder(); 452 | if (inputStream == null) { 453 | // Nothing to do. 454 | // Log.e(TAG, "InputStream Is Null"); 455 | return null; 456 | 457 | } 458 | reader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); 459 | 460 | String inputLine; 461 | while ((inputLine = reader.readLine()) != null) 462 | buffer.append(inputLine).append("\n"); 463 | 464 | if (buffer.length() == 0) { 465 | // Log.e(TAG, "Stream was empty. No point in parsing."); 466 | return null; 467 | } else { 468 | 469 | JsonResponse = buffer.toString(); 470 | //response data 471 | // Log.i(TAG, "doInBackGround() " + JsonResponse); 472 | return JsonResponse; 473 | } 474 | 475 | } catch (IOException e) { 476 | e.printStackTrace(); 477 | } finally { 478 | if (urlConnection != null) { 479 | urlConnection.disconnect(); 480 | } 481 | if (reader != null) { 482 | try { 483 | reader.close(); 484 | } catch (final IOException e) { 485 | // Log.e(TAG, "Error closing stream", e); 486 | } 487 | } 488 | } 489 | return null; 490 | } 491 | 492 | 493 | protected void onPostExecute(String data) { 494 | 495 | // android.util.Log.i(TAG, data); 496 | if (data == null) { 497 | // Log.e(TAG, "Error Null"); 498 | } 499 | 500 | progressDialog.dismiss(); 501 | String message_alertBox; 502 | String title_alertBox; 503 | 504 | if (responseCode == 201) { 505 | 506 | title_alertBox = "Request Sent"; 507 | message_alertBox = "Please Wait For The Response"; 508 | //TODO: add this user to the list, 509 | 510 | } else if (responseCode == 400) { 511 | 512 | message_alertBox = "Error"; 513 | title_alertBox = "User has different Blood group"; 514 | // Log.e(TAG, "Response Code = 400"); 515 | } else if (responseCode == 409) { 516 | 517 | message_alertBox = "Conflict"; 518 | title_alertBox = "You cannot request yourself"; 519 | // Log.e(TAG, "Response Code = 400"); 520 | } else if (responseCode == 404) { 521 | 522 | message_alertBox = "Not Found"; 523 | title_alertBox = "Donor Not Found"; 524 | // Log.e(TAG, "Response Code = 400"); 525 | } else { 526 | 527 | // Log.e(TAG, "JSON Response returns =" + data); 528 | 529 | message_alertBox = "Error"; 530 | title_alertBox = "Internal Server Error"; 531 | // Log.i("INFO", "data" + data); 532 | } 533 | showMessageDialog(title_alertBox, message_alertBox); 534 | } 535 | 536 | 537 | } 538 | 539 | private void showMessageDialog(String title, String message) { 540 | 541 | 542 | android.app.AlertDialog.Builder builderSingle; 543 | if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { 544 | builderSingle = new android.app.AlertDialog.Builder(MapsActivity.this); 545 | } else { 546 | builderSingle = new android.app.AlertDialog.Builder(MapsActivity.this); 547 | } 548 | 549 | // AlertDialog.Builder builderSingle = new AlertDialog.Builder(FirstTimeLogIn.this,R.style.MyAlertDialogStyle); 550 | builderSingle.setMessage(message); 551 | builderSingle.setTitle(title); 552 | builderSingle.setNegativeButton("OK", new DialogInterface.OnClickListener() { 553 | @Override 554 | public void onClick(DialogInterface dialog, int which) { 555 | 556 | 557 | } 558 | }); 559 | builderSingle.show(); 560 | 561 | 562 | } 563 | 564 | String convertback(String Acode) { 565 | StringBuilder ss = new StringBuilder(""); 566 | return ss.append((Integer.parseInt(Acode.substring(0, 4), 36) * 1.0 / 10000) + 7.4).append(",").append((Integer.parseInt(Acode.substring(4, 8), 36) * 1.0 / 10000) + 67.5).toString(); 567 | } 568 | 569 | String convert(double lati, double longi) { 570 | int l = (int) (Math.round(longi * 10000) - 675000); 571 | int la = (int) (Math.round(lati * 10000) - 74000); 572 | return (Integer.toString(la, 36) + Integer.toString(l, 36)).toUpperCase(); 573 | } 574 | 575 | private final LocationListener mLocationListener = new LocationListener() { 576 | @Override 577 | public void onLocationChanged(final Location location) { 578 | //your code here 579 | } 580 | }; 581 | 582 | /** 583 | * Manipulates the map once available. 584 | * This callback is triggered when the map is ready to be used. 585 | * This is where we can add markers or lines, add listeners or move the camera. In this case, 586 | * we just add a marker near Sydney, Australia. 587 | * If Google Play services is not installed on the device, the user will be prompted to install 588 | * it inside the SupportMapFragment. This method will only be triggered once the user has 589 | * installed Google Play services and returned to the app. 590 | */ 591 | 592 | @Override 593 | public void onMapReady(GoogleMap map) { 594 | mMap = map; 595 | 596 | mMap.setOnMyLocationButtonClickListener(this); 597 | if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { 598 | // TODO: Consider calling 599 | // ActivityCompat#requestPermissions 600 | // here to request the missing permissions, and then overriding 601 | // public void onRequestPermissionsResult(int requestCode, String[] permissions, 602 | // int[] grantResults) 603 | // to handle the case where the user grants the permission. See the documentation 604 | // for ActivityCompat#requestPermissions for more details. 605 | return; 606 | } 607 | mMap.setMyLocationEnabled(true); 608 | 609 | enableMyLocation(); 610 | } 611 | private boolean getLatitudeAndLongitude() { 612 | 613 | if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { 614 | // TODO: Consider calling 615 | // ActivityCompat#requestPermissions 616 | // here to request the missing permissions, and then overriding 617 | // public void onRequestPermissionsResult(int requestCode, String[] permissions, 618 | // int[] grantResults) 619 | // to handle the case where the user grants the permission. See the documentation 620 | // for ActivityCompat#requestPermissions for more details. 621 | return false; 622 | } 623 | // Create an instance of GoogleAPIClient. To get current location 624 | // Log.e(TAG, "check " + mGoogleApiClient); 625 | //if (mGoogleApiClient == null) { 626 | //} 627 | 628 | 629 | mLastLocation = LocationServices.FusedLocationApi.getLastLocation( 630 | mGoogleApiClient); 631 | if (mLastLocation == null) { 632 | // Log.e(TAG, "Last Location Was Null"); 633 | displayLocationSettingsRequest(mGoogleApiClient); 634 | } else { 635 | 636 | receive_current_latitude = String.valueOf(mLastLocation.getLatitude()); 637 | receive_current_longitude = String.valueOf(mLastLocation.getLongitude()); 638 | //dialog_Settings.show(); 639 | mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(mLastLocation.getLatitude(), mLastLocation.getLongitude()), 6.0f)); 640 | // Log.e(TAG, "LATITUDE = " + receive_current_latitude); 641 | // Log.e(TAG, "LONGITUDE = " + receive_current_longitude); 642 | } 643 | 644 | return true; 645 | } 646 | 647 | //get current location without navigating to the settings page 648 | private void displayLocationSettingsRequest(GoogleApiClient mGoogleApiClient) { 649 | LocationRequest locationRequest = LocationRequest.create(); 650 | locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); 651 | locationRequest.setInterval(10000); 652 | locationRequest.setFastestInterval(10000 / 2); 653 | 654 | LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest); 655 | builder.setAlwaysShow(true); 656 | 657 | PendingResult result = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build()); 658 | result.setResultCallback(new ResultCallback() { 659 | @Override 660 | public void onResult(@NonNull LocationSettingsResult result) { 661 | final Status status = result.getStatus(); 662 | switch (status.getStatusCode()) { 663 | case LocationSettingsStatusCodes.SUCCESS: 664 | // Log.i(TAG, "All location settings are satisfied." + status); 665 | getLatitudeAndLongitude(); 666 | break; 667 | case LocationSettingsStatusCodes.RESOLUTION_REQUIRED: 668 | // Log.i(TAG, "Location settings are not satisfied. Show the user a dialog to upgrade location settings " + status); 669 | 670 | try { 671 | // Show the dialog by calling startResolutionForResult(), and check the result 672 | // in onActivityResult(). 673 | status.startResolutionForResult(MapsActivity.this, REQUEST_CHECK_SETTINGS); 674 | 675 | } catch (IntentSender.SendIntentException e) { 676 | // Log.i(TAG, "PendingIntent unable to execute request."); 677 | } 678 | break; 679 | case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: 680 | // Log.i(TAG, "Location settings are inadequate, and cannot be fixed here. Dialog not created."); 681 | // Log.e(TAG, "2Last Location Was Denied"); 682 | break; 683 | } 684 | } 685 | }); 686 | } 687 | 688 | @Override 689 | public void onActivityResult(int requestCode, int resultCode, Intent data) { 690 | // Log.d(TAG, "resultCode=" + Integer.toString(resultCode)); 691 | //final LocationSettingsStates states = LocationSettingsStates.fromIntent(data); 692 | switch (resultCode) { 693 | case Activity.RESULT_OK: { 694 | // All required changes were successfully made 695 | // Log.i(TAG, "Location enabled by user!"); 696 | if(requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE){ 697 | Place place = PlaceAutocomplete.getPlace(this, data); 698 | Log.i(TAG, "Place: " + place.getLatLng()); 699 | createMarkerLatLng(convert(place.getLatLng().latitude,place.getLatLng().longitude),place.getLatLng()); 700 | Toast.makeText(getApplicationContext(),place.getName(),Toast.LENGTH_SHORT).show(); 701 | }else { 702 | Toast.makeText(getApplicationContext(), "Location Enabled", Toast.LENGTH_SHORT).show(); 703 | enableMyLocation(); 704 | startActivity(new Intent(MapsActivity.this, MapsActivity.class)); 705 | }break; 706 | } 707 | case Activity.RESULT_CANCELED: { 708 | // The user was asked to change settings, but chose not to 709 | //TODO: display the below code 710 | Toast.makeText(getApplicationContext(),"No Connection Found",Toast.LENGTH_SHORT).show(); 711 | /*Snackbar snackbar = Snackbar.make(, "No Connection Found", Snackbar.LENGTH_INDEFINITE) 712 | .setAction("GO OFFLINE", new View.OnClickListener() { 713 | @Override 714 | public void onClick(View view) { 715 | 716 | } 717 | }); 718 | */// Log.i(TAG, "Location not enabled, user cancelled."); 719 | break; 720 | } 721 | default: { 722 | // Log.e(TAG, "Error in selecting the button in Auto-Switch On Location Feature"); 723 | break; 724 | } 725 | } 726 | } 727 | 728 | private void createMarkerLatLng(CharSequence name, LatLng latLng_local) { 729 | Marker mMarker = null; 730 | if (name!= null) { 731 | 732 | mMap.setOnMarkerClickListener(this); 733 | mMap.addMarker(new MarkerOptions().position(latLng_local).anchor(0.5f, 0.5f).title(name.toString())); 734 | //mMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.pegman)); 735 | 736 | CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng_local, 10); 737 | mMap.animateCamera(cameraUpdate); 738 | 739 | 740 | } 741 | } 742 | 743 | /** 744 | * Enables the My Location layer if the fine location permission has been granted. 745 | */ 746 | private void enableMyLocation() { 747 | if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) 748 | != PackageManager.PERMISSION_GRANTED) { 749 | // Permission to access the location is missing. 750 | // PermissionUtils.requestPermission(getApplicationContext(), LOCATION_PERMISSION_REQUEST_CODE, 751 | // Manifest.permission.ACCESS_FINE_LOCATION, true); 752 | } else if (mMap != null) { 753 | // Access to the location has been granted to the app. 754 | mMap.setMyLocationEnabled(true); 755 | } 756 | } 757 | 758 | 759 | public boolean isNetworkAvailable() { 760 | ConnectivityManager connectivityManager = (ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); 761 | NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); 762 | return activeNetworkInfo != null && activeNetworkInfo.isConnected(); 763 | } 764 | 765 | @Override 766 | public void onConnected(@Nullable Bundle bundle) { 767 | 768 | } 769 | 770 | @Override 771 | public void onConnectionSuspended(int i) { 772 | 773 | } 774 | 775 | @Override 776 | public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { 777 | 778 | } 779 | 780 | @Override 781 | public boolean onMarkerClick(Marker marker) { 782 | getCustomName(marker); 783 | return false; 784 | } 785 | 786 | private void getCustomName(final Marker marker) { 787 | 788 | Context context = MapsActivity.this; 789 | LayoutInflater li = LayoutInflater.from(context); 790 | View promptsView = li.inflate(R.layout.dialog_layout, null); 791 | 792 | AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( 793 | context); 794 | 795 | // set prompts.xml to alertdialog builder 796 | alertDialogBuilder.setView(promptsView); 797 | 798 | final EditText userInput = (EditText) promptsView 799 | .findViewById(R.id.editTextDialogUserInput); 800 | 801 | // set dialog message 802 | alertDialogBuilder 803 | .setCancelable(false) 804 | .setPositiveButton("OK", 805 | new DialogInterface.OnClickListener() { 806 | public void onClick(DialogInterface dialog, int id) { 807 | // get user input and set it to result 808 | // edit text 809 | new SendCustomName().execute(userInput.getText().toString(),convert(marker.getPosition().latitude,marker.getPosition().longitude)); 810 | Toast.makeText(getApplicationContext(), userInput.getText(), Toast.LENGTH_LONG).show(); 811 | 812 | } 813 | }) 814 | .setNegativeButton("Cancel", 815 | new DialogInterface.OnClickListener() { 816 | public void onClick(DialogInterface dialog, int id) { 817 | dialog.cancel(); 818 | } 819 | }); 820 | 821 | // create alert dialog 822 | AlertDialog alertDialog = alertDialogBuilder.create(); 823 | 824 | // show it 825 | alertDialog.show(); 826 | } 827 | 828 | @Override 829 | public boolean onMyLocationButtonClick() { 830 | return false; 831 | } 832 | 833 | @Override 834 | public void onBackPressed(){ 835 | 836 | } 837 | 838 | @Override 839 | public boolean onCreateOptionsMenu(Menu menu) { 840 | getMenuInflater().inflate(R.menu.maps_menu, menu); 841 | 842 | // Retrieve the SearchView and plug it into SearchManager 843 | /* final SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search)); 844 | SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE); 845 | searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); 846 | */ 847 | return true; 848 | } 849 | @Override 850 | public boolean onOptionsItemSelected(MenuItem item) { 851 | switch (item.getItemId()) { 852 | case R.id.action_addCustomName: 853 | // TODO put your code here to respond to the button tap 854 | Toast.makeText(getApplicationContext(), "ADD!", Toast.LENGTH_SHORT).show(); 855 | return true; 856 | default: 857 | return super.onOptionsItemSelected(item); 858 | } 859 | } 860 | 861 | 862 | 863 | } 864 | -------------------------------------------------------------------------------- /app/src/main/java/reverieworks/addy/Activity/PlacesAPIActivity.java: -------------------------------------------------------------------------------- 1 | package reverieworks.addy.Activity; 2 | 3 | import android.Manifest; 4 | import android.content.pm.PackageManager; 5 | import android.os.Bundle; 6 | import android.support.v4.app.ActivityCompat; 7 | import android.support.v4.content.ContextCompat; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.util.Log; 10 | import android.view.View; 11 | import android.widget.Button; 12 | import android.widget.Toast; 13 | 14 | import com.google.android.gms.common.ConnectionResult; 15 | import com.google.android.gms.common.api.GoogleApiClient; 16 | import com.google.android.gms.common.api.PendingResult; 17 | import com.google.android.gms.common.api.ResultCallback; 18 | import com.google.android.gms.location.places.PlaceLikelihood; 19 | import com.google.android.gms.location.places.PlaceLikelihoodBuffer; 20 | import com.google.android.gms.location.places.Places; 21 | 22 | import reverieworks.addy.R; 23 | 24 | public class PlacesAPIActivity extends AppCompatActivity implements 25 | GoogleApiClient.OnConnectionFailedListener { 26 | private static final String LOG_TAG = "PlacesAPIActivity"; 27 | private static final int GOOGLE_API_CLIENT_ID = 0; 28 | private GoogleApiClient mGoogleApiClient; 29 | private static final int PERMISSION_REQUEST_CODE = 100; 30 | 31 | @Override 32 | protected void onCreate(Bundle savedInstanceState) { 33 | super.onCreate(savedInstanceState); 34 | setContentView(R.layout.activity_places_api); 35 | Button currentButton = (Button) findViewById(R.id.currentButton); 36 | mGoogleApiClient = new GoogleApiClient.Builder(PlacesAPIActivity.this) 37 | .addApi(Places.PLACE_DETECTION_API) 38 | .enableAutoManage(this, GOOGLE_API_CLIENT_ID, this) 39 | .build(); 40 | currentButton.setOnClickListener(new View.OnClickListener() { 41 | @Override 42 | public void onClick(View v) { 43 | if (mGoogleApiClient.isConnected()) { 44 | if (ContextCompat.checkSelfPermission(PlacesAPIActivity.this, 45 | Manifest.permission.ACCESS_FINE_LOCATION) 46 | != PackageManager.PERMISSION_GRANTED) { 47 | ActivityCompat.requestPermissions(PlacesAPIActivity.this, 48 | new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 49 | PERMISSION_REQUEST_CODE); 50 | } else { 51 | callPlaceDetectionApi(); 52 | } 53 | 54 | } 55 | } 56 | }); 57 | } 58 | 59 | @Override 60 | public void onConnectionFailed(ConnectionResult connectionResult) { 61 | Log.e(LOG_TAG, "Google Places API connection failed with error code: " 62 | + connectionResult.getErrorCode()); 63 | 64 | Toast.makeText(this, 65 | "Google Places API connection failed with error code:" + 66 | connectionResult.getErrorCode(), 67 | Toast.LENGTH_LONG).show(); 68 | } 69 | 70 | @Override 71 | public void onRequestPermissionsResult(int requestCode, 72 | String permissions[], int[] grantResults) { 73 | switch (requestCode) { 74 | case PERMISSION_REQUEST_CODE: 75 | if (grantResults.length > 0 76 | && grantResults[0] == PackageManager.PERMISSION_GRANTED) { 77 | callPlaceDetectionApi(); 78 | } 79 | break; 80 | } 81 | } 82 | 83 | private void callPlaceDetectionApi() throws SecurityException { 84 | PendingResult result = Places.PlaceDetectionApi 85 | .getCurrentPlace(mGoogleApiClient, null); 86 | result.setResultCallback(new ResultCallback() { 87 | @Override 88 | public void onResult(PlaceLikelihoodBuffer likelyPlaces) { 89 | for (PlaceLikelihood placeLikelihood : likelyPlaces) { 90 | Log.i(LOG_TAG, String.format("Place '%s' with " + 91 | "likelihood: %g", 92 | placeLikelihood.getPlace().getName(), 93 | placeLikelihood.getLikelihood())); 94 | } 95 | likelyPlaces.release(); 96 | } 97 | }); 98 | } 99 | } 100 | 101 | -------------------------------------------------------------------------------- /app/src/main/java/reverieworks/addy/Activity/RegistrationActivity.java: -------------------------------------------------------------------------------- 1 | package reverieworks.addy.Activity; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.content.SharedPreferences; 6 | import android.os.Bundle; 7 | import android.support.design.widget.TabLayout; 8 | import android.support.v4.app.Fragment; 9 | import android.support.v4.app.FragmentManager; 10 | import android.support.v4.app.FragmentPagerAdapter; 11 | import android.support.v4.view.ViewPager; 12 | import android.support.v7.app.AppCompatActivity; 13 | import android.support.v7.widget.Toolbar; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | import reverieworks.addy.Fragment.SignUp; 19 | import reverieworks.addy.Fragment.SignIn; 20 | import reverieworks.addy.R; 21 | 22 | 23 | 24 | public class RegistrationActivity extends AppCompatActivity { 25 | 26 | private static final String TAG = "RegistrationActivity"; 27 | private Toolbar toolbar; 28 | private TabLayout tabLayout; 29 | private ViewPager viewPager; 30 | private String local_sessionManagement="1"; 31 | 32 | @Override 33 | protected void onCreate(Bundle savedInstanceState) { 34 | super.onCreate(savedInstanceState); 35 | setContentView(R.layout.activity_registration); 36 | 37 | //check for session management 38 | //Session Management 39 | SharedPreferences sharedPref = getSharedPreferences(WelcomeActivity.MyPREFERENCES, Context.MODE_PRIVATE); 40 | local_sessionManagement = (sharedPref.getString("LOCAL_sessionManagement", "")); 41 | 42 | if (local_sessionManagement.compareTo("1") == 0) { 43 | finish(); 44 | startActivity(new Intent(RegistrationActivity.this,MapsActivity.class)); 45 | } 46 | 47 | 48 | 49 | toolbar = (Toolbar) findViewById(R.id.toolbar); 50 | //setSupportActionBar(toolbar); 51 | 52 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 53 | 54 | viewPager = (ViewPager) findViewById(R.id.viewpager); 55 | setupViewPager(viewPager); 56 | 57 | tabLayout = (TabLayout) findViewById(R.id.tabs); 58 | tabLayout.setupWithViewPager(viewPager); 59 | 60 | } 61 | 62 | 63 | private void setupViewPager(ViewPager viewPager) { 64 | ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager()); 65 | adapter.addFragment(new SignIn(), "SignIn"); 66 | adapter.addFragment(new SignUp(), "SignUp"); 67 | viewPager.setAdapter(adapter); 68 | } 69 | 70 | class ViewPagerAdapter extends FragmentPagerAdapter { 71 | private final List mFragmentList = new ArrayList<>(); 72 | private final List mFragmentTitleList = new ArrayList<>(); 73 | 74 | public ViewPagerAdapter(FragmentManager manager) { 75 | super(manager); 76 | } 77 | 78 | @Override 79 | public Fragment getItem(int position) { 80 | return mFragmentList.get(position); 81 | } 82 | 83 | @Override 84 | public int getCount() { 85 | return mFragmentList.size(); 86 | } 87 | 88 | public void addFragment(Fragment fragment, String title) { 89 | mFragmentList.add(fragment); 90 | mFragmentTitleList.add(title); 91 | } 92 | 93 | @Override 94 | public CharSequence getPageTitle(int position) { 95 | return mFragmentTitleList.get(position); 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /app/src/main/java/reverieworks/addy/Activity/WelcomeActivity.java: -------------------------------------------------------------------------------- 1 | package reverieworks.addy.Activity; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.content.SharedPreferences; 6 | import android.net.ConnectivityManager; 7 | import android.net.NetworkInfo; 8 | import android.os.Build; 9 | import android.os.Bundle; 10 | import android.os.Handler; 11 | import android.support.v7.app.AppCompatActivity; 12 | import android.widget.Toast; 13 | 14 | import reverieworks.addy.R; 15 | 16 | public class WelcomeActivity extends AppCompatActivity { 17 | 18 | protected int _splashTime = 2000; 19 | public static final String MyPREFERENCES = "MyPrefs" ; 20 | private String local_sessionManagement; 21 | 22 | 23 | @Override 24 | protected void onCreate(Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | setContentView(R.layout.activity_welcome); 27 | //final LinearLayout linearLayout = (LinearLayout) findViewById(R.id.layou); 28 | if (isNetworkAvailable()) { 29 | 30 | Handler handler = new Handler(); 31 | handler.postDelayed(new Runnable() { 32 | public void run() { 33 | finish(); 34 | //check for session management 35 | //Session Management 36 | SharedPreferences sharedPref = getSharedPreferences(WelcomeActivity.MyPREFERENCES, Context.MODE_PRIVATE); 37 | local_sessionManagement = (sharedPref.getString("LOCAL_sessionManagement", "")); 38 | 39 | if (local_sessionManagement.compareTo("1") == 0) { 40 | 41 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 42 | finishAfterTransition(); 43 | } else { 44 | finish(); 45 | } 46 | Intent intent = new Intent(WelcomeActivity.this, reverieworks.addy.Activity.MapsActivity.class); 47 | startActivity(intent); 48 | } else { 49 | // dialog_Settings.show(); 50 | startActivity(new Intent(getApplicationContext(),reverieworks.addy.Activity.RegistrationActivity.class)); 51 | } 52 | } 53 | }, _splashTime); 54 | } else { 55 | Toast.makeText(getApplicationContext(),"No Connetion Found",Toast.LENGTH_LONG).show(); 56 | Toast.makeText(getApplicationContext(),"No Connetion Found",Toast.LENGTH_LONG).show(); 57 | Toast.makeText(getApplicationContext(),"No Connetion Found",Toast.LENGTH_LONG).show(); 58 | } 59 | } 60 | 61 | public boolean isNetworkAvailable() { 62 | ConnectivityManager connectivityManager = (ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); 63 | NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); 64 | return activeNetworkInfo != null && activeNetworkInfo.isConnected(); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/reverieworks/addy/Fragment/SignIn.java: -------------------------------------------------------------------------------- 1 | package reverieworks.addy.Fragment; 2 | 3 | import android.content.Intent; 4 | import android.content.SharedPreferences; 5 | import android.graphics.PorterDuff; 6 | import android.graphics.Typeface; 7 | import android.os.Bundle; 8 | import android.support.annotation.NonNull; 9 | import android.support.multidex.MultiDex; 10 | import android.support.v4.app.Fragment; 11 | import android.util.Log; 12 | import android.view.LayoutInflater; 13 | import android.view.MotionEvent; 14 | import android.view.View; 15 | import android.view.ViewGroup; 16 | import android.widget.Button; 17 | import android.widget.EditText; 18 | import android.widget.ImageView; 19 | import android.widget.TextView; 20 | import android.widget.Toast; 21 | 22 | import com.facebook.CallbackManager; 23 | import com.facebook.FacebookCallback; 24 | import com.facebook.FacebookException; 25 | import com.facebook.FacebookSdk; 26 | import com.facebook.appevents.AppEventsLogger; 27 | import com.facebook.login.LoginManager; 28 | import com.facebook.login.LoginResult; 29 | import com.facebook.login.widget.LoginButton; 30 | import com.google.android.gms.auth.api.Auth; 31 | import com.google.android.gms.auth.api.signin.GoogleSignInAccount; 32 | import com.google.android.gms.auth.api.signin.GoogleSignInOptions; 33 | import com.google.android.gms.auth.api.signin.GoogleSignInResult; 34 | import com.google.android.gms.common.ConnectionResult; 35 | import com.google.android.gms.common.api.GoogleApiClient; 36 | import com.google.android.gms.common.api.ResultCallback; 37 | import com.google.android.gms.common.api.Status; 38 | import com.google.android.gms.tasks.OnCompleteListener; 39 | import com.google.android.gms.tasks.Task; 40 | import com.google.firebase.auth.AuthCredential; 41 | import com.google.firebase.auth.AuthResult; 42 | import com.google.firebase.auth.FirebaseAuth; 43 | import com.google.firebase.auth.FirebaseUser; 44 | import com.google.firebase.auth.GoogleAuthProvider; 45 | 46 | import reverieworks.addy.Activity.MapsActivity; 47 | import reverieworks.addy.R; 48 | 49 | import static android.content.Context.MODE_PRIVATE; 50 | import static com.facebook.FacebookSdk.getApplicationContext; 51 | import static reverieworks.addy.Activity.WelcomeActivity.MyPREFERENCES; 52 | 53 | 54 | public class SignIn extends Fragment implements GoogleApiClient.OnConnectionFailedListener { 55 | 56 | private static final String TAG = "SignInFragment"; 57 | private TextView textView_usernameLogo_signIn; 58 | private TextView textView_passwordLogo_signIn; 59 | private EditText editText_username; 60 | private EditText editText_password; 61 | private ImageView imageView_facebookLogIn; 62 | private ImageView imageView_GoogleLogIn; 63 | private Button button_signIn; 64 | private FirebaseAuth mAuth; 65 | private FirebaseAuth.AuthStateListener mAuthListener; 66 | private CallbackManager callbackManager; 67 | 68 | private static final int RC_SIGN_IN = 9001; 69 | private GoogleApiClient mGoogleApiClient; 70 | 71 | public SignIn() { 72 | // Required empty public constructor 73 | } 74 | 75 | @Override 76 | public void onCreate(Bundle savedInstanceState) { 77 | 78 | super.onCreate(savedInstanceState); 79 | MultiDex.install(getContext()); 80 | mAuth = FirebaseAuth.getInstance(); 81 | 82 | FacebookSdk.sdkInitialize(getApplicationContext()); 83 | AppEventsLogger.activateApp(getActivity()); 84 | callbackManager = CallbackManager.Factory.create(); 85 | //LoginButton loginButton = (LoginButton) findViewById(R.id.usersettings_fragment_login_button); 86 | //loginButton.registerCallback(callbackManager, new FacebookCallback() { ... }); 87 | callbackManager = CallbackManager.Factory.create(); 88 | 89 | LoginManager.getInstance().registerCallback(callbackManager, 90 | new FacebookCallback() { 91 | @Override 92 | public void onSuccess(LoginResult loginResult) { 93 | // App code 94 | } 95 | 96 | @Override 97 | public void onCancel() { 98 | // App code 99 | } 100 | 101 | @Override 102 | public void onError(FacebookException exception) { 103 | // App code 104 | } 105 | }); 106 | 107 | //Google SignIn 108 | GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) 109 | .requestIdToken(getString(R.string.default_web_client_id)) 110 | .requestEmail() 111 | .build(); 112 | 113 | 114 | mGoogleApiClient = new GoogleApiClient.Builder(getActivity()) 115 | .enableAutoManage(getActivity() /* FragmentActivity */, this /* OnConnectionFailedListener */) 116 | .addApi(Auth.GOOGLE_SIGN_IN_API, gso) 117 | .build(); 118 | 119 | } 120 | 121 | @Override 122 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 123 | Bundle savedInstanceState) { 124 | 125 | final View view = inflater.inflate(R.layout.fragment_sign_in, container, false); 126 | 127 | mAuth = FirebaseAuth.getInstance(); 128 | 129 | mAuthListener = new FirebaseAuth.AuthStateListener() { 130 | @Override 131 | public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { 132 | FirebaseUser user = firebaseAuth.getCurrentUser(); 133 | if (user != null) { 134 | // User is signed in 135 | Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid()); 136 | Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getEmail()); 137 | } else { 138 | // User is signed out 139 | Log.d(TAG, "onAuthStateChanged:signed_out"); 140 | } 141 | // ... 142 | } 143 | }; 144 | 145 | Typeface typeface = Typeface.createFromAsset(getContext().getAssets(), "fonts/fontawesome-webfont.ttf"); 146 | 147 | textView_usernameLogo_signIn = (TextView) view.findViewById(R.id.textView_usernameLogo_signIn); 148 | textView_passwordLogo_signIn = (TextView) view.findViewById(R.id.textView_PasswordLogo_signIn); 149 | 150 | assert textView_usernameLogo_signIn != null; 151 | textView_usernameLogo_signIn.setTypeface(typeface); 152 | 153 | assert textView_passwordLogo_signIn != null; 154 | textView_passwordLogo_signIn.setTypeface(typeface); 155 | 156 | textView_usernameLogo_signIn.setText("\uf007"); 157 | textView_passwordLogo_signIn.setText("\uf023"); 158 | 159 | //Get Details From User 160 | editText_username = (EditText) view.findViewById(R.id.editText_Email_SignIn); 161 | editText_password = (EditText) view.findViewById(R.id.editText_Password_signIn); 162 | 163 | //SignIn 164 | button_signIn = (Button) view.findViewById(R.id.button_logIn_SignIn); 165 | button_signIn.setOnClickListener(new View.OnClickListener() { 166 | @Override 167 | public void onClick(View v) { 168 | 169 | String email = editText_username.getText().toString(); 170 | String password = editText_password.getText().toString(); 171 | 172 | mAuth.signInWithEmailAndPassword(email, password) 173 | .addOnCompleteListener(getActivity(), new OnCompleteListener() { 174 | @Override 175 | public void onComplete(@NonNull Task task) { 176 | Log.d(TAG, "signInWithEmail:onComplete:" + task.isSuccessful()); 177 | 178 | Toast.makeText(getContext(), "Successfully Logged In", Toast.LENGTH_SHORT).show(); 179 | //startActivity(new Intent(getApplicationContext(), Homepage.class)); 180 | // If sign in fails, display a message to the user. If sign in succeeds 181 | // the auth state listener will be notified and logic to handle the 182 | // signed in user can be handled in the listener. 183 | if (!task.isSuccessful()) { 184 | Log.w(TAG, "signInWithEmail:failed", task.getException()); 185 | Toast.makeText(getContext(), "Auth Failed", 186 | Toast.LENGTH_SHORT).show(); 187 | } 188 | 189 | // ... 190 | } 191 | }); 192 | } 193 | }); 194 | 195 | //Facebook LogIn 196 | imageView_facebookLogIn = (ImageView) view.findViewById(R.id.imageView_FacebookLogo_signIn); 197 | imageView_facebookLogIn.setOnTouchListener(new View.OnTouchListener() { 198 | @Override 199 | public boolean onTouch(View v, MotionEvent event) { 200 | 201 | switch (event.getAction()) { 202 | 203 | case MotionEvent.ACTION_DOWN:{ 204 | 205 | //overlay is black with transparency of 0x77 (119) 206 | imageView_facebookLogIn.setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP); 207 | imageView_facebookLogIn.invalidate(); 208 | 209 | facebookLogIn(view); 210 | break; 211 | } 212 | case MotionEvent.ACTION_UP:{ 213 | imageView_facebookLogIn.clearColorFilter(); 214 | imageView_facebookLogIn.invalidate(); 215 | break; 216 | } 217 | } 218 | return true; 219 | } 220 | }); 221 | 222 | //Google LogIn 223 | imageView_GoogleLogIn = (ImageView) view.findViewById(R.id.imageView_GoogleLogo_signIn); 224 | imageView_GoogleLogIn.setOnTouchListener(new View.OnTouchListener() { 225 | @Override 226 | public boolean onTouch(View v, MotionEvent event) { 227 | 228 | switch (event.getAction()) { 229 | 230 | case MotionEvent.ACTION_DOWN: { 231 | signIn(); 232 | //overlay is black with transparency of 0x77 (119) 233 | imageView_GoogleLogIn.setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP); 234 | imageView_GoogleLogIn.invalidate(); 235 | break; 236 | } 237 | case MotionEvent.ACTION_UP: { 238 | imageView_GoogleLogIn.clearColorFilter(); 239 | imageView_GoogleLogIn.invalidate(); 240 | break; 241 | } 242 | } 243 | return true; 244 | } 245 | }); 246 | 247 | // Inflate the layout for this fragment 248 | return view; 249 | } 250 | 251 | private void facebookLogIn(View view) { 252 | 253 | LoginButton loginButton = (LoginButton) view.findViewById(R.id.login_button); 254 | loginButton.setReadPermissions("email"); 255 | // If using in a fragment 256 | loginButton.setFragment(this); 257 | // Other app specific specialization 258 | loginButton.performClick(); 259 | // Callback registration 260 | loginButton.registerCallback(callbackManager, new FacebookCallback() { 261 | @Override 262 | public void onSuccess(LoginResult loginResult) { 263 | // App code 264 | Toast.makeText(getContext(), "Logged In Successfully", Toast.LENGTH_SHORT).show(); 265 | setSessionManagement(); 266 | startActivity(new Intent(getApplicationContext(), MapsActivity.class)); 267 | } 268 | 269 | @Override 270 | public void onCancel() { 271 | // App code 272 | Toast.makeText(getContext(), "LogIn Failed", 273 | Toast.LENGTH_SHORT).show(); 274 | } 275 | 276 | @Override 277 | public void onError(FacebookException exception) { 278 | // App code 279 | Toast.makeText(getContext(), "LogIn Failed", 280 | Toast.LENGTH_SHORT).show(); 281 | 282 | } 283 | }); 284 | } 285 | 286 | 287 | @Override 288 | public void onStart() { 289 | super.onStart(); 290 | mAuth.addAuthStateListener(mAuthListener); 291 | } 292 | 293 | @Override 294 | public void onStop() { 295 | super.onStop(); 296 | if (mAuthListener != null) { 297 | mAuth.removeAuthStateListener(mAuthListener); 298 | } 299 | } 300 | 301 | @Override 302 | public void onActivityResult(int requestCode, int resultCode, Intent data) { 303 | super.onActivityResult(requestCode, resultCode, data); 304 | callbackManager.onActivityResult(requestCode, resultCode, data); 305 | 306 | // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...); 307 | if (requestCode == RC_SIGN_IN) { 308 | GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); 309 | if (result.isSuccess()) { 310 | // Google Sign In was successful, authenticate with Firebase 311 | GoogleSignInAccount account = result.getSignInAccount(); 312 | setSessionManagement(); 313 | firebaseAuthWithGoogle(account); 314 | } else { 315 | // Google Sign In failed, update UI appropriately 316 | // ... 317 | } 318 | } 319 | 320 | 321 | } 322 | 323 | private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { 324 | Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); 325 | 326 | AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); 327 | mAuth.signInWithCredential(credential) 328 | .addOnCompleteListener(getActivity(), new OnCompleteListener() { 329 | @Override 330 | public void onComplete(@NonNull Task task) { 331 | Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful()); 332 | 333 | Toast.makeText(getContext(), "Successfully LoggedIn", 334 | Toast.LENGTH_SHORT).show(); 335 | setSessionManagement(); 336 | 337 | startActivity(new Intent(getApplicationContext(), MapsActivity.class)); 338 | 339 | 340 | // If sign in fails, display a message to the user. If sign in succeeds 341 | // the auth state listener will be notified and logic to handle the 342 | // signed in user can be handled in the listener. 343 | if (!task.isSuccessful()) { 344 | Log.w(TAG, "signInWithCredential", task.getException()); 345 | Toast.makeText(getContext(), "Authentication failed.", 346 | Toast.LENGTH_SHORT).show(); 347 | } 348 | // ... 349 | } 350 | }); 351 | } 352 | 353 | private void setSessionManagement() { 354 | 355 | SharedPreferences.Editor editor = this.getActivity().getSharedPreferences(MyPREFERENCES, MODE_PRIVATE).edit(); 356 | 357 | editor.putString("LOCAL_sessionManagement", String.valueOf(1)); 358 | editor.apply(); 359 | } 360 | 361 | private void signIn() { 362 | Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient); 363 | startActivityForResult(signInIntent, RC_SIGN_IN); 364 | } 365 | 366 | @Override 367 | public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { 368 | // An unresolvable error has occurred and Google APIs (including Sign-In) will not 369 | // be available. 370 | Log.d(TAG, "onConnectionFailed:" + connectionResult); 371 | Toast.makeText(getActivity(), "Google Play Services error.", Toast.LENGTH_SHORT).show(); 372 | } 373 | 374 | private void revokeAccess() { 375 | // Firebase sign out 376 | mAuth.signOut(); 377 | 378 | // Google revoke access 379 | Auth.GoogleSignInApi.revokeAccess(mGoogleApiClient).setResultCallback( 380 | new ResultCallback() { 381 | @Override 382 | public void onResult(@NonNull Status status) { 383 | //updateUI(null); 384 | } 385 | }); 386 | } 387 | } -------------------------------------------------------------------------------- /app/src/main/java/reverieworks/addy/Fragment/SignUp.java: -------------------------------------------------------------------------------- 1 | package reverieworks.addy.Fragment; 2 | 3 | import android.content.Intent; 4 | import android.graphics.Typeface; 5 | import android.os.Bundle; 6 | import android.support.annotation.NonNull; 7 | import android.support.v4.app.Fragment; 8 | import android.util.Log; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.Button; 13 | import android.widget.EditText; 14 | import android.widget.TextView; 15 | import android.widget.Toast; 16 | 17 | import com.google.android.gms.tasks.OnCompleteListener; 18 | import com.google.android.gms.tasks.Task; 19 | import com.google.firebase.auth.AuthResult; 20 | import com.google.firebase.auth.FirebaseAuth; 21 | import com.google.firebase.auth.FirebaseUser; 22 | 23 | import reverieworks.addy.Activity.MapsActivity; 24 | import reverieworks.addy.R; 25 | 26 | import static com.facebook.FacebookSdk.getApplicationContext; 27 | import static reverieworks.addy.R.id.textView_userLogo_signUp; 28 | 29 | 30 | public class SignUp extends Fragment{ 31 | 32 | private static final String TAG = "SignUpFragment"; 33 | private TextView textView_userLogo; 34 | private TextView textView_EmailLogo_signUp; 35 | private TextView textView_PasswordLogo_signUp; 36 | private TextView textView_ViewPassword_signUp; 37 | private EditText editText_username; 38 | private EditText editText_password; 39 | private EditText editText_email; 40 | private Button button_signUp; 41 | private FirebaseAuth mAuth; 42 | private FirebaseAuth.AuthStateListener mAuthListener; 43 | 44 | public SignUp() { 45 | // Required empty public constructor 46 | } 47 | 48 | @Override 49 | public void onCreate(Bundle savedInstanceState) { 50 | 51 | super.onCreate(savedInstanceState); 52 | } 53 | 54 | @Override 55 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 56 | Bundle savedInstanceState) { 57 | 58 | 59 | // Inflate the layout for this fragment 60 | final View view = inflater.inflate(R.layout.fragment_sign_up, container, false); 61 | 62 | Typeface typeface = Typeface.createFromAsset(getContext().getAssets(), "fonts/fontawesome-webfont.ttf"); 63 | 64 | textView_userLogo = (TextView) view.findViewById(textView_userLogo_signUp); 65 | textView_EmailLogo_signUp = (TextView) view.findViewById(R.id.textView_EmailLogo_signUp); 66 | textView_PasswordLogo_signUp = (TextView) view.findViewById(R.id.textView_PasswordLogo_signUp); 67 | textView_ViewPassword_signUp = (TextView) view.findViewById(R.id.textView_ViewPassword_signUp); 68 | 69 | assert textView_userLogo != null; 70 | textView_userLogo.setTypeface(typeface); 71 | 72 | assert textView_EmailLogo_signUp != null; 73 | textView_EmailLogo_signUp.setTypeface(typeface); 74 | 75 | assert textView_PasswordLogo_signUp != null; 76 | textView_PasswordLogo_signUp.setTypeface(typeface); 77 | 78 | assert textView_ViewPassword_signUp != null; 79 | textView_ViewPassword_signUp.setTypeface(typeface); 80 | 81 | textView_userLogo.setText("\uf007"); 82 | textView_EmailLogo_signUp.setText("\uf0e0"); 83 | textView_PasswordLogo_signUp.setText("\uf023"); 84 | textView_ViewPassword_signUp.setText("\uf06e"); 85 | textView_ViewPassword_signUp.setOnClickListener(new View.OnClickListener() { 86 | @Override 87 | public void onClick(View v) { 88 | if(textView_ViewPassword_signUp.getText().toString().compareTo("\uf06e")==0) 89 | textView_ViewPassword_signUp.setText("\uf070"); 90 | else 91 | textView_ViewPassword_signUp.setText("\uf06e"); 92 | } 93 | }); 94 | 95 | mAuth = FirebaseAuth.getInstance(); 96 | 97 | mAuthListener = new FirebaseAuth.AuthStateListener() { 98 | @Override 99 | public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { 100 | FirebaseUser user = firebaseAuth.getCurrentUser(); 101 | if (user != null) { 102 | // User is signed in 103 | Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid()); 104 | } else { 105 | // User is signed out 106 | Log.d(TAG, "onAuthStateChanged:signed_out"); 107 | } 108 | // ... 109 | } 110 | }; 111 | 112 | //Get Details From The User (Input) 113 | editText_username = (EditText) view.findViewById(R.id.editText_Name_SignUp); 114 | editText_email = (EditText) view.findViewById(R.id.editText_Email_SignUp); 115 | editText_password = (EditText) view.findViewById(R.id.editText_Password_SignUp); 116 | 117 | //SignUp 118 | button_signUp = (Button) view.findViewById(R.id.button_signUp_signUp); 119 | button_signUp.setOnClickListener(new View.OnClickListener() { 120 | @Override 121 | public void onClick(View v) { 122 | 123 | 124 | String email = editText_email.getText().toString(); 125 | String password = editText_password.getText().toString(); 126 | 127 | mAuth.createUserWithEmailAndPassword(email, password) 128 | .addOnCompleteListener(getActivity(), new OnCompleteListener() { 129 | @Override 130 | public void onComplete(@NonNull Task task) { 131 | Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful()); 132 | 133 | Toast.makeText(getContext(), "Sign Up Success", Toast.LENGTH_SHORT).show(); 134 | startActivity(new Intent(getApplicationContext(), MapsActivity.class)); 135 | // If sign in fails, display a message to the user. If sign in succeeds 136 | // the auth state listener will be notified and logic to handle the 137 | // signed in user can be handled in the listener. 138 | if (!task.isSuccessful()) { 139 | Toast.makeText(getContext(), "Sign Up Failed", Toast.LENGTH_SHORT).show(); 140 | } 141 | 142 | // ... 143 | } 144 | }); 145 | 146 | } 147 | }); 148 | 149 | return view; 150 | } 151 | 152 | private void createAccount(String email, String password) { 153 | 154 | } 155 | 156 | @Override 157 | public void onStart() { 158 | super.onStart(); 159 | mAuth.addAuthStateListener(mAuthListener); 160 | } 161 | 162 | @Override 163 | public void onStop() { 164 | super.onStop(); 165 | if (mAuthListener != null) { 166 | mAuth.removeAuthStateListener(mAuthListener); 167 | } 168 | } 169 | 170 | 171 | } 172 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/facebook_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/addy-org/Addy-Android/e9440e650d442d1fc50caf96b0a9c34496ccd77a/app/src/main/res/drawable/facebook_logo.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/google_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/addy-org/Addy-Android/e9440e650d442d1fc50caf96b0a9c34496ccd77a/app/src/main/res/drawable/google_logo.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_camera.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_gallery.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_manage.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_send.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_share.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_slideshow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/image_button.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/logo_addy_wp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/addy-org/Addy-Android/e9440e650d442d1fc50caf96b0a9c34496ccd77a/app/src/main/res/drawable/logo_addy_wp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/twitter_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/addy-org/Addy-Android/e9440e650d442d1fc50caf96b0a9c34496ccd77a/app/src/main/res/drawable/twitter_logo.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_homepage.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_maps.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 13 | 14 | 18 | 19 | 22 | 23 | 27 | 28 | 29 |