Tag Archives: android

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

Moving Files from one Git Repository to Another, Preserving History

Once upon a time all my Android apps and VMSoft related stuff were part of one big BitBucket git repository along with an issue tracker. This was a good idea when being an Android dev was just a hobby for the weekends and not my primary job.

Enough rambling πŸ™‚ , this blog post is about moving files from one git repository to another and preserving your history.

Our goal is to move a single directory from one big Git repository to it’s own repository, we would like to preserve the commits history for that specific directory also.

In this example our big repo willΒ  be called A and our new repo that will host it’s own subset of files will be calledΒ B

First filter the files from the big repoΒ (A) by leaving only the ones you need:

git clone < repo A url >
cd < repo A directory >

Remove the “origin”

git remote rm origin

and filter A by < directory_to_move >. This action will go trough all the history and files and remove anything that’s not in < directory_to_move >.
More info on the inner workings of git filter-branch here.

git filter-branch --subdirectory-filter <directory_to_move> -- --all

filter-branch will leave you with the contents of < directory_to_move > in the root of repository A. Commit the changes and we can continue with the next step.

git add .
git commit

Moving to the new repository

Link repo A with repo B. The command below will make repository A branch of repository B.

git remote add repo-A-branch <git repository A directory>

Pull from the branch allowing unrelated histories

git pull repo-A-branch master --allow-unrelated-histories

and finally remove repo-A-branch

git remote rm repo-A-branch

That’s it, you now have your files in a new repository while preserving commits history.

Every opacity value hex code

I often work with HEX colors and want to apply some alpha to them.

Calculating the exact alpha HEX value is tedious job so here it is: the complete list of every possible opacity value in HEX

100% β€” FF
99% β€” FC
98% β€” FA
97% β€” F7
96% β€” F5
95% β€” F2
94% β€” F0
93% β€” ED
92% β€” EB
91% β€” E8
90% β€” E6
89% β€” E3
88% β€” E0
87% β€” DE
86% β€” DB
85% β€” D9
84% β€” D6
83% β€” D4
82% β€” D1
81% β€” CF
80% β€” CC
79% β€” C9
78% β€” C7
77% β€” C4
76% β€” C2
75% β€” BF
74% β€” BD
73% β€” BA
72% β€” B8
71% β€” B5
70% β€” B3
69% β€” B0
68% β€” AD
67% β€” AB
66% β€” A8
65% β€” A6
64% β€” A3
63% β€” A1
62% β€” 9E
61% β€” 9C
60% β€” 99
59% β€” 96
58% β€” 94
57% β€” 91
56% β€” 8F
55% β€” 8C
54% β€” 8A
53% β€” 87
52% β€” 85
51% β€” 82
50% β€” 80
49% β€” 7D
48% β€” 7A
47% β€” 78
46% β€” 75
45% β€” 73
44% β€” 70
43% β€” 6E
42% β€” 6B
41% β€” 69
40% β€” 66
39% β€” 63
38% β€” 61
37% β€” 5E
36% β€” 5C
35% β€” 59
34% β€” 57
33% β€” 54
32% β€” 52
31% β€” 4F
30% β€” 4D
29% β€” 4A
28% β€” 47
27% β€” 45
26% β€” 42
25% β€” 40
24% β€” 3D
23% β€” 3B
22% β€” 38
21% β€” 36
20% β€” 33
19% β€” 30
18% β€” 2E
17% β€” 2B
16% β€” 29
15% β€” 26
14% β€” 24
13% β€” 21
12% β€” 1F
11% β€” 1C
10% β€” 1A
9% β€” 17
8% β€” 14
7% β€” 12
6% β€” 0F
5% β€” 0D
4% β€” 0A
3% β€” 08
2% β€” 05
1% β€” 03
0% β€” 00

How to use it:
#000000 – Black with ought opacity
#17000000 – Black with 9% opacity

Recompile with -Xlint in Android studio

Staying out of deprecated methods is useful, so your app won’t run in some compatibility mode on the device. Plus having clean build output is also nice πŸ™‚

While building an app, Gradle may produces some warnings telling you that some input files are using unchecked or unsafe operations or they are overriding a deprecated API.

Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

As the message suggest, we should recompile with -Xlint to get more details about the warnings.

In the app level build.gradle file

app level build.gradle file

we should add a section labelled  allprojects{}(if not already present).

In the allprojects{} section we will instruct Gradle to apply custom compiler arguments for each task involving  Java code compilation.

allprojects {
    tasks.withType(JavaCompile) {
        options.compilerArgs &lt;&lt; "-Xlint:unchecked" &lt;&lt; "-Xlint:deprecation"

Now each time we build our app we will get detailed output of the unchecked or unsafe operations and the deprecated API we are using.

Tip: if for some reason we want to continue using a deprecated API and just suppress the warnings, we could annotate the deprecated method with the



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.