Skip to content

Instantly share code, notes, and snippets.

View eveliotc's full-sized avatar

Evelio Tarazona eveliotc

View GitHub Profile
@eveliotc
eveliotc / resize.sh
Created August 15, 2012 02:24
Script to batch resize non 9patch images
#!/bin/bash
SRC_DIR=$1; # e.g. res/drawable-xhdpi/
DEST_DIR=$2; # e.g. res/drawable-mdpi/
RESIZE_BY=$3; # e.g. 50%
echo "From $SRC_DIR to $DEST_DIR resize by $RESIZE_BY";
for item in $( ls $SRC_DIR | grep -v '\.9.png$' ); do
echo Resizing: $item
convert $SRC_DIR$item -resize $RESIZE_BY $DEST_DIR$item
done
<!-- res/values/styles.xml -->
<style name="MyCheckbox" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/btn_check</item>
<item name="android:paddingLeft">@dimen/checkbox_padding_left_workaround</item>
<!-- yada yada yada -->
</style>
<!-- res/values/dimens.xml -->
<dimen name="checkbox_padding_left_workaround">50dip</dimen> <!-- or whatever your drawable is -->
<!-- res/values-v17/dimens.xml -->
<dimen name="checkbox_padding_left_workaround">0dip</dimen> <!-- yup, you got it -->
@eveliotc
eveliotc / bad_avatar_overlay.xml
Created July 22, 2013 02:52
A sample of a bad way of doing rounded avatars
<?xml version="1.0" encoding="utf-8"?>
<!-- From post http://evel.io/2013/07/21/rounded-avatars-in-android/ -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
@eveliotc
eveliotc / getRoundedBitmap.java
Created July 22, 2013 03:26
A better yet dirty way of get rounded avatars
public static Bitmap getRoundedBitmap(Bitmap bitmap) {
final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(output);
final int color = Color.RED;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
paint.setAntiAlias(true);
@eveliotc
eveliotc / RoundedAvatarDrawable.java
Created July 22, 2013 04:59
RoundedAvatarDrawable: A Drawable that draws an oval with given {@link Bitmap} See http://evel.io/2013/07/21/rounded-avatars-in-android/
/*
* Copyright 2013 Evelio Tarazona Cáceres <evelio@evelio.info>
*
* 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
@eveliotc
eveliotc / MyActivityOrFragment.java
Created July 29, 2013 15:38
A variant of https://gist.github.com/eveliotc/6051367 to show a drop shadow, should not be used for performance in mind views
final ImageView imageView = (ImageView) view.findViewById(R.id.image);
final int shadowSize = getResources().getDimensionPixelSize(R.dimen.shadow_size);
final int shadowColor = getResources().getColor(R.color.shadow_color);
imageView.setImageDrawable(new RoundedAvatarDrawable(mBitmap, shadowSize, shadowColor));
if (SDK_INT >= HONEYCOMB) {
imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
@eveliotc
eveliotc / README.md
Last active August 29, 2015 14:05 — forked from JoelBesada/README.md

A visited command for Backtick. Injects CSS to visually differentiate regular links from visited ones.

To install Copy 68fbf2e317c8b4b473c3 then Paste it into the custom commands field in the Backtick settings. You can easily access the settings by clicking the Backtick icon on the command execution console.

@eveliotc
eveliotc / android-select-device
Last active February 5, 2019 06:10
My (android) dev aliases and scripts
#! /bin/bash
# from http://dtmilano.blogspot.com/2012/03/selecting-adb-device.html
# selects an android device
PROGNAME=$(basename $0)
UNAME=$(uname)
DEVICE_OPT=
for opt in "$@"
do
case "$opt" in