Tag Archives: java

15 Number puzzle sliding game version 2.0 released

I’m happy to announce that a new version of Numbers puzzle / 15 Puzzle (Game of Fifteen) is now available on Google Play.

15 Number puzzle sliding game

What’s new

* Redesigned/improved interface with beautiful animations
* Dark mode
* Android 13 support
* New 5×5, 7×7, 10×10 game board sizes. 10×10 puzzle is available on 7″ and 10″ inch tablets
* Fixed issue where some puzzles may be unsolvable.
* Pause and continue playing option
* Statistics for all game board sizes

Get it on Google Play

Android, Smartphone, Android Developer, Android Studio

Auto ‘versionCode’ increment when building production apk’s

Since I adopted Fabric as a way to monitor vital app stats such as ‘Time in App per User‘ and it’s Beta distribution platform to distribute test builds, increasing APK’s versionCode numbers became a tedious task.

I decided to simplify the things by letting Gradle to do auto versionCode increments when producing release APK’s

Our implementation of build number increments will consist of a property file named version.properties located in the root folder of our project.

The property file will contain 2 variables, one defining the version name such as “2.3” and one defining the version code such as 15


In our app module build.gradle file


we will define a function which takes care of retrieving the a bough mentioned values from the properties file and increment the VERSION_CODE if needed.

 * Get's value from 'version.properties' file
 * @param varName the name of the variable which value we wan't to get.
 * @return the variable value.
def getVersionPropertiesValue(def varName)
    def propertiesFile = file('version.properties')
    if(!propertiesFile.canRead()) {
        throw new GradleException("Could not read " + propertiesFile.name)
    Properties properties = new Properties();
    properties.load(new FileInputStream(propertiesFile))
    def propertyValue = properties[varName]
    if(varName == 'VERSION_CODE')
        // If we are building release increment the version code
        List gradleTasksNames = gradle.startParameter.getTaskNames();
        for(String taskName : gradleTasksNames)
                propertyValue = propertyValue.toInteger() + 1
                properties[varName] = propertyValue.toString()
                properties.store(propertiesFile.newWriter(), null)
    return propertyValue

In the defaultConfig section of the gradle build script we will call this function to retrieve values for the versionName and versionCode of our app.

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.foo"
        versionCode Integer.valueOf(getVersionPropertiesValue('VERSION_CODE'))
        versionName getVersionPropertiesValue('VERSION_NAME')
        minSdkVersion 14
        targetSdkVersion 28

Now each time a release build is made, the version code will increment automatically. If we want to change the version name we can do so by changing the value of VERSION_NAME property.

Java: Parts of the Day

A handy utility method that will return the part of the day, such as morning, afternoon, evening, etc.

public static String getPartOfTheDay(final int hour)
    if(hour > 4 && hour < 12)
        if(hour <= 8)
            return "Early Morning";
        else if(hour > 8 && hour < 11)
            return "Morning";
        return "Late Morning";        
    else if(hour >= 12 && hour < 17)
        if(hour >= 13 && hour <= 15)
            return "Early Afternoon";
        else if(hour >= 16)
            return "Late Afternoon";
        return "Afternoon";
    else if(hour >= 17 && hour <= 21)
        if(hour <= 19)
            return "Early Evening";
        return "Evening";
        return "Night";

The method is based on the following logic, that many people would agree with:

Morning: 5 to 12

  • Early morning: 5 to 8
  • Late morning: 11 to 12

Afternoon: 12 to 17

  • Early afternoon: 13 to 15
  • Late afternoon: 16 to 17

Evening: 17 to 21

  • Early evening: 17 to 21

Night: 21 to 4

Gentoo Linux: Ugly fonts in NetBeans and how to fix them

I recently installed Gentoo GNU/Linux + KDE 5 on my dev machine. One thing that was bugging me was the crappy font rendering in NetBeans.

To relolve the problem, locate your netbeans.conf file. Usually under /etc in your NetBeans installation folder, and append to netbeans_default_options the follwing:

-J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd --laf Metal

This will enable font smoothing in SWING and use default system settings for font smoothing. The last entry –laf Metal sets the preferred UI theme for the IDE, it should be Swing based theme such as Metal or Numbus.

Happy coding 🙂

GSM Signal Monitor 1.5 out now!

GSM Signal Monitor 1.5 is out now!
This version features new app visual style, additional logging options, bug fixes and Android 5.x and up support.

Version 1.5 Change Log
* New app visual style
* Compatibility with Android 5.x and up
* Fixed bug when clicking over the app notification in the notification area
* GSM Signal monitor will now log (optional) information when the phone is entering roaming state and changes in your mobile data connectivity.
* Fixed bug when no notifications will be made on some devices
* New Google play services version

Get it on Google Play