summaryrefslogtreecommitdiffstats
path: root/tools/layoutlib/bridge/update_nav_icons.sh
blob: 7030d1914e254b79d5fad22083342248f00d4f15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh

# copies the navigation bar icons from system ui code to layoutlib.
# to run, simply execute the script. (if not using bash, cd to the dir
# containing this script and then run by ./update_nav_icons.sh)

# Try to get the location of this script.
if [ -n $BASH ]; then
  # see http://stackoverflow.com/a/246128/1546000
  MY_LOCATION=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
  cd $MY_LOCATION
else
  # Let's assume script was run from the same dir.
  MY_LOCATION=$(pwd)
fi

# Check mac or linux to get sed argument to enable extended regex.
case $(uname -s) in
  Darwin)
    EXT_REGEX="-E"
    ;;
  *)
    EXT_REGEX="-r"
    ;;
esac


FB="frameworks/base"
# frameworks/base relative to current location
FB=$(echo $MY_LOCATION | sed $EXT_REGEX -e "s,.*$FB[^/]*/,," -e "s,[^/]+,..,g")
CURRENT_API=21  # update only if icons change from this api version.
DENSITIES="ldpi mdpi hdpi xhdpi xxhdpi"
ICONS="ic_sysbar_back.png ic_sysbar_home.png ic_sysbar_recent.png"
BARS="./resources/bars/"

for icon in $ICONS
do
  for density in $DENSITIES
  do
    destination="$BARS/v$CURRENT_API/$density/"
    mkdir -p "$destination"  # create if not present.
    cp -v "$FB/packages/SystemUI/res/drawable-$density/$icon" "$destination"
  done

  for density in $DENSITIES
  do
    destination="$BARS/v$CURRENT_API/ldrtl-$density/"
    mkdir -p "$destination"
    cp -v "$FB/packages/SystemUI/res/drawable-ldrtl-$density/$icon" "$destination"
    done
done