Skip to content

Instantly share code, notes, and snippets.

View stefanhoth's full-sized avatar
:shipit:
Shipping it

Stefan Hoth stefanhoth

:shipit:
Shipping it
View GitHub Profile
SDK_HOME_PATH="$HOME"
SDK_PATH="$SDK_HOME_PATH/android-sdk-linux"
# Needs to be updated when new releases are made
SDK_DOWNLOAD_URL="http://dl.google.com/android/android-sdk_r22.6.2-linux.tgz"
curl --location $SDK_DOWNLOAD_URL | tar -xz -C $SDK_HOME_PATH
# Just install platform-tools, build-tools & Android-19
# Filter names are from `android list sdk -e -a`
@stefanhoth
stefanhoth / LICENSE
Last active October 24, 2015 17:42
Rock Paper Scissors Lizard Spock - Android VectorDrawable definitions based on https://commons.wikimedia.org/wiki/File:Pierre_ciseaux_feuille_l%C3%A9zard_spock_aligned.svg
http://creativecommons.org/licenses/by-sa/4.0/
Creative Commons Attribution-ShareAlike 4.0 International Public License
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
Section 1 – Definitions.
Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licen
@stefanhoth
stefanhoth / GradleWorkersPleaseStopTakingFocus.gradle
Last active August 29, 2015 14:25 — forked from artem-zinnatullin/GradleWorkersPleaseStopTakingFocus.gradle
Prevent Gradle Workers from taking focus! #DevelopersLikeComfort
// You can place it in the root build.gradle
allprojects {
tasks.withType(JavaForkOptions) {
// Forked processes like GradleWorkerMain for tests won't steal focus!
jvmArgs '-Djava.awt.headless=true'
}
}
@stefanhoth
stefanhoth / device_provider.gradle
Last active August 29, 2015 14:21
Allow gradle to only use devices that meet your criteria
android {
...
deviceProvider new AwesomeDeviceProvider(getAdbExe())
}
class AwesomeDeviceProvider extends com.android.builder.testing.ConnectedDeviceProvider {
AwesomeDeviceProvider(File adbLocation) {
super(adbLocation)
}
@stefanhoth
stefanhoth / RootStatus.java
Last active August 29, 2015 14:16
How to detect if an app is launched on a potentially rooted phone in an non-invasive way. It could be improved by checking existence of known super user apk in the package manager and certain build tags of the ROM.
package com.yourapp;
import java.io.File;
public final class RootStatus {
private static RootStatus instance;
private final boolean rooted;
@stefanhoth
stefanhoth / gist:5d6fa521aad322d15d44
Last active August 29, 2015 14:14 — forked from anonymous/gist:1571520dd1aa934fce28
Simple Factory pattern
// The Factory
public final class VehicleFactory {
// private constructor => can't be instanciated, final can't be extended since the constructor is not reachable for a subclass
private VehicleFactory (){
// no-op
}
public static Vehicel Vehicle produceVehicle(String name, String manufacturer, int horsepowerInPS){
return new Vehicle(name, manufacturer, horsepowerInPS);
@stefanhoth
stefanhoth / tools_override.xml
Last active August 29, 2015 14:13
Override a views visibility at design time using the tools namespace. See line 13 how and don't forget to add line 2. See http://tools.android.com/tips/layout-designtime-attributes for details.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/group_image"
@stefanhoth
stefanhoth / build.gradle
Last active March 3, 2017 12:03
Simple plugin for build.gradle to instruct Jetbrains IDEA-based IDEs (IntelliJ, Android Studio) to download sources of the dependencies. More settings can be found here: http://gradle.org/docs/current/dsl/org.gradle.plugins.ide.idea.model.IdeaModule.html
// your code
apply from: "build-plugins/idea-gradle-sources.gradle"
@stefanhoth
stefanhoth / jack.bat
Last active August 29, 2015 14:11
Jack & Jill command line helpers. Put them in a directory in your PATH, e.g. <android-sdk>/. Use .bat files for Windows, .sh for Mac/Linux. More info in the documentation: http://tools.android.com/tech-docs/jackandjill
@ECHO OFF
@REM Jack is only available from build tools version 21.1.0 and up. Install/Update via SDK Manager
SET BUILD_TOOLS_VERSION=21.1.2
java -jar %ANDROID_HOME%/build-tools/%BUILD_TOOLS_VERSION%/jack.jar %1 %2 %3 %4 %5 %6 %7 %8 %9
@stefanhoth
stefanhoth / build.gradle
Created June 11, 2014 06:56
AndroidDev / gradle: How to rename your output apk during build time to include details like the version.
android {
// .. set up build flavors etc here
//instead of "app-release.apk" this method will rewrite the name to
// "MyCoolCompany-MyGreatProduct-v<defaultConfig.versionName>-RELEASE.apk which is much better suited for archiving and overall handling
// To restore the default behavior just delete the whole block below
applicationVariants.all { variant ->
def apk = variant.outputFile;