Skip to content

Instantly share code, notes, and snippets.

View pratamawijaya's full-sized avatar

Pratama Nur Wijaya pratamawijaya

View GitHub Profile
@pratamawijaya
pratamawijaya / checkGooglePlayServicesAvailable.java
Created November 27, 2016 06:59
Android: Check whether Google Play Services are installed and current
/**
* Check whether Google Play Services are available.
*
* If not, then display dialog allowing user to update Google Play Services
*
* @return true if available, or false if not
*/
private boolean checkGooglePlayServicesAvailable()
{
final int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
@pratamawijaya
pratamawijaya / checkstyle.xml
Created November 22, 2016 09:02 — forked from alpargabos/checkstyle.xml
Checkstyle-checkstyle.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!-- This is a checkstyle configuration file. For descriptions of
what the following rules do, please see the checkstyle configuration
page at http://checkstyle.sourceforge.net/config.html -->
<module name="Checker">
@pratamawijaya
pratamawijaya / .gitlab-ci.yml
Created November 17, 2016 13:56
CI Gitlab Android
image: pratamawijaya/gitlab-ci-android
stages:
- check
- build
- deploy
before_script:
- export GRADLE_USER_HOME=/cache/.gradle
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import com.google.android.gms.common.ConnectionResult;
package nl.remcomokveld.firebaseloaders;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.content.Loader;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.ValueEventListener;
@pratamawijaya
pratamawijaya / Utils.java
Created October 24, 2016 04:32
Spannable TextView set color to text
private void setColor(TextView view, String fulltext, String subtext, int color) {
view.setText(fulltext, TextView.BufferType.SPANNABLE);
Spannable str = (Spannable) view.getText();
int i = fulltext.indexOf(subtext);
str.setSpan(new ForegroundColorSpan(color), i, i + subtext.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
@pratamawijaya
pratamawijaya / SignatureCheck.java
Created October 17, 2016 09:45 — forked from scottyab/SignatureCheck.java
Simple Android signature check. It's not bullet proof but does increase the difficulty of backdooring the app
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.Signature;
public class TamperCheck {
//we store the hash of the signture for a little more protection
private static final String APP_SIGNATURE = "1038C0E34658923C4192E61B16846";
<templateSet group="AndroidLog">
<template name="time" value="Timber.e(&quot;$METHOD_NAME$() : $content$ %s&quot;,$exception$);" description="Timber.e(Method,Exc)" toReformat="true" toShortenFQNames="true">
<variable name="METHOD_NAME" expression="methodName()" defaultValue="" alwaysStopAt="true" />
<variable name="content" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="exception" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template name="timd" value="Timber.d(&quot;$METHOD_NAME$() : $content$ %s&quot;,$exception$);" description="Timber.d(Method,exc)" toReformat="true" toShortenFQNames="true">
@pratamawijaya
pratamawijaya / build.gradle
Created September 27, 2016 23:54 — forked from ph0b/build.gradle
sample build.gradle for generating split APKs per ABI
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig{
minSdkVersion 14
targetSdkVersion 21
versionCode 101
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
tools:context="com.pratama.examplelayouting.MainActivity"
>
<LinearLayout