├── .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 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | xmlns:android
18 |
19 | ^$
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | xmlns:.*
29 |
30 | ^$
31 |
32 |
33 | BY_NAME
34 |
35 |
36 |
37 |
38 |
39 |
40 | .*:id
41 |
42 | http://schemas.android.com/apk/res/android
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | .*:name
52 |
53 | http://schemas.android.com/apk/res/android
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | name
63 |
64 | ^$
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | style
74 |
75 | ^$
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | .*
85 |
86 | ^$
87 |
88 |
89 | BY_NAME
90 |
91 |
92 |
93 |
94 |
95 |
96 | .*
97 |
98 | http://schemas.android.com/apk/res/android
99 |
100 |
101 | ANDROID_ATTRIBUTE_ORDER
102 |
103 |
104 |
105 |
106 |
107 |
108 | .*
109 |
110 | .*
111 |
112 |
113 | BY_NAME
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
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 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
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 | 
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 | [](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 | [](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 |  |  |  |  | 
26 |
27 |
28 |
29 | ## We Support Dark Mode Too 🌚
30 | Dashboard | All Income | All Expense | Details | Add Transaction
31 | --- | --- | --- |--- |---
32 |  |  |  |  | 
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 | 
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 |
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 |
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 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_about.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
25 |
26 |
37 |
38 |
39 |
48 |
49 |
50 |
61 |
62 |
63 |
74 |
75 |
76 |
87 |
88 |
89 |
103 |
104 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_add_transaction.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
13 |
14 |
15 |
21 |
22 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_dashboard.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
17 |
18 |
19 |
23 |
24 |
25 |
36 |
37 |
38 |
48 |
49 |
55 |
56 |
62 |
63 |
64 |
65 |
76 |
77 |
78 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
105 |
106 |
118 |
119 |
120 |
121 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_edit_transaction.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
13 |
14 |
15 |
21 |
22 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_transaction_details.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
12 |
13 |
16 |
17 |
18 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_autocomplete_layout.xml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_filter_dropdown.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_transaction_layout.xml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
16 |
17 |
29 |
30 |
41 |
42 |
53 |
54 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/total_balance_view.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
16 |
17 |
25 |
26 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_share.xml:
--------------------------------------------------------------------------------
1 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_ui.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
10 |
11 |
17 |
18 |
23 |
24 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/navigation/nav_graph.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
20 |
27 |
34 |
35 |
40 |
45 |
46 |
51 |
54 |
61 |
64 |
65 |
70 |
73 |
76 |
77 |
82 |
94 |
95 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #4F9BFF
4 | #FF000000
5 | #FFFFFFFF
6 | #1A191E
7 | #121212
8 | #6FCF97
9 | #EB5757
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | false
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #006AF6
4 | #FF000000
5 | #FFFFFFFF
6 | #FFFFFF
7 | #f9f9f9
8 | #6FCF97
9 | #EB5757
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimen.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 0dp
4 | 4dp
5 | 8dp
6 | 12dp
7 | 16dp
8 | 24dp
9 | 32dp
10 | 48dp
11 | 64dp
12 | 150dp
13 | 250dp
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values/filters.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - Overall
5 | - All Income
6 | - All Expense
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/font_certs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - @array/com_google_android_gms_fonts_certs_dev
5 | - @array/com_google_android_gms_fonts_certs_prod
6 |
7 |
8 | -
9 | MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAeFw0wODA0MTUyMzM2NTZaFw0zNTA5MDEyMzM2NTZaMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBANbOLggKv+IxTdGNs8/TGFy0PTP6DHThvbbR24kT9ixcOd9W+EaBPWW+wPPKQmsHxajtWjmQwWfna8mZuSeJS48LIgAZlKkpFeVyxW0qMBujb8X8ETrWy550NaFtI6t9+u7hZeTfHwqNvacKhp1RbE6dBRGWynwMVX8XW8N1+UjFaq6GCJukT4qmpN2afb8sCjUigq0GuMwYXrFVee74bQgLHWGJwPmvmLHC69EH6kWr22ijx4OKXlSIx2xT1AsSHee70w5iDBiK4aph27yH3TxkXy9V89TDdexAcKk/cVHYNnDBapcavl7y0RiQ4biu8ymM8Ga/nmzhRKya6G0cGw8CAQOjgfwwgfkwHQYDVR0OBBYEFI0cxb6VTEM8YYY6FbBMvAPyT+CyMIHJBgNVHSMEgcEwgb6AFI0cxb6VTEM8YYY6FbBMvAPyT+CyoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJANWFuGx90071MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADggEBABnTDPEF+3iSP0wNfdIjIz1AlnrPzgAIHVvXxunW7SBrDhEglQZBbKJEk5kT0mtKoOD1JMrSu1xuTKEBahWRbqHsXclaXjoBADb0kkjVEJu/Lh5hgYZnOjvlba8Ld7HCKePCVePoTJBdI4fvugnL8TsgK05aIskyY0hKI9L8KfqfGTl1lzOv2KoWD0KWwtAWPoGChZxmQ+nBli+gwYMzM1vAkP+aayLe0a1EQimlOalO762r0GXO0ks+UeXde2Z4e+8S/pf7pITEI/tP+MxJTALw9QUWEv9lKTk+jkbqxbsh8nfBUapfKqYn0eidpwq2AzVp3juYl7//fKnaPhJD9gs=
10 |
11 |
12 |
13 | -
14 | MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDAeFw0wODA4MjEyMzEzMzRaFw0zNjAxMDcyMzEzMzRaMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBAKtWLgDYO6IIrgqWbxJOKdoR8qtW0I9Y4sypEwPpt1TTcvZApxsdyxMJZ2JORland2qSGT2y5b+3JKkedxiLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjAsb/GEuq/eFdpuzSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/CxURaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJEqO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/Tgt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/yzKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/preloaded_fonts.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - @font/open_sans_bold
5 | - @font/open_sans_regular
6 | - @font/open_sans_semibold
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Expenso
3 | Save Transaction
4 | UI Mode
5 | Total Income
6 | Total Expense
7 | Total Balance
8 | Recent Transactions
9 | View all
10 | When
11 | Amount
12 | Transaction type
13 | Tag
14 | Note
15 | Save Transaction
16 | ₹
17 | Transaction saved successfully
18 | Transaction deleted successfully!
19 | Title
20 | About
21 | Filter
22 | Edit
23 | Created At
24 |
25 |
26 | Transaction exported successfully!
27 | Transaction exported failed ☹️
28 | Transaction exported failed ☹️
29 | Support for export on Android10+ is still in progress, kindly be patient and thanks for support!
30 | Open
31 |
32 |
33 |
34 | Licensed Under Apache 2.0 License
35 | Visit
36 | https://github.com/Spikeysanju/Expenso
37 | v%s (%d)
38 | Share as Text
39 | Share as Image
40 | Delete
41 | Share
42 |
43 |
44 | \%s \nAmount: %s, \nTransaction-Type: %s, \nTag: %s, \nDate: %s, \nNote: %s, \nCreatedAt: %s \n\nVisit: https://github.com/Spikeysanju/Expenso
45 | No Transaction Yet!
46 | After your first transaction you will be able to view it here
47 | Export to CSV
48 | Add Transaction
49 | Undo
50 | Error occurred!
51 |
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
13 |
14 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | true
4 |
5 |
6 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/test/java/dev/spikeysanju/expensetracker/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package dev.spikeysanju.expensetracker
2 |
3 | import org.junit.Assert.assertEquals
4 | import org.junit.Test
5 |
6 | /**
7 | * Example local unit test, which will execute on the development machine (host).
8 | *
9 | * See [testing documentation](http://d.android.com/tools/testing).
10 | */
11 | class ExampleUnitTest {
12 | @Test
13 | fun addition_isCorrect() {
14 | assertEquals(4, 2 + 2)
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/art/ADD-TRANSACTION.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Spikeysanju/Expenso/dd807562eeb0c3fe6c14bc0882b2c442a6bd7388/art/ADD-TRANSACTION.png
--------------------------------------------------------------------------------
/art/DARK-ADD-TRANSACTION.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Spikeysanju/Expenso/dd807562eeb0c3fe6c14bc0882b2c442a6bd7388/art/DARK-ADD-TRANSACTION.png
--------------------------------------------------------------------------------
/art/DARK-DASHBOARD.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Spikeysanju/Expenso/dd807562eeb0c3fe6c14bc0882b2c442a6bd7388/art/DARK-DASHBOARD.png
--------------------------------------------------------------------------------
/art/DARK-DETAILS.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Spikeysanju/Expenso/dd807562eeb0c3fe6c14bc0882b2c442a6bd7388/art/DARK-DETAILS.png
--------------------------------------------------------------------------------
/art/DARK-EXPENSE.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Spikeysanju/Expenso/dd807562eeb0c3fe6c14bc0882b2c442a6bd7388/art/DARK-EXPENSE.png
--------------------------------------------------------------------------------
/art/DARK-INCOME.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Spikeysanju/Expenso/dd807562eeb0c3fe6c14bc0882b2c442a6bd7388/art/DARK-INCOME.png
--------------------------------------------------------------------------------
/art/DASHBOARD.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Spikeysanju/Expenso/dd807562eeb0c3fe6c14bc0882b2c442a6bd7388/art/DASHBOARD.png
--------------------------------------------------------------------------------
/art/DETAILS.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Spikeysanju/Expenso/dd807562eeb0c3fe6c14bc0882b2c442a6bd7388/art/DETAILS.png
--------------------------------------------------------------------------------
/art/EXPENSE.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Spikeysanju/Expenso/dd807562eeb0c3fe6c14bc0882b2c442a6bd7388/art/EXPENSE.png
--------------------------------------------------------------------------------
/art/EXPENSO-ANDROID.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Spikeysanju/Expenso/dd807562eeb0c3fe6c14bc0882b2c442a6bd7388/art/EXPENSO-ANDROID.png
--------------------------------------------------------------------------------
/art/INCOME.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Spikeysanju/Expenso/dd807562eeb0c3fe6c14bc0882b2c442a6bd7388/art/INCOME.png
--------------------------------------------------------------------------------
/beta_android.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Spikeysanju/Expenso/dd807562eeb0c3fe6c14bc0882b2c442a6bd7388/beta_android.png
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | val kotlin_version = "1.5.31"
4 |
5 | repositories {
6 | google()
7 | mavenCentral()
8 | }
9 |
10 | dependencies {
11 | classpath("com.android.tools.build:gradle:7.2.0-alpha03")
12 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
13 | classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5")
14 | classpath("com.google.dagger:hilt-android-gradle-plugin:2.38.1")
15 | }
16 | }
17 |
18 | plugins {
19 | id("com.diffplug.spotless") version ("5.14.0")
20 | }
21 |
22 | allprojects {
23 |
24 | repositories {
25 | google()
26 | mavenCentral()
27 | }
28 |
29 | apply {
30 | plugin("com.diffplug.spotless")
31 | }
32 |
33 | spotless {
34 |
35 | format("misc") {
36 | target("**/*.gradle', '**/*.md', '**/.gitignore")
37 | indentWithSpaces()
38 | trimTrailingWhitespace()
39 | endWithNewline()
40 | }
41 |
42 | kotlin {
43 | target("**/*.kt")
44 | targetExclude("$buildDir/**/*.kt")
45 | targetExclude("bin/**/*.kt")
46 | trimTrailingWhitespace()
47 | indentWithSpaces()
48 | endWithNewline()
49 | ktlint("0.41.0").userData(mapOf("disabled_rules" to "no-wildcard-imports"))
50 | }
51 | }
52 | }
53 |
54 | tasks.register(name = "type", type = Delete::class) {
55 | delete(rootProject.buildDir)
56 | }
57 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
22 | kotlin.daemon.jvmargs=--illegal-access=permit
23 | kapt.use.worker.api=false
24 |
25 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Spikeysanju/Expenso/dd807562eeb0c3fe6c14bc0882b2c442a6bd7388/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Nov 04 01:13:44 IST 2021
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-rc-1-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | rootProject.name = "ExpenseTracker"
--------------------------------------------------------------------------------