Android Team Coding Standards

These guidelines should be followed when writing Java and Kotlin code for the Android platform. Patches and additions to any code base will be checked for adherence to these guidelines. If code is in violation, you will be asked to reformat it. For Android Studio you can import the this code style scheme: Vokal.xml (Preferences > Editor > Code Style > Manage... > Import...)

There are separate documents for Java Code Standards, Kotlin Code Standards, and Android Resource Formatting Standards

Naming Guidelines

    vokalApi[‘IO’] and not vokalApi[‘Io’]
    vokalApi[‘Api’]

Coding Style

, . ; : { } ( [ = < > ? ! + - * / % ~ ^ | & == != <= >= += -= *= /= %= ^= |= &= << >> || && === !== <<= >>= >>> >>>=
    String someMessage = (conditional) ? "This is the message when some thing is true"
                                       : "This is the message when some thing is false!";
    if (condition) {
        callSomeFunction(args);
    }
    adLayout = (RelativeLayout) findViewById(R.id.ad);
    public void foo() {
        if (condition) {
            ...
        } else if (condition) {
            ...
        }

        while (condition) {
            ...
        }
    }
    int total = x + 2;
    String someString = otherString + anotherString;
    if(variable == 14.76) {
        ...
    }
import android.content.Context;
import android.os.Bundle;
import android.view.View;

import java.util.ArrayList;
import java.util.HashMap;

import org.json.JSONObject;

import com.vokal.myapp.MyClass;

MVP

    showLoadingDialog()
   onLoginButtonClick()

Implementation Guidelines

Commenting

        i = 0; // Set i to zero.