DEV Community

Tong Liu
Tong Liu

Posted on

Reflect: Release 0.4 3/3

I finally finished implementing the issue of #1057 I selected for Release 0.4. Here is the Pull Request link for it #1157. This issue is the biggest issue I have worked on so far on GitHub, the complexity of this issue also suggests the same way. However, when I look back at what I have done throughout this issue, I found out that it is actually not as terrific as I thought it would be in the first place.

My Pull Request may not be accepted before this class ends

Although I submitted the Pull Request early enough for my Pull Request to get reviewed, the maintainer will not be able to give me a review at any time soon since the project maintainer has been burnt out by the high level of workload during Hacktoberfest 2022 as well as the backlogs of Pull Requests. However, this does not mean that this issue has never become less significant to me, on the contrary, I have learned lots of knowledge of Android including database, Intent mechanism, Data Object serialization, and so on. I may not be able to get my Pull Request accepted for merge, but even after this course ends, I will keep following up with my Pull Request until it's accepted and merged.

What have I achieved in this Issue?

In this issue, I implemented a feature which automatically sets cover images to the card when the user adds a card by scanning a barcode picture in the local gallery. To give the right of selection to users to decide if they want to automatically set the cover images, I also created a dialog to ask if the user wants to set the scanned picture as the cover image. Moreover, if the cover image has already been set by the user, it will not replace the cover image when the user rescans the barcode. To make the app know if the front/back cover image is set by the user, I need to create 2 extra flag variables to the Card Data Entity. Since the Card Data is stored in the database, I also modified the database to save them. However, since the parameters of the data-saving function changed, I have to fix every single line of code that uses it, including the tests which call this function more than 30 times.
Here is the image of the prompting dialog.
Prompting Dialog
And once I clicked yes, the scanned barcode photo will be set as the front or back photo depending on which one has not been set yet.

Automatically set cover image

What I've learned

I have learned a lot of Android knowledge throughout this Issue. It mainly boils down to two points:

  1. Database: This is the biggest thing I've learned. Now I know to create a database I need to create a class that extends SQLiteOpenHelper and DB initialization code(e.g. table creating code) should go into the onCreate() function. To read data from the database, I need to pass a SQL sentence to the function database.query() and use the returned cursor to get specific data with the column name, for example, when I want to get the card's note I call cursor.getString(LoyaltyCardDbIds.NOTE). Another important element of the Android database is "update". To update the database from the old version to the new version, I should override the function onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) and use the SQL sentence ALTER TABLE to add or remove columns from a table based on the version range of the user's database.
  2. Activity Intent: Passing data between Activities can be done by using an Android pre-built mechanism named Activity Intent. Since card editing Activity is shared among the 3 ways of adding cards (adding by scanning with the camera, adding by scanning library photo, and adding by manually inputting). In the adding by scanning library photo mode, I used bundle.putParcelble() to pass the URL of the scanned photo to the card editing activity to tell the card editing Activity that it needs to do the process to automatically add cover photos. It was quite straightforward, but it did take me some time to figure it out.

At the end

DPS909 has been the best course I've ever taken at Seneca College. I'm so happy that I could choose this course to allow me an immersive in-depth experience on GitHub open-source projects.

Top comments (0)