Skip to content

Instantly share code, notes, and snippets.

View tiwiz's full-sized avatar

Roberto Orgiu tiwiz

View GitHub Profile
@tiwiz
tiwiz / ChangeLocale.java
Created August 23, 2016 10:29
Change locale of the app
private void setLocale(String language, String country) {
Locale locale = buildLocaleWith(language, country);
Resources res = InstrumentationRegistry.getContext().getResources();
Configuration config = res.getConfiguration();
setLocaleInto(config, locale);
res.updateConfiguration(config, res.getDisplayMetrics());
}
@NonNull
private Locale buildLocaleWith(String language, String country) {
@tiwiz
tiwiz / debug_layout.sh
Created July 11, 2016 13:59
This script is a faster way to enable and disable debug layout. Just run it and it will toggle the debug layout.
#!/bin/bash
adb shell setprop debug.layout true
adb shell am start com.android.settings/.DevelopmentSettings
adb shell input keyevent 4

Keybase proof

I hereby claim:

  • I am tiwiz on github.
  • I am tiwiz (https://keybase.io/tiwiz) on keybase.
  • I have a public key whose fingerprint is EE83 0A02 F863 BF6C AE5D FA37 A3AC 13C1 7DE5 62DF

To claim this, I am signing this object:

@tiwiz
tiwiz / grabdng.py
Created March 21, 2016 11:24 — forked from rock3r/grabdng.py
Grabs all DNG files from the connected Android device's camera roll
#!/usr/bin/python
import argparse, os, subprocess
# Grab the script directory to use as default
current_directory = os.path.dirname(os.path.abspath(__file__))
def parse_cli_arguments():
parser = argparse.ArgumentParser(description = 'Grabs all DNG files from the connected Android device\'s camera roll.')
@tiwiz
tiwiz / AndroidManifest.xml
Created November 23, 2015 16:03
Draw over other apps on Android 6
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
@tiwiz
tiwiz / build.gradle
Last active June 12, 2018 19:26
How to make Retrolambda work with both Mac OS X and Windows. Thanks to @Takhion - https://gist.github.com/Takhion/5c0f6c0c5aba9db5a488
import org.gradle.internal.os.OperatingSystem;
String getJavaHome(String version) {
def stdout = new ByteArrayOutputStream()
exec {
commandLine "/usr/libexec/java_home", "-v", version
standardOutput = stdout;
}
return stdout.toString().trim()
}
@tiwiz
tiwiz / Builder
Created June 22, 2015 15:06
This is a Builder template (as in Android's Dialog.Builder) for IntelliJ/Android Studio. To import it, open any Java file and right click on an empty space. Go then to Generate > Getter and Setter and click on the "..." button on the Setter's line. From there create a new template with the "+" icon and paste this code
#set($paramName = $helper.getParamName($field, $project))
public ##
#if($field.modifierStatic)
static void ##
#else
$classname ##
#end
set$StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))($field.type $paramName) {
#if ($field.name == $paramName)
#if (!$field.modifierStatic)
@tiwiz
tiwiz / build.gradle
Last active August 29, 2015 14:22 — forked from Takhion/build.gradle
String getJavaHome(String version)
{
def stdout = new ByteArrayOutputStream()
exec {
commandLine "/usr/libexec/java_home", "-v", version
standardOutput = stdout;
}
return stdout.toString().trim()
}
@tiwiz
tiwiz / Script
Created June 6, 2015 08:18
Implementing Crashlytics on a multiflavour and multi-key environment
final File fabricFile = file("fabric.properties")
afterEvaluate {
android.applicationVariants.all { variant ->
final String variantName = variant.getName().capitalize()
final Task targetTask = tasks["process${variantName}Manifest"]
if (fabricTask != null) {
final Task generateFabricFile = task("generateFabricFile$variantName") {
doLast {
String fabricApiSecret = 'verySecretApiSecretForEveryoneGuessItsNotThatSecret'
@tiwiz
tiwiz / tabname.md
Last active August 29, 2015 14:05
Add name for the current tab of Terminal in Mac OS X

#Set a custom name for the current Tab on Mac OS X terminal alt text

Open your ~/.bash_profile file and add the following lines:

function tabname {
	printf "\e]1;$1\a"
}

Then, save the file and close the editor and invoke source ~/.bash_profileon a terminal window.