DEV Community

Cover image for HacktobeferFest:2019 Completed
Subbu Lakshmanan
Subbu Lakshmanan

Posted on

HacktobeferFest:2019 Completed

Yeah, I did it, 2nd time completing Hacktoberfest. It's been extra fun working on Hacktoberfest this year (extra special coz., I had loads of fun working on a puzzle game in android).

First of all, Huge thanks to DigitalOcean and dev.to for organizing the Hacktoberfest 2019. Of course, the primary objective of my participation is to get the cool T-Shirts & Sticker and a self-gratifying of human behavior of achieving something. But along the way, I felt a bit happy about contributing to somebody's work and giving it back to the community.

It all started with one of our dev.to community buddy
Beautus S Gumede's question regarding how to write test cases a year back.

I was much more active in 'dev.to' than nowadays. What started as answering to a question, led me to complete Hacktoberfest in 2018.

I started this year early. So the Hacktoberfest plan for this year is.

# Plan

- [x] Identify repos to contribute (Criteria: Android, Java/Kotlin, Easy/Medium difficulty)
- [x] Follow best coding practices & use conventional commits for git commits
- [x] Submit PRs
- [x] Get the HacktoberFest T-Shirt

Learnings

Lesson 1: You can learn a lot of new things when you review a repo & fix/add things

Issue

Build fails on Android Studio 3.4.x and 3.5, since libraries officially migrated to `androidx` #1

Thank you so much for publishing this wonderful guide with source code!

Would you be so kind as to do a quick update, please? There were significant changes in the Android development world since your post in January 2019.

For instance, as of May 2019, Google recommends Kotlin for new development of Android apps-- you were one step ahead! Migration to androidx is out of preview and official, such that android.support.v7.app becomes androidx.appcompat.app, etc. As noted in comments to the blog post, there are deprecation warnings when running the python-based utilities.

Would you also note library versions used, please?

The Rust parts seem fine as of rustc v1.37.0, as expected.

As I'm new to both Kotlin and Android development, it would be a while before I'd be able to submit a PR with any confidence for this issue-- sorry.

Thanks!

Several of my PRs focussed on improving the existing code by addressing lint warnings & suggestions based on my experience. Most of the lint warnings are pretty evident, and the android studio can help in resolving those. The below one was something I didn't come across and was glad to be bumped with the error. It allowed me to learn something new.

While working on the 'MEME' app, I came across the below deprecation as a result of running 'lint.'

Environment.getExternalStorageDirectory() is deprecated in SDK 29

From a quick research, found out baseContext.getExternalFilesDir("directory_name_to_create") can be used. And from the logs, able to understand the differences of their implementation as well.

10-15 15:31:05.328 27301-27301/com.example.lenovo.meme D/Test: Directory Path: baseContext.getExternalFilesDir("Meme"): /storage/emulated/0/Android/data/com.example.lenovo.meme/files/Meme
10-15 15:31:05.333 27301-27301/com.example.lenovo.meme D/Test: Environment.getExternalStorageDirectory(): /storage/emulated/0

Pull Requests

hotfix: Addresses Lint Warnings #20

  • Cleans up unused import statements
  • Applies appropriate scope qualifiers (i.e., private) for variables & functions
  • Moves hard-coded strings to String.xml & consts as required
  • Cleans up Regular expressions by removing unnecessary character escapes

Note:

  1. Almost all of the fixes were applied automatically through Android Studio's Auto-Suggestions which made sense & appropriate. None of the changes should affect the functionality of the app. No files were removed, although there were unused files & references.
  2. Reports character escapes that are replaceable with the unescaped character without a change in meaning. Note that inside the square brackets of a character class, many escapes are unnecessary that would be necessary outside of a character class. For example the regex [.] is identical to [.]
  3. None of the changes should affect any functionality. But in case of any doubt, any change can be removed, analyzed & applied on another iteration.

Reference: #16

Migration to Latest Dev Tools #11

  • Migrates to 'kotlin' from 'java'
  • Upgrades gradle & gradle wrapper
  • Updates the compile & target SDK to fix warnings
  • Moves from 'appcompat' to 'androidx' library usage
  • Moves hard coded strings to 'Strings.xml'
  • Removes unused resources
  • Fixes Lint warnings
  • Fixes typos

This commit migrates the code base to the latest android development tools before adding new features. This will enable building new features quickly and attact more developers to work on.

The migration is done as follows,

  1. Making use of Android Studio's tools: 'Convert Java to Kotlin' & 'Migrate to AndroidX'
  2. Analyze the project using lint and apply auto-suggesions wherever possible
  3. When auto-suggestion isn't available, apply sensible changes manually

Preview: Gets deleted after 30 days from Oct 15

Lesson 2: Be conscious of the boundaries when proposing the changes & ask first

Issue

redesign/modify UI and UX #6

Interested people can redesign UI/UX for a better user experience. The current UI has a single page for all the activities and looks space deficient. Providing different pages for all the activities would provide a better control over the app.

Also, one thing I learned this year was to be conscious of the boundaries & propose the changes. Although the primary goal of an owner/maintainer of a repository to get their bugs fixed, the implementation we provide may not align with what they need/requirements some times.

While working on this 'MEME' app, the question the maintainer was related to the UI/UX change. I had a pretty good idea for the UX flow, so I planned to work on it. However, I noticed that the app was written in Java, and as Google has been promoting Kotlin, I felt it would be better to migrate to 'Kotlin.' So I migrated the app from Java to Kotlin and worked on my idea and submitted PR.

But as I was working, I realized that I didn't check with the maintainer if he wished to migrate to 'Kotlin.' I opened up a discussion with the maintainer, and as I expected, he didn't want to migrate to Kotlin. No hard feelings; of course, the maintainer of a repo retains the right to decide what's best.

In any case, I submitted the PR as I wanted to increase the hacktoberfest count (to be honest). I added the idea & shared a video of the new UX in the comments, in case the maintainer wants to take a look.

I wish I asked the maintainer before starting working on the issue if he wanted to migrate the app from Java to Kotlin. In any case, it was fun to work.

Lesson 3: Contributing is more fun when you work on a game

Issue

The most fun I had was working on this repo: Memory-Game, which was a single screen memory based puzzle game. The repository was already in 'kotlin,' and I got a couple of ideas of extending the concept. I proposed a simple idea of providing 'difficulty' and let the user choose and play. Another idea was to allow the user to start at the beginner level and increase the difficulty as he finishes each level. I submitted PRs for both, and It was enjoyable working on this app.

Pull Requests

Migration to Latest Dev Tools #12

feat: Migration to Latest Dev Tools

- Upgrades gradle & gradle wrapper
- Updates the compile & target SDK to fix warnings
- Moves from 'appcompat' to 'androidx' library usage
- Moves hard coded strings to 'Strings.xml'
- Fixes Lint warnings

This commit migrates the code base to the latest android development tools before adding new features.

The migration is done as follows,

- Analyze the project using lint and apply auto-suggesions wherever possible
- When auto-suggestion isn't available, apply sensible changes manually

Simple Game Idea with three challenge levels #13

feat: Simple Game Idea with three challenge levels

- Adds new launcher activity with challenge levels
- Replaces the hard-coded number of tiles & tries with flexible number based on challenge

The idea is to present the user with three challenge levels

1. Easy
2. Medium
3. Hard

Based on the user choice, set the number of tiles & max. number of tries. The user can play as many times as he wants in the current challenge level. To choose a much challenging level, he has to go back to the start of the app and change and continue playing. We can track how quickly user clears a challenge and award points/stars.

For now,

Easy -> 4 tiles, 4 tries
Medium -> 6 tiles, 6 tries
Hard -> 8 tiles, 8 tries

The number of tiles & tries are chosen as the same for simplicity but can be improved.

Screenshots:

Start

memorygame-GameActivity-challenges

Easy

memorygame-GameActivity-easy

Medium

memorygame-GameActivity-medium

Hard

memorygame-GameActivity-hard


Game with progressive levels #14

feat: Game with progressive levels

- Adds 'level' to the game to track the current level
- Shows 'current level' before starting a game
- Makes dialog dismiss listener as optional to avoid the need of additional listener
- Removes code imported from simple game branch

The idea of the game is to start with level 1 and increase difficulty as you win.

Level 1..3 -> 4 tiles & 4 tries
Level 4..7 -> 8 tiles & 8 tries
Level 8..20 -> 10 tiles & 10 tries

Games starts with level 1 and as the player wins the game, he's taken to next level. Once the max level is reached, the game will end. As of the max level is set to 10.

Level 1

memorygame-level-1

Level 4

memorygame-level-4

Level 8

memorygame-level-8

Game Completion

memorygame-complete

Hacktober Completion Status

Latest comments (0)