├── .editorconfig ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── dependabot.yml └── workflows │ └── android_ci.yml ├── .gitignore ├── .idea ├── .gitignore ├── .name ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── compiler.xml ├── encodings.xml ├── gradle.xml ├── jarRepositories.xml ├── misc.xml └── vcs.xml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTION.md ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle.kts ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── dev │ │ └── spikeysanju │ │ └── expensetracker │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── dev │ │ │ └── spikeysanju │ │ │ └── expensetracker │ │ │ ├── app │ │ │ └── ExpenseTracker.kt │ │ │ ├── data │ │ │ └── local │ │ │ │ ├── AppDatabase.kt │ │ │ │ ├── TransactionDao.kt │ │ │ │ └── datastore │ │ │ │ └── UIModeDataStore.kt │ │ │ ├── di │ │ │ └── AppModule.kt │ │ │ ├── model │ │ │ └── Transaction.kt │ │ │ ├── repo │ │ │ └── TransactionRepo.kt │ │ │ ├── services │ │ │ └── exportcsv │ │ │ │ ├── CsvActivityContracts.kt │ │ │ │ ├── ExportCsvService.kt │ │ │ │ └── TransactionsCsv.kt │ │ │ ├── utils │ │ │ ├── Constants.kt │ │ │ ├── DEFAULT_FILENAME.kt │ │ │ ├── ViewExt.kt │ │ │ ├── viewModelFactory.kt │ │ │ └── viewState │ │ │ │ ├── DetailState.kt │ │ │ │ ├── ExportState.kt │ │ │ │ └── ViewState.kt │ │ │ └── view │ │ │ ├── about │ │ │ ├── AboutFragment.kt │ │ │ └── AboutViewModel.kt │ │ │ ├── adapter │ │ │ └── TransactionAdapter.kt │ │ │ ├── add │ │ │ └── AddTransactionFragment.kt │ │ │ ├── base │ │ │ └── BaseFragment.kt │ │ │ ├── dashboard │ │ │ └── DashboardFragment.kt │ │ │ ├── details │ │ │ └── TransactionDetailsFragment.kt │ │ │ ├── dialog │ │ │ └── ErrorDialog.kt │ │ │ ├── edit │ │ │ └── EditTransactionFragment.kt │ │ │ └── main │ │ │ ├── MainActivity.kt │ │ │ └── viewmodel │ │ │ └── TransactionViewModel.kt │ └── res │ │ ├── anim │ │ ├── slide_in_left.xml │ │ ├── slide_in_right.xml │ │ ├── slide_out_left.xml │ │ └── slide_out_right.xml │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── ic_baseline_add.xml │ │ ├── ic_baseline_calendar.xml │ │ ├── ic_day.xml │ │ ├── ic_delete.xml │ │ ├── ic_edit.xml │ │ ├── ic_entertainment.xml │ │ ├── ic_expense.xml │ │ ├── ic_food.xml │ │ ├── ic_housing.xml │ │ ├── ic_income.xml │ │ ├── ic_insurance.xml │ │ ├── ic_launcher_background.xml │ │ ├── ic_logo.xml │ │ ├── ic_medical.xml │ │ ├── ic_night.xml │ │ ├── ic_others.xml │ │ ├── ic_personal_spending.xml │ │ ├── ic_savings.xml │ │ ├── ic_share.xml │ │ ├── ic_transport.xml │ │ ├── ic_utilities.xml │ │ └── icon_bg.xml │ │ ├── font │ │ ├── open_sans_bold.xml │ │ ├── open_sans_regular.xml │ │ └── open_sans_semibold.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── content_add_transaction_layout.xml │ │ ├── content_empty_state_layout.xml │ │ ├── content_income_expense_card_layout.xml │ │ ├── content_transaction_details.xml │ │ ├── error_dialog_layout.xml │ │ ├── fragment_about.xml │ │ ├── fragment_add_transaction.xml │ │ ├── fragment_dashboard.xml │ │ ├── fragment_edit_transaction.xml │ │ ├── fragment_transaction_details.xml │ │ ├── item_autocomplete_layout.xml │ │ ├── item_filter_dropdown.xml │ │ ├── item_transaction_layout.xml │ │ └── total_balance_view.xml │ │ ├── menu │ │ ├── menu_share.xml │ │ └── menu_ui.xml │ │ ├── navigation │ │ └── nav_graph.xml │ │ ├── raw │ │ ├── empty.json │ │ └── failed.json │ │ ├── values-night │ │ ├── colors.xml │ │ └── themes.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimen.xml │ │ ├── filters.xml │ │ ├── font_certs.xml │ │ ├── preloaded_fonts.xml │ │ ├── strings.xml │ │ ├── styles.xml │ │ └── themes.xml │ └── test │ └── java │ └── dev │ └── spikeysanju │ └── expensetracker │ └── ExampleUnitTest.kt ├── art ├── ADD-TRANSACTION.png ├── DARK-ADD-TRANSACTION.png ├── DARK-DASHBOARD.png ├── DARK-DETAILS.png ├── DARK-EXPENSE.png ├── DARK-INCOME.png ├── DASHBOARD.png ├── DETAILS.png ├── EXPENSE.png ├── EXPENSO-ANDROID.png └── INCOME.png ├── beta_android.png ├── build.gradle.kts ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: ["https://www.paypal.com/paypalme2/spikeysanju"] 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: Spikeysanju 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Smartphone (please complete the following information):** 27 | - Device: [e.g. iPhone6] 28 | - OS: [e.g. iOS8.1] 29 | - Browser [e.g. stock browser, safari] 30 | - Version [e.g. 22] 31 | 32 | **Additional context** 33 | Add any other context about the problem here. 34 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: Spikeysanju 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: gradle 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "23:30" 8 | open-pull-requests-limit: 10 9 | -------------------------------------------------------------------------------- /.github/workflows/android_ci.yml: -------------------------------------------------------------------------------- 1 | name: Android CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | 10 | jobs: 11 | build: 12 | 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v1 17 | 18 | - name: 🧱 Set Up JDK 19 | uses: actions/setup-java@v1 20 | with: 21 | java-version: 11 22 | 23 | - name: 🧪 Run Tests 24 | run: ./gradlew test 25 | 26 | - name: 🛠 Build Project with Spotless Check 27 | run: ./gradlew spotlessCheck assemble lintDebug --stacktrace 28 | 29 | - name: ⏳ Build with Gradle 30 | run: ./gradlew build 31 | 32 | - name: 🏗 Build APK 33 | run: bash ./gradlew assembleDebug --stacktrace 34 | 35 | - name: 🚀 Upload APK 📱 36 | uses: actions/upload-artifact@v2 37 | with: 38 | name: app 39 | path: app/build/outputs/apk/debug/app-debug.apk 40 | retention-days: 3 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | ExpenseTracker -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 119 | 120 | 122 | 123 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 20 | 21 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | 29 | 30 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at spikeysanju98@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /CONTRIBUTION.md: -------------------------------------------------------------------------------- 1 | ## Welcome Dev!, Thanks for making our this Expenso App great. 2 | 3 | ### What you can do 4 | You can contribute us by filing issues, bugs and PRs. 5 | 6 | ### Contributing guidelines: 7 | - Open issue regarding proposed change. 8 | - Repo owner will contact you there. 9 | - If your proposed change is approved, Fork this repo and do changes. 10 | - Open PR against latest `dev` branch. Add nice description in PR. 11 | - You're done! 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2021 Spikey Sanju 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![GitHub Cards Preview](https://github.com/Spikeysanju/Expenso/blob/master/art/EXPENSO-ANDROID.png?raw=true) 2 | 3 | # Expenso 📊 4 | A Simple Expense Tracker App 📱 built to demonstrate the use of modern android architecture component with MVVM Architecture 🏗. *Made with love ❤️ by [Spikeysanju](https://github.com/Spikeysanju)* 5 | 6 |
7 | 8 | ***Try latest Expenso app apk from below 👇*** 9 | 10 | [![Expenso](https://img.shields.io/badge/Expenso-APK-black.svg?style=for-the-badge&logo=android)](https://github.com/Spikeysanju/Expenso/releases/download/v1.0.0-alpha01/Expenso.apk) 11 | 12 |
13 | 14 | ## UI Design 🎨 15 | 16 | ***Click to View Expenso app Design from below 👇*** 17 | 18 | [![Expenso](https://img.shields.io/badge/Expenso-FIGMA-black.svg?style=for-the-badge&logo=figma)](https://www.figma.com/file/Z5KMfiwo9RYtYBUMRSIfHh/Expense-Tracker-App?node-id=140%3A1016) 19 | 20 |
21 | 22 | ## Day Mode 🌞 23 | Dashboard | All Income | All Expense | Details | Add Transaction 24 | --- | --- | --- |--- |--- 25 | ![](https://github.com/Spikeysanju/Expenso/blob/master/art/DASHBOARD.png) | ![](https://github.com/Spikeysanju/Expenso/blob/master/art/INCOME.png) | ![](https://github.com/Spikeysanju/Expenso/blob/master/art/EXPENSE.png) | ![](https://github.com/Spikeysanju/Expenso/blob/master/art/DETAILS.png) | ![](https://github.com/Spikeysanju/Expenso/blob/master/art/ADD-TRANSACTION.png) 26 | 27 |
28 | 29 | ## We Support Dark Mode Too 🌚 30 | Dashboard | All Income | All Expense | Details | Add Transaction 31 | --- | --- | --- |--- |--- 32 | ![](https://github.com/Spikeysanju/Expenso/blob/master/art/DARK-DASHBOARD.png) | ![](https://github.com/Spikeysanju/Expenso/blob/master/art/DARK-INCOME.png) | ![](https://github.com/Spikeysanju/Expenso/blob/master/art/DARK-EXPENSE.png) | ![](https://github.com/Spikeysanju/Expenso/blob/master/art/DARK-DETAILS.png) | ![](https://github.com/Spikeysanju/Expenso/blob/master/art/DARK-ADD-TRANSACTION.png) 33 | 34 |
35 | 36 | 37 | ## Built With 🛠 38 | - [Kotlin](https://kotlinlang.org/) - First class and official programming language for Android development. 39 | - [Coroutines](https://kotlinlang.org/docs/reference/coroutines-overview.html) - For asynchronous and more.. 40 | - [Android Architecture Components](https://developer.android.com/topic/libraries/architecture) - Collection of libraries that help you design robust, testable, and maintainable apps. 41 | - [Stateflow](https://developer.android.com/kotlin/flow/stateflow-and-sharedflow) - StateFlow is a state-holder observable flow that emits the current and new state updates to its collectors. 42 | - [Flow](https://kotlinlang.org/docs/reference/coroutines/flow.html) - A flow is an asynchronous version of a Sequence, a type of collection whose values are lazily produced. 43 | - [ViewModel](https://developer.android.com/topic/libraries/architecture/viewmodel) - Stores UI-related data that isn't destroyed on UI changes. 44 | - [Room](https://developer.android.com/topic/libraries/architecture/room) - SQLite object mapping library. 45 | - [Jetpack Navigation](https://developer.android.com/guide/navigation) - Navigation refers to the interactions that allow users to navigate across, into, and back out from the different pieces of content within your app 46 | - [DataStore](https://developer.android.com/topic/libraries/architecture/datastore) - Jetpack DataStore is a data storage solution that allows you to store key-value pairs or typed objects with protocol buffers. DataStore uses Kotlin coroutines and Flow to store data asynchronously, consistently, and transactionally. 47 | - [Material Components for Android](https://github.com/material-components/material-components-android) - Modular and customizable Material Design UI components for Android. 48 | - [Figma](https://figma.com/) - Figma is a vector graphics editor and prototyping tool which is primarily web-based. 49 | 50 |
51 | 52 | ## Package Structure 📦 53 | 54 | dev.spikeysanju.expenso # Root Package 55 | ├── di # Hilt DI Modules 56 | ├── data # For data handling. 57 | │ ├── local # Local Persistence Database. Room (SQLite) database 58 | | │ ├── dao # Data Access Object for Room 59 | | | |── database # Database Instance 60 | | 61 | ├── model # Model classes [Transaction] 62 | | 63 | |-- repo # Used to handle all data operations 64 | | 65 | ├── view # Activity/Fragment View layer 66 | │ ├── main # Main root folder 67 | | │ ├── main # Main Activity for RecyclerView 68 | | │ └── viewmodel # Transaction ViewModel 69 | | │ ├── adapter # Adapter for RecyclerView 70 | │ ├── Dashboard # Dashboard root folder 71 | | | |__ dashboard # Dashboard 72 | │ ├── Add # Add Transaction root folder 73 | | | |__ add # Add Transaction 74 | │ ├── Edit # Edit Transaction root folder 75 | | | |__ edit # Edit Transaction 76 | │ ├── Details # Add Transaction root folder 77 | | | |__ details # Transaction Details 78 | │ ├── About # About root folder 79 | | | |__ about # About 80 | │ ├── Dialog # All Dialogs root folder 81 | | | |__ dialog # Error Dialog 82 | ├── utils # All extension functions 83 | 84 | 85 |
86 | 87 | 88 | ## Architecture 🗼 89 | This app uses [***MVVM (Model View View-Model)***](https://developer.android.com/jetpack/docs/guide#recommended-app-arch) architecture. 90 | 91 | ![](https://github.com/TheCodeMonks/Notes-App/blob/master/screenshots/ANDROID%20ROOM%20DB%20DIAGRAM.jpg) 92 | 93 | ## Build-tool 🧰 94 | You need to have [Android Studio Beta 3 or above](https://developer.android.com/studio/preview) to build this project. 95 |
96 | Beta-studio 97 | 98 |
99 | 100 | ## Ohh You want iOS App Too? 📱 101 | Well, we've iOS version here, Checkout the iOS version of this app Expenso 102 | 103 |
104 | 105 | ## Contribute 🤝 106 | If you want to contribute to this app, you're always welcome! 107 | See [Contributing Guidelines](https://github.com/Spikeysanju/Expenso/blob/master/CONTRIBUTION.md). 108 | 109 |
110 | 111 | ## Contact 📩 112 | Have an project? DM us at 👇 113 | 114 | Drop a mail to:- spikeysanju98@gmail.com 115 | 116 |
117 | 118 | ## Donation 💰 119 | If this project help you reduce time to develop, you can give me a cup of coffee :) 120 | 121 | Buy Me A Coffee 122 | 123 |
124 | 125 | 126 | ## Credits 🤗 127 | 128 | - 🤓 Icons are from [tablericons.com](https://tablericons.com) 129 | - 📄 Thanks for [NotyKT](https://github.com/PatilShreyas/NotyKT) 130 | 131 |
132 | 133 | ## License 🔖 134 | ``` 135 | Apache 2.0 License 136 | 137 | 138 | Copyright 2021 Spikey sanju 139 | 140 | Licensed under the Apache License, Version 2.0 (the "License"); 141 | you may not use this file except in compliance with the License. 142 | You may obtain a copy of the License at 143 | 144 | http://www.apache.org/licenses/LICENSE-2.0 145 | 146 | Unless required by applicable law or agreed to in writing, software 147 | distributed under the License is distributed on an "AS IS" BASIS, 148 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 149 | See the License for the specific language governing permissions and 150 | limitations under the License. 151 | 152 | ``` 153 | 154 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | id("kotlin-kapt") 5 | id("androidx.navigation.safeargs.kotlin") 6 | id("dagger.hilt.android.plugin") 7 | } 8 | 9 | android { 10 | compileSdk = 31 11 | buildToolsVersion = "30.0.3" 12 | 13 | defaultConfig { 14 | applicationId = "dev.spikeysanju.expensetracker" 15 | minSdk = 21 16 | targetSdk = 30 17 | versionCode = 1 18 | versionName = "v1.0.0-alpha01" 19 | 20 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" 21 | vectorDrawables { 22 | useSupportLibrary = true 23 | } 24 | } 25 | 26 | lint { 27 | checkReleaseBuilds = false 28 | abortOnError = false 29 | } 30 | 31 | buildFeatures { 32 | viewBinding = true 33 | } 34 | 35 | buildTypes { 36 | release { 37 | isMinifyEnabled = true 38 | isShrinkResources = true 39 | proguardFiles( 40 | getDefaultProguardFile("proguard-android.txt"), 41 | "proguard-rules.pro" 42 | ) 43 | } 44 | } 45 | 46 | compileOptions { 47 | sourceCompatibility = JavaVersion.VERSION_11 48 | targetCompatibility = JavaVersion.VERSION_11 49 | } 50 | 51 | kotlinOptions { 52 | jvmTarget = "11" 53 | } 54 | 55 | } 56 | 57 | dependencies { 58 | 59 | implementation("org.jetbrains.kotlin:kotlin-stdlib:1.5.31") 60 | implementation("androidx.core:core-ktx:1.7.0") 61 | implementation("androidx.appcompat:appcompat:1.3.1") 62 | implementation("com.google.android.material:material:1.4.0") 63 | implementation("androidx.constraintlayout:constraintlayout:2.1.1") 64 | implementation("androidx.legacy:legacy-support-v4:1.0.0") 65 | testImplementation("junit:junit:4.13.2") 66 | androidTestImplementation("androidx.test.ext:junit:1.1.3") 67 | androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") 68 | 69 | // Room 70 | implementation("androidx.room:room-runtime:2.3.0") 71 | kapt("androidx.room:room-compiler:2.3.0") 72 | kapt("org.xerial:sqlite-jdbc:3.36.0.3") 73 | 74 | // Kotlin Extensions and Coroutines support for Room 75 | implementation("androidx.room:room-ktx:2.3.0") 76 | 77 | // Coroutines 78 | implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2") 79 | implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2-native-mt") 80 | implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.5.2-native-mt") 81 | 82 | // Coroutine Lifecycle Scopes 83 | implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0") 84 | implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.0") 85 | 86 | // Navigation Components 87 | implementation("androidx.navigation:navigation-fragment-ktx:2.3.5") 88 | implementation("androidx.navigation:navigation-ui-ktx:2.3.5") 89 | 90 | // RecyclerView 91 | implementation("androidx.recyclerview:recyclerview:1.2.1") 92 | 93 | // Preference DataStore 94 | implementation("androidx.datastore:datastore-preferences:1.0.0") 95 | 96 | // activity & fragment ktx 97 | implementation("androidx.fragment:fragment-ktx:1.3.6") 98 | implementation("androidx.activity:activity-ktx:1.4.0") 99 | implementation("androidx.appcompat:appcompat:1.4.0-rc01") 100 | 101 | // Lottie Animation Library 102 | implementation("com.airbnb.android:lottie:4.2.0") 103 | 104 | // Hilt 105 | implementation("com.google.dagger:hilt-android:2.39.1") 106 | kapt("com.google.dagger:hilt-android-compiler:2.39.1") 107 | kapt("androidx.hilt:hilt-compiler:1.0.0") 108 | 109 | //implementation "com.google.dagger:hilt-android-testing:$hilt_ver" 110 | implementation("androidx.hilt:hilt-common:1.0.0") 111 | implementation("androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03") 112 | 113 | // OpenCsv 114 | implementation("com.opencsv:opencsv:5.3") 115 | 116 | } 117 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle.kts. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/dev/spikeysanju/expensetracker/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker 2 | 3 | import androidx.test.ext.junit.runners.AndroidJUnit4 4 | import androidx.test.platform.app.InstrumentationRegistry 5 | import org.junit.Assert.assertEquals 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | /** 10 | * Instrumented test, which will execute on an Android device. 11 | * 12 | * See [testing documentation](http://d.android.com/tools/testing). 13 | */ 14 | @RunWith(AndroidJUnit4::class) 15 | class ExampleInstrumentedTest { 16 | @Test 17 | fun useAppContext() { 18 | // Context of the app under test. 19 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 20 | assertEquals("dev.spikeysanju.expensetracker", appContext.packageName) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 9 | 10 | 11 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/app/ExpenseTracker.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.app 2 | 3 | import android.app.Application 4 | import dagger.hilt.android.HiltAndroidApp 5 | 6 | @HiltAndroidApp 7 | class ExpenseTracker : Application() 8 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/data/local/AppDatabase.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.data.local 2 | 3 | import androidx.room.Database 4 | import androidx.room.RoomDatabase 5 | import dev.spikeysanju.expensetracker.model.Transaction 6 | 7 | @Database( 8 | entities = [Transaction::class], 9 | version = 1, 10 | exportSchema = false 11 | ) 12 | abstract class AppDatabase : RoomDatabase() { 13 | abstract fun getTransactionDao(): TransactionDao 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/data/local/TransactionDao.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.data.local 2 | 3 | import androidx.room.* 4 | import dev.spikeysanju.expensetracker.model.Transaction 5 | import kotlinx.coroutines.flow.Flow 6 | 7 | @Dao 8 | interface TransactionDao { 9 | 10 | // used to insert new transaction 11 | @Insert(onConflict = OnConflictStrategy.REPLACE) 12 | suspend fun insertTransaction(transaction: Transaction) 13 | 14 | // used to update existing transaction 15 | @Update(onConflict = OnConflictStrategy.REPLACE) 16 | suspend fun updateTransaction(transaction: Transaction) 17 | 18 | // used to delete transaction 19 | @Delete 20 | suspend fun deleteTransaction(transaction: Transaction) 21 | 22 | // get all saved transaction list 23 | @Query("SELECT * FROM all_transactions ORDER by createdAt DESC") 24 | fun getAllTransactions(): Flow> 25 | 26 | // get all income or expense list by transaction type param 27 | @Query("SELECT * FROM all_transactions WHERE transactionType == :transactionType ORDER by createdAt DESC") 28 | fun getAllSingleTransaction(transactionType: String): Flow> 29 | 30 | // get single transaction by id 31 | @Query("SELECT * FROM all_transactions WHERE id = :id") 32 | fun getTransactionByID(id: Int): Flow 33 | 34 | // delete transaction by id 35 | @Query("DELETE FROM all_transactions WHERE id = :id") 36 | suspend fun deleteTransactionByID(id: Int) 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/data/local/datastore/UIModeDataStore.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.data.local.datastore 2 | 3 | import android.content.Context 4 | import androidx.datastore.preferences.core.booleanPreferencesKey 5 | import androidx.datastore.preferences.core.edit 6 | import androidx.datastore.preferences.preferencesDataStore 7 | import kotlinx.coroutines.flow.Flow 8 | import kotlinx.coroutines.flow.map 9 | import javax.inject.Singleton 10 | 11 | val Context.themePrefDataStore by preferencesDataStore("ui_mode_pref") 12 | 13 | class UIModeDataStore(context: Context) : UIModeImpl { 14 | 15 | private val dataStore = context.themePrefDataStore 16 | 17 | // used to get the data from datastore 18 | override val uiMode: Flow 19 | get() = dataStore.data.map { preferences -> 20 | val uiMode = preferences[UI_MODE_KEY] ?: false 21 | uiMode 22 | } 23 | 24 | // used to save the ui preference to datastore 25 | override suspend fun saveToDataStore(isNightMode: Boolean) { 26 | dataStore.edit { preferences -> 27 | preferences[UI_MODE_KEY] = isNightMode 28 | } 29 | } 30 | 31 | companion object { 32 | private val UI_MODE_KEY = booleanPreferencesKey("ui_mode") 33 | } 34 | } 35 | 36 | @Singleton 37 | interface UIModeImpl { 38 | val uiMode: Flow 39 | suspend fun saveToDataStore(isNightMode: Boolean) 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/di/AppModule.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.di 2 | 3 | import android.content.Context 4 | import androidx.room.Room 5 | import dagger.Module 6 | import dagger.Provides 7 | import dagger.hilt.InstallIn 8 | import dagger.hilt.android.qualifiers.ApplicationContext 9 | import dagger.hilt.components.SingletonComponent 10 | import dev.spikeysanju.expensetracker.data.local.AppDatabase 11 | import dev.spikeysanju.expensetracker.data.local.datastore.UIModeDataStore 12 | import dev.spikeysanju.expensetracker.data.local.datastore.UIModeImpl 13 | import dev.spikeysanju.expensetracker.services.exportcsv.ExportCsvService 14 | import javax.inject.Singleton 15 | 16 | @InstallIn(SingletonComponent::class) 17 | @Module 18 | object AppModule { 19 | 20 | @Singleton 21 | @Provides 22 | fun providePreferenceManager(@ApplicationContext context: Context): UIModeImpl { 23 | return UIModeDataStore(context) 24 | } 25 | 26 | @Singleton 27 | @Provides 28 | fun provideNoteDatabase(@ApplicationContext context: Context): AppDatabase { 29 | return Room.databaseBuilder(context, AppDatabase::class.java, "transaction.db") 30 | .fallbackToDestructiveMigration().build() 31 | } 32 | 33 | @Singleton 34 | @Provides 35 | fun provideExportCSV(@ApplicationContext context: Context): ExportCsvService { 36 | return ExportCsvService(appContext = context) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/model/Transaction.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.model 2 | 3 | import androidx.room.ColumnInfo 4 | import androidx.room.Entity 5 | import androidx.room.PrimaryKey 6 | import java.io.Serializable 7 | import java.text.DateFormat 8 | 9 | @Entity(tableName = "all_transactions") 10 | data class Transaction( 11 | 12 | @ColumnInfo(name = "title") 13 | var title: String, 14 | @ColumnInfo(name = "amount") 15 | var amount: Double, 16 | @ColumnInfo(name = "transactionType") 17 | var transactionType: String, 18 | @ColumnInfo(name = "tag") 19 | var tag: String, 20 | @ColumnInfo(name = "date") 21 | var date: String, 22 | @ColumnInfo(name = "note") 23 | var note: String, 24 | @ColumnInfo(name = "createdAt") 25 | var createdAt: Long = 26 | System.currentTimeMillis(), 27 | @PrimaryKey(autoGenerate = true) 28 | @ColumnInfo(name = "id") 29 | var id: Int = 0, 30 | ) : Serializable { 31 | val createdAtDateFormat: String 32 | get() = DateFormat.getDateTimeInstance() 33 | .format(createdAt) // Date Format: Jan 11, 2021, 11:30 AM 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/repo/TransactionRepo.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.repo 2 | 3 | import dev.spikeysanju.expensetracker.data.local.AppDatabase 4 | import dev.spikeysanju.expensetracker.model.Transaction 5 | import javax.inject.Inject 6 | 7 | class TransactionRepo @Inject constructor(private val db: AppDatabase) { 8 | 9 | // insert transaction 10 | suspend fun insert(transaction: Transaction) = db.getTransactionDao().insertTransaction( 11 | transaction 12 | ) 13 | 14 | // update transaction 15 | suspend fun update(transaction: Transaction) = db.getTransactionDao().updateTransaction( 16 | transaction 17 | ) 18 | 19 | // delete transaction 20 | suspend fun delete(transaction: Transaction) = db.getTransactionDao().deleteTransaction( 21 | transaction 22 | ) 23 | 24 | // get all transaction 25 | fun getAllTransactions() = db.getTransactionDao().getAllTransactions() 26 | 27 | // get single transaction type - Expense or Income or else overall 28 | fun getAllSingleTransaction(transactionType: String) = if (transactionType == "Overall") { 29 | getAllTransactions() 30 | } else { 31 | db.getTransactionDao().getAllSingleTransaction(transactionType) 32 | } 33 | 34 | // get transaction by ID 35 | fun getByID(id: Int) = db.getTransactionDao().getTransactionByID(id) 36 | 37 | // delete transaction by ID 38 | suspend fun deleteByID(id: Int) = db.getTransactionDao().deleteTransactionByID(id) 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/services/exportcsv/CsvActivityContracts.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.services.exportcsv 2 | 3 | import android.app.Activity 4 | import android.content.Context 5 | import android.content.Intent 6 | import android.net.Uri 7 | import androidx.activity.result.contract.ActivityResultContract 8 | 9 | class CreateCsvContract : ActivityResultContract() { 10 | 11 | override fun createIntent(context: Context, input: String): Intent { 12 | return Intent(Intent.ACTION_CREATE_DOCUMENT).apply { 13 | addCategory(Intent.CATEGORY_OPENABLE) 14 | type = "application/csv" 15 | putExtra(Intent.EXTRA_TITLE, "$input.csv") 16 | } 17 | } 18 | 19 | override fun parseResult(resultCode: Int, intent: Intent?): Uri? { 20 | if (resultCode != Activity.RESULT_OK) { 21 | return null 22 | } 23 | return intent?.data 24 | } 25 | } 26 | 27 | class OpenCsvContract : ActivityResultContract() { 28 | 29 | override fun createIntent(context: Context, input: Uri): Intent { 30 | val title = "Open with" 31 | val csvPreviewIntent = Intent(Intent.ACTION_OPEN_DOCUMENT, input).apply { 32 | addCategory(Intent.CATEGORY_OPENABLE) 33 | type = "*/*" 34 | } 35 | return Intent.createChooser(csvPreviewIntent, title) 36 | } 37 | 38 | override fun parseResult(resultCode: Int, intent: Intent?) { 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/services/exportcsv/ExportCsvService.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.services.exportcsv 2 | 3 | import android.content.Context 4 | import android.net.Uri 5 | import androidx.annotation.WorkerThread 6 | import com.opencsv.CSVWriter 7 | import com.opencsv.bean.StatefulBeanToCsvBuilder 8 | import kotlinx.coroutines.flow.flow 9 | import java.io.FileWriter 10 | import javax.inject.Inject 11 | 12 | class ExportCsvService @Inject constructor( 13 | private val appContext: Context 14 | ) { 15 | 16 | @WorkerThread 17 | fun writeToCSV(csvFileUri: Uri, content: List) = flow { 18 | val fileDescriptor = appContext.contentResolver.openFileDescriptor(csvFileUri, "w") 19 | if (fileDescriptor != null) { 20 | fileDescriptor.use { 21 | val csvWriter = CSVWriter(FileWriter(it.fileDescriptor)) 22 | StatefulBeanToCsvBuilder(csvWriter) 23 | .withSeparator(CSVWriter.DEFAULT_SEPARATOR) 24 | .build() 25 | .write(content) 26 | csvWriter.close() 27 | emit(csvFileUri) 28 | } 29 | } else { 30 | throw IllegalStateException("failed to read fileDescriptor") 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/services/exportcsv/TransactionsCsv.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.services.exportcsv 2 | 3 | import com.opencsv.bean.CsvBindByName 4 | import dev.spikeysanju.expensetracker.model.Transaction 5 | 6 | data class TransactionsCSV( 7 | @CsvBindByName(column = "title") 8 | val title: String, 9 | @CsvBindByName(column = "amount") 10 | val amount: Double, 11 | @CsvBindByName(column = "transactionType") 12 | val transactionType: String, 13 | @CsvBindByName(column = "tag") 14 | val tag: String, 15 | @CsvBindByName(column = "date") 16 | val date: String, 17 | @CsvBindByName(column = "note") 18 | val note: String, 19 | @CsvBindByName(column = "createdAt") 20 | val createdAtDate: String 21 | ) 22 | 23 | fun List.toCsv() = map { 24 | TransactionsCSV( 25 | title = it.title, 26 | amount = it.amount, 27 | transactionType = it.transactionType, 28 | tag = it.tag, 29 | date = it.date, 30 | note = it.note, 31 | createdAtDate = it.createdAtDateFormat, 32 | ) 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/utils/Constants.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.utils 2 | 3 | object Constants { 4 | 5 | val transactionType = listOf("Income", "Expense") 6 | 7 | val transactionTags = listOf( 8 | "Housing", 9 | "Transportation", 10 | "Food", 11 | "Utilities", 12 | "Insurance", 13 | "Healthcare", 14 | "Saving & Debts", 15 | "Personal Spending", 16 | "Entertainment", 17 | "Miscellaneous" 18 | ) 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/utils/DEFAULT_FILENAME.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.utils 2 | 3 | import android.app.Activity 4 | import android.content.ContentValues 5 | import android.graphics.Bitmap 6 | import android.net.Uri 7 | import android.os.Build 8 | import android.os.Environment 9 | import android.provider.MediaStore 10 | 11 | @JvmField 12 | val DEFAULT_FILENAME = "${"Expenso" + System.currentTimeMillis()}.png" 13 | 14 | fun saveBitmap(activity: Activity, bitmap: Bitmap, filename: String = DEFAULT_FILENAME): Uri? { 15 | val contentValues = ContentValues().apply { 16 | put(MediaStore.MediaColumns.DISPLAY_NAME, filename) 17 | put(MediaStore.MediaColumns.MIME_TYPE, "image/jpeg") 18 | 19 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { 20 | put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_PICTURES) 21 | } 22 | } 23 | 24 | val contentResolver = activity.contentResolver 25 | 26 | val imageUri: Uri? = contentResolver.insert( 27 | MediaStore.Images.Media.EXTERNAL_CONTENT_URI, 28 | contentValues 29 | ) 30 | 31 | return imageUri.also { 32 | val fileOutputStream = imageUri?.let { contentResolver.openOutputStream(it) } 33 | bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream) 34 | fileOutputStream?.close() 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/utils/ViewExt.kt: -------------------------------------------------------------------------------- 1 | import android.app.DatePickerDialog 2 | import android.content.Context 3 | import android.view.View 4 | import androidx.annotation.StringRes 5 | import androidx.core.content.ContextCompat 6 | import com.google.android.material.snackbar.Snackbar 7 | import com.google.android.material.textfield.TextInputEditText 8 | import java.text.NumberFormat 9 | import java.text.SimpleDateFormat 10 | import java.util.* 11 | 12 | fun View.show() { 13 | visibility = View.VISIBLE 14 | } 15 | 16 | fun View.hide() { 17 | visibility = View.GONE 18 | } 19 | 20 | inline fun View.snack( 21 | @StringRes string: Int, 22 | length: Int = Snackbar.LENGTH_LONG, 23 | action: Snackbar.() -> Unit = {} 24 | ) { 25 | val snack = Snackbar.make(this, resources.getString(string), length) 26 | action.invoke(snack) 27 | snack.show() 28 | } 29 | 30 | fun Snackbar.action( 31 | @StringRes text: Int, 32 | color: Int? = null, 33 | listener: (View) -> Unit 34 | ) { 35 | setAction(text, listener) 36 | color?.let { setActionTextColor(ContextCompat.getColor(context, color)) } 37 | } 38 | 39 | fun TextInputEditText.transformIntoDatePicker( 40 | context: Context, 41 | format: String, 42 | maxDate: Date? = null 43 | ) { 44 | isFocusableInTouchMode = false 45 | isClickable = true 46 | isFocusable = false 47 | 48 | val myCalendar = Calendar.getInstance() 49 | val datePickerOnDataSetListener = 50 | DatePickerDialog.OnDateSetListener { _, year, monthOfYear, dayOfMonth -> 51 | myCalendar.set(Calendar.YEAR, year) 52 | myCalendar.set(Calendar.MONTH, monthOfYear) 53 | myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth) 54 | val sdf = SimpleDateFormat(format, Locale.UK) 55 | setText(sdf.format(myCalendar.time)) 56 | } 57 | 58 | setOnClickListener { 59 | DatePickerDialog( 60 | context, 61 | datePickerOnDataSetListener, 62 | myCalendar 63 | .get(Calendar.YEAR), 64 | myCalendar.get(Calendar.MONTH), 65 | myCalendar.get(Calendar.DAY_OF_MONTH) 66 | ).run { 67 | maxDate?.time?.also { datePicker.maxDate = it } 68 | show() 69 | } 70 | } 71 | } 72 | 73 | // indian rupee converter 74 | fun indianRupee(amount: Double): String { 75 | val format: NumberFormat = NumberFormat.getCurrencyInstance() 76 | format.maximumFractionDigits = 0 77 | format.currency = Currency.getInstance("INR") 78 | return format.format(amount) 79 | } 80 | 81 | val String.cleanTextContent: String 82 | get() { 83 | // strips off all non-ASCII characters 84 | var text = this 85 | text = text.replace("[^\\x00-\\x7F]".toRegex(), "") 86 | 87 | // erases all the ASCII control characters 88 | text = text.replace("[\\p{Cntrl}&&[^\r\n\t]]".toRegex(), "") 89 | 90 | // removes non-printable characters from Unicode 91 | text = text.replace("\\p{C}".toRegex(), "") 92 | text = text.replace(",".toRegex(), "") 93 | return text.trim() 94 | } 95 | 96 | // parse string to double 97 | fun parseDouble(value: String?): Double { 98 | return if (value == null || value.isEmpty()) Double.NaN else value.toDouble() 99 | } 100 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/utils/viewModelFactory.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.utils 2 | 3 | import androidx.lifecycle.ViewModel 4 | import androidx.lifecycle.ViewModelProvider 5 | 6 | @Suppress("UNCHECKED_CAST") 7 | inline fun viewModelFactory(crossinline function: () -> VM) = 8 | object : ViewModelProvider.Factory { 9 | override fun create(aClass: Class): T = function() as T 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/utils/viewState/DetailState.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.utils.viewState 2 | 3 | import dev.spikeysanju.expensetracker.model.Transaction 4 | 5 | sealed class DetailState { 6 | object Loading : DetailState() 7 | object Empty : DetailState() 8 | data class Success(val transaction: Transaction) : DetailState() 9 | data class Error(val exception: Throwable) : DetailState() 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/utils/viewState/ExportState.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.utils.viewState 2 | 3 | import android.net.Uri 4 | 5 | sealed class ExportState { 6 | object Loading : ExportState() 7 | object Empty : ExportState() 8 | data class Success(val fileUri: Uri) : ExportState() 9 | data class Error(val exception: Throwable) : ExportState() 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/utils/viewState/ViewState.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.utils.viewState 2 | 3 | import dev.spikeysanju.expensetracker.model.Transaction 4 | 5 | sealed class ViewState { 6 | object Loading : ViewState() 7 | object Empty : ViewState() 8 | data class Success(val transaction: List) : ViewState() 9 | data class Error(val exception: Throwable) : ViewState() 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/view/about/AboutFragment.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.view.about 2 | 3 | import android.content.Intent 4 | import android.net.Uri 5 | import android.os.Bundle 6 | import android.view.LayoutInflater 7 | import android.view.View 8 | import android.view.ViewGroup 9 | import androidx.fragment.app.viewModels 10 | import dagger.hilt.android.AndroidEntryPoint 11 | import dev.spikeysanju.expensetracker.BuildConfig 12 | import dev.spikeysanju.expensetracker.R 13 | import dev.spikeysanju.expensetracker.databinding.FragmentAboutBinding 14 | import dev.spikeysanju.expensetracker.view.base.BaseFragment 15 | 16 | @AndroidEntryPoint 17 | class AboutFragment : BaseFragment() { 18 | override val viewModel: AboutViewModel by viewModels() 19 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 20 | super.onViewCreated(view, savedInstanceState) 21 | initViews() 22 | } 23 | 24 | private fun initViews() = with(binding) { 25 | appVersion.text = getString( 26 | R.string.text_app_version, 27 | BuildConfig.VERSION_NAME, 28 | BuildConfig.VERSION_CODE 29 | ) 30 | 31 | license.setOnClickListener { 32 | viewModel.launchLicense().run { 33 | launchBrowser(viewModel.url.value) 34 | } 35 | } 36 | 37 | visitURL.setOnClickListener { 38 | viewModel.launchRepository().run { 39 | launchBrowser(viewModel.url.value) 40 | } 41 | } 42 | } 43 | 44 | private fun launchBrowser(url: String) = 45 | Intent(Intent.ACTION_VIEW, Uri.parse(url)).also { 46 | startActivity(it) 47 | } 48 | 49 | override fun getViewBinding(inflater: LayoutInflater, container: ViewGroup?) = 50 | FragmentAboutBinding.inflate(inflater, container, false) 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/view/about/AboutViewModel.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.view.about 2 | 3 | import androidx.lifecycle.ViewModel 4 | import dagger.hilt.android.lifecycle.HiltViewModel 5 | import kotlinx.coroutines.flow.MutableStateFlow 6 | import kotlinx.coroutines.flow.StateFlow 7 | import javax.inject.Inject 8 | 9 | @HiltViewModel 10 | class AboutViewModel @Inject constructor() : ViewModel() { 11 | private val _url = MutableStateFlow("https://github.com/Spikeysanju/Expenso") 12 | val url: StateFlow = _url 13 | 14 | fun launchLicense() { 15 | _url.value = "https://github.com/Spikeysanju/Expenso/blob/master/LICENSE" 16 | } 17 | 18 | fun launchRepository() { 19 | _url.value = "https://github.com/Spikeysanju/Expenso" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/view/adapter/TransactionAdapter.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.view.adapter 2 | 3 | import android.view.LayoutInflater 4 | import android.view.ViewGroup 5 | import androidx.core.content.ContextCompat 6 | import androidx.recyclerview.widget.AsyncListDiffer 7 | import androidx.recyclerview.widget.DiffUtil 8 | import androidx.recyclerview.widget.RecyclerView 9 | import dev.spikeysanju.expensetracker.R 10 | import dev.spikeysanju.expensetracker.databinding.ItemTransactionLayoutBinding 11 | import dev.spikeysanju.expensetracker.model.Transaction 12 | import indianRupee 13 | 14 | class TransactionAdapter : RecyclerView.Adapter() { 15 | 16 | inner class TransactionVH(val binding: ItemTransactionLayoutBinding) : 17 | RecyclerView.ViewHolder(binding.root) 18 | 19 | private val differCallback = object : DiffUtil.ItemCallback() { 20 | override fun areItemsTheSame(oldItem: Transaction, newItem: Transaction): Boolean { 21 | return oldItem.id == newItem.id 22 | } 23 | 24 | override fun areContentsTheSame(oldItem: Transaction, newItem: Transaction): Boolean { 25 | return oldItem == newItem 26 | } 27 | } 28 | 29 | val differ = AsyncListDiffer(this, differCallback) 30 | 31 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TransactionVH { 32 | val binding = 33 | ItemTransactionLayoutBinding.inflate(LayoutInflater.from(parent.context), parent, false) 34 | return TransactionVH(binding) 35 | } 36 | 37 | override fun getItemCount(): Int { 38 | return differ.currentList.size 39 | } 40 | 41 | override fun onBindViewHolder(holder: TransactionVH, position: Int) { 42 | 43 | val item = differ.currentList[position] 44 | holder.binding.apply { 45 | 46 | transactionName.text = item.title 47 | transactionCategory.text = item.tag 48 | 49 | when (item.transactionType) { 50 | "Income" -> { 51 | transactionAmount.setTextColor( 52 | ContextCompat.getColor( 53 | transactionAmount.context, 54 | R.color.income 55 | ) 56 | ) 57 | 58 | transactionAmount.text = "+ ".plus(indianRupee(item.amount)) 59 | } 60 | "Expense" -> { 61 | transactionAmount.setTextColor( 62 | ContextCompat.getColor( 63 | transactionAmount.context, 64 | R.color.expense 65 | ) 66 | ) 67 | transactionAmount.text = "- ".plus(indianRupee(item.amount)) 68 | } 69 | } 70 | 71 | when (item.tag) { 72 | "Housing" -> { 73 | transactionIconView.setImageResource(R.drawable.ic_food) 74 | } 75 | "Transportation" -> { 76 | transactionIconView.setImageResource(R.drawable.ic_transport) 77 | } 78 | "Food" -> { 79 | transactionIconView.setImageResource(R.drawable.ic_food) 80 | } 81 | "Utilities" -> { 82 | transactionIconView.setImageResource(R.drawable.ic_utilities) 83 | } 84 | "Insurance" -> { 85 | transactionIconView.setImageResource(R.drawable.ic_insurance) 86 | } 87 | "Healthcare" -> { 88 | transactionIconView.setImageResource(R.drawable.ic_medical) 89 | } 90 | "Saving & Debts" -> { 91 | transactionIconView.setImageResource(R.drawable.ic_savings) 92 | } 93 | "Personal Spending" -> { 94 | transactionIconView.setImageResource(R.drawable.ic_personal_spending) 95 | } 96 | "Entertainment" -> { 97 | transactionIconView.setImageResource(R.drawable.ic_entertainment) 98 | } 99 | "Miscellaneous" -> { 100 | transactionIconView.setImageResource(R.drawable.ic_others) 101 | } 102 | else -> { 103 | transactionIconView.setImageResource(R.drawable.ic_others) 104 | } 105 | } 106 | 107 | // on item click 108 | holder.itemView.setOnClickListener { 109 | onItemClickListener?.let { it(item) } 110 | } 111 | } 112 | } 113 | 114 | // on item click listener 115 | private var onItemClickListener: ((Transaction) -> Unit)? = null 116 | fun setOnItemClickListener(listener: (Transaction) -> Unit) { 117 | onItemClickListener = listener 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/view/add/AddTransactionFragment.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.view.add 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import android.widget.ArrayAdapter 8 | import androidx.fragment.app.activityViewModels 9 | import androidx.navigation.fragment.findNavController 10 | import dagger.hilt.android.AndroidEntryPoint 11 | import dev.spikeysanju.expensetracker.R 12 | import dev.spikeysanju.expensetracker.databinding.FragmentAddTransactionBinding 13 | import dev.spikeysanju.expensetracker.model.Transaction 14 | import dev.spikeysanju.expensetracker.utils.Constants 15 | import dev.spikeysanju.expensetracker.view.base.BaseFragment 16 | import dev.spikeysanju.expensetracker.view.main.viewmodel.TransactionViewModel 17 | import parseDouble 18 | import snack 19 | import transformIntoDatePicker 20 | import java.util.* 21 | 22 | @AndroidEntryPoint 23 | class AddTransactionFragment : 24 | BaseFragment() { 25 | override val viewModel: TransactionViewModel by activityViewModels() 26 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 27 | super.onViewCreated(view, savedInstanceState) 28 | initViews() 29 | } 30 | 31 | private fun initViews() { 32 | 33 | val transactionTypeAdapter = 34 | ArrayAdapter( 35 | requireContext(), 36 | R.layout.item_autocomplete_layout, 37 | Constants.transactionType 38 | ) 39 | val tagsAdapter = ArrayAdapter( 40 | requireContext(), 41 | R.layout.item_autocomplete_layout, 42 | Constants.transactionTags 43 | ) 44 | 45 | with(binding) { 46 | // Set list to TextInputEditText adapter 47 | addTransactionLayout.etTransactionType.setAdapter(transactionTypeAdapter) 48 | addTransactionLayout.etTag.setAdapter(tagsAdapter) 49 | 50 | // Transform TextInputEditText to DatePicker using Ext function 51 | addTransactionLayout.etWhen.transformIntoDatePicker( 52 | requireContext(), 53 | "dd/MM/yyyy", 54 | Date() 55 | ) 56 | btnSaveTransaction.setOnClickListener { 57 | binding.addTransactionLayout.apply { 58 | val (title, amount, transactionType, tag, date, note) = getTransactionContent() 59 | // validate if transaction content is empty or not 60 | when { 61 | title.isEmpty() -> { 62 | this.etTitle.error = "Title must not be empty" 63 | } 64 | amount.isNaN() -> { 65 | this.etAmount.error = "Amount must not be empty" 66 | } 67 | transactionType.isEmpty() -> { 68 | this.etTransactionType.error = "Transaction type must not be empty" 69 | } 70 | tag.isEmpty() -> { 71 | this.etTag.error = "Tag must not be empty" 72 | } 73 | date.isEmpty() -> { 74 | this.etWhen.error = "Date must not be empty" 75 | } 76 | note.isEmpty() -> { 77 | this.etNote.error = "Note must not be empty" 78 | } 79 | else -> { 80 | viewModel.insertTransaction(getTransactionContent()).run { 81 | binding.root.snack( 82 | string = R.string.success_expense_saved 83 | ) 84 | findNavController().navigate( 85 | R.id.action_addTransactionFragment_to_dashboardFragment 86 | ) 87 | } 88 | } 89 | } 90 | } 91 | } 92 | } 93 | } 94 | 95 | private fun getTransactionContent(): Transaction = binding.addTransactionLayout.let { 96 | val title = it.etTitle.text.toString() 97 | val amount = parseDouble(it.etAmount.text.toString()) 98 | val transactionType = it.etTransactionType.text.toString() 99 | val tag = it.etTag.text.toString() 100 | val date = it.etWhen.text.toString() 101 | val note = it.etNote.text.toString() 102 | 103 | return Transaction(title, amount, transactionType, tag, date, note) 104 | } 105 | 106 | override fun getViewBinding( 107 | inflater: LayoutInflater, 108 | container: ViewGroup? 109 | ) = FragmentAddTransactionBinding.inflate(inflater, container, false) 110 | } 111 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/view/base/BaseFragment.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.view.base 2 | 3 | import android.content.Context 4 | import android.os.Bundle 5 | import android.view.LayoutInflater 6 | import android.view.View 7 | import android.view.ViewGroup 8 | import android.widget.Toast 9 | import androidx.fragment.app.Fragment 10 | import androidx.lifecycle.ViewModel 11 | import androidx.viewbinding.ViewBinding 12 | 13 | abstract class BaseFragment : Fragment() { 14 | 15 | private var _binding: VB? = null 16 | protected val binding get() = _binding!! 17 | protected abstract val viewModel: VM 18 | override fun onCreateView( 19 | inflater: LayoutInflater, 20 | container: ViewGroup?, 21 | savedInstanceState: Bundle? 22 | ): View? { 23 | _binding = getViewBinding(inflater, container) 24 | return binding.root 25 | } 26 | 27 | protected abstract fun getViewBinding(inflater: LayoutInflater, container: ViewGroup?): VB 28 | 29 | fun toast(message: String) { 30 | Toast.makeText(activity, message, Toast.LENGTH_SHORT).show() 31 | } 32 | 33 | fun applicationContext(): Context = requireActivity().applicationContext 34 | 35 | override fun onDestroy() { 36 | super.onDestroy() 37 | _binding = null 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/view/details/TransactionDetailsFragment.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.view.details 2 | 3 | import android.Manifest 4 | import android.annotation.SuppressLint 5 | import android.content.Intent 6 | import android.content.pm.PackageManager 7 | import android.os.Bundle 8 | import android.view.LayoutInflater 9 | import android.view.Menu 10 | import android.view.MenuInflater 11 | import android.view.MenuItem 12 | import android.view.View 13 | import android.view.ViewGroup 14 | import androidx.activity.result.contract.ActivityResultContracts 15 | import androidx.core.app.ShareCompat 16 | import androidx.core.content.ContextCompat 17 | import androidx.core.view.drawToBitmap 18 | import androidx.fragment.app.activityViewModels 19 | import androidx.lifecycle.lifecycleScope 20 | import androidx.navigation.fragment.findNavController 21 | import androidx.navigation.fragment.navArgs 22 | import cleanTextContent 23 | import dagger.hilt.android.AndroidEntryPoint 24 | import dev.spikeysanju.expensetracker.R 25 | import dev.spikeysanju.expensetracker.databinding.FragmentTransactionDetailsBinding 26 | import dev.spikeysanju.expensetracker.model.Transaction 27 | import dev.spikeysanju.expensetracker.utils.saveBitmap 28 | import dev.spikeysanju.expensetracker.utils.viewState.DetailState 29 | import dev.spikeysanju.expensetracker.view.base.BaseFragment 30 | import dev.spikeysanju.expensetracker.view.main.viewmodel.TransactionViewModel 31 | import hide 32 | import indianRupee 33 | import kotlinx.coroutines.flow.collect 34 | import show 35 | import snack 36 | 37 | @AndroidEntryPoint 38 | class TransactionDetailsFragment : BaseFragment() { 39 | private val args: TransactionDetailsFragmentArgs by navArgs() 40 | override val viewModel: TransactionViewModel by activityViewModels() 41 | 42 | // handle permission dialog 43 | private val requestLauncher = 44 | registerForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted -> 45 | if (isGranted) shareImage() else showErrorDialog() 46 | } 47 | 48 | private fun showErrorDialog() = 49 | findNavController().navigate( 50 | TransactionDetailsFragmentDirections.actionTransactionDetailsFragmentToErrorDialog( 51 | "Image share failed!", 52 | "You have to enable storage permission to share transaction as Image" 53 | ) 54 | ) 55 | 56 | override fun onCreate(savedInstanceState: Bundle?) { 57 | super.onCreate(savedInstanceState) 58 | setHasOptionsMenu(true) 59 | } 60 | 61 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 62 | super.onViewCreated(view, savedInstanceState) 63 | val transaction = args.transaction 64 | getTransaction(transaction.id) 65 | observeTransaction() 66 | } 67 | 68 | private fun getTransaction(id: Int) { 69 | viewModel.getByID(id) 70 | } 71 | 72 | private fun observeTransaction() = lifecycleScope.launchWhenCreated { 73 | 74 | viewModel.detailState.collect { detailState -> 75 | 76 | when (detailState) { 77 | DetailState.Loading -> { 78 | } 79 | is DetailState.Success -> { 80 | onDetailsLoaded(detailState.transaction) 81 | } 82 | is DetailState.Error -> { 83 | binding.root.snack( 84 | string = R.string.text_error 85 | ) 86 | } 87 | DetailState.Empty -> { 88 | findNavController().navigateUp() 89 | } 90 | } 91 | } 92 | } 93 | 94 | private fun onDetailsLoaded(transaction: Transaction) = with(binding.transactionDetails) { 95 | title.text = transaction.title 96 | amount.text = indianRupee(transaction.amount).cleanTextContent 97 | type.text = transaction.transactionType 98 | tag.text = transaction.tag 99 | date.text = transaction.date 100 | note.text = transaction.note 101 | createdAt.text = transaction.createdAtDateFormat 102 | 103 | binding.editTransaction.setOnClickListener { 104 | val bundle = Bundle().apply { 105 | putSerializable("transaction", transaction) 106 | } 107 | findNavController().navigate( 108 | R.id.action_transactionDetailsFragment_to_editTransactionFragment, 109 | bundle 110 | ) 111 | } 112 | } 113 | 114 | override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { 115 | inflater.inflate(R.menu.menu_share, menu) 116 | super.onCreateOptionsMenu(menu, inflater) 117 | } 118 | 119 | override fun onOptionsItemSelected(item: MenuItem): Boolean { 120 | when (item.itemId) { 121 | R.id.action_delete -> { 122 | viewModel.deleteByID(args.transaction.id) 123 | .run { 124 | findNavController().navigateUp() 125 | } 126 | } 127 | R.id.action_share_text -> shareText() 128 | R.id.action_share_image -> shareImage() 129 | } 130 | return super.onOptionsItemSelected(item) 131 | } 132 | 133 | private fun shareImage() { 134 | if (!isStoragePermissionGranted()) { 135 | requestLauncher.launch(Manifest.permission.WRITE_EXTERNAL_STORAGE) 136 | return 137 | } 138 | 139 | // unHide the app logo and name 140 | showAppNameAndLogo() 141 | val imageURI = binding.transactionDetails.detailView.drawToBitmap().let { bitmap -> 142 | hideAppNameAndLogo() 143 | saveBitmap(requireActivity(), bitmap) 144 | } ?: run { 145 | binding.root.snack( 146 | string = R.string.text_error_occurred 147 | ) 148 | return 149 | } 150 | 151 | val intent = ShareCompat.IntentBuilder(requireActivity()) 152 | .setType("image/jpeg") 153 | .setStream(imageURI) 154 | .intent 155 | 156 | startActivity(Intent.createChooser(intent, null)) 157 | } 158 | 159 | private fun showAppNameAndLogo() = with(binding.transactionDetails) { 160 | appIconForShare.show() 161 | appNameForShare.show() 162 | } 163 | 164 | private fun hideAppNameAndLogo() = with(binding.transactionDetails) { 165 | appIconForShare.hide() 166 | appNameForShare.hide() 167 | } 168 | 169 | private fun isStoragePermissionGranted(): Boolean = ContextCompat.checkSelfPermission( 170 | requireContext(), 171 | Manifest.permission.WRITE_EXTERNAL_STORAGE 172 | ) == PackageManager.PERMISSION_GRANTED 173 | 174 | @SuppressLint("StringFormatMatches") 175 | private fun shareText() = with(binding) { 176 | val shareMsg = getString( 177 | R.string.share_message, 178 | transactionDetails.title.text.toString(), 179 | transactionDetails.amount.text.toString(), 180 | transactionDetails.type.text.toString(), 181 | transactionDetails.tag.text.toString(), 182 | transactionDetails.date.text.toString(), 183 | transactionDetails.note.text.toString(), 184 | transactionDetails.createdAt.text.toString() 185 | ) 186 | 187 | val intent = ShareCompat.IntentBuilder(requireActivity()) 188 | .setType("text/plain") 189 | .setText(shareMsg) 190 | .intent 191 | 192 | startActivity(Intent.createChooser(intent, null)) 193 | } 194 | 195 | override fun getViewBinding( 196 | inflater: LayoutInflater, 197 | container: ViewGroup? 198 | ) = FragmentTransactionDetailsBinding.inflate(inflater, container, false) 199 | } 200 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/view/dialog/ErrorDialog.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.view.dialog 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import android.view.WindowManager 8 | import androidx.navigation.fragment.navArgs 9 | import com.google.android.material.bottomsheet.BottomSheetDialogFragment 10 | import dev.spikeysanju.expensetracker.databinding.ErrorDialogLayoutBinding 11 | 12 | class ErrorDialog : BottomSheetDialogFragment() { 13 | private var _binding: ErrorDialogLayoutBinding? = null 14 | private val binding get() = _binding!! 15 | private val args: ErrorDialogArgs by navArgs() 16 | override fun onCreateView( 17 | inflater: LayoutInflater, 18 | container: ViewGroup?, 19 | savedInstanceState: Bundle? 20 | ): View { 21 | _binding = ErrorDialogLayoutBinding.inflate(inflater, container, false) 22 | return binding.root 23 | } 24 | 25 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 26 | super.onViewCreated(view, savedInstanceState) 27 | 28 | binding.run { 29 | dialogTitle.text = args.title 30 | dialogMessage.text = args.message 31 | dialogButtonOk.setOnClickListener { dialog?.dismiss() } 32 | } 33 | } 34 | 35 | override fun onStart() { 36 | super.onStart() 37 | dialog?.window?.setLayout( 38 | WindowManager.LayoutParams.MATCH_PARENT, 39 | WindowManager.LayoutParams.MATCH_PARENT 40 | ) 41 | } 42 | 43 | override fun onDestroy() { 44 | super.onDestroy() 45 | _binding = null 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/view/edit/EditTransactionFragment.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.view.edit 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import android.widget.ArrayAdapter 8 | import androidx.fragment.app.activityViewModels 9 | import androidx.navigation.fragment.findNavController 10 | import androidx.navigation.fragment.navArgs 11 | import dagger.hilt.android.AndroidEntryPoint 12 | import dev.spikeysanju.expensetracker.R 13 | import dev.spikeysanju.expensetracker.databinding.FragmentEditTransactionBinding 14 | import dev.spikeysanju.expensetracker.model.Transaction 15 | import dev.spikeysanju.expensetracker.utils.Constants 16 | import dev.spikeysanju.expensetracker.view.base.BaseFragment 17 | import dev.spikeysanju.expensetracker.view.main.viewmodel.TransactionViewModel 18 | import parseDouble 19 | import snack 20 | import transformIntoDatePicker 21 | import java.util.* 22 | 23 | @AndroidEntryPoint 24 | class EditTransactionFragment : BaseFragment() { 25 | private val args: EditTransactionFragmentArgs by navArgs() 26 | override val viewModel: TransactionViewModel by activityViewModels() 27 | 28 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 29 | super.onViewCreated(view, savedInstanceState) 30 | // receiving bundles here 31 | val transaction = args.transaction 32 | initViews() 33 | loadData(transaction) 34 | } 35 | 36 | private fun loadData(transaction: Transaction) = with(binding) { 37 | addTransactionLayout.etTitle.setText(transaction.title) 38 | addTransactionLayout.etAmount.setText(transaction.amount.toString()) 39 | addTransactionLayout.etTransactionType.setText(transaction.transactionType, false) 40 | addTransactionLayout.etTag.setText(transaction.tag, false) 41 | addTransactionLayout.etWhen.setText(transaction.date) 42 | addTransactionLayout.etNote.setText(transaction.note) 43 | } 44 | 45 | private fun initViews() = with(binding) { 46 | val transactionTypeAdapter = 47 | ArrayAdapter( 48 | requireContext(), 49 | R.layout.item_autocomplete_layout, 50 | Constants.transactionType 51 | ) 52 | val tagsAdapter = ArrayAdapter( 53 | requireContext(), 54 | R.layout.item_autocomplete_layout, 55 | Constants.transactionTags 56 | ) 57 | 58 | // Set list to TextInputEditText adapter 59 | addTransactionLayout.etTransactionType.setAdapter(transactionTypeAdapter) 60 | addTransactionLayout.etTag.setAdapter(tagsAdapter) 61 | 62 | // Transform TextInputEditText to DatePicker using Ext function 63 | addTransactionLayout.etWhen.transformIntoDatePicker( 64 | requireContext(), 65 | "dd/MM/yyyy", 66 | Date() 67 | ) 68 | btnSaveTransaction.setOnClickListener { 69 | binding.addTransactionLayout.apply { 70 | val (title, amount, transactionType, tag, date, note) = 71 | getTransactionContent() 72 | // validate if transaction content is empty or not 73 | when { 74 | title.isEmpty() -> { 75 | this.etTitle.error = "Title must not be empty" 76 | } 77 | amount.isNaN() -> { 78 | this.etAmount.error = "Amount must not be empty" 79 | } 80 | transactionType.isEmpty() -> { 81 | this.etTransactionType.error = "Transaction type must not be empty" 82 | } 83 | tag.isEmpty() -> { 84 | this.etTag.error = "Tag must not be empty" 85 | } 86 | date.isEmpty() -> { 87 | this.etWhen.error = "Date must not be empty" 88 | } 89 | note.isEmpty() -> { 90 | this.etNote.error = "Note must not be empty" 91 | } 92 | else -> { 93 | viewModel.updateTransaction(getTransactionContent()).also { 94 | 95 | binding.root.snack( 96 | string = R.string.success_expense_saved 97 | ).run { 98 | findNavController().popBackStack() 99 | } 100 | } 101 | } 102 | } 103 | } 104 | } 105 | } 106 | 107 | private fun getTransactionContent(): Transaction = binding.addTransactionLayout.let { 108 | 109 | val id = args.transaction.id 110 | val title = it.etTitle.text.toString() 111 | val amount = parseDouble(it.etAmount.text.toString()) 112 | val transactionType = it.etTransactionType.text.toString() 113 | val tag = it.etTag.text.toString() 114 | val date = it.etWhen.text.toString() 115 | val note = it.etNote.text.toString() 116 | 117 | return Transaction( 118 | title = title, 119 | amount = amount, 120 | transactionType = transactionType, 121 | tag = tag, 122 | date = date, 123 | note = note, 124 | createdAt = System.currentTimeMillis(), 125 | id = id 126 | ) 127 | } 128 | 129 | override fun getViewBinding( 130 | inflater: LayoutInflater, 131 | container: ViewGroup? 132 | ) = FragmentEditTransactionBinding.inflate(inflater, container, false) 133 | } 134 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/view/main/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.view.main 2 | 3 | import android.os.Bundle 4 | import androidx.activity.viewModels 5 | import androidx.appcompat.app.AppCompatActivity 6 | import androidx.appcompat.app.AppCompatDelegate 7 | import androidx.lifecycle.lifecycleScope 8 | import androidx.navigation.NavController 9 | import androidx.navigation.fragment.NavHostFragment 10 | import androidx.navigation.ui.AppBarConfiguration 11 | import androidx.navigation.ui.setupActionBarWithNavController 12 | import dagger.hilt.android.AndroidEntryPoint 13 | import dev.spikeysanju.expensetracker.R 14 | import dev.spikeysanju.expensetracker.data.local.datastore.UIModeImpl 15 | import dev.spikeysanju.expensetracker.databinding.ActivityMainBinding 16 | import dev.spikeysanju.expensetracker.repo.TransactionRepo 17 | import dev.spikeysanju.expensetracker.services.exportcsv.ExportCsvService 18 | import dev.spikeysanju.expensetracker.view.main.viewmodel.TransactionViewModel 19 | import kotlinx.coroutines.flow.collect 20 | import javax.inject.Inject 21 | 22 | @AndroidEntryPoint 23 | class MainActivity : AppCompatActivity() { 24 | private lateinit var navHostFragment: NavHostFragment 25 | private lateinit var appBarConfiguration: AppBarConfiguration 26 | 27 | @Inject 28 | lateinit var repo: TransactionRepo 29 | @Inject 30 | lateinit var exportCsvService: ExportCsvService 31 | @Inject 32 | lateinit var themeManager: UIModeImpl 33 | private val viewModel: TransactionViewModel by viewModels() 34 | 35 | override fun onCreate(savedInstanceState: Bundle?) { 36 | super.onCreate(savedInstanceState) 37 | val binding = ActivityMainBinding.inflate(layoutInflater) 38 | setContentView(binding.root) 39 | 40 | /** 41 | * Just so the viewModel doesn't get removed by the compiler, as it isn't used 42 | * anywhere here for now 43 | */ 44 | viewModel 45 | 46 | initViews(binding) 47 | observeThemeMode() 48 | observeNavElements(binding, navHostFragment.navController) 49 | } 50 | 51 | private fun observeThemeMode() { 52 | lifecycleScope.launchWhenStarted { 53 | viewModel.getUIMode.collect { 54 | val mode = when (it) { 55 | true -> AppCompatDelegate.MODE_NIGHT_YES 56 | false -> AppCompatDelegate.MODE_NIGHT_NO 57 | } 58 | AppCompatDelegate.setDefaultNightMode(mode) 59 | } 60 | } 61 | } 62 | 63 | private fun observeNavElements( 64 | binding: ActivityMainBinding, 65 | navController: NavController 66 | ) { 67 | navController.addOnDestinationChangedListener { _, destination, _ -> 68 | when (destination.id) { 69 | 70 | R.id.dashboardFragment -> { 71 | supportActionBar!!.setDisplayShowTitleEnabled(false) 72 | } 73 | R.id.addTransactionFragment -> { 74 | supportActionBar!!.setDisplayShowTitleEnabled(true) 75 | binding.toolbar.title = getString(R.string.text_add_transaction) 76 | } 77 | else -> { 78 | supportActionBar!!.setDisplayShowTitleEnabled(true) 79 | } 80 | } 81 | } 82 | } 83 | 84 | private fun initViews(binding: ActivityMainBinding) { 85 | setSupportActionBar(binding.toolbar) 86 | supportActionBar!!.setDisplayShowTitleEnabled(false) 87 | 88 | navHostFragment = supportFragmentManager 89 | .findFragmentById(R.id.nav_host_fragment) as NavHostFragment? 90 | ?: return 91 | 92 | with(navHostFragment.navController) { 93 | appBarConfiguration = AppBarConfiguration(graph) 94 | setupActionBarWithNavController(this, appBarConfiguration) 95 | } 96 | } 97 | 98 | override fun onSupportNavigateUp(): Boolean { 99 | navHostFragment.navController.navigateUp() 100 | return super.onSupportNavigateUp() 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /app/src/main/java/dev/spikeysanju/expensetracker/view/main/viewmodel/TransactionViewModel.kt: -------------------------------------------------------------------------------- 1 | package dev.spikeysanju.expensetracker.view.main.viewmodel 2 | 3 | import android.net.Uri 4 | import android.util.Log 5 | import androidx.lifecycle.ViewModel 6 | import androidx.lifecycle.viewModelScope 7 | import dagger.hilt.android.lifecycle.HiltViewModel 8 | import dev.spikeysanju.expensetracker.data.local.datastore.UIModeImpl 9 | import dev.spikeysanju.expensetracker.model.Transaction 10 | import dev.spikeysanju.expensetracker.repo.TransactionRepo 11 | import dev.spikeysanju.expensetracker.services.exportcsv.ExportCsvService 12 | import dev.spikeysanju.expensetracker.services.exportcsv.toCsv 13 | import dev.spikeysanju.expensetracker.utils.viewState.DetailState 14 | import dev.spikeysanju.expensetracker.utils.viewState.ExportState 15 | import dev.spikeysanju.expensetracker.utils.viewState.ViewState 16 | import kotlinx.coroutines.Dispatchers 17 | import kotlinx.coroutines.Dispatchers.IO 18 | import kotlinx.coroutines.flow.MutableStateFlow 19 | import kotlinx.coroutines.flow.StateFlow 20 | import kotlinx.coroutines.flow.catch 21 | import kotlinx.coroutines.flow.collect 22 | import kotlinx.coroutines.flow.flatMapMerge 23 | import kotlinx.coroutines.flow.flowOn 24 | import kotlinx.coroutines.flow.map 25 | import kotlinx.coroutines.launch 26 | import javax.inject.Inject 27 | 28 | @HiltViewModel 29 | class TransactionViewModel @Inject constructor( 30 | private val transactionRepo: TransactionRepo, 31 | private val exportService: ExportCsvService, 32 | private val uiModeDataStore: UIModeImpl 33 | ) : ViewModel() { 34 | 35 | // state for export csv status 36 | private val _exportCsvState = MutableStateFlow(ExportState.Empty) 37 | val exportCsvState: StateFlow = _exportCsvState 38 | 39 | private val _transactionFilter = MutableStateFlow("Overall") 40 | val transactionFilter: StateFlow = _transactionFilter 41 | 42 | private val _uiState = MutableStateFlow(ViewState.Loading) 43 | private val _detailState = MutableStateFlow(DetailState.Loading) 44 | 45 | // UI collect from this stateFlow to get the state updates 46 | val uiState: StateFlow = _uiState 47 | val detailState: StateFlow = _detailState 48 | 49 | // get ui mode 50 | val getUIMode = uiModeDataStore.uiMode 51 | 52 | // save ui mode 53 | fun setDarkMode(isNightMode: Boolean) { 54 | viewModelScope.launch(IO) { 55 | uiModeDataStore.saveToDataStore(isNightMode) 56 | } 57 | } 58 | 59 | // export all Transactions to csv file 60 | fun exportTransactionsToCsv(csvFileUri: Uri) = viewModelScope.launch { 61 | _exportCsvState.value = ExportState.Loading 62 | transactionRepo 63 | .getAllTransactions() 64 | .flowOn(Dispatchers.IO) 65 | .map { it.toCsv() } 66 | .flatMapMerge { exportService.writeToCSV(csvFileUri, it) } 67 | .catch { error -> 68 | _exportCsvState.value = ExportState.Error(error) 69 | }.collect { uriString -> 70 | _exportCsvState.value = ExportState.Success(uriString) 71 | } 72 | } 73 | 74 | // insert transaction 75 | fun insertTransaction(transaction: Transaction) = viewModelScope.launch { 76 | transactionRepo.insert(transaction) 77 | } 78 | 79 | // update transaction 80 | fun updateTransaction(transaction: Transaction) = viewModelScope.launch { 81 | transactionRepo.update(transaction) 82 | } 83 | 84 | // delete transaction 85 | fun deleteTransaction(transaction: Transaction) = viewModelScope.launch { 86 | transactionRepo.delete(transaction) 87 | } 88 | 89 | // get all transaction 90 | fun getAllTransaction(type: String) = viewModelScope.launch { 91 | transactionRepo.getAllSingleTransaction(type).collect { result -> 92 | if (result.isNullOrEmpty()) { 93 | _uiState.value = ViewState.Empty 94 | } else { 95 | _uiState.value = ViewState.Success(result) 96 | Log.i("Filter", "Transaction filter is ${transactionFilter.value}") 97 | } 98 | } 99 | } 100 | 101 | // get transaction by id 102 | fun getByID(id: Int) = viewModelScope.launch { 103 | _detailState.value = DetailState.Loading 104 | transactionRepo.getByID(id).collect { result: Transaction? -> 105 | if (result != null) { 106 | _detailState.value = DetailState.Success(result) 107 | } 108 | } 109 | } 110 | 111 | // delete transaction 112 | fun deleteByID(id: Int) = viewModelScope.launch { 113 | transactionRepo.deleteByID(id) 114 | } 115 | 116 | fun allIncome() { 117 | _transactionFilter.value = "Income" 118 | } 119 | 120 | fun allExpense() { 121 | _transactionFilter.value = "Expense" 122 | } 123 | 124 | fun overall() { 125 | _transactionFilter.value = "Overall" 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_in_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_in_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_out_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_out_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_baseline_add.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_baseline_calendar.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_day.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_delete.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 27 | 34 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_edit.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_entertainment.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_expense.xml: -------------------------------------------------------------------------------- 1 | 6 | 10 | 17 | 24 | 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_food.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_housing.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_income.xml: -------------------------------------------------------------------------------- 1 | 6 | 10 | 17 | 24 | 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_insurance.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 27 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_logo.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | 11 | 14 | 17 | 20 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_medical.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 27 | 34 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_night.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_others.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_personal_spending.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_savings.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_share.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 27 | 34 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_transport.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_utilities.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/icon_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/font/open_sans_bold.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/font/open_sans_regular.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/font/open_sans_semibold.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 16 | 17 | 21 | 22 | 23 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_add_transaction_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 16 | 17 | 23 | 24 | 25 | 26 | 34 | 35 | 41 | 42 | 43 | 44 | 52 | 53 | 60 | 61 | 62 | 63 | 64 | 72 | 73 | 80 | 81 | 82 | 83 | 94 | 95 | 101 | 102 | 103 | 104 | 111 | 112 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_empty_state_layout.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 19 | 20 | 31 | 32 | 33 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_income_expense_card_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 17 | 18 | 23 | 24 | 32 | 33 | 42 | 43 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_transaction_details.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 | 17 | 28 | 29 | 41 | 42 | 43 | 54 | 55 | 67 | 68 | 69 | 80 | 81 | 93 | 94 | 95 | 106 | 107 | 119 | 120 | 121 | 132 | 133 | 145 | 146 | 157 | 158 | 170 | 171 | 182 | 183 | 195 | 196 | 204 | 205 | 219 | 220 | 221 | 222 | 223 | -------------------------------------------------------------------------------- /app/src/main/res/layout/error_dialog_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 22 | 23 | 34 | 35 | 47 | 48 |