diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..496ee2c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100755 index 0000000..8a088db --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: node_js +node_js: + - "6" +before_script: + - cd iliad-api + - npm install express + - npm install request + - npm install cheerio +script: + - node server.js & + - npm test diff --git a/LICENSE b/LICENSE new file mode 100755 index 0000000..23cb790 --- /dev/null +++ b/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/PRIVACY b/PRIVACY new file mode 100755 index 0000000..7f73164 --- /dev/null +++ b/PRIVACY @@ -0,0 +1,59 @@ +Privacy Policy +Fast0n built the Area Personale app as an Open Source app. This SERVICE is provided by Fast0n at no cost and is intended for use as is. + +This page is used to inform website visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service. + +If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy. + +The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which is accessible at Area Personale unless otherwise defined in this Privacy Policy. + +Information Collection and Use + +For a better experience, while using our Service, I may require you to provide us with certain personally identifiable information. The information that I request is retained on your device and is not collected by me in any way + +The app does use third party services that may collect information used to identify you. + +Link to privacy policy of third party service providers used by the app + +Google Play Services +Log Data + +I want to inform you that whenever you use my Service, in a case of an error in the app I collect data and information (through third party products) on your phone called Log Data. This Log Data may include information such as your device Internet Protocol (“IP”) address, device name, operating system version, the configuration of the app when utilizing my Service, the time and date of your use of the Service, and other statistics. + +Cookies + +Cookies are files with a small amount of data that are commonly used as anonymous unique identifiers. These are sent to your browser from the websites that you visit and are stored on your device's internal memory. + +This Service does not use these “cookies” explicitly. However, the app may use third party code and libraries that use “cookies” to collect information and improve their services. You have the option to either accept or refuse these cookies and know when a cookie is being sent to your device. If you choose to refuse our cookies, you may not be able to use some portions of this Service. + +Service Providers + +I may employ third-party companies and individuals due to the following reasons: + +To facilitate our Service; +To provide the Service on our behalf; +To perform Service-related services; or +To assist us in analyzing how our Service is used. +I want to inform users of this Service that these third parties have access to your Personal Information. The reason is to perform the tasks assigned to them on our behalf. However, they are obligated not to disclose or use the information for any other purpose. + +Security + +I value your trust in providing us your Personal Information, thus we are striving to use commercially acceptable means of protecting it. But remember that no method of transmission over the internet, or method of electronic storage is 100% secure and reliable, and I cannot guarantee its absolute security. + +Links to Other Sites + +This Service may contain links to other sites. If you click on a third-party link, you will be directed to that site. Note that these external sites are not operated by me. Therefore, I strongly advise you to review the Privacy Policy of these websites. I have no control over and assume no responsibility for the content, privacy policies, or practices of any third-party sites or services. + +Children’s Privacy + +These Services do not address anyone under the age of 13. I do not knowingly collect personally identifiable information from children under 13. In the case I discover that a child under 13 has provided me with personal information, I immediately delete this from our servers. If you are a parent or guardian and you are aware that your child has provided us with personal information, please contact me so that I will be able to do necessary actions. + +Changes to This Privacy Policy + +I may update our Privacy Policy from time to time. Thus, you are advised to review this page periodically for any changes. I will notify you of any changes by posting the new Privacy Policy on this page. These changes are effective immediately after they are posted on this page. + +Contact Us + +If you have any questions or suggestions about my Privacy Policy, do not hesitate to contact me. + +This privacy policy page was created at privacypolicytemplate.net and modified/generated by App Privacy Policy Generator \ No newline at end of file diff --git a/README.md b/README.md new file mode 100755 index 0000000..8d71241 --- /dev/null +++ b/README.md @@ -0,0 +1,54 @@ +# Area Personale + +[![Donate](https://img.shields.io/badge/Donate-PayPal-blue?style=flat-square)](https://paypal.me/fast0n) [![License](https://img.shields.io/github/license/Fast0n/iliad)](https://img.shields.io/github/license/Fast0n/iliad) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/fast0n/iliad) ![GitHub All Releases](https://img.shields.io/github/downloads/fast0n/iliad/total) + + +Area Personale è un'app non ufficiale di Iliad che utilizza delle API non ufficiali create ad hoc. + +

Area Personale

+ +## Funzionalità +L'app prende le informazioni dal sito, di conseguenza se una sezione/testo/oggetto non è presente sul sito non lo sarà nemmeno nell'app. + +Di seguito le feature implementate: +* Login +* Attivazione SIM +* Controllo del tracking di spedizione +* Cambio password +* Cambio email +* Ricarica credito +* Visualizzazione costi e dettagli +* Visualizzazione offerte +* Tema scuro +* Modalità offline + +
+ +This is an unofficial API and Android app developed for learning purposes. Iliad Italia S.p.A. is not responsible in any way. + +This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it. + +``` +iliad web app/client + Copyright (C) 2020 Massimiliano Montaleone + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +``` +### Contributors + + +| [
MattVoid](https://github.com/MattVoid)
[💻](https://github.com/Fast0n/iliad/commits?author=mattvoid "Code") [⚠️](https://github.com/Fast0n/iliad/commits?author=mattvoid "Tests") [🐛](https://github.com/Fast0n/iliad/issues?q=author%3Amattvoid "Bug reports") | [
Nicuz](https://github.com/Nicuz)
[🎨]("Design") | +| :---: | :---: | + diff --git a/iliad/.gitignore b/iliad/.gitignore new file mode 100755 index 0000000..5edb4ee --- /dev/null +++ b/iliad/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/iliad/.idea/assetWizardSettings.xml b/iliad/.idea/assetWizardSettings.xml new file mode 100755 index 0000000..a78e40a --- /dev/null +++ b/iliad/.idea/assetWizardSettings.xml @@ -0,0 +1,46 @@ + + + + + + \ No newline at end of file diff --git a/iliad/.idea/caches/build_file_checksums.ser b/iliad/.idea/caches/build_file_checksums.ser new file mode 100755 index 0000000..b457269 Binary files /dev/null and b/iliad/.idea/caches/build_file_checksums.ser differ diff --git a/iliad/.idea/caches/gradle_models.ser b/iliad/.idea/caches/gradle_models.ser new file mode 100755 index 0000000..be60154 Binary files /dev/null and b/iliad/.idea/caches/gradle_models.ser differ diff --git a/iliad/.idea/codeStyles/Project.xml b/iliad/.idea/codeStyles/Project.xml new file mode 100755 index 0000000..681f41a --- /dev/null +++ b/iliad/.idea/codeStyles/Project.xml @@ -0,0 +1,116 @@ + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+
\ No newline at end of file diff --git a/iliad/.idea/encodings.xml b/iliad/.idea/encodings.xml new file mode 100755 index 0000000..15a15b2 --- /dev/null +++ b/iliad/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/iliad/.idea/gradle.xml b/iliad/.idea/gradle.xml new file mode 100755 index 0000000..5cd135a --- /dev/null +++ b/iliad/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/iliad/.idea/inspectionProfiles/Project_Default.xml b/iliad/.idea/inspectionProfiles/Project_Default.xml new file mode 100755 index 0000000..b08e5aa --- /dev/null +++ b/iliad/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/iliad/.idea/jarRepositories.xml b/iliad/.idea/jarRepositories.xml new file mode 100755 index 0000000..eb2873e --- /dev/null +++ b/iliad/.idea/jarRepositories.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/iliad/.idea/misc.xml b/iliad/.idea/misc.xml new file mode 100755 index 0000000..46859f1 --- /dev/null +++ b/iliad/.idea/misc.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/iliad/.idea/runConfigurations.xml b/iliad/.idea/runConfigurations.xml new file mode 100755 index 0000000..7f68460 --- /dev/null +++ b/iliad/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/iliad/.idea/vcs.xml b/iliad/.idea/vcs.xml new file mode 100755 index 0000000..6c0b863 --- /dev/null +++ b/iliad/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/iliad/app/.gitignore b/iliad/app/.gitignore new file mode 100755 index 0000000..67aaf57 --- /dev/null +++ b/iliad/app/.gitignore @@ -0,0 +1,3 @@ +/build +/release +/debug \ No newline at end of file diff --git a/iliad/app/build.gradle b/iliad/app/build.gradle new file mode 100755 index 0000000..8bb6abd --- /dev/null +++ b/iliad/app/build.gradle @@ -0,0 +1,75 @@ +apply plugin: 'com.android.application' +apply plugin: 'io.fabric' +android { + signingConfigs { + } + compileSdkVersion 30 + defaultConfig { + applicationId 'com.fast0n.ap' + targetSdkVersion 30 + versionCode 62 + versionName '0.5' + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' + minSdkVersion 23 + ndk.abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64' + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + productFlavors { + } + compileOptions { + targetCompatibility '1.8' + sourceCompatibility '1.8' + } + buildToolsVersion '30.0.2' + defaultConfig { + vectorDrawables { + useSupportLibrary = true + } + } + android { + lintOptions { + checkReleaseBuilds false + } + } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.1' + implementation 'com.google.android.material:material:1.2.1' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + testImplementation 'junit:junit:4.13' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + // google library + implementation 'com.android.volley:volley:1.1.1' + implementation 'com.google.firebase:firebase-analytics:17.5.0' + //implementation 'com.google.firebase:firebase-core:16.0.8' + implementation 'com.google.firebase:firebase-messaging:17.6.0' + implementation 'com.crashlytics.sdk.android:crashlytics:2.10.0' + // github library + implementation 'com.github.bumptech.glide:glide:4.11.0' + annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' + implementation 'com.github.GrenderG:Toasty:1.3.0' + implementation 'com.github.ybq:Android-SpinKit:1.2.0' + implementation 'com.github.sharish:CreditCardView:v1.0.4' + implementation 'com.github.javiersantos:MaterialStyledDialogs:2.1' + implementation 'com.thoughtbot:expandablerecyclerview:1.3' + implementation 'com.github.blikoon:QRCodeScanner:0.1.2' + implementation 'com.github.StevenDXC:DxLoadingButton:2.0' + implementation 'gun0912.ted:tedpermission:2.2.2' + implementation('com.journeyapps:zxing-android-embedded:3.6.0') { transitive = false } + + implementation 'com.ethanhua:skeleton:1.1.2' + implementation 'io.supercharge:shimmerlayout:2.1.0' + //account Library + implementation 'com.mikepenz:itemanimators:1.0.2' + implementation 'com.mikepenz:materialdrawer:6.0.8' +} +apply plugin: 'com.google.gms.google-services' diff --git a/iliad/app/google-services.json b/iliad/app/google-services.json new file mode 100755 index 0000000..d46713e --- /dev/null +++ b/iliad/app/google-services.json @@ -0,0 +1,48 @@ +{ + "project_info": { + "project_number": "789065959141", + "firebase_url": "https://iliad-unofficial-app.firebaseio.com", + "project_id": "iliad-unofficial-app", + "storage_bucket": "iliad-unofficial-app.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:789065959141:android:0f83e09aaadaa57cd4760c", + "android_client_info": { + "package_name": "com.fast0n.ap" + } + }, + "oauth_client": [ + { + "client_id": "789065959141-1g6c3li4g5u4v61kttdihvmlsl4c371u.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "com.fast0n.ap", + "certificate_hash": "2d9ed74733b3ebeb5973f224cf45123cd04a495d" + } + }, + { + "client_id": "789065959141-r4pa1uggsqnmt2mqa0sf059usssqshit.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyBFkOOSZDlTpKKo9-U-rgvDmccw4LciOyI" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "789065959141-r4pa1uggsqnmt2mqa0sf059usssqshit.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/iliad/app/proguard-rules.pro b/iliad/app/proguard-rules.pro new file mode 100755 index 0000000..f1b4245 --- /dev/null +++ b/iliad/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/iliad/app/src/main/AndroidManifest.xml b/iliad/app/src/main/AndroidManifest.xml new file mode 100755 index 0000000..ff03fda --- /dev/null +++ b/iliad/app/src/main/AndroidManifest.xml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/iliad/app/src/main/ic_launcher-web.png b/iliad/app/src/main/ic_launcher-web.png new file mode 100755 index 0000000..b556733 Binary files /dev/null and b/iliad/app/src/main/ic_launcher-web.png differ diff --git a/iliad/app/src/main/java/com/fast0n/ap/ChangeEmailActivity.java b/iliad/app/src/main/java/com/fast0n/ap/ChangeEmailActivity.java new file mode 100755 index 0000000..768ff7c --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/ChangeEmailActivity.java @@ -0,0 +1,191 @@ +package com.fast0n.ap; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.ActivityInfo; +import android.os.Bundle; +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import android.util.Base64; +import android.view.MenuItem; +import android.view.View; +import android.view.inputmethod.InputMethodManager; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ProgressBar; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.fast0n.ap.java.CubeLoading; +import com.fast0n.ap.java.DialogError; +import com.fast0n.ap.java.myDbAdapter; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import es.dmoral.toasty.Toasty; + +public class ChangeEmailActivity extends AppCompatActivity { + + SharedPreferences settings; + String theme; + private myDbAdapter helper; + private String pwd, account; + private EditText edt_email, edt_password; + private Button btn_change_email; + + private static boolean isEmail(String email) { + String expression = "^[\\w.]+@([\\w]+\\.)+[A-Z]{2,7}$"; + Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); + Matcher matcher = pattern.matcher(email); + return matcher.matches(); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_change_email); + Toolbar toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); + TextView mTitle = toolbar.findViewById(R.id.toolbar_title); + mTitle.setText(R.string.change_email_title); + Objects.requireNonNull(getSupportActionBar()).setDisplayShowTitleEnabled(false); + + // set row icon in the toolbar + ActionBar actionBar = getSupportActionBar(); + actionBar.setHomeButtonEnabled(true); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setDisplayShowHomeEnabled(true); + helper = new myDbAdapter(this); + + final Bundle extras = getIntent().getExtras(); + assert extras != null; + final String token = extras.getString("token"); + final String site_url = getString(R.string.site_url) + getString(R.string.infomation); + + // java adresses + SharedPreferences settings = getSharedPreferences("sharedPreferences", 0); + edt_email = findViewById(R.id.edt_email); + edt_password = findViewById(R.id.edt_password); + btn_change_email = findViewById(R.id.btn_change_email); + + // prendere le SharedPreferences + account = settings.getString("account", null); + + btn_change_email.setOnClickListener(v -> { + + if (edt_password.getText().toString().length() != 0 + || edt_email.getText().toString().length() != 0) { + + String getAllData = helper.getAllData(); + String[] arrayData = getAllData.split("\n"); + for (String anArrayData : arrayData) { + String onlyname = anArrayData.split("&")[0]; + String onlypassword = anArrayData.split("&")[1]; + if (onlyname.equals(account)) { + pwd = onlypassword; + break; + } + } + + byte[] decodeValue1 = Base64.decode(pwd, Base64.DEFAULT); + String ppassword = new String(decodeValue1); + + if (isEmail(edt_email.getText().toString()) && edt_password.getText().toString().equals(ppassword.replaceAll("\\s+", ""))) { + View view = this.getCurrentFocus(); + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + String url = site_url + "?email=" + edt_email.getText().toString() + "&email_confirm=" + + edt_email.getText().toString() + "&password=" + pwd.replaceAll("\\s+", "") + "&token=" + token; + changeMail(url); + + + btn_change_email.setEnabled(false); + } else { + btn_change_email.setEnabled(true); + Toasty.warning(ChangeEmailActivity.this, getString(R.string.email_wrong), Toast.LENGTH_LONG, + true).show(); + } + } else + btn_change_email.setEnabled(true); + Toasty.warning(ChangeEmailActivity.this, getString(R.string.error_forget1), Toast.LENGTH_LONG, + true).show(); + + }); + + } + + private void changeMail(String url) { + + final ProgressBar loading; + final ConstraintLayout layout; + + layout = findViewById(R.id.constraint); + + loading = findViewById(R.id.progressBar); + settings = getSharedPreferences("sharedPreferences", 0); + theme = settings.getString("toggleTheme", null); + new CubeLoading(this, loading, theme).showLoading(); + + + layout.setVisibility(View.INVISIBLE); + loading.setVisibility(View.VISIBLE); + + RequestQueue queue = Volley.newRequestQueue(ChangeEmailActivity.this); + + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + String string_response = json.getString("0"); + + if (string_response.equals("true")) { + + edt_password.setInputType(0); + Intent intent = new Intent(ChangeEmailActivity.this, LoginActivity.class); + startActivity(intent); + + Toasty.success(ChangeEmailActivity.this, getString(R.string.email_change_success), + Toast.LENGTH_LONG, true).show(); + } + + } catch (JSONException e) { + new DialogError(this, String.valueOf(e)).alertbox(); + } + + }, e -> new DialogError(this, String.valueOf(e)).alertbox()); + + queue.add(getRequest); + + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + + switch (item.getItemId()) { + case android.R.id.home: + + super.onBackPressed(); + + return true; + default: + return super.onOptionsItemSelected(item); + } + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/ChangePasswordActivity.java b/iliad/app/src/main/java/com/fast0n/ap/ChangePasswordActivity.java new file mode 100755 index 0000000..b850ab9 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/ChangePasswordActivity.java @@ -0,0 +1,203 @@ +package com.fast0n.ap; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.ActivityInfo; +import android.os.Bundle; +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import android.util.Base64; +import android.view.MenuItem; +import android.view.View; +import android.view.inputmethod.InputMethodManager; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ProgressBar; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.fast0n.ap.java.CubeLoading; +import com.fast0n.ap.java.DialogError; +import com.fast0n.ap.java.GenerateToken; +import com.fast0n.ap.java.myDbAdapter; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.Objects; + +import es.dmoral.toasty.Toasty; + +public class ChangePasswordActivity extends AppCompatActivity { + + String theme; + SharedPreferences settings; + private myDbAdapter helper; + private String pwd, account; + private EditText edt_newpassword, edt_password; + private Button btn_change_password; + + @Override + protected void onCreate(Bundle savedInstanceState) { + settings = getSharedPreferences("sharedPreferences", 0); + theme = settings.getString("toggleTheme", null); + if (theme.equals("0")) + setTheme(R.style.AppTheme); + else + setTheme(R.style.DarkTheme); + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_change_password); + Toolbar toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); + TextView mTitle = toolbar.findViewById(R.id.toolbar_title); + mTitle.setText(R.string.change_password_title); + Objects.requireNonNull(getSupportActionBar()).setDisplayShowTitleEnabled(false); + + // set row icon in the toolbar + ActionBar actionBar = getSupportActionBar(); + actionBar.setHomeButtonEnabled(true); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setDisplayShowHomeEnabled(true); + + // java adresses + edt_newpassword = findViewById(R.id.edt_newpassword); + edt_password = findViewById(R.id.edt_oldpassword); + btn_change_password = findViewById(R.id.btn_password); + helper = new myDbAdapter(this); + + // prendere le SharedPreferences + account = settings.getString("account", null); + + final Bundle extras = getIntent().getExtras(); + assert extras != null; + final String token = extras.getString("token", null); + final String site_url = getString(R.string.site_url) + getString(R.string.infomation); + + btn_change_password.setOnClickListener(v -> { + + + if (edt_password.getText().toString().length() != 0 + || edt_newpassword.getText().toString().length() != 0) { + + + String getAllData = helper.getAllData(); + String[] arrayData = getAllData.split("\n"); + for (String anArrayData : arrayData) { + String onlyname = anArrayData.split("&")[0]; + String onlypassword = anArrayData.split("&")[1]; + if (onlyname.equals(account)) { + pwd = onlypassword; + break; + } + } + + byte[] decodeValue1 = Base64.decode(pwd, Base64.DEFAULT); + String ppassword = new String(decodeValue1); + + + if (edt_password.getText().toString().equals(ppassword.replaceAll("\\s+", ""))) { + View view = this.getCurrentFocus(); + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + + byte[] decodeValue = Base64.encode(edt_password.getText().toString().getBytes(), Base64.DEFAULT); + String oldpassword = new String(decodeValue); + + + byte[] encodeValue1 = Base64.encode(edt_newpassword.getText().toString().getBytes(), Base64.DEFAULT); + String newpassword = new String(encodeValue1); + + + String url = site_url + "?new_password=" + newpassword.replaceAll("\\s+", "") + + "&new_password_confirm=" + newpassword.replaceAll("\\s+", "") + "&password=" + oldpassword.replaceAll("\\s+", "") + + "&token=" + token; + + + changePassword(url, oldpassword.replaceAll("\\s+", ""), newpassword.replaceAll("\\s+", "")); + btn_change_password.setEnabled(false); + } else { + btn_change_password.setEnabled(true); + Toasty.warning(ChangePasswordActivity.this, getString(R.string.wrong_password), Toast.LENGTH_LONG, + true).show(); + } + } else { + btn_change_password.setEnabled(true); + Toasty.warning(ChangePasswordActivity.this, getString(R.string.wrong_password), Toast.LENGTH_LONG, + true).show(); + } + }); + + } + + private void changePassword(String url, String oldPassword, final String newpassword) { + + final ProgressBar loading; + final ConstraintLayout layout; + + layout = findViewById(R.id.constraint); + + loading = findViewById(R.id.progressBar); + settings = getSharedPreferences("sharedPreferences", 0); + theme = settings.getString("toggleTheme", null); + new CubeLoading(this, loading, theme).showLoading(); + + layout.setVisibility(View.INVISIBLE); + loading.setVisibility(View.VISIBLE); + + RequestQueue queue = Volley.newRequestQueue(ChangePasswordActivity.this); + queue.getCache().clear(); + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + String string_response = json.getString("0"); + + if (string_response.equals("true")) { + String token = GenerateToken.randomString(20); + Intent intent = new Intent(ChangePasswordActivity.this, HomeActivity.class); + helper.updatePassword(oldPassword, newpassword); + intent.putExtra("token", token); + intent.putExtra("checkbox", "true"); + startActivity(intent); + Toasty.success(ChangePasswordActivity.this, getString(R.string.password_change_success), + Toast.LENGTH_LONG, true).show(); + + + } + + } catch (JSONException e) { + new DialogError(this, String.valueOf(e)).alertbox(); + } + + }, e -> new DialogError(this, String.valueOf(e)).alertbox()); + + queue.add(getRequest); + + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + + switch (item.getItemId()) { + case android.R.id.home: + + super.onBackPressed(); + + return true; + default: + return super.onOptionsItemSelected(item); + } + } +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/ChargeActivity.java b/iliad/app/src/main/java/com/fast0n/ap/ChargeActivity.java new file mode 100755 index 0000000..f3a5db2 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/ChargeActivity.java @@ -0,0 +1,440 @@ +package com.fast0n.ap; + +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.ActivityInfo; +import android.os.Bundle; +import com.google.android.material.textfield.TextInputLayout; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import android.text.Editable; +import android.text.TextWatcher; +import android.util.Base64; +import android.view.MenuItem; +import android.view.View; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Spinner; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.cooltechworks.creditcarddesign.CreditCardView; +import com.fast0n.ap.java.myDbAdapter; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.regex.Pattern; + +import es.dmoral.toasty.Toasty; + +public class ChargeActivity extends AppCompatActivity { + + myDbAdapter helper; + TextInputLayout edt_password_visibility; + String typecard = null, account; + SharedPreferences settings; + String theme; + Button button; + private EditText ncvv, nCard, nExpiration, edt_password; + private CreditCardView creditCardView; + private Boolean touch = true; + private Spinner spinner; + + @Override + protected void onCreate(Bundle savedInstanceState) { + settings = getSharedPreferences("sharedPreferences", 0); + theme = settings.getString("toggleTheme", null); + if (theme.equals("0")) + setTheme(R.style.AppTheme); + else + setTheme(R.style.DarkTheme); + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_charge); + Toolbar toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); + TextView mTitle = toolbar.findViewById(R.id.toolbar_title); + mTitle.setText(R.string.chargeNumber); + Objects.requireNonNull(getSupportActionBar()).setDisplayShowTitleEnabled(false); + + // set row icon in the toolbar + ActionBar actionBar = getSupportActionBar(); + actionBar.setHomeButtonEnabled(true); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setDisplayShowHomeEnabled(true); + helper = new myDbAdapter(this); + + // java adresses + button = findViewById(R.id.button); + creditCardView = findViewById(R.id.card); + spinner = findViewById(R.id.spinner); + edt_password_visibility = findViewById(R.id.edt_password_visibility); + edt_password = findViewById(R.id.edt_password); + + SharedPreferences settings = getSharedPreferences("sharedPreferences", 0); + + // prendere le SharedPreferences + account = settings.getString("account", null); + + final Bundle extras = getIntent().getExtras(); + assert extras != null; + final String token = extras.getString("token", null); + final String name = extras.getString("name", null); + String price_spinner = extras.getString("price", null); + + if (price_spinner.equals("false")) { + mTitle.setText("Modifica metodo di pagamento"); + button.setText("Modifica il mio metodo di pagamento"); + spinner.setVisibility(View.INVISIBLE); + edt_password_visibility.setVisibility(View.VISIBLE); + } + + creditCardView.setCardHolderName(name); + + // prende gli importi + final String site_url = getString(R.string.site_url); + RequestQueue queue = Volley.newRequestQueue(ChargeActivity.this); + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, site_url + getString(R.string.recharge) + "?payinfoprice=true&&token=" + token, null, + response -> { + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + String price = json.getString("0"); + JSONArray json_title = new JSONArray(price); + + final List list = new ArrayList<>(); + + for (int z = 0; z < json_title.length(); z++) { + + String stringPrice = json_title.getString(z); + list.add(stringPrice + "€"); + } + list.add("Importo"); + final int listsize = list.size() - 1; + ArrayAdapter dataAdapter = new ArrayAdapter(ChargeActivity.this, R.layout.spinner_item, list) { + @Override + public int getCount() { + return (listsize); + } + }; + spinner.setAdapter(dataAdapter); + spinner.setSelection(list.size() - 1); + + } catch (JSONException ignored) { + } + + }, error -> { + + }); + queue.add(getRequest); + + + creditCardView.setOnClickListener(v -> { + if (touch) { + creditCardView.showBack(); + touch = false; + } else { + creditCardView.showFront(); + touch = true; + } + }); + + + final ArrayList listOfPattern = new ArrayList<>(); + + String ptVisa = "^4[0-9]{6,}$"; + listOfPattern.add(ptVisa); + String ptMasterCard = "^5[1-5][0-9]{5,}$"; + listOfPattern.add(ptMasterCard); + + nCard = findViewById(R.id.nCard); + nExpiration = findViewById(R.id.nExpiration); + ncvv = findViewById(R.id.ncvv); + + nCard.addTextChangedListener(new TextWatcher() { + private final String space = " "; // you can change this to whatever you want + private final Pattern pattern = Pattern.compile("^(\\d{4}" + space + "){0,3}\\d{1,4}$"); // check whether we need to modify or not + + @Override + public void onTextChanged(CharSequence s, int st, int be, int count) { + creditCardView.setCardNumber(nCard.getText().toString().replaceAll("\\s+", "")); + String currentText = nCard.getText().toString(); + if (currentText.isEmpty() || pattern.matcher(currentText).matches()) + return; + String numbersOnly = currentText.trim().replaceAll("[^\\d.]", ""); + StringBuilder formatted = new StringBuilder(); + for (int i = 0; i < numbersOnly.length(); i += 4) + if (i + 4 < numbersOnly.length()) + formatted.append(numbersOnly, i, i + 4).append(space); + else + formatted.append(numbersOnly.substring(i)); + nCard.setText(formatted.toString()); + nCard.setSelection(nCard.getText().toString().length()); + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } + + @Override + public void afterTextChanged(Editable s) { + + } + }); + + + ncvv.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + if (ncvv.getText().toString().length() == 3 || ncvv.getText().toString().length() == 4) { + creditCardView.showFront(); + touch = true; + } else { + if (touch) { + creditCardView.showBack(); + touch = false; + } + } + creditCardView.setCVV(ncvv.getText().toString()); + } + + @Override + public void afterTextChanged(Editable s) { + } + }); + + + nExpiration.addTextChangedListener(new TextWatcher() { + private final String space = "/"; // you can change this to whatever you want + private final Pattern pattern = Pattern.compile("^(\\d{2}" + space + ")?\\d{1,2}$"); // check whether we need to modify or not + + @Override + public void onTextChanged(CharSequence s, int st, int be, int count) { + creditCardView.setCardExpiry(nExpiration.getText().toString().replaceAll("\\s+", "")); + String currentText = nExpiration.getText().toString(); + if (currentText.isEmpty() || pattern.matcher(currentText).matches()) + return; + String numbersOnly = currentText.trim().replaceAll("[^\\d.]", ""); + StringBuilder formatted = new StringBuilder(); + for (int i = 0; i < numbersOnly.length(); i += 2) + if (i + 2 < numbersOnly.length()) + formatted.append(numbersOnly, i, i + 2).append(space); + else + formatted.append(numbersOnly.substring(i)); + nExpiration.setText(formatted.toString()); + nExpiration.setSelection(nExpiration.getText().toString().length()); + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } + + @Override + public void afterTextChanged(Editable e) { + } + }); + + button.setOnClickListener(v -> { + String montant = spinner.getSelectedItem().toString(); + + if (price_spinner.equals("true")) { + if (montant.equals("Importo") || price_spinner.equals("false")) + Toasty.warning(ChargeActivity.this, montant + " " + getString(R.string.missing), Toast.LENGTH_SHORT).show(); + else if (nCard.getText().toString().length() < 19) + Toasty.warning(ChargeActivity.this, getString(R.string.edtCard) + " " + getString(R.string.missing), Toast.LENGTH_SHORT).show(); + else if (nExpiration.getText().toString().length() == 0) + Toasty.warning(ChargeActivity.this, getString(R.string.edtExpiration) + " " + getString(R.string.missing), Toast.LENGTH_SHORT).show(); + else if (ncvv.getText().toString().length() == 0) + Toasty.warning(ChargeActivity.this, getString(R.string.edtCvv) + " " + getString(R.string.missing), Toast.LENGTH_SHORT).show(); + else { + + String ccNum = nCard.getText().toString().replaceAll("\\s+", ""); + for (String p : listOfPattern) { + if (ccNum.matches(p)) { + switch (p) { + case "^4[0-9]{6,}$": + typecard = "visa"; + break; + case "^5[1-5][0-9]{5,}$": + typecard = "mastercard"; + break; + default: + typecard = ""; + break; + } + break; + } + } + + button.setEnabled(false); + RequestQueue queue1 = Volley.newRequestQueue(ChargeActivity.this); + JsonObjectRequest getRequest1 = new JsonObjectRequest(Request.Method.GET, site_url + getString(R.string.recharge) + "?phonecharge=true&montant=" + + montant.replace("€", "") + + "&cbtype=" + typecard + + "&cbnumero=" + nCard.getText().toString().replaceAll("\\s+", "") + + "&cbexpmois=" + nExpiration.getText().toString().split("/")[0] + + "&cbexpannee=20" + nExpiration.getText().toString().split("/")[1] + + "&cbcrypto=" + ncvv.getText().toString() + + "&token=" + token, null, + response -> { + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + JSONObject json = new JSONObject(iliad); + + String price = json.getString("0"); + + + if (price.equals("true")) { + Toasty.success(ChargeActivity.this, price, Toast.LENGTH_SHORT).show(); + Intent intent = new Intent(ChargeActivity.this, LoginActivity.class); + startActivity(intent); + button.setEnabled(true); + } else { + Toasty.error(ChargeActivity.this, price, Toast.LENGTH_SHORT).show(); + button.setEnabled(true); + + } + + + } catch (JSONException ignored) { + } + + }, error -> { + + }); + + queue1.add(getRequest1); + } + } else { + //cambio metodo + if (nCard.getText().toString().length() < 19) + Toasty.warning(ChargeActivity.this, getString(R.string.edtCard) + " " + getString(R.string.missing), Toast.LENGTH_SHORT).show(); + else if (nExpiration.getText().toString().length() == 0) + Toasty.warning(ChargeActivity.this, getString(R.string.edtExpiration) + " " + getString(R.string.missing), Toast.LENGTH_SHORT).show(); + else if (ncvv.getText().toString().length() == 0) + Toasty.warning(ChargeActivity.this, getString(R.string.edtCvv) + " " + getString(R.string.missing), Toast.LENGTH_SHORT).show(); + else if (edt_password.getText().toString().length() == 0) { + String getAllData = helper.getAllData(); + String[] arrayData = getAllData.split("\n"); + String pwd = null; + for (String anArrayData : arrayData) { + String onlyname = anArrayData.split("&")[0]; + String onlypassword = anArrayData.split("&")[1]; + if (onlyname.equals(account)) { + pwd = onlypassword; + break; + } + } + + byte[] decodeValue1 = Base64.decode(pwd, Base64.DEFAULT); + String ppassword = new String(decodeValue1); + + if (!edt_password.getText().toString().equals(ppassword.replaceAll("\\s+", ""))) { + Toasty.warning(ChargeActivity.this, getString(R.string.wrong_password), Toast.LENGTH_LONG, + true).show(); + } + } else { + + String ccNum = nCard.getText().toString().replaceAll("\\s+", ""); + for (String p : listOfPattern) { + if (ccNum.matches(p)) { + switch (p) { + case "^4[0-9]{6,}$": + typecard = "visa"; + break; + case "^5[1-5][0-9]{5,}$": + typecard = "mastercard"; + break; + default: + typecard = ""; + break; + } + break; + } + } + + byte[] encodeValue1 = Base64.encode(edt_password.getText().toString().getBytes(), Base64.DEFAULT); + String newpassword = new String(encodeValue1); + button.setEnabled(false); + RequestQueue queue1 = Volley.newRequestQueue(ChargeActivity.this); + JsonObjectRequest getRequest1 = new JsonObjectRequest(Request.Method.GET, + site_url + getString(R.string.infomation) + + "?method=cb&cbtype=" + typecard + + "&cbnumero=" + nCard.getText().toString() + + "&cbexpmois=" + nExpiration.getText().toString().split("/")[0] + + "&cbexpannee=20" + nExpiration.getText().toString().split("/")[1] + + "&cbcrypto=" + ncvv.getText().toString() + + "&password=" + newpassword + + "&token=" + token, null, + response -> { + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + JSONObject json = new JSONObject(iliad); + + String price = json.getString("0"); + + + if (price.equals("true")) { + Toasty.success(ChargeActivity.this, price, Toast.LENGTH_SHORT).show(); + Intent intent = new Intent(ChargeActivity.this, LoginActivity.class); + startActivity(intent); + button.setEnabled(true); + } else { + Toasty.error(ChargeActivity.this, price, Toast.LENGTH_SHORT).show(); + button.setEnabled(true); + + } + + + } catch (JSONException ignored) { + } + + }, error -> { + + }); + + queue1.add(getRequest1); + + } + } + }); + + } + + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + + switch (item.getItemId()) { + case android.R.id.home: + + super.onBackPressed(); + + return true; + default: + return super.onOptionsItemSelected(item); + } + } +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/ConsumptionDetailsActivity.java b/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/ConsumptionDetailsActivity.java new file mode 100755 index 0000000..e392213 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/ConsumptionDetailsActivity.java @@ -0,0 +1,249 @@ +package com.fast0n.ap.ConsumptionDetailsActivity; + +import android.content.SharedPreferences; +import android.content.pm.ActivityInfo; +import android.os.Bundle; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.appcompat.widget.Toolbar; +import android.view.MenuItem; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.ProgressBar; +import android.widget.Spinner; +import android.widget.TextView; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.fast0n.ap.R; +import com.fast0n.ap.java.CubeLoading; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class ConsumptionDetailsActivity extends AppCompatActivity { + + private final ArrayList title = new ArrayList<>(); + private final ArrayList desc = new ArrayList<>(); + private final ArrayList info = new ArrayList<>(); + SharedPreferences settings; + String theme; + private RecyclerView recyclerView; + private ArrayList model; + private CustomAdapter adapter; + private ProgressBar loading; + private TextView no_consumption; + private Spinner spinner; + + @Override + protected void onCreate(Bundle savedInstanceState) { + settings = getSharedPreferences("sharedPreferences", 0); + theme = settings.getString("toggleTheme", null); + if (theme.equals("0")) + setTheme(R.style.AppTheme); + else + setTheme(R.style.DarkTheme); + + + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_consumption_detail); + Toolbar toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + TextView mTitle = toolbar.findViewById(R.id.toolbar_title); + mTitle.setText(R.string.app_name); + Objects.requireNonNull(getSupportActionBar()).setDisplayShowTitleEnabled(false); + + // set row icon in the toolbar + ActionBar actionBar = getSupportActionBar(); + actionBar.setHomeButtonEnabled(true); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setDisplayShowHomeEnabled(true); + + final Bundle extras = getIntent().getExtras(); + assert extras != null; + final String token = extras.getString("token", null); + final String site_url = getString(R.string.site_url) + getString(R.string.credit); + TextView offer; + + + // java adresses + offer = findViewById(R.id.offer); + spinner = findViewById(R.id.spinner); // try + recyclerView = findViewById(R.id.recycler_view); + model = new ArrayList<>(); + loading = findViewById(R.id.progressBar); + no_consumption = findViewById(R.id.textView); + new CubeLoading(this, loading, theme).showLoading(); + loading.setVisibility(View.VISIBLE); + + offer.setText(getString(R.string.consumptiondetail)); + + String history = site_url + "?history=true&token=" + token; + getHistory(history); + + + LinearLayoutManager layoutManager = new LinearLayoutManager(this); + recyclerView.setLayoutManager(layoutManager); + + + } + + /* try */ + private void getHistory(String url) { + RequestQueue queue = Volley.newRequestQueue(ConsumptionDetailsActivity.this); + + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + + String title = json.getString("date"); + JSONArray date = new JSONArray(title); + + List lista = new ArrayList<>(); + + spinner.setOnItemSelectedListener(new CustomOnItemSelectedListener()); + + for (int i = 0; i < date.length(); i++) { + lista.add((String) date.get(i)); + } + + ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<>(this, R.layout.spinner_item, lista); + spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner_item); + spinner.setAdapter(spinnerArrayAdapter); + } catch (JSONException ignored) { + + } + + + }, error -> { + + }); + + queue.add(getRequest); + + } + + private void getConsumption(String url) { + + RequestQueue queue = Volley.newRequestQueue(ConsumptionDetailsActivity.this); + + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + + try { + + ArrayList[] ConsumptionDetails = new ArrayList[]{title, desc, info}; + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + + String title = json.getString("title"); + JSONObject json_title = new JSONObject(title); + + for (int z = 0; z < json_title.length(); z++) { + String x = json_title.getString(String.valueOf(z)); + try { + ConsumptionDetails[z].clear(); + } catch (Exception e) { + } + + try { + String string = json.getString(String.valueOf(z)); + JSONObject json_strings = new JSONObject(string); + + for (int j = 0; j < json_strings.length(); j++) { + + String string_one = json_strings.getString(String.valueOf(j)); + JSONObject json_strings_one = new JSONObject(string_one); + + String a = json_strings_one.getString(String.valueOf(0)); + String b = json_strings_one.getString(String.valueOf(1)); + String c = json_strings_one.getString(String.valueOf(2)); + String d = json_strings_one.getString(String.valueOf(3)); + String e = json_strings_one.getString(String.valueOf(4)); + String f = json_strings_one.getString(String.valueOf(5)); + + ConsumptionDetails[z].add(new ModelChildren(a, b, c, d, e, f)); + } + model.add(new Model(x, ConsumptionDetails[z])); + loading.setVisibility(View.INVISIBLE); + } catch (JSONException e) { + + } + } + + adapter = new CustomAdapter(ConsumptionDetailsActivity.this, model); + recyclerView.setAdapter(adapter); + + recyclerView.setVisibility(View.VISIBLE); + + } catch (JSONException ignored) { + + } + + + }, error -> { + int error_code = error.networkResponse.statusCode; + if (error_code == 503) { + no_consumption.setVisibility(View.VISIBLE); + loading.setVisibility(View.INVISIBLE); + + } + + }); + + queue.add(getRequest); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + + if (item.getItemId() == android.R.id.home) { + super.onBackPressed(); + + return true; + } + return super.onOptionsItemSelected(item); + } + + public class CustomOnItemSelectedListener implements AdapterView.OnItemSelectedListener { + + public void onItemSelected(AdapterView parent, View view, int pos, long id) { + final Bundle extras = getIntent().getExtras(); + assert extras != null; + final String token = extras.getString("token", null); + final String site_url = getString(R.string.site_url) + getString(R.string.credit); + String url = site_url + "?details=true&history=" + pos + "&token=" + token; + model.clear(); + recyclerView.setVisibility(View.GONE); + no_consumption.setVisibility(View.GONE); + loading.setVisibility(View.VISIBLE); + getConsumption(url); + } + + @Override + public void onNothingSelected(AdapterView arg0) { + // TODO Auto-generated method stub + } + + } + +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/ConsumptionRoamingDetailActivity.java b/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/ConsumptionRoamingDetailActivity.java new file mode 100755 index 0000000..3c73754 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/ConsumptionRoamingDetailActivity.java @@ -0,0 +1,104 @@ +package com.fast0n.ap.ConsumptionDetailsActivity; + +import android.content.SharedPreferences; +import android.content.pm.ActivityInfo; +import android.os.Bundle; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import android.view.MenuItem; +import android.widget.TextView; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.fast0n.ap.R; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.Objects; + +public class ConsumptionRoamingDetailActivity extends AppCompatActivity { + + SharedPreferences settings; + String theme; + + @Override + protected void onCreate(Bundle savedInstanceState) { + + settings = getSharedPreferences("sharedPreferences", 0); + theme = settings.getString("toggleTheme", null); + if (theme.equals("0")) + setTheme(R.style.AppTheme); + else + setTheme(R.style.DarkTheme); + + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_consumption_roaming_detail); + Toolbar toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + TextView mTitle = toolbar.findViewById(R.id.toolbar_title); + mTitle.setText(R.string.app_name); + Objects.requireNonNull(getSupportActionBar()).setDisplayShowTitleEnabled(false); + + // set row icon in the toolbar + ActionBar actionBar = getSupportActionBar(); + actionBar.setHomeButtonEnabled(true); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setDisplayShowHomeEnabled(true); + + final Bundle extras = getIntent().getExtras(); + assert extras != null; + final String token = extras.getString("token", null); + final String site_url = getString(R.string.site_url) + getString(R.string.credit); + + + // java adresses + + String url = site_url + "?details=true&token=" + token; + getConsumption(url); + + + } + + private void getConsumption(String url) { + + RequestQueue queue = Volley.newRequestQueue(ConsumptionRoamingDetailActivity.this); + + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + + } catch (JSONException ignored) { + } + + }, error -> { + + }); + + queue.add(getRequest); + + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + + switch (item.getItemId()) { + case android.R.id.home: + + super.onBackPressed(); + + return true; + default: + return super.onOptionsItemSelected(item); + } + } + +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/CustomAdapter.java b/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/CustomAdapter.java new file mode 100755 index 0000000..6ceb6db --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/CustomAdapter.java @@ -0,0 +1,49 @@ +package com.fast0n.ap.ConsumptionDetailsActivity; + +import android.app.Activity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.fast0n.ap.R; +import com.thoughtbot.expandablerecyclerview.ExpandableRecyclerViewAdapter; +import com.thoughtbot.expandablerecyclerview.models.ExpandableGroup; + +import java.util.List; + +class CustomAdapter extends ExpandableRecyclerViewAdapter { + + private final Activity activity; + + CustomAdapter(Activity activity, List groups) { + super(groups); + this.activity = activity; + } + + @Override + public DataModelChildren onCreateGroupViewHolder(ViewGroup parent, int viewType) { + LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); + View view = inflater.inflate(R.layout.row_consumption_details, parent, false); + + return new DataModelChildren(view); + } + + @Override + public DataModel onCreateChildViewHolder(ViewGroup parent, final int viewType) { + LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); + View view = inflater.inflate(R.layout.row_consumption_details_children, parent, false); + + return new DataModel(view); + } + + @Override + public void onBindChildViewHolder(DataModel holder, int flatPosition, ExpandableGroup group, int childIndex) { + final ModelChildren modelChildren = ((Model) group).getItems().get(childIndex); + holder.onBind(modelChildren); + } + + @Override + public void onBindGroupViewHolder(DataModelChildren holder, int flatPosition, ExpandableGroup group) { + holder.setGroupName(group); + } +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/DataModel.java b/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/DataModel.java new file mode 100755 index 0000000..9ac0113 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/DataModel.java @@ -0,0 +1,72 @@ +package com.fast0n.ap.ConsumptionDetailsActivity; + +import android.content.ContentResolver; +import android.database.Cursor; +import android.net.Uri; +import android.provider.ContactsContract; +import android.view.View; +import android.widget.TextView; + +import com.fast0n.ap.R; +import com.thoughtbot.expandablerecyclerview.viewholders.ChildViewHolder; + +public class DataModel extends ChildViewHolder { + + private final TextView a; + private final TextView b; + private final TextView c; + private final TextView d; + private final TextView e; + private final TextView f; + + DataModel(View itemView) { + super(itemView); + + a = itemView.findViewById(R.id.a); + b = itemView.findViewById(R.id.b); + c = itemView.findViewById(R.id.c); + d = itemView.findViewById(R.id.d); + e = itemView.findViewById(R.id.e); + f = itemView.findViewById(R.id.f); + + } + + public void onBind(ModelChildren modelChildren) { + + + a.setText(modelChildren.getA()); + b.setText(modelChildren.getB()); + c.setText(modelChildren.getC()); + d.setText(getContactName(modelChildren.getD())); + e.setText(modelChildren.getE()); + f.setText(modelChildren.getF()); + + + } + + private String getContactName(String number) { + String name = ""; + Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number)); + + ContentResolver contentResolver = itemView.getContext().getContentResolver(); + try { + Cursor contactLookup = contentResolver.query(uri, null, null, null, null); + try { + if (contactLookup != null && contactLookup.getCount() > 0) { + contactLookup.moveToNext(); + name = contactLookup.getString(contactLookup.getColumnIndex(ContactsContract.Data.DISPLAY_NAME)); + } else { + name = number; + } + } finally { + if (contactLookup != null) { + contactLookup.close(); + } + } + } catch (Exception ignored) { + name = number; + } + + return name; + } +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/DataModelChildren.java b/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/DataModelChildren.java new file mode 100755 index 0000000..b5c7685 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/DataModelChildren.java @@ -0,0 +1,33 @@ +package com.fast0n.ap.ConsumptionDetailsActivity; + +import android.view.View; +import android.widget.TextView; + +import com.fast0n.ap.R; +import com.thoughtbot.expandablerecyclerview.models.ExpandableGroup; +import com.thoughtbot.expandablerecyclerview.viewholders.GroupViewHolder; + +public class DataModelChildren extends GroupViewHolder { + + private final TextView osName; + + public DataModelChildren(View itemView) { + super(itemView); + + osName = itemView.findViewById(R.id.mobile_os); + } + + @Override + public void expand() { + osName.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.up_arrow, 0); + } + + @Override + public void collapse() { + osName.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.down_arrow, 0); + } + + public void setGroupName(ExpandableGroup group) { + osName.setText(group.getTitle()); + } +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/Model.java b/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/Model.java new file mode 100755 index 0000000..1c005e8 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/Model.java @@ -0,0 +1,13 @@ +package com.fast0n.ap.ConsumptionDetailsActivity; + +import com.thoughtbot.expandablerecyclerview.models.ExpandableGroup; + +import java.util.List; + +class Model extends ExpandableGroup { + + Model(String title, List items) { + super(title, items); + } +} + diff --git a/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/ModelChildren.java b/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/ModelChildren.java new file mode 100755 index 0000000..ccb25b9 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/ConsumptionDetailsActivity/ModelChildren.java @@ -0,0 +1,109 @@ +package com.fast0n.ap.ConsumptionDetailsActivity; + +import android.os.Parcel; +import android.os.Parcelable; + +public class ModelChildren implements Parcelable { + public static final Creator CREATOR = new Creator() { + @Override + public ModelChildren createFromParcel(Parcel in) { + return new ModelChildren(in); + } + + @Override + public ModelChildren[] newArray(int size) { + return new ModelChildren[size]; + } + }; + private String a; + private String b; + private String c; + private String d; + private String e; + private String f; + + private ModelChildren(Parcel in) { + + a = in.readString(); + b = in.readString(); + c = in.readString(); + d = in.readString(); + e = in.readString(); + e = in.readString(); + f = in.readString(); + } + + ModelChildren(String a, String b, String c, String d, String e, String f) { + this.a = a; + this.b = b; + this.c = c; + this.d = d; + this.e = e; + this.f = f; + + } + + public String getA() { + return a; + } + + public void setA(String a) { + this.a = a; + } + + public String getB() { + return b; + } + + public void setB(String b) { + this.b = b; + } + + public String getC() { + return c; + } + + public void setC(String c) { + this.c = c; + } + + public String getD() { + return d; + } + + public void setD(String d) { + this.d = d; + } + + public String getE() { + return e; + } + + public void setE(String e) { + this.e = e; + } + + public String getF() { + return f; + } + + public void setF(String f) { + this.f = f; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeString(a); + dest.writeString(b); + dest.writeString(c); + dest.writeString(d); + dest.writeString(e); + dest.writeString(f); + + } + + @Override + public int describeContents() { + return 0; + } +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/ForgetActivity.java b/iliad/app/src/main/java/com/fast0n/ap/ForgetActivity.java new file mode 100755 index 0000000..2480606 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/ForgetActivity.java @@ -0,0 +1,246 @@ +package com.fast0n.ap; + +import android.content.SharedPreferences; +import android.content.pm.ActivityInfo; +import android.graphics.Color; +import android.os.Bundle; +import androidx.constraintlayout.widget.ConstraintLayout; +import com.google.android.material.textfield.TextInputLayout; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; + +import android.util.Log; +import android.view.MenuItem; +import android.view.View; +import android.view.inputmethod.InputMethodManager; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ProgressBar; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.fast0n.ap.java.GenerateToken; +import com.github.ybq.android.spinkit.style.CubeGrid; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import es.dmoral.toasty.Toasty; + +public class ForgetActivity extends AppCompatActivity { + + String theme; + SharedPreferences settings; + private TextInputLayout id, surname, name; + private EditText edt_id, edt_email, edt_surname, edt_name; + + private static boolean isEmail(String email) { + String expression = "^[\\w.]+@([\\w]+\\.)+[A-Z]{2,7}$"; + Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); + Matcher matcher = pattern.matcher(email); + return matcher.matches(); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + settings = getSharedPreferences("sharedPreferences", 0); + theme = settings.getString("toggleTheme", null); + if (theme.equals("0")) + setTheme(R.style.AppTheme); + else + setTheme(R.style.DarkTheme); + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_forget); + Toolbar toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); + TextView mTitle = toolbar.findViewById(R.id.toolbar_title); + mTitle.setText(R.string.tv_title_foget); + Objects.requireNonNull(getSupportActionBar()).setDisplayShowTitleEnabled(false); + + // set row icon in the toolbar + ActionBar actionBar = getSupportActionBar(); + actionBar.setHomeButtonEnabled(true); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setDisplayShowHomeEnabled(true); + + // java adresses + id = findViewById(R.id.id); + surname = findViewById(R.id.surname); + name = findViewById(R.id.name); + TextView tv_forget_id = findViewById(R.id.tv_forget_id); + Button done_forget = findViewById(R.id.done_forget); + + edt_id = findViewById(R.id.edt_id); + edt_email = findViewById(R.id.edt_email); + edt_surname = findViewById(R.id.edt_surname); + edt_name = findViewById(R.id.edt_name); + + + String token = GenerateToken.randomString(20); + + done_forget.setOnClickListener(v -> { + + if (id.getVisibility() == View.VISIBLE) { + + if (edt_id.getText().toString().length() == 8 && isEmail(edt_email.getText().toString())) { + + InputMethodManager inputManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); + inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); + + final ProgressBar loading; + final ConstraintLayout layout; + + layout = findViewById(R.id.constraint); + + loading = findViewById(R.id.progressBar); + CubeGrid cubeGrid = new CubeGrid(); + loading.setIndeterminateDrawable(cubeGrid); + if (theme.equals("0")) + cubeGrid.setColor(Color.parseColor("#c00000")); + else + + cubeGrid.setColor(Color.parseColor("#ffffff")); + + layout.setVisibility(View.INVISIBLE); + loading.setVisibility(View.VISIBLE); + + String site_url = getString(R.string.site_url) + getString(R.string.recover) + "?userid=" + edt_id.getText().toString() + "&email=" + edt_email.getText().toString() + "&token=" + token; + + requests(site_url, layout, loading); + + + } + else{ + Toasty.warning(ForgetActivity.this, getString(R.string.error_forget), Toast.LENGTH_LONG, + true).show(); + } + + } else { + + if (edt_surname.getText().toString().length() != 0 && edt_name.getText().toString().length() != 0 && isEmail(edt_email.getText().toString())) { + + InputMethodManager inputManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); + inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); + + final ProgressBar loading; + final ConstraintLayout layout; + + layout = findViewById(R.id.constraint); + + loading = findViewById(R.id.progressBar); + CubeGrid cubeGrid = new CubeGrid(); + loading.setIndeterminateDrawable(cubeGrid); + if (theme.equals("0")) + cubeGrid.setColor(Color.parseColor("#c000000")); + else + cubeGrid.setColor(Color.parseColor("#ffffff")); + + layout.setVisibility(View.INVISIBLE); + loading.setVisibility(View.VISIBLE); + + String site_url = getString(R.string.site_url) + getString(R.string.recover) + "?surname=" + edt_surname.getText().toString() + "&name=" + edt_name.getText().toString() + "&email=" + edt_email.getText().toString() + "&token=" + token; + requests(site_url, layout, loading); + + } + else{ + Toasty.warning(ForgetActivity.this, getString(R.string.error_forget1), Toast.LENGTH_LONG, + true).show(); + } + + + } + + }); + + + tv_forget_id.setOnClickListener(v -> { + if (id.getVisibility() == View.VISIBLE) { + tv_forget_id.setText(R.string.tv_forget_id_back); + id.setVisibility(View.GONE); + surname.setVisibility(View.VISIBLE); + name.setVisibility(View.VISIBLE); + } else { + tv_forget_id.setText(R.string.tv_forget_id); + id.setVisibility(View.VISIBLE); + surname.setVisibility(View.GONE); + name.setVisibility(View.GONE); + } + }); + + + } + + private void requests(String site_url, ConstraintLayout layout, ProgressBar loading) { + RequestQueue queue = Volley.newRequestQueue(ForgetActivity.this); + + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, site_url, null, + response -> { + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + String string_response = json.getString("0"); + + if (string_response.equals("true")) { + Toasty.success(ForgetActivity.this, "Fatto", Toast.LENGTH_LONG, + true).show(); + finish(); + } else { + Toasty.warning(ForgetActivity.this, getString(R.string.error_forget1), Toast.LENGTH_LONG, + true).show(); + } + + + } catch (JSONException error) { + Log.e(getString(R.string.app_name) + " " + this.getClass().getSimpleName(), String.valueOf(error)); + Toasty.warning(ForgetActivity.this, getString(R.string.email_wrong), Toast.LENGTH_LONG, + true).show(); + } + + }, error -> { + + + try { + + int error_code = error.networkResponse.statusCode; + + if (error_code == 400) { + layout.setVisibility(View.VISIBLE); + loading.setVisibility(View.INVISIBLE); + Toasty.warning(ForgetActivity.this, getString(R.string.email_wrong), Toast.LENGTH_LONG, + true).show(); + } + } catch (Exception e) { + Log.e(getString(R.string.app_name) + " " + this.getClass().getSimpleName(), String.valueOf(e)); + } + + + }); + + queue.add(getRequest); + + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + + if (item.getItemId() == android.R.id.home) { + super.onBackPressed(); + + return true; + } + return super.onOptionsItemSelected(item); + } +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/HomeActivity.java b/iliad/app/src/main/java/com/fast0n/ap/HomeActivity.java new file mode 100755 index 0000000..a942d1d --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/HomeActivity.java @@ -0,0 +1,867 @@ +package com.fast0n.ap; + +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.ActivityInfo; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.net.ConnectivityManager; +import android.net.Uri; +import android.os.Bundle; +import android.os.CountDownTimer; +import android.os.Handler; +import android.preference.PreferenceManager; +import android.text.Html; +import android.util.Log; +import android.view.Menu; +import android.view.View; +import android.widget.Button; +import android.widget.ProgressBar; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.appcompat.app.ActionBarDrawerToggle; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.core.view.GravityCompat; +import androidx.drawerlayout.widget.DrawerLayout; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; + +import com.android.volley.DefaultRetryPolicy; +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.fast0n.ap.fragments.AboutFragment.AboutFragment; +import com.fast0n.ap.fragments.ConditionsFragment.ConditionsFragment; +import com.fast0n.ap.fragments.InfoFragments.InfoFragments; +import com.fast0n.ap.fragments.MasterCreditFragment; +import com.fast0n.ap.fragments.OptionsFragment.OptionsFragment; +import com.fast0n.ap.fragments.ServicesFragment.ServicesFragment; +import com.fast0n.ap.fragments.SettingsFragment.SettingsFragment; +import com.fast0n.ap.fragments.SimFragments; +import com.fast0n.ap.fragments.VoicemailFragment.VoicemailFragment; +import com.fast0n.ap.java.CubeLoading; +import com.fast0n.ap.java.DialogError; +import com.fast0n.ap.java.SnackbarMaterial; +import com.fast0n.ap.java.myDbAdapter; +import com.fast0n.ap.notifications.CheckNotification; +import com.github.javiersantos.materialstyleddialogs.MaterialStyledDialog; +import com.github.javiersantos.materialstyleddialogs.enums.Style; +import com.google.android.material.snackbar.Snackbar; +import com.mikepenz.itemanimators.AlphaCrossFadeAnimator; +import com.mikepenz.materialdrawer.AccountHeader; +import com.mikepenz.materialdrawer.AccountHeaderBuilder; +import com.mikepenz.materialdrawer.Drawer; +import com.mikepenz.materialdrawer.DrawerBuilder; +import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; +import com.mikepenz.materialdrawer.model.ProfileDrawerItem; +import com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem; +import com.mikepenz.materialdrawer.model.SecondaryDrawerItem; +import com.mikepenz.materialdrawer.model.SectionDrawerItem; +import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; +import com.mikepenz.materialdrawer.model.interfaces.IProfile; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.Locale; +import java.util.Objects; +import java.util.concurrent.TimeUnit; + +import es.dmoral.toasty.Toasty; + +public class HomeActivity extends AppCompatActivity { + + private static final int PROFILE_SETTING = 100000; + SharedPreferences settings; + String account, toggleNotification, userid, password, theme, alert; + CoordinatorLayout coordinatorLayout; + String[] arrayData; + private int pos = 0; + private myDbAdapter helper; + private ActionBarDrawerToggle toggle; + private DrawerLayout drawer; + private ProgressBar loading; + private SharedPreferences.Editor editor; + private boolean backPressedToExitOnce = false; + private AccountHeader headerResult = null; + private Drawer result = null; + + public static Bitmap getBitmapFromURL(String src) { + try { + URL url = new URL(src); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setDoInput(true); + connection.connect(); + InputStream input = connection.getInputStream(); + Bitmap myBitmap = BitmapFactory.decodeStream(input); + return myBitmap; + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } // Author: silentnuke + + @Override + protected void onCreate(Bundle savedInstanceState) { + settings = getSharedPreferences("sharedPreferences", 0); + theme = settings.getString("toggleTheme", null); + if (theme.equals("0")) + setTheme(R.style.AppTheme); + else + setTheme(R.style.DarkTheme); + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_home); + + Toolbar toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); + TextView mTitle = toolbar.findViewById(R.id.toolbar_title); + mTitle.setText(toolbar.getTitle()); + Objects.requireNonNull(getSupportActionBar()).setDisplayShowTitleEnabled(false); + + // java adresses + editor = settings.edit(); + drawer = findViewById(R.id.drawer_layout); + loading = findViewById(R.id.progressBar); + helper = new myDbAdapter(this); + coordinatorLayout = findViewById(R.id.cordinatorLayout); + + // prendere le SharedPreferences + account = settings.getString("account", null); + alert = settings.getString("alert", null); + theme = settings.getString("toggleTheme", null); + toggleNotification = settings.getString("toggleNotification", null); + + new CubeLoading(this, loading, theme).showLoading(); + new CheckNotification(toggleNotification, editor); + + toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, + R.string.navigation_drawer_close); + drawer.addDrawerListener(toggle); + drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); + + if (!isOnline()) { + Snackbar.make(findViewById(R.id.drawer_layout), R.string.snackbar, + Snackbar.LENGTH_INDEFINITE) + .show(); + + + Snackbar snack = Snackbar.make(coordinatorLayout, + getString(R.string.snackbar), Snackbar.LENGTH_INDEFINITE); + SnackbarMaterial.configSnackbar(getApplicationContext(), snack); + snack.show(); + } + + try { + String getAllData = helper.getAllData(); + arrayData = getAllData.split("\n"); + for (String anArrayData1 : arrayData) { + String onlyname = anArrayData1.split("&")[0]; + String onlypassword = anArrayData1.split("&")[1]; + if (onlyname.equals(account)) { + userid = onlyname; + password = onlypassword; + break; + } + } + } catch (ArrayIndexOutOfBoundsException e) { + helper.reset(); + finish(); + } + Bundle extras = getIntent().getExtras(); + assert extras != null; + String token = extras.getString("token", null); + + int mColor; + if (theme.equals("0")) + mColor = R.color.primary; + else + mColor = android.R.color.black; + + + headerResult = new AccountHeaderBuilder() + .withActivity(this) + .withTranslucentStatusBar(true) + .withHeaderBackground(mColor) + + .addProfiles( + new ProfileSettingDrawerItem().withName("Agg. Account").withEmail("Aggiungi account iliad").withIcon(R.drawable.ic_add).withIdentifier(PROFILE_SETTING) + + ) + .withOnAccountHeaderListener((view, profile, current) -> { + if (profile instanceof IDrawerItem && profile.getIdentifier() == PROFILE_SETTING) { + if (headerResult.getProfiles() != null) { + editor.putString("checkbox", "false"); + editor.apply(); + + Intent mainActivity = new Intent(HomeActivity.this, LoginActivity.class); + startActivity(mainActivity); + } + } else { + + for (String anArrayData : arrayData) { + String onlyname = anArrayData.split("&")[0]; + String onlypassword = anArrayData.split("&")[1]; + String phone = anArrayData.split("&")[2]; + String getPhone = profile.getEmail().getText().toString(); + + + if (getPhone.replaceAll("\\s+", "").equals(phone.replaceAll("\\s+", ""))) { + userid = onlyname; + password = onlypassword; + editor.putString("account", onlyname); + editor.apply(); + + Intent mainActivity = new Intent(HomeActivity.this, LoginActivity.class); + startActivity(mainActivity); + break; + } + } + } + + + return false; + }) + .withSavedInstance(savedInstanceState) + .build(); + + + String nameDB = helper.getName(); + String phoneDB = helper.getPhoneNumber(); + String idDB = helper.getUserID(); + + String[] prova = nameDB.split("\n"); + String[] prova1 = phoneDB.split("\n"); + String[] prova2 = idDB.split("\n"); + + + for (int z = 0; z < prova.length; z++) { + + + if (prova2[z].equals(account)) { + IProfile profile = new ProfileDrawerItem().withNameShown(true).withName(prova[z]).withEmail(prova1[z]).withIcon(R.drawable.ic_account_circle).withIdentifier(z); + + + headerResult.addProfile(profile, pos); + } + } + + for (int z = 0; z < prova.length; z++) { + + if (!prova2[z].equals(account)) { + IProfile profile = new ProfileDrawerItem().withNameShown(true).withName(prova[z]).withEmail(prova1[z]).withIcon(R.drawable.ic_account_circle).withIdentifier(z); + headerResult.addProfile(profile, pos++); + } + } + + + if (isOnline()) { + try { + String site_url = getString(R.string.site_url) + getString(R.string.login); + String url = site_url + "?userid=" + userid + "&password=" + password.replaceAll("\\s+", "") + "&token=" + token; + getObject(url, toolbar, savedInstanceState); + settings = getSharedPreferences("sharedPreferences", 0); + editor = settings.edit(); + editor.putString("token", token); + editor.apply(); + } catch (Exception ignored) { + //startActivity(new Intent(this, LoginActivity.class)); + + } + + } else { + String jsonLogin = PreferenceManager. + getDefaultSharedPreferences(HomeActivity.this).getString("login", null); + + try { + JSONObject jsonObjLogin = new JSONObject(jsonLogin); + getOfflineObject(jsonObjLogin, toolbar, savedInstanceState); + } catch (JSONException e) { + e.printStackTrace(); + } + + } + + + // se alert non esiste esegui l'azione e incrementalo a 1 + if (alert == null) { + if (isOnline()) { + RequestQueue queue = Volley.newRequestQueue(HomeActivity.this); + String site_url = getString(R.string.site_url) + getString(R.string.alert); + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, site_url, null, + response -> { + try { + + PreferenceManager.getDefaultSharedPreferences(HomeActivity.this).edit() + .putString("alert", response.toString()).apply(); + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + String string_response = json.getString("0"); + + AlertDialog dialog = new AlertDialog.Builder(this) + .setTitle(R.string.warning) + .setMessage(Html.fromHtml(string_response)) + .setCancelable(false) + .setPositiveButton(R.string.read, (dialog1, which) -> dialog1.dismiss()) + .setNegativeButton(R.string.show, (dialog12, which) -> { + editor.putString("alert", "1"); + editor.apply(); + }) + .create(); + dialog.setOnShowListener(new DialogInterface.OnShowListener() { + private static final int ONE_DISMISS_MILLIS = 6000; + private static final int TWO_DISMISS_MILLIS = 16000; + + @Override + public void onShow(final DialogInterface dialog) { + + final Button oneButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); + final CharSequence oneButtonText = oneButton.getText(); + oneButton.setEnabled(false); + + final Button twoButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE); + final CharSequence twoButtonText = twoButton.getText(); + twoButton.setEnabled(false); + + + new CountDownTimer(ONE_DISMISS_MILLIS, 100) { + @Override + public void onTick(long millisUntilFinished) { + oneButton.setText(String.format( + Locale.getDefault(), "%s (%d)", + oneButtonText, + TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) + )); + } + + @Override + public void onFinish() { + if (((AlertDialog) dialog).isShowing()) { + oneButton.setEnabled(true); + oneButton.setText(oneButtonText); + + } + } + }.start(); + + + new CountDownTimer(TWO_DISMISS_MILLIS, 100) { + @Override + public void onTick(long millisUntilFinished) { + twoButton.setText(String.format( + Locale.getDefault(), "%s (%d)", + twoButtonText, + TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) + )); + } + + @Override + public void onFinish() { + if (((AlertDialog) dialog).isShowing()) { + twoButton.setEnabled(true); + twoButton.setText(twoButtonText); + + } + } + }.start(); + + + } + }); + if (!this.isFinishing()) + dialog.show(); + + + } catch (JSONException e) { + new DialogError(this, String.valueOf(e)).alertbox(); + } + + }, error -> { + }); + queue.add(getRequest); + } else { + + try { + String jsonAlert = PreferenceManager. + getDefaultSharedPreferences(HomeActivity.this).getString("alert", null); + + + JSONObject json_raw = new JSONObject(jsonAlert); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + String string_response = json.getString("0"); + + AlertDialog dialog = new AlertDialog.Builder(this) + .setTitle(R.string.warning) + .setMessage(Html.fromHtml(string_response)) + .setCancelable(false) + .setPositiveButton(R.string.read, (dialog1, which) -> dialog1.dismiss()) + .setNegativeButton(R.string.show, (dialog12, which) -> { + editor.putString("alert", "1"); + editor.apply(); + }) + .create(); + dialog.setOnShowListener(new DialogInterface.OnShowListener() { + private static final int ONE_DISMISS_MILLIS = 6000; + private static final int TWO_DISMISS_MILLIS = 16000; + + @Override + public void onShow(final DialogInterface dialog) { + + final Button oneButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); + final CharSequence oneButtonText = oneButton.getText(); + oneButton.setEnabled(false); + + final Button twoButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE); + final CharSequence twoButtonText = twoButton.getText(); + twoButton.setEnabled(false); + + + new CountDownTimer(ONE_DISMISS_MILLIS, 100) { + @Override + public void onTick(long millisUntilFinished) { + oneButton.setText(String.format( + Locale.getDefault(), "%s (%d)", + oneButtonText, + TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) + )); + } + + @Override + public void onFinish() { + if (((AlertDialog) dialog).isShowing()) { + oneButton.setEnabled(true); + oneButton.setText(oneButtonText); + + } + } + }.start(); + + + new CountDownTimer(TWO_DISMISS_MILLIS, 100) { + @Override + public void onTick(long millisUntilFinished) { + twoButton.setText(String.format( + Locale.getDefault(), "%s (%d)", + twoButtonText, + TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) + )); + } + + @Override + public void onFinish() { + if (((AlertDialog) dialog).isShowing()) { + twoButton.setEnabled(true); + twoButton.setText(twoButtonText); + + } + } + }.start(); + + + } + }); + if (!this.isFinishing()) + dialog.show(); + + } catch (JSONException e) { + new DialogError(this, String.valueOf(e)).alertbox(); + } + + } + } + + + } + + private void getObject(String url, Toolbar toolbar, Bundle savedInstanceState) { + + + RequestQueue queue = Volley.newRequestQueue(HomeActivity.this); + queue.getCache().clear(); + JsonObjectRequest getRequest1 = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + try { + + PreferenceManager.getDefaultSharedPreferences(HomeActivity.this).edit() + .putString("login", response.toString()).apply(); + + String iliad = response.getString("iliad"); + JSONObject json = new JSONObject(iliad); + + // se la versione non è supportata vai alla schermata di errore + + String stringVersion = json.getString("version"); + if (BuildConfig.VERSION_CODE < Integer.parseInt(stringVersion)) { + + AlertDialog dialog = new AlertDialog.Builder(this) + .setTitle(R.string.dlgTitleUpdate) + .setMessage(String.format(getString(R.string.dlgMsgUpdate), getString(R.string.app_name), stringVersion)) + .setCancelable(false) + .setPositiveButton(R.string.dlgBtnUpdate, null) + .show(); + + Button btnUpdate = dialog.getButton(AlertDialog.BUTTON_POSITIVE); + btnUpdate.setOnClickListener(v -> startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("http://github.com/fast0n/iliad/releases/latest")))); + loading.setVisibility(View.INVISIBLE); + + } else { + + String stringSim = json.getString("sim"); + + result = new DrawerBuilder() + .withActivity(HomeActivity.this) + .withToolbar(toolbar) + .withHasStableIds(true) + .withItemAnimator(new AlphaCrossFadeAnimator()) + .withAccountHeader(headerResult) + .addDrawerItems( + new PrimaryDrawerItem().withName(R.string.nav_credit).withIcon(R.drawable.ic_credit).withIdentifier(1).withSelectable(true), + new PrimaryDrawerItem().withName(R.string.nav_info).withIcon(R.drawable.ic_info).withIdentifier(5).withSelectable(true), + new PrimaryDrawerItem().withName(R.string.nav_sim).withIcon(R.drawable.ic_sim_card).withIdentifier(6).withSelectable(true), + + new SectionDrawerItem().withName(R.string.split_menu), + new SecondaryDrawerItem().withName(R.string.nav_contactus).withIcon(R.drawable.ic_warning).withIdentifier(20).withSelectable(false), + new SecondaryDrawerItem().withName(R.string.nav_aboutus).withIcon(R.drawable.ic_info_outline).withIdentifier(21).withSelectable(true), + new SecondaryDrawerItem().withName(R.string.nav_logout).withIcon(R.drawable.ic_logout).withIdentifier(23).withSelectable(false) + + ) + .withOnDrawerItemClickListener((view, position, drawerItem) -> { + + Fragment fragment = null; + + if (drawerItem != null && isOnline()) { + + + if (drawerItem.getIdentifier() == 1 ) { + fragment = new MasterCreditFragment(); + } else if (drawerItem.getIdentifier() == 2) { + fragment = new OptionsFragment(); + } else if (drawerItem.getIdentifier() == 3 ) { + fragment = new ServicesFragment(); + } else if (drawerItem.getIdentifier() == 4 ) { + fragment = new VoicemailFragment(); + } else if (drawerItem.getIdentifier() == 5 ) { + fragment = new InfoFragments(); + } else if (drawerItem.getIdentifier() == 6 ) { + fragment = new SimFragments(); + } else if (drawerItem.getIdentifier() == 7 ) { + fragment = new ConditionsFragment(); + } + else if (drawerItem.getIdentifier() == 20) { + RequestQueue queue1 = Volley.newRequestQueue(HomeActivity.this); + + String url1 = getString(R.string.site_url) + getString(R.string.alert); + + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url1, null, + response1 -> { + try { + + PreferenceManager.getDefaultSharedPreferences(HomeActivity.this).edit() + .putString("alert", response1.toString()).apply(); + + JSONObject json_raw1 = new JSONObject(response1.toString()); + String iliad1 = json_raw1.getString("iliad"); + + JSONObject json1 = new JSONObject(iliad1); + String string_response = json1.getString("0"); + + new MaterialStyledDialog.Builder(HomeActivity.this) + .setTitle(R.string.warning) + .setDescription(Html.fromHtml(string_response)) + .setScrollable(true) + .setStyle(Style.HEADER_WITH_TITLE) + .setPositiveText(R.string.read) + .setCancelable(false) + .onPositive((dialog, which) -> { + + }).setScrollable(true, 10) + .show(); + + } catch (JSONException ignored) { + } + + }, error -> { + }); + + queue1.add(getRequest); + + } + else if (drawerItem.getIdentifier() == 21 ) { + fragment = new AboutFragment(); + } else if (drawerItem.getIdentifier() == 22 ) { + fragment = new SettingsFragment(); + } else if (drawerItem.getIdentifier() == 23 ) { + new AlertDialog.Builder(HomeActivity.this).setMessage(R.string.dialog_exit).setCancelable(false) + .setPositiveButton(getString(R.string.yes), (dialog, id1) -> { + + + String getAllData = helper.getAllData(); + String[] arrayData = getAllData.split("\n"); + + for (String anArrayData : arrayData) { + String onlyname = anArrayData.split("&")[0]; + if (onlyname.equals(account)) { + helper.delete(account); + break; + } + } + + if (arrayData.length > 1) { + String onlyname = arrayData[arrayData.length - 1].split("&")[0]; + editor.putString("account", onlyname); + editor.apply(); + Intent mainActivity = new Intent(HomeActivity.this, LoginActivity.class); + startActivity(mainActivity); + } else { + editor.putString("checkbox", "false"); + editor.putString("account", null); + editor.apply(); + + Intent mainActivity = new Intent(HomeActivity.this, LoginActivity.class); + startActivity(mainActivity); + } + + + }).setNegativeButton(getString(R.string.no), null).show(); + } + if (fragment != null) { + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction ft = fragmentManager.beginTransaction(); + ft.replace(R.id.fragment, fragment); + ft.commit(); + } + } + else { + AlertDialog dialog = new AlertDialog.Builder(this) + .setTitle(R.string.errorconnection) + .setMessage(R.string.errorconnection_one) + .setCancelable(false) + .setPositiveButton(R.string.reload, null) + .show(); + + Button btnUpdate = dialog.getButton(AlertDialog.BUTTON_POSITIVE); + btnUpdate.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (isOnline()) + startActivity(new Intent(HomeActivity.this, LoginActivity.class)); + else + Toasty.info(HomeActivity.this, getString(R.string.errorconnection_one), Toast.LENGTH_SHORT, true) + .show(); + + } + }); + } + + return false; + }) + .withSavedInstance(savedInstanceState) + .build(); + + + SecondaryDrawerItem menuSetting = new SecondaryDrawerItem().withName(R.string.nav_settings).withIcon(R.drawable.ic_settings).withIdentifier(22).withSelectable(true); + PrimaryDrawerItem menuService = new PrimaryDrawerItem().withName(R.string.nav_options).withIcon(R.drawable.ic_options).withIdentifier(2).withSelectable(true); + PrimaryDrawerItem menuVoiceMail = new PrimaryDrawerItem().withName(R.string.nav_services).withIcon(R.drawable.ic_service).withIdentifier(3).withSelectable(true); + PrimaryDrawerItem menuInfo = new PrimaryDrawerItem().withName(R.string.nav_voicemail).withIcon(R.drawable.ic_voicemail).withIdentifier(4).withSelectable(true); + PrimaryDrawerItem menuConditions = new PrimaryDrawerItem().withName(R.string.nav_conditions).withIcon(R.drawable.ic_conditions).withIdentifier(7).withSelectable(true); + + if (stringSim.equals("false")) { + + Fragment fragment; + fragment = new SimFragments(); + + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction ft = fragmentManager.beginTransaction(); + ft.replace(R.id.fragment, fragment); + ft.commit(); + + } else { + Fragment fragment; + fragment = new MasterCreditFragment(); + + result.addItemAtPosition(menuService, 2); + result.addItemAtPosition(menuVoiceMail, 3); + result.addItemAtPosition(menuInfo, 4); + result.addItemAtPosition(menuConditions, 7); + + + result.addItemAtPosition(menuSetting, 11); + + + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction ft = fragmentManager.beginTransaction(); + ft.replace(R.id.fragment, fragment); + ft.commit(); + } + loading.setVisibility(View.INVISIBLE); + + + toggle.syncState(); + drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); + + } + } catch (JSONException error) { + Log.e(getString(R.string.app_name) + " " + this.getClass().getSimpleName(), String.valueOf(error)); + } catch (ArrayIndexOutOfBoundsException e) { + finish(); + } + + }, + error -> { + + + if (String.valueOf(error).equals("com.android.volley.TimeoutError")) { + finish(); + overridePendingTransition(0, 0); + startActivity(getIntent()); + overridePendingTransition(0, 0); + } else { + Log.e(getString(R.string.app_name) + " " + this.getClass().getSimpleName(), String.valueOf(error)); + } + + + }); + getRequest1.setRetryPolicy(new DefaultRetryPolicy( + 1000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT + )); + queue.add(getRequest1); + + + } + + private void getOfflineObject(JSONObject jsonRaw, Toolbar toolbar, Bundle savedInstanceState) { + + + try { + + String iliad = jsonRaw.getString("iliad"); + JSONObject json = new JSONObject(iliad); + + // se la versione non è supportata vai alla schermata di errore + String stringVersion = json.getString("version"); + if (BuildConfig.VERSION_CODE < Integer.parseInt(stringVersion)) { + AlertDialog dialog = new AlertDialog.Builder(this) + .setTitle(R.string.dlgTitleUpdate) + .setMessage(String.format(getString(R.string.dlgMsgUpdate), getString(R.string.app_name), stringVersion)) + .setCancelable(false) + .setPositiveButton(R.string.dlgBtnUpdate, null) + .show(); + + Button btnUpdate = dialog.getButton(AlertDialog.BUTTON_POSITIVE); + btnUpdate.setOnClickListener(v -> startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("http://github.com/fast0n/iliad/releases/latest")))); + loading.setVisibility(View.INVISIBLE); + } else { + + + result = new DrawerBuilder() + .withActivity(HomeActivity.this) + .withToolbar(toolbar) + .withItemAnimator(new AlphaCrossFadeAnimator()) + .withAccountHeader(headerResult) + .addDrawerItems( + new PrimaryDrawerItem().withName(R.string.nav_credit).withIcon(R.drawable.ic_credit).withIdentifier(0).withSelectable(true), + new SectionDrawerItem().withName(R.string.split_menu), + new PrimaryDrawerItem().withName(R.string.nav_settings).withIcon(R.drawable.ic_settings).withIdentifier(1).withSelectable(true), + new SecondaryDrawerItem().withName(R.string.nav_aboutus).withIcon(R.drawable.ic_info_outline).withIdentifier(2).withSelectable(true), + new SecondaryDrawerItem().withName(R.string.nav_logout).withIcon(R.drawable.ic_logout).withIdentifier(3).withSelectable(false) + + ) + .withOnDrawerItemClickListener((view, position, drawerItem) -> { + + Fragment fragment = null; + + if (drawerItem != null) { + if (drawerItem.getIdentifier() == 0) { + fragment = new MasterCreditFragment(); + } else if (drawerItem.getIdentifier() == 2) { + fragment = new AboutFragment(); + } else if (drawerItem.getIdentifier() == 1) { + fragment = new SettingsFragment(); + } + + if (fragment != null) { + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction ft = fragmentManager.beginTransaction(); + ft.replace(R.id.fragment, fragment); + ft.commit(); + } + } + + + return false; + }) + .withSavedInstance(savedInstanceState) + .build(); + + + Fragment fragment; + fragment = new MasterCreditFragment(); + + + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction ft = fragmentManager.beginTransaction(); + ft.replace(R.id.fragment, fragment); + ft.commit(); + + loading.setVisibility(View.INVISIBLE); + + + toggle.syncState(); + drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); + + } + } catch (JSONException error) { + Log.e(getString(R.string.app_name) + " " + this.getClass().getSimpleName(), String.valueOf(error)); + } + + + } + + private boolean isOnline() { + ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); + return (cm != null ? cm.getActiveNetworkInfo() : null) != null + && cm.getActiveNetworkInfo().isConnectedOrConnecting(); + } + + @Override + public void onBackPressed() { + DrawerLayout drawer = findViewById(R.id.drawer_layout); + if (drawer.isDrawerOpen(GravityCompat.START)) { + drawer.closeDrawer(GravityCompat.START); + } else { + if (backPressedToExitOnce) { + finishAffinity(); + + } else { + this.backPressedToExitOnce = true; + Toasty.error(HomeActivity.this, getString(R.string.press_back), Toast.LENGTH_SHORT).show(); + new Handler().postDelayed(() -> backPressedToExitOnce = false, 1000); + } + + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.home, menu); + return true; + } + +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/LoginActivity.java b/iliad/app/src/main/java/com/fast0n/ap/LoginActivity.java new file mode 100755 index 0000000..79590b8 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/LoginActivity.java @@ -0,0 +1,270 @@ +package com.fast0n.ap; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.ActivityInfo; +import android.net.ConnectivityManager; +import android.net.Uri; +import android.os.Bundle; +import android.os.Handler; + +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import android.util.Base64; +import android.view.View; +import android.view.inputmethod.InputMethodManager; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.dx.dxloadingbutton.lib.LoadingButton; +import com.fast0n.ap.java.GenerateToken; +import com.fast0n.ap.java.myDbAdapter; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.Objects; + +import es.dmoral.toasty.Toasty; + +public class LoginActivity extends AppCompatActivity { + + private final String token = GenerateToken.randomString(20); + TextView mTitle, textView2; + private int i; + private SharedPreferences settings; + private SharedPreferences.Editor editor; + private myDbAdapter helper; + private String account, checkbox_preference, theme; + private LoadingButton btn_login; + private EditText edt_id, edt_password; + + @Override + protected void onCreate(Bundle savedInstanceState) { + settings = getSharedPreferences("sharedPreferences", 0); + editor = settings.edit(); + theme = settings.getString("toggleTheme", null); + try { + if (theme.equals("0")) + setTheme(R.style.AppTheme); + else + setTheme(R.style.DarkTheme); + } catch (Exception ignored) { + editor.putString("toggleTheme", "0"); + editor.apply(); + } + + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_login); + + Toolbar toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); + mTitle = toolbar.findViewById(R.id.toolbar_title); + mTitle.setText(toolbar.getTitle()); + Objects.requireNonNull(getSupportActionBar()).setDisplayShowTitleEnabled(false); + + // java adresses + btn_login = findViewById(R.id.btn_login); + edt_id = findViewById(R.id.edt_id); + edt_password = findViewById(R.id.edt_password); + textView2 = findViewById(R.id.textView2); + helper = new myDbAdapter(this); + + // recupero password + textView2.setOnClickListener(v -> startActivity(new Intent(LoginActivity.this, ForgetActivity.class))); + + // prendere le SharedPreferences + checkbox_preference = settings.getString("checkbox", null); + account = settings.getString("account", null); + editor.apply(); + + // se la checkbox è uguale a true va alla home activity + if (checkbox_preference != null && checkbox_preference.equals("true")) + startActivity(new Intent(LoginActivity.this, HomeActivity.class).putExtra("token", token).addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)); + + + // azione tasto login + btn_login.setOnClickListener(v -> { + + // nascondere la tastiera + View view = this.getCurrentFocus(); + if (view != null) { + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } + + if (isOnline()) { + if (edt_id.getText().toString().length() != 0 + && edt_password.getText().toString().length() != 0) { + btn_login.startLoading(); //start loading + + String userid1 = edt_id.getText().toString(); + String password1 = edt_password.getText().toString(); + + byte[] encodeValue = Base64.encode(password1.getBytes(), Base64.DEFAULT); + String npassword = new String(encodeValue); + + String site_url = getString(R.string.site_url) + getString(R.string.login); + String url = site_url + "?userid=" + userid1 + "&password=" + npassword.replaceAll("\\s+", "") + "&token=" + token; + + + String getAllData = helper.getAllData(); + String[] arrayData = getAllData.split("\n"); + + boolean found = false; + + + for (String anArrayData : arrayData) { + String onlyname = anArrayData.split("&")[0]; + if (onlyname.equals(userid1)) { + found = true; + btn_login.loadingFailed(); + Toasty.info(LoginActivity.this, getString(R.string.account_already_use), Toast.LENGTH_SHORT).show(); + break; + } + } + + if (!found) + getObject(url, token, npassword.replaceAll("\\s+", "")); + btn_login.setEnabled(false); + + } else { + btn_login.setEnabled(true); + Toasty.error(LoginActivity.this, getString(R.string.error_login), Toast.LENGTH_SHORT).show(); + } + } else { + btn_login.setEnabled(true); + Toasty.error(LoginActivity.this, getString(R.string.errorconnection), Toast.LENGTH_SHORT).show(); + } + }); + } + + private void getObject(String url, String token, String password) { + RequestQueue queue = Volley.newRequestQueue(LoginActivity.this); + + + queue.getCache().clear(); + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + try { + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + JSONObject json = new JSONObject(iliad); + + // se la versione non è supportata vai alla schermata di errore + String stringVersion = json.getString("version"); + if (BuildConfig.VERSION_CODE < Integer.parseInt(stringVersion)) { + AlertDialog dialog = new AlertDialog.Builder(this) + .setTitle(R.string.dlgTitleUpdate) + .setMessage(String.format(getString(R.string.dlgMsgUpdate), getString(R.string.app_name), stringVersion)) + .setCancelable(false) + .setPositiveButton(R.string.dlgBtnUpdate, null) + .show(); + + Button btnUpdate = dialog.getButton(AlertDialog.BUTTON_POSITIVE); + btnUpdate.setOnClickListener(v -> startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("http://github.com/fast0n/iliad/releases/latest")))); + } + + String stringName = json.getString("user_name"); + String stringNumber = json.getString("user_numtell").replace("Numero: ", ""); + btn_login.loadingSuccessful(); + + // esegue il login dopo 1 sec per visualizzare l'animazione + Handler handler = new Handler(); + handler.postDelayed(() -> { + + + Intent intent = new Intent(LoginActivity.this, HomeActivity.class); + byte[] encodeValue = Base64.encode(password.getBytes(), Base64.DEFAULT); + String npassword = new String(encodeValue); + intent.putExtra("password", npassword); + intent.putExtra("token", token); + + + editor.putString("account", edt_id.getText().toString()); + editor.apply(); + + // Inserire i dati su DB + helper.insertData(edt_id.getText().toString(), password, stringName, stringNumber); + + settings = getSharedPreferences("sharedPreferences", 0); + editor = settings.edit(); + editor.putString("checkbox", "true"); + editor.apply(); + startActivity(intent); + + }, 000); + + + } catch (JSONException ignored) { + } + + }, + error -> { + + + try { + int error_code = error.networkResponse.statusCode; + + if (error_code == 503) { + Toasty.warning(LoginActivity.this, getString(R.string.error_login), Toast.LENGTH_LONG, true) + .show(); + btn_login.loadingFailed(); + btn_login.setEnabled(true); + } + } catch (Exception ignored) { + if (i <= 15) { + getObject(url, token, password); + i++; + } else { + Toasty.warning(LoginActivity.this, getString(R.string.error_login), Toast.LENGTH_LONG, true) + .show(); + btn_login.loadingFailed(); + btn_login.setEnabled(true); + + } + } + }); + + queue.add(getRequest); + } + + private boolean isOnline() { + ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); + return Objects.requireNonNull(cm).getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isConnectedOrConnecting(); + } + + @Override + public void onBackPressed() { + + try { + if (account == null && checkbox_preference.equals("false")) + finishAffinity(); + else { + editor.putString("checkbox", "true"); + editor.apply(); + finish(); + } + } catch (Exception e) { + finish(); + } + + } + + + @Override + protected void onStop() { + editor.putString("checkbox", "true"); + editor.apply(); + super.onStop(); + } +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/Widget.java b/iliad/app/src/main/java/com/fast0n/ap/Widget.java new file mode 100755 index 0000000..f1aa7e3 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/Widget.java @@ -0,0 +1,285 @@ +package com.fast0n.ap; + + +import android.app.AlarmManager; +import android.app.PendingIntent; +import android.appwidget.AppWidgetManager; +import android.appwidget.AppWidgetProvider; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.widget.RemoteViews; +import android.widget.Toast; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; +import com.bumptech.glide.request.target.AppWidgetTarget; +import com.fast0n.ap.java.GenerateToken; +import com.fast0n.ap.java.myDbAdapter; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; + +import static android.view.View.GONE; +import static android.view.View.INVISIBLE; +import static android.view.View.VISIBLE; + +public class Widget extends AppWidgetProvider { + public static String CLOCK_WIDGET_UPDATE = "com.fast0n.ap.widget.8BITCLOCK_WIDGET_UPDATE", stringUser_numtell; + private static myDbAdapter helper; + private static String password, account; + + static void updateAppWidget(Context context, + AppWidgetManager appWidgetManager, + int appWidgetId) { + + RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget); + RequestOptions options = new RequestOptions().override(50, 50); + + + AppWidgetTarget img = new AppWidgetTarget(context, R.id.img, views, appWidgetId) { + }; + Glide.with(context.getApplicationContext()).asBitmap() + .load(context.getString(R.string.site_url) +"ic_call.png").apply(options).into(img); + + + AppWidgetTarget img2 = new AppWidgetTarget(context, R.id.img2, views, appWidgetId) { + }; + Glide.with(context.getApplicationContext()).asBitmap() + .load(context.getString(R.string.site_url) + "ic_sms.png").apply(options).into(img2); + + + AppWidgetTarget img3 = new AppWidgetTarget(context, R.id.img3, views, appWidgetId) { + }; + Glide.with(context.getApplicationContext()).asBitmap() + .load(context.getString(R.string.site_url) +"ic_mms.png").apply(options).into(img3); + + helper = new myDbAdapter(context); + + + // java adresses + SharedPreferences settings = context.getSharedPreferences("sharedPreferences", 0); + + // prendere le SharedPreferences + account = settings.getString("account", null); + + + try { + String getAllData = helper.getAllData(); + String[] arrayData = getAllData.split("\n"); + for (String anArrayData : arrayData) { + String onlyname = anArrayData.split("&")[0]; + String onlypassword = anArrayData.split("&")[1]; + + if (onlyname.equals(account)) { + password = onlypassword; + stringUser_numtell = anArrayData.split("&")[2]; + break; + } + } + views.setViewVisibility(R.id.linearLayout, VISIBLE); + views.setViewVisibility(R.id.textView, INVISIBLE); + } catch (Exception ignored) { + views.setTextViewText(R.id.textView, "Esegui il login..."); + } + + + Intent iSetting = new Intent(context, LoginActivity.class); + PendingIntent piSetting = PendingIntent.getActivity(context, 0, iSetting, 0); + views.setOnClickPendingIntent(R.id.widget_click, piSetting); + + + Intent intentUpdate = new Intent(context, Widget.class); + intentUpdate.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE); + + + int[] idArray = new int[]{appWidgetId}; + intentUpdate.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, idArray); + PendingIntent pendingUpdate = PendingIntent.getBroadcast(context, appWidgetId, intentUpdate, PendingIntent.FLAG_UPDATE_CURRENT); + views.setOnClickPendingIntent(R.id.refresh, pendingUpdate); + + appWidgetManager.updateAppWidget(appWidgetId, views); + } + + @Override + public void onReceive(Context context, Intent intent) { + super.onReceive(context, intent); + + if (CLOCK_WIDGET_UPDATE.equals(intent.getAction())) { + ComponentName thisAppWidget = new ComponentName(context.getPackageName(), getClass().getName()); + AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); + int ids[] = appWidgetManager.getAppWidgetIds(thisAppWidget); + for (int appWidgetID : ids) { + updateAppWidget(context, appWidgetManager, appWidgetID); + + } + } + } + + @Override + public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { + final int N = appWidgetIds.length; + + + // Perform this loop procedure for each App Widget that belongs to this + // provider + for (int i = 0; i < N; i++) { + int appWidgetId = appWidgetIds[i]; + + updateAppWidget(context, appWidgetManager, appWidgetId); + final String site_url = context.getString(R.string.site_url); + // String site_url = PreferenceManager.getDefaultSharedPreferences(context).getString("credit", null); + + loading(site_url, account, context, appWidgetManager, appWidgetId); + + + } + } + + @Override + public void onDisabled(Context context) { + super.onDisabled(context); + AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); + alarmManager.cancel(createClockTickIntent(context)); + } + + + @Override + public void onEnabled(Context context) { + super.onEnabled(context); + AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); + + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(System.currentTimeMillis()); + calendar.add(Calendar.SECOND, 1); + alarmManager.setRepeating(AlarmManager.RTC, calendar.getTimeInMillis(), 1000, createClockTickIntent(context)); + } + + private PendingIntent createClockTickIntent(Context context) { + Intent intent = new Intent(CLOCK_WIDGET_UPDATE); + PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); + + return pendingIntent; + } + + private void loading(String site, String userid, Context context, AppWidgetManager appWidgetManager, int appWidgetId) { + Toast.makeText(context, "Widget aggiornato...", Toast.LENGTH_SHORT).show(); + RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget); + + final String token = GenerateToken.randomString(20); + String url = (site + "login/?userid=" + userid + "&password=" + password + "&token=" + token).replaceAll("\\s+", ""); + RequestQueue login = Volley.newRequestQueue(context); + JsonObjectRequest getRequestLogin = new JsonObjectRequest(Request.Method.GET, url, null, + (JSONObject response) -> { + + views.setTextViewText(R.id.user_numtell, stringUser_numtell); + Date date = new Date(System.currentTimeMillis()); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm", + Locale.ITALIAN); + String var = dateFormat.format(date); + + views.setTextViewText(R.id.update, context.getString(R.string.updatedat) + " " + var); + + + String url1 = site + "credit/?credit=true&token=" + token; + + RequestQueue creditqueue = Volley.newRequestQueue(context); + JsonObjectRequest getRequestCredit = new JsonObjectRequest(Request.Method.GET, url1, null, + response1 -> { + + try { + + JSONObject json_raw = new JSONObject(response1.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + + String stringCredit = json.getString("0"); + JSONObject json_Credit = new JSONObject(stringCredit); + String credit = json_Credit.getString("0"); + views.setTextViewText(R.id.credit, credit.split("&")[0]); + + String stringCall = json.getString("1"); + JSONObject json_Call = new JSONObject(stringCall); + String call = json_Call.getString("0"); + views.setTextViewText(R.id.call, call.replace("Chiamate: ", "")); + + String stringSms = json.getString("2"); + JSONObject json_Sms = new JSONObject(stringSms); + String sms = json_Sms.getString("0"); + views.setTextViewText(R.id.sms, sms); + + String stringGb = json.getString("3"); + JSONObject json_Gb = new JSONObject(stringGb); + String gb = json_Gb.getString("0"); + views.setTextViewText(R.id.gb, gb); + + String x = gb.split("/")[0]; + String y = gb.split("/")[1]; + + Double f = null; + Double e; + + + if (x.contains("GB")) { + x = x.substring(0, x.length() - 3); + e = Double.parseDouble(x.replace(",", ".")) * 1000; + + } else { + x = x.substring(0, x.length() - 2); + e = Double.parseDouble(x.replace(",", ".")); + + } + if (y.contains("GB")) { + y = y.substring(0, y.length() - 2); + f = Double.parseDouble(y.replace(",", ".")) * 1000; + + } + + Double ef = (e / f) * 100; + int result1 = ef.intValue(); + + views.setProgressBar(R.id.progressbar, 100, result1, false); + + String stringMms = json.getString("4"); + JSONObject json_Mms = new JSONObject(stringMms); + String mms = json_Mms.getString("0"); + views.setTextViewText(R.id.mms, mms); + views.setTextViewText(R.id.percentage, result1 + "%"); + + appWidgetManager.updateAppWidget(appWidgetId, views); + + + } catch (JSONException ignored) { + } + + }, error -> { + }); + creditqueue.add(getRequestCredit); + + }, error1 -> { + + try { + views.setViewVisibility(R.id.linearLayout, GONE); + } catch (Exception ignored) { + + + } + + + }); + + + login.add(getRequestLogin); + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/AboutFragment/AboutFragment.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/AboutFragment/AboutFragment.java new file mode 100755 index 0000000..0a1b4bb --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/AboutFragment/AboutFragment.java @@ -0,0 +1,91 @@ +package com.fast0n.ap.fragments.AboutFragment; + + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.Uri; +import android.os.Bundle; +import android.text.Html; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + +import com.fast0n.ap.BuildConfig; +import com.fast0n.ap.R; + +import java.util.Objects; + +public class AboutFragment extends Fragment { + + TextView tv_version, tv_author, tv_author2, tv_author3; + LinearLayout linearLayout, linearLayout2, linearLayout3, linearLayout4, linearLayout5, linearLayout6, linearLayout99; + + + public AboutFragment() { + } + + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + final View view = inflater.inflate(R.layout.fragment_about, container, false); + + final Context context; + context = Objects.requireNonNull(getActivity()).getApplicationContext(); + + // java adresses + tv_version = view.findViewById(R.id.tv_version); + tv_author = view.findViewById(R.id.tv_author); + tv_author2 = view.findViewById(R.id.tv_author2); + tv_author3 = view.findViewById(R.id.tv_author3); + + linearLayout = view.findViewById(R.id.linearLayout); + linearLayout2 = view.findViewById(R.id.linearLayout2); + linearLayout3 = view.findViewById(R.id.linearLayout3); + linearLayout4 = view.findViewById(R.id.linearLayout4); + linearLayout5 = view.findViewById(R.id.linearLayout5); + linearLayout6 = view.findViewById(R.id.linearLayout6); + + linearLayout99 = view.findViewById(R.id.linearLayout99); + + // print version and name app + tv_version.setText(Html.fromHtml(String.format(" %s
%s (%s) (%s)", getString(R.string.version), BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, BuildConfig.APPLICATION_ID))); + + + SharedPreferences settings = context.getSharedPreferences("sharedPreferences", 0); + String theme = settings.getString("toggleTheme", null); + if (theme.equals("0")) { + tv_author.setText(Html.fromHtml("" + getString(R.string.author) + "
Massimiliano Montaleone (Fast0n)")); + tv_author2.setText(Html.fromHtml("" + getString(R.string.authorapi) + "
Matteo Monteleone (MattVoid)")); + tv_author3.setText(Html.fromHtml("" + getString(R.string.designer) + "
Domenico Majorana (Nicuz)")); + } else { + tv_author.setText(Html.fromHtml("" + getString(R.string.author) + "
Massimiliano Montaleone (Fast0n)")); + tv_author2.setText(Html.fromHtml("" + getString(R.string.authorapi) + "
Matteo Monteleone (MattVoid)")); + tv_author3.setText(Html.fromHtml("" + getString(R.string.designer) + "
Domenico Majorana (Nicuz)")); + } + + + linearLayout.setOnClickListener(v -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://raw.githubusercontent.com/Fast0n/iliad/master/LICENSE")))); + + linearLayout2.setOnClickListener(v -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/fast0n/iliad")))); + + linearLayout3.setOnClickListener(v -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.me/Fast0n/1.0")))); + + linearLayout4.setOnClickListener(v -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/fast0n/")))); + + linearLayout5.setOnClickListener(v -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/mattvoid/")))); + + linearLayout6.setOnClickListener(v -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/Nicuz/")))); + + linearLayout99.setOnClickListener(v -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://raw.githubusercontent.com/Fast0n/iliad/master/PRIVACY")))); + + return view; + } + +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/ConditionsFragment/ConditionsFragment.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/ConditionsFragment/ConditionsFragment.java new file mode 100755 index 0000000..0e61b37 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/ConditionsFragment/ConditionsFragment.java @@ -0,0 +1,125 @@ +package com.fast0n.ap.fragments.ConditionsFragment; + +import android.content.Context; +import android.content.SharedPreferences; +import android.os.Bundle; +import androidx.annotation.NonNull; +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ProgressBar; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.fast0n.ap.R; +import com.fast0n.ap.java.CubeLoading; +import com.fast0n.ap.java.DialogError; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class ConditionsFragment extends Fragment { + + public ConditionsFragment() { + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + final View view = inflater.inflate(R.layout.fragment_conditions, container, false); + + final ProgressBar loading; + final Context context; + context = Objects.requireNonNull(getActivity()).getApplicationContext(); + ConstraintLayout linearLayout; + SharedPreferences settings; + String theme; + + // java adresses + loading = view.findViewById(R.id.progressBar); + settings = context.getSharedPreferences("sharedPreferences", 0); + theme = settings.getString("toggleTheme", null); + new CubeLoading(context, loading, theme).showLoading(); + linearLayout = view.findViewById(R.id.linearLayout); + linearLayout.setVisibility(View.INVISIBLE); + loading.setVisibility(View.VISIBLE); + + final Bundle extras = getActivity().getIntent().getExtras(); + assert extras != null; + final String token = extras.getString("token"); + + final String site_url = getString(R.string.site_url) + getString(R.string.document); + String url = site_url + "?doc=true&token=" + token; + + getObject(url, context, view); + + return view; + } + + private void getObject(String url, final Context context, View view) { + + final ProgressBar loading; + final RecyclerView recyclerView; + final List conditionList = new ArrayList<>(); + final ConstraintLayout linearLayout; + + // java adresses + recyclerView = view.findViewById(R.id.recycler_view); + loading = view.findViewById(R.id.progressBar); + linearLayout = view.findViewById(R.id.linearLayout); + + recyclerView.setHasFixedSize(true); + LinearLayoutManager llm = new LinearLayoutManager(context); + llm.setOrientation(LinearLayoutManager.VERTICAL); + recyclerView.setLayoutManager(llm); + + + RequestQueue queue = Volley.newRequestQueue(context); + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + + JSONObject json_raw; + try { + json_raw = new JSONObject(response.toString()); + + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + + for (int j = 0; j < json.length(); j++) { + + String string = json.getString(String.valueOf(j)); + JSONObject json_strings = new JSONObject(string); + + String a = json_strings.getString("0"); + String b = json_strings.getString("1"); + String c = json_strings.getString("2"); + + conditionList.add(new DataConditionsFragments(a, b, c)); + CustomAdapterConditions ca = new CustomAdapterConditions(conditionList, this.getActivity()); + recyclerView.setAdapter(ca); + + } + + linearLayout.setVisibility(View.VISIBLE); + loading.setVisibility(View.INVISIBLE); + } catch (JSONException e) { + new DialogError(this.getActivity(), String.valueOf(e)).alertbox(); + } + }, e -> new DialogError(this.getActivity(), String.valueOf(e)).alertbox()); + + // add it to the RequestQueue + queue.add(getRequest); + + } + +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/ConditionsFragment/CustomAdapterConditions.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/ConditionsFragment/CustomAdapterConditions.java new file mode 100755 index 0000000..6c51a86 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/ConditionsFragment/CustomAdapterConditions.java @@ -0,0 +1,70 @@ +package com.fast0n.ap.fragments.ConditionsFragment; + +import android.content.Intent; +import android.net.Uri; +import androidx.annotation.NonNull; +import androidx.fragment.app.FragmentActivity; +import androidx.recyclerview.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import com.fast0n.ap.R; + +import java.util.List; + +public class CustomAdapterConditions extends RecyclerView.Adapter { + + private final List conditionList; + FragmentActivity activity; + + CustomAdapterConditions(List conditionList, FragmentActivity activity) { + this.conditionList = conditionList; + this.activity = activity; + } + + @Override + public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { + DataConditionsFragments c = conditionList.get(position); + + holder.textView.setText(c.textView); + holder.textView1.setText(c.textView1); + + holder.icon.setImageResource(R.drawable.ic_open_in_browser); + holder.icon_info.setImageResource(R.drawable.ic_documents); + holder.icon.setOnClickListener(v -> activity.startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(c.url)))); + + + } + + @Override + public int getItemCount() { + return conditionList.size(); + } + + @NonNull + @Override + public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_info, parent, false); + return new MyViewHolder(v); + } + + class MyViewHolder extends RecyclerView.ViewHolder { + + TextView textView, textView1; + ImageView icon; + ImageView icon_info; + + MyViewHolder(View view) { + super(view); + textView = view.findViewById(R.id.textView2); + textView1 = view.findViewById(R.id.textView3); + icon = view.findViewById(R.id.icon); + icon_info = view.findViewById(R.id.icon_info); + + + } + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/ConditionsFragment/DataConditionsFragments.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/ConditionsFragment/DataConditionsFragments.java new file mode 100755 index 0000000..4ef98a2 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/ConditionsFragment/DataConditionsFragments.java @@ -0,0 +1,14 @@ +package com.fast0n.ap.fragments.ConditionsFragment; + +class DataConditionsFragments { + + public final String textView; + public final String textView1; + public final String url; + + DataConditionsFragments(String textView, String textView1, String url) { + this.textView = textView; + this.textView1 = textView1; + this.url = url; + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/CreditFragment/CreditFragment.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/CreditFragment/CreditFragment.java new file mode 100755 index 0000000..6ebeaf5 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/CreditFragment/CreditFragment.java @@ -0,0 +1,253 @@ +package com.fast0n.ap.fragments.CreditFragment; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.ConnectivityManager; +import android.os.Bundle; +import android.preference.PreferenceManager; +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.ProgressBar; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.ethanhua.skeleton.Skeleton; +import com.ethanhua.skeleton.SkeletonScreen; +import com.fast0n.ap.ConsumptionDetailsActivity.ConsumptionDetailsActivity; +import com.fast0n.ap.R; +import com.fast0n.ap.java.DialogError; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class CreditFragment extends Fragment { + + private final List creditList = new ArrayList<>(); + SharedPreferences settings; + String theme; + CustomAdapterCredit mRecyclerViewAdapter; + SwipeRefreshLayout pullToRefresh; + private ProgressBar loading; + private Context context; + private Button button; + private RecyclerView recyclerView; + private SkeletonScreen skeletonScreen; + + public CreditFragment() { + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + final View view = inflater.inflate(R.layout.fragment_credit, container, false); + int mColor; + + context = Objects.requireNonNull(getActivity()).getApplicationContext(); + // java adresses + loading = view.findViewById(R.id.progressBar); + settings = context.getSharedPreferences("sharedPreferences", 0); + theme = settings.getString("toggleTheme", null); + if (theme.equals("0")) + mColor = android.R.color.black; + else + mColor = android.R.color.white; + recyclerView = view.findViewById(R.id.recycler_view); + pullToRefresh = view.findViewById(R.id.pullToRefresh); + button = view.findViewById(R.id.button); + + SharedPreferences settings = context.getSharedPreferences("sharedPreferences", 0); + String token = settings.getString("token", null); + SharedPreferences.Editor editor = settings.edit(); + editor.apply(); + + final String site_url = getString(R.string.site_url) + getString(R.string.credit); + String url = site_url + "?credit=true&token=" + token; + + if (isOnline()) + getObject(url, context, mColor); + else + getOfflineObject(context, mColor); + + + pullToRefresh.setRefreshing(false); + + LinearLayoutManager llm = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false); + llm.setOrientation(LinearLayoutManager.VERTICAL); + recyclerView.setLayoutManager(llm); + recyclerView.setLayoutManager(new GridLayoutManager(context, 2)); + + pullToRefresh.setOnRefreshListener(() -> { + + skeletonScreen = Skeleton.bind(recyclerView) + .load(R.layout.row_credit_roaming_loading) + .duration(2000) + .count(4) + .angle(0) + .color(mColor) + .frozen(false) + .show(); + + recyclerView.setEnabled(false); + creditList.clear(); + mRecyclerViewAdapter = new CustomAdapterCredit(context, creditList); + recyclerView.setAdapter(mRecyclerViewAdapter); + + + if (isOnline()) + getObject(url, context, mColor); + else + getOfflineObject(context, mColor); + + pullToRefresh.setRefreshing(false); + }); + + if (!isOnline()) + button.setVisibility(View.GONE); + + button.setOnClickListener(v -> { + Intent intent = new Intent(context, ConsumptionDetailsActivity.class); + intent.putExtra("token", token); + startActivity(intent); + }); + return view; + } + + private void getObject(String url, final Context context, int mColor) { + + skeletonScreen = Skeleton.bind(recyclerView) + .load(R.layout.row_credit_roaming_loading) + .duration(2000) + .count(4) + .angle(0) + .frozen(false) + .color(mColor) + .show(); + + RequestQueue queue = Volley.newRequestQueue(context); + queue.getCache().clear(); + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + try { + PreferenceManager.getDefaultSharedPreferences(context).edit() + .remove("credit").apply(); + + + PreferenceManager.getDefaultSharedPreferences(context).edit() + .putString("credit", response.toString()).apply(); + + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + + for (int j = 1; j < json.length(); j++) { + + String string = json.getString(String.valueOf(j)); + JSONObject json_strings = new JSONObject(string); + + String c = json_strings.getString("0"); + try { + String b = json_strings.getString("1"); + String d = json_strings.getString("3"); + + creditList.add(new DataCreditFragments(b, c, d)); + mRecyclerViewAdapter = new CustomAdapterCredit(context, creditList); + recyclerView.setLayoutManager(new GridLayoutManager(context, 2)); + recyclerView.setAdapter(mRecyclerViewAdapter); + + } catch (Exception e) { + } + } + + + } catch (JSONException e) { + new DialogError(this.getActivity(), String.valueOf(e)).alertbox(); + } + }, + + ignored -> { + }); + + queue.add(getRequest); + + } + + + private void getOfflineObject(final Context context, int mColor) { + + skeletonScreen = Skeleton.bind(recyclerView) + .load(R.layout.row_credit_roaming_loading) + .duration(2000) + .count(4) + .angle(0) + .frozen(false) + .color(mColor) + .show(); + + String jsonCredit = PreferenceManager. + getDefaultSharedPreferences(context).getString("credit", null); + + try { + + JSONObject response = new JSONObject(jsonCredit); + + PreferenceManager.getDefaultSharedPreferences(context).edit() + .putString("credit", response.toString()).apply(); + + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + + for (int j = 1; j < json.length(); j++) { + + String string = json.getString(String.valueOf(j)); + JSONObject json_strings = new JSONObject(string); + + + String c = json_strings.getString("0"); + try { + String b = json_strings.getString("1"); + String d = json_strings.getString("3"); + + creditList.add(new DataCreditFragments(b, c, d)); + mRecyclerViewAdapter = new CustomAdapterCredit(context, creditList); + recyclerView.setLayoutManager(new GridLayoutManager(context, 2)); + recyclerView.setAdapter(mRecyclerViewAdapter); + + } catch (Exception e) { + } + + } + + + } catch (JSONException e) { + new DialogError(this.getActivity(), String.valueOf(e)).alertbox(); + } + } + + + private boolean isOnline() { + ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE); + return (cm != null ? cm.getActiveNetworkInfo() : null) != null + && cm.getActiveNetworkInfo().isConnectedOrConnecting(); + } + + +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/CreditFragment/CustomAdapterCredit.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/CreditFragment/CustomAdapterCredit.java new file mode 100755 index 0000000..571001b --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/CreditFragment/CustomAdapterCredit.java @@ -0,0 +1,72 @@ +package com.fast0n.ap.fragments.CreditFragment; + +import android.content.Context; +import android.content.SharedPreferences; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import com.bumptech.glide.Glide; +import com.fast0n.ap.R; + +import java.util.List; + +public class CustomAdapterCredit extends RecyclerView.Adapter { + + private final Context context; + private final List creditList; + + CustomAdapterCredit(Context context, List creditList) { + this.context = context; + this.creditList = creditList; + } + + @Override + public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { + DataCreditFragments c = creditList.get(position); + + holder.textView2.setText(c.title); + holder.textView3.setText(c.description); + + SharedPreferences settings = context.getSharedPreferences("sharedPreferences", 0); + String theme = settings.getString("toggleTheme", null); + + if (theme.equals("0")) + Glide.with(context).load(context.getString(R.string.site_url) + c.url).into(holder.icon_info); + else + Glide.with(context).load(context.getString(R.string.site_url) + c.url.replace(".png", "_dark.png")).into(holder.icon_info); + + } + + @Override + public int getItemCount() { + return creditList.size(); + } + + @NonNull + @Override + public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_credit_roaming, parent, false); + return new MyViewHolder(v); + } + + class MyViewHolder extends RecyclerView.ViewHolder { + + final TextView textView2; + final TextView textView3; + final ImageView icon_info; + + MyViewHolder(View view) { + super(view); + textView2 = view.findViewById(R.id.textView2); + textView3 = view.findViewById(R.id.textView3); + icon_info = view.findViewById(R.id.icon_info); + } + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/CreditFragment/DataCreditFragments.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/CreditFragment/DataCreditFragments.java new file mode 100755 index 0000000..47131ae --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/CreditFragment/DataCreditFragments.java @@ -0,0 +1,14 @@ +package com.fast0n.ap.fragments.CreditFragment; + +class DataCreditFragments { + + public final String title; + public final String description; + public final String url; + + DataCreditFragments(String description, String title, String url) { + this.title = title; + this.description = description; + this.url = url; + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/CreditRoamingFragment/CreditRoamingFragment.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/CreditRoamingFragment/CreditRoamingFragment.java new file mode 100755 index 0000000..5786b18 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/CreditRoamingFragment/CreditRoamingFragment.java @@ -0,0 +1,234 @@ +package com.fast0n.ap.fragments.CreditRoamingFragment; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.ConnectivityManager; +import android.os.Bundle; +import android.preference.PreferenceManager; +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.ProgressBar; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.ethanhua.skeleton.Skeleton; +import com.ethanhua.skeleton.SkeletonScreen; +import com.fast0n.ap.ConsumptionDetailsActivity.ConsumptionRoamingDetailActivity; +import com.fast0n.ap.R; +import com.fast0n.ap.java.DialogError; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +public class CreditRoamingFragment extends Fragment { + + private final List creditEsteroList = new ArrayList<>(); + SharedPreferences settings; + String theme; + CustomAdapterCreditRoaming mRecyclerViewAdapter; + SwipeRefreshLayout pullToRefresh; + private ProgressBar loading; + private Context context; + private Button button; + private RecyclerView recyclerView; + private SkeletonScreen skeletonScreen; + + + public CreditRoamingFragment() { + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + final View view = inflater.inflate(R.layout.fragment_credit_roaming, container, false); + int mColor; + + context = Objects.requireNonNull(getActivity()).getApplicationContext(); + + // java adresses + loading = view.findViewById(R.id.progressBar); + settings = context.getSharedPreferences("sharedPreferences", 0); + theme = settings.getString("toggleTheme", null); + if (theme.equals("0")) + mColor = android.R.color.black; + else + mColor = android.R.color.white; + recyclerView = view.findViewById(R.id.recycler_view); + pullToRefresh = view.findViewById(R.id.pullToRefresh); + button = view.findViewById(R.id.button); + + final Bundle extras = getActivity().getIntent().getExtras(); + assert extras != null; + final String token = extras.getString("token"); + + final String site_url = getString(R.string.site_url) + getString(R.string.credit); + String url = site_url + "?estero=true&token=" + token; + + if (isOnline()) + getObject(url, context, mColor); + else + getOfflineObject(context, mColor); + + + pullToRefresh.setRefreshing(false); + + LinearLayoutManager llm = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false); + llm.setOrientation(LinearLayoutManager.VERTICAL); + recyclerView.setLayoutManager(llm); + recyclerView.setLayoutManager(new GridLayoutManager(context, 2)); + + pullToRefresh.setOnRefreshListener(() -> { + skeletonScreen = Skeleton.bind(recyclerView) + .load(R.layout.row_credit_roaming_loading) + .duration(2000) + .count(4) + .angle(0) + .frozen(false) + .show(); + recyclerView.setEnabled(false); + creditEsteroList.clear(); + mRecyclerViewAdapter = new CustomAdapterCreditRoaming(context, creditEsteroList); + recyclerView.setAdapter(mRecyclerViewAdapter); + + if (isOnline()) + getObject(url, context, mColor); + else + getOfflineObject(context, mColor); + + pullToRefresh.setRefreshing(false); + + }); + + if (!isOnline()) + button.setVisibility(View.GONE); + + button.setOnClickListener(v -> { + Intent intent = new Intent(context, ConsumptionRoamingDetailActivity.class); + intent.putExtra("token", token); + startActivity(intent); + }); + + return view; + } + + private void getObject(String url, final Context context, int mColor) { + + skeletonScreen = Skeleton.bind(recyclerView) + .load(R.layout.row_credit_roaming_loading) + .duration(2000) + .count(4) + .angle(0) + .color(mColor) + .frozen(false) + .show(); + + // java adresses + RequestQueue queue = Volley.newRequestQueue(context); + queue.getCache().clear(); + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + try { + + PreferenceManager.getDefaultSharedPreferences(context).edit() + .putString("creditEstero", response.toString()).apply(); + + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + + for (int j = 1; j < json.length(); j++) { + + String string = json.getString(String.valueOf(j)); + JSONObject json_strings = new JSONObject(string); + + String c = json_strings.getString("0"); + try { + String b = json_strings.getString("1"); + String d = json_strings.getString("3"); + creditEsteroList.add(new DataCreditRoamingFragments(b, c, d)); + mRecyclerViewAdapter = new CustomAdapterCreditRoaming(context, creditEsteroList); + recyclerView.setLayoutManager(new GridLayoutManager(context, 2)); + recyclerView.setAdapter(mRecyclerViewAdapter); + } catch (Exception ignored) { + } + + + } + + } catch (JSONException e) { + new DialogError(this.getActivity(), String.valueOf(e)).alertbox(); + } + }, e -> new DialogError(this.getActivity(), String.valueOf(e)).alertbox()); + + + queue.add(getRequest); + + } + + private void getOfflineObject(final Context context, int mColor) { + skeletonScreen = Skeleton.bind(recyclerView) + .load(R.layout.row_credit_roaming_loading) + .duration(2000) + .count(4) + .angle(0) + .color(mColor) + .frozen(false) + .show(); + + + String jsonCredit = PreferenceManager. + getDefaultSharedPreferences(context).getString("creditEstero", null); + + try { + + JSONObject json_raw = new JSONObject(jsonCredit); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + + for (int j = 1; j < json.length(); j++) { + + String string = json.getString(String.valueOf(j)); + JSONObject json_strings = new JSONObject(string); + + String c = json_strings.getString("0"); + try { + String b = json_strings.getString("1"); + String d = json_strings.getString("3"); + creditEsteroList.add(new DataCreditRoamingFragments(b, c, d)); + } catch (Exception ignored) { + } + } + + + } catch (JSONException e) { + new DialogError(this.getActivity(), String.valueOf(e)).alertbox(); + } + mRecyclerViewAdapter = new CustomAdapterCreditRoaming(context, creditEsteroList); + recyclerView.setAdapter(mRecyclerViewAdapter); + } + + + private boolean isOnline() { + ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE); + return (cm != null ? cm.getActiveNetworkInfo() : null) != null + && cm.getActiveNetworkInfo().isConnectedOrConnecting(); + } +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/CreditRoamingFragment/CustomAdapterCreditRoaming.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/CreditRoamingFragment/CustomAdapterCreditRoaming.java new file mode 100755 index 0000000..651f775 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/CreditRoamingFragment/CustomAdapterCreditRoaming.java @@ -0,0 +1,70 @@ +package com.fast0n.ap.fragments.CreditRoamingFragment; + +import android.content.Context; +import android.content.SharedPreferences; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import com.bumptech.glide.Glide; +import com.fast0n.ap.R; + +import java.util.List; + +public class CustomAdapterCreditRoaming extends RecyclerView.Adapter { + + private final List creditEsteroList; + private final Context context; + + CustomAdapterCreditRoaming(Context context, List creditEsteroList) { + this.context = context; + this.creditEsteroList = creditEsteroList; + } + + @Override + public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { + DataCreditRoamingFragments c = creditEsteroList.get(position); + + holder.textView2.setText(c.title); + holder.textView3.setText(c.description); + SharedPreferences settings = context.getSharedPreferences("sharedPreferences", 0); + String theme = settings.getString("toggleTheme", null); + if (theme.equals("0")) + Glide.with(context).load(context.getString(R.string.site_url) + c.url).into(holder.icon_info); + else + Glide.with(context).load(context.getString(R.string.site_url) + c.url.replace(".png", "_dark.png")).into(holder.icon_info); + + } + + @Override + public int getItemCount() { + return creditEsteroList.size(); + } + + @NonNull + @Override + public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_credit_roaming, parent, false); + return new MyViewHolder(v); + } + + class MyViewHolder extends RecyclerView.ViewHolder { + + final TextView textView2; + final TextView textView3; + final ImageView icon_info; + + MyViewHolder(View view) { + super(view); + textView2 = view.findViewById(R.id.textView2); + textView3 = view.findViewById(R.id.textView3); + icon_info = view.findViewById(R.id.icon_info); + + + } + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/CreditRoamingFragment/DataCreditRoamingFragments.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/CreditRoamingFragment/DataCreditRoamingFragments.java new file mode 100755 index 0000000..b7f914f --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/CreditRoamingFragment/DataCreditRoamingFragments.java @@ -0,0 +1,14 @@ +package com.fast0n.ap.fragments.CreditRoamingFragment; + +class DataCreditRoamingFragments { + + public final String title; + public final String description; + public final String url; + + DataCreditRoamingFragments(String description, String title, String url) { + this.title = title; + this.description = description; + this.url = url; + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/InfoFragments/CustomAdapterInfo.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/InfoFragments/CustomAdapterInfo.java new file mode 100755 index 0000000..1c87e2c --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/InfoFragments/CustomAdapterInfo.java @@ -0,0 +1,76 @@ +package com.fast0n.ap.fragments.InfoFragments; + +import android.content.Context; +import android.content.SharedPreferences; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import com.bumptech.glide.Glide; +import com.fast0n.ap.R; + +import java.util.List; + +public class CustomAdapterInfo extends RecyclerView.Adapter { + + private final List infoList; + private final Context context; + + CustomAdapterInfo(Context context, List infoList) { + this.context = context; + this.infoList = infoList; + } + + @Override + public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { + DataInfoFragments c = infoList.get(position); + + holder.textView2.setText(c.textView2); + holder.textView3.setText(c.textView3); + holder.textView4.setText(c.textView4); + SharedPreferences settings = context.getSharedPreferences("sharedPreferences", 0); + String theme = settings.getString("toggleTheme", null); + if (theme.equals("0")) { + Glide.with(context).load(c.url).into(holder.icon_info); + Glide.with(context).load(c.url1).into(holder.icon); + } else { + Glide.with(context).load(context.getString(R.string.site_url)+c.url.replace(".png", "_dark.png")).into(holder.icon_info); + Glide.with(context).load(context.getString(R.string.site_url)+c.url1.replace(".png", "_dark.png")).into(holder.icon); + } + } + + @Override + public int getItemCount() { + return infoList.size(); + } + + @NonNull + @Override + public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_info, parent, false); + return new MyViewHolder(v); + } + + class MyViewHolder extends RecyclerView.ViewHolder { + + final TextView textView2; + final TextView textView3; + final TextView textView4; + final ImageView icon_info; + final ImageView icon; + + MyViewHolder(View view) { + super(view); + textView2 = view.findViewById(R.id.textView2); + textView3 = view.findViewById(R.id.textView3); + textView4 = view.findViewById(R.id.textView4); + icon_info = view.findViewById(R.id.icon_info); + icon = view.findViewById(R.id.icon); + + } + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/InfoFragments/DataInfoFragments.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/InfoFragments/DataInfoFragments.java new file mode 100755 index 0000000..05e3c54 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/InfoFragments/DataInfoFragments.java @@ -0,0 +1,18 @@ +package com.fast0n.ap.fragments.InfoFragments; + +class DataInfoFragments { + + public final String url1; + public final String textView2; + public final String textView3; + public final String textView4; + public final String url; + + DataInfoFragments(String url1, String textView2, String textView3, String textView4, String url) { + this.url1 = url1; + this.textView2 = textView2; + this.textView3 = textView3; + this.textView4 = textView4; + this.url = url; + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/InfoFragments/InfoFragments.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/InfoFragments/InfoFragments.java new file mode 100755 index 0000000..d184286 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/InfoFragments/InfoFragments.java @@ -0,0 +1,215 @@ +package com.fast0n.ap.fragments.InfoFragments; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ProgressBar; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.fast0n.ap.ChangeEmailActivity; +import com.fast0n.ap.ChangePasswordActivity; +import com.fast0n.ap.ChargeActivity; +import com.fast0n.ap.LoginActivity; +import com.fast0n.ap.R; +import com.fast0n.ap.java.CubeLoading; +import com.fast0n.ap.java.DialogError; +import com.fast0n.ap.java.RecyclerItemListener; +import com.github.javiersantos.materialstyleddialogs.MaterialStyledDialog; +import com.github.javiersantos.materialstyleddialogs.enums.Style; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import es.dmoral.toasty.Toasty; + +public class InfoFragments extends Fragment { + + public InfoFragments() { + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + final View view = inflater.inflate(R.layout.fragment_info, container, false); + + final ProgressBar loading; + final Context context; + context = Objects.requireNonNull(getActivity()).getApplicationContext(); + TextView offer; + SharedPreferences settings; + String theme; + + + // java adresses + loading = view.findViewById(R.id.progressBar); + settings = context.getSharedPreferences("sharedPreferences", 0); + theme = settings.getString("toggleTheme", null); + new CubeLoading(context, loading, theme).showLoading(); + offer = view.findViewById(R.id.offer); + + offer.setVisibility(View.INVISIBLE); + loading.setVisibility(View.VISIBLE); + + final Bundle extras = getActivity().getIntent().getExtras(); + assert extras != null; + final String password = extras.getString("password"); + final String token = extras.getString("token"); + + final String site_url = getString(R.string.site_url) + getString(R.string.infomation); + String url = site_url + "?info=true&token=" + token; + getObject(site_url, url, context, view, token, password); + + return view; + } + + private void getObject(String site_url, String url, final Context context, View view, final String token, final String password) { + + final ProgressBar loading; + final RecyclerView recyclerView; + TextView offer; + final List infoList = new ArrayList<>(); + + + // java adresses + offer = view.findViewById(R.id.offer); + recyclerView = view.findViewById(R.id.recycler_view); + loading = view.findViewById(R.id.progressBar); + + recyclerView.setHasFixedSize(true); + LinearLayoutManager llm = new LinearLayoutManager(context); + llm.setOrientation(LinearLayoutManager.VERTICAL); + recyclerView.setLayoutManager(llm); + + recyclerView.addOnItemTouchListener( + new RecyclerItemListener(context, recyclerView, new RecyclerItemListener.RecyclerTouchListener() { + public void onClickItem(View arg1, int position) { + + + switch (position) { + case 1: + TextView getNome = arg1.findViewById(R.id.textView3); + String type = getNome.getText().toString(); + if (type.equals("Manuale")) { + Intent intent1 = new Intent(context, ChargeActivity.class); + intent1.putExtra("name", "Cambio metodo..."); + intent1.putExtra("price", "false"); + intent1.putExtra("token", token); + startActivity(intent1); + } + break; + case 2: + Intent intent2 = new Intent(context, ChangeEmailActivity.class); + intent2.putExtra("password", password); + intent2.putExtra("token", token); + startActivity(intent2); + break; + case 3: + Intent intent = new Intent(context, ChangePasswordActivity.class); + intent.putExtra("password", password); + intent.putExtra("token", token); + startActivity(intent); + break; + case 4: + RequestQueue queue = Volley.newRequestQueue(context); + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, site_url + "?puk=true&token=" + token, null, + response -> { + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + String string = json.getString(String.valueOf(0)); + + new MaterialStyledDialog.Builder(getContext()) + .setStyle(Style.HEADER_WITH_TITLE) + .setTitle(string) + .show(); + + + } catch (JSONException e) { + startActivity(new Intent(context, LoginActivity.class)); + } + }, error -> startActivity(new Intent(context, LoginActivity.class))); + + // add it to the RequestQueue + queue.add(getRequest); + break; + default: + Toasty.warning(context, getString(R.string.coming_soon), Toast.LENGTH_SHORT, true).show(); + } + + } + + public void onLongClickItem(View v, int position) { + } + })); + + RequestQueue queue = Volley.newRequestQueue(context); + + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + + for (int i = 0; i < json.length(); i++) { + + String string = json.getString(String.valueOf(i)); + JSONObject json_strings = new JSONObject(string); + + try { + String a = json_strings.getString("0"); + String b = json_strings.getString("1"); + String c = json_strings.getString("2"); + String d = json_strings.getString("3"); + String e = json_strings.getString("4"); + infoList.add(new DataInfoFragments(d, a, b, c, e)); + + } catch (Exception e) { + String a = json_strings.getString("0"); + String b = json_strings.getString("1"); + String c = json_strings.getString("2"); + String d = json_strings.getString("3"); + + infoList.add(new DataInfoFragments(c, a, b, "", d)); + CustomAdapterInfo ca = new CustomAdapterInfo(context, infoList); + recyclerView.setAdapter(ca); + } + + } + + + offer.setVisibility(View.VISIBLE); + loading.setVisibility(View.INVISIBLE); + + } catch (JSONException e) { + new DialogError(this.getActivity(), String.valueOf(e)).alertbox(); + } + }, e -> new DialogError(this.getActivity(), String.valueOf(e)).alertbox()); + + // add it to the RequestQueue + queue.add(getRequest); + + } + +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/MasterCreditFragment.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/MasterCreditFragment.java new file mode 100755 index 0000000..ff41d35 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/MasterCreditFragment.java @@ -0,0 +1,234 @@ +package com.fast0n.ap.fragments; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.net.ConnectivityManager; +import android.os.Bundle; +import android.preference.PreferenceManager; +import androidx.annotation.NonNull; +import com.google.android.material.tabs.TabLayout; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentPagerAdapter; +import androidx.viewpager.widget.ViewPager; +import androidx.appcompat.app.AppCompatDelegate; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.TextView; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.fast0n.ap.ChargeActivity; +import com.fast0n.ap.R; +import com.fast0n.ap.fragments.CreditFragment.CreditFragment; +import com.fast0n.ap.fragments.CreditRoamingFragment.CreditRoamingFragment; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.TimeUnit; + +public class MasterCreditFragment extends Fragment { + + + String theme; + SharedPreferences settings; + + public static long getDateDiff(SimpleDateFormat format, String oldDate, String newDate) { + try { + return TimeUnit.DAYS.convert(format.parse(newDate).getTime() - format.parse(oldDate).getTime(), TimeUnit.MILLISECONDS); + } catch (Exception e) { + return 0; + } + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setRetainInstance(true); + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); + final Context context; + context = Objects.requireNonNull(getActivity()).getApplicationContext(); + + // java adresses + View view = inflater.inflate(R.layout.fragment_credit_master, container, false); + ViewPager viewPager = view.findViewById(R.id.viewpager); + TextView credit = view.findViewById(R.id.creditText); + TextView description = view.findViewById(R.id.descriptionText); + TextView description2 = view.findViewById(R.id.descriptionText2); + + Button button = view.findViewById(R.id.button); + + SharedPreferences settings = context.getSharedPreferences("sharedPreferences", 0); + String token = settings.getString("token", null); + SharedPreferences.Editor editor = settings.edit(); + editor.apply(); + + if (!isOnline()) + button.setVisibility(View.GONE); + + + if (isOnline()) { + + String site_url = getString(R.string.site_url) + getString(R.string.credit); + String url = site_url + "?credit=true&token=" + token; + + RequestQueue queue = Volley.newRequestQueue(context); + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + try { + + PreferenceManager.getDefaultSharedPreferences(context).edit() + .putString("master", response.toString()).apply(); + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + String string1 = json.getString("0"); + JSONObject json_strings1 = new JSONObject(string1); + String stringCredit = json_strings1.getString("0"); + + credit.setText(stringCredit.split("&")[0]); + + String timeStamp = new SimpleDateFormat("dd/MM/yyyy").format(Calendar.getInstance().getTime()); + + + int dateDifference = (int) getDateDiff(new SimpleDateFormat("dd/MM/yyyy"), timeStamp, stringCredit.split("&")[1].replaceAll("\\s+", "")); + description.setText(String.valueOf(dateDifference - 1)); + + if (dateDifference - 1 > 1) + description2.setText(context.getString(R.string.days_renewal)); + else + description2.setText(context.getString(R.string.day_renewal)); + + + button.setOnClickListener(v -> { + Intent intent1 = new Intent(context, ChargeActivity.class); + intent1.putExtra("name", "Ricarica"); + intent1.putExtra("price", "true"); + intent1.putExtra("token", token); + startActivity(intent1); + }); + + + } catch (JSONException ignored) { + } + + }, error -> { + + }); + + queue.add(getRequest); + } else { + String jsonMaster = PreferenceManager. + getDefaultSharedPreferences(context).getString("master", null); + + + try { + JSONObject response = new JSONObject(jsonMaster); + PreferenceManager.getDefaultSharedPreferences(context).edit() + .putString("master", response.toString()).apply(); + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + String string1 = json.getString("0"); + JSONObject json_strings1 = new JSONObject(string1); + String stringCredit = json_strings1.getString("0"); + + credit.setText(stringCredit.split("&")[0]); + + String timeStamp = new SimpleDateFormat("dd/MM/yyyy").format(Calendar.getInstance().getTime()); + + + int dateDifference = (int) getDateDiff(new SimpleDateFormat("dd/MM/yyyy"), timeStamp, stringCredit.split("&")[1].replaceAll("\\s+", "")); + description.setText(String.valueOf(dateDifference - 1)); + + if (dateDifference - 1 > 1) + description2.setText(context.getString(R.string.days_renewal)); + else + description2.setText(context.getString(R.string.day_renewal)); + + } catch (JSONException ignored) { + } + + + } + setupViewPager(viewPager); + TabLayout tabs = view.findViewById(R.id.tabs); + tabs.setupWithViewPager(viewPager); + + settings = context.getSharedPreferences("sharedPreferences", 0); + theme = settings.getString("toggleTheme", null); + + if (theme.equals("0")) + tabs.setTabTextColors(Color.parseColor("#000000"),Color.parseColor("#c00000")); + else + tabs.setTabTextColors(Color.parseColor("#4f4f4f"),Color.parseColor("#ffffff")); + + return view; + + } + + private boolean isOnline() { + ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE); + return (cm != null ? cm.getActiveNetworkInfo() : null) != null + && cm.getActiveNetworkInfo().isConnectedOrConnecting(); + } + + private void setupViewPager(ViewPager viewPager) { + + Adapter adapter = new Adapter(getChildFragmentManager()); + adapter.addFragment(new CreditFragment(), getString(R.string.italy)); + adapter.addFragment(new CreditRoamingFragment(), getString(R.string.estero)); + viewPager.setAdapter(adapter); + + } + + static class Adapter extends FragmentPagerAdapter { + private final List mFragmentList = new ArrayList<>(); + private final List mFragmentTitleList = new ArrayList<>(); + + Adapter(FragmentManager manager) { + super(manager); + } + + @Override + public Fragment getItem(int position) { + return mFragmentList.get(position); + } + + @Override + public int getCount() { + return mFragmentList.size(); + } + + void addFragment(Fragment fragment, String title) { + mFragmentList.add(fragment); + mFragmentTitleList.add(title); + } + + @Override + public CharSequence getPageTitle(int position) { + return mFragmentTitleList.get(position); + } + } + +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/OptionsFragment/CustomAdapterOptions.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/OptionsFragment/CustomAdapterOptions.java new file mode 100755 index 0000000..331424d --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/OptionsFragment/CustomAdapterOptions.java @@ -0,0 +1,187 @@ +package com.fast0n.ap.fragments.OptionsFragment; + +import android.content.Context; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import androidx.recyclerview.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.CompoundButton; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.Switch; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.fast0n.ap.R; +import com.fast0n.ap.java.DialogError; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.List; + +import es.dmoral.toasty.Toasty; + +public class CustomAdapterOptions extends RecyclerView.Adapter { + + private final Context context; + private final String token; + private final List optionsList; + + CustomAdapterOptions(Context context, List optionsList, String token) { + this.context = context; + this.optionsList = optionsList; + this.token = token; + } + + @Override + public void onBindViewHolder(@NonNull final MyViewHolder holder, final int position) { + final DataOptionsFragments c = optionsList.get(position); + holder.textView.setText(c.textView); + + holder.toggle.setChecked(!c.toggle.equals("false")); + + if (position == 0) + holder.toggle.setEnabled(false); + /* TODO: aggiungere l'icona edit per poter modificare e attivare l'opzione */ + if (position == 3 || position == 4) + holder.toggle.setVisibility(View.INVISIBLE); + + + holder.imageView.setOnClickListener(v -> { + + if (!c.info.isEmpty()) { + + holder.progressBar.setVisibility(View.VISIBLE); + holder.imageView.setEnabled(false); + + String URL = context.getString(R.string.site_url) + context.getString(R.string.options) + "?info=true&type=" + c.info + "&token=" + token; + RequestQueue queue = Volley.newRequestQueue(context); + + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, URL, null, + response -> { + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + String title = json.getString("0"); + String description = json.getString("1"); + String isEnabled = json.getString("2"); + + AlertDialog.Builder alertDialog = new AlertDialog.Builder(v.getContext()); + + alertDialog.setTitle(title); + alertDialog.setMessage(description); + + if (!isEnabled.isEmpty() && isEnabled.equals("1")) { + alertDialog.setPositiveButton( + context.getString(R.string.enable), + (dialog, which) -> holder.toggle.setChecked(true) + ); + } else if (!isEnabled.isEmpty() && isEnabled.equals("0")) { + alertDialog.setNegativeButton( + context.getString(R.string.disable), + (dialog, which) -> holder.toggle.setChecked(false) + ); + } + + alertDialog.show(); + holder.progressBar.setVisibility(View.INVISIBLE); + holder.imageView.setEnabled(true); + + } catch (JSONException e) { + holder.progressBar.setVisibility(View.INVISIBLE); + holder.imageView.setEnabled(true); + new DialogError(context, String.valueOf(e)).alertbox(); + } + + }, error -> { + + }); + + queue.add(getRequest); + } + + + }); + + + holder.toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + + final String site_url = context.getString(R.string.site_url) + context.getString(R.string.options); + String url = site_url + "?change_options=true&update=" + c.update + "&token=" + token + + "&activate=" + (isChecked ? 1 : 0); + request_options_services(url, holder.textView.getText() + " " + (isChecked ? "attivo" : "disattivato")); + } + + private void request_options_services(String url, String labelOn) { + + RequestQueue queue = Volley.newRequestQueue(context); + + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + try { + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + String string_response = json.getString("0"); + + if (string_response.equals("true")) { + + Toasty.warning(context, labelOn, Toast.LENGTH_SHORT, true).show(); + } + + } catch (JSONException ignored) { + } + + }, e -> new DialogError(context, String.valueOf(e)).alertbox()); + + queue.add(getRequest); + + } + + }); + + + } + + @Override + public int getItemCount() { + return optionsList.size(); + } + + @NonNull + @Override + public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_options_services, parent, false); + return new MyViewHolder(v); + } + + class MyViewHolder extends RecyclerView.ViewHolder { + + final TextView textView; + final Switch toggle; + ImageView imageView; + ProgressBar progressBar; + + MyViewHolder(View view) { + super(view); + textView = view.findViewById(R.id.textView1); + toggle = view.findViewById(R.id.toggle); + imageView = view.findViewById(R.id.imageView); + progressBar = view.findViewById(R.id.progressBar); + + } + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/OptionsFragment/DataOptionsFragments.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/OptionsFragment/DataOptionsFragments.java new file mode 100755 index 0000000..ec341ff --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/OptionsFragment/DataOptionsFragments.java @@ -0,0 +1,16 @@ +package com.fast0n.ap.fragments.OptionsFragment; + +class DataOptionsFragments { + + public final String textView; + public final String toggle; + public final String update; + public final String info; + + DataOptionsFragments(String textView, String toggle, String update, String info) { + this.textView = textView; + this.toggle = toggle; + this.update = update; + this.info = info; + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/OptionsFragment/OptionsFragment.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/OptionsFragment/OptionsFragment.java new file mode 100755 index 0000000..b7063a8 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/OptionsFragment/OptionsFragment.java @@ -0,0 +1,146 @@ +package com.fast0n.ap.fragments.OptionsFragment; + +import android.content.Context; +import android.content.SharedPreferences; +import android.os.Bundle; +import androidx.annotation.NonNull; +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ProgressBar; +import android.widget.TextView; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.fast0n.ap.R; +import com.fast0n.ap.java.CubeLoading; +import com.fast0n.ap.java.DialogError; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class OptionsFragment extends Fragment { + + public OptionsFragment() { + // Required empty public constructor + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + final View view = inflater.inflate(R.layout.fragment_options, container, false); + + final ProgressBar loading; + final Context context; + context = Objects.requireNonNull(getActivity()).getApplicationContext(); + ConstraintLayout linearLayout; + SharedPreferences settings; + String theme; + + // java adresses + loading = view.findViewById(R.id.progressBar); + settings = context.getSharedPreferences("sharedPreferences", 0); + theme = settings.getString("toggleTheme", null); + new CubeLoading(context, loading, theme).showLoading(); + linearLayout = view.findViewById(R.id.linearLayout); + + linearLayout.setVisibility(View.INVISIBLE); + loading.setVisibility(View.VISIBLE); + + final Bundle extras = getActivity().getIntent().getExtras(); + assert extras != null; + final String token = extras.getString("token"); + + final String site_url = getString(R.string.site_url) + getString(R.string.options); + String url = site_url + "?option=true&token=" + token; + + getObject(url, context, view); + + return view; + } + + private void getObject(String url, final Context context, View view) { + + final ProgressBar loading; + final RecyclerView recyclerView; + final List infoList = new ArrayList<>(); + final ConstraintLayout linearLayout; + final TextView credit; + + final Bundle extras = getActivity().getIntent().getExtras(); + assert extras != null; + final String token = extras.getString("token"); + + // java adresses + recyclerView = view.findViewById(R.id.recycler_view); + loading = view.findViewById(R.id.progressBar); + linearLayout = view.findViewById(R.id.linearLayout); + credit = view.findViewById(R.id.optionsText); + + recyclerView.setHasFixedSize(true); + LinearLayoutManager llm = new LinearLayoutManager(context); + llm.setOrientation(LinearLayoutManager.VERTICAL); + recyclerView.setLayoutManager(llm); + + + RequestQueue queue = Volley.newRequestQueue(context); + + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + + String string1 = json.getString("0"); + JSONObject json_strings1 = new JSONObject(string1); + String stringCredit = json_strings1.getString("0"); + credit.setText(stringCredit); + + for (int i = 1; i < json.length(); i++) { + + String string = json.getString(String.valueOf(i)); + JSONObject json_strings = new JSONObject(string); + + String name = json_strings.getString("0"); // nome dell'opzione + String status = json_strings.getString("2"); // parametro per controllare se l'opzione è attiva (quindi anche il toggle) + String update = json_strings.getString("3"); // parametro per attivare o disattivare l'opzione + String info = json_strings.getString("4"); // parametro per ottenere le informazioni dell'opzione + + infoList.add(new DataOptionsFragments(name, status, update, info)); + + + CustomAdapterOptions ca = new CustomAdapterOptions(context, infoList, token); + recyclerView.setAdapter(ca); + + } + + + linearLayout.setVisibility(View.VISIBLE); + loading.setVisibility(View.INVISIBLE); + + } catch (JSONException e) { + new DialogError(this.getActivity(), String.valueOf(e)).alertbox(); + } + + }, e -> new DialogError(this.getActivity(), String.valueOf(e)).alertbox()); + + // add it to the RequestQueue + queue.add(getRequest); + + + } + +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/ServicesFragment/CustomAdapterServices.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/ServicesFragment/CustomAdapterServices.java new file mode 100755 index 0000000..8486df7 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/ServicesFragment/CustomAdapterServices.java @@ -0,0 +1,183 @@ +package com.fast0n.ap.fragments.ServicesFragment; + +import android.content.Context; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import androidx.recyclerview.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.Switch; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.fast0n.ap.R; +import com.fast0n.ap.java.DialogError; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.List; + +import es.dmoral.toasty.Toasty; + +public class CustomAdapterServices extends RecyclerView.Adapter { + + private final Context context; + private final String token; + private final List ServicesList; + + CustomAdapterServices(Context context, List ServicesList, String token) { + this.context = context; + this.ServicesList = ServicesList; + this.token = token; + } + + @Override + public void onBindViewHolder(@NonNull final MyViewHolder holder, final int position) { + final DataServicesFragments c = ServicesList.get(position); + holder.textView.setText(c.textView); + + + final String site_url = context.getString(R.string.site_url) + context.getString(R.string.services); + + + holder.imageView.setOnClickListener(v -> { + + if (!c.info.isEmpty()) { + + holder.progressBar.setVisibility(View.VISIBLE); + holder.imageView.setEnabled(false); + + String URL = context.getString(R.string.site_url) + context.getString(R.string.services) + "?info=true&type=" + c.info + "&token=" + token; + RequestQueue queue = Volley.newRequestQueue(context); + + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, URL, null, + response -> { + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + String title = json.getString("0"); + String description = json.getString("1"); + String isEnabled = json.getString("2"); + + AlertDialog.Builder alertDialog = new AlertDialog.Builder(v.getContext()); + + + alertDialog.setTitle(title); + alertDialog.setMessage(description); + + if (!isEnabled.isEmpty() && isEnabled.equals("1")) { + alertDialog.setPositiveButton( + context.getString(R.string.enable), + (dialog, which) -> holder.toggle.setChecked(true) + ); + } else if (!isEnabled.isEmpty() && isEnabled.equals("0")) { + alertDialog.setNegativeButton( + context.getString(R.string.disable), + (dialog, which) -> holder.toggle.setChecked(false) + ); + } + + + alertDialog.show(); + holder.progressBar.setVisibility(View.INVISIBLE); + holder.imageView.setEnabled(true); + + + } catch (JSONException e) { + holder.progressBar.setVisibility(View.INVISIBLE); + holder.imageView.setEnabled(true); + new DialogError(context, String.valueOf(e)).alertbox(); + } + + }, error -> { + + }); + + queue.add(getRequest); + } + + }); + + if (c.toggle.equals("false")) + holder.toggle.setChecked(false); + else + holder.toggle.setChecked(true); + + holder.toggle.setOnCheckedChangeListener((buttonView, isChecked) -> { + if (!isChecked) { + String url = site_url + "?change_services=true&update=" + c.update + "&token=" + token + "&activate=0"; + request_options_services(url, holder.textView.getText() + " " + "disattivato"); + } else { + String url = site_url + "?change_services=true&update=" + c.update + "&token=" + token + "&activate=1"; + request_options_services(url, holder.textView.getText() + " " + "attivo"); + } + + }); + } + + private void request_options_services(String url, final String labelOn) { + + RequestQueue queue = Volley.newRequestQueue(context); + + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + try { + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + String string_response = json.getString("0"); + + if (string_response.equals("true")) { + + Toasty.warning(context, labelOn, Toast.LENGTH_SHORT, true).show(); + } + + } catch (JSONException ignored) { + } + + }, e -> new DialogError(context, String.valueOf(e)).alertbox()); + + queue.add(getRequest); + + } + + @Override + public int getItemCount() { + return ServicesList.size(); + } + + @Override + public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_options_services, parent, false); + return new MyViewHolder(v); + } + + class MyViewHolder extends RecyclerView.ViewHolder { + + TextView textView; + Switch toggle; + ImageView imageView; + ProgressBar progressBar; + + MyViewHolder(View view) { + super(view); + textView = view.findViewById(R.id.textView1); + toggle = view.findViewById(R.id.toggle); + imageView = view.findViewById(R.id.imageView); + progressBar = view.findViewById(R.id.progressBar); + + } + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/ServicesFragment/DataServicesFragments.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/ServicesFragment/DataServicesFragments.java new file mode 100755 index 0000000..fd27ffb --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/ServicesFragment/DataServicesFragments.java @@ -0,0 +1,16 @@ +package com.fast0n.ap.fragments.ServicesFragment; + +class DataServicesFragments { + + public final String textView; + public final String toggle; + public final String update; + public final String info; + + DataServicesFragments(String textView, String toggle, String update, String info) { + this.textView = textView; + this.toggle = toggle; + this.update = update; + this.info = info; + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/ServicesFragment/ServicesFragment.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/ServicesFragment/ServicesFragment.java new file mode 100755 index 0000000..761694b --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/ServicesFragment/ServicesFragment.java @@ -0,0 +1,140 @@ +package com.fast0n.ap.fragments.ServicesFragment; + +import android.content.Context; +import android.content.SharedPreferences; +import android.os.Bundle; +import androidx.annotation.NonNull; +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ProgressBar; +import android.widget.TextView; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.fast0n.ap.R; +import com.fast0n.ap.java.CubeLoading; +import com.fast0n.ap.java.DialogError; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class ServicesFragment extends Fragment { + + public ServicesFragment() { + // Required empty public constructor + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + final View view = inflater.inflate(R.layout.fragment_services, container, false); + + final ProgressBar loading; + final Context context; + context = Objects.requireNonNull(getActivity()).getApplicationContext(); + ConstraintLayout linearLayout; + + // java adresses + loading = view.findViewById(R.id.progressBar); + linearLayout = view.findViewById(R.id.linearLayout); + + linearLayout.setVisibility(View.INVISIBLE); + loading.setVisibility(View.VISIBLE); + + final Bundle extras = getActivity().getIntent().getExtras(); + assert extras != null; + final String token = extras.getString("token"); + + final String site_url = getString(R.string.site_url) + getString(R.string.services); + String url = site_url + "?services=true&token=" + token; + + getObject(url, context, view); + + return view; + } + + private void getObject(String url, final Context context, View view) { + + final ProgressBar loading; + final RecyclerView recyclerView; + final List infoList = new ArrayList<>(); + final ConstraintLayout linearLayout; + final TextView credit; + SharedPreferences settings; + String theme; + + // java adresses + loading = view.findViewById(R.id.progressBar); + settings = context.getSharedPreferences("sharedPreferences", 0); + theme = settings.getString("toggleTheme", null); + new CubeLoading(context, loading, theme).showLoading(); + + recyclerView = view.findViewById(R.id.recycler_view); + linearLayout = view.findViewById(R.id.linearLayout); + credit = view.findViewById(R.id.creditText); + + final Bundle extras = getActivity().getIntent().getExtras(); + assert extras != null; + final String token = extras.getString("token"); + + recyclerView.setHasFixedSize(true); + LinearLayoutManager llm = new LinearLayoutManager(context); + llm.setOrientation(LinearLayoutManager.VERTICAL); + recyclerView.setLayoutManager(llm); + + RequestQueue queue = Volley.newRequestQueue(context); + + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + + String string1 = json.getString("0"); + JSONObject json_strings1 = new JSONObject(string1); + String stringCredit = json_strings1.getString("0"); + credit.setText(stringCredit); + + for (int i = 1; i < json.length(); i++) { + + String string = json.getString(String.valueOf(i)); + JSONObject json_strings = new JSONObject(string); + + String name = json_strings.getString("0"); // nome del servizio + String status = json_strings.getString("2"); // parametro per controllare se il servizio è attivo (quindi anche il toggle) + String update = json_strings.getString("3"); // parametro per attivare o disattivare il servizio + String info = json_strings.getString("4"); // parametro per ottenere le informazioni del servizio + + infoList.add(new DataServicesFragments(name, status, update, info)); + CustomAdapterServices ca = new CustomAdapterServices(context, infoList, token); + recyclerView.setAdapter(ca); + } + + + linearLayout.setVisibility(View.VISIBLE); + loading.setVisibility(View.INVISIBLE); + + } catch (JSONException e) { + new DialogError(this.getActivity(), String.valueOf(e)).alertbox(); + } + }, e -> new DialogError(this.getActivity(), String.valueOf(e)).alertbox()); + + // add it to the RequestQueue + queue.add(getRequest); + + } + +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/SettingsFragment/CustomAdapterSettings.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/SettingsFragment/CustomAdapterSettings.java new file mode 100755 index 0000000..929aa4b --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/SettingsFragment/CustomAdapterSettings.java @@ -0,0 +1,195 @@ +package com.fast0n.ap.fragments.SettingsFragment; + +import android.Manifest; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.net.Uri; +import android.os.Handler; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import android.provider.Settings; +import android.text.Html; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.Switch; +import android.widget.TextView; +import android.widget.Toast; + +import com.bumptech.glide.Glide; +import com.fast0n.ap.BuildConfig; +import com.fast0n.ap.LoginActivity; +import com.fast0n.ap.R; +import com.fast0n.ap.notifications.CheckNotification; +import com.google.firebase.messaging.FirebaseMessaging; +import com.gun0912.tedpermission.PermissionListener; +import com.gun0912.tedpermission.TedPermission; + +import java.util.List; + +import es.dmoral.toasty.Toasty; + +import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; + +public class CustomAdapterSettings extends RecyclerView.Adapter { + + private final Context context; + private final List SettingsList; + + CustomAdapterSettings(Context context, List SettingsList) { + this.context = context; + this.SettingsList = SettingsList; + } + + @Override + public void onBindViewHolder(@NonNull final MyViewHolder holder, final int position) { + final DataSettingsFragments c = SettingsList.get(position); + holder.textView.setText(Html.fromHtml(c.name)); + Glide.with(context).load(R.drawable.ic_settings).into(holder.imageView); + Handler handler = new Handler(); + + String[] permission = {"android.permission.READ_CONTACTS", "android.permission.WRITE_EXTERNAL_STORAGE"}; + + if (position == 3 && holder.toggleTheme.equals("1")) + holder.toggle.setChecked(true); + else if (position == 2 && holder.toggleNotification.equals("0")) + holder.toggle.setChecked(true); + else + holder.toggle.setChecked(false); + + + for (int i = 0; i < permission.length - 1; i++) { + int permission1 = context.checkCallingOrSelfPermission(permission[i]); + if (position == i && permission1 == PackageManager.PERMISSION_GRANTED) + holder.toggle.setChecked(true); + } + + holder.toggle.setOnCheckedChangeListener((buttonView, isChecked) -> { + PermissionListener permissionlistener = new PermissionListener() { + @Override + public void onPermissionGranted() { + Toasty.success(context, "Permesso approvato", Toast.LENGTH_SHORT).show(); + } + + @Override + public void onPermissionDenied(List deniedPermissions) { + Toasty.error(context, "Permesso negato", Toast.LENGTH_SHORT).show(); + holder.toggle.setChecked(false); + } + + + }; + + + switch (position) { + case 0: + if (holder.toggle.isChecked()) + TedPermission.with(context) + .setPermissionListener(permissionlistener) + .setPermissions(Manifest.permission.READ_CONTACTS) + .check(); + else { + holder.toggle.setChecked(true); + Intent i = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:" + BuildConfig.APPLICATION_ID)).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |Intent.FLAG_ACTIVITY_CLEAR_TASK); + context.startActivity(i); + } + break; + + case 1: + if (holder.toggle.isChecked()) + TedPermission.with(context) + .setPermissionListener(permissionlistener) + .setPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE) + .check(); + else { + holder.toggle.setChecked(true); + Intent i = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:" + BuildConfig.APPLICATION_ID)).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |Intent.FLAG_ACTIVITY_CLEAR_TASK); + context.startActivity(i); + } + break; + + case 2: + if (holder.toggle.isChecked()) { + holder.editor.putString("toggleNotification", "0"); + holder.editor.apply(); + String toasty = context.getString(R.string.toast_notification, context.getString(R.string.toggle_enable)); + Toasty.info(context, toasty, Toast.LENGTH_SHORT, true).show(); + FirebaseMessaging.getInstance().subscribeToTopic("notification"); + + } else { + holder.editor.putString("toggleNotification", "1"); + holder.editor.apply(); + String toasty = context.getString(R.string.toast_notification, context.getString(R.string.toggle_disable)); + Toasty.info(context, toasty, Toast.LENGTH_SHORT, true).show(); + FirebaseMessaging.getInstance().unsubscribeFromTopic("notification"); + + } + break; + + case 3: + final Runnable runnable = () -> context.startActivity(new Intent(context.getApplicationContext(), LoginActivity.class).addFlags(FLAG_ACTIVITY_NEW_TASK)); + + if (holder.toggle.isChecked()) { + holder.editor.putString("toggleTheme", "1"); + holder.editor.apply(); + String toasty = context.getString(R.string.toast_theme, context.getString(R.string.toggle_enable)); + Toasty.info(context, toasty, Toast.LENGTH_SHORT, true).show(); + handler.postDelayed(runnable, 500); + + } else { + holder.editor.putString("toggleTheme", "0"); + holder.editor.apply(); + String toasty = context.getString(R.string.toast_theme, context.getString(R.string.toggle_disable)); + Toasty.info(context, toasty, Toast.LENGTH_SHORT, true).show(); + handler.postDelayed(runnable, 500); + } + break; + + + } + + + }); + + } + + + @Override + public int getItemCount() { + return SettingsList.size(); + } + + @Override + public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_options_services, parent, false); + return new MyViewHolder(v); + } + + class MyViewHolder extends RecyclerView.ViewHolder { + + final TextView textView; + final Switch toggle; + ImageView imageView; + SharedPreferences settings; + SharedPreferences.Editor editor; + String toggleNotification, toggleTheme; + + MyViewHolder(View view) { + super(view); + textView = view.findViewById(R.id.textView1); + toggle = view.findViewById(R.id.toggle); + imageView = view.findViewById(R.id.imageView); + settings = context.getSharedPreferences("sharedPreferences", 0); + editor = settings.edit(); + toggleNotification = settings.getString("toggleNotification", null); + toggleTheme = settings.getString("toggleTheme", null); + new CheckNotification(toggleNotification, editor); + + + } + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/SettingsFragment/DataSettingsFragments.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/SettingsFragment/DataSettingsFragments.java new file mode 100755 index 0000000..ca0df08 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/SettingsFragment/DataSettingsFragments.java @@ -0,0 +1,10 @@ +package com.fast0n.ap.fragments.SettingsFragment; + +class DataSettingsFragments { + + public final String name; + + DataSettingsFragments(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/SettingsFragment/SettingsFragment.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/SettingsFragment/SettingsFragment.java new file mode 100755 index 0000000..0b5e012 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/SettingsFragment/SettingsFragment.java @@ -0,0 +1,75 @@ +package com.fast0n.ap.fragments.SettingsFragment; + +import android.content.Context; +import android.content.SharedPreferences; +import android.os.Bundle; +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ProgressBar; + +import com.fast0n.ap.R; +import com.fast0n.ap.java.CubeLoading; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class SettingsFragment extends Fragment { + + public SettingsFragment() { + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + final View view = inflater.inflate(R.layout.fragment_settings, container, false); + + final ProgressBar loading; + final Context context; + context = Objects.requireNonNull(getActivity()).getApplicationContext(); + final RecyclerView recyclerView; + final List infoList = new ArrayList<>(); + String color, theme; + SharedPreferences settings; + + + // java adresses + loading = view.findViewById(R.id.progressBar); + settings = context.getSharedPreferences("sharedPreferences", 0); + theme = settings.getString("toggleTheme", null); + new CubeLoading(context, loading, theme).showLoading(); + recyclerView = view.findViewById(R.id.recycler_view); + recyclerView.setHasFixedSize(true); + LinearLayoutManager llm = new LinearLayoutManager(context); + llm.setOrientation(LinearLayoutManager.VERTICAL); + recyclerView.setLayoutManager(llm); + + if (theme.equals("0")) + color = "#000"; + else + color = "#ffffff"; + + + String[] list = { + "" + getString(R.string.one_title) + "
" + getString(R.string.one_description) + "", + "" + getString(R.string.two_title) + "
" + getString(R.string.two_description) + "", + "" + getString(R.string.four_title) + "
" + getString(R.string.four_description) + "", + "" + getString(R.string.five_title) + "
"}; + + + for (String a : list) { + + infoList.add(new DataSettingsFragments(a)); + CustomAdapterSettings ca = new CustomAdapterSettings(context, infoList); + recyclerView.setAdapter(ca); + } + + + return view; + } + +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/SimFragments.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/SimFragments.java new file mode 100755 index 0000000..25d3d1d --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/SimFragments.java @@ -0,0 +1,280 @@ +package com.fast0n.ap.fragments; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.Uri; +import android.os.Bundle; +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.cardview.widget.CardView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.inputmethod.InputMethodManager; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ProgressBar; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.fast0n.ap.LoginActivity; +import com.fast0n.ap.R; +import com.fast0n.ap.java.CubeLoading; +import com.fast0n.ap.java.DialogError; +import com.google.zxing.integration.android.IntentIntegrator; +import com.google.zxing.integration.android.IntentResult; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.Objects; + +import es.dmoral.toasty.Toasty; + +public class SimFragments extends Fragment { + + public SimFragments() { + } + + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + + + final View view = inflater.inflate(R.layout.fragment_sim, container, false); + final ProgressBar loading; + final CardView cardView1, cardView2, cardView3; + final Button btn_activatesim, scan; + final EditText edt_iccid; + final Context context; + context = Objects.requireNonNull(getActivity()).getApplicationContext(); + SharedPreferences settings; + String theme; + SharedPreferences.Editor editor; + + // java adresses + loading = view.findViewById(R.id.progressBar); + settings = context.getSharedPreferences("sharedPreferences", 0); + theme = settings.getString("toggleTheme", null); + new CubeLoading(context, loading, theme).showLoading(); + btn_activatesim = view.findViewById(R.id.btn_activatesim); + edt_iccid = view.findViewById(R.id.edt_iccid); + cardView1 = view.findViewById(R.id.cardView1); + cardView2 = view.findViewById(R.id.cardView2); + cardView3 = view.findViewById(R.id.cardView3); + scan = view.findViewById(R.id.btn_scan); + + cardView1.setVisibility(View.GONE); + cardView2.setVisibility(View.GONE); + cardView3.setVisibility(View.GONE); + loading.setVisibility(View.VISIBLE); + + final Bundle extras = getActivity().getIntent().getExtras(); + assert extras != null; + final String token = extras.getString("token"); + + final String site_url = getString(R.string.site_url) + getString(R.string.sim); + String url = site_url + "?activation_sim=true&token=" + token; + + getObject(url, context, view); + + settings = context.getApplicationContext().getSharedPreferences("sharedPreferences", 0); + editor = settings.edit(); + editor.apply(); + + + scan.setOnClickListener(view1 -> { + + + IntentIntegrator integrator = new IntentIntegrator(getActivity()); + integrator.setDesiredBarcodeFormats(IntentIntegrator.CODE_128); + integrator.setPrompt(""); + integrator.setOrientationLocked(false); + integrator.setCameraId(0); + integrator.setBeepEnabled(false); + integrator.setBarcodeImageEnabled(false); + IntentIntegrator.forSupportFragment(SimFragments.this).initiateScan(); + }); + + btn_activatesim.setOnClickListener(v -> { + if (edt_iccid.getText().toString().length() == 19) + activateSim(site_url + "?iccid=" + edt_iccid.getText().toString() + "&token=" + token, context); + else + Toasty.error(context, getString(R.string.error_iccid), Toast.LENGTH_SHORT).show(); + }); + + edt_iccid.setOnClickListener(v -> { + InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + }); + + + return view; + } + + private void activateSim(String url, final Context context) { + + RequestQueue queue = Volley.newRequestQueue(context); + + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + String stringSim = json.getString("sim"); + + JSONObject json_sim = new JSONObject(stringSim); + String toast = json_sim.getString("0"); + String sim_state = json_sim.getString("1"); + + if (sim_state.equals("false")) + Toasty.warning(context, toast, Toast.LENGTH_LONG, true).show(); + + else { + Toasty.success(context, toast, Toast.LENGTH_LONG, true).show(); + Intent intent = new Intent(context, LoginActivity.class); + startActivity(intent); + + } + } catch (JSONException e) { + } + }, e -> { + }); + + // add it to the RequestQueue + queue.add(getRequest); + + } + + + private void getObject(String url, final Context context, View view) { + + final ProgressBar loading; + final CardView cardView1, cardView2, cardView3; + final TextView tvvalidation, tvorder_date, tvdate, tvtracking, tvshipping, tvorder_shipped, tvactivation, + tvtitle_activation, tvoffer; + final EditText edt_iccid; + final Button btn_activatesim, btn_scan; + + // java adresses + tvvalidation = view.findViewById(R.id.validation); + tvorder_date = view.findViewById(R.id.order_date); + tvdate = view.findViewById(R.id.date); + tvshipping = view.findViewById(R.id.shipping); + tvtracking = view.findViewById(R.id.tracking); + tvorder_shipped = view.findViewById(R.id.order_shipped); + tvactivation = view.findViewById(R.id.activation); + tvtitle_activation = view.findViewById(R.id.title_activation); + tvoffer = view.findViewById(R.id.offer); + edt_iccid = view.findViewById(R.id.edt_iccid); + btn_activatesim = view.findViewById(R.id.btn_activatesim); + btn_scan = view.findViewById(R.id.btn_scan); + + cardView1 = view.findViewById(R.id.cardView1); + cardView2 = view.findViewById(R.id.cardView2); + cardView3 = view.findViewById(R.id.cardView3); + + loading = view.findViewById(R.id.progressBar); + loading.setVisibility(View.VISIBLE); + + RequestQueue queue = Volley.newRequestQueue(context); + + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + String stringValidation = json.getString("validation"); + String stringShipping = json.getString("shipping"); + String stringSim = json.getString("sim"); + + JSONObject json_validation = new JSONObject(stringValidation); + String validation = json_validation.getString("0"); + String order_date = json_validation.getString("1"); + String date = json_validation.getString("2"); + + tvvalidation.setText(validation); + tvorder_date.setText(order_date); + tvdate.setText(date); + + JSONObject json_shipping = new JSONObject(stringShipping); + String shipping = json_shipping.getString("0"); + String order_shipped = json_shipping.getString("1"); + String tracking = json_shipping.getString("2"); + + + tvshipping.setText(shipping); + tvorder_shipped.setText(order_shipped); + tvtracking.setText(tracking); + + JSONObject json_sim = new JSONObject(stringSim); + String activation = json_sim.getString("0"); + String title_activation = json_sim.getString("1"); + String response_sim = json_sim.getString("2"); + String offer = json_sim.getString("3"); + + tvoffer.setText(offer); + tvactivation.setText(activation); + tvtitle_activation.setText(title_activation); + + + if (response_sim.equals("true")) { + tvtitle_activation.setTextColor(getResources().getColor(R.color.colorPrimary)); + edt_iccid.setVisibility(View.GONE); + btn_activatesim.setVisibility(View.GONE); + btn_scan.setVisibility(View.GONE); + } + + + try { + String tracking_url = json_shipping.getString("3"); + cardView3.setVisibility(View.VISIBLE); + cardView3.setOnClickListener(v -> { + Intent i = new Intent(Intent.ACTION_VIEW); + i.setData(Uri.parse(tracking_url)); + startActivity(i); + }); + } catch (Exception ignored) { + cardView3.setVisibility(View.GONE); + } + + + cardView1.setVisibility(View.VISIBLE); + cardView2.setVisibility(View.VISIBLE); + + loading.setVisibility(View.INVISIBLE); + + } catch (JSONException ignored) { + } + }, e -> new DialogError(this.getActivity(), String.valueOf(e)).alertbox()); + + // add it to the RequestQueue + queue.add(getRequest); + + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data); + + EditText edt_iccid = getView().findViewById(R.id.edt_iccid); + Button btn_activatesim = getView().findViewById(R.id.btn_activatesim); + + edt_iccid.setText(result.getContents()); + btn_activatesim.performClick(); + + + } + +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/CustomAdapterCustomization.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/CustomAdapterCustomization.java new file mode 100755 index 0000000..3587661 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/CustomAdapterCustomization.java @@ -0,0 +1,124 @@ +package com.fast0n.ap.fragments.VoicemailFragment; + + +import android.content.Context; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.CompoundButton; +import android.widget.Switch; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.fast0n.ap.R; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.List; + +import es.dmoral.toasty.Toasty; + +public class CustomAdapterCustomization extends RecyclerView.Adapter { + + private final Context context; + private final String token; + private final List optionsList; + + CustomAdapterCustomization(Context context, List optionsList, String token) { + this.context = context; + this.optionsList = optionsList; + this.token = token; + } + + @Override + public void onBindViewHolder(@NonNull final MyViewHolder holder, final int position) { + final DataCustomizationFragments c = optionsList.get(position); + holder.textView.setText(c.textView); + + + if (c.toggle.equals("false")) + holder.toggle.setChecked(false); + else + holder.toggle.setChecked(true); + + holder.toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + + final String site_url = context.getString(R.string.site_url) + context.getString(R.string.voicemail); + + if (!isChecked) { + String url = site_url + "?changevoicemailoptions=true&update=" + c.name + "&token=" + token + "&activate=0"; + request_options_services(url, holder.textView.getText() + " " + String.valueOf(isChecked).replace("false", "disattivato")); + } else if (isChecked) { + + String url = site_url + "?changevoicemailoptions=true&update=" + c.name + "&token=" + token + "&activate=1"; + request_options_services(url, holder.textView.getText() + " " + String.valueOf(isChecked).replace("true", "attivo")); + } + } + + private void request_options_services(String url, String labelOn) { + + RequestQueue queue = Volley.newRequestQueue(context); + + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + try { + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + String string_response = json.getString("0"); + + if (string_response.equals("true")) { + + Toasty.warning(context, labelOn, Toast.LENGTH_SHORT, true).show(); + } + + } catch (JSONException ignored) { + } + + }, error -> { + + }); + + queue.add(getRequest); + + } + + }); + + + } + + @Override + public int getItemCount() { + return optionsList.size(); + } + + @Override + public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_options_services, parent, false); + return new MyViewHolder(v); + } + + class MyViewHolder extends RecyclerView.ViewHolder { + + final TextView textView; + final Switch toggle; + + MyViewHolder(View view) { + super(view); + textView = view.findViewById(R.id.textView1); + toggle = view.findViewById(R.id.toggle); + + } + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/CustomAdapterNotification.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/CustomAdapterNotification.java new file mode 100755 index 0000000..4db8445 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/CustomAdapterNotification.java @@ -0,0 +1,116 @@ +package com.fast0n.ap.fragments.VoicemailFragment; + +import android.content.Context; +import androidx.recyclerview.widget.RecyclerView; +import android.text.Html; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageButton; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.fast0n.ap.R; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.List; + +import es.dmoral.toasty.Toasty; + +public class CustomAdapterNotification extends RecyclerView.Adapter { + + private final Context context; + private final String token; + private final List modelList; + + CustomAdapterNotification(Context context, List modelList, String token) { + this.context = context; + this.modelList = modelList; + this.token = token; + } + + @Override + public void onBindViewHolder(MyViewHolder holder, int position) { + DataNotificationFragments c = modelList.get(position); + holder.textView.setText(c.textView); + holder.textView1.setText(c.textView1); + holder.textView2.setText(c.textView2); + holder.textView3.setText(c.textView3); + + + holder.button.setOnClickListener(v -> { + final String site_url = context.getString(R.string.site_url) + context.getString(R.string.voicemail); + + String url = site_url + "?email=" + c.textView1 + "&action=delete&token=" + token; + + + RequestQueue queue = Volley.newRequestQueue(context); + + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + String string_json1 = json.getString("0"); + + + Toasty.success(context, Html.fromHtml(string_json1), Toast.LENGTH_LONG, + true).show(); + + int newPosition = holder.getAdapterPosition(); + modelList.remove(newPosition); + notifyItemRemoved(newPosition); + notifyItemRangeChanged(newPosition, modelList.size()); + + + } catch (JSONException ignored) { + } + + }, error -> { + + }); + + queue.add(getRequest); + }); + + + } + + @Override + public int getItemCount() { + return modelList.size(); + } + + @Override + public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_voicemail_notification, parent, false); + return new MyViewHolder(v); + } + + public class MyViewHolder extends RecyclerView.ViewHolder { + + final TextView textView; + final TextView textView1; + final TextView textView2; + final TextView textView3; + final ImageButton button; + + MyViewHolder(View view) { + super(view); + button = view.findViewById(R.id.button); + textView = view.findViewById(R.id.textView); + textView1 = view.findViewById(R.id.textView1); + textView2 = view.findViewById(R.id.textView2); + textView3 = view.findViewById(R.id.textView3); + } + } +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/CustomAdapterVoicemail.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/CustomAdapterVoicemail.java new file mode 100755 index 0000000..c8cc05c --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/CustomAdapterVoicemail.java @@ -0,0 +1,301 @@ +package com.fast0n.ap.fragments.VoicemailFragment; + +import android.content.ContentResolver; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.database.Cursor; +import android.media.AudioManager; +import android.media.MediaPlayer; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Environment; +import android.provider.ContactsContract; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; +import android.text.Html; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageButton; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.HurlStack; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.fast0n.ap.R; +import com.fast0n.ap.java.InputStreamVolleyRequest; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.File; +import java.io.FileOutputStream; +import java.util.List; + +import es.dmoral.toasty.Toasty; + +public class CustomAdapterVoicemail extends RecyclerView.Adapter { + + private final List conditionList; + private final Context context; + private MediaPlayer mediaPlayer; + + private boolean playPause; + private boolean initialStage = true; + + + CustomAdapterVoicemail(List conditionList, Context context) { + this.conditionList = conditionList; + this.context = context; + } + + @Override + public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { + DataVoicemailFragments c = conditionList.get(position); + final String site_url = context.getString(R.string.site_url) + context.getString(R.string.voicemail); + + + holder.textView.setText(getContactName(c.num_tell)); + holder.textView1.setText(Html.fromHtml(c.date)); + + if (c.date.equals("")) { + holder.button.setVisibility(View.INVISIBLE); + holder.button1.setVisibility(View.INVISIBLE); + } + + holder.button.setOnClickListener(v -> { + + String url = site_url + "?deleteaudio=true&idaudio=" + c.id + "&token=" + c.token; + + + RequestQueue queue = Volley.newRequestQueue(context); + queue.getCache().clear(); + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + String string_json1 = json.getString("1"); + + + Toasty.success(context, string_json1, Toast.LENGTH_LONG, + true).show(); + int newPosition = holder.getAdapterPosition(); + conditionList.remove(newPosition); + notifyItemRemoved(newPosition); + notifyItemRangeChanged(newPosition, conditionList.size()); + + } catch (JSONException ignored) { + } + + }, error -> { + + }); + + queue.add(getRequest); + }); + + + String requiredPermission = "android.permission.WRITE_EXTERNAL_STORAGE"; + int checkVal = context.checkCallingOrSelfPermission(requiredPermission); + + if (checkVal == PackageManager.PERMISSION_GRANTED) { + holder.button2.setVisibility(View.VISIBLE); + } + + + holder.button2.setOnClickListener(v -> { + holder.button2.setEnabled(false); + Toast.makeText(context, "Download in corso...", Toast.LENGTH_LONG).show(); + + + String mUrl = site_url + "?idaudio=" + c.id + "&token=" + c.token; + + + File file = new File(Environment.getExternalStorageDirectory() + File.separator + context.getString(R.string.app_name)); + + + if (!file.exists()) { + file.mkdir(); + } + + + InputStreamVolleyRequest request = new InputStreamVolleyRequest(Request.Method.GET, mUrl, + response -> { + try { + if (response != null) { + + + FileOutputStream outputStream; + outputStream = new FileOutputStream(file + File.separator + c.id + ".wav"); + outputStream.write(response); + outputStream.close(); + Toast.makeText(context, "Download completato", Toast.LENGTH_LONG).show(); + + holder.button2.setEnabled(true); + + + Intent share = new Intent(Intent.ACTION_SEND); + share.setType("audio/*"); + share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + share.putExtra(Intent.EXTRA_STREAM, + Uri.parse(file + File.separator + c.id + ".wav")); + context.startActivity(Intent.createChooser(share, "Share voicemail")); + } + } catch (Exception e) { + e.printStackTrace(); + } + }, error -> { + }, null); + RequestQueue mRequestQueue = Volley.newRequestQueue(context.getApplicationContext(), new HurlStack()); + mRequestQueue.add(request); + + + }); + + + holder.button1.setOnClickListener(new View.OnClickListener() { + + + @Override + public void onClick(View v) { + + + if (!playPause) { + holder.button1.setBackgroundResource(R.drawable.ic_pause); + + + if (initialStage) { + + new Player().execute(site_url + "?idaudio=" + c.id + "&token=" + c.token); + } else { + if (!mediaPlayer.isPlaying()) + mediaPlayer.start(); + } + + playPause = true; + + } else { + holder.button1.setBackgroundResource(R.drawable.ic_play); + + if (mediaPlayer.isPlaying()) { + mediaPlayer.pause(); + + } + + + playPause = false; + } + + } + + class Player extends AsyncTask { + @Override + protected Boolean doInBackground(String... strings) { + Boolean prepared; + + try { + mediaPlayer.setDataSource(strings[0]); + mediaPlayer.setOnCompletionListener(mediaPlayer -> { + initialStage = true; + playPause = false; + holder.button1.setBackgroundResource(R.drawable.ic_play); + mediaPlayer.stop(); + mediaPlayer.reset(); + }); + + mediaPlayer.prepare(); + prepared = true; + + } catch (Exception e) { + prepared = false; + } + + return prepared; + } + + + @Override + protected void onPostExecute(Boolean aBoolean) { + super.onPostExecute(aBoolean); + + + mediaPlayer.start(); + initialStage = false; + } + + } + + }); + + + } + + private String getContactName(String number) { + String name = ""; + Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number)); + + ContentResolver contentResolver = context.getContentResolver(); + try { + Cursor contactLookup = contentResolver.query(uri, null, null, null, null); + try { + if (contactLookup != null && contactLookup.getCount() > 0) { + contactLookup.moveToNext(); + name = contactLookup.getString(contactLookup.getColumnIndex(ContactsContract.Data.DISPLAY_NAME)); + } else { + name = number; + } + } finally { + if (contactLookup != null) { + contactLookup.close(); + } + } + } catch (Exception ignored) { + name = number; + } + + return name; + } + + + @Override + public int getItemCount() { + return conditionList.size(); + } + + @NonNull + @Override + public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_voicemail, parent, false); + return new MyViewHolder(v); + } + + class MyViewHolder extends RecyclerView.ViewHolder { + + final TextView textView; + final TextView textView1; + final ImageButton button; + final ImageButton button1, button2; + + + MyViewHolder(View view) { + super(view); + textView = view.findViewById(R.id.textView); + textView1 = view.findViewById(R.id.textView1); + button1 = view.findViewById(R.id.button1); + button2 = view.findViewById(R.id.button2); + button = view.findViewById(R.id.button); + + mediaPlayer = new MediaPlayer(); + mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); + + } + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/DataCustomizationFragments.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/DataCustomizationFragments.java new file mode 100755 index 0000000..39fee87 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/DataCustomizationFragments.java @@ -0,0 +1,14 @@ +package com.fast0n.ap.fragments.VoicemailFragment; + +class DataCustomizationFragments { + + public final String textView; + public final String toggle; + public final String name; + + DataCustomizationFragments(String textView, String toggle, String name) { + this.textView = textView; + this.toggle = toggle; + this.name = name; + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/DataNotificationFragments.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/DataNotificationFragments.java new file mode 100755 index 0000000..149c624 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/DataNotificationFragments.java @@ -0,0 +1,18 @@ +package com.fast0n.ap.fragments.VoicemailFragment; + +class DataNotificationFragments { + + public final String textView; + public final String textView1; + public final String textView2; + public final String textView3; + + + DataNotificationFragments(String textView, String textView1, String textView2, String textView3) { + this.textView = textView; + this.textView1 = textView1; + this.textView2 = textView2; + this.textView3 = textView3; + + } +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/DataVoicemailFragments.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/DataVoicemailFragments.java new file mode 100755 index 0000000..d15866f --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/DataVoicemailFragments.java @@ -0,0 +1,19 @@ +package com.fast0n.ap.fragments.VoicemailFragment; + +class DataVoicemailFragments { + + + public final String num_tell; + public final String date; + public final String id; + public final String token; + + + DataVoicemailFragments(String num_tell, String date, String id, String token) { + this.num_tell = num_tell; + this.date = date; + this.id = id; + this.token = token; + + } +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/VoicemailFragment.java b/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/VoicemailFragment.java new file mode 100755 index 0000000..23ba985 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/fragments/VoicemailFragment/VoicemailFragment.java @@ -0,0 +1,303 @@ +package com.fast0n.ap.fragments.VoicemailFragment; + + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import androidx.fragment.app.Fragment; +import androidx.cardview.widget.CardView; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.ProgressBar; +import android.widget.Spinner; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.JsonObjectRequest; +import com.android.volley.toolbox.Volley; +import com.fast0n.ap.LoginActivity; +import com.fast0n.ap.R; +import com.fast0n.ap.java.CubeLoading; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import es.dmoral.toasty.Toasty; + +public class VoicemailFragment extends Fragment { + + + public VoicemailFragment() { + } + + private boolean isEmail(String email) { + String expression = "^[\\w.]+@([\\w]+\\.)+[A-Z]{2,7}$"; + Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); + Matcher matcher = pattern.matcher(email); + return matcher.matches(); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + final View view = inflater.inflate(R.layout.fragment_voicemail, container, false); + + final ProgressBar loading; + final Context context; + context = Objects.requireNonNull(getActivity()).getApplicationContext(); + CardView cardView1; + SharedPreferences settings; + String theme; + + // java adresses + loading = view.findViewById(R.id.progressBar); + settings = context.getSharedPreferences("sharedPreferences", 0); + theme = settings.getString("toggleTheme", null); + new CubeLoading(context, loading, theme).showLoading(); + cardView1 = view.findViewById(R.id.cardView1); + cardView1.setVisibility(View.INVISIBLE); + loading.setVisibility(View.VISIBLE); + + final Bundle extras = getActivity().getIntent().getExtras(); + assert extras != null; + final String token = extras.getString("token"); + + final String site_url = getString(R.string.site_url) + getString(R.string.voicemail); + String url = site_url + "?voicemail=true&token=" + token; + + + getObject(url, context, view, token); + + return view; + } + + private void getObject(String url, Context context, View view, String token) { + + final ProgressBar loading; + final RecyclerView recyclerView, recyclerView1, recyclerView2, recyclerView3; + final List infomail = new ArrayList<>(); + final List infoList = new ArrayList<>(); + final List infoList1 = new ArrayList<>(); + CardView cardView1; + EditText editText; + Spinner spinner; + ImageButton button; + + TextView textvoicemail, customization, notification; + + // java adresses + button = view.findViewById(R.id.button); + cardView1 = view.findViewById(R.id.cardView1); + editText = view.findViewById(R.id.editText); + textvoicemail = view.findViewById(R.id.textView); + customization = view.findViewById(R.id.textView1); + notification = view.findViewById(R.id.textView2); + recyclerView = view.findViewById(R.id.recycler_view); + recyclerView1 = view.findViewById(R.id.recycler_view1); + recyclerView2 = view.findViewById(R.id.recycler_view2); + recyclerView3 = view.findViewById(R.id.recycler_view3); + spinner = view.findViewById(R.id.spinner); + + + String[] list = {"Notifica inviata via email", "File audio inviato in allegato"}; + + + button.setOnClickListener(v -> { + if (isEmail(editText.getText().toString())) { + String montant = spinner.getSelectedItem().toString(); + + RequestQueue queue = Volley.newRequestQueue(context); + final String site_url = getString(R.string.site_url) + getString(R.string.voicemail); + + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, site_url + "?email=" + editText.getText().toString() + "&action=add&type=" + montant.replace("Notifica inviata via email", "report").replace("File audio inviato in allegato", "attachment") + "&token=" + token, null, + response -> { + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + + JSONObject json = new JSONObject(iliad); + + } catch (JSONException ignored) { + } + + }, error -> { + + }); + + queue.add(getRequest); + + } else { + Toasty.warning(context, getString(R.string.email_wrong), Toast.LENGTH_LONG, + true).show(); + } + }); + + ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<>(context, R.layout.spinner_item, list); + spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner_item); + spinner.setAdapter(spinnerArrayAdapter); + + loading = view.findViewById(R.id.progressBar); + + LinearLayoutManager llm = new LinearLayoutManager(context); + llm.setOrientation(LinearLayoutManager.VERTICAL); + recyclerView.setHasFixedSize(true); + recyclerView.setLayoutManager(llm); + + LinearLayoutManager llm1 = new LinearLayoutManager(context); + llm1.setOrientation(LinearLayoutManager.VERTICAL); + recyclerView1.setHasFixedSize(true); + recyclerView1.setLayoutManager(llm1); + + LinearLayoutManager llm2 = new LinearLayoutManager(context); + llm2.setOrientation(LinearLayoutManager.VERTICAL); + recyclerView2.setHasFixedSize(true); + recyclerView2.setLayoutManager(llm2); + + LinearLayoutManager llm3 = new LinearLayoutManager(context); + llm3.setOrientation(LinearLayoutManager.VERTICAL); + recyclerView3.setHasFixedSize(true); + recyclerView3.setLayoutManager(llm3); + + + RequestQueue queue = Volley.newRequestQueue(context); + + JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, + response -> { + try { + + JSONObject json_raw = new JSONObject(response.toString()); + String iliad = json_raw.getString("iliad"); + JSONObject json_iliad = new JSONObject(iliad); + + // message + + String message = json_iliad.getString("message"); + JSONObject json_message = new JSONObject(message); + + String string1 = json_message.getString("0"); + JSONObject json_strings1 = new JSONObject(string1); + String stringCredit = json_strings1.getString("0"); + + textvoicemail.setText(stringCredit); + + for (int i = 1; i < json_message.length(); i++) { + + String string = json_message.getString(String.valueOf(i)); + JSONObject json_strings = new JSONObject(string); + + String a = json_strings.getString("0"); + try { + String b = json_strings.getString("1"); + String c = json_strings.getString("2"); + infomail.add(new DataVoicemailFragments(a, b, c, token)); + } catch (Exception ignored) { + infomail.add(new DataVoicemailFragments(a, "", "0", token)); + } + + CustomAdapterVoicemail ca = new CustomAdapterVoicemail(infomail, context); + recyclerView.setAdapter(ca); + + } + + textvoicemail.setVisibility(View.VISIBLE); + + // options + + String options = json_iliad.getString("options"); + JSONObject json_options = new JSONObject(options); + + + string1 = json_options.getString("0"); + json_strings1 = new JSONObject(string1); + stringCredit = json_strings1.getString("0"); + customization.setText(stringCredit); + + for (int i = 1; i < json_options.length(); i++) { + + String string = json_options.getString(String.valueOf(i)); + JSONObject json_strings = new JSONObject(string); + + String a = json_strings.getString("0"); + String b = json_strings.getString("2"); + String c = json_strings.getString("3"); + infoList.add(new DataCustomizationFragments(a, b, c)); + customization.setVisibility(View.VISIBLE); + + } + + CustomAdapterCustomization ca = new CustomAdapterCustomization(context, infoList, token); + recyclerView1.setAdapter(ca); + notification.setVisibility(View.VISIBLE); + + // report + + try { + String report = json_iliad.getString("report"); + JSONObject json_report = new JSONObject(report); + + string1 = json_report.getString("0"); + json_strings1 = new JSONObject(string1); + stringCredit = json_strings1.getString("0"); + notification.setText(stringCredit); + + + for (int i = 1; i < json_report.length(); i++) { + + String string = json_report.getString(String.valueOf(i)); + JSONObject json_strings = new JSONObject(string); + + + String a = json_strings.getString("0"); + String d = json_strings.getString("3"); + + try { + String b = json_strings.getString("1"); + String c = json_strings.getString("2"); + infoList1.add(new DataNotificationFragments(a, b, c, d)); + } catch (Exception ignored) { + infoList1.add(new DataNotificationFragments(a, "", "0", d)); + } + + } + + CustomAdapterNotification ca1 = new CustomAdapterNotification(context, infoList1, token); + recyclerView2.setAdapter(ca1); + loading.setVisibility(View.INVISIBLE); + cardView1.setVisibility(View.VISIBLE); + + + } catch (Exception ignored) { + } + + + } catch (JSONException e) { + System.out.println(e); + startActivity(new Intent(context, LoginActivity.class)); + } + + }, error -> { + + }); + + queue.add(getRequest); + + + } + +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/java/CubeLoading.java b/iliad/app/src/main/java/com/fast0n/ap/java/CubeLoading.java new file mode 100755 index 0000000..03f25d0 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/java/CubeLoading.java @@ -0,0 +1,31 @@ +package com.fast0n.ap.java; + +import android.content.Context; +import android.graphics.Color; +import android.widget.ProgressBar; + +import com.github.ybq.android.spinkit.style.CubeGrid; + + +public class CubeLoading { + Context context; + private ProgressBar loadingError; + private String themeError; + + public CubeLoading(Context con, ProgressBar loading, String theme) { + this.context = con; + this.loadingError = loading; + this.themeError = theme; + } + + public void showLoading() { + + CubeGrid cubeGrid = new CubeGrid(); + loadingError.setIndeterminateDrawable(cubeGrid); + if (themeError.equals("0")) + cubeGrid.setColor(Color.parseColor("#c00000")); + else + cubeGrid.setColor(Color.parseColor("#ffffff")); + + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/java/DialogError.java b/iliad/app/src/main/java/com/fast0n/ap/java/DialogError.java new file mode 100755 index 0000000..eb4f08b --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/java/DialogError.java @@ -0,0 +1,69 @@ +package com.fast0n.ap.java; + +import android.content.Context; +import android.content.Intent; +import androidx.appcompat.app.AlertDialog; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.Response; +import com.android.volley.VolleyError; +import com.android.volley.toolbox.StringRequest; +import com.android.volley.toolbox.Volley; +import com.fast0n.ap.LoginActivity; +import com.fast0n.ap.R; + + +public class DialogError { + private final String token = GenerateToken.randomString(10); + Context context; + String descriptionError; + + public DialogError(Context con, String s) { + this.context = con; + this.descriptionError = s; + } + + public void alertbox() { + AlertDialog.Builder builder = new AlertDialog.Builder(context); + builder.setTitle(R.string.alertbox_title) + .setMessage(R.string.alertbox_message) + .setCancelable(false) + .setPositiveButton(R.string.alertbox_posbtn, (dialog, id) -> { + //Go home + context.startActivity(new Intent(context, LoginActivity.class)); + }) + .setNegativeButton(R.string.alertbox_negbtn, (dialog, id) -> { + + // Instantiate the RequestQueue. + RequestQueue queue = Volley.newRequestQueue(context); + + final String site_url = context.getString(R.string.site_url) + context.getString(R.string.support); + + + String url = "?title=" + "Segnalazione App Iliad (ID: " + token.toUpperCase() + + ")&message=" + + descriptionError + + "&screen=" + + context; + + StringRequest stringRequest = new StringRequest(Request.Method.GET, site_url + url, + response -> { + // Display the first 500 characters of the response string. + context.startActivity(new Intent(context, LoginActivity.class)); + + }, new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + //textView.setText("That didn't work!"); + } + }); + + queue.add(stringRequest); + + + }); + AlertDialog alert = builder.create(); + alert.show(); + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/java/GenerateToken.java b/iliad/app/src/main/java/com/fast0n/ap/java/GenerateToken.java new file mode 100755 index 0000000..36c22be --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/java/GenerateToken.java @@ -0,0 +1,20 @@ +package com.fast0n.ap.java; + +import java.util.Random; + +public class GenerateToken { + + private static final String DATA = "0123456789abcdefghijklmnopqrstuvwxyz"; + private static final Random RANDOM = new Random(); + + public static String randomString(int len) { + StringBuilder sb = new StringBuilder(len); + + for (int i = 0; i < len; i++) { + sb.append(DATA.charAt(RANDOM.nextInt(DATA.length()))); + } + + return sb.toString(); + } + +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/java/InputStreamVolleyRequest.java b/iliad/app/src/main/java/com/fast0n/ap/java/InputStreamVolleyRequest.java new file mode 100755 index 0000000..ef3125a --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/java/InputStreamVolleyRequest.java @@ -0,0 +1,36 @@ +package com.fast0n.ap.java; + +import com.android.volley.NetworkResponse; +import com.android.volley.Request; +import com.android.volley.Response; +import com.android.volley.toolbox.HttpHeaderParser; + +import java.util.Map; + +public class InputStreamVolleyRequest extends Request { + private final Response.Listener listener; + private Map params; + + public InputStreamVolleyRequest(int method, String url, Response.Listener listener, Response.ErrorListener errorListener, Map params) { + super(method, url, errorListener); + setShouldCache(false); + this.listener = listener; + this.params = params; + } + + @Override + protected Map getParams() { + params.put("Content-Type", "audio/wav"); + return params; + } + + @Override + protected Response parseNetworkResponse(NetworkResponse response) { + return Response.success(response.data, HttpHeaderParser.parseCacheHeaders(response)); + } + + @Override + protected void deliverResponse(byte[] response) { + listener.onResponse(response); + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/java/MyAppGlideModule.java b/iliad/app/src/main/java/com/fast0n/ap/java/MyAppGlideModule.java new file mode 100755 index 0000000..074d5f9 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/java/MyAppGlideModule.java @@ -0,0 +1,8 @@ +package com.fast0n.ap.java; + +import com.bumptech.glide.annotation.GlideModule; +import com.bumptech.glide.module.AppGlideModule; + +@GlideModule +public final class MyAppGlideModule extends AppGlideModule { +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/java/RecyclerItemListener.java b/iliad/app/src/main/java/com/fast0n/ap/java/RecyclerItemListener.java new file mode 100755 index 0000000..ed26efd --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/java/RecyclerItemListener.java @@ -0,0 +1,55 @@ +package com.fast0n.ap.java; + +import android.content.Context; +import androidx.recyclerview.widget.RecyclerView; +import android.view.GestureDetector; +import android.view.MotionEvent; +import android.view.View; + +public class RecyclerItemListener implements RecyclerView.OnItemTouchListener { + + private final GestureDetector gd; + + public RecyclerItemListener(Context ctx, final RecyclerView recycler_view, final RecyclerTouchListener listener) { + gd = new GestureDetector(ctx, new GestureDetector.SimpleOnGestureListener() { + @Override + public void onLongPress(MotionEvent e) { + // We find the view + View v = recycler_view.findChildViewUnder(e.getX(), e.getY()); + // Notify the even + listener.onLongClickItem(v, recycler_view.getChildAdapterPosition(v)); + } + + @Override + public boolean onSingleTapUp(MotionEvent e) { + View v = recycler_view.findChildViewUnder(e.getX(), e.getY()); + // Notify the even + listener.onClickItem(v, recycler_view.getChildAdapterPosition(v)); + return true; + } + }); + + } + + @Override + public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { + View child = rv.findChildViewUnder(e.getX(), e.getY()); + return (child != null && gd.onTouchEvent(e)); + } + + @Override + public void onTouchEvent(RecyclerView recycler_view, MotionEvent e) { + + } + + @Override + public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) { + + } + + public interface RecyclerTouchListener { + void onClickItem(View v, int position); + + void onLongClickItem(View v, int position); + } +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/java/SnackbarMaterial.java b/iliad/app/src/main/java/com/fast0n/ap/java/SnackbarMaterial.java new file mode 100755 index 0000000..830cf82 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/java/SnackbarMaterial.java @@ -0,0 +1,39 @@ +package com.fast0n.ap.java; + +import android.content.Context; +import android.content.SharedPreferences; +import com.google.android.material.snackbar.Snackbar; +import androidx.core.view.ViewCompat; +import android.view.ViewGroup; + +import com.fast0n.ap.R; + + +public class SnackbarMaterial { + public static void configSnackbar(Context context, Snackbar snack) { + addMargins(snack); + setRoundBordersBg(context, snack); + ViewCompat.setElevation(snack.getView(), 6f); + } + + private static void addMargins(Snackbar snack) { + ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) snack.getView().getLayoutParams(); + params.setMargins(12, 12, 12, 12); + snack.getView().setLayoutParams(params); + } + + private static void setRoundBordersBg(Context context, Snackbar snackbar) { + SharedPreferences settings; + String theme; + + settings = context.getSharedPreferences("sharedPreferences", 0); + theme = settings.getString("toggleTheme", null); + if (theme.equals("0")) + snackbar.getView().setBackground(context.getDrawable(R.drawable.bg_snackbar)); + else + snackbar.getView().setBackground(context.getDrawable(R.drawable.bg_snackbar_dark)); + + } + + +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/java/myDbAdapter.java b/iliad/app/src/main/java/com/fast0n/ap/java/myDbAdapter.java new file mode 100755 index 0000000..4dec291 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/java/myDbAdapter.java @@ -0,0 +1,153 @@ +package com.fast0n.ap.java; + +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; + + +public class myDbAdapter { + private final myDbHelper myhelper; + + public myDbAdapter(Context context) { + myhelper = new myDbHelper(context); + } + + public void insertData(String userID, String pass, String name, String phone) { + SQLiteDatabase dbb = myhelper.getWritableDatabase(); + ContentValues contentValues = new ContentValues(); + contentValues.put(myDbHelper.userID, userID); + contentValues.put(myDbHelper.MyPASSWORD, pass); + contentValues.put(myDbHelper.MyName, name); + contentValues.put(myDbHelper.MyPhone, phone); + + dbb.insert(myDbHelper.TABLE_NAME, null, contentValues); + } + + public String getAllData() { + SQLiteDatabase db = myhelper.getWritableDatabase(); + String[] columns = {myDbHelper.UID, myDbHelper.userID, myDbHelper.MyPASSWORD, myDbHelper.MyPhone}; + Cursor cursor = db.query(myDbHelper.TABLE_NAME, columns, null, null, null, null, null); + StringBuilder buffer = new StringBuilder(); + while (cursor.moveToNext()) { + String userID = cursor.getString(cursor.getColumnIndex(myDbHelper.userID)); + String password = cursor.getString(cursor.getColumnIndex(myDbHelper.MyPASSWORD)); + String phone = cursor.getString(cursor.getColumnIndex(myDbHelper.MyPhone)); + + buffer.append(userID).append("&").append(password).append("&").append(phone).append(" \n"); + } + cursor.close(); + return buffer.toString(); + } + + + public String getUserID() { + SQLiteDatabase db = myhelper.getWritableDatabase(); + String[] columns = {myDbHelper.UID, myDbHelper.userID, myDbHelper.MyPASSWORD, myDbHelper.MyName, myDbHelper.MyPhone}; + Cursor cursor = db.query(myDbHelper.TABLE_NAME, columns, null, null, null, null, null); + StringBuilder buffer = new StringBuilder(); + while (cursor.moveToNext()) { + String name = cursor.getString(cursor.getColumnIndex(myDbHelper.userID)); + buffer.append(name).append("\n"); + } + cursor.close(); + return buffer.toString(); + } + + + public String getPassword() { + SQLiteDatabase db = myhelper.getWritableDatabase(); + String[] columns = {myDbHelper.UID, myDbHelper.userID, myDbHelper.MyPASSWORD, myDbHelper.MyName, myDbHelper.MyPhone}; + Cursor cursor = db.query(myDbHelper.TABLE_NAME, columns, null, null, null, null, null); + StringBuilder buffer = new StringBuilder(); + while (cursor.moveToNext()) { + String password = cursor.getString(cursor.getColumnIndex(myDbHelper.MyPASSWORD)); + buffer.append(password); + } + cursor.close(); + return buffer.toString(); + } + + + public String getName() { + SQLiteDatabase db = myhelper.getWritableDatabase(); + String[] columns = {myDbHelper.UID, myDbHelper.userID, myDbHelper.MyPASSWORD, myDbHelper.MyName, myDbHelper.MyPhone}; + Cursor cursor = db.query(myDbHelper.TABLE_NAME, columns, null, null, null, null, null); + StringBuilder buffer = new StringBuilder(); + while (cursor.moveToNext()) { + String name = cursor.getString(cursor.getColumnIndex(myDbHelper.MyName)); + buffer.append(name).append("\n"); + } + cursor.close(); + return buffer.toString(); + } + + + public String getPhoneNumber() { + SQLiteDatabase db = myhelper.getWritableDatabase(); + String[] columns = {myDbHelper.UID, myDbHelper.userID, myDbHelper.MyPASSWORD, myDbHelper.MyName, myDbHelper.MyPhone}; + Cursor cursor = db.query(myDbHelper.TABLE_NAME, columns, null, null, null, null, null); + StringBuilder buffer = new StringBuilder(); + while (cursor.moveToNext()) { + String name = cursor.getString(cursor.getColumnIndex(myDbHelper.MyPhone)); + buffer.append(name).append("\n"); + } + cursor.close(); + return buffer.toString(); + } + + + public void reset() { + SQLiteDatabase db = myhelper.getWritableDatabase(); + String clearDBQuery = "DELETE FROM " + myDbHelper.TABLE_NAME; + db.execSQL(clearDBQuery); + } + + public void delete(String uname) { + SQLiteDatabase db = myhelper.getWritableDatabase(); + String[] whereArgs = {uname}; + + db.delete(myDbHelper.TABLE_NAME, myDbHelper.userID + " = ?", whereArgs); + } + + public void updatePassword(String oldName, String newName) { + SQLiteDatabase db = myhelper.getWritableDatabase(); + ContentValues contentValues = new ContentValues(); + contentValues.put(myDbHelper.MyPASSWORD, newName); + String[] whereArgs = {oldName}; + db.update(myDbHelper.TABLE_NAME, contentValues, myDbHelper.MyPASSWORD + " = ?", whereArgs); + } + + static class myDbHelper extends SQLiteOpenHelper { + private static final String DATABASE_NAME = "myDatabase"; + private static final String TABLE_NAME = "myTable"; + private static final int DATABASE_Version = 1; + private static final String UID = "_id"; + private static final String userID = "userID"; + private static final String MyPASSWORD = "Password"; + private static final String MyName = "Name"; + private static final String MyPhone = "Phone"; + private static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + + " (" + UID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + userID + " VARCHAR(255) ," + MyPASSWORD + " VARCHAR(225) ," + MyName + " VARCHAR(225) ," + MyPhone + " VARCHAR(225));"; + private static final String DROP_TABLE = "DROP TABLE IF EXISTS " + TABLE_NAME; + private final Context context; + + myDbHelper(Context context) { + super(context, DATABASE_NAME, null, DATABASE_Version); + this.context = context; + } + + public void onCreate(SQLiteDatabase db) { + try { + db.execSQL(CREATE_TABLE); + } catch (Exception ignored) { + } + } + + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + + } + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/notifications/CheckNotification.java b/iliad/app/src/main/java/com/fast0n/ap/notifications/CheckNotification.java new file mode 100755 index 0000000..09b2d3e --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/notifications/CheckNotification.java @@ -0,0 +1,23 @@ +package com.fast0n.ap.notifications; + +import android.content.SharedPreferences; + +import com.google.firebase.messaging.FirebaseMessaging; + +public class CheckNotification { + public CheckNotification(String toggleNotification, SharedPreferences.Editor editor) { + + try { + if (toggleNotification.equals("0")) + FirebaseMessaging.getInstance().subscribeToTopic("notification"); + else + FirebaseMessaging.getInstance().unsubscribeFromTopic("notification"); + } catch (Exception ignored) { + FirebaseMessaging.getInstance().subscribeToTopic("notification"); + editor.putString("toggleNotification", "0"); + editor.apply(); + + } + + } +} diff --git a/iliad/app/src/main/java/com/fast0n/ap/notifications/MyFirebaseInstanceIDService.java b/iliad/app/src/main/java/com/fast0n/ap/notifications/MyFirebaseInstanceIDService.java new file mode 100755 index 0000000..c5e728e --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/notifications/MyFirebaseInstanceIDService.java @@ -0,0 +1,19 @@ +package com.fast0n.ap.notifications; + +import com.google.firebase.iid.FirebaseInstanceId; +import com.google.firebase.iid.FirebaseInstanceIdService; + +public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService { + + @Override + public void onTokenRefresh() { + super.onTokenRefresh(); + + String refreshedToken = FirebaseInstanceId.getInstance().getToken(); + sendRegistrationToServer(refreshedToken); + } + + private void sendRegistrationToServer(String token) { + // Add custom implementation, as needed. + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/notifications/MyFirebaseMessagingService.java b/iliad/app/src/main/java/com/fast0n/ap/notifications/MyFirebaseMessagingService.java new file mode 100755 index 0000000..94c8d6d --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/notifications/MyFirebaseMessagingService.java @@ -0,0 +1,91 @@ +package com.fast0n.ap.notifications; + +import android.app.Notification; +import android.app.NotificationChannel; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; +import android.graphics.BitmapFactory; +import android.graphics.Color; +import android.media.RingtoneManager; +import android.os.Build; +import android.os.Bundle; +import androidx.core.app.NotificationCompat; + +import com.fast0n.ap.R; +import com.google.firebase.messaging.FirebaseMessagingService; +import com.google.firebase.messaging.RemoteMessage; + +import java.util.Map; + +public class MyFirebaseMessagingService extends FirebaseMessagingService { + public static final String FCM_PARAM = "picture"; + private static final String CHANNEL_NAME = "FCM"; + private static final String CHANNEL_DESC = "Firebase Cloud Messaging"; + private int numMessages = 0; + + @Override + public void onMessageReceived(RemoteMessage remoteMessage) { + super.onMessageReceived(remoteMessage); + RemoteMessage.Notification notification = remoteMessage.getNotification(); + Map data = remoteMessage.getData(); + sendNotification(notification, data); + + } + + private void sendNotification(RemoteMessage.Notification notification, Map data) { + Bundle bundle = new Bundle(); + String url_link = data.get("url_link"); + bundle.putString("url_link", String.valueOf(url_link)); + + String click_action = notification.getClickAction(); + Intent intent = new Intent(click_action); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); + intent.putExtras(bundle); + makeNotification(intent, notification); + + } + + private void makeNotification(Intent intent, RemoteMessage.Notification notification) { + PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, + PendingIntent.FLAG_ONE_SHOT); + + NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, getString(R.string.notification_channel_id)) + .setContentTitle(notification.getTitle()) + .setAutoCancel(true) + .setStyle(new NotificationCompat.BigTextStyle() + .bigText(notification.getBody())) + .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) + .setContentIntent(pendingIntent) + .setContentInfo("Hello") + .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher)) + .setLights(Color.RED, 1000, 300) + .setDefaults(Notification.DEFAULT_VIBRATE) + .setNumber(++numMessages) + .setSmallIcon(R.drawable.ic_notification); + + + NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + NotificationChannel channel = new NotificationChannel( + getString(R.string.notification_channel_id), CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT + ); + channel.setDescription(CHANNEL_DESC); + channel.setShowBadge(true); + channel.canShowBadge(); + channel.enableLights(true); + channel.setLightColor(Color.RED); + channel.enableVibration(true); + channel.setVibrationPattern(new long[]{100, 200, 300, 400, 500}); + + assert notificationManager != null; + notificationManager.createNotificationChannel(channel); + } + + assert notificationManager != null; + notificationManager.notify(0, notificationBuilder.build()); + + } +} \ No newline at end of file diff --git a/iliad/app/src/main/java/com/fast0n/ap/notifications/NotificationActivity.java b/iliad/app/src/main/java/com/fast0n/ap/notifications/NotificationActivity.java new file mode 100755 index 0000000..654d9f8 --- /dev/null +++ b/iliad/app/src/main/java/com/fast0n/ap/notifications/NotificationActivity.java @@ -0,0 +1,45 @@ +package com.fast0n.ap.notifications; + +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.os.Handler; +import androidx.appcompat.app.AppCompatActivity; + +import com.fast0n.ap.LoginActivity; +import com.fast0n.ap.R; + +public class NotificationActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_notification); + + Bundle extras = getIntent().getExtras(); + assert extras != null; + String url_link = extras.getString("url_link"); + + + if (url_link != null) { + + + Handler handler = new Handler(); + handler.postDelayed(() -> { + + Intent i = new Intent(Intent.ACTION_VIEW); + i.setData(Uri.parse(url_link)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + startActivity(i); + + + }, 500); + + startActivity(new Intent(NotificationActivity.this, LoginActivity.class)); + + + } else { + startActivity(new Intent(this, LoginActivity.class)); + + } + } +} diff --git a/iliad/app/src/main/res/drawable-hdpi/ic_stat_name.png b/iliad/app/src/main/res/drawable-hdpi/ic_stat_name.png new file mode 100755 index 0000000..0bb7560 Binary files /dev/null and b/iliad/app/src/main/res/drawable-hdpi/ic_stat_name.png differ diff --git a/iliad/app/src/main/res/drawable-mdpi/ic_stat_name.png b/iliad/app/src/main/res/drawable-mdpi/ic_stat_name.png new file mode 100755 index 0000000..4bbf221 Binary files /dev/null and b/iliad/app/src/main/res/drawable-mdpi/ic_stat_name.png differ diff --git a/iliad/app/src/main/res/drawable-nodpi/widget_preview.png b/iliad/app/src/main/res/drawable-nodpi/widget_preview.png new file mode 100755 index 0000000..ac5eb01 Binary files /dev/null and b/iliad/app/src/main/res/drawable-nodpi/widget_preview.png differ diff --git a/iliad/app/src/main/res/drawable-xhdpi/ic_stat_name.png b/iliad/app/src/main/res/drawable-xhdpi/ic_stat_name.png new file mode 100755 index 0000000..66e09fe Binary files /dev/null and b/iliad/app/src/main/res/drawable-xhdpi/ic_stat_name.png differ diff --git a/iliad/app/src/main/res/drawable-xxhdpi/ic_stat_name.png b/iliad/app/src/main/res/drawable-xxhdpi/ic_stat_name.png new file mode 100755 index 0000000..6df64b9 Binary files /dev/null and b/iliad/app/src/main/res/drawable-xxhdpi/ic_stat_name.png differ diff --git a/iliad/app/src/main/res/drawable/background_widget.xml b/iliad/app/src/main/res/drawable/background_widget.xml new file mode 100755 index 0000000..a5c1179 --- /dev/null +++ b/iliad/app/src/main/res/drawable/background_widget.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/drawable/bg_snackbar.xml b/iliad/app/src/main/res/drawable/bg_snackbar.xml new file mode 100755 index 0000000..b08d6d4 --- /dev/null +++ b/iliad/app/src/main/res/drawable/bg_snackbar.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/drawable/bg_snackbar_dark.xml b/iliad/app/src/main/res/drawable/bg_snackbar_dark.xml new file mode 100755 index 0000000..71b83a3 --- /dev/null +++ b/iliad/app/src/main/res/drawable/bg_snackbar_dark.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/drawable/button_round_red.xml b/iliad/app/src/main/res/drawable/button_round_red.xml new file mode 100755 index 0000000..7fedd57 --- /dev/null +++ b/iliad/app/src/main/res/drawable/button_round_red.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/drawable/button_round_white.xml b/iliad/app/src/main/res/drawable/button_round_white.xml new file mode 100755 index 0000000..4f39abf --- /dev/null +++ b/iliad/app/src/main/res/drawable/button_round_white.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/drawable/down_arrow.xml b/iliad/app/src/main/res/drawable/down_arrow.xml new file mode 100755 index 0000000..974b5ce --- /dev/null +++ b/iliad/app/src/main/res/drawable/down_arrow.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_account_circle.xml b/iliad/app/src/main/res/drawable/ic_account_circle.xml new file mode 100755 index 0000000..ea06c00 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_account_circle.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_add.xml b/iliad/app/src/main/res/drawable/ic_add.xml new file mode 100755 index 0000000..56c3718 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_add.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_conditions.xml b/iliad/app/src/main/res/drawable/ic_conditions.xml new file mode 100755 index 0000000..5fc5f88 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_conditions.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_credit.xml b/iliad/app/src/main/res/drawable/ic_credit.xml new file mode 100755 index 0000000..407af12 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_credit.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/drawable/ic_credit_card.xml b/iliad/app/src/main/res/drawable/ic_credit_card.xml new file mode 100755 index 0000000..b244230 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_credit_card.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_delete.xml b/iliad/app/src/main/res/drawable/ic_delete.xml new file mode 100755 index 0000000..b1fc130 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_delete.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_documents.xml b/iliad/app/src/main/res/drawable/ic_documents.xml new file mode 100755 index 0000000..bfd30b7 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_documents.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_github.xml b/iliad/app/src/main/res/drawable/ic_github.xml new file mode 100755 index 0000000..9ad20c2 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_github.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/drawable/ic_info.xml b/iliad/app/src/main/res/drawable/ic_info.xml new file mode 100755 index 0000000..f643fa7 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_info.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_info_outline.xml b/iliad/app/src/main/res/drawable/ic_info_outline.xml new file mode 100755 index 0000000..6d704be --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_info_outline.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_logout.xml b/iliad/app/src/main/res/drawable/ic_logout.xml new file mode 100755 index 0000000..fcb9347 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_logout.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_notification.xml b/iliad/app/src/main/res/drawable/ic_notification.xml new file mode 100755 index 0000000..d5c671b --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_notification.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_open_in_browser.xml b/iliad/app/src/main/res/drawable/ic_open_in_browser.xml new file mode 100755 index 0000000..d3ee7bb --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_open_in_browser.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_options.xml b/iliad/app/src/main/res/drawable/ic_options.xml new file mode 100755 index 0000000..1952b07 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_options.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/drawable/ic_pause.xml b/iliad/app/src/main/res/drawable/ic_pause.xml new file mode 100755 index 0000000..acd944d --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_pause.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_play.xml b/iliad/app/src/main/res/drawable/ic_play.xml new file mode 100755 index 0000000..dabd926 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_play.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_refresh.xml b/iliad/app/src/main/res/drawable/ic_refresh.xml new file mode 100755 index 0000000..6e2f5de --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_refresh.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_service.xml b/iliad/app/src/main/res/drawable/ic_service.xml new file mode 100755 index 0000000..c67be65 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_service.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/drawable/ic_settings.xml b/iliad/app/src/main/res/drawable/ic_settings.xml new file mode 100755 index 0000000..dc1ceb2 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_settings.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_share.xml b/iliad/app/src/main/res/drawable/ic_share.xml new file mode 100755 index 0000000..14581b4 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_share.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_sim_card.xml b/iliad/app/src/main/res/drawable/ic_sim_card.xml new file mode 100755 index 0000000..798c272 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_sim_card.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_sim_card_alert.xml b/iliad/app/src/main/res/drawable/ic_sim_card_alert.xml new file mode 100755 index 0000000..54e3fc3 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_sim_card_alert.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_tracking.xml b/iliad/app/src/main/res/drawable/ic_tracking.xml new file mode 100755 index 0000000..b745a59 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_tracking.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/drawable/ic_user.xml b/iliad/app/src/main/res/drawable/ic_user.xml new file mode 100755 index 0000000..c5baf3d --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_voicemail.xml b/iliad/app/src/main/res/drawable/ic_voicemail.xml new file mode 100755 index 0000000..92bc446 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_voicemail.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/ic_warning.xml b/iliad/app/src/main/res/drawable/ic_warning.xml new file mode 100755 index 0000000..30bb193 --- /dev/null +++ b/iliad/app/src/main/res/drawable/ic_warning.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/drawable/progress_bar.xml b/iliad/app/src/main/res/drawable/progress_bar.xml new file mode 100755 index 0000000..e66ae8c --- /dev/null +++ b/iliad/app/src/main/res/drawable/progress_bar.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/drawable/up_arrow.xml b/iliad/app/src/main/res/drawable/up_arrow.xml new file mode 100755 index 0000000..56303b7 --- /dev/null +++ b/iliad/app/src/main/res/drawable/up_arrow.xml @@ -0,0 +1,9 @@ + + + diff --git a/iliad/app/src/main/res/layout/activity_change_email.xml b/iliad/app/src/main/res/layout/activity_change_email.xml new file mode 100755 index 0000000..9af8fb9 --- /dev/null +++ b/iliad/app/src/main/res/layout/activity_change_email.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/layout/activity_change_password.xml b/iliad/app/src/main/res/layout/activity_change_password.xml new file mode 100755 index 0000000..730625d --- /dev/null +++ b/iliad/app/src/main/res/layout/activity_change_password.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/layout/activity_charge.xml b/iliad/app/src/main/res/layout/activity_charge.xml new file mode 100755 index 0000000..1429bdb --- /dev/null +++ b/iliad/app/src/main/res/layout/activity_charge.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/layout/activity_consumption_detail.xml b/iliad/app/src/main/res/layout/activity_consumption_detail.xml new file mode 100755 index 0000000..d130a55 --- /dev/null +++ b/iliad/app/src/main/res/layout/activity_consumption_detail.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/layout/activity_consumption_roaming_detail.xml b/iliad/app/src/main/res/layout/activity_consumption_roaming_detail.xml new file mode 100755 index 0000000..ffbf667 --- /dev/null +++ b/iliad/app/src/main/res/layout/activity_consumption_roaming_detail.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/layout/activity_forget.xml b/iliad/app/src/main/res/layout/activity_forget.xml new file mode 100755 index 0000000..e57b348 --- /dev/null +++ b/iliad/app/src/main/res/layout/activity_forget.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/layout/activity_home.xml b/iliad/app/src/main/res/layout/activity_home.xml new file mode 100755 index 0000000..c962e87 --- /dev/null +++ b/iliad/app/src/main/res/layout/activity_home.xml @@ -0,0 +1,15 @@ + + + + + + diff --git a/iliad/app/src/main/res/layout/activity_login.xml b/iliad/app/src/main/res/layout/activity_login.xml new file mode 100755 index 0000000..d4b4145 --- /dev/null +++ b/iliad/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/layout/activity_notification.xml b/iliad/app/src/main/res/layout/activity_notification.xml new file mode 100755 index 0000000..0442323 --- /dev/null +++ b/iliad/app/src/main/res/layout/activity_notification.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/layout/app_bar_home.xml b/iliad/app/src/main/res/layout/app_bar_home.xml new file mode 100755 index 0000000..b58b829 --- /dev/null +++ b/iliad/app/src/main/res/layout/app_bar_home.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/iliad/app/src/main/res/layout/content_change_email.xml b/iliad/app/src/main/res/layout/content_change_email.xml new file mode 100755 index 0000000..edf5a32 --- /dev/null +++ b/iliad/app/src/main/res/layout/content_change_email.xml @@ -0,0 +1,168 @@ + + + + + + + + +