Skip to content

Instantly share code, notes, and snippets.

@cyrilmottier
cyrilmottier / _app_avelibRelease_res_values_config.xml
Last active November 20, 2020 11:27
Using the new Gradle-based Android build system: an example
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="config_app_name">AVélib</string>
<string name="config_authority">com.cyrilmottier.android.avelib.citybikes</string>
<string name="config_com.google.android.maps.v2.api_key">XXX</string>
</resources>
@orip
orip / build.gradle
Created October 7, 2013 17:52
Define an Android app's versionName and versionCode from git tags. http://orip.org/2013/10/versioning-android-apps-with-git-tags.html
android {
def gitTag = {
def tagMatchOptions
try {
tagMatchOptions = "--match ${tagToBuildFrom}"
} catch (MissingPropertyException) {
tagMatchOptions = ""
}
"git describe --exact HEAD ${tagMatchOptions}".execute().text.trim()
}()
public class Dexter {
private static String optimizedDirectory = "optimized";
private static String workDirectory = "working";
public static void loadFromAssets(Context context, String fileName) throws Exception {
File optimized = new File(optimizedDirectory);
optimized = context.getDir(optimized.toString(), Context.MODE_PRIVATE);
optimized = new File(optimized, fileName);
@frankiesardo
frankiesardo / CustomMatchers.java
Created November 15, 2013 19:20
Espresso & Brioche
public class CustomMatchers {
public static Matcher<View> withBackground(final int resourceId) {
return new TypeSafeMatcher<View>() {
@Override
public boolean matchesSafely(View view) {
return sameBitmap(view.getContext(), view.getBackground(), resourceId);
}
@Override
@Sloy
Sloy / video2gif.py
Last active December 30, 2015 09:59
Este script genera una animación gif a partir de un archivo de vídeo, colocando opcionalmente un fondo en cada frame. Está pensado para convertir los vídeos obtenidos en Android mediante 'adb shell screenrecord' o con la herramienta de Android Studio.
#coding=utf-8
"""
Por: Rafa Vázquez
http://sloydev.com/
Este script genera una animación gif a partir de un archivo de vídeo, colocando opcionalmente un fondo en cada frame.
Está pensado para convertir los vídeos obtenidos en Android mediante 'adb shell screenrecord' o con la herramienta de Android Studio.
Un ejemplo del resultado puede verse en http://i.imgur.com/Opu5aG3.gif
####### start emulators script:
#!/bin/bash
export PATH=$ANDROID_HOME/tools/:$ANDROID_HOME/platform-tools/:$PATH
echo "Android HOME : $ANDROID_HOME"
echo "Android SDK HOME : $ANDROID_SDK_HOME"
echo "PATH : $PATH"
`dirname $0`/kill_android_emulators.sh
@untalfranfernandez
untalfranfernandez / dex-methods.sh
Created April 3, 2014 19:38
Bash script to find out how many methods your .apk file will contain. (Original idea from @rochoa)
#! /bin/bash
if [ $# -ne 1 ]; then
echo
echo " Usage: dex-methods.sh [dex file to explore] "
echo
echo
else
NUMBER=`cat $@ | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'`
echo "The number of methods found is: " $NUMBER
fi
@chrisbanes
chrisbanes / FloatLabelLayout.java
Last active March 15, 2024 06:39
FloatLabelLayout
/*
* Copyright 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@xrigau
xrigau / AndroidManifest.xml
Last active October 22, 2022 02:36
Disable animations for Espresso tests - run with `gradle cATDD`
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.novoda.espresso">
<!-- For espresso testing purposes, this is removed in live builds, but not in dev builds -->
<uses-permission android:name="android.permission.SET_ANIMATION_SCALE" />
<!-- ... -->
@dmarcato
dmarcato / strip_play_services.gradle
Last active December 21, 2022 10:10
Gradle task to strip unused packages on Google Play Services library
def toCamelCase(String string) {
String result = ""
string.findAll("[^\\W]+") { String word ->
result += word.capitalize()
}
return result
}
afterEvaluate { project ->
Configuration runtimeConfiguration = project.configurations.getByName('compile')