Android, Java, Open Source

Release 0.3 – PR#2; A bug and a squash!


This PR is quite special to me – it’s a PR that resulted from me filing a bug and actually fixing it. Sure it is a small bug, but this achievement made me happy because I was able to actually see my fix and not have it break any other components of the app itself. The Issue that I filed can be found here(Bug with Daily Quotes when user starts the app) and the corresponding PR – the proposed fix – can be found here. Since I filed the bug report itself, I knew exactly the process involved to replicate the bug and those steps are listed in the Issue linked above. Put simply, here’s a demonstration of the bug occurring:


Squashing It

In total, it took me about 2 hours to fix the problem. The first step is of course simple – Android Studio had a ‘Find’ feature that can be used to search for files that contains the target keyword. Since I’ve already worked with TravelMate before (See Release 0.2), I knew that the name involved ‘DailyQuotes’ so I used that as a keyword, a bunch of files came up, I quickly skimmed those files and found the appropriate one – In the codebase and in Android development, Fragments are used as a type of representation for the User Interface (UI)  known for their flexibility – compared to the traditional UI option of using Intents and multiple app pages as UI, with a Fragment, you only need to ‘hook’ it up to an Activity file and you can reuse that same Activity file to host other fragments, thereby allowing you to host multiple fragments with one Activity – saving computing resources and programming resources as you don’t need to create multiple Intents and corresponding app pages anymore.

The fix itself is pretty simple, but the discovery of it isn’t quite so much as simple, as seen here:


The reason why the ‘Do Not Show’ button wasn’t working as intended is because the doNotShowClicked() function isn’t working properly. My first guess on the root of the bug was pretty close enough though – I thought there was something wrong with the closeQuoteFragment() function at first and after repeated trial and errors, I confirmed that the problem didn’t lie there. Then as I experimented with the doNotShowClicked(), I discovered that the conditional statements themselves were causing the error – something obviously isn’t being satisfied hence why the DailyQuoteManager.dontShowQuotes(getContext()) and closequoteFragment() weren’t working properly. Since I wanted a clear fix that wouldn’t mess up everything else and leave the code as a future reference (in case something breaks again), I just decided to comment out the code, directly calling DailyQuoteManager.dontShowQuotes(getContext()) and closequoteFragment() instead of having a conditional statement before they’re called. Of course, it worked:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s