Last active
July 17, 2016 22:14
-
-
Save atroutt/0ba1fcaa1370a0435b3c3434141ed1be to your computer and use it in GitHub Desktop.
Convenient script for sucking icons from https://github.com/google/material-design-icons into your Android app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 1. PUT THIS SCRIPT IN YOUR APP's RES folder, for example /Users/myname/Developer/MyAndroidProject/app/src/main/res | |
# 2. UPDATE THIS VARIABLE to point to your local clone of https://github.com/google/material-design-icons | |
# if you don't alread have it git clone git@github.com:google/material-design-icons.git | |
basefolder="/Users/myname/Developer/material-design-icons" | |
# 3. Find Material Icons on https://design.google.com/icons/ and note the group and icon name and use this script to suck them into your project | |
if [ $# -lt 2 ]; then | |
echo "Usage: `basename $0` <icon group> <icon name> <(optional, default black) white/black> <(optional, default 24) 18/24/36/48>" | |
exit 1 | |
fi | |
if [ ! -d "$basefolder" ]; then | |
echo "ERROR: $basefolder does not exist. Update the script to point to your local clone of https://github.com/google/material-design-icons" | |
exit 1 | |
fi | |
color="black" | |
if [ -n "$3" ]; then | |
color=$3 | |
case $3 in | |
white) | |
;; | |
black) | |
;; | |
*) | |
echo "ERROR: $3 is not a valid color. Choose white or black." | |
exit 1 | |
esac | |
fi | |
size="24dp" | |
if [ -n "$4" ]; then | |
size="$4dp" | |
case $4 in | |
18) | |
;; | |
24) | |
;; | |
36) | |
;; | |
48) | |
;; | |
*) | |
echo "ERROR: $4 is not a valid size. Choose 18, 24, 36, or 48." | |
exit 1 | |
esac | |
fi | |
if [ ! -d "$basefolder/$1" ]; then | |
echo "ERROR: $1 is not a icon group. Choose from:" | |
for i in $(ls -d $basefolder/*/); do echo " $(basename "$i")"; done | |
exit 1 | |
fi | |
for f in $basefolder/$1/drawable-mdpi; do | |
d=$(basename "$f") | |
echo "looking for $f/$2_${color}_$size.png" | |
if [ -f "$f/$2_${color}_$size.png" ]; then | |
echo "copying $f/$2_${color}_$size.png" | |
mkdir -vp $d | |
cp -v "$f/$2_${color}_$size.png" "$d/$2.png" | |
fi | |
done | |
for f in $basefolder/$1/drawable-hdpi; do | |
d=$(basename "$f") | |
if [ -f "$f/$2_${color}_$size.png" ]; then | |
echo "copying $f/$2_${color}_$size.png" | |
mkdir -vp $d | |
cp -v "$f/$2_${color}_$size.png" "$d/$2.png" | |
fi | |
done | |
for f in $basefolder/$1/drawable-xxhdpi; do | |
d=$(basename "$f") | |
if [ -f "$f/$2_${color}_$size.png" ]; then | |
echo "copying $f/$2_${color}_$size.png" | |
mkdir -vp $d | |
cp -v "$f/$2_${color}_$size.png" "$d/$2.png" | |
fi | |
done | |
for f in $basefolder/$1/drawable-xxhdpi; do | |
d=$(basename "$f") | |
if [ -f "$f/$2_${color}_$size.png" ]; then | |
echo "copying $f/$2_${color}_$size.png" | |
mkdir -vp $d | |
cp -v "$f/$2_${color}_$size.png" "$d/$2.png" | |
fi | |
done | |
for f in $basefolder/$1/drawable-xxxhdpi; do | |
d=$(basename "$f") | |
if [ -f "$f/$2_${color}_$size.png" ]; then | |
echo "copying $f/$2_${color}_$size.png" | |
mkdir -vp $d | |
cp -v "$f/$2_${color}_$size.png" "$d/$2.png" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment