Skip to content

Instantly share code, notes, and snippets.

{
"data": {
"v1": [
{
"action": "purchase_boost",
"action_text": "Behold the {beans} <- picture of beans",
"header_text": "Beans Icon Test",
"id": "1034",
"image_url": "https://d1brdre1rcy624.cloudfront.net/action_card_images/2021/04/21/cadbury_creme_egg.jpg",
"message_text": "Testing bean image in CTA."
package com.lastminutedevice.gists;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import com.google.firebase.FirebaseApp;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
@Turnsole
Turnsole / add_user_certificate_acceptance.sh
Created June 22, 2020 18:17
Modify Android app to allow user-signed SSL certificates (such as Charles Proxy)
#!/bin/bash
# To use Charles Proxy with SSL:
# (1) On the device, open a browser and visit https://chls.pro/ssl to download a security certificate
# (2) Open the certificate, and when it installs select "VPN and apps"
# (3) Open up wifi settings, under "Advanced" set the proxy address to your laptop's IP address, port 8888
# (4) Run this script from the app module before building the app so that it will allow proxying with a user-installed certificate (such as you installed in step (2))
#
# Don't forget to revert these changes when you're done if you don't mean to commit them.
@Turnsole
Turnsole / adb_commands.txt
Created August 7, 2019 17:13
Handy ADB Commands
// See current activity name
adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'
@Turnsole
Turnsole / gist:ea4ac3a851fa818e2be636d387e62daf
Created August 6, 2019 22:25
Access file storage of any debug build
adb shell
run-as <package name>
@Turnsole
Turnsole / InputErrorHandler.java
Created December 14, 2016 20:08
Delay setting the error message on an EditText. Avoid leaking that View, despite delay.
import android.os.Handler;
import android.os.Message;
import android.support.annotation.NonNull;
import android.widget.EditText;
import java.lang.ref.WeakReference;
/**
* Delay setting the error message on an EditText. Avoid leaking that View, despite delay.
* <p>
@Turnsole
Turnsole / count_words_in_string_resources.py
Created November 12, 2015 19:35
Quick and dirty way to see how many words are contained in an Android string resources file. (I needed an estimate to guess how much hiring a translator would cost.)
import argparse
import re
import sys
regex = re.compile(r'<string .*>(.*?)<\/string>')
def scrape_line(line):
matched = re.findall(regex, line)
if matched is None or len(matched) == 0:
@Turnsole
Turnsole / gist:7dcc7e10673d58c07bb3
Last active August 29, 2015 14:23
Porter and Duff Demonstration
import android.annotation.TargetApi;
import android.app.Activity;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.ImageView;