1#!/bin/sh
2
3# copies the navigation bar icons from system ui code to layoutlib.
4# to run, simply execute the script. (if not using bash, cd to the dir
5# containing this script and then run by ./update_nav_icons.sh)
6
7# Try to get the location of this script.
8if [ -n $BASH ]; then
9  # see http://stackoverflow.com/a/246128/1546000
10  MY_LOCATION=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
11  cd $MY_LOCATION
12else
13  # Let's assume script was run from the same dir.
14  MY_LOCATION=$(pwd)
15fi
16
17# Check mac or linux to get sed argument to enable extended regex.
18case $(uname -s) in
19  Darwin)
20    EXT_REGEX="-E"
21    ;;
22  *)
23    EXT_REGEX="-r"
24    ;;
25esac
26
27
28FB="frameworks/base"
29# frameworks/base relative to current location
30FB=$(echo $MY_LOCATION | sed $EXT_REGEX -e "s,.*$FB[^/]*/,," -e "s,[^/]+,..,g")
31CURRENT_API=21  # update only if icons change from this api version.
32DENSITIES="ldpi mdpi hdpi xhdpi xxhdpi"
33ICONS="ic_sysbar_back.png ic_sysbar_home.png ic_sysbar_recent.png"
34BARS="./resources/bars/"
35
36for icon in $ICONS
37do
38  for density in $DENSITIES
39  do
40    destination="$BARS/v$CURRENT_API/$density/"
41    mkdir -p "$destination"  # create if not present.
42    cp -v "$FB/packages/SystemUI/res/drawable-$density/$icon" "$destination"
43  done
44
45  for density in $DENSITIES
46  do
47    destination="$BARS/v$CURRENT_API/ldrtl-$density/"
48    mkdir -p "$destination"
49    cp -v "$FB/packages/SystemUI/res/drawable-ldrtl-$density/$icon" "$destination"
50    done
51done
52