6 – Allowance Tracker: A Super Simple Android App

what my app looks like right now :]

Hey so I know I said I would talk about my experience with HealthKit, but before we get to that I wanted to talk about this app I made. It’s a super simple allowance tracker that my husband asked me to build so we could keep track of our expenses, but only the frivolous ones like getting coffee or buying something for fun. Here is the link to the github.

Allowance Tracker

My husband asked for an app that has a list of the stuff we purchased, and a way to add to the balance. I drew out some stuff and asked if that’s what he wanted and he said yes:

“But you can just write this stuff down!” “You don’t need an app for that!” “Why are you doing this?” “You don’t need to do this.”

you, the reader of this blog, probably

Okay! You’re right, I don’t need an app for this, but it’s fun 😀 This is a fun exercise that helps me flex my Android skills. Also, it’s super convenient for us to just be able to type in stuff into our phones and have it stored there, then we don’t need to keep track of paper or messy handwriting or anything like that.

What is this app

Let’s take a tour of the app and what it has to offer before I dive into how I built it, shall we? :]

So when you first open the app you have a balance of $400 and you can either start adding purchases with that large button down there, or you can increase the amount in the balance with the small plus button. We have it starting at $400 because that’s how much of an allowance we allowed ourselves each month.

This screen can definitely be improved, and I encourage you to make changes to this and make it better!

For example, there is no empty state for the list. There should be some sort of message for the user telling them that there is nothing in the list. Having it just be empty is not good user experience because they don’t know if there’s just no list, or if it’s because it’s empty. Having an empty state is important and good.

When you tap the “Add Purchase” button it shows a dialog where you can enter the cost and a description of what the purchase was for. When the dialog pops up the “Add Purchase” button goes away because my husband didn’t like that you could technically tap the button again and again when the dialog was up. So I hid it, but that makes the list go up and down because it’s constrained to the top of the “Add Purchase” button. I could and should and will definitely fix this at some point, I just didn’t noticed it until after I built it haha.

Also, you may have noticed the discrepancy between the thing I drew on the post it note and the actual app: there’s no where to put the date of your purchase. I decided against it because dates are hard to handle sometimes and I realized we didn’t really need to put dates anyways. So I just omitted it. If you’d like dates to go along with your purchases feel free to add it!

You can also add to the balance by tapping on the “+” button. It will show a dialog that will ask for how much you’d like to add to the balance. I also added these increases to the balances to the list so you can keep track of how much you added.

AND THAT’S ALL FOLKS!

Seriously, that’s the whole app lol

How did you build it though?

So let’s start talking about how I made this thing.

First thing I did when I created this project was added view binding because I was not going to use findViewById. It’s very simple to use and it’s super nice because it has null safety and type safety and

These differences mean that incompatibilities between your layout and your code will result in your build failing at compile time rather than at runtime.

google documentation

and this is super nice. So of course any time I make a new project I add view binding.

I knew I needed four major things for this app to work the way my husband wanted:

  • A label to show the balance
  • A list of purchases
  • A way to add a purchase (subtract from the balance)
  • A way to add a deposit (add to the balance)

So I built the layouts first because that’s the fun and easy part in Android development.

I don’t think there was anything too crazy about what I built or how I did it. I think the hardest part was adding elevation to the dialog, and I don’t even think I did it correctly, like I think it adds elevation when it’s in Light Mode, but doesn’t when it’s in Dark Mode ¯\_(ツ)_/¯ If you help me fix that I’ll buy you a coffee!

Recycler View

So I used a recycler view for my list of purchases. I really really like the way I made my Adapter for my recycler view and I highly recommend taking a look at my code. Actually, I really want you to look at my Adapter and I wanna talk about it, so we’re going to talk about it real quick:

This is my Adapter class that I use for my recycler.

It’s got a ViewHolder that I can bind nicely to the list of purchases. In the bind function I set the description and cost for the list item.

I dunno it just looks so clean and small and nice I thought I’d share it with you.

The only thing that sucks about this is I use notifyDataSetChanged() and I guess you’re not supposed to use that anymore :[

Also that weird stuff with the TypedArray is there because I wanted to use a color from a theme so that it would be compatible with light/dark mode. Not sure if that’s the best way to do it, but it’s what I found how to do it.

Room

I realized if I wanted to keep this list of purchases and not lose them every time I opened the app I needed to store it somewhere. I’ve used Room before for Vocable so I thought hey why not use it for this too. I mostly followed google documentation for how I implemented my room database. Here’s another resource I used to create my room database.


I did some cleanup and voilà! We got the app going. It’s super simple, it’s taken me maybe 3 full days of work to make this app (probably less). Because Google is so kind and nice they allow you to just slap your app onto your phone no questions asked! So I just put it on my phone and my husband’s phone. He started using it and then asked me for small things like reversing the order of purchases in the list (so newer ones first, older ones last), and to hide the add purchase button. He’s also asked for a widget, which I haven’t gotten to yet.

There’s a ton I can do to make this app better, for example what if you typed something in wrong on your description and you’d like to edit it? What if you want to delete a purchase or a deposit? Right now the app doesn’t handle that stuff, but it can! I should also probably add some unit tests, maybe some UI tests as well, and probably a database migration test because I’ll probably need to change the way my database handles things in the future. I could probably also add in accessibility stuff to my app and make sure it handles things like text getting larger and make sure colors make sense.

This is a fun little project that I did because my husband asked me for it and because I thought it would be a fun exercise. It was fun to build, and I’ll add (and fix lol) stuff in the future.

stuff I did / I’m gonna do

Right now I’m just putting stuff on post its to keep track of things we’d like to add to the app. I know it’s not Jira, but hey it works! If you have any questions on how I did something, or if you would like to contribute to this project please do 😀 Also if you want the actual app I can send you the apk, just contact me or you can download the apk here!

If you add/fix something in this project I will buy you a coffee!!


Cowboy pep 🤠

Thanks for reading, hope to see you in the next blog post! Hopefully I’ll talk to you about HealthKit, but maybe it’ll be about the next fun thing I do. See you there :]

Leave a comment

Design a site like this with WordPress.com
Get started