forked from tommytomatoe/Android-Utility
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path9patch
More file actions
executable file
·138 lines (129 loc) · 2.9 KB
/
9patch
File metadata and controls
executable file
·138 lines (129 loc) · 2.9 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#! /bin/bash
# Draw9Patch Script Linux
# Author: Tommy Nguyen [tommytomatoe]
# Version: 1.0.1
# Date: July 20, 2011
# Contact: tommytomatoe@gmail.com
##FUNCTIONS
#load
load_dot ()
{ echo -n "."
sleep .15
echo -n "."
sleep .15
echo -n "."
sleep .15
echo -n "."
sleep .15
echo -n "."
sleep .15
echo "."
}
#enterKey
enterKey()
{ echo "Press [enter] or [space] to $COM, any other key to quit";
read -s -n 1 key
if [[ $key = "" ]]; then
echo "Initiating..."
echo
else
echo "Command not executed";
enter
fi
}
#enter
enter()
{ echo "Please press [enter] to continue";
read -s -n 1 key
if [[ $key = "" ]]; then
echo
fi
}
#future features
ff ()
{ clear
echo "Feature coming in a future release. Stay tuned."
enter
}
#compile
compile_it ()
{ echo "Please place your raw ninepatch images in:"
echo
echo "/working-folder/ninepatch/SOURCE"
echo
enter
mkdir $n/res
mkdir $n/res/drawable
for a in *.9.png ; do
cp $r/$a $o
done
cd $n
echo "Compiling Images. Please Wait"
load_dot
touch AndroidManifest.xml
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"
package=\"com.blank\"
/>" > AndroidManifest.xml
aapt p -F out.apk -M AndroidManifest.xml -S res -f
unzip -jo $n/out.apk *.9.png -d $q/ &>/dev/null
rm AndroidManifest.xml
rm -r res
rm out.apk
echo "Images Compiled to:"
load_dot
echo "$q"
echo
enter
}
#decompile
decompile_it ()
{ echo "Please place your raw ninepatch images in:"
echo
echo "/working-folder/ninepatch/compiled"
echo
enter
cd $q
for a in *9.png ; do
echo "Decompiling $a. Please wait."
load_dot
java -jar $HOME/bin/decode9patchPng.jar < $a > $p/$a
done
echo "Images Decompiled to:"
load_dot
echo "$p"
echo
enter
}
clear
#variables
n=$HOME/android-utility/working-folder/ninepatch
o=$n/res/drawable
p=$HOME/android-utility/working-folder/ninepatch/decompiled
q=$HOME/android-utility/working-folder/ninepatch/compiled
r=$HOME/android-utility/working-folder/ninepatch/SOURCE
echo "|--------------------------------|"
echo "| Draw9Patch Utilities |"
echo "|--------------------------------|"
echo "|--------------------------------|"
echo "| 1. compile RAW 9.png |"
echo "|--------------------------------|"
echo "| 2. decompile compiled 9.png |"
echo "|--------------------------------|"
echo "| 3. INFO on draw9patch |"
echo "|--------------------------------|"
echo "| 4. Run draw9patch tool |"
echo "|--------------------------------|"
echo "|--------------------------------|"
echo " q. Go Back to Main Menu "
echo
printf %s "Select an Option: "
read num
case $num in
1) clear; compile_it; 9patch;;
2) clear; decompile_it; 9patch;;
3) firefox http://code.google.com/p/android-apktool/wiki/9PatchImages; echo; enter; 9patch;;
4) clear; $HOME/bin/draw9patch; 9patch;;
q) clear; exit;;
*) echo; echo "Not a Valid Option" ; echo; enter; 9patch;;
esac