My first experiences with Kotlin: some quick notes that might comes handy for beginners

Standard

Checkout my Article about “My first experiences with Kotlin some quick notes that might comes handy for beginners” @ medium.com:

My first experiences with Kotlin

Creating a quick fancy Android application prototype Using Framer

Standard

Checkout my Article about “Creating a quick fancy Android application prototype Using Framer for Android prototyping” @ medium.com:

Creating a quick fancy Android application prototype

A useful memory debugger plugin for Android Studio

Standard

Checkout my Article about “JetBrains JVM Debugger Memory View plugin: A useful memory debugger plugin for Android Studio” @ medium.com:

A useful memory debugger plugin for Android Studio

 

MVP — How to present different errors on View Layer using only one method?

Standard

Checkout my Article about “How to present different errors on View Layer using only one method @ medium.com:

MVP — How to present different errors on View Layer using only one method?

Yet another MVP article…

Standard

Checkout my 5-part Article about MVP methodology in Android development @ medium.com:

Part 1: Lets get to know the project

Part 2: How Dagger helps with the project

Part 3: Calling APIs using Retrofit

Part 4: RxJava and RxAndroid know how to response

Part 5: Writing Test using a mixture of Dagger and Espresso

Android Utils

Standard

This is a utils library for Android Applications containing useful methods.
AndroidUtils class help you to interact with different parts of android os without writing many codes and as simple as possible.

Github_LogoGithub repo:
https://github.com/mirhoseini/android_utils

Grab via Maven:

<dependency>
 <groupId>com.mirhoseini.utils</groupId>
 <artifactId>utils</artifactId>
 <version>1.0.7</version>
 <type>pom</type>
</dependency>

or Gradle:

compile 'com.mirhoseini.utils:utils:1.0.7'

How to setup CircleCI environment JAVA7_HOME, JAVA6_HOME for RetroLambda

Standard

Using retrolambda in Android application being built using circleci as continuous integration cause some issues:

> Building 10%When running gradle with java 8, you must set the path to the old jdk, either with property retrolambda.oldJdk or environment variable JAVA5_HOME/JAVA6_HOME/JAVA7_HOME

The problem is you have to configure environment variables for Java_Home, Java7_Home, Java6_Home and etc in circleci virtual machine.

this circle.yml file could help you in this regard:

#
# Build configuration for Circle CI
#

general:
    artifacts:
        - /home/ubuntu/weather_app/app/build/outputs/apk/
        - /usr/lib/jvm/

machine:
    environment:
        ANDROID_HOME: /usr/local/android-sdk-linux
        JAVA6_HOME: /usr/lib/jvm/java-6-openjdk-amd64

    java:
      version: openjdk8

dependencies:
    override:
        - echo y | sudo apt-get update
        - echo y | sudo apt-get install libpango-1.0-0
        - echo y | sudo apt-get install openjdk-6-jre

        - echo y | android update sdk --no-ui --all --filter tools,platform-tools,build-tools-23.0.3,android-23,extra-google-m2repository,extra-google-google_play_services,extra-android-support
        - ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies

test:
    override:
        - (./gradlew assemble):
            timeout: 360

        - (./gradlew test):
            timeout: 360

How to add Vector image support to old Android versions using new AppCompat?

Standard

Finally we had vector support for all Android versions, 8-)

  • bye bye all different PNG size files in different drawable folders!
  • bye bye FontAwesome!
  1. first of all add these dependencies to your module’s build.gradle:
dependencies {
    .
    .
    .
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:support-vector-drawable:23.3.0'
  1. add this to your android defaultConfig tag in your module’s build.gradle:
android {
    .
    .
    .

    defaultConfig {
        .
        .
        .
        vectorDrawables.useSupportLibrary = true
    }
  1. replace all your ImageView with android.support.v7.widget.AppCompatImageView
    and ImageButton with android.support.v7.widget.AppCompatImageButton in all your project’s xml layouts.

  2. replace all android:src attribute in all ImageView with app:srcCompat.

  3. now import your vector image using New -> “Vector Asset” submenu by right clicking on your drawable folder…

That’s it!!!

Best practise for Logcat colours in Android Studio!

Android Studio Logcat color scheme Preferences
Standard

I know that using solid black colour logcat in Android Studio  is awful !!!

Here is my best practice colour codes that you can use for changing the face of you logcat in Android Studio to make it more useful. go to Android Studio Preferences and search for logcat and save as your own scheme:

Assert9C27B0
Debug2196F3
ErrorF44336
Info4CAF50
WarningFFC107

All colours are picked from material design colour pattern: https://www.google.com/design/spec/style/color.html

App Settings

Standard

This is a best practice for Android Applications Config Management using Shared Preferences.
AppSettings class help you to manage deferent types of data in your application and load them in memory for faster use also save them in shared preferences for next run.

  • Eliminate SharedPreferences and Editor Commits calls.
  • Different method ovverride to set and get all data types.
  • Allow to use different XML files for saving and accessing settings.

Github_LogoGithub repo:
https://github.com/mirhoseini/app_settings

// load saved values
 private void loadValues() {
 etName.setText(AppSettings.getString(this, KEY_NAME, ""));
 spAge.setSelection(AppSettings.getInt(this, KEY_AGE, 0));
 rbMale.setChecked(AppSettings.getBoolean(this, KEY_IS_MALE, true));
 rbFemale.setChecked(!AppSettings.getBoolean(this, KEY_IS_MALE, true));
 sbWeight.setProgress((int) (AppSettings.getFloat(this, KEY_WEIGHT, 0f) * WEIGHT_FACTOR));
 }

 // clear saved values
 private void clearValues() {
 AppSettings.clearValue(this, KEY_NAME);
 AppSettings.clearValue(this, KEY_AGE);
 AppSettings.clearValue(this, KEY_IS_MALE);
 AppSettings.clearValue(this, KEY_WEIGHT);

 loadValues();
 }

 // save input values
 private void saveValues() {
 AppSettings.setValue(this, KEY_NAME, etName.getText().toString().trim());
 AppSettings.setValue(this, KEY_AGE, spAge.getSelectedItemPosition());
 AppSettings.setValue(this, KEY_IS_MALE, rbMale.isChecked());
 AppSettings.setValue(this, KEY_WEIGHT, (float) sbWeight.getProgress() / WEIGHT_FACTOR);
 }

Grab via Maven:

<dependency>
 <groupId>com.mirhoseini.appsettings</groupId>
 <artifactId>appsettings</artifactId>
 <version>1.0.1</version>
 <type>pom</type>
</dependency>

or Gradle:

compile 'com.mirhoseini.appsettings:appsettings:1.0.1'