Skip to content

Instantly share code, notes, and snippets.

View FrancoisBlavoet's full-sized avatar

François Blavoet FrancoisBlavoet

View GitHub Profile
@nickbutcher
nickbutcher / MainActivity.kt
Last active February 22, 2024 21:17
Demonstrating how to tile a (Vector) Drawable
/*
* Copyright 2017 Google Inc.
*
* 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 distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@devunwired
devunwired / FlickerActivity.java
Created December 22, 2016 22:27
Quick Android Things demo using ObjectAnimator to animate the brightness of a PWM output. This example uses a BounceInterpolator to create a flickering effect on an LED (like a candle).
/*
* Copyright 2016 Google Inc.
*
* 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
@mannodermaus
mannodermaus / CompatTextView.java
Last active August 30, 2018 09:59
Custom TextView implementation to allow VectorDrawableCompat to work with compound Drawables
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.AppCompatDrawableManager;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;
@tmelz
tmelz / pre-commit.sh
Last active April 12, 2023 15:09
auto format java files with google-java-format
#!/bin/bash
# Auto format changed java files using google-java-format.
# To install, copy this file into $repo/.git/hooks and remove the .sh extension.
# Download the google-java-format JAR from
# https://github.com/google/google-java-format
# A more mature implementation of this would be a plugin for Yelp's pre-commit library:
# http://pre-commit.com/
echo "Running auto-formatter for any changed Java files"
echo "(formatting changes will be automatically added to your commit)"
@lopspower
lopspower / README.md
Last active May 11, 2022 02:47
Android Tools Attributes

Android Tools Attributes

Twitter

Android has a dedicated XML namespace intended for tools to be able to record information in XML files, and have that information stripped when the application is packaged such that there is no runtime or download size penalty. The namespace URI is http://schemas.android.com/tools and is usually bound to the tools: prefix:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
@onyxmueller
onyxmueller / strip_android_png_metadata.sh
Last active October 25, 2015 11:13
A Bash shell script to strip metadata from Android PNG resources.
#!/bin/bash
#
# Get rid of 'libpng warning: iCCP: Not recognizing known sRGB profile that has been edited' compilation warnings
# from AAPT by running this Bash shell script in the root folder of your Android project. This will use exiftool
# to remove PNG metadata (created by tools like Photoshop) from your Android project's PNG resources.
#
# NOTE: exiftool needs to be installed and in your path. Install it using homebrew or some other method.
#
@rock3r
rock3r / giffify.py
Last active January 14, 2022 09:00
Giffify - easily create optimised GIFs from a video
#!/usr/bin/python
# License for any modification to the original (linked below):
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# Sebastiano Poggi and Daniele Conti wrote this file. As long as you retain
# this notice you can do whatever you want with this stuff. If we meet some day,
# and you think this stuff is worth it, you can buy us a beer in return.
import argparse, sys, subprocess, tempfile
@JohNan
JohNan / QuickReturnRecyclerView.java
Created November 12, 2014 15:38
A simple RecyclerView where a Quick Return view can be added either at the top or the bottom. Inspired by https://github.com/LarsWerkman/QuickReturnListView
import android.content.Context;
import android.os.Build;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.TranslateAnimation;
import android.widget.FrameLayout;
@JakeWharton
JakeWharton / AutoGson.java
Last active November 28, 2021 12:32
A Gson TypeAdapterFactory which allows serialization of @autovalue types. Apache 2 licensed.
import com.google.auto.value.AutoValue;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Marks an {@link AutoValue @AutoValue}-annotated type for proper Gson serialization.
* <p>
@rallat
rallat / dexmethodcount
Last active March 25, 2024 13:54
Android Dex Method Count more sophisticated scripts that gives you method cound by package @JakeWharton https://gist.github.com/JakeWharton/6002797 and @tsmith https://gist.github.com/tyvsmith/6056422
You can add this to your shell profile and then use it as dexcount file.
This file should have a classes.dex in order to work, that means it has to be a android lib project or android apk.
count(){
mkdir temp >/dev/null
cp $1 temp/$1+copy > /dev/null
unzip temp/$1+copy -d temp/ > /dev/null
cat temp/classes.dex | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'
rm -R temp > /dev/null
}