├── APKManager.app
└── Contents
│ ├── PkgInfo
│ ├── MacOS
│ ├── keys
│ └── applet
│ ├── Resources
│ ├── applet.icns
│ ├── applet.rsrc
│ ├── Scripts
│ │ └── main.scpt
│ └── description.rtfd
│ │ └── TXT.rtf
│ └── Info.plist
├── other
├── bin
│ ├── aapt
│ ├── JD-GUI.app
│ │ └── Contents
│ │ │ ├── MacOS
│ │ │ └── jd-gui
│ │ │ ├── Resources
│ │ │ └── jd-gui.icns
│ │ │ └── Info.plist
│ ├── rm
│ ├── iptest
│ ├── runj
│ ├── preftool
│ ├── newttab
│ └── timeout3
├── lib
│ ├── smali.jar
│ ├── signapk.jar
│ ├── testkey.pk8
│ ├── baksmali.jar
│ ├── logapps
│ ├── testkey.x509.pem
│ ├── colorsetup.sh
│ ├── png_out.sh
│ ├── clean_funcs.sh
│ ├── batch_funcs.sh
│ ├── graphics.sh
│ ├── migrate.sh
│ ├── misc_funcs.sh
│ ├── errors.sh
│ ├── sign_funcs.sh
│ ├── updates.sh
│ ├── debug_funcs.sh
│ ├── multimenu.sh
│ ├── install.sh
│ ├── zipcmp_funcs.sh
│ ├── decext_funcs.sh
│ └── menus.sh
└── apktool
│ ├── apktool_147.jar
│ └── apktool_152.jar
├── .gitignore
├── README.md
└── JocelynCustom.terminal
/APKManager.app/Contents/PkgInfo:
--------------------------------------------------------------------------------
1 | APPLaplt
--------------------------------------------------------------------------------
/other/bin/aapt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jocelynmallon/apkmanager/HEAD/other/bin/aapt
--------------------------------------------------------------------------------
/other/lib/smali.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jocelynmallon/apkmanager/HEAD/other/lib/smali.jar
--------------------------------------------------------------------------------
/other/lib/signapk.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jocelynmallon/apkmanager/HEAD/other/lib/signapk.jar
--------------------------------------------------------------------------------
/other/lib/testkey.pk8:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jocelynmallon/apkmanager/HEAD/other/lib/testkey.pk8
--------------------------------------------------------------------------------
/other/lib/baksmali.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jocelynmallon/apkmanager/HEAD/other/lib/baksmali.jar
--------------------------------------------------------------------------------
/other/apktool/apktool_147.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jocelynmallon/apkmanager/HEAD/other/apktool/apktool_147.jar
--------------------------------------------------------------------------------
/other/apktool/apktool_152.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jocelynmallon/apkmanager/HEAD/other/apktool/apktool_152.jar
--------------------------------------------------------------------------------
/APKManager.app/Contents/MacOS/keys:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jocelynmallon/apkmanager/HEAD/APKManager.app/Contents/MacOS/keys
--------------------------------------------------------------------------------
/APKManager.app/Contents/MacOS/applet:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jocelynmallon/apkmanager/HEAD/APKManager.app/Contents/MacOS/applet
--------------------------------------------------------------------------------
/other/bin/JD-GUI.app/Contents/MacOS/jd-gui:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jocelynmallon/apkmanager/HEAD/other/bin/JD-GUI.app/Contents/MacOS/jd-gui
--------------------------------------------------------------------------------
/APKManager.app/Contents/Resources/applet.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jocelynmallon/apkmanager/HEAD/APKManager.app/Contents/Resources/applet.icns
--------------------------------------------------------------------------------
/APKManager.app/Contents/Resources/applet.rsrc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jocelynmallon/apkmanager/HEAD/APKManager.app/Contents/Resources/applet.rsrc
--------------------------------------------------------------------------------
/APKManager.app/Contents/Resources/Scripts/main.scpt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jocelynmallon/apkmanager/HEAD/APKManager.app/Contents/Resources/Scripts/main.scpt
--------------------------------------------------------------------------------
/other/bin/JD-GUI.app/Contents/Resources/jd-gui.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jocelynmallon/apkmanager/HEAD/other/bin/JD-GUI.app/Contents/Resources/jd-gui.icns
--------------------------------------------------------------------------------
/APKManager.app/Contents/Resources/description.rtfd/TXT.rtf:
--------------------------------------------------------------------------------
1 | {\rtf1\ansi\ansicpg1252\cocoartf1138\cocoasubrtf320
2 | {\fonttbl}
3 | {\colortbl;\red255\green255\blue255;}
4 | }
--------------------------------------------------------------------------------
/other/lib/logapps:
--------------------------------------------------------------------------------
1 | Apple TextEdit|open
2 | TextMate|mate
3 | SubEthaEdit|see
4 | TextWrangler|edit
5 | BBEDIT|bbedit
6 | Coda|coda
7 | MacVIM|mvim
8 | Aquamacs|aquamacs
9 | Smultron|smultron
10 | Nano|nano
11 | VIM|vi
12 | GNU Emacs|emacs
13 | Sublime Text 2|subl
14 | Vico|vico
15 | Chocolat|choc
--------------------------------------------------------------------------------
/other/bin/rm:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v3.0+
4 | # "Safe" rm function
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.0
10 | # Sun. Oct 07, 2012
11 | # -----------------------------------------------------------------------
12 |
13 | for path in "$@"; do
14 | if [[ "${path}" = -* ]]; then :
15 | else
16 | dst=${path##*/}
17 | while [[ -e ~/.Trash/"${dst}" ]]; do
18 | dst="${dst} "$(date +%H-%M-%S)
19 | done
20 | mv "${path}" ~/.Trash/"${dst}" &>/dev/null
21 | fi
22 | done
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .tm_properties
3 | log.txt
4 | adblog.txt
5 | 7za
6 | 32_7za
7 | 64_7za
8 | optipng
9 | 32_optipng
10 | 64_optipng
11 | pngcrush
12 | 32_pngcrush
13 | 64_pngcrush
14 | pngout
15 | adb
16 | zipalign
17 | sox
18 | android
19 | ddms
20 | draw9patch
21 | monitor
22 | jd-gui.cfg
23 | apktool.jar
24 | apktool_131.jar
25 | apktool_132_honeycomb_mod.jar
26 | apktool_132.jar
27 | apktool_141.jar
28 | apktool_142_31e6dc5.jar
29 | apktool_142_269870b.jar
30 | apktool_143_ics_mod.jar
31 | apktool_144_5174001.jar
32 | apktool_147.jar
33 | apktool_150.jar
34 | aaptOLD
35 | dex2jar
36 | temp
37 | bitstream_vera_mono
38 | place-here-for-modding
39 | place-here-for-signing
40 | place-here-to-batch-optimize
41 | place-ogg-here
42 | projects
43 | untracked
44 | keep
45 | CHANGELOG.md
46 | TIPS.md
47 | apktool_143.jar
48 | test
49 | screencaps
50 |
51 | Icon
--------------------------------------------------------------------------------
/other/bin/iptest:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | #Written by:Paul Podolny 26.4.2009
4 | #Purpose: The script checks a passed IPv4 IP address and determines it's class.
5 |
6 |
7 |
8 | #Check that input is passed in the form of IPv4 IP address
9 | if [ ! "$(echo $1 | grep '[0-9]\{1,3\}[.][0-9]\{1,3\}[.][0-9]\{1,3\}[.][0-9]\{1,3\}')" ]
10 | then
11 | echo "Usage: '$0' "
12 | exit 1
13 | fi
14 |
15 | DOTSCHK=`echo $1 | awk '{gsub("[0-9]","");print}' | wc -c`
16 | if [ $DOTSCHK -ne 4 ];then
17 | echo "illegal input"
18 | exit 1
19 | fi
20 |
21 |
22 | for n in $(seq 1 4);do
23 |
24 | OCTET=`echo $1 | awk -F "." '{print $'$n'}'`
25 | if [ $OCTET -lt 0 -o $OCTET -gt 255 ]; then #check if the octet range is between 0 & 255
26 | echo "$1 is not legal IP address"
27 | exit 1
28 | fi
29 | done
30 |
31 | echo "$1 is legal IP address"
32 |
33 |
34 | #Check wether IP is external or internal + determines it's class.
35 | case $1 in
36 |
37 | 192.168.*.*)
38 | echo "$1 is class C internal IP address"
39 | ;;
40 |
41 | 172.*.*.*)
42 | SCND=`echo $1 | awk -F "." '{print $2}'`
43 | if [ $SCND -ge 16 -a $SCND -le 31 ];then
44 | echo "$1 is class B internal IP address"
45 | fi
46 | ;;
47 |
48 | 10.*.*.*)
49 | echo "$1 is class A internal IP address"
50 | ;;
51 |
52 | 169.254.*.*)
53 | echo "$1 is an APIPA IP address"
54 | ;;
55 |
56 | *)
57 | echo "$1 is an external IP address"
58 | ;;
59 | esac
--------------------------------------------------------------------------------
/other/bin/runj:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v3.0+
4 | # Java app wrapper script
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.0
10 | # Sun. Oct 07, 2012
11 | # -----------------------------------------------------------------------
12 |
13 | prog="$0"
14 | while [ -h "${prog}" ]; do
15 | newProg="$(/bin/ls -ld "${prog}")"
16 | newProg="$(expr "${newProg}" : ".* -> \(.*\)$")"
17 | if expr "x${newProg}" : 'x/' >/dev/null; then
18 | prog="${newProg}"
19 | else
20 | progdir="$(dirname "${prog}")"
21 | prog="${progdir}/${newProg}"
22 | fi
23 | done
24 |
25 | oldwd="$(pwd)"
26 | progdir="$(dirname "${prog}")"
27 | cd "${progdir}"
28 | progdir="$(pwd)"
29 | prog="${progdir}"/"$(basename "${prog}")"
30 | cd "${oldwd}"
31 |
32 | jarfile="$1".jar
33 | shift;
34 | libdir="$(dirname "${progdir}")/lib"
35 | if [ ! -r "$libdir/$jarfile" ]
36 | then
37 | echo $(basename "${prog}")": can't find ${libdir}/${jarfile}"
38 | exit 1
39 | fi
40 |
41 | while expr "x$1" : 'x-J' >/dev/null; do
42 | opt="$(expr "$1" : '-J\(.*\)')"
43 | javaOpts="${javaOpts} -${opt}"
44 | shift
45 | done
46 |
47 | jarpath="${libdir}/${jarfile}"
48 |
49 | exec java ${javaOpts} -jar "${jarpath}" "$@"
50 |
--------------------------------------------------------------------------------
/APKManager.app/Contents/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleAllowMixedLocalizations
6 |
7 | CFBundleDevelopmentRegion
8 | English
9 | CFBundleExecutable
10 | applet
11 | CFBundleIconFile
12 | applet
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | APKManager
17 | CFBundlePackageType
18 | APPL
19 | CFBundleSignature
20 | aplt
21 | CFBundleShortVersionString
22 | 3.1
23 | LSMinimumSystemVersionByArchitecture
24 |
25 | x86_64
26 | 10.6
27 |
28 | LSRequiresCarbon
29 |
30 | WindowState
31 |
32 | dividerCollapsed
33 |
34 | eventLogLevel
35 | -1
36 | name
37 | ScriptWindowState
38 | positionOfDivider
39 | 475
40 | savedFrame
41 | 0 60 1440 818 0 0 1440 878
42 | selectedTabView
43 | result
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/other/bin/preftool:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v3.0+
4 | # User preferences utility functions
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.0
10 | # Sun. Oct 07, 2012
11 | # -----------------------------------------------------------------------
12 |
13 |
14 | # Write 'string' type user preferences
15 | write_string () {
16 | /usr/bin/defaults write "${plist}" "${key}" "${value}" 2>/dev/null
17 | }
18 |
19 | # Write 'boolean' type user preferences
20 | write_boolean () {
21 | /usr/bin/defaults write "${plist}" "${key}" -bool "${value}" 2>/dev/null
22 | }
23 |
24 | # Check the type of pref to write
25 | check_type () {
26 | if [[ ${pref} = string ]]; then
27 | write_string
28 | elif [[ ${pref} = bool ]]; then
29 | write_boolean
30 | else
31 | exit 1
32 | fi
33 | }
34 |
35 | # parse options and set vars if necessary
36 | main () {
37 | if [[ $# -lt 3 ]]; then
38 | exit 1
39 | else
40 | while getopts 'b' OPTION
41 | do
42 | case "$OPTION" in
43 | b) pref="bool" ;;
44 | esac
45 | shift $(($OPTIND - 1))
46 | done
47 | if [[ -z ${pref} ]]; then
48 | pref="string"
49 | fi
50 | plist="$1"; shift
51 | key="$1"; shift
52 | value="$1"
53 | check_type
54 | fi
55 | }
56 |
57 | # Start
58 | main $*
59 | exit 0
60 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | APK Manager for Mac OS X
2 | ==================
3 | **version: 3.1b**
4 | **Sun. Jul 21, 2013**
5 |
6 | [CC (by-nc-sa)](http://creativecommons.org/licenses/by-nc-sa/3.0/) Jocelyn Mallon, 2011-2012
7 | [http://girlintroverted.wordpress.com](http://girlintroverted.wordpress.com)
8 |
9 | Original windows version (C) 2010 by Daneshm90
10 | Adapted from Linux version, by farmatito 2010
11 |
12 |
13 | APK Manager is a (massive) wrapper script to automate a number of various tools for android application re-engineering. The easiest way to install, is using [**git**](http://git-scm.com/) & [**Homebrew**](http://mxcl.github.com/homebrew/).
14 |
15 | ```
16 | git clone git://github.com/jocelynmallon/apkmanager.git
17 | ```
18 |
19 | Then run APKManager.app and follow the instructions that show up on screen.
20 |
21 | If you have any problems, please see the wiki for further instructions and extra information, etc.
22 |
23 | 1. [**APK Manager Wiki Homepage**](https://github.com/jocelynmallon/apkmanager/wiki)
24 | 2. [**Basic Installation information**](https://github.com/jocelynmallon/apkmanager/wiki/Installation)
25 | 3. [**Basic tips and tricks, etc.**](https://github.com/jocelynmallon/apkmanager/wiki/General-Tips)
26 | 4. [**About/semi-FAQ**](https://github.com/jocelynmallon/apkmanager/wiki/Basic-Information)
27 | 5. [**Other Notes/Misc information**](https://github.com/jocelynmallon/apkmanager/wiki/Other-Notes)
28 | 6. [**Advanced/Nerd information**](https://github.com/jocelynmallon/apkmanager/wiki/Advanced-Nerd-info)
29 | 7. [**APKManager.app Source/info**](https://github.com/jocelynmallon/apkmanager/wiki/APKManager.app-source)
30 | 8. [**APK Manager Changelog (v3.x)**](https://github.com/jocelynmallon/apkmanager/wiki/Changelog)
--------------------------------------------------------------------------------
/other/bin/newttab:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v3.0+
4 | # Open new terminal tab script
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.0
10 | # Sun. Oct 07, 2012
11 | # -----------------------------------------------------------------------
12 |
13 | red='\033[0;31m'
14 | bred='\033[1;31m'
15 |
16 | # Set up prog to be the path of this script, including following symlinks,
17 | # and set up progdir to be the fully-qualified pathname of its directory.
18 | prog="$0"
19 | while [ -h "${prog}" ]; do
20 | newProg="$(/bin/ls -ld "${prog}")"
21 | newProg="$(expr "${newProg}" : ".* -> \(.*\)$")"
22 | if expr "x${newProg}" : 'x/' >/dev/null; then
23 | prog="${newProg}"
24 | else
25 | progdir="$(dirname "${prog}")"
26 | prog="${progdir}/${newProg}"
27 | fi
28 | done
29 | oldwd="$(pwd)"
30 | progdir="$(dirname "${prog}")"
31 | cd "${progdir}"
32 | progdir="$(pwd)"
33 | prog="${progdir}"/"$(basename "${prog}")"
34 | cd "${oldwd}"
35 |
36 | apkmopt="$1"
37 | shift;
38 | log="$1"
39 | shift;
40 |
41 | if [[ -z $apkmopt ]]; then
42 | echo $bred"Something went wrong... please try again."; $rclr;
43 | read -n 1 -s
44 | exit 1
45 | else
46 | set -e
47 | echo "newttab (open new terminal tab, through applescript) function" 1>> "$log"
48 | apkmdir="cd ${oldwd}"
49 | osascript <<-EOF
50 | tell application "System Events"
51 | tell process "Terminal" to keystroke "t" using command down
52 | end
53 | tell application "Terminal"
54 | activate
55 | do script with command "$apkmdir; $apkmopt" in window 1
56 | end tell
57 | EOF
58 | set +e
59 | fi
60 |
--------------------------------------------------------------------------------
/other/lib/testkey.x509.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIEqDCCA5CgAwIBAgIJAJNurL4H8gHfMA0GCSqGSIb3DQEBBQUAMIGUMQswCQYD
3 | VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4g
4 | VmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UE
5 | AxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAe
6 | Fw0wODAyMjkwMTMzNDZaFw0zNTA3MTcwMTMzNDZaMIGUMQswCQYDVQQGEwJVUzET
7 | MBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4G
8 | A1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9p
9 | ZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZI
10 | hvcNAQEBBQADggENADCCAQgCggEBANaTGQTexgskse3HYuDZ2CU+Ps1s6x3i/waM
11 | qOi8qM1r03hupwqnbOYOuw+ZNVn/2T53qUPn6D1LZLjk/qLT5lbx4meoG7+yMLV4
12 | wgRDvkxyGLhG9SEVhvA4oU6Jwr44f46+z4/Kw9oe4zDJ6pPQp8PcSvNQIg1QCAcy
13 | 4ICXF+5qBTNZ5qaU7Cyz8oSgpGbIepTYOzEJOmc3Li9kEsBubULxWBjf/gOBzAzU
14 | RNps3cO4JFgZSAGzJWQTT7/emMkod0jb9WdqVA2BVMi7yge54kdVMxHEa5r3b97s
15 | zI5p58ii0I54JiCUP5lyfTwE/nKZHZnfm644oLIXf6MdW2r+6R8CAQOjgfwwgfkw
16 | HQYDVR0OBBYEFEhZAFY9JyxGrhGGBaR0GawJyowRMIHJBgNVHSMEgcEwgb6AFEhZ
17 | AFY9JyxGrhGGBaR0GawJyowRoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UE
18 | CBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMH
19 | QW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAG
20 | CSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJAJNurL4H8gHfMAwGA1Ud
21 | EwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAHqvlozrUMRBBVEY0NqrrwFbinZa
22 | J6cVosK0TyIUFf/azgMJWr+kLfcHCHJsIGnlw27drgQAvilFLAhLwn62oX6snb4Y
23 | LCBOsVMR9FXYJLZW2+TcIkCRLXWG/oiVHQGo/rWuWkJgU134NDEFJCJGjDbiLCpe
24 | +ZTWHdcwauTJ9pUbo8EvHRkU3cYfGmLaLfgn9gP+pWA7LFQNvXwBnDa6sppCccEX
25 | 31I828XzgXpJ4O+mDL1/dBd+ek8ZPUP0IgdyZm5MTYPhvVqGCHzzTy3sIeJFymwr
26 | sBbmg2OAUNLEMO6nwmocSdN2ClirfxqCzJOLSDE4QyS9BAH6EhY6UFcOaE0=
27 | -----END CERTIFICATE-----
28 |
--------------------------------------------------------------------------------
/other/lib/colorsetup.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v3.0+
4 | # Color setup and check functions
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.0
10 | # Sun. Oct 07, 2012
11 | # -----------------------------------------------------------------------
12 |
13 | # Set dark color scheme function
14 | colorsetdark () {
15 | echo "colorsetlight (setting dark text on light bg scheme)" 1>> "$log" 2>&1
16 | local key="color"
17 | local value="alternate"
18 | write_preference
19 | white='\033[0;30m'
20 | bwhite='\033[1;30m'
21 | }
22 |
23 | # Set light color scheme function
24 | colorsetlight () {
25 | echo "colorsetlight (setting light text on dark bg scheme)" 1>> "$log" 2>&1
26 | local key="color"
27 | local value="default"
28 | write_preference
29 | white='\033[0;37m'
30 | bwhite='\033[1;37m'
31 | }
32 |
33 | # Select main color scheme menu
34 | colormenu () {
35 | clear
36 | lwhite="\033[0;37m"
37 | lbwhite="\033[1;37m"
38 | dwhite="\033[0;30m"
39 | dbwhite="\033[1;30m"
40 | echo ""
41 | version_banner
42 | echo ""
43 | echo $bgreen" APK Manager color setup (this should only run on very first launch)"
44 | echo ""
45 | echo $green" Setup APK Manager for the following terminal color(s)..."
46 | echo ""
47 | echo $bgreen" 1 "$lwhite"Light"$green" text on dark/black background"
48 | echo $bgreen" ("$lbwhite"example of bold/bright text"$bgreen")"
49 | echo $bgreen" 2 "$dwhite"Dark"$green" text on light/white background"
50 | echo $bgreen" ("$dbwhite"example of bold/bright text"$bgreen")"
51 | echo ""
52 | printf "$bgreen%s""Please make a selection: "; $rclr;
53 | read input
54 | case "$input" in
55 | [1]) colorsetlight ;;
56 | [2]) colorsetdark ;;
57 | *) input_err; colorcheck ;;
58 | esac
59 | unset lwhite
60 | unset lbwhite
61 | unset dwhite
62 | unset dbwhite
63 | }
64 |
65 | # Start
66 | colormenu
67 | return 0
68 |
--------------------------------------------------------------------------------
/other/bin/JD-GUI.app/Contents/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion English
6 | CFBundleExecutable jd-gui
7 | CFBundleName JD-GUI
8 | CFBundleGetInfoString JD-GUI version 0.3.5, (c) 2008-2010 Emmanuel Dupuy
9 | CFBundleIconFile jd-gui.icns
10 | CFBundleIdentifier jd.jd-gui
11 | CFBundleInfoDictionaryVersion 6.0
12 | CFBundlePackageType APPL
13 | CFBundleLongVersionString 0.3.5, (c) 2008-2010 Emmanuel Dupuy
14 | CFBundleShortVersionString 0.3.5
15 | CFBundleVersion 0.3.5
16 | CSResourcesFileMapped
17 | LSRequiresCarbon
18 | NSHumanReadableCopyright Copyright 2008-2010 Emmanuel Dupuy
19 | CFBundleDocumentTypes
20 |
21 |
22 | CFBundleTypeExtensions
23 |
24 | class
25 |
26 | CFBundleTypeName Class File
27 | CFBundleTypeRole Viewer
28 | LSIsAppleDefaultForType
29 | LSTypeIsPackage
30 |
31 |
32 | CFBundleTypeExtensions
33 |
34 | jar
35 |
36 | CFBundleTypeName Jar File
37 | CFBundleTypeRole Viewer
38 | LSIsAppleDefaultForType
39 | LSTypeIsPackage
40 |
41 |
42 | CFBundleTypeExtensions
43 |
44 | zip
45 |
46 | CFBundleTypeName Zip File
47 | CFBundleTypeRole Viewer
48 | LSIsAppleDefaultForType
49 | LSTypeIsPackage
50 |
51 |
52 | CFBundleTypeExtensions
53 |
54 | log
55 | txt
56 |
57 | CFBundleTypeName Log File
58 | CFBundleTypeRole Viewer
59 | LSIsAppleDefaultForType
60 | LSTypeIsPackage
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/other/bin/timeout3:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # The Bash shell script executes a command with a time-out.
4 | # Upon time-out expiration SIGTERM (15) is sent to the process. If the signal
5 | # is blocked, then the subsequent SIGKILL (9) terminates it.
6 | #
7 | # Based on the Bash documentation example.
8 |
9 | # Hello Chet,
10 | # please find attached a "little easier" :-) to comprehend
11 | # time-out example. If you find it suitable, feel free to include
12 | # anywhere: the very same logic as in the original examples/scripts, a
13 | # little more transparent implementation to my taste.
14 | #
15 | # Dmitry V Golovashkin
16 |
17 | scriptName="${0##*/}"
18 |
19 | declare -i DEFAULT_TIMEOUT=9
20 | declare -i DEFAULT_INTERVAL=1
21 | declare -i DEFAULT_DELAY=1
22 |
23 | # Timeout.
24 | declare -i timeout=DEFAULT_TIMEOUT
25 | # Interval between checks if the process is still alive.
26 | declare -i interval=DEFAULT_INTERVAL
27 | # Delay between posting the SIGTERM signal and destroying the process by SIGKILL.
28 | declare -i delay=DEFAULT_DELAY
29 |
30 | function printUsage() {
31 | cat < 0)); do
79 | sleep $interval
80 | kill -0 $$ || exit 0
81 | ((t -= interval))
82 | done
83 |
84 | # Be nice, post SIGTERM first.
85 | # The 'exit 0' below will be executed if any preceeding command fails.
86 | kill -s SIGTERM $$ && kill -0 $$ || exit 0
87 | sleep $delay
88 | kill -s SIGKILL $$
89 | ) 2> /dev/null &
90 |
91 | exec "$@"
92 |
--------------------------------------------------------------------------------
/other/lib/png_out.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v3.0+
4 | # Pngout check and install functions
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.0.2
10 | # Wed. May 22, 2013
11 | # -----------------------------------------------------------------------
12 |
13 | # static url for latest version of pngout for mac
14 | pngouturl="http://static.jonof.id.au/dl/kenutils/pngout-20130221-darwin.tar.gz"
15 | pngoutmd5="2f35b7369d5ab668cea414772de6fba9"
16 |
17 | # setup name of downloaded folder
18 | set_pngout_fld () {
19 | pngoutfld="${pngouturl##*/}"
20 | pngoutfld="${pngoutfld%%.*}"
21 | }
22 |
23 | # Check if pngout install succeeded
24 | inst_pngo_check () {
25 | if [[ $(command -v pngout) ]]; then
26 | echo $bgreen"pngout installed succesfully!"
27 | echo ""
28 | echo $bgreen"$apkmftr";
29 | local key="pngtool"
30 | local value="pngout"
31 | write_preference
32 | getpngoutver
33 | local key="pngout"
34 | write_preference
35 | pngtoolset
36 | debuganykey
37 | unset key
38 | unset value
39 | else
40 | echo $bred"Something went wrong installing pngout"
41 | echo $bred"Please check the log and try again."; $rclr;
42 | debuganykey
43 | fi
44 | unset pngouturl
45 | unset pngoutfld
46 | unset pngoutmd5
47 | }
48 |
49 | # Actually install pngout
50 | install_pngout () {
51 | echo "install_pngout (download and install pngout) function" 1>> "$log"
52 | set_pngout_fld
53 | clear
54 | menu_header
55 | echo $bgreen"$apkmspr"; $rclr;
56 | echo ""
57 | # if [[ ${installtype} = homebrew ]]; then
58 | if [[ ${installtype} = disabled ]]; then
59 | if [[ ${BTAP} -eq 1 ]]; then
60 | brew tap adamv/alt
61 | unset BTAP
62 | echo ""
63 | fi
64 | brew install pngout
65 | echo ""
66 | inst_pngo_check
67 | else
68 | echo $bgreen"Downloading pngout..."; $rclr;
69 | curl "${pngouturl}" > "${maindir}/other/pngout.tar.gz"
70 | local filehash="$(md5 -q "${maindir}/other/pngout.tar.gz")"
71 | if [[ ${filehash} = ${pngoutmd5} ]]; then
72 | echo $green"Extracting pngout..."; $rclr;
73 | tar -xzvf "${maindir}/other/pngout.tar.gz" 1>> "$log" 2>&1
74 | cp -p "${maindir}/${pngoutfld}/pngout" "${maindir}/other/bin/pngout"
75 | echo $green"cleaning up temporary files..."; $rclr;
76 | rm -rf "${maindir}/other/pngout.tar.gz"
77 | rm -rf "${maindir}/${pngoutfld}"
78 | inst_pngo_check
79 | else
80 | echo $bred" ERROR: Corrupt download/file, md5 hash fail:"
81 | echo $bred" download: ${filehash}"
82 | echo $bred" expected: ${pngoutmd5}"
83 | echo ""
84 | echo $white"press any key to try download again..."
85 | wait
86 | rm -r "${maindir}/other/pngout.tar.gz"
87 | install_pngout
88 | fi
89 | fi
90 | echo "install_pngout function complete" 1>> "$log"
91 | }
92 |
93 | # Prompt to install pngout
94 | pngout_prompt () {
95 | clear
96 | menu_header
97 | echo $bgreen"$apkmspr";
98 | echo ""
99 | echo $bred" A pngout binary was not found on your system. "$white"Unfortunately, pngout is not open"
100 | echo $white" source software, and is "$bgreen" (c) Ken Silverman http://advsys.net/ken/utils.htm"
101 | echo $white" Due to copyright, pngout can't legally be redistributed with APK Manager."
102 | echo ""
103 | # if [[ ${installtype} = homebrew ]]; then
104 | if [[ ${installtype} = disabled ]]; then
105 | echo $white" However, APK Manager can install pngout using Homebrew,"
106 | echo $white" thanks to the alt formula here: "$blue"https://github.com/adamv/homebrew-alt"
107 | echo $white" this will execute the following commands:"
108 | echo ""
109 | if [[ ! $(brew tap | grep "adamv/alt") ]]; then
110 | echo $bgreen" brew tap adamv/alt"
111 | BTAP="1"
112 | fi
113 | echo $bgreen" brew install pngout"
114 | else
115 | echo $white" However, APK Manager can download the latest pre-compiled mac binary "
116 | echo $white" from the official mac download page here:"
117 | echo ""
118 | echo $bgreen" ${pngouturl}"
119 | echo ""
120 | echo $white" and copy/install it automatically into the apkmanager/other/bin folder for you."
121 | fi
122 | echo ""
123 | echo $bgreen"$apkmftr";
124 | printf "$white%s""Do you want to download/install pngout? ("$bgreen"y"$white"/"$bgreen"n"$white") "; $rclr;
125 | read input
126 | case "$input" in
127 | [yY]) install_pngout ;;
128 | [nN]) ;;
129 | *) input_err; pngout_check ;;
130 | esac
131 | unset input
132 | }
133 |
134 | # Check if pngout exists and is in $PATH
135 | pngout_check () {
136 | echo "pngout_check (checking if pngout is installed)" 1>> "$log"
137 | if [[ $(command -v pngout) ]]; then
138 | local key="pngtool"
139 | local value="pngout"
140 | write_preference
141 | pngtoolset
142 | else
143 | pngout_prompt
144 | fi
145 | }
146 |
--------------------------------------------------------------------------------
/other/lib/clean_funcs.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v3.0+
4 | # Clean menu functions
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.1b
10 | # Wed. Jul 31, 2013
11 | # -----------------------------------------------------------------------
12 |
13 | # Cleanup for 'cleaning' functions
14 | cmcleanup () {
15 | unset clnpth
16 | unset clndir
17 | }
18 |
19 | # Clean/reset working project only
20 | clean_capp () {
21 | capp_test
22 | echo "clean_capp (removing current working project folder)" 1>> "$log"
23 | clnpth="${maindir}/${prj_dir}"
24 | clndir="${capp}"
25 | rm -rf "${clnpth}/${clndir}"
26 | }
27 |
28 | # Clean/reset all files in modding folder
29 | clean_modding () {
30 | echo "clean_modding (removing \"${mod_dir}\" folder)" 1>> "$log"
31 | clnpth="${maindir}"
32 | clndir="${mod_dir}"
33 | clean_exec
34 | project_test
35 | }
36 |
37 | # Clean/reset all files in batch ogg folder
38 | clean_ogg () {
39 | echo "clean_ogg (removing \"${ogg_dir}\" folder)" 1>> "$log"
40 | clnpth="${maindir}"
41 | clndir="${ogg_dir}"
42 | clean_exec
43 | }
44 |
45 | # Clean/reset all files in bath optimize folder
46 | clean_batch () {
47 | echo "clean_batch (removing \"${bat_dir}\" folder)" 1>> "$log"
48 | clnpth="${maindir}"
49 | clndir="${bat_dir}"
50 | clean_exec
51 | }
52 |
53 | # Clean/reset all files in batch signing folder
54 | clean_signing () {
55 | echo "clean_signing (removing \"${sig_dir}\" folder)" 1>> "$log"
56 | clnpth="${maindir}"
57 | clndir="${sig_dir}"
58 | clean_exec
59 | }
60 |
61 | # Clean/reset all projects
62 | clean_projects () {
63 | echo "clean_projects (removing \"projects\" folder)" 1>> "$log"
64 | clnpth="${maindir}"
65 | clndir="${prj_dir}"
66 | clean_exec
67 | }
68 |
69 | # Clean/reset apktool framework files
70 | clean_apktool () {
71 | echo "clean_apktool (removing apktool framework files)" 1>> "$log"
72 | find "${HOME}/apktool/framework" -iname "*.apk" -exec mv {} ~/.Trash \;
73 | }
74 |
75 | # Clean/reset log & adblog files
76 | clean_logs () {
77 | rm -rf "${log}"
78 | rm -rf "${maindir}/adblog.txt"
79 | logstart
80 | }
81 |
82 | # Clean/reset all working directories
83 | clean_all () {
84 | echo "clean_all (cleaning all files and folders)" 1>> "$log"
85 | clean_modding
86 | clean_ogg
87 | clean_batch
88 | clean_signing
89 | clean_projects
90 | clean_apktool
91 | echo "clean_all complete" 1>> "$log"
92 | project_test
93 | }
94 |
95 | # Clean/reset log viewer app choice
96 | clean_viewer () {
97 | echo "clean_viewer (resetting log viewer app to default)" 1>> "$log"
98 | defaults delete "${plist}" logviewapp 2>/dev/null
99 | logvset
100 | }
101 |
102 | # Clean/reset persistent java heap memory choice
103 | clean_heapsize () {
104 | echo "clean_heapsize (resetting persistent java heap memory size)" 1>> "$log"
105 | defaults delete "${plist}" heap 2>/dev/null
106 | jvheapck
107 | }
108 |
109 | # Clean/reset persistent compression level choice
110 | clean_complvl () {
111 | echo "clean_complvl (resetting persistent compression level)" 1>> "$log"
112 | defaults delete "${plist}" complvl 2>/dev/null
113 | complvlck
114 | }
115 |
116 | # Clean/reset persistent keystore choice
117 | clean_keystore () {
118 | echo "clean_keystore (resetting persistent keystore setting)" 1>> "$log"
119 | defaults delete "${plist}" keychoice 2>/dev/null
120 | unset keystore
121 | storecheck
122 | }
123 |
124 | # Clean/reset png optimization tool choice
125 | clean_pngtool () {
126 | echo "clean_pngtool (resetting png optimization tool setting)" 1>> "$log"
127 | defaults delete "${plist}" pngtool 2>/dev/null
128 | unset pngtool
129 | pngtoolset
130 | }
131 |
132 | # Clean/reset persistant ADB device choice
133 | clean_adb_device () {
134 | echo "clean_adb_device (resetting ADB device choice)" 1>> "$log"
135 | defaults delete "${plist}" adb_dev_choice 2>/dev/null
136 | defaults delete "${plist}" adb_dev_model 2>/dev/null
137 | defaults delete "${plist}" adb_dev_product 2>/dev/null
138 | defaults delete "${plist}" adb_dev_device 2>/dev/null
139 | unset adb_dev_choice
140 | unset adb_dev_model
141 | unset adb_dev_product
142 | unset adb_dev_device
143 | adb_dev_choice="none"
144 | }
145 |
146 | # Clean/reset apktool.jar symlink
147 | clean_apktjar () {
148 | echo "clean_apktjar (resetting apktool.jar to newest version)" 1>> "$log"
149 | rm "${libdir}/apktool.jar"
150 | unset apktool_ver
151 | apktcheck
152 | getapktver
153 | }
154 |
155 | # Clean/reset debug/binary information
156 | clean_debug () {
157 | echo "clean_debug (resetting debug information)" 1>> "$log"
158 | local key="debugset"
159 | local value="false"
160 | write_preference
161 | unset apktool_ver
162 | }
163 |
164 | # Clean/reset user color preference
165 | clean_color () {
166 | echo "clean_color (resetting color scheme selection)" 1>> "$log"
167 | defaults delete "${plist}" color 2>/dev/null
168 | unset white
169 | unset bwhite
170 | echo "color selection reset, launching colorcheck..." 1>> "$log" 2>&1
171 | colorcheck
172 | }
173 |
174 | # Actually execute clean commands
175 | clean_exec () {
176 | rm -rf "${clnpth}/${clndir}"
177 | mkdir -p "${clnpth}/${clndir}"
178 | }
179 |
--------------------------------------------------------------------------------
/other/lib/batch_funcs.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v3.0+
4 | # Basic "batch" operation functions
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.0
10 | # Sun. Oct 07, 2012
11 | # -----------------------------------------------------------------------
12 |
13 | # Cleanup variables used in 'batch' functions
14 | batch_cleanup () {
15 | unset input
16 | unset infile
17 | unset batchnum
18 | unset dir
19 | unset file
20 | unset ogg_file
21 | unset png_file
22 | }
23 |
24 | # Batch zipalign apk and/or jar files
25 | batch_zalign () {
26 | echo "batch_zalign (batch zipalign files) function" 1>> "$log"
27 | cd "${maindir}/other"
28 | find "${maindir}/${bat_dir}" -type f \( -iname "*.apk" -o -iname "*.jar" \) | while read infile ;
29 | do
30 | dir="$(dirname "${infile}")"
31 | infile="$(basename "${infile}")"
32 | zipalign -fv 4 "${dir}/${infile}" "${dir}/${infile}-aligned" 1>> "$log" 2>&1
33 | if [[ $? -eq 0 ]]; then
34 | echo $green"${infile} aligned ok"; $rclr;
35 | mv -f "${dir}/${infile}-aligned" "${dir}/${infile}"
36 | fi
37 | done
38 | cd "${maindir}"
39 | echo "batch_zalign function complete" 1>> "$log"
40 | }
41 |
42 | # Batch optimize png images
43 | batch_png () {
44 | echo "batch_png (batch optimize png images) function" 1>> "$log"
45 | if [[ ${pngopts} = disabled ]];then
46 | echo $bred"ERROR, no png optimization program was found on your system"
47 | echo $bred"this option is unavailable until one is installed"; $rclr;
48 | pressanykey
49 | else
50 | if [[ -z ${pngtool} ]]; then
51 | pngtool="optipng"
52 | fi
53 | cd "${maindir}/other"
54 | mkdir -p "${maindir}/${bat_dir}/temp"
55 | find "${maindir}/${bat_dir}" -iname "*.apk" | while read infile ;
56 | do
57 | dir="$(dirname "${infile}")"
58 | infile="$(basename "${infile}")"
59 | echo "Optimizing ${infile}"
60 | 7za x -o"${dir}/temp" "${dir}/${infile}" -y 1>> "$log" 2>&1
61 | find "${dir}/temp" -iname "*.png" | while read png_file ;
62 | do
63 | if [[ $(echo "${png_file}" | grep -c "\.9\.png$") -eq 0 ]]; then
64 | if [[ ${pngtool} = optipng ]]; then
65 | optipng -o99 "${png_file}"
66 | elif [[ ${pngtool} = pngcrush ]]; then
67 | pngcrush -reduce -brute "${png_file}" "opt_png.png"
68 | mv -f opt_png.png "${png_file}"
69 | elif [[ ${pngtool} = pngout ]]; then
70 | pngout "${png_file}"
71 | fi
72 | fi
73 | done
74 | 7za a -tzip "${dir}/temp.zip" "${dir}/temp/*" -mx${uscr} -y 1>> "$log" 2>&1
75 | mv -f "${dir}/temp.zip" "${dir}/${infile}"
76 | rm -rf "${dir}/temp/*"
77 | done
78 | rm -rf "${maindir}/${bat_dir}/temp"
79 | cd "${maindir}"
80 | fi
81 | echo "batch_png function complete" 1>> "$log"
82 | }
83 |
84 | # Optimize both (z & p) check function
85 | batch_both () {
86 | if [[ ${pngopts} = disabled ]];then
87 | echo $bred"ERROR, no png optimization program was not found on your"
88 | echo $bred"system. This option is unavailable until one is installed"
89 | echo $bwhite"Type \"Q\" to return to main menu, or type anything else"
90 | printf "$bwhite%s""to proceed with \"batch zipalign\" only... "; $rclr;
91 | read input
92 | case "$input" in
93 | [qQ]) ;;
94 | *) batch_zalign ;;
95 | esac
96 | else
97 | batch_png
98 | batch_zalign
99 | fi
100 | }
101 |
102 | # Batch optimize files prompt
103 | batch_opt () {
104 | echo "batch_opt (batch optimize main prompt) function" 1>> "$log"
105 | local batchnum="$(ls -1 "${maindir}/${bat_dir}" | wc -l)"
106 | cd "${maindir}"
107 | if [[ ${batchnum} = 0 ]]; then
108 | echo $bred"Error, nothing to optimize"; $rclr;
109 | pressanykey
110 | else
111 | printf "$white%s""Do you want to zipalign "$green"(z)"$white", optimize png "$green"(p)"$white" or both "$green"(zp)"$white"? :"; $rclr;
112 | read input
113 | case "$input" in
114 | [zZ]) batch_zalign ;;
115 | [pP]) batch_png ;;
116 | [zZ][pP]) batch_both ;;
117 | *) input_err; batch_opt ;;
118 | esac
119 | fi
120 | echo "batch optimize function complete" 1>> "$log"
121 | }
122 |
123 | # Batch sign apk files with test key
124 | batch_sign_tk () {
125 | echo "batch_sign_tk (batch sign with test keys) function" 1>> "$log"
126 | local batchnum="$(ls -1 "${maindir}/${sig_dir}" | wc -l)"
127 | if [[ ${batchnum} -eq 0 ]]; then
128 | echo $bred"Error, nothing to sign"; $rclr;
129 | pressanykey
130 | else
131 | find "${maindir}/${sig_dir}" -iname "signed-*.apk" -exec mv {} ~/.Trash \;
132 | find "${maindir}/${sig_dir}" -iname "*.apk" | while read infile ;
133 | do
134 | dir="$(dirname "${infile}")"
135 | infile="$(basename "${infile}")"
136 | runj signapk -JXmx"${heapy}""m" -w "${libdir}/testkey.x509.pem" "${libdir}/testkey.pk8" "${dir}/${infile}" "${dir}/signed-${infile}" 1>> "$log" 2>&1
137 | if [[ $? -ne 0 ]]; then
138 | echo $bred"An error occured signing ${infile}"; $rclr;
139 | echo $bred"please check the log for details"; $rclr;
140 | else
141 | echo $green"${infile} signed; ok."; $rclr;
142 | echo "${infile} signed; ok." 1>> "$log"
143 | fi
144 | done
145 | fi
146 | echo "batch_sign_tk function complete" 1>> "$log"
147 | }
148 |
149 | # Batch optimize .ogg files
150 | batch_ogg () {
151 | echo "batch_ogg (batch optimize ogg files) function" 1>> "$log"
152 | if [[ ${oggopts} = disabled ]];then
153 | echo $bred"ERROR, program \"sox\" was not found on your system"
154 | echo $bred"this option is unavailable until it is installed"; $rclr;
155 | pressanykey
156 | else
157 | find "${maindir}/${ogg_dir}/" -iname "*.ogg" | while read ogg_file ;
158 | do
159 | dir="$(dirname "${ogg_file}")"
160 | file="$(basename "${ogg_file}")"
161 | printf "%s" "Optimizing: ${file}"
162 | sox "${dir}/${file}" -C 0 "${dir}/optimized-${file}"
163 | if [[ $? -eq 0 ]]; then
164 | printf "\n"
165 | echo "${file} optimized ok" 1>> "$log"
166 | else
167 | printf "...%s\n" "Failed"
168 | echo "optimizing ${file} failed" 1>> "$log"
169 | fi
170 | done
171 | fi
172 | echo "batch_ogg function complete" 1>> "$log"
173 | }
174 |
--------------------------------------------------------------------------------
/other/lib/graphics.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v3.0+
4 | # Colors and graphics definition file
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.2b
10 | # Wed. Aug 7, 2013
11 | # -----------------------------------------------------------------------
12 |
13 | # define colors for pretty output
14 | red='\033[0;31m'
15 | bred='\033[1;31m'
16 | green='\033[0;32m'
17 | bgreen='\033[1;32m'
18 | blue='\033[0;34m'
19 | bblue='\033[1;34m'
20 | pink='\033[0;35m'
21 | bpink='\033[1;35m'
22 | yellow='\033[0;33m'
23 | byellow='\033[1;33m'
24 | rclr='tput sgr0'
25 |
26 | # set some graphical variables for easy pretty menus and logs
27 | apkmspr="----------------------------------------------------------------------------------------------------"
28 | apkmftr="****************************************************************************************************"
29 | logspr2="**************************************************"
30 | logspcr="--------------------------------------------------"
31 |
32 | # version banner display function
33 | version_banner () {
34 | local vernum
35 | local apkstring
36 | local title_len
37 | local title_fill
38 | vernum="$(awk '/# version:/ { print $3; exit}' "${maindir}/other/main.sh")"
39 | if [[ $(( ${#vernum} % 2)) -eq '0' ]]; then
40 | apkstring="APK Manager Mac OS X v${vernum}"
41 | else
42 | apkstring="APK Manager Mac OSX v${vernum}"
43 | fi
44 | title_len="${apkstring//[*]}"
45 | title_len="${#apkstring}"
46 | title_fill="$(printf "%*s" $(((98-${title_len})/2)))"
47 | echo $bgreen"${title_fill// /*}\c"
48 | echo " ${apkstring} \c"
49 | echo $bgreen"${title_fill// /*}"; $rclr;
50 | }
51 |
52 | # generate ADB killing on quit status for display
53 | adb_kill_display () {
54 | if [[ ${adb_kill} -eq 1 ]]; then
55 | echo $bred"ON"$blue")"; $rclr;
56 | else
57 | echo $bgreen"OFF"$blue")"; $rclr;
58 | fi
59 | }
60 |
61 | # generate ADB screenshot enabled status for display
62 | adb_screencap_display () {
63 | if [[ ${adb_screencap} -eq 1 ]]; then
64 | echo $bgreen"ON"$blue")"; $rclr;
65 | else
66 | echo $bred"OFF"$blue")"; $rclr;
67 | fi
68 | }
69 |
70 | # generate ADB connect on start status for display
71 | adb_connect_start_display () {
72 | if [[ ${adb_connect_on_start} -eq 1 ]]; then
73 | echo $bgreen"ON"$blue")"; $rclr;
74 | else
75 | echo $bred"OFF"$blue")"; $rclr;
76 | fi
77 | }
78 |
79 | # generate ADB device information for header
80 | gen_adb_device_info () {
81 | if [[ -n $adb_dev_choice ]] && [[ -n $adb_dev_model ]] && [[ -n $adb_dev_product ]] && [[ -n $adb_dev_device ]]; then
82 | echo $green"${adb_dev_choice}"$blue" (model: "$green"${adb_dev_model}"$blue" | device: "$green"${adb_dev_device}"$blue" | product: "$green"${adb_dev_product} "$blue")"; $rclr;
83 | else
84 | adb_dev_choice="none"
85 | echo $green"No ADB device connected"
86 | fi
87 | }
88 |
89 | # check if we need to truncate project name for display
90 | gen_project_display_text () {
91 | local maxlength="$((47 - (${#uscr} + ${#heapy})))"
92 | if [[ ${#capp} -gt ${maxlength} ]]; then
93 | local cappoffset="$(( ${#capp} - $((maxlength - ${#trunc_symbol})) ))"
94 | local newcapp="${trunc_symbol}${capp:$cappoffset:$maxlength}"
95 | echo "${newcapp}"
96 | else
97 | echo "${capp}"
98 | fi
99 | }
100 |
101 | # generate basic debug information for display
102 | gen_debug_display_text () {
103 | if [[ ${v_mode} -ne 0 ]]; then
104 | printf "$bred%s"" VERBOSE MODE ENABLED (-v for entire script) "$bwhite" | "
105 | fi
106 | if [[ ${t_mode} -ne 0 ]]; then
107 | printf "$bred%s"" TRACE MODE ENABLED (-x for entire script) "$bwhite" | "
108 | fi
109 | if [[ ${e_mode} -ne 0 ]]; then
110 | printf "$bred%s"" -e"$bwhite" |"
111 | local emode=5
112 | fi
113 | if [[ ${debugstate} -ne 0 ]]; then
114 | if [[ -z $emode ]]; then
115 | local emode=0
116 | fi
117 | local pidw="$$"
118 | if [[ -z ${errcode} ]]; then
119 | errcode=0
120 | local err_string="${bwhite}| \$?: ${bred}${errcode}"
121 | local pwdfill=28
122 | else
123 | local err_string="${bwhite}| ${bred}${errfunc} ${bwhite}\$?: ${bred}${errcode} ${bwhite}line: ${bred}${errline}"
124 | local pwdfill=36
125 | fi
126 | local maxlength="$((100 - (((((${#errfunc} + ${#errcode}) + ${#errline}) + ${#pidw}) + ${emode} ) + ${pwdfill} )))"
127 | if [[ ${#PWD} -gt ${maxlength} ]]; then
128 | local pwdoffset="$(( ${#PWD} - $((maxlength - ${#trunc_symbol})) ))"
129 | local newpwd="${trunc_symbol}${PWD:$pwdoffset:$maxlength}"
130 | else
131 | newpwd="$(pwd)"
132 | fi
133 | printf "$bwhite%s"" PID: "$bred"$$"$bwhite" ${err_string}"$bwhite" | Last 'cd': "$bred"${newpwd}\n"; $rclr;
134 | unset errcode
135 | unset errline
136 | unset errfunc
137 | else
138 | echo ""
139 | fi
140 | }
141 |
142 | # Main APK Manager header
143 | menu_header () {
144 | local trunc_symbol="..."
145 | echo ""
146 | version_banner
147 | echo $bwhite" Compression-Level: "$bgreen"${uscr}"$bwhite" | Heap Size: "$bgreen"${heapy}""mb"$bwhite" | Project:"$bgreen $(gen_project_display_text); $rclr;
148 | echo $bgreen"$apkmspr"; $rclr;
149 | gen_debug_display_text
150 | }
151 |
152 | # Debug/settings menu sub-header
153 | debug_header () {
154 | if [[ -z $adb_dev_choice ]] && [[ -z $adb_dev_model ]] && [[ -z $adb_dev_product ]]; then
155 | get_saved_adb_device
156 | fi
157 | echo $bgreen"------------------------------------"$bwhite"Debug Info and Misc Settings"$bgreen"------------------------------------";
158 | echo $white" Current System: "$green"Mac OS X ${osx_ver} ${osx_bld} ${arch_ver}";
159 | echo $white" APK Manager install type: "$green"${installtype}";
160 | echo $white" APK Manager root dir: "$green"${maindir}";
161 | echo $white" ANDROID_SDK_ROOT: "$green"${ANDROID_SDK_ROOT}";
162 | echo $white" Selected ADB Device:" $(gen_adb_device_info);
163 | echo $white" Current log viewer: "$green"${logapp}";
164 | echo $white" Current \"png\" tool: "$green"${pngtool}";
165 | echo $white" Current APKtool: "$green"${apktool_ver}"$blue" ($(basename "$(readlink "${libdir}/apktool.jar")"))";
166 | }
167 |
168 | # automatic updates menu header
169 | updates_header () {
170 | echo $bgreen"-------------------------------------"$bwhite"Automatic Updates Settings"$bgreen"-------------------------------------";
171 | local updatestate="$(defaults read "${plist}" updates 2>/dev/null)"
172 | if [[ $? -ne 0 ]]; then
173 | updatestate=0
174 | local key="updates"
175 | local value="false"
176 | write_preference
177 | fi
178 | if [[ ${updatestate} -eq 1 ]]; then
179 | update_branch_check
180 | local commit
181 | commit="$(get_commit_ver)"
182 | commit="${commit:0:8}"
183 | commit="${commit} $(echo $blue"(")$(git log --pretty=format:"%s" --max-count=1)$(echo ")")"
184 | update_prompt_state
185 | if [[ ${upromptstate} -eq 1 ]]; then
186 | local uprompt="${green}ON"
187 | else
188 | local uprompt="${bred}OFF"
189 | fi
190 | build_last_date_time
191 | check_update_freq
192 | if [[ ${ufreq} -eq 1 ]]; then
193 | local updfreq="${ufreq} ${white}day"
194 | elif [[ ${ufreq} -gt 1 ]]; then
195 | local updfreq="${ufreq} ${white}days"
196 | fi
197 | echo $white" Updates status: "$green"ON"; $rclr;
198 | echo $white" Updates prompt: $uprompt"; $rclr;
199 | echo $white" Update frequency: "$green"${updfreq}"; $rclr;
200 | echo $white" Last update check: "$green"${last_check}"; $rclr;
201 | echo $bgreen"$apkmspr"; $rclr;
202 | echo $white" Current branch: "$green"${saved_channel}"; $rclr;
203 | echo $white" Current commit: "$green"${commit}"; $rclr;
204 | else
205 | echo $white" Updates status: "$bred"OFF"; $rclr;
206 | fi
207 | }
208 |
--------------------------------------------------------------------------------
/other/lib/migrate.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v2.1+
4 | # Private Key & User Settings Migration functions
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.0
10 | # Sun. Oct 07, 2012
11 | # -----------------------------------------------------------------------
12 |
13 | # Set migration status
14 | setmigratestatus () {
15 | local key="migration"
16 | local value="true"
17 | write_preference
18 | }
19 |
20 | # Cleanup, unset variables
21 | finishmigrate () {
22 | unset f
23 | unset count
24 | unset dir
25 | unset needmigrate
26 | unset usrsetting
27 | unset header_shown
28 | setmigratestatus
29 | }
30 |
31 | # Error when migrating private keys
32 | migratekey_err () {
33 | if [[ -e "${HOME}/.apkmanager/.migration" ]]; then
34 | rm -r "${HOME}/.apkmanager/.migration"
35 | fi
36 | if [[ $(defaults read "${plist}" migration) -ne 0 ]]; then
37 | defaults delete "${plist}" migration 2>/dev/null
38 | fi
39 | echo $bred"ERROR MIGRATING keystore(s) to VERSION 2.1 SCHEMA"
40 | echo $bred"PLEASE CHECK LOG FOR DETAILS AND MANUALLY MOVE"
41 | echo $bred"EXISTING KEY(s) AND keystore(s) TO NEW LOCATION:"
42 | echo $bred"${HOME}/.apkmanager/.keystores/"
43 | printf "$bred%s""press any key to exit"; $rclr;
44 | wait
45 | exit 1
46 | }
47 |
48 | # Delete old key folder on succesfull migration
49 | finishkeymigrate () {
50 | echo $bred"removing old ${maindir}/other/.keystores directory"; $rclr;
51 | echo ""
52 | echo "removing old ${maindir}/other/.keystores directory" 1>> "$log"
53 | rm -r "${maindir}/other/.keystores"
54 | echo $bgreen"Succesfully migrated to v2.1+ private key schema!"; $rclr;
55 | echo "Succesfully migrated to v2.1+ private key schema" 1>> "$log"
56 | }
57 |
58 | # Actually migrate user private keys
59 | keymigrate () {
60 | if [[ -d "${maindir}/other/.keystores" ]] && [[ ! -d "${HOME}/.apkmanager/.keystores" ]]; then
61 | echo $white" Found old private KEY(s) in:"
62 | echo $green" ${maindir}/other/.keystores"; $rclr;
63 | echo $white" Migrating private KEY(s) to:"
64 | echo $green" ${HOME}/.apkmanager/.keystores"; $rclr;
65 | echo "Migrating private KEY(s) to ${HOME}/.apkmanager/.keystores" 1>> "$log"
66 | cp -pRv "${maindir}/other/.keystores" "${HOME}/.apkmanager" 1>> "$log" 2>&1
67 | if [[ $? -ne 0 ]]; then
68 | echo "ERROR MIGRATING PRIVATE KEYS TO v2.1 SCHEMA" 1>> "$log"
69 | migratekey_err
70 | else
71 | finishkeymigrate
72 | fi
73 | elif [[ ! -d "${maindir}/other/.keystores" ]] && [[ ! -d "${HOME}/.apkmanager/.keystores" ]]; then
74 | echo $white"No existing keys found, creating new private key directory in:"; $rclr;
75 | echo $green"${HOME}/.apkmanager/.keystores"; $rclr;
76 | mkdir -p "$HOME/.apkmanager/.keystores"
77 | elif [[ -d "${maindir}/other/.keystores" ]] && [[ -d "${HOME}/.apkmanager/.keystores" ]]; then
78 | echo $white"Found both old private KEY(s) directory in:"
79 | echo $green"${maindir}/other/.keystores"; $rclr;
80 | echo $white"and new v2.1+ private KEY(s) directory in:"
81 | echo $green"${HOME}/.apkmanager/.keystores"; $rclr;
82 | echo $white"comparing "$bgreen"${maindir}/other/.keystores"; $rclr;
83 | echo $white"to "$bgreen"${HOME}/.apkmanager/.keystores"; $rclr;
84 | echo "comparing ${maindir}/other/.keystores to ${HOME}/.apkmanager/.keystores" 1>> "$log"
85 | diff -rq "${maindir}/other/.keystores" "${HOME}/.apkmanager/.keystores" 1>> "$log" 2>&1
86 | if [[ $? -ne 0 ]]; then
87 | echo "ERROR MIGRATING PRIVATE KEYS TO v2.1+ SCHEMA" 1>> "$log"
88 | migratekey_err
89 | else
90 | echo $bgreen"Directories match, key migration already completed."; $rclr;
91 | finishkeymigrate
92 | fi
93 | else
94 | echo $bgreen"Already using v2.1+ private key schema"; $rclr;
95 | echo ""
96 | echo "Already using v2.1+ private key schema" 1>> "$log"
97 | fi
98 | }
99 |
100 | # Actually migrate user settings
101 | migrate_settings () {
102 | echo "migrate_settings (migrate settings to v3.0+ plist) function" 1>> "$log"
103 | if [[ ${needmigrate} = v2 ]]; then
104 | dir="${maindir}/other"
105 | else
106 | dir="${HOME}/.apkmanager"
107 | fi
108 | for f in ".debuginfo" ".migration" ".debug" ".colors"
109 | do
110 | if [[ -e "${dir}/${f}" ]]; then
111 | rm -r "${dir}/${f}"
112 | fi
113 | done
114 | for f in ".complvl" ".heap" ".keychoice" ".logviewapp" ".pngtool"
115 | do
116 | if [[ -e "${dir}/${f}" ]]; then
117 | if [[ ${f} = .complvl ]]; then
118 | usrsetting="persistent compression level"
119 | elif [[ ${f} = .heap ]]; then
120 | usrsetting="persistent java heap size"
121 | elif [[ ${f} = .keychoice ]]; then
122 | usrsetting="persistent private keystore selection"
123 | elif [[ ${f} = .logviewapp ]]; then
124 | usrsetting="text/log viewing application selection"
125 | elif [[ ${f} = .pngtool ]]; then
126 | usrsetting="persistent png tool setting"
127 | fi
128 | echo $white" found $(basename ${dir}/${f}) file "$bgreen"(${usrsetting})"; $rclr;
129 | echo $white" writing preference into plist file..."; $rclr;
130 | local key="${f##*.}"
131 | local value="$(awk '{print $0}' "${dir}/${f}")"
132 | write_preference
133 | rm -r "${dir}/${f}"
134 | fi
135 | done
136 | if [[ ${needmigrate} = v3 ]]; then
137 | unset needmigrate
138 | fi
139 | echo "migrate_settings function complete" 1>> "$log"
140 | }
141 |
142 | # Main migration skeleton
143 | migrate () {
144 | echo "migrate (check/migrate settings & private keys) function" 1>> "$log"
145 | if [[ -z ${header_shown} ]]; then
146 | clear
147 | echo ""
148 | version_banner
149 | echo ""
150 | echo $bwhite"APK Manager OS X migrate script (migrate user settings and private keys to v3.0+ schema)"
151 | echo "This should only appear on first launch of APK Manager, or when manually upgrading"
152 | echo "individual APK Manager files to version 3.0a or greater."; $rclr;
153 | header_shown=1
154 | fi
155 | echo ""
156 | echo $bgreen"Checking for pre ${needmigrate} persistent user settings to migrate..."
157 | echo ""
158 | migrate_settings
159 | if [[ -z ${needmigrate} ]]; then
160 | echo $bgreen"v3.0+ user settings migration complete!"; $rclr;
161 | echo ""
162 | echo $bgreen"Checking for private key(s) to migrate..."; $rclr;
163 | keymigrate
164 | echo ""
165 | fi
166 | echo "migrate function complete" 1>> "$log"
167 | }
168 |
169 | # Check for anything post v2.1 but pre v3.0
170 | migrate_check_two () {
171 | local dir="${HOME}/.apkmanager"
172 | local f
173 | local count
174 | for f in ".complvl" ".heap" ".keychoice" ".logviewapp" ".pngtool" ".debuginfo" ".migration" ".debug" ".colors"
175 | do
176 | if [[ -e "${dir}/${f}" ]]; then
177 | count=$((count+1))
178 | fi
179 | done
180 | if [[ $count -ne 0 ]]; then
181 | needmigrate="v3"
182 | fi
183 | cd "${maindir}"
184 | }
185 |
186 | # Check for anything pre-2.1
187 | migrate_check_one () {
188 | local dir="${maindir}/other"
189 | local f
190 | local count
191 | for f in ".complvl" ".heap" ".keychoice" ".logviewapp" ".pngtool" ".keystores" ".debuginfo"
192 | do
193 | if [[ -e "${dir}/${f}" ]]; then
194 | count=$((count+1))
195 | fi
196 | done
197 | if [[ $count -ne 0 ]]; then
198 | needmigrate="v2"
199 | fi
200 | cd "${maindir}"
201 | }
202 |
203 | # Migration check skeleton
204 | migratecheck () {
205 | user_dir_check
206 | migrate_check_one
207 | if [[ ${needmigrate} ]]; then
208 | migrate
209 | fi
210 | migrate_check_two
211 | if [[ ${needmigrate} ]]; then
212 | migrate
213 | finishmigrate
214 | genericpanykey
215 | else
216 | echo "Nothing to migrate" 1>> "$log" 2>&1
217 | finishmigrate
218 | fi
219 | }
220 |
221 | # Start
222 | migratecheck
223 | return 0
224 |
--------------------------------------------------------------------------------
/other/lib/misc_funcs.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v3.0+
4 | # misc/catch-all functions
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.1b
10 | # Wed. Jul 31, 2013
11 | # -----------------------------------------------------------------------
12 |
13 | # Prompt user for android.jar location
14 | and_sdk_err () {
15 | echo "and_sdk_err (request android.jar location) function" 1>> "$log"
16 | clear
17 | menu_header
18 | echo $bred" WARNING: APK Manager wasn't able to automatically"
19 | echo $bred" determine the location of the Android SDK."
20 | echo ""
21 | echo $white" APK Manager needs \"android.jar\" from the sdk in order"
22 | echo $white" to compile .9.png files without a working project"
23 | echo ""
24 | echo $white" If you have the Android SDK installed, you can set the"
25 | echo $white" location to \"android.jar\" manually now."
26 | echo ""
27 | echo $bwhite" Please drag \"android.jar\" into this window and press enter"
28 | echo $bwhite" or leave blank and press enter to quit."
29 | echo $bgreen"$apkmspr";
30 | read input
31 | if [[ -z $input ]]; then
32 | return 1
33 | else
34 | andjar="$input"
35 | fi
36 | unset input
37 | echo "and_sdk_err function complete" 1>> "$log"
38 | }
39 |
40 | # Try to locate android.jar
41 | andsdk_check () {
42 | echo "andsdk_check (check for android sdk) function" 1>> "$log"
43 | if [[ $(command -v brew) ]] && [[ $(dirname "$(command -v android)") = "/usr/local/bin" ]]; then
44 | local sdkrev="/usr/local/var/lib/android-sdk/platforms"
45 | sdkrev="${sdkrev}/$(ls -1 "${sdkrev}" | sort -n -r -t - -k 2 | head -n 1)"
46 | andjar="${sdkrev}/android.jar"
47 | elif [[ $(command -v android) ]] && [[ ! $(dirname "$(command -v android)") = "/usr/local/bin" ]]; then
48 | local sdkrev="$(dirname "$(dirname "$(command -v android)")")"
49 | sdkrev="${sdkrev}/platforms/$(ls -1 "${sdkrev}" | sort -n -r -t - -k 2 | head -n 1)"
50 | andjar="${sdkrev}/android.jar"
51 | else
52 | and_sdk_err
53 | fi
54 | echo "andsdk_check function complete" 1>> "$log"
55 | }
56 |
57 | # Generate manifest for compiling .9.png files
58 | gen_temp_manifest () {
59 | cat >"${maindir}/temp/AndroidManifest.xml" <
61 |
65 |
66 | EOF
67 | }
68 |
69 | # Setup ./temp dir for compiling .9.png files
70 | temp_dir_setup () {
71 | echo "temp_dir_setup (create temporary folders) function" 1>> "$log"
72 | if [[ -d "${maindir}/temp" ]]; then
73 | rm -r "${maindir}/temp"
74 | fi
75 | mkdir -p "${maindir}/temp"
76 | mkdir -p "${maindir}/temp/res/drawable"
77 | mkdir -p "${maindir}/temp/res/drawable-mdpi"
78 | mkdir -p "${maindir}/temp/res/drawable-hdpi"
79 | mkdir -p "${maindir}/temp/res/layout"
80 | echo "temp_dir_setup function complete" 1>> "$log"
81 | }
82 |
83 | # Compile .9.png files subroutine
84 | compile_9png_sub () {
85 | andsdk_check
86 | if [[ -z ${andjar} ]]; then
87 | echo $bred"ERROR: cannot find android.jar, aborting."
88 | echo "cannot find android.jar, aborting." 1>> "$log"
89 | return 1
90 | fi
91 | echo $bgreen" Using android.jar found here:"
92 | echo $green" ${andjar}"; $rclr;
93 | echo $bgreen" generating temporary AndroidManifest.xml file..."
94 | gen_temp_manifest
95 | local tmp_zip="$(mktemp -u "${maindir}"/temp/res-XXXXXX).zip"
96 | echo $bgreen" compiling resources now..."
97 | aapt package -v -f -M "${maindir}/temp/AndroidManifest.xml" -F "${tmp_zip}" -S "${maindir}/temp/res" -I "${andjar}" 1>> "$log" 2>&1
98 | if [[ $? -ne 0 ]]; then
99 | return 1
100 | fi
101 | echo $bgreen" extracting compiled files to temp/compiled..."
102 | 7za x -o"${maindir}/temp/compiled" "${tmp_zip}" -y 1>> "$log" 2>&1
103 | if [[ $? -ne 0 ]]; then
104 | echo "cannot extract ${tmp_zip}, aborting." 1>> "$log"
105 | return 1
106 | else
107 | echo $bgreen" removing termporary files..."
108 | rm -r "${tmp_zip}"
109 | rm -r "${maindir}/temp/AndroidManifest.xml"
110 | rm -r "${maindir}/temp/compiled/AndroidManifest.xml"
111 | rm -r "${maindir}/temp/compiled/resources.arsc"
112 | fi
113 | echo $bgreen" Resources compiled succesfully!"
114 | pressanykey
115 | unset andjar
116 | }
117 |
118 | # Compile .9.png files start page
119 | compile_9patch () {
120 | echo "compile_9patch (compile .9.png files) function" 1>> "$log"
121 | temp_dir_setup
122 | clear
123 | menu_header
124 | echo $bgreen"-----------------------------"$bwhite"Compile nine-patch and/or binary xml files"$bgreen"----------------------------- "
125 | echo $white" APK Manager has the ability to compile \"nine-patch\" png files"
126 | echo $white" and binary xml files without needing a working eclipse project,"
127 | echo $white" or using/hijacking an already decompiled apk file."
128 | echo ""
129 | echo $white" In your main apkmanager directory, you will find a new folder"
130 | echo ""
131 | echo $green" ${maindir}/temp"
132 | echo ""
133 | echo $white" This folder has a few of the most common android application"
134 | echo $white" resource folders already created inside. ex:"
135 | echo ""
136 | echo $green" ${maindir}/temp/res/drawable"
137 | echo $green" ${maindir}/temp/res/drawable-mdpi"
138 | echo $green" ${maindir}/temp/res/drawable-hdpi"
139 | echo $green" ${maindir}/temp/res/layout"
140 | echo ""
141 | echo $white" Please copy your source .9.png and xml files into the appropriate"
142 | echo $white" folders. Feel free to create any new folders you need too."
143 | echo $bgreen"$apkmspr";
144 | echo $bwhite"Once finished, come back here and press enter to continue..."
145 | wait
146 | compile_9png_sub
147 | echo "compile_9patch function complete" 1>> "$log"
148 | }
149 |
150 | # Optimize png images inisde a project folder
151 | opt_apk_png () {
152 | echo "opt_apk_png (optimize images inside apk) function" 1>> "$log"
153 | capp_test
154 | if [[ ${capp} = "None" ]]; then
155 | echo "no project selected, aborting" 1>> "$log"
156 | return 1
157 | elif [[ ${pngopts} = disabled ]];then
158 | echo $bred"ERROR, no png optimization program was not found on your system"
159 | echo $bred"this option is unavailable until one is installed"; $rclr;
160 | pressanykey
161 | elif [[ ! ${prjext} = [Aa][Pp][Kk] ]]; then
162 | jarext_err
163 | elif [[ ! -d "${maindir}/${prj_dir}/${capp}" ]]; then
164 | nodir_err
165 | elif [[ "$(ls -1 ${maindir}/${prj_dir}/${capp} | wc -l)" -eq 0 ]]; then
166 | nodir_err
167 | else
168 | if [[ -z ${pngtool} ]]; then
169 | pngtool="optipng"
170 | fi
171 | local png_file
172 | cd "${maindir}/${prj_dir}/${capp}"
173 | find "./res" -iname "*.png" | while read png_file ;
174 | do
175 | if [[ $(echo "${png_file}" | grep -c "\.9\.png$") -eq 0 ]]; then
176 | if [[ ${pngtool} = optipng ]]; then
177 | optipng -o99 "${png_file}"
178 | elif [[ ${pngtool} = pngcrush ]]; then
179 | pngcrush -reduce -brute -ow "${png_file}"
180 | elif [[ ${pngtool} = pngout ]]; then
181 | pngout "${png_file}"
182 | fi
183 | fi
184 | done
185 | fi
186 | echo "opt_apk_png function complete" 1>> "$log"
187 | }
188 |
189 | # Zipalign a single file
190 | zalign_file () {
191 | echo "zalign_file (single file) function" 1>> "$log"
192 | capp_test
193 | if [[ ${capp} = "None" ]]; then
194 | echo "no project selected, aborting" 1>> "$log"
195 | return 1
196 | else
197 | local string
198 | for string in "signed" "unsigned"
199 | do
200 | if [[ -e "${maindir}/${mod_dir}/${string}-${capp}" ]]; then
201 | zipalign -fv 4 "${maindir}/${mod_dir}/${string}-${capp}" "${maindir}/${mod_dir}/${string}-aligned-${capp}" 1>> "$log" 2>&1
202 | if [[ $? -eq 0 ]]; then
203 | mv -f "${maindir}/${mod_dir}/${string}-aligned-${capp}" "${maindir}/${mod_dir}/${string}-${capp}"
204 | fi
205 | else
206 | echo "zipalign: cannot find file ${mod_dir}/${string}-${capp}" 1>> "$log" 2>&1
207 | fi
208 | done
209 | fi
210 | echo "zalign_file function complete" 1>> "$log"
211 | }
212 |
213 | # Open a text file with log viewing app
214 | read_txt () {
215 | if [[ ${logviewer} = "nano" ]] || [[ ${logviewer} = "vi" ]] || [[ ${logviewer} = "emacs" ]]; then
216 | local apkmopt="${logviewer} ${txt}; exit"
217 | newttab "${apkmopt}" "$log"
218 | else
219 | "${logviewer}" "${txt}"
220 | fi
221 | unset txt
222 | }
223 |
--------------------------------------------------------------------------------
/other/lib/errors.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v3.0+
4 | # Common error strings library
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.2b
10 | # Wed. Aug 7, 2013
11 | # -----------------------------------------------------------------------
12 |
13 | # Unknown input error string
14 | input_err () {
15 | printf "$bred%s""Unknown command: $input press any key to try again...\n"; $rclr;
16 | wait
17 | clear
18 | }
19 |
20 | # Unknown input error string, no new line at end
21 | input_err_noline () {
22 | printf "$bred%s""Unknown command: $input press any key to try again..."; $rclr;
23 | wait
24 | clear
25 | }
26 |
27 | # main menu, press-any-key string
28 | pressanykey () {
29 | printf "$bred%s""press any key to return to main menu...\n"; $rclr;
30 | wait
31 | }
32 |
33 | # signing menu, press-any-key string
34 | signpanykey () {
35 | printf "$bred%s""press any key to return to signing menu...\n"; $rclr;
36 | wait
37 | }
38 |
39 | # generic 'continue' press-any-key string
40 | genericpanykey () {
41 | printf "$bwhite%s""press any key to continue...\n"; $rclr;
42 | wait
43 | }
44 |
45 | # debug menu, press-any-key string
46 | debuganykey () {
47 | printf "$bred%s""press any key to return to debug menu\n"; $rclr;
48 | wait
49 | }
50 |
51 | # updates menu, press-any-key string
52 | updateanykey () {
53 | printf "$bred%s""press any key to return to updates menu\n"; $rclr;
54 | wait
55 | }
56 |
57 | # ADB menu, press-any-key string
58 | adbanykey () {
59 | printf "$bred%s""press any key to return to ADB menu\n"; $rclr;
60 | wait
61 | }
62 |
63 | # fatal error press-any-key string
64 | fatalpanykey () {
65 | printf "$bred%s""press any key to exit...\n"; $rclr;
66 | wait
67 | }
68 |
69 | # fatal error while checking for required programs string
70 | startup_check_fatal_err () {
71 | echo $bred"The program ${prg} is missing or is not in your"
72 | echo $bred"\$PATH, please install it or fix your \$PATH."
73 | echo "${prg} is missing or not in PATH" 1>> "$log" 2>&1
74 | }
75 |
76 | # .jar file extension error string
77 | jarext_err () {
78 | echo $bred"Error, this option only available for APK files"; $rclr;
79 | echo "Error, this option only available for APK files" 1>> "$log"
80 | pressanykey
81 | }
82 |
83 | # file not found error string
84 | notfound_err () {
85 | echo $bred"Selected project file $capp cannot be found"; $rclr;
86 | echo "Selected project file $capp cannot be found" 1>> "$log"
87 | pressanykey
88 | }
89 |
90 | # not yet extracted/decompiled error string
91 | nodir_err () {
92 | echo $bred"Error, $prjext has not yet been extracted/decompiled";
93 | echo "Error, $prjext has not yet been extracted/decompiled" 1>> "$log"
94 | echo $bred"Please use \"extract\" or \"decompile\" option first"; $rclr;
95 | pressanykey
96 | }
97 |
98 | # project not decompile error string
99 | nodec_err () {
100 | echo $bred"Error, project was not decompiled";
101 | echo "Error, project was not decompiled" 1>> "$log"
102 | echo $bred"Please use \"zip\" or \"advanced\" options instead"; $rclr;
103 | pressanykey
104 | }
105 |
106 | # project not extracted error string
107 | noex_err () {
108 | echo $bred"Error, project was decompiled not extracted";
109 | echo "Error, project was decompiled not extracted" 1>> "$log"
110 | echo $bred"Please use \"compile\" or \"advanced\" options instead"; $rclr;
111 | pressanykey
112 | }
113 |
114 | # dex2jar, classes.dex extract error string
115 | decj_extdex_err () {
116 | echo $bred"An error occured while extracting classes.dex, please check log."; $rclr;
117 | pressanykey
118 | }
119 |
120 | # dex2jar, classes.dex decompile error string
121 | decj_process_dex_err () {
122 | echo $bred"An error occured while decompiling classes.dex, please check log."; $rclr;
123 | pressanykey
124 | }
125 |
126 | # dex2jar, jar extract error string
127 | decj_extract_jar_err () {
128 | echo $bred"An error occured while extracting jar file, please check log."; $rclr;
129 | pressanykey
130 | }
131 |
132 | # overwrite existing project folder prompt
133 | overwrite_prompt () {
134 | echo $bred"Warning, /projects/$capp exists";
135 | printf "$white%s""Overwrite project folder? ("$bgreen"y"$white"/"$bgreen"n"$white") "; $rclr;
136 | }
137 |
138 | # all-in-one 'java source' error
139 | aio_java_err () {
140 | echo $bred"Error, project was decompiled to java source";
141 | echo $bred"Please delete the /projects/$capp/java"; $rclr;
142 | echo $bred"folder and try your selection again."; $rclr;
143 | echo "Error, project was decompiled to java source" 1>> "$log"
144 | pressanykey
145 | }
146 |
147 | # no .git directory found error string
148 | updates_dir_err () {
149 | echo $bred"ERROR: APK Manager was not setup using \"git\".";
150 | echo $bred"If you would like to enable Automatic Updates,";
151 | echo $bred"please re-install APK Manager using \"git clone ...\"";
152 | echo $bred"Instructions can be found on github here:"; $rclr;
153 | echo $bred"https://github.com/jocelynmallon/apkmanager"; $rclr;
154 | genericpanykey
155 | }
156 |
157 | # 'git' not found error string
158 | updates_git_err () {
159 | echo $bred"ERROR: \"git\" was not found on this system.";
160 | echo $bred"Unfortunately, git is required to enable and use";
161 | echo $bred"the included automatic update features. Please";
162 | echo $bred"download and instal git, or fix your \$PATH"; $rclr;
163 | genericpanykey
164 | }
165 |
166 | # failure trying to pull/update apk manager error string
167 | git_pull_error () {
168 | echo $bred"FATAL ERROR: APK Manager failed trying"
169 | echo $bred"to run \"git pull\" to check for updates"
170 | echo $bred"please check the log for details."
171 | fatalpanykey
172 | defaults delete $plist update_prompt 2>/dev/null
173 | echo "GIT PULL EROOR: $(gen_date)" 1>> "$log" 2>&1
174 | echo "$apkmftr" 1>> "$log" 2>&1
175 | exit 1
176 | }
177 |
178 | # failure to checkout git branch error string
179 | git_checkout_error () {
180 | echo $bred"ERROR: APK Manager failed trying to checkout"
181 | echo $bred"$saved_channel branch to check for updates"
182 | echo $bred"please check the log for details."
183 | fatalpanykey
184 | }
185 |
186 | # failure when attempting 'git config' error string
187 | git_config_error () {
188 | echo $bred"ERROR: APK Manager failed trying to set"
189 | echo $bred"git config options to check for updates"
190 | echo $bred"please check the log for details."
191 | fatalpanykey
192 | }
193 |
194 | # no branches to checkout error string
195 | no_branches_err () {
196 | echo $bred"ERROR: APK Manager only found one remote"
197 | echo $bred"branch. There's nothing to switch to."
198 | echo $bred"please check the log for details."
199 | updateanykey
200 | }
201 |
202 | # had to change branches message/error string
203 | git_branch_change () {
204 | echo $bgreen"APK Manager had to switch branches"; $rclr;
205 | echo $bgreen"during the update, and will now exit."; $rclr;
206 | }
207 |
208 | # no preferred ADB device error
209 | adb_saved_device_error () {
210 | echo $bred"ERROR: APK Manager found an invalid setting for"; $rclr;
211 | echo $bred"your saved ADB device preference: ${adb_dev_choice}"; $rclr;
212 | echo $bred"APK Manager will reset your saved ADB device."; $rclr;
213 | genericpanykey
214 | }
215 |
216 | # no preferred ADB device error
217 | adb_saved_device_state_error () {
218 | echo $bred"ERROR: When attempting to connect to: ${adb_dev_choice}"; $rclr;
219 | echo $bred"APK Manager found ADB device status: ${adbstat}"; $rclr;
220 | echo $bred"Please try re-connecting your ADB device before using"; $rclr;
221 | echo $bred"any ADB options (e.g. push, pull, shell, etc.)"; $rclr;
222 | echo $bred"APK Manager will reset your saved ADB device now too."; $rclr;
223 | genericpanykey
224 | }
225 |
226 | # failed to connect to wireless ADB device
227 | adb_wireless_connection_error () {
228 | echo $bred"ERROR: APK Manager failed to connect to: ${adb_dev_choice}"; $rclr;
229 | echo $bred"Within the default 5 second timeout. Please ensure"; $rclr;
230 | echo $bred"Wireelss ADB is running on your device, and the device"; $rclr;
231 | echo $bred"is connected to the same network as your computer"; $rclr;
232 | if [[ -n $adb_startup_check ]]; then
233 | echo $bred"APK Manager will reset your saved ADB device now too."; $rclr;
234 | fi
235 | genericpanykey
236 | }
237 |
238 | # no preferred ADB device error
239 | adb_nodevice_error () {
240 | echo $bred"ERROR: no preferred ADB device selected"; $rclr;
241 | genericpanykey
242 | }
243 |
244 | # failed to restart adb daemon as root error
245 | adb_device_root_error () {
246 | echo $bred"ERROR: failed to restart ADB Daemon on: ${adb_dev_choice}"; $rclr;
247 | echo $bred"as root. Please ensure that your device has root access,"; $rclr;
248 | echo $bred"and root for ADB shell is enabled, then try again."; $rclr;
249 | genericpanykey
250 | }
251 |
252 | # Project APK not found on device to uninstall
253 | apk_not_installed_err () {
254 | echo $bred"ERROR: APK Maanger did not find an installed APK"; $rclr;
255 | echo $bred"with package name: "$bpink"${apk_package}"; $rclr;
256 | echo $bred"to uninstall from your device. Please ensure the"; $rclr;
257 | echo $bred"package names match, or try uninstalling"; $rclr;
258 | echo $bred"the app from your device manually."; $rclr;
259 | genericpanykey
260 | }
261 |
262 | # failed to uninstall selected APK error
263 | apk_uninstall_failed_err () {
264 | echo $bred"ERROR: Something went wrong while attempting"; $rclr;
265 | echo $bred"to uninstall: ${apk_package}"; $rclr;
266 | echo $bred"Please ensure the app is installed, and not"; $rclr;
267 | echo $bred"a system app, and try again."; $rclr;
268 | genericpanykey
269 | }
270 |
271 | # no preferred ADB device error
272 | adb_multiple_devices_error () {
273 | echo $bred"ERROR: APK Maanger found multiple ADB devices"; $rclr;
274 | echo $bred"connected to this computer. Please select a"; $rclr;
275 | echo $bred"specific ADB device to use for ADB functions."; $rclr;
276 | genericpanykey
277 | }
278 |
279 | # ADB device missing info error
280 | adb_device_missing_info_error () {
281 | echo $bred"ERROR: ADB device information is incomplete or"; $rclr;
282 | echo $bred"corrupted. Please re-select ADB device and try again."; $rclr;
283 | adbanykey
284 | }
285 |
286 | # Android Studio App not found error
287 | andstudio_notfound_err () {
288 | echo $bred"ERROR: Android Studio was not found, or is not installed"; $rclr;
289 | echo $bred"in default location (/Applications/Android Studio.app)"; $rclr;
290 | genericpanykey
291 | }
292 |
293 | # ANDROID_SDK_ROOT unset, error message
294 | android_sdk_root_err () {
295 | echo $bred"WARNING: ANDROID_SDK_ROOT is not set. This"
296 | echo $bred"\"might\" cause problems for APK Manager."
297 | echo $bred"If you have the Android SDK installed, please"
298 | echo $bred"add the following to your .bashrc/.zshrc/etc."
299 | echo ""
300 | echo $bred"export \"ANDROID_SDK_ROOT=/path/to/sdk/root\""
301 | echo ""
302 | pressanykey
303 | }
304 |
--------------------------------------------------------------------------------
/other/lib/sign_funcs.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v3.0+
4 | # File signing functions
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.0
10 | # Sun. Oct 07, 2012
11 | # -----------------------------------------------------------------------
12 |
13 | # Cleanup for advanced signing functions
14 | signcleanup () {
15 | unset alias
16 | unset f
17 | unset files
18 | unset batchnum
19 | unset storenum
20 | unset infile
21 | unset input
22 | unset outfile
23 | }
24 |
25 | # Actually sign with test key
26 | signtkey () {
27 | echo "signtkey, actually signing now" 1>> "$log"
28 | runj signapk -JXmx"${heapy}""m" -w "${libdir}/testkey.x509.pem" "${libdir}/testkey.pk8" "${infile}" "${outfile}" 1>> "$log" 2>&1
29 | }
30 |
31 | # Sign an apk file with test key (signapk.jar)
32 | sign_apk_tk () {
33 | echo "sign_apk_tk (with test keys) function" 1>> "$log"
34 | capp_test
35 | if [[ ${capp} = "None" ]]; then
36 | echo "no project selected, aborting" 1>> "$log"
37 | return 1
38 | elif [[ ! ${prjext} = [Aa][Pp][Kk] ]]; then
39 | jarext_err
40 | else
41 | infile="${maindir}/${mod_dir}/unsigned-${capp}"
42 | outfile="${maindir}/${mod_dir}/signed-${capp}"
43 | if [[ ! -f "${infile}" ]]; then
44 | echo $bred"Error, cannot find file: unsigned-${capp}";
45 | echo "Error, cannot find file: unsigned-${capp}" 1>> "$log"
46 | echo $bred"Please use \"zip\" or \"compile\" options first"; $rclr;
47 | pressanykey
48 | else
49 | signtkey
50 | if [[ $? -ne 0 ]]; then
51 | echo $bred"Error signing unsigned-${capp}, please check log"; $rclr;
52 | pressanykey
53 | else
54 | rm "${infile}"
55 | fi
56 | fi
57 | signcleanup
58 | fi
59 | echo "sign_apk_tk function complete" 1>> "$log"
60 | }
61 |
62 | # Check for keystore(s) and persistent setting
63 | storecheck () {
64 | echo "storecheck (check for existing keystores) function" 1>> "$log"
65 | if [[ ! -d "${HOME}/.apkmanager/.keystores" ]]; then
66 | keystore="None"
67 | return 1
68 | fi
69 | keystore="$(defaults read "${plist}" keychoice 2>/dev/null)"
70 | if [[ $? -ne 0 ]]; then
71 | cd "${HOME}/.apkmanager/.keystores"
72 | local storenum="$(ls -1 *.[kK][eE][yY][sS][tT][oO][rR][eE] | wc -l)"
73 | if [[ ${storenum} = 0 ]]; then
74 | keystore="None"
75 | elif [[ ${storenum} -gt 1 ]]; then
76 | keystore="Multiple keystores found, please select one below"
77 | else
78 | keystore="$(ls -1 *.[kK][eE][yY][sS][tT][oO][rR][eE])"
79 | fi
80 | cd "${maindir}"
81 | fi
82 | }
83 |
84 | # Actually verifying signature of file/files
85 | sigverify () {
86 | echo "sigverify, actually verifying now" 1>> "$log"
87 | local f
88 | for f in ${files}; do
89 | jarsigner -verify -verbose ${f} 1>> "$log" 2>&1
90 | if [[ $? -ne 0 ]]; then
91 | echo $bred"An error occured verifying $(basename "${f}")";
92 | echo $bred"please check the log for details"; $rclr;
93 | else
94 | echo $green"$(basename "${f}") verified; ok."; $rclr;
95 | fi
96 | done
97 | signcleanup
98 | }
99 |
100 | # Verify signature of a single file
101 | single_vrfy () {
102 | echo "single_vrfy (verify a single file signature) function" 1>> "$log"
103 | capp_test
104 | if [[ ${capp} = "None" ]]; then
105 | echo "no project selected, aborting" 1>> "$log"
106 | return 1
107 | elif [[ ! -f "${maindir}/${mod_dir}/signed-${capp}" ]]; then
108 | echo "signed-${capp} not found, nothing to verify."
109 | signpanykey
110 | echo "signed-${capp} not found, aborting." 1>> "$log"
111 | return 1
112 | else
113 | files="${maindir}/${mod_dir}/signed-${capp}"
114 | sigverify
115 | signpanykey
116 | fi
117 | echo "single_vrfy function complete" 1>> "$log"
118 | }
119 |
120 | # Batch verify signature of files
121 | batch_vrfy () {
122 | echo "batch_vrfy (batch verify signature) function" 1>> "$log"
123 | local batchnum="$(ls -1 | wc -l)"
124 | if [[ ${batchnum} = 0 ]]; then
125 | echo $bred"Error, nothing to verify"; $rclr;
126 | else
127 | files=$(find "${maindir}/${sig_dir}" -type f \( -iname "*.apk" -o -iname "*.jar" \))
128 | sigverify
129 | fi
130 | signpanykey
131 | echo "batch_vrfy function complete" 1>> "$log"
132 | }
133 |
134 | # Actually sign a single file with private key
135 | signpkey () {
136 | echo "signpkey, actually signing now" 1>> "$log"
137 | jarsigner -verbose -keystore "${HOME}/.apkmanager/.keystores/${keystore}" "${infile}" "${key}"
138 | if [[ $? -ne 0 ]]; then
139 | echo $bred"An error occured signing ${infile}";
140 | echo $bred"please check the log for details"; $rclr;
141 | else
142 | echo $green"$(basename "${infile}") signed; ok."; $rclr;
143 | cp "${infile}" "${maindir}/${mod_dir}/signed-${capp}"
144 | rm "${infile}"
145 | fi
146 | }
147 |
148 | # Batch-sign with private keys, actually signing
149 | bsignpkey () {
150 | echo "bsignpkey, actually signing now" 1>> "$log"
151 | local spasswrd
152 | local kpasswrd
153 | local f
154 | echo ""
155 | printf "$white%s""Enter passphrase for keystore "$bgreen"${keystore}"$white": "; $rclr;
156 | read -s spasswrd
157 | echo ""
158 | printf "$white%s""Enter key password for "$bgreen"${key}"$white": "; $rclr;
159 | echo ""
160 | read -s kpasswrd
161 | find "${maindir}/${sig_dir}" -iname "*signed*" -exec mv {} ~/.Trash \;
162 | find "${maindir}/${sig_dir}" -type f \( -iname "*.apk" -o -iname "*.jar" \) | while read f ;
163 | do
164 | f="$(basename "${f}")"
165 | jarsigner -verbose -keystore "${HOME}/.apkmanager/.keystores/${keystore}" -storepass "${spasswrd}" -keypass "${kpasswrd}" "${maindir}/${sig_dir}/${f}" "${key}"
166 | if [[ $? -ne 0 ]]; then
167 | echo $bred"An error occured signing ${f}";
168 | echo $bred"please check the log for details"; $rclr;
169 | else
170 | echo $green"${f} signed; ok."; $rclr;
171 | cp "${maindir}/${sig_dir}/${f}" "${maindir}/${sig_dir}/signed-${f}"
172 | rm "${maindir}/${sig_dir}/${f}"
173 | fi
174 | done
175 | }
176 |
177 | # Sign with private keys info text/prompt
178 | sign_prompt () {
179 | echo "sign_prompt (sign with private keys prompt) function" 1>> "$log"
180 | clear
181 | menu_header
182 | echo $bgreen"$apkmspr";
183 | echo ""
184 | echo $white" APK Manager will attempt to sign all apk or jar files in the";
185 | echo $green" \"${sig_dir}\""$white" folder, using your selected private key:"; $rclr;
186 | echo ""
187 | echo $white" Keystore: "$bgreen"${keystore}";
188 | echo $white" Key: "$bgreen"${key}"; $rclr;
189 | echo ""
190 | echo $blue" (you will be asked for both your keystore and key passwords)";
191 | echo $bgreen"$apkmftr"
192 | genericpanykey
193 | }
194 |
195 | # Sign a single file with private key initial checks
196 | sign_apk_pk () {
197 | echo "sign_apk_pk (sign single file with private key) function" 1>> "$log"
198 | capp_test
199 | if [[ ${capp} = "None" ]]; then
200 | echo "no project selected, aborting" 1>> "$log"
201 | return 1
202 | elif [[ ! ${keystore##*.} = [kK][eE][yY][sS][tT][oO][rR][eE] ]]; then
203 | echo $bred"Error, invalid or no keystore selected."; $rclr;
204 | signpanykey
205 | else
206 | storename="${keystore%%.*}"
207 | key="$(awk '{ print $0}' "${HOME}/.apkmanager/.keystores/.${storename}_keyname")"
208 | infile="${maindir}/${mod_dir}/unsigned-${capp}"
209 | if [[ ! -e "${infile}" ]]; then
210 | echo $bred"Error, Cannot find $(basename "${infile}") to sign"; $rclr;
211 | signpanykey
212 | else
213 | sign_prompt
214 | signpkey
215 | signpanykey
216 | fi
217 | unset infile
218 | fi
219 | echo "sign_apk_pk function complete" 1>> "$log"
220 | }
221 |
222 | # Batch sign files with private key initial checks
223 | batch_sign_pk () {
224 | echo "batch_sign_pk (batch sign with private key) function" 1>> "$log"
225 | if [[ ! ${keystore##*.} = [kK][eE][yY][sS][tT][oO][rR][eE] ]]; then
226 | echo $bred"Error, invalid or no keystore selected."; $rclr;
227 | signpanykey
228 | else
229 | storename="${keystore%%.*}"
230 | key="$(awk '{ print $0}' "${HOME}/.apkmanager/.keystores/.${storename}_keyname")"
231 | local batchnum="$(ls "${maindir}/${sig_dir}" | wc -l)"
232 | if [[ ${batchnum} -eq 0 ]]; then
233 | echo $bred"Error, nothing to sign"; $rclr;
234 | signpanykey
235 | else
236 | sign_prompt
237 | bsignpkey
238 | signpanykey
239 | fi
240 | fi
241 | echo "batch_sign_pk function complete" 1>> "$log"
242 | }
243 |
244 | # Actually generate private key/keystore
245 | genpkey () {
246 | echo "create new privte key, actually generating key now" 1>> "$log"
247 | keytool -genkey -v -keystore "${keystore}" -alias "${alias}" -keyalg RSA -keysize 2048 -validity 10000
248 | echo "$logspcr" 1>> "$log" 2>&1
249 | echo "created keystore: ${keystore}" 1>> "$log" 2>&1
250 | echo "contains private key: ${alias}" 1>> "$log" 2>&1
251 | echo "$logspcr" 1>> "$log" 2>&1
252 | echo "${alias}" 1> "${HOME}/.apkmanager/.keystores/.${keystore%%.*}_keyname"
253 | }
254 |
255 | # Create a private key/keystore main function
256 | createpkey () {
257 | echo "createpkey (create new privte key) function" 1>> "$log"
258 | if [[ ! -d "${HOME}/.apkmanager/.keystores" ]]; then
259 | mkdir -p "${HOME}/.apkmanager/.keystores"
260 | fi
261 | cd "${HOME}/.apkmanager/.keystores"
262 | echo $white"Enter a name for your new keystore ("$green"e.g. myprivatekey.keystore"$white")"; $rclr;
263 | read input
264 | if [[ ! ${input##*.} = [kK][eE][yY][sS][tT][oO][rR][eE] ]]; then
265 | keystore="${input%%.*}.keystore"
266 | else
267 | keystore="$input"
268 | fi
269 | echo $white"Enter a unique alias name? ("$green"e.g. myprivatekey, testing, etc."$white")";
270 | echo $green"(Leave blank to use keystore name for alias too)"; $rclr;
271 | read input
272 | if [[ ! -z $input ]]; then
273 | alias="$input"
274 | else
275 | alias="${keystore%%.*}"
276 | fi
277 | echo $white"Keystore name "$bgreen"${keystore}"; $rclr;
278 | echo $white"Alias name: "$bgreen"${alias}"; $rclr;
279 | printf "$white%s""Proceed with these names? ("$bgreen"y"$white"/"$bgreen"n"$white") "; $rclr;
280 | read input
281 | case "$input" in
282 | [yY]) genpkey; unset keystore ;;
283 | [nN]) ;;
284 | *) input_err; createpkey ;;
285 | esac
286 | signcleanup
287 | echo "createpkey function complete" 1>> "$log"
288 | }
289 |
290 | # Set persistent keystore selection
291 | savekey () {
292 | echo "savekey (save default keystore setting) function" 1>> "$log"
293 | if [[ ! ${keystore##*.} = [kK][eE][yY][sS][tT][oO][rR][eE] ]]; then
294 | echo $bred"Error, invalid or no keystore selected."; $rclr;
295 | signpanykey
296 | else
297 | local key="keychoice"
298 | local value="${keystore}"
299 | write_preference
300 | fi
301 | }
302 |
303 | # Actually delete a private key/keystore
304 | delpkey () {
305 | echo "delpkey, actually deleting now" 1>> "$log"
306 | cd "${HOME}/.apkmanager/.keystores"
307 | echo "removing ${keystore}" 1>> "$log" 2>&1
308 | rm "${keystore}"
309 | rm ".${keystore%%.*}_keyname"
310 | clean_keystore
311 | }
312 |
313 | # Delete a private key/keystore prompt
314 | delkey () {
315 | echo "delkey (delete private key) function" 1>> "$log"
316 | if [[ ! ${keystore##*.} = [kK][eE][yY][sS][tT][oO][rR][eE] ]]; then
317 | echo $bred"Error, invalid or no keystore selected."; $rclr;
318 | signpanykey
319 | else
320 | storename="${keystore%%.*}"
321 | key="$(awk '{ print $0}' "${HOME}/.apkmanager/.keystores/.${storename}_keyname")"
322 | echo $bgreen"Selected keystore is: ${keystore}"; $rclr;
323 | printf "$white%s""Delete this keystore? ("$bgreen"y"$white"/"$bgreen"n"$white") "; $rclr;
324 | read input
325 | case "$input" in
326 | [yY]) delpkey ;;
327 | [nN]) ;;
328 | *) input_err delkey ;;
329 | esac
330 | fi
331 | echo "delkey function complete" 1>> "$log"
332 | }
333 |
--------------------------------------------------------------------------------
/JocelynCustom.terminal:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ANSIBlackColor
6 |
7 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
8 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAB
9 | TxAnMC40ODYyNzQ1MDk4IDAuNDg2Mjc0NTA5OCAwLjQ4NjI3NDUwOTgA0hAREhNaJGNs
10 | YXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFyY2hp
11 | dmVy0RcYVHJvb3SAAQgRGiMtMjc7QUhPXGJkZpCVoKmxtL3P0tcAAAAAAAABAQAAAAAA
12 | AAAZAAAAAAAAAAAAAAAAAAAA2Q==
13 |
14 | ANSIBlueColor
15 |
16 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
17 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAC
18 | TxAbMC43MTM3MjU0OTAyIDAuODYyNzQ1MDk4IDEA0hAREhNaJGNsYXNzbmFtZVgkY2xh
19 | c3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFyY2hpdmVy0RcYVHJvb3SA
20 | AQgRGiMtMjc7QUhPXGJkZoSJlJ2lqLHDxssAAAAAAAABAQAAAAAAAAAZAAAAAAAAAAAA
21 | AAAAAAAAzQ==
22 |
23 | ANSIBrightBlackColor
24 |
25 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
26 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAB
27 | TxAqMC4wOTgwMzkyMTcyOSAwLjA5ODAzOTIxNzI5IDAuMDk4MDM5MjE3MjkA0hAREhNa
28 | JGNsYXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFy
29 | Y2hpdmVy0RcYVHJvb3SAAQgRGiMtMjc7QUhPXGJkZpOYo6y0t8DS1doAAAAAAAABAQAA
30 | AAAAAAAZAAAAAAAAAAAAAAAAAAAA3A==
31 |
32 | ANSIBrightBlueColor
33 |
34 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
35 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAC
36 | TxAnMC41ODgyMzUyOTQxIDAuNzk2MDc4NDMxNCAwLjk5NjA3ODQzMTQA0hAREhNaJGNs
37 | YXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFyY2hp
38 | dmVy0RcYVHJvb3SAAQgRGiMtMjc7QUhPXGJkZpCVoKmxtL3P0tcAAAAAAAABAQAAAAAA
39 | AAAZAAAAAAAAAAAAAAAAAAAA2Q==
40 |
41 | ANSIBrightCyanColor
42 |
43 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
44 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAC
45 | TxAcMC41NjQ3MDU4ODI0IDAuOTQ1MDk4MDM5MiAxANIQERITWiRjbGFzc25hbWVYJGNs
46 | YXNzZXNXTlNDb2xvcqISFFhOU09iamVjdF8QD05TS2V5ZWRBcmNoaXZlctEXGFRyb290
47 | gAEIERojLTI3O0FIT1xiZGaFipWepqmyxMfMAAAAAAAAAQEAAAAAAAAAGQAAAAAAAAAA
48 | AAAAAAAAAM4=
49 |
50 | ANSIBrightGreenColor
51 |
52 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
53 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAC
54 | TxAcMC42NTg4MjM1Mjk0IDEgMC4zNzY0NzA1ODgyANIQERITWiRjbGFzc25hbWVYJGNs
55 | YXNzZXNXTlNDb2xvcqISFFhOU09iamVjdF8QD05TS2V5ZWRBcmNoaXZlctEXGFRyb290
56 | gAEIERojLTI3O0FIT1xiZGaFipWepqmyxMfMAAAAAAAAAQEAAAAAAAAAGQAAAAAAAAAA
57 | AAAAAAAAAM4=
58 |
59 | ANSIBrightMagentaColor
60 |
61 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
62 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAC
63 | TxAcMSAwLjQ1MDk4MDM5MjIgMC45OTIxNTY4NjI3ANIQERITWiRjbGFzc25hbWVYJGNs
64 | YXNzZXNXTlNDb2xvcqISFFhOU09iamVjdF8QD05TS2V5ZWRBcmNoaXZlctEXGFRyb290
65 | gAEIERojLTI3O0FIT1xiZGaFipWepqmyxMfMAAAAAAAAAQEAAAAAAAAAGQAAAAAAAAAA
66 | AAAAAAAAAM4=
67 |
68 | ANSIBrightRedColor
69 |
70 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
71 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAC
72 | TxAcMSAwLjQyMzUyOTQxMTggMC4zNzY0NzA1ODgyANIQERITWiRjbGFzc25hbWVYJGNs
73 | YXNzZXNXTlNDb2xvcqISFFhOU09iamVjdF8QD05TS2V5ZWRBcmNoaXZlctEXGFRyb290
74 | gAEIERojLTI3O0FIT1xiZGaFipWepqmyxMfMAAAAAAAAAQEAAAAAAAAAGQAAAAAAAAAA
75 | AAAAAAAAAM4=
76 |
77 | ANSIBrightWhiteColor
78 |
79 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
80 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAC
81 | RjEgMSAxANIQERITWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xvcqISFFhOU09iamVj
82 | dF8QD05TS2V5ZWRBcmNoaXZlctEXGFRyb290gAEIERojLTI3O0FIT1xiZGZtcn2GjpGa
83 | rK+0AAAAAAAAAQEAAAAAAAAAGQAAAAAAAAAAAAAAAAAAALY=
84 |
85 | ANSIBrightYellowColor
86 |
87 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
88 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAC
89 | TxARMSAxIDAuNzEzNzI1NDkwMgDSEBESE1okY2xhc3NuYW1lWCRjbGFzc2VzV05TQ29s
90 | b3KiEhRYTlNPYmplY3RfEA9OU0tleWVkQXJjaGl2ZXLRFxhUcm9vdIABCBEaIy0yNztB
91 | SE9cYmRmen+Kk5uep7m8wQAAAAAAAAEBAAAAAAAAABkAAAAAAAAAAAAAAAAAAADD
92 |
93 | ANSICyanColor
94 |
95 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
96 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAB
97 | TxAnMC42MDQ4MzI4NDg4IDAuODY1ODk3NTI5MSAwLjg4MzA4NTAyOTEA0hAREhNaJGNs
98 | YXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFyY2hp
99 | dmVy0RcYVHJvb3SAAQgRGiMtMjc7QUhPXGJkZpCVoKmxtL3P0tcAAAAAAAABAQAAAAAA
100 | AAAZAAAAAAAAAAAAAAAAAAAA2Q==
101 |
102 | ANSIGreenColor
103 |
104 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
105 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAC
106 | TxAcMC44MDc4NDMxMzczIDEgMC42NzQ1MDk4MDM5ANIQERITWiRjbGFzc25hbWVYJGNs
107 | YXNzZXNXTlNDb2xvcqISFFhOU09iamVjdF8QD05TS2V5ZWRBcmNoaXZlctEXGFRyb290
108 | gAEIERojLTI3O0FIT1xiZGaFipWepqmyxMfMAAAAAAAAAQEAAAAAAAAAGQAAAAAAAAAA
109 | AAAAAAAAAM4=
110 |
111 | ANSIMagentaColor
112 |
113 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
114 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAC
115 | TxAcMSAwLjYxMTc2NDcwNTkgMC45OTYwNzg0MzE0ANIQERITWiRjbGFzc25hbWVYJGNs
116 | YXNzZXNXTlNDb2xvcqISFFhOU09iamVjdF8QD05TS2V5ZWRBcmNoaXZlctEXGFRyb290
117 | gAEIERojLTI3O0FIT1xiZGaFipWepqmyxMfMAAAAAAAAAQEAAAAAAAAAGQAAAAAAAAAA
118 | AAAAAAAAAM4=
119 |
120 | ANSIRedColor
121 |
122 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
123 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAC
124 | TxAlMC44NTg4MjM1OTc0IDAuNDgyMzUyOTcyIDAuNDgyMzUyOTcyANIQERITWiRjbGFz
125 | c25hbWVYJGNsYXNzZXNXTlNDb2xvcqISFFhOU09iamVjdF8QD05TS2V5ZWRBcmNoaXZl
126 | ctEXGFRyb290gAEIERojLTI3O0FIT1xiZGaOk56nr7K7zdDVAAAAAAAAAQEAAAAAAAAA
127 | GQAAAAAAAAAAAAAAAAAAANc=
128 |
129 | ANSIWhiteColor
130 |
131 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
132 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAB
133 | TxAnMC44MDAwMDAwMTE5IDAuODAwMDAwMDExOSAwLjgwMDAwMDAxMTkA0hAREhNaJGNs
134 | YXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFyY2hp
135 | dmVy0RcYVHJvb3SAAQgRGiMtMjc7QUhPXGJkZpCVoKmxtL3P0tcAAAAAAAABAQAAAAAA
136 | AAAZAAAAAAAAAAAAAAAAAAAA2Q==
137 |
138 | ANSIYellowColor
139 |
140 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
141 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAC
142 | SDEgMSAwLjgA0hAREhNaJGNsYXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2Jq
143 | ZWN0XxAPTlNLZXllZEFyY2hpdmVy0RcYVHJvb3SAAQgRGiMtMjc7QUhPXGJkZm90f4iQ
144 | k5yusbYAAAAAAAABAQAAAAAAAAAZAAAAAAAAAAAAAAAAAAAAuA==
145 |
146 | BackgroundBlur
147 | 0.39820544554455445
148 | BackgroundColor
149 |
150 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
151 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAC
152 | TxAqMC4xNDkwMTk2MTM5IDAuMTYwNzg0MzE5IDAuMTcyNTQ5MDI0MiAwLjkA0hAREhNa
153 | JGNsYXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFy
154 | Y2hpdmVy0RcYVHJvb3SAAQgRGiMtMjc7QUhPXGJkZpOYo6y0t8DS1doAAAAAAAABAQAA
155 | AAAAAAAZAAAAAAAAAAAAAAAAAAAA3A==
156 |
157 | BackgroundImageBookmark
158 |
159 | YnBsaXN0MDDUAQIDBAUGFBVYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
160 | AAGGoKMHCA1VJG51bGzSCQoLDFYkY2xhc3NXTlMuZGF0YYACTxECsGJvb2uwAgAAAAAB
161 | EBAAAAAIAgAABQAAAAEBAABVc2VycwAAAAYAAAABAQAAU2hhcmVkAAAIAAAAAQEAAFBp
162 | Y3R1cmVzEgAAAAEBAABwcm9tYXRlXzJ0ZXJtMi5wbmcAABAAAAABBgAABAAAABQAAAAk
163 | AAAANAAAAAgAAAAEAwAAEr8AAAAAAAAIAAAABAMAABO/AAAAAAAACAAAAAQDAAD5sQYA
164 | AAAAAAgAAAAEAwAAz5U0AAAAAAAQAAAAAQYAAGgAAAB4AAAAiAAAAJgAAAAYAAAAAQIA
165 | AAEAAAAAAAAADwAAAAAAAAAAAAAAAAAAAAgAAAABAQAATGFwcHlTU0QIAAAABAMAAACA
166 | RpwdAAAACAAAAAAEAABBtB6rkwAAACQAAAABAQAAMkUyMTZCMjctOUM4My0zNzc1LUE3
167 | MEEtOURCQTkxRjhBMzg1GAAAAAECAACBAAAAAQAIAO8/AAABAAgAAAAAAAAAAAABAAAA
168 | AQEAAC8AAAAAAAAAAQUAAJAAAAABAgAAODkzMTI3MTM3ZmZmODYwOGNlYzRiOGVlZWRh
169 | MTRlNzBmM2FjOTVmYjswMDAwMDAwMDswMDAwMDAwMDswMDAwMDAwMDAwMDAwMDIwO2Nv
170 | bS5hcHBsZS5hcHAtc2FuZGJveC5yZWFkLXdyaXRlOzAwMDAwMDAwMGUwMDAwMDU7MDAw
171 | MDAwMDAwMDM0OTVjZjsAkAAAAP7///8BAAAAAAAAAAsAAAAEEAAAUAAAAAAAAAAFEAAA
172 | qAAAAAAAAAAQEAAAwAAAAAAAAAACIAAAXAEAAAAAAAAQIAAA4AAAAAAAAAARIAAAEAEA
173 | AAAAAAASIAAA8AAAAAAAAAATIAAAAAEAAAAAAAAgIAAAPAEAAAAAAAAwIAAAaAEAAAAA
174 | AACA8AAAcAEAAAAAAADSDg8QEVokY2xhc3NuYW1lWCRjbGFzc2VzXU5TTXV0YWJsZURh
175 | dGGjEBITVk5TRGF0YVhOU09iamVjdF8QD05TS2V5ZWRBcmNoaXZlctEWF1Ryb290gAEA
176 | CAARABoAIwAtADIANwA7AEEARgBNAFUAVwMLAxADGwMkAzIDNgM9A0YDWANbA2AAAAAA
177 | AAACAQAAAAAAAAAYAAAAAAAAAAAAAAAAAAADYg==
178 |
179 | CommandString
180 |
181 | CursorBlink
182 |
183 | CursorColor
184 |
185 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
186 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAB
187 | TxAXMSAwLjY0NzA1ODg0IDAuMzc2NDcwNgDSEBESE1okY2xhc3NuYW1lWCRjbGFzc2Vz
188 | V05TQ29sb3KiEhRYTlNPYmplY3RfEA9OU0tleWVkQXJjaGl2ZXLRFxhUcm9vdIABCBEa
189 | Iy0yNztBSE9cYmRmgIWQmaGkrb/CxwAAAAAAAAEBAAAAAAAAABkAAAAAAAAAAAAAAAAA
190 | AADJ
191 |
192 | CursorType
193 | 1
194 | Font
195 |
196 | YnBsaXN0MDDUAQIDBAUGGBlYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
197 | AAGGoKQHCBESVSRudWxs1AkKCwwNDg8QViRjbGFzc1ZOU05hbWVWTlNTaXplWE5TZkZs
198 | YWdzgAOAAiNAKAAAAAAAABAQXxAbQml0c3RyZWFtVmVyYVNhbnNNb25vLVJvbWFu0hMU
199 | FRZaJGNsYXNzbmFtZVgkY2xhc3Nlc1ZOU0ZvbnSiFRdYTlNPYmplY3RfEA9OU0tleWVk
200 | QXJjaGl2ZXLRGhtUcm9vdIABCBEaIy0yNzxCS1JZYGlrbXZ4lpumr7a5wtTX3AAAAAAA
201 | AAEBAAAAAAAAABwAAAAAAAAAAAAAAAAAAADe
202 |
203 | FontAntialias
204 |
205 | FontWidthSpacing
206 | 0.99596774193548387
207 | Linewrap
208 |
209 | ProfileCurrentVersion
210 | 2.02
211 | RunCommandAsShell
212 |
213 | SelectionColor
214 |
215 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
216 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VXTlNXaGl0ZYAC
217 | EANLMC4yNTQwMzIyNQDSEBESE1okY2xhc3NuYW1lWCRjbGFzc2VzV05TQ29sb3KiEhRY
218 | TlNPYmplY3RfEA9OU0tleWVkQXJjaGl2ZXLRFxhUcm9vdIABCBEaIy0yNztBSE9cZGZo
219 | dHmEjZWYobO2uwAAAAAAAAEBAAAAAAAAABkAAAAAAAAAAAAAAAAAAAC9
220 |
221 | ShowActiveProcessInTitle
222 |
223 | ShowCommandKeyInTitle
224 |
225 | ShowDimensionsInTitle
226 |
227 | ShowShellCommandInTitle
228 |
229 | ShowTTYNameInTitle
230 |
231 | ShowWindowSettingsNameInTitle
232 |
233 | TextBoldColor
234 |
235 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
236 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VXTlNXaGl0ZYAC
237 | EANCMQDSEBESE1okY2xhc3NuYW1lWCRjbGFzc2VzV05TQ29sb3KiEhRYTlNPYmplY3Rf
238 | EA9OU0tleWVkQXJjaGl2ZXLRFxhUcm9vdIABCBEaIy0yNztBSE9cZGZoa3B7hIyPmKqt
239 | sgAAAAAAAAEBAAAAAAAAABkAAAAAAAAAAAAAAAAAAAC0
240 |
241 | TextColor
242 |
243 | YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
244 | AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAB
245 | TxAnMC44MDAwMDAwMTE5IDAuODAwMDAwMDExOSAwLjgwMDAwMDAxMTkA0hAREhNaJGNs
246 | YXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFyY2hp
247 | dmVy0RcYVHJvb3SAAQgRGiMtMjc7QUhPXGJkZpCVoKmxtL3P0tcAAAAAAAABAQAAAAAA
248 | AAAZAAAAAAAAAAAAAAAAAAAA2Q==
249 |
250 | UseBrightBold
251 |
252 | columnCount
253 | 100
254 | name
255 | JocelynCustom
256 | noWarnProcesses
257 |
258 |
259 | ProcessName
260 | rlogin
261 |
262 |
263 | ProcessName
264 | telnet
265 |
266 |
267 | ProcessName
268 | ssh
269 |
270 |
271 | ProcessName
272 | slogin
273 |
274 |
275 | ProcessName
276 | screen
277 |
278 |
279 | ProcessName
280 | tmux
281 |
282 |
283 | ProcessName
284 | adb
285 |
286 |
287 | rowCount
288 | 39
289 | shellExitAction
290 | 1
291 | type
292 | Window Settings
293 |
294 |
295 |
--------------------------------------------------------------------------------
/other/lib/updates.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v3.0+
4 | # Automatic Updates functions
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.0
10 | # Sun. Oct 07, 2012
11 | # -----------------------------------------------------------------------
12 |
13 | # setup git repo address
14 | git_origin="git://github.com/jocelynmallon/apkmanager.git"
15 |
16 | # cleanup all variables used by update functions
17 | updates_cleanup () {
18 | unset last_epoch
19 | unset upromptstate
20 | unset epoch_diff
21 | unset old_commit
22 | unset new_commit
23 | unset channel_ver
24 | unset saved_channel
25 | unset input
26 | unset last_check
27 | unset last_time
28 | unset key
29 | unset value
30 | unset commit
31 | unset uprompt
32 | unset ufreq
33 | unset last_check
34 | unset last_time
35 | unset updfreq
36 | }
37 |
38 | # get the current revision of HEAD
39 | get_commit_ver () {
40 | echo $(git rev-parse -q --verify HEAD)
41 | }
42 |
43 | # get the current git branch
44 | get_current_branch () {
45 | echo $(git symbolic-ref HEAD)
46 | }
47 |
48 | # Disable confirmation prompt when updating
49 | enable_update_prompt () {
50 | local key="updates_prompt"
51 | local value="true"
52 | write_preference
53 | }
54 |
55 | # Enable confirmation prompt when updating
56 | disable_update_prompt () {
57 | local key="updates_prompt"
58 | local value="false"
59 | write_preference
60 | }
61 |
62 | # Configure automatic updates
63 | disable_auto_updates () {
64 | local key="updates"
65 | local value="false"
66 | write_preference
67 | }
68 |
69 | # Configure automatic updates
70 | enable_auto_updates () {
71 | local key="updates"
72 | local value="true"
73 | write_preference
74 | if [[ ! -d "${maindir}"/.git ]]; then
75 | updates_init_prompt
76 | fi
77 | }
78 |
79 | # Write log message on successful git checkout
80 | branch_change_log () {
81 | echo "CHECKOUT COMPLETE: $(gen_date)" 1>> "$log" 2>&1
82 | echo "$apkmftr" 1>> "$log" 2>&1
83 | }
84 |
85 | # try to checkout the selected branch
86 | checkout_new_branch () {
87 | echo "checkout_new_branch (change branches now)" 1>> "$log"
88 | cd "${maindir}"
89 | echo "==> checking out branch: ${saved_channel}" 1>> "$log"
90 | if [[ $(git branch | grep "${saved_channel}") ]]; then
91 | git checkout -q "${saved_channel}" 2>> "$log"
92 | if [[ $? -ne 0 ]]; then
93 | git_checkout_error
94 | exit 1
95 | else
96 | branch_change_log
97 | exit 0
98 | fi
99 | else
100 | git checkout -t -q "origin/${saved_channel}" 2>> "$log"
101 | if [[ $? -ne 0 ]]; then
102 | git_checkout_error
103 | exit 1
104 | else
105 | branch_change_log
106 | exit 0
107 | fi
108 | fi
109 | }
110 |
111 | # placeholder - change branch
112 | change_update_branch () {
113 | if [[ $(ls -1 "${maindir}"/.git/refs/remotes/origin | wc -l) -eq 1 ]]; then
114 | no_branches_err
115 | return 1
116 | else
117 | git_branches_menu
118 | fi
119 | }
120 |
121 | # Change the number of days between updates
122 | change_update_freq () {
123 | printf "$white%s""Enter number of days to wait between update checks ("$bgreen"1-31"$white")\n"; $rclr;
124 | printf "$white%s""("$green"i.e. 1 means check every 24 hours, 2 is 48 hours, etc."$white"): "; $rclr;
125 | read input
126 | if [[ ! ${input} = *[^0-9]* ]] && [[ ${input} -ge 1 ]] && [[ ${input} -le 31 ]]; then
127 | local key="updates_freq"
128 | local value="${input}"
129 | write_preference
130 | echo "==> update frequency set to: ${input} days" 1>> "$log" 2>&1
131 | else
132 | echo $bred"Error: ${input} is not valid, press any key to try again"; $rclr;
133 | wait
134 | change_update_freq
135 | fi
136 | unset input
137 | }
138 |
139 | # placeholder - force update check
140 | force_update_check () {
141 | echo "force_update_check (force updates check now)" 1>> "$log"
142 | update_apkm
143 | if [[ ! ${new_commit} = ${old_commit} ]]; then
144 | echo "force_update_check complete" 1>> "$log"
145 | updates_complete_log
146 | exit 0
147 | elif [[ ! ${channel_ver} = ${saved_channel} ]]; then
148 | echo "force_update_check complete" 1>> "$log"
149 | echo $bgreen"Manual/forced update check complete!"; $rclr;
150 | git_branch_change
151 | updates_complete_log
152 | exit 0
153 | else
154 | echo "force_update_check complete" 1>> "$log"
155 | fi
156 | }
157 |
158 | # get the date and time of the last update check
159 | build_last_date_time () {
160 | last_check="$(defaults read "${plist}" updates_last_date 2>/dev/null)"
161 | if [[ $? -ne 0 ]]; then
162 | last_check="Never"
163 | else
164 | last_check="$(echo "${last_check}" | sed 's/_/\ /g')"
165 | last_time="$(defaults read "${plist}" updates_last_time 2>/dev/null)"
166 | last_time="$(echo "${last_time}" | sed 's/_/\ /g')"
167 | last_check="${last_check}${white} at: ${green}${last_time}"
168 | fi
169 | }
170 |
171 | # Initialize an empty repo if necessary
172 | updates_init_repo () {
173 | if [[ ! -d "${maindir}"/.git ]]; then
174 | echo ".git repo not found, initializing repo" 1>> "$log"
175 | cd "${maindir}"
176 | echo "==> git init..." 1>> "$log"
177 | git init 2>> "$log"
178 | echo "==> git config core.autocrlf false..." 1>> "$log"
179 | git config core.autocrlf false 2>> "$log"
180 | echo "==> git config branch.autosetuprebase always..." 1>> "$log"
181 | git config branch.autosetuprebase always
182 | echo "==> git remote add origin..." 1>> "$log"
183 | git remote add origin "${git_origin}" 2>> "$log"
184 | echo "==> git remote fetch origin..." 1>> "$log"
185 | git fetch origin 2>> "$log"
186 | echo "==> git reset --hard origin/master..." 1>> "$log"
187 | git reset --hard origin/master 2>> "$log"
188 | fi
189 | }
190 |
191 | # prompt user to initiliaze the git repo
192 | updates_init_prompt () {
193 | clear
194 | echo ""
195 | version_banner
196 | echo ""
197 | echo $white" In order to enable automatic updates, APK Manager must be set"
198 | echo $white" up to use git, and track a remote repository on github:"; $rclr;
199 | echo ""
200 | echo $green" https://github.com/jocelynmallon/apkmanager"; $rclr;
201 | echo ""
202 | echo $white" APK Manager will run the following commands:"; $rclr;
203 | echo ""
204 | echo $bgreen" 1 "$green"cd ${maindir}"
205 | echo $bgreen" 2 "$green"git init"
206 | echo $bgreen" 3 "$green"git config core.autocrlf false"
207 | echo $bgreen" 4 "$green"git config branch.autosetuprebase always"
208 | echo $bgreen" 5 "$green"git remote add origin ${git_origin}"
209 | echo $bgreen" 6 "$green"git fetch origin"
210 | echo $bgreen" 7 "$green"git reset --hard origin/master"; $rclr;
211 | echo ""
212 | echo $white" To (hopefully) minimize errors with this process,"
213 | echo $white" APK Manager will quit automatically once completed."
214 | echo $bgreen"$apkmspr"
215 | genericpanykey
216 | updates_init_repo
217 | echo ""
218 | echo $bgreen"$apkmftr"
219 | fatalpanykey
220 | echo "GIT INIT COMPLETE: $(gen_date)" 1>> "$log" 2>&1
221 | echo "$apkmftr" 1>> "$log" 2>&1
222 | exit 0
223 | }
224 |
225 | # Make sure 'git' was used to install
226 | updates_git_check () {
227 | if [[ ! $(command -v git) ]]; then
228 | updates_git_err
229 | else
230 | updates_menu
231 | fi
232 | }
233 |
234 | # apkmanager was updated message
235 | yes_update_message () {
236 | clear
237 | echo ""
238 | version_banner
239 | echo $bgreen" _ ____ _ ____ __ _ _ _ _ ____ _____ ____ ___ ____ __ __ "
240 | echo $bgreen" / \ | _ \| |/ / \/ | / \ | \ | | / \ / ___| ____| _ \ / _ \/ ___| \ \/ / "
241 | echo $bgreen" / _ \ | |_) | ' /| |\/| | / _ \ | \| | / _ \| | _| _| | |_) | | | | \___ \ \ / "
242 | echo $bgreen" / ___ \| __/| . \| | | |/ ___ \| |\ |/ ___ \ |_| | |___| _ < | |_| |___) | / \ "
243 | echo $bgreen" /_/ \_\_| |_|\_\_| |_/_/ \_\_| \_/_/ \_\____|_____|_| \_\ \___/|____/ /_/\_\ "
244 | echo $bgreen""
245 | echo $bgreen"$apkmspr"; $rclr;
246 | echo ""
247 | echo $bwhite" APK Manager for OSX succesfully updated from "$bgreen"${old_commit} "$bwhite"to "$bgreen"${new_commit} "$bwhite"!"
248 | echo $bwhite" APK Manager for OSX is currently on the "$bgreen"${channel_ver} "$bwhite"branch/channel"
249 | echo $bwhite" You can change the branch/channel for updates in the debug/settings"
250 | echo $bwhite" menu, and/or disable automatic updates entirely."
251 | echo ""
252 | echo $bred" APK Manager will now exit, please re-launch to complete the update."
253 | echo $bgreen"$apkmftr"
254 | echo "APK Manager updated from ${old_commit} to ${new_commit}" 1>> "$log"
255 | echo "==> on update branch/channel: ${saved_channel}" 1>> "$log"
256 | genericpanykey
257 | }
258 |
259 | # apkmanager wasn't updated message
260 | no_update_message () {
261 | echo $bgreen"APK Manager is already up to date!"; $rclr;
262 | echo "APK Manager already up to date @: ${new_commit}" 1>> "$log"
263 | genericpanykey
264 | }
265 |
266 | # fancy display message on succesful update
267 | finish_message () {
268 | if [[ ! ${new_commit} = ${old_commit} ]]; then
269 | yes_update_message
270 | else
271 | no_update_message
272 | fi
273 | }
274 |
275 | update_branch_check () {
276 | saved_channel="$(defaults read "${plist}" updates_branch 2>/dev/null)"
277 | if [[ $? -ne 0 ]]; then
278 | saved_channel="master"
279 | local key="updates_branch"
280 | local value="master"
281 | write_preference
282 | fi
283 | }
284 |
285 | # Actually checking for updates now
286 | update_apkm () {
287 | echo "update_apkm (actually checking for updates now)" 1>> "$log"
288 | cd "${maindir}"
289 | echo "==> git config core.autocrlf false ..." 1>> "$log"
290 | git config core.autocrlf false
291 | if [[ $? -ne 0 ]]; then
292 | git_config_error
293 | return 1
294 | fi
295 | echo "==> git config branch.autosetuprebase always ..." 1>> "$log"
296 | git config branch.autosetuprebase always
297 | if [[ $? -ne 0 ]]; then
298 | git_config_error
299 | return 1
300 | fi
301 | channel_ver="$(get_current_branch)"
302 | channel_ver="${channel_ver#refs/heads/}"
303 | update_branch_check
304 | if [[ ! ${channel_ver} = ${saved_channel} ]]; then
305 | echo "Checking out branch: ${saved_channel}" 1>> "$log"
306 | git checkout -q ${saved_channel} 2>> "$log"
307 | if [[ $? -ne 0 ]]; then
308 | git_checkout_error
309 | return 1
310 | fi
311 | fi
312 | old_commit="$(get_commit_ver)"
313 | old_commit="${old_commit:0:8}"
314 | echo "==> git pull -q origin ${saved_channel} ..." 1>> "$log"
315 | git pull -q origin refs/heads/${saved_channel}:refs/remotes/origin/${saved_channel} 2>> "$log"
316 | if [[ $? -ne 0 ]]; then
317 | git_pull_error
318 | return 1
319 | else
320 | new_commit="$(get_commit_ver)"
321 | new_commit="${new_commit:0:8}"
322 | finish_message
323 | fi
324 | update_last_epoch
325 | echo "update_apkm complete" 1>> "$log"
326 | }
327 |
328 | # Generate epoch to check against
329 | gen_epoch () {
330 | echo $(($(date +%s) / 60 / 60 / 24))
331 | }
332 |
333 | # Write last update epoch, date and time to plist
334 | update_last_epoch () {
335 | local key="updates_last_epoch"
336 | local value="$(gen_epoch)"
337 | write_preference
338 | local key="updates_last_date"
339 | local value="$(date +"%b_%d_%Y")"
340 | write_preference
341 | local key="updates_last_time"
342 | local value="$(date +"%T_%Z")"
343 | write_preference
344 | }
345 |
346 | # Prompt user if they want to check for updates
347 | updates_check_prompt () {
348 | printf "$white%s""Would you like to check for updates to APK Manager? ("$bgreen"y"$white"/"$bgreen"n"$white") "; $rclr;
349 | read input
350 | case $input in
351 | [yY]) update_apkm ;;
352 | [nN]) update_last_epoch; echo "user cancelled update check" 1>> "$log" ;;
353 | *) input_err; updates_check_prompt ;;
354 | esac
355 | }
356 |
357 | # Check if the update prompt is disabled
358 | update_prompt_state () {
359 | upromptstate="$(defaults read "${plist}" updates_prompt 2>/dev/null)"
360 | if [[ $? -ne 0 ]]; then
361 | local key="updates_prompt"
362 | local value="true"
363 | write_preference
364 | upromptstate=1
365 | fi
366 | }
367 |
368 | # Check number of days to wait between updates
369 | check_update_freq () {
370 | ufreq="$(defaults read "${plist}" updates_freq 2>/dev/null)"
371 | if [[ $? -ne 0 ]]; then
372 | ufreq="6"
373 | local key="updates_freq"
374 | local value="${ufreq}"
375 | write_preference
376 | fi
377 | }
378 |
379 | # write a log message on completion before exit
380 | updates_complete_log () {
381 | echo "UPDATE COMPLETE: $(gen_date)" 1>> "$log" 2>&1
382 | echo "$apkmftr" 1>> "$log" 2>&1
383 | }
384 |
385 | # Check status of automatic updates
386 | updates_status () {
387 | echo "updates_status (check for updates) function" 1>> "$log"
388 | if [[ ! -d "${maindir}"/.git ]]; then
389 | updates_init_prompt
390 | fi
391 | last_epoch="$(defaults read "${plist}" updates_last_epoch 2>/dev/null)"
392 | if [[ $? -ne 0 ]] || [[ -z ${last_epoch} ]]; then
393 | local key="updates_last_epoch"
394 | local value="$(gen_epoch)"
395 | write_preference
396 | return 0
397 | fi
398 | epoch_diff=$(($(gen_epoch) - ${last_epoch}))
399 | check_update_freq
400 | if [[ ${epoch_diff} -ge ${ufreq} ]]; then
401 | update_prompt_state
402 | if [[ ${upromptstate} -eq 0 ]]; then
403 | update_apkm
404 | else
405 | updates_check_prompt
406 | fi
407 | fi
408 | if [[ ! ${new_commit} = ${old_commit} ]]; then
409 | updates_cleanup
410 | echo "updates_status complete" 1>> "$log"
411 | updates_complete_log
412 | exit 0
413 | elif [[ ! ${channel_ver} = ${saved_channel} ]]; then
414 | git_branch_change
415 | updates_cleanup
416 | echo "updates_status complete" 1>> "$log"
417 | updates_complete_log
418 | exit 0
419 | else
420 | updates_cleanup
421 | fi
422 | echo "updates_status complete" 1>> "$log"
423 | }
424 |
--------------------------------------------------------------------------------
/other/lib/debug_funcs.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v3.0+
4 | # Debug information functions
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.2b
10 | # Mon. Jan 27, 2014
11 | # -----------------------------------------------------------------------
12 |
13 | debug_cleanup () {
14 | unset p7zip_ver
15 | unset pngcrush_ver
16 | unset optipng_ver
17 | unset pngout_ver
18 | unset sox_ver
19 | unset smali_ver
20 | unset baksmali_ver
21 | unset adb_ver
22 | unset aapt_ver
23 | unset dex2jar_ver
24 | unset osx_ver
25 | unset osx_bld
26 | }
27 |
28 | # Toggle set -x/+x trace output
29 | toggle_trace () {
30 | if [[ ${t_mode} -ne 0 ]]; then
31 | t_mode=0
32 | set +x
33 | elif [[ ${t_mode} -eq 0 ]]; then
34 | t_mode=1
35 | set -x
36 | fi
37 | }
38 |
39 | # Toggle set -v/+v verbose output
40 | toggle_verbose () {
41 | if [[ ${v_mode} -ne 0 ]]; then
42 | v_mode=0
43 | set +v
44 | elif [[ ${v_mode} -eq 0 ]]; then
45 | v_mode=1
46 | set -v
47 | fi
48 | }
49 |
50 | # Toggle set -e/+e error checking
51 | toggle_error () {
52 | if [[ ${e_mode} -ne 0 ]]; then
53 | e_mode=0
54 | set +e
55 | elif [[ ${e_mode} -eq 0 ]]; then
56 | e_mode=1
57 | set -e
58 | fi
59 | }
60 |
61 | # Toggle killing ADB daemon on APKM quit
62 | toggle_adb_kill_on_quit () {
63 | local key="adbkillonquit"
64 | if [[ ${adb_kill} -ne 0 ]]; then
65 | adb_kill=0
66 | local value="false"
67 | elif [[ ${adb_kill} -eq 0 ]]; then
68 | adb_kill=1
69 | local value="true"
70 | fi
71 | write_preference
72 | }
73 |
74 | # generate system memory information
75 | gen_system_memory_info () {
76 | local free_blocks=$(vm_stat | grep free | awk '{ print $3 }' | sed 's/\.//')
77 | local inactive_blocks=$(vm_stat | grep inactive | awk '{ print $3 }' | sed 's/\.//')
78 | local speculative_blocks=$(vm_stat | grep speculative | awk '{ print $3 }' | sed 's/\.//')
79 | local active_blocks=$(vm_stat | grep -m1 active | awk '{ print $3 }' | sed 's/\.//')
80 | local wired_blocks=$(vm_stat | grep wired | awk '{ print $4 }' | sed 's/\.//')
81 | local reactive_blocks=$(vm_stat | grep -m1 reactivated | awk '{ print $3 }' | sed 's/\.//')
82 | local active=$(($active_blocks*4096/1048576))
83 | local reactive=$(($reactive_blocks*4096/1048576))
84 | local wired=$(($wired_blocks*4096/1048576))
85 | local free=$((($free_blocks+speculative_blocks)*4096/1048576))
86 | local inactive=$(($inactive_blocks*4096/1048576))
87 | totalfree=$((($free+$inactive)))
88 | totalactive=$((($wired+$active+reactive)))
89 | sysmem=$((($free+$inactive+$active+$wired+$reactive)))
90 | }
91 |
92 |
93 | git_parse_commit_detail () {
94 | git log --name-status --pretty --diff-filter="[A|C|D|M|R|T]" -1 -U "${commit_detail}"
95 | }
96 |
97 | # detail view for selected git commit
98 | git_commit_detail_view () {
99 | clear
100 | menu_header
101 | echo $bgreen"$apkmspr"; $rclr;
102 | echo ""
103 | echo $bwhite"Viewing commit detail for: "$bgreen"${commit_detail}"; $rclr;
104 | echo ""
105 | cd "${maindir}"
106 | echo "$(git_parse_commit_detail)"
107 | echo ""
108 | echo $bgreen"$apkmftr";
109 | echo $white"press "$bgreen"G"$white" to open commit history on github.com"; $rclr;
110 | echo $white"press "$bgreen"W"$white" to view the wiki changelog on github.com"; $rclr;
111 | echo $white"press "$bgreen"Q"$white" to return to debug menu"; $rclr;
112 | printf "$bwhite%s""Please select an option from above: "; $rclr;
113 | read input
114 | case "$input" in
115 | [gG]) view_github_commits ;;
116 | [wW]) view_github_wiki ;;
117 | [qQ]) ;;
118 | [qQ][qQ]) quit ;;
119 | *) input_err; git_commit_detail_view ;;
120 | esac
121 | unset input
122 | }
123 |
124 | # Open the github wiki changelog page
125 | view_github_wiki () {
126 | open https://github.com/jocelynmallon/apkmanager/wiki/Changelog
127 | }
128 |
129 | # Open the github commit history page
130 | view_github_commits () {
131 | open https://github.com/jocelynmallon/apkmanager/commits/master/
132 | }
133 |
134 | # View changelog/git-log
135 | view_changelog () {
136 | if [[ $(command -v git) ]] && [[ -d "${maindir}/.git" ]]; then
137 | git_log_menu
138 | else
139 | view_github_wiki
140 | fi
141 | }
142 |
143 | # Toggle APK Manager symlink
144 | apkm_tool_toggle () {
145 | if [[ $(echo ${PATH} | grep -m1 "/usr/local/bin") ]]; then
146 | if [[ $(command -v apkm) = "/usr/local/bin/apkm" ]]; then
147 | echo "deleting \"apkm\" symlink in /usr/local/bin" 1>> "$log"
148 | rm "/usr/local/bin/apkm"
149 | elif [[ ! $(command -v apkm) ]]; then
150 | echo "creating \"apkm\" symlink in /usr/local/bin" 1>> "$log"
151 | ln -s -F "${maindir}/other/main.sh" "/usr/local/bin/apkm"; chmod ug+x "/usr/local/bin/apkm"
152 | fi
153 | fi
154 | }
155 |
156 | # Actually download extra apktool versions
157 | install_apktool () {
158 | if [[ ! -f "${maindir}/other/apktool_jar_files.tar.gz" ]]; then
159 | echo $green" Local copy of archive not found, downloading now..."; $rclr;
160 | echo ""
161 | curl "https://dl.dropboxusercontent.com/u/9401664/APK%20Manager/apktool_jar_files.tar.gz" > "${maindir}/other/apktool_jar_files.tar.gz"
162 | echo ""
163 | fi
164 | local filehash="$(md5 -q "${maindir}/other/apktool_jar_files.tar.gz")"
165 | local expected="d1e4fee31e403bc63457e12731b25db6"
166 | if [[ ${filehash} = ${expected} ]]; then
167 | echo $white" Extracting extra apktool.jar files to:"
168 | echo $green" ${maindir}/other/apktool"; $rclr;
169 | echo ""
170 | cd "${maindir}/other"
171 | tar -xzvf "${maindir}/other/apktool_jar_files.tar.gz" 1>> "$log" 2>&1
172 | echo $green" Removing temporary files."
173 | rm -r "${maindir}/other/apktool_jar_files.tar.gz"
174 | echo $bgreen" Download complete!"
175 | echo ""
176 | echo $bgreen"$apkmftr";
177 | genericpanykey
178 | apktool_menu
179 | else
180 | echo $bred" ERROR: Corrupt download/file, md5 hash fail:"
181 | echo $bred" download: ${filehash}"
182 | echo $bred" expected: ${expected}"
183 | echo ""
184 | echo $white"press any key to try download again..."
185 | wait
186 | rm -r "${maindir}/other/apktool_jar_files.tar.gz"
187 | install_apktool
188 | fi
189 | }
190 |
191 | # Prompt to download extra apktool versions
192 | apkt_prompt () {
193 | clear
194 | menu_header
195 | debug_header
196 | echo $bgreen"$apkmspr";
197 | echo ""
198 | echo $white" APK Manager has the ability to change the version of "$bgreen"apktool.jar"$white" used when decompiling"
199 | echo $white" and compiling android applications. However, to cut down on file size, only the most"
200 | echo $white" recent \"official\" release of apktool.jar ("$green"${apktool_ver}"$white") is included by default."
201 | echo ""
202 | echo $white" Would you like to download extra versions of apktool.jar file to use with APK Manager?"
203 | echo ""
204 | echo $bgreen"$apkmftr";
205 | printf "$white%s""Download extra apktool.jar versions? ("$bgreen"y"$white"/"$bgreen"n"$white") "; $rclr;
206 | read input
207 | case "$input" in
208 | [yY]) install_apktool ;;
209 | [nN]) ;;
210 | *) input_err; apkt_prompt ;;
211 | esac
212 | unset input
213 | }
214 |
215 | # Check for extra versions of apktool.jar
216 | apkt_menu_check () {
217 | if [[ $( ls "${aptdir}" | wc -l) -gt 1 ]]; then
218 | apktool_menu
219 | elif [[ $( ls "${aptdir}" | wc -l) -eq 1 ]]; then
220 | apkt_prompt
221 | fi
222 | }
223 |
224 | # Launch ddms/monitor if it exists
225 | launch_ddms () {
226 | if [[ $(command -v monitor) ]]; then
227 | local apkmopt="monitor; exit"
228 | newttab "${apkmopt}" "$log"
229 | elif [[ $(command -v ddms) ]] && [[ ! $(command -v monitor) ]]; then
230 | local apkmopt="ddms; exit"
231 | newttab "${apkmopt}" "$log"
232 | elif [[ ! $(command -v monitor) ]] && [[ ! $(command -v ddms) ]]; then
233 | echo $bred"ERROR: Android Device Monitor not found on the system."
234 | debuganykey
235 | fi
236 | }
237 |
238 | # Launch android sdk manager if it exists
239 | launch_sdk_manager () {
240 | if [[ $(command -v android) ]]; then
241 | local apkmopt="android; exit"
242 | newttab "${apkmopt}" "$log"
243 | elif [[ ! $(command -v android) ]]; then
244 | echo $bred"ERROR: Android SDK Manager not found on the system."
245 | debuganykey
246 | fi
247 | }
248 |
249 | # Launch draw9patch if it exists
250 | draw_nine () {
251 | if [[ $(command -v draw9patch) ]]; then
252 | local apkmopt="draw9patch; exit"
253 | newttab "${apkmopt}" "$log"
254 | elif [[ ! $(command -v draw9patch) ]]; then
255 | echo $bred"ERROR: draw9patch not found on the system."
256 | debuganykey
257 | fi
258 | }
259 |
260 | # Check to make sure we used Android Studio SDK
261 | # before we try and launch the SDK tools menu
262 | andsdk_tools_check () {
263 | if [[ -e "/Applications/Android Studio.app" ]]; then
264 | android_studio_menu
265 | else
266 | andstudio_notfound_err
267 | fi
268 | }
269 |
270 | # Select PNG optimization tool
271 | png_tool_menu () {
272 | clear
273 | menu_header
274 | debug_header
275 | echo $bgreen"$apkmspr";
276 | echo $white" Please select a PNG optimization tool to use"
277 | echo $white" with the "$bgreen"\"Optimize images inside\""$white" and"
278 | echo $white" batch optimize PNG file functions."; $rclr;
279 | echo ""
280 | echo $bred" This setting is persistent."; $rclr;
281 | echo $bgreen"$apkmspr";
282 | echo $bgreen" 1 "$white"Optipng "$blue"(default APK Manager tool - Open Source)"
283 | echo $bgreen" 2 "$white"Pngcrush "$blue"(the tool used by CyanogenMod - Open Source)"
284 | echo $bgreen" 3 "$white"Pngout "$blue"(used in commercial plugins - "$bred"NOT OPEN SOURCE"$blue")"
285 | echo $bgreen" Q "$white"Return to Debug Menu";
286 | echo $bgreen"$apkmftr";
287 | printf "$bwhite%s""Please select an option from above: "; $rclr;
288 | read input
289 | case "$input" in
290 | 1) local key="pngtool" && local value="optipng" && write_preference && pngtoolset ;;
291 | 2) local key="pngtool" && local value="pngcrush" && write_preference && pngtoolset ;;
292 | 3) pngout_check ;;
293 | [sS][sS]) ret_menu="png_tool_menu"; adb_screenshot; unset ret_menu ;;
294 | [qQ]) ;;
295 | [qQ][qQ]) quit ;;
296 | *) input_err; png_tool_menu ;;
297 | esac
298 | }
299 |
300 | # Generate apktool version information
301 | getapktver () {
302 | local key="apktool"
303 | local value="$(runj apktool | grep 'Apktool'| cut -d - -f1 | sed 's/^[ \t]*//;s/[ \t]*$//' | sed 's/\ /_/g')"
304 | write_preference
305 | apktool_ver="${value}"
306 | }
307 |
308 | # Generate SOX version information
309 | getsoxver () {
310 | if [[ ${installtype} = homebrew ]]; then
311 | if [[ $(command -v sox) ]]; then
312 | value="$(brew list --versions sox | sed s/sox\ //g)"
313 | else
314 | value="ERROR_sox_not_found"
315 | fi
316 | else
317 | if [[ $(command -v sox) ]]; then
318 | value="$(sox --version | sed s/\ \ SoX\ //g |sed 's/^[ \t]*//;s/[ \t]*$//')"
319 | else
320 | value="ERROR_sox_not_found"
321 | fi
322 | fi
323 | }
324 |
325 | # Generate pngout version information
326 | getpngoutver () {
327 | if [[ ! $(command -v pngout) ]]; then
328 | value="pngout_not_found"
329 | else
330 | value="$(pngout 2>&1 | grep -m1 'PNGOUT' | awk '{print $5"_"$6"_"$7}')"
331 | fi
332 | }
333 |
334 | # Generate dex2jar version information
335 | getdex2jarver () {
336 | if [[ ! $(command -v dex2jar) ]]; then
337 | value="dex2jar_not_found"
338 | else
339 | value="$(dex2jar 2>/dev/null | grep 'version' | cut -d - -f2)"
340 | fi
341 | }
342 |
343 | # Generate debug/binary version information
344 | getdebuginfo () {
345 | local p
346 | local key
347 | local value
348 | for p in "p7zip" "optipng" "pngcrush" "pngout" "sox" "smali" "baksmali" "adb" "aapt" "apktool" "dex2jar" "arch"
349 | do
350 | key="${p}"
351 | if [[ ${p} = p7zip ]]; then
352 | value="$(7za | grep '7-Zip..............' | cut -d C -f1 | sed 's/^[ \t]*//;s/[ \t]*$//' | sed 's/(//g' | sed 's/)//g' | sed 's/\[//g' | sed 's/\]//g' | sed 's/\ /_/g')"
353 | elif [[ ${p} = optipng ]]; then
354 | value="$(optipng -v | grep 'OptiPNG version......' | sed s/OptiPNG\ version\ //g)"
355 | elif [[ ${p} = pngcrush ]]; then
356 | value="$(pngcrush -version 2>&1 | grep 'pngcrush' | sed s/pngcrush\ //g | cut -d , -f1)"
357 | elif [[ ${p} = pngout ]]; then
358 | getpngoutver
359 | elif [[ ${p} = sox ]]; then
360 | getsoxver
361 | elif [[ ${p} = smali ]]; then
362 | value="$(runj smali --version | grep 'smali' | sed s/smali\ //g | cut -d ' ' -f1)"
363 | elif [[ ${p} = baksmali ]]; then
364 | value="$(runj baksmali --version | grep 'baksmali' | sed s/baksmali\ //g | cut -d ' ' -f1)"
365 | elif [[ ${p} = adb ]]; then
366 | value="$(adb version | sed s/Android\ Debug\ Bridge\ version\ //g)"
367 | elif [[ ${p} = aapt ]]; then
368 | value="$(aapt v | cut -d , -f2 | sed 's/^[ \t]*//;s/[ \t]*$//')"
369 | elif [[ ${p} = dex2jar ]]; then
370 | getdex2jarver
371 | elif [[ ${p} = arch ]]; then
372 | value="$(uname -m)"
373 | fi
374 | if [[ -z ${value} ]]; then
375 | value="${p}_not_found"
376 | fi
377 | write_preference
378 | pv="${p}_ver"
379 | eval $pv=\${value}
380 | done
381 | getapktver
382 | key="debugset"
383 | value="true"
384 | write_preference
385 | }
386 |
387 | # Check for .debuginfo
388 | debug_check () {
389 | osx_ver="$(sw_vers | awk '/ProductVersion/ {print $2}')"
390 | osx_bld="$(sw_vers | awk '/BuildVersion/ {print $2}')"
391 | debugset="$(defaults read "${plist}" debugset 2>/dev/null)"
392 | if [[ $? -ne 0 ]] || [[ ${debugset} -ne 1 ]] || [[ -z ${debugset} ]]; then
393 | getdebuginfo
394 | return 1
395 | fi
396 | arch_ver="$(defaults read "${plist}" arch 2>/dev/null)"
397 | if [[ $? -ne 0 ]] || [[ ! ${arch_ver} = "$(uname -m)" ]] || [[ -z ${arch_ver} ]]; then
398 | getdebuginfo
399 | return 1
400 | fi
401 | local p
402 | local v
403 | for p in "p7zip" "optipng" "pngcrush" "pngout" "sox" "smali" "baksmali" "adb" "aapt" "dex2jar" "apktool"
404 | do
405 | v="$(defaults read "${plist}" ${p} 2>/dev/null)"
406 | if [[ $? -ne 0 ]];then
407 | getdebuginfo
408 | else
409 | pv="${p}_ver"
410 | eval $pv=\${v}
411 | fi
412 | done
413 | }
414 |
415 | # Display debug/binary version information
416 | debug_display () {
417 | cd "${maindir}"
418 | clear
419 | menu_header
420 | debug_header
421 | echo $bgreen"-----------------------------------"$bwhite"Binary version info, path, etc"$bgreen"-----------------------------------";
422 | echo $white" smali version: "$green"${smali_ver}"
423 | echo $white" baksmali version: "$green"${baksmali_ver}"
424 | echo $white" dex2jar version: "$green"${dex2jar_ver}"
425 | echo $white" dex2jar path: "$blue"$(command -v dex2jar)";
426 | echo $white" sox version: "$green"${sox_ver}"
427 | echo $white" sox path: "$blue"$(command -v sox)";
428 | echo $white" 7za version: "$green"${p7zip_ver}"
429 | echo $white" 7za path: "$blue"$(command -v 7za)";
430 | echo $white" optipng version: "$green"${optipng_ver}"
431 | echo $white" optipng path: "$blue"$(command -v optipng)";
432 | echo $white" pngcrush version: "$green"${pngcrush_ver}"
433 | echo $white" pngcrush path: "$blue"$(command -v pngcrush)";
434 | echo $white" pngout version: "$green"${pngout_ver}"
435 | echo $white" pngout path: "$blue"$(command -v pngout)";
436 | echo $white" adb version: "$green"${adb_ver}"
437 | echo $white" adb path: "$blue"$(command -v adb)";
438 | echo $white" aapt version: "$green"${aapt_ver}"
439 | echo $white" aapt path: "$blue"$(command -v aapt)";
440 | echo $white" zipalign path: "$blue"$(command -v zipalign)";
441 | echo $white" rm path: "$blue"$(command -v rm)";
442 | echo $bgreen"$apkmftr";
443 | printf "$bwhite%s""Press any key to return to debug menu... "; $rclr;
444 | wait
445 | }
446 |
--------------------------------------------------------------------------------
/other/lib/multimenu.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v3.0+
4 | # Dynamic, array-built multi-selection menu
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.2b
10 | # Mon. Nov 4, 2013
11 | # -----------------------------------------------------------------------
12 |
13 | # cleanup and unset all variables used
14 | mmcleanup () {
15 | unset files
16 | unset count
17 | unset input
18 | unset mkey
19 | unset pages
20 | unset pindex
21 | unset scount
22 | unset limit
23 | unset rem
24 | unset total
25 | unset pnum
26 | unset apktver
27 | unset sdkrev
28 | unset spasswrd
29 | }
30 |
31 | # keystore menu finish function
32 | adbd_finish () {
33 | adb_dev_choice="${files[$input]}"
34 | adb_dev_model="${files[$input]}"
35 | adb_dev_product="${files[$input]}"
36 | adb_dev_device="${files[$input]}"
37 | set_adb_device_info
38 | echo "==> Selected ADB device ID is: ${adb_dev_choice}" 1>> "$log" 2>&1
39 | echo "==> ADB device: ${adb_dev_device}, model: ${adb_dev_model}, product: ${adb_dev_product}" 1>> "$log" 2>&1
40 | }
41 |
42 | # keystore menu finish function
43 | sign_finish () {
44 | keystore="${files[$input]}"
45 | echo "==> Selected Keystore is: ${keystore}" 1>> "$log" 2>&1
46 | }
47 |
48 | # branch menu finish function
49 | gitc_finish () {
50 | commit_detail="${files[$input]}"
51 | commit_detail="$(echo "${commit_detail}" | cut -d ' ' -f1)"
52 | commit_detail="$(echo $commit_detail | sed -E "s/\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")"
53 | git_commit_detail_view
54 | unset commit_detail
55 | }
56 |
57 | # branch menu finish function
58 | gitb_finish () {
59 | local saved_channel="${files[$input]}"
60 | local key="updates_branch"
61 | local value="${files[$input]}"
62 | write_preference
63 | checkout_new_branch
64 | echo "==> Selected update branch is: ${saved_channel}" 1>> "$log" 2>&1
65 | }
66 |
67 | # projects menu finish function
68 | proj_finish () {
69 | capp="${files[$input]}"
70 | prjext="${capp##*.}"
71 | echo "$logspr2" 1>> "$log" 2>&1
72 | echo "==> Selected Project file: ${capp}" 1>> "$log" 2>&1
73 | echo "==> Selected Project is an ${prjext} file" 1>> "$log" 2>&1
74 | echo "$logspr2" 1>> "$log" 2>&1
75 | }
76 |
77 | # apktool menu finish function
78 | apkt_finish () {
79 | local apktjar="${files[$input]}"
80 | echo "$logspcr" 1>> "$log" 2>&1
81 | echo "==> Selected APKtool version is: ${apktver[$input]}" 1>> "$log" 2>&1
82 | echo "$logspcr" 1>> "$log" 2>&1
83 | ln -s -f -F "${aptdir}/${apktjar}" "${libdir}/apktool.jar"
84 | find "${HOME}/apktool/framework/" -type f -name "*.apk" -exec rm -rf {} \;
85 | getapktver
86 | }
87 |
88 | # android studio menu finish function
89 | ands_finish () {
90 | if [[ -z $sdkrev ]]; then
91 | local sdkrev="${files[$input]}"
92 | fi
93 | clear
94 | version_banner
95 | echo ""
96 | echo $bgreen" You will need to enter your administrator password to continue."
97 | echo ""
98 | echo $green" First, APK Manager will generate a file with the fully qualified paths to the"
99 | echo $green" Android SDK tools embedded inside Android Studio:"
100 | echo ""
101 | echo $blue" touch \"/tmp/.android_studio\""
102 | echo $blue" echo \"/Applications/Android Studio.app/sdk/build-tools/${sdkrev}\" 1>> \"/tmp/.android_studio\""
103 | echo $blue" echo \"/Applications/Android Studio.app/sdk/tools/\" 1>> \"/tmp/.android_studio\""
104 | echo $blue" echo \"/Applications/Android Studio.app/sdk/platform-tools/\" 1>> \"/tmp/.android_studio\""
105 | echo ""
106 | echo $green" Then it will use SUDO/Administrator privilidges to copy the file to /etc/paths.d"
107 | echo ""
108 | echo $green" This is a special folder that the OSX path_helper tool checks whenever a new shell"
109 | echo $green" is opened, and adds the paths it finds to your global \$PATH variable."
110 | echo ""
111 | echo $bgreen" SUDO will be used to run the following command ONLY:"
112 | echo ""
113 | echo $blue" sudo -S cp -f \"/tmp/.android_studio\" \"/etc/paths.d/android_studio\""
114 | echo ""
115 | echo $bred" NOTE: your password is never recorded to disk, and is"
116 | echo $bred" cleared from memory once this process completes."
117 | echo ""
118 | echo $bred" APK Manager will quit and need to be re-opened after this process completes."
119 | echo ""
120 | local spasswrd
121 | printf "$bgreen%s""Enter administrator/sudo password:"; $rclr;
122 | read -s spasswrd
123 | echo ""
124 | touch "/tmp/.android_studio"
125 | echo "/Applications/Android Studio.app/sdk/build-tools/$sdkrev" 1>> "/tmp/.android_studio"
126 | echo "/Applications/Android Studio.app/sdk/tools/" 1>> "/tmp/.android_studio"
127 | echo "/Applications/Android Studio.app/sdk/platform-tools/" 1>> "/tmp/.android_studio"
128 | echo $spasswrd | sudo -S cp -f "/tmp/.android_studio" "/etc/paths.d/android_studio"
129 | if [[ $? -ne 0 ]]; then
130 | echo "==> ERROR: unable to copy path file to /etc/paths.d/android_studio" 1>> "$log" 2>&1
131 | else
132 | echo "==> Copied paths file to /etc/paths.d/android_studio" 1>> "$log" 2>&1
133 | fi
134 | rm "/tmp/.android_studio"
135 | exit 0
136 | }
137 |
138 | # read and check user input
139 | get_mmenu_input () {
140 | read input
141 | if [[ ${input} = [qQ] ]]; then
142 | if [[ $mkey = andstudio ]]; then
143 | fatal_err=$(($fatal_err+1))
144 | fi
145 | mmcleanup
146 | elif [[ ${input} = [qQ][qQ] ]]; then
147 | quit
148 | elif [[ ${input} = [nN] ]]; then
149 | if [[ ${pindex} -lt ${pages} ]]; then
150 | pindex="$((pindex + 1))"
151 | buildmenu
152 | else
153 | case ${mkey} in
154 | projects) capp="None"; prjext=""; input_err; projects_menu ;;
155 | apktool) input_err; apktool_menu ;;
156 | signing) input_err; listpkeys ;;
157 | branches) input_err; git_branches_menu ;;
158 | adbdev) input_err; adb_devices_menu ;;
159 | commits) input_err; git_log_menu ;;
160 | andstudio) input_err; android_studio_menu ;;
161 | esac
162 | fi
163 | elif [[ ${input} = [bB] ]]; then
164 | if [[ ${pindex} -gt 1 ]]; then
165 | pindex="$((pindex - 1))"
166 | buildmenu
167 | else
168 | case ${mkey} in
169 | projects) capp="None"; prjext=""; input_err; projects_menu ;;
170 | apktool) input_err; apktool_menu ;;
171 | signing) input_err; listpkeys ;;
172 | branches) input_err; git_branches_menu ;;
173 | adbdev) input_err; adb_devices_menu ;;
174 | commits) input_err; git_log_menu ;;
175 | andstudio) input_err; android_studio_menu ;;
176 | esac
177 | fi
178 | elif [[ ! ${input} =~ ^[0-9]+$ ]]; then
179 | case ${mkey} in
180 | projects) capp="None"; prjext=""; input_err; projects_menu ;;
181 | apktool) input_err; apktool_menu ;;
182 | signing) input_err; listpkeys ;;
183 | branches) input_err; git_branches_menu ;;
184 | adbdev) input_err; adb_devices_menu ;;
185 | commits) input_err; git_log_menu ;;
186 | andstudio) input_err; android_studio_menu ;;
187 | esac
188 | elif [[ ${input} -lt ${scount} ]] || [[ ${input} -gt ${limit} ]]; then
189 | case ${mkey} in
190 | projects) capp="None"; prjext=""; input_err; projects_menu ;;
191 | apktool) input_err; apktool_menu ;;
192 | signing) input_err; listpkeys ;;
193 | branches) input_err; git_branches_menu ;;
194 | adbdev) input_err; adb_devices_menu ;;
195 | commits) input_err; git_log_menu ;;
196 | andstudio) input_err; android_studio_menu ;;
197 | esac
198 | else
199 | case ${mkey} in
200 | projects) proj_finish ;;
201 | apktool) apkt_finish ;;
202 | signing) sign_finish ;;
203 | branches) gitb_finish ;;
204 | adbdev) adbd_finish ;;
205 | commits) gitc_finish ;;
206 | andstudio) ands_finish ;;
207 | esac
208 | fi
209 | }
210 |
211 | # actually parse array items/files
212 | parse_files () {
213 | for ((count=${scount}; count <= ${limit}; count++)); do
214 | if [[ ${mkey} = apktool ]]; then
215 | local apktvtmp1="$(java -jar "${aptdir}/${files[$count]}" | grep 'Apktool'| cut -d - -f1 | sed 's/^[ \t]*//;s/[ \t]*$//' | sed 's/\ /_/g')"
216 | apktver[$count]="${apktvtmp1%%-*}"
217 | if [[ ${count} -le 9 ]]; then
218 | echo $bgreen" ${count}"$white" ${files[$count]} "$blue"(${apktver[$count]})"; $rclr;
219 | elif [[ ${count} -ge 10 ]]; then
220 | echo $bgreen" ${count}"$white" ${files[$count]} "$blue"(${apktver[$count]})"; $rclr;
221 | fi
222 | else
223 | if [[ ${count} -le 9 ]]; then
224 | echo $bgreen" ${count}"$white" ${files[$count]}"; $rclr;
225 | elif [[ ${count} -ge 10 ]]; then
226 | echo $bgreen" ${count}"$white" ${files[$count]}"; $rclr;
227 | fi
228 | fi
229 | done
230 | }
231 |
232 | # set the range of items to show on the page
233 | setup_page () {
234 | if [[ ${pages} -le 1 ]]; then
235 | pindex="${pages}"
236 | scount="1"
237 | limit="${total}"
238 | else
239 | if [[ -z ${pindex} ]]; then
240 | pindex="1"
241 | fi
242 | limit="$((pindex * ${pnum}))"
243 | scount="$((limit - $((pnum - 1))))"
244 | if [[ ${limit} -ge ${total} ]]; then
245 | if [[ ${rem} -ne 0 ]]; then
246 | local ldiff="$((pnum - ${rem}))"
247 | limit="$((limit - ${ldiff}))"
248 | fi
249 | fi
250 | fi
251 | }
252 |
253 | # check if we only need one page
254 | page_check () {
255 | total="${#files[*]}"
256 | total="$((total -1))"
257 | pages="$((total / ${pnum}))"
258 | rem="$((total % ${pnum}))"
259 | if [[ ${rem} -ne 0 ]]; then
260 | pages="$((pages + 1))"
261 | fi
262 | }
263 |
264 | # check if menu type is set
265 | check_mkey_set () {
266 | if [[ -z ${mkey} ]]; then
267 | return 1
268 | fi
269 | }
270 |
271 | # start building dynamic menu
272 | buildmenu () {
273 | check_mkey_set
274 | clear
275 | if [[ ${mkey} = andstudio ]]; then
276 | version_banner
277 | else
278 | menu_header
279 | fi
280 | if [[ ${mkey} = projects ]]; then
281 | echo $bgreen"-----------------------------------"$bwhite"Select project file to work on"$bgreen"-----------------------------------";
282 | elif [[ ${mkey} = adbdev ]]; then
283 | debug_header
284 | echo $bgreen"----------------------------------------"$bwhite"Select an ADB Device"$bgreen"----------------------------------------";
285 | echo $bred" If Menu is empty, try reconnecting your devices USB cable, or setup a wireless adb connection."
286 | echo $bgreen"$apkmspr"
287 | elif [[ ${mkey} = apktool ]]; then
288 | debug_header
289 | echo $bgreen"------------------------------------------"$bwhite"APKtool Versions"$bgreen"------------------------------------------";
290 | elif [[ ${mkey} = signing ]]; then
291 | echo $bgreen"---------------------------------------"$bwhite"Select a keystore menu"$bgreen"---------------------------------------";
292 | echo $white" Current Keystore: "$bgreen"${keystore}"
293 | echo $bgreen"$apkmspr"
294 | elif [[ ${mkey} = commits ]]; then
295 | updates_header
296 | echo $bgreen"--------------------------------"$bwhite"Select commit to view detail history"$bgreen"--------------------------------";
297 | echo $green" Enter list number to see detailed commit information for the selected commit."
298 | echo $bgreen"$apkmspr"
299 | elif [[ ${mkey} = branches ]]; then
300 | updates_header
301 | echo $bgreen"----------------------------------------"$bwhite"Select update branch"$bgreen"----------------------------------------";
302 | echo $bred" Warning: APK Manager will automatically quit once the new branch has been checked out."
303 | echo $bgreen"$apkmspr"
304 | elif [[ ${mkey} = andstudio ]]; then
305 | echo ""
306 | echo $bgreen"-------------------------------"$bwhite"Select Android Studio Platform Version"$bgreen"-------------------------------";
307 | echo $bred" Note: due to the way updates are handled to the Android SDK, most tools (adb, zipalign, monitor,"
308 | echo $bred" draw9patch) will always be from the newest platform installed, regardless of your choice."
309 | echo $bred" The choice here will effect which version of \"aapt\" and other build-tools are used."
310 | echo $bgreen"$apkmspr"
311 | echo $bred" Note: the \"android-4.2.2\" option is API level 17."
312 | echo $bgreen"$apkmspr"
313 | fi
314 | page_check
315 | setup_page
316 | parse_files
317 | echo $bgreen"$apkmftr";
318 | if [[ ${pages} -ge 2 ]]; then
319 | echo $white"(use "$bgreen"N"$white" to go to next page, "$bgreen"B"$white" to go back to previous page, or "$bgreen"Q"$white" to quit)"; $rclr;
320 | else
321 | echo $white"(use "$bgreen"Q"$white" to quit)"; $rclr;
322 | fi
323 | printf "$bwhite%s""Please select an option from above: "; $rclr;
324 | get_mmenu_input
325 | }
326 |
327 | # parse the ADB devices command
328 | populate_adb_devices () {
329 | adb devices -l | while read line;
330 | do
331 | if [[ "${line}" = *daemon* ]] || [[ "${line}" = *List* ]]; then
332 | :
333 | else
334 | echo "${line}"
335 | fi
336 | done
337 | }
338 |
339 | # parse the git log/commits history
340 | populate_git_commits () {
341 | git log --pretty=format:"%Cred%h%Creset | %Cgreen%ad%Creset | %s" --date=short | while read line;
342 | do
343 | echo "${line}"
344 | done
345 | }
346 |
347 | # check for existing array before starting
348 | check_files_set () {
349 | if [[ $files ]]; then
350 | unset files
351 | fi
352 | }
353 |
354 | # android studio platforms default only check
355 | and_studio_platforms_check () {
356 | # if [[ ${files[1]} = "android-4.2.2" ]]; then
357 | if [[ ${#files[@]} -eq 2 ]]; then
358 | sdkrev="${files[1]}"
359 | ands_finish
360 | else
361 | pnum=19
362 | buildmenu
363 | fi
364 | mmcleanup
365 | }
366 |
367 | # Projects menu
368 | projects_menu () {
369 | check_files_set
370 | mkey="projects"
371 | cd "${maindir}/${mod_dir}"
372 | files[0]="projects_menu - YOU SHOULD NOT SEE THIS"
373 | files+=( $(ls *.[aA][pP][kK] *.[jJ][aA][rR]) )
374 | pnum=29
375 | buildmenu
376 | mmcleanup
377 | }
378 |
379 | # Keystore menu
380 | listpkeys () {
381 | check_files_set
382 | mkey="signing"
383 | cd "${HOME}/.apkmanager/.keystores"
384 | files[0]="listpkeys - YOU SHOULD NOT SEE THIS"
385 | files+=( $(ls *.[kK][eE][yY][sS][tT][oO][rR][eE]) )
386 | pnum=27
387 | buildmenu
388 | mmcleanup
389 | }
390 |
391 | # Apktool.jar menu
392 | apktool_menu () {
393 | check_files_set
394 | mkey="apktool"
395 | cd "${aptdir}"
396 | files[0]="apktool_menu - YOU SHOULD NOT SEE THIS"
397 | files+=( $(ls [aA][pP][kK][tT][oO][oO][lL]_*.[jJ][aA][rR]) )
398 | pnum=20
399 | buildmenu
400 | mmcleanup
401 | }
402 |
403 | # git/update branches menu
404 | git_branches_menu () {
405 | check_files_set
406 | mkey="branches"
407 | cd "${maindir}/.git/refs/remotes/origin"
408 | files[0]="git_branches_menu - YOU SHOULD NOT SEE THIS"
409 | files+=( $(ls -1) )
410 | pnum=20
411 | buildmenu
412 | mmcleanup
413 | }
414 |
415 | # git log/commit history menu
416 | git_log_menu () {
417 | check_files_set
418 | mkey="commits"
419 | cd "${maindir}"
420 | OLDIFS=$IFS
421 | IFS=$'\n'
422 | files[0]="git_branches_menu - YOU SHOULD NOT SEE THIS"
423 | files+=( $(populate_git_commits) )
424 | IFS=$OLDIFS
425 | pnum=19
426 | buildmenu
427 | mmcleanup
428 | }
429 |
430 | # android studio platform selection menu
431 | android_studio_menu () {
432 | check_files_set
433 | mkey="andstudio"
434 | cd "/Applications/Android Studio.app/sdk/build-tools"
435 | OLDIFS=$IFS
436 | IFS=$'\n'
437 | files[0]="android_studio_menu - YOU SHOULD NOT SEE THIS"
438 | files+=( $(ls | sort) )
439 | IFS=$OLDIFS
440 | and_studio_platforms_check
441 | }
442 |
443 | # ADB connected devices menu
444 | adb_devices_menu () {
445 | check_files_set
446 | mkey="adbdev"
447 | cd "${maindir}"
448 | OLDIFS=$IFS
449 | IFS=$'\n'
450 | files[0]="adb_devices_menu - YOU SHOULD NOT SEE THIS"
451 | files+=( $(populate_adb_devices) )
452 | IFS=$OLDIFS
453 | pnum=18
454 | buildmenu
455 | mmcleanup
456 | }
457 |
--------------------------------------------------------------------------------
/other/lib/install.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v3.0+
4 | # Installation functions
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.2b
10 | # Sat. Nov 2, 2013
11 | # -----------------------------------------------------------------------
12 |
13 | # cleanup variables used during installation
14 | cleanup_install () {
15 | unset count
16 | unset missing
17 | unset key
18 | unset value
19 | unset input
20 | unset err_shown
21 | unset btap
22 | unset needsdk
23 | unset p
24 | }
25 |
26 | # write install status to plist
27 | setinstallstatus () {
28 | local key
29 | local value
30 | key="install"
31 | value="${installtype}"
32 | write_preference
33 | local key="debugset"
34 | local value="false"
35 | write_preference
36 | unset apktool_ver
37 | if [[ -f "${HOME}/.apkmanager/.debuginfo" ]]; then
38 | rm -r "${HOME}/.apkmanager/.debuginfo"
39 | fi
40 | }
41 |
42 | # java not found fatal error string
43 | java_error () {
44 | echo $bred" FATAL ERROR: Java was not found on this system."
45 | echo $bred" Starting with OS X 10.7, java is not included"
46 | echo $bred" with the default OS X installation."
47 | echo $bred" Please install Java before using APK Manager."
48 | echo ""
49 | printf "$bred%s"" PRESS ANY KEY TO EXIT..."; $rclr;
50 | wait
51 | exit 1
52 | }
53 |
54 | # android sdk warning/error message
55 | andsdk_error () {
56 | clear
57 | echo ""
58 | version_banner
59 | echo ""
60 | echo $bred" WARNING: neither a standalone copy of the Android SDK"
61 | echo $bred" or Android Studio were found on this system."
62 | echo ""
63 | echo $white" And APK Manager did not find \"homebrew\" to"
64 | echo $white" install the SDK automatically for you."
65 | echo ""
66 | echo $white" Though not technically required to function, the"
67 | echo $white" Android SDK is incredibly useful, and will enable"
68 | echo $white" APK Manager to launch ddms and draw9patch."
69 | echo ""
70 | echo $white" Please see the Android SDK installation page:"
71 | echo ""
72 | echo $bgreen" http://developer.android.com/sdk/index.html"
73 | echo ""
74 | echo $bred" be sure to add both \"tools\" and \"platform-tools\""
75 | echo $bred" to your \"\$PATH\" after installation finishes."
76 | echo ""
77 | echo $bgreen"$apkmftr";
78 | printf "$bred%s"" PRESS ANY KEY TO CONTINUE..."; $rclr;
79 | err_shown="1"
80 | wait
81 | }
82 |
83 | # homebrew installation error message
84 | brew_install_error () {
85 | echo $bred" ERROR: Homebrew encountered an error"
86 | echo $bred" trying to install the necessary programs."
87 | echo $bred" Please run \"brew doctor\" and \"brew update\""
88 | echo $bred" and try apk manager setup again."
89 | echo ""
90 | printf "$bred%s"" PRESS ANY KEY TO EXIT..."; $rclr;
91 | wait
92 | exit 1
93 | }
94 |
95 | # pngout error message
96 | pngout_error () {
97 | echo $bred" WARNING: pngout was not found on this system."
98 | echo $bred" To install pngout, please select pngout for"
99 | echo $bred" your optimization tool from the debug menu inside"
100 | echo $bred" APK Manager once setup finishes."
101 | echo ""
102 | printf "$bred%s"" PRESS ANY KEY TO CONTINUE..."; $rclr;
103 | wait
104 | }
105 |
106 | # error message during install
107 | bin_install_err () {
108 | echo $bred"Something went wrong trying to install required binaries"
109 | printf "$bred%s""PRESS ANY KEY TO EXIT..."; $rclr;
110 | wait
111 | exit 1
112 | }
113 |
114 | # placeholder for updates setup prompt
115 | setup_updates_prompt () {
116 | if [[ $count -ne 0 ]]; then
117 | clear
118 | echo ""
119 | version_banner
120 | fi
121 | echo ""
122 | echo $white" APK Manager has detected that \"git\" is installed on this system."
123 | echo $white" Using git, APK Manager can keep itself up-to-date by automatically"
124 | echo $white" by checking weekly for new updates to APK Manager on github:"; $rclr;
125 | echo ""
126 | echo $green" https://github.com/jocelynmallon/apkmanager"
127 | echo ""
128 | echo $bgreen"$apkmftr";
129 | printf "$white%s""Would you like to enable automatic updates? ("$bgreen"y"$white"/"$bgreen"n"$white") "; $rclr;
130 | read input
131 | case "$input" in
132 | [yY]) enable_auto_updates ;;
133 | [nN]) disable_auto_updates ;;
134 | *) input_err; setup_updates_prompt ;;
135 | esac
136 | }
137 |
138 | # check if 'git' installed, and we have .git repo
139 | finish_setup () {
140 | if [[ $(command -v git) ]]; then
141 | setup_updates_prompt
142 | cleanup_install
143 | else
144 | echo "git not found, disabling updates" 1>> "$log"
145 | disable_auto_updates
146 | finish_install_prompt
147 | cleanup_install
148 | fi
149 | }
150 |
151 | # simple finish function for homebrew setup
152 | homebrew_finish () {
153 | installtype="homebrew"
154 | setinstallstatus
155 | }
156 |
157 | # install programs with homebrew
158 | setup_homebrew () {
159 | clear
160 | echo ""
161 | version_banner
162 | echo ""
163 | echo $white" APK Manager will now perform the following to install the required programs:"
164 | echo ""
165 | declare -i count=1
166 | while [[ ${missing[$count]} ]]
167 | do
168 | if [[ ${missing[$count]} = android-sdk ]]; then
169 | needsdk="1"
170 | echo $green" brew install ${missing[$count]}"
171 | elif [[ ${missing[$count]} = sox ]]; then
172 | echo $green" brew install ${missing[$count]} "$blue"(opens a new terminal tab)"
173 | soxdeps="1"
174 | unset missing[$count]
175 | count=$((count-1))
176 | else
177 | echo $green" brew install ${missing[$count]}"
178 | fi
179 | count=$((count+1))
180 | done
181 | echo ""
182 | echo $white" Depending on the specific missing programs, this may take a while."
183 | echo $white" Please do not close terminal until everything finishes."
184 | if [[ $needsdk -ne 0 ]]; then
185 | echo ""
186 | echo $white" Homebrew is installing the android-sdk. After it finishes, it"
187 | echo $white" attempts to launch the Android SDK Manager. Please install"
188 | echo $white" the \"Android SDK Platform-tools\" and update and/or install"
189 | echo $white" any other components or SDK revisions you'd like. I suggest"
190 | echo $white" installing the SDK API's and Google API's for levels 10-15."
191 | fi
192 | if [[ $soxdeps -ne 0 ]]; then
193 | echo ""
194 | echo $white" APK Manager needs to install \"sox\" in order to be able to"; $rclr;
195 | echo $white" optimize .ogg files. However, installing sox will fail if run"; $rclr;
196 | echo $white" inside this script. Instead, APK Manager will open a new tab"; $rclr;
197 | echo $white" and run: "$bgreen"brew install sox; exit"; $rclr;
198 | echo $white" once the new tab closes, come back to this script and press enter.\n"; $rclr;
199 | fi
200 | echo $bgreen"$apkmspr"
201 | genericpanykey
202 | echo ""
203 | if [[ $btap -ne 0 ]]; then
204 | brew tap adamv/alt
205 | if [[ $? -ne 0 ]]; then
206 | brew_install_error
207 | else
208 | echo ""
209 | unset btap
210 | fi
211 | fi
212 | if [[ $soxdeps -ne 0 ]]; then
213 | local apkmopt="brew install sox; exit"
214 | newttab "$apkmopt" "$log"
215 | genericpanykey
216 | if [[ $? -ne 0 ]]; then
217 | brew_install_error
218 | else
219 | echo ""
220 | unset soxdeps
221 | fi
222 | fi
223 | if [[ $count -eq 1 ]]; then
224 | homebrew_finish
225 | finish_setup
226 | else
227 | brew install ${missing[*]}
228 | if [[ $? -ne 0 ]]; then
229 | brew_install_error
230 | else
231 | if [[ $needsdk -ne 0 ]]; then
232 | echo ""
233 | echo $bgreen" Launching the Android SDK Manager..."
234 | android
235 | unset needsdk
236 | fi
237 | homebrew_finish
238 | echo ""
239 | echo $bgreen"$apkmftr";
240 | genericpanykey
241 | finish_setup
242 | fi
243 | fi
244 | }
245 |
246 | # setup using precompiled/bundled programs
247 | setup_bundled () {
248 | cd "${maindir}/other"
249 | clear
250 | echo ""
251 | version_banner
252 | echo ""
253 | echo $bgreen" Setting up APK Manager for pre-compiled programs..."
254 | echo ""
255 | echo $white" Checking for other/bundled_programs.tar.gz"
256 | echo ""
257 | if [[ ! -f "${maindir}/other/bundled_programs.tar.gz" ]]; then
258 | echo $green" Archive not found, downloading archive..."; $rclr;
259 | echo ""
260 | curl "http://dl.dropbox.com/u/9401664/APK%20Manager/bundled_programs.tar.gz" > "${maindir}/other/bundled_programs.tar.gz"
261 | echo ""
262 | fi
263 | local filehash="$(md5 -q ${maindir}/other/bundled_programs.tar.gz)"
264 | local expected="9780aeca7928aaba3e18cd89d29fbe31"
265 | if [[ ${filehash} = ${expected} ]]; then
266 | echo $bgreen" Extracting pre-compiled programs to:"
267 | echo $bgreen" ${maindir}/other"; $rclr;
268 | echo ""
269 | echo "Extracting pre-compiled programs..." 1>> "$log" 2>&1
270 | tar -xzvf "${maindir}/other/bundled_programs.tar.gz" 1>> "$log" 2>&1
271 | if [[ $? -ne 0 ]]; then
272 | bin_install_err
273 | else
274 | echo $bgreen" Removing temporary files..."
275 | echo "Removing temporary files." 1>> "$log" 2>&1
276 | rm -r "${maindir}/other/bundled_programs.tar.gz"
277 | echo ""
278 | echo $bgreen"$apkmftr";
279 | installtype="bundled"
280 | setinstallstatus
281 | genericpanykey
282 | finish_setup
283 | fi
284 | else
285 | echo $bred" ERROR: Corrupt download/file, md5 hash fail:"
286 | echo $bred" download: ${filehash}"
287 | echo $bred" expected: ${expected}"
288 | echo ""
289 | echo $white"press any key to try download again..."
290 | wait
291 | rm -r "${maindir}/other/bundled_programs.tar.gz"
292 | setup_bundled
293 | fi
294 | }
295 |
296 | # Installation complete message/prompt
297 | finish_install_prompt () {
298 | echo ""
299 | echo $white"APK Manager did not find \"git\" on this sytem to enable"
300 | echo $white"automatic updates. If you install git and want to enable"
301 | echo $white"them at a later date, please see the debug/settings menu."; $rclr;
302 | echo ""
303 | echo $bgreen"APK Manager v3.0 setup complete!"
304 | echo $bgreen"$apkmftr";
305 | genericpanykey
306 | }
307 |
308 | # no missing programs, check for git, or finish
309 | preconf_text () {
310 | echo $bgreen"$apkmspr"
311 | if [[ $(command -v brew) ]] && [[ $count -eq 0 ]]; then
312 | echo $white" APK Manager has detected that \"Homebrew\" is already setup on this system"; $rclr;
313 | echo $green" and found all programs necessary to function already installed!"; $rclr;
314 | installtype="homebrew"
315 | elif [[ ! $(command -v brew) ]] && [[ $count -eq 0 ]]; then
316 | echo $white" APK Manager has detected that Homebrew is not setup on this system."; $rclr;
317 | echo $green" However all programs necessary to function are already installed!"; $rclr;
318 | installtype="preconfigured"
319 | fi
320 | echo $bgreen"$apkmspr"
321 | if [[ $(command -v git) ]]; then
322 | setinstallstatus
323 | setup_updates_prompt
324 | else
325 | setinstallstatus
326 | disable_auto_updates
327 | finish_install_prompt
328 | fi
329 | }
330 |
331 | # can't/won't use homebrew message
332 | no_brew_text () {
333 | echo $white" If you prefer not to use Homebrew (or for some reason you can't use Homebrew,"
334 | echo $blue" (ex. work computer, you don't want to install Xcode/command line tools, etc.)"
335 | echo $white" then APK Manager can use pre-compiled binaries for your architecture."
336 | }
337 |
338 | # use homebrew prompt/message
339 | brew_text () {
340 | echo $bgreen"$apkmspr"
341 | echo $white" APK Manager has detected that Homebrew is already setup on this system"
342 | echo $bred" however it did not find all the required programs it needs to function."
343 | echo $white" Would you like to use homebrew to install the missing programs?"
344 | echo ""
345 | no_brew_text
346 | echo $bgreen"$apkmftr";
347 | printf "$white%s""Would you like to use Homebrew? ("$bgreen"y"$white"/"$bgreen"n"$white") "; $rclr;
348 | read input
349 | case "$input" in
350 | [yY]) setup_homebrew ;;
351 | [nN]) setup_bundled ;;
352 | *) input_err; install ;;
353 | esac
354 | }
355 |
356 | # default install prompt/message
357 | default_text () {
358 | echo $bgreen"$apkmspr"
359 | echo $bred" APK Manager has detected that Homebrew is not setup on this system."
360 | echo $white" If you would like to use Homebrew, please follow the instructions here:"
361 | echo ""
362 | echo $blue" https://github.com/mxcl/homebrew/wiki/installation"
363 | echo ""
364 | echo $bred" please be sure and run \"brew doctor\" and \"brew update\" after the "
365 | echo $bred" installation finishes, before running APK Manager again."
366 | echo ""
367 | no_brew_text
368 | echo $bgreen"$apkmftr";
369 | printf "$white%s""Would you like to use pre-compiled binaries? ("$bgreen"y"$white"/"$bgreen"n"$white") "; $rclr;
370 | read input
371 | case "$input" in
372 | [yY]) setup_bundled ;;
373 | [nN]) echo $bred"EXITING SETUP...\n"; $rclr; exit 1 ;;
374 | *) input_err; install ;;
375 | esac
376 | }
377 |
378 | # main install skeleton function
379 | install () {
380 | echo "install (setup/install APK Manager) function" 1>> "$log"
381 | clear
382 | echo ""
383 | version_banner
384 | echo ""
385 | echo $bwhite" Welcome to APK Manager for Mac OS X!"
386 | echo ""
387 | echo $bgreen" This installation script should only appear on first launch of v3.0+"
388 | echo ""
389 | echo $white" Version 3.0 adds an option to use "$bgreen"Homebrew"$white" ("$blue"http://mxcl.github.com/homebrew/"$white")"
390 | echo $white" to automatically install programs necessary for APK Manager to function."
391 | echo $white" Using Homebrew is highly recommended. It allows for cleaner installations,"
392 | echo $white" faster updates to required programs, and enables automatic updates"
393 | echo $white" to APK Manager using \"git\" and \"github.com\"."
394 | echo ""
395 | if [[ $count -eq 0 ]]; then
396 | preconf_text
397 | elif [[ $(command -v brew) ]] && [[ $count -ne 0 ]]; then
398 | brew_text
399 | else
400 | default_text
401 | fi
402 | echo "install function complete" 1>> "$log"
403 | }
404 |
405 | # missing android sdk programs sub function
406 | and_sdk_sub () {
407 | if [[ $(command -v brew) ]]; then
408 | if [[ ! ${missing[$((count - 1))]} = "android-sdk" ]]; then
409 | p="android-sdk"
410 | missing[$count]="$p"
411 | fi
412 | else
413 | count=$((count-1))
414 | if [[ -z $err_shown ]]; then
415 | andsdk_error
416 | fi
417 | fi
418 | }
419 |
420 | # check for required programs
421 | installcheck () {
422 | if [[ ! $(command -v java) ]]; then
423 | java_error
424 | elif [[ ! $(command -v sudo) ]]; then
425 | sudo_error
426 | else
427 | declare -i count=0
428 | for p in "optipng" "sox" "pngcrush" "7za" "adb" "aapt" "zipalign"
429 | do
430 | if [[ ! $(command -v ${p}) ]]; then
431 | count=$((count+1))
432 | if [[ ${p} = adb ]] || [[ ${p} = aapt ]] || [[ ${p} = zipalign ]]; then
433 | if [[ ${p} = aapt ]]; then
434 | if [[ $(command -v android) ]] && [[ $(command -v brew) ]]; then
435 | if [[ $(dirname "$(command -v android)") = /usr/local/bin ]]; then
436 | local sdkrev="$(brew list --versions android-sdk | sed s/android-sdk\ //g)"
437 | ln -s "/usr/local/Cellar/android-sdk/${sdkrev}/platform-tools/aapt" "/usr/local/bin/aapt"
438 | count=$((count-1))
439 | fi
440 | else
441 | and_sdk_sub
442 | fi
443 | elif [[ ${p} = adb ]] || [[ ${p} = zipalign ]]; then
444 | and_sdk_sub
445 | fi
446 | elif [[ ${p} = 7za ]]; then
447 | p="p7zip"
448 | missing[$count]="${p}"
449 | else
450 | missing[$count]="${p}"
451 | fi
452 | fi
453 | done
454 | fi
455 | install
456 | }
457 |
458 | # Start
459 | user_dir_check
460 | installcheck
461 | return 0
462 |
--------------------------------------------------------------------------------
/other/lib/zipcmp_funcs.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v3.0+
4 | # Zip, compile, all-in-one functions
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.2b
10 | # Wed. Aug 7, 2013
11 | # -----------------------------------------------------------------------
12 |
13 | # Zip/compress a system apk file
14 | zip_sys_apk () {
15 | echo "zip_sys_apk (actually zipping apk now) function" 1>> "$log"
16 | 7za a -tzip "${maindir}/${mod_dir}/unsigned-${capp}" "${maindir}/${prj_dir}/${capp}/*" -mx${uscr} 1>> "$log" 2>&1
17 | }
18 |
19 | # Zip/compress non-system apk file
20 | zip_nrm_apk () {
21 | echo "zip_nrm_apk (remove signature for non system-apk) function" 1>> "$log"
22 | rm -rf "${maindir}/${prj_dir}/${capp}/META-INF"
23 | zip_sys_apk
24 | }
25 |
26 | # Zip/compress single file, initial checks
27 | zip_apk () {
28 | echo "zip_apk (main prompt) function" 1>> "$log"
29 | capp_test
30 | if [[ ${capp} = "None" ]]; then
31 | echo "no project selected, aborting" 1>> "$log"
32 | return 1
33 | elif [[ ! ${prjext} = [Aa][Pp][Kk] ]]; then
34 | jarext_err
35 | elif [[ ! -d "${maindir}/${prj_dir}/${capp}" ]]; then
36 | nodir_err
37 | elif [[ $(ls -1 "${maindir}/${prj_dir}/${capp}" | wc -l) -eq 0 ]]; then
38 | nodir_err
39 | elif [[ ! -f "${maindir}/${prj_dir}/${capp}/resources.arsc" ]]; then
40 | noex_err
41 | else
42 | rm "${maindir}/${mod_dir}/signed-${capp}"
43 | rm "${maindir}/${mod_dir}/unsigned-${capp}"
44 | echo $bgreen" 1"$white" System apk "$green"(Retains signature)";
45 | echo $bgreen" 2"$white" Regular apk "$green"(Removes signature for re-signing)";
46 | printf "$bwhite%s""Please select an option: "; $rclr;
47 | read input
48 | case "$input" in
49 | 1) zip_sys_apk ;;
50 | 2) zip_nrm_apk ;;
51 | *) input_err; zip_apk ;;
52 | esac
53 | unset input
54 | fi
55 | echo "zip_apk function complete" 1>> "$log"
56 | }
57 |
58 | # Install an apk file
59 | install_apk () {
60 | echo "install_apk function" 1>> "$log"
61 | capp_test
62 | if [[ ${capp} = "None" ]]; then
63 | echo "no project selected, aborting" 1>> "$log"
64 | return 1
65 | elif [[ ! ${prjext} = [Aa][Pp][Kk] ]]; then
66 | jarext_err
67 | else
68 | adb_multiple_devices_check
69 | if [[ $? -ne 0 ]]; then
70 | return 1
71 | elif [[ ! -e "${maindir}/${mod_dir}/signed-${capp}" ]]; then
72 | echo $bred"Error, cannot find file: signed-${capp}";
73 | echo "Error, cannot find file: signed-${capp}" 1>> "$log"
74 | echo $bred"Please use \"sign apk\" option first"; $rclr;
75 | pressanykey
76 | else
77 | echo "Attempting to install signed-${capp} to:"
78 | timeout3 -t 5 adb devices | grep "${adb_dev_choice}"
79 | echo ""
80 | printf "$bwhite%s""Press any key to continue "; $rclr;
81 | wait
82 | adb -s "${adb_dev_choice}" wait-for-device install -r "$mod_dir/signed-$capp"
83 | printf "$bwhite%s""Press any key to continue "; $rclr;
84 | wait
85 | fi
86 | fi
87 | echo "install_apk function complete" 1>> "$log"
88 | }
89 |
90 | # Use "keep" process
91 | sys_yes_keep () {
92 | echo "sys_yes_keep (compile system apk, YES keep folder)" 1>> "$log"
93 | if [[ ! -d "${maindir}/keep" ]]; then
94 | mkdir -p "${maindir}/keep"
95 | fi
96 | 7za x -o"${maindir}/keep" "${maindir}/${mod_dir}/${capp}" 1>> "$log" 2>&1
97 | echo ""
98 | echo $white"In the apk manager folder you'll find"
99 | echo "a "$bgreen"keep"$white" folder. Within it, delete"
100 | echo "everything you have modified and leave any"
101 | echo "files that you haven't. "$bgreen"If you have modified"
102 | echo "any xml, then delete resources.arsc from that"
103 | echo "folder as well."$white" Once done then press enter"
104 | echo "on this script."; $rclr;
105 | wait
106 | 7za a -tzip "${maindir}/${mod_dir}/unsigned-${capp}" "${maindir}/keep/*" -mx${uscr} -r -y 1>> "$log" 2>&1
107 | if [[ $? -eq 0 ]]; then
108 | rm -rf "${maindir}/keep"
109 | fi
110 | echo "sys_yes_keep function complete" 1>> "$log"
111 | }
112 |
113 | # Don't use "keep" process
114 | sys_no_keep () {
115 | echo "sys_no_keep (compile system apk, NO keep folder)" 1>> "$log"
116 | if [[ -d "${maindir}/${prj_dir}/temp" ]]; then
117 | rm -rf "${maindir}/${prj_dir}/temp"
118 | mkdir -p "${maindir}/${prj_dir}/temp"
119 | fi
120 | cd "${maindir}/other"
121 | 7za x -o"${maindir}/${prj_dir}/temp" "${maindir}/${mod_dir}/${capp}" META-INF -r -y 1>> "$log" 2>&1
122 | 7za x -o"${maindir}/${prj_dir}/temp" "${maindir}/${mod_dir}/${capp}" AndroidManifest.xml -y 1>> "$log" 2>&1
123 | 7za a -tzip "${maindir}/${mod_dir}/unsigned-${capp}" "${maindir}/${prj_dir}/temp/*" -mx${uscr} -r -y 1>> "$log" 2>&1
124 | if [[ $? -eq 0 ]]; then
125 | rm -rf "${maindir}/${prj_dir}/temp"
126 | fi
127 | cd "${maindir}"
128 | echo "sys_no_keep function complete" 1>> "$log"
129 | }
130 |
131 | # System apk "keep" process prompt
132 | sys_keep_prompt () {
133 | echo "sys_keep_prompt (compile system apk, keep folder prompt)" 1>> "$log"
134 | echo ""
135 | echo $bgreen"Aside from the signatures"$white", would you like to copy";
136 | echo $white"over any additional files that you didn't modify";
137 | echo $white"from the original apk in order to ensure least";
138 | printf "$white%s""number of errors? ("$bgreen"y"$white"/"$bgreen"n"$white") "; $rclr;
139 | read input
140 | case "$input" in
141 | [yY]) sys_yes_keep ;;
142 | [nN]) sys_no_keep ;;
143 | *) input_err; sys_keep_prompt ;;
144 | esac
145 | }
146 |
147 | # Compile, system apk keep prompt
148 | co_sys_prompt () {
149 | echo "co_sys_prompt (compile apk, system apk prompt)" 1>> "$log"
150 | printf "$white%s""Is this a system apk? ("$bgreen"y"$white"/"$bgreen"n"$white") "; $rclr;
151 | read input
152 | case "$input" in
153 | [yY]) sys_keep_prompt ;;
154 | [nN]) ;;
155 | *) input_err; co_sys_prompt ;;
156 | esac
157 | }
158 |
159 | # Actually compile with smali.jar
160 | comp_smali () {
161 | echo "comp_smali, actually compiling now" 1>> "$log"
162 | rm -rf "${maindir}/${prj_dir}/${capp}/build"
163 | mkdir -p "${maindir}/${prj_dir}/${capp}/build"
164 | touch "${maindir}/${prj_dir}/${capp}/build/classes.dex"
165 | runj smali -JXmx"${heapy}""m" "${maindir}/${prj_dir}/${capp}" -o "${maindir}/${prj_dir}/${capp}/build/classes.dex" 1>> "$log" 2>&1
166 | echo "comp_smali function complete" 1>> "$log"
167 | }
168 |
169 | # Actually compile an apk file with apktool
170 | comp_apkt () {
171 | echo "comp_apkt, actually compiling now" 1>> "$log"
172 | runj apktool -JXmx"${heapy}""m" b "${maindir}/${prj_dir}/${capp}" "${maindir}/${mod_dir}/unsigned-${capp}" 1>> "$log" 2>&1
173 | }
174 |
175 | # Compile an apk skeleton/shell
176 | compile_apk () {
177 | echo "compile_apk, (compile with apktool) function" 1>> "$log"
178 | echo "Compiling apk..."
179 | comp_apkt
180 | if [[ $? -ne 0 ]]; then
181 | echo $bred"An error occured while compiling, please check log."; $rclr;
182 | pressanykey
183 | else
184 | co_sys_prompt
185 | fi
186 | echo "compile_apk function complete" 1>> "$log"
187 | }
188 |
189 | # Advanced compile final packaging
190 | comp_adv_final () {
191 | 7za x -o"${maindir}/${prj_dir}/temp" "${maindir}/${mod_dir}/unsigned-${capp}" classes.dex -y 1>> "$log" 2>&1
192 | dex1="${maindir}/${prj_dir}/${capp}/build/classes.dex"
193 | dex2="${maindir}/${prj_dir}/temp/classes.dex"
194 | echo "comparing classes.dex to ensure the smali version is used" 1>> "$log"
195 | diff -s "${dex1}" "${dex2}" 1>> "$log" 2>&1
196 | if [[ $? -ne 0 ]]; then
197 | echo "copying classes.dex compiled by smali into unsigned-$capp" 1>> "$log"
198 | 7za a -tzip "${maindir}/${mod_dir}/unsigned-${capp}" "${maindir}/${prj_dir}/${capp}/build/classes.dex" -y -mx${uscr} 1>> "$log" 2>&1
199 | rm -rf "${maindir}/${prj_dir}/temp"
200 | else
201 | rm -rf "${maindir}/${prj_dir}/temp"
202 | fi
203 | }
204 |
205 | # Advanced compile skeleton/shell
206 | compile_adv () {
207 | echo "compile_adv function" 1>> "$log"
208 | echo "Compiling Code..."
209 | comp_smali
210 | if [[ $? -ne 0 ]]; then
211 | echo $bred"An error occured while compiling code, please check log."; $rclr;
212 | pressanykey
213 | else
214 | echo "Compiling Resources..."
215 | mkdir -p "${maindir}/${prj_dir}/${capp}/build/apk"
216 | cp -p "${maindir}/${prj_dir}/${capp}/build/classes.dex" "${maindir}/${prj_dir}/${capp}/build/apk/classes.dex"
217 | comp_apkt
218 | if [[ $? -ne 0 ]]; then
219 | echo $bred"An error occured while compiling resources, please check log."; $rclr;
220 | pressanykey
221 | else
222 | co_sys_prompt
223 | if [[ $? -ne 0 ]]; then
224 | echo $bred"An error occured during system-apk \"keep\" process, please check log."; $rclr;
225 | pressanykey
226 | else
227 | echo "Packaging APK..."
228 | comp_adv_final
229 | if [[ $? -ne 0 ]]; then
230 | echo $bred"An error occured during final packaging process, please check log."; $rclr;
231 | pressanykey
232 | fi
233 | fi
234 | fi
235 | fi
236 | echo "compile_adv function complete" 1>> "$log"
237 | }
238 |
239 | # Ccompile jar file skeleton/shell
240 | compile_jar () {
241 | echo "compile_jar function" 1>> "$log"
242 | echo "Compiling jar..."
243 | cp -pf "${maindir}/${mod_dir}/${capp}" "${maindir}/${mod_dir}/unsigned-${capp}" 1>> "$log" 2>&1
244 | comp_smali
245 | if [[ $? -ne 0 ]]; then
246 | echo $bred"An error occured while compiling code, please check log."; $rclr;
247 | pressanykey
248 | else
249 | 7za a -tzip "${maindir}/${mod_dir}/unsigned-${capp}" "${maindir}/${prj_dir}/${capp}/build/classes.dex" -mx${uscr} 1>> "$log" 2>&1
250 | if [[ $? -ne 0 ]]; then
251 | echo $bred"An error occured while zipping classes.dex, please check log."; $rclr;
252 | pressanykey
253 | fi
254 | fi
255 | echo "compile_jar function complete" 1>> "$log"
256 | }
257 |
258 | # Compile function, initial checks
259 | compile () {
260 | echo "compile (main) function" 1>> "$log"
261 | capp_test
262 | if [[ ${capp} = "None" ]]; then
263 | echo "no project selected, aborting" 1>> "$log"
264 | return 1
265 | elif [[ ! -d "${maindir}/${prj_dir}/${capp}" ]]; then
266 | nodir_err
267 | elif [[ -d "${maindir}/${prj_dir}/${capp}/java" ]]; then
268 | if [[ ! -f "${maindir}/${prj_dir}/${capp}/apktool.yml" ]]; then
269 | nodir_err
270 | fi
271 | elif [[ $(ls -1 "${maindir}/${prj_dir}/${capp}" | wc -l) -eq 0 ]]; then
272 | nodir_err
273 | elif [[ -f "${maindir}/${prj_dir}/${capp}/resources.arsc" ]]; then
274 | nodec_err
275 | elif [[ ! -f "${maindir}/${mod_dir}/${capp}" ]]; then
276 | notfound_err
277 | elif [[ -f "${maindir}/${prj_dir}/${capp}/.advanced" ]]; then
278 | compile_adv
279 | elif [[ ${prjext} = [Jj][Aa][Rr] ]]; then
280 | compile_jar
281 | elif [[ ${prjext} = [Aa][Pp][Kk] ]]; then
282 | compile_apk
283 | fi
284 | echo "compile function complete" 1>> "$log"
285 | }
286 |
287 | # All-in-one actually sign and install now
288 | aio_sub_finish () {
289 | if [[ ${signfunc} = signpkey ]]; then
290 | if [[ -z ${keystore} ]]; then
291 | storecheck
292 | fi
293 | if [[ ! ${keystore##*.} = [kK][eE][yY][sS][tT][oO][rR][eE] ]]; then
294 | echo $bred"Error, invalid or no keystore selected."; $rclr;
295 | echo "Error, invalid or no keystore selected." 1>> "$log" 2>&1
296 | pressanykey
297 | return 1
298 | else
299 | storename="${keystore%%.*}"
300 | key="$(awk '{ print $0}' "${HOME}/.apkmanager/.keystores/.${storename}_keyname")"
301 | fi
302 | fi
303 | echo "Signing APK..."
304 | ${signfunc}
305 | if [[ $? -ne 0 ]]; then
306 | echo "error during signing (aio_sub_finish function)" 1>> "$log" 2>&1
307 | return 1
308 | fi
309 | echo "Installing APK..."
310 | install_apk
311 | if [[ $? -ne 0 ]]; then
312 | echo "error during install (aio_sub_finish function)" 1>> "$log" 2>&1
313 | return 1
314 | fi
315 | }
316 |
317 | # All-in-one, .advanced, actually compile now
318 | aio_sub_adv () {
319 | echo "Compiling Code..."
320 | comp_smali
321 | if [[ $? -ne 0 ]]; then
322 | echo "error during compile (smali/code) (aio_sub_adv function)" 1>> "$log" 2>&1
323 | return 1
324 | fi
325 | echo "Compiling Resources..."
326 | mkdir -p "${maindir}/${prj_dir}/${capp}/build/apk"
327 | cp -p "${maindir}/${prj_dir}/${capp}/build/classes.dex" "${maindir}/${prj_dir}/${capp}/build/apk/classes.dex"
328 | comp_apkt
329 | if [[ $? -ne 0 ]]; then
330 | echo "error during compile (resources) (aio_sub_adv function)" 1>> "$log" 2>&1
331 | return 1
332 | fi
333 | echo "Packaging APK..."
334 | comp_adv_final
335 | if [[ $? -ne 0 ]]; then
336 | echo "error during compile (.advanced packaging) (aio_sub_adv function)" 1>> "$log" 2>&1
337 | return 1
338 | else
339 | aio_sub_finish
340 | fi
341 | }
342 |
343 | # All-in-one, actually zip/compress now
344 | aio_sub_zip () {
345 | echo "Zipping up APK..."
346 | zip_nrm_apk
347 | if [[ $? -ne 0 ]]; then
348 | echo "error during zip (aio_sub_zip function)" 1>> "$log" 2>&1
349 | return 1
350 | else
351 | aio_sub_finish
352 | fi
353 | }
354 |
355 | # All-in-one, actually compile apk now
356 | aio_sub_cmp () {
357 | echo "Compiling APK..."
358 | comp_apkt
359 | if [[ $? -ne 0 ]]; then
360 | echo "error during compile (aio_sub_cmp function)" 1>> "$log" 2>&1
361 | return 1
362 | else
363 | aio_sub_finish
364 | fi
365 | }
366 |
367 | # All-in-one, .advanced decompile check
368 | aio_cmp_check () {
369 | if [[ -f "${maindir}/${prj_dir}/${capp}/.advanced" ]]; then
370 | aio_sub_adv
371 | else
372 | aio_sub_cmp
373 | fi
374 | }
375 |
376 | # Cleanup/unset variables used by 'all-in-one' functions
377 | aio_cleanup () {
378 | unset signfunc
379 | unset aio_option
380 | unset storename
381 | unset key
382 | unset infile
383 | unset outfile
384 | }
385 |
386 | # Check which all-in-one sub-functions to run
387 | aio_type_check () {
388 | if [[ ${aio_option} = zipapk ]]; then
389 | if [[ ! -e "${maindir}/${prj_dir}/${capp}/resources.arsc" ]]; then
390 | noex_err
391 | else
392 | aio_sub_zip
393 | fi
394 | elif [[ ${aio_option} = compapk ]]; then
395 | if [[ ! -e "${maindir}/${prj_dir}/${capp}/apktool.yml" ]]; then
396 | nodec_err
397 | else
398 | aio_cmp_check
399 | fi
400 | elif [[ ${aio_option} = advanced ]]; then
401 | if [[ ! -e "${maindir}/${prj_dir}/${capp}/apktool.yml" ]]; then
402 | aio_sub_zip
403 | elif [[ -e "${maindir}/${prj_dir}/${capp}/apktool.yml" ]]; then
404 | aio_cmp_check
405 | else
406 | echo $bred"Something went wrong, please check the log."
407 | fi
408 | fi
409 | }
410 |
411 | # All-in-one function(s) initial start/check
412 | all_in_one () {
413 | echo "all_in_one function" 1>> "$log"
414 | if [[ ! ${prjext} = [Aa][Pp][Kk] ]]; then
415 | jarext_err
416 | elif [[ ! -d "${maindir}/${prj_dir}/${capp}" ]]; then
417 | nodir_err
418 | elif [[ "$(ls -1 "${maindir}/${prj_dir}/${capp}" | wc -l)" -eq 0 ]]; then
419 | nodir_err
420 | elif [[ -d "${maindir}/${prj_dir}/${capp}/java" ]]; then
421 | aio_java_err
422 | else
423 | aio_type_check
424 | fi
425 | aio_cleanup
426 | echo "all_in_one function complete" 1>> "$log" 2>&1
427 | }
428 |
429 | # Zip-sign-install function initial startup
430 | zip_sign_install () {
431 | echo "zip_sign_install (zip, sign, install) function" 1>> "$log"
432 | capp_test
433 | if [[ ${capp} = "None" ]]; then
434 | echo "no project selected, aborting" 1>> "$log"
435 | return 1
436 | else
437 | infile="${maindir}/${mod_dir}/unsigned-${capp}"
438 | outfile="${maindir}/${mod_dir}/signed-${capp}"
439 | signfunc="signtkey"
440 | aio_option="zipapk"
441 | all_in_one
442 | fi
443 | echo "zip_sign_install function complete" 1>> "$log" 2>&1
444 | }
445 |
446 | # Compile-sign-install function initial startup
447 | co_sign_install () {
448 | echo "co_sign_install (compile, sign, install) function" 1>> "$log"
449 | capp_test
450 | if [[ ${capp} = "None" ]]; then
451 | echo "no project selected, aborting" 1>> "$log"
452 | return 1
453 | else
454 | infile="${maindir}/${mod_dir}/unsigned-${capp}"
455 | outfile="${maindir}/${mod_dir}/signed-${capp}"
456 | signfunc="signtkey"
457 | aio_option="compapk"
458 | all_in_one
459 | fi
460 | echo "co_sign_install function complete" 1>> "$log" 2>&1
461 | }
462 |
463 | # Advanced all-in-one function initial startup
464 | adv_all_in_one () {
465 | echo "adv_all_in_one (advanced all-in-one) function" 1>> "$log"
466 | capp_test
467 | if [[ ${capp} = "None" ]]; then
468 | echo "no project selected, aborting" 1>> "$log"
469 | return 1
470 | else
471 | infile="${maindir}/${mod_dir}/unsigned-${capp}"
472 | signfunc="signpkey"
473 | aio_option="advanced"
474 | all_in_one
475 | fi
476 | echo "adv_all_in_one function complete" 1>> "$log" 2>&1
477 | }
478 |
--------------------------------------------------------------------------------
/other/lib/decext_funcs.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v3.0+
4 | # Decompile & Extract functions
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.0.3
10 | # Mon. Jul 08, 2013
11 | # -----------------------------------------------------------------------
12 |
13 | # Remove existing files before extract/decompile
14 | decext_rmfiles () {
15 | echo "decext_rmfiles (remove previous build files if they exist)" 1>> "$log"
16 | if [[ -e "${maindir}/${mod_dir}/signed-${capp}" ]]; then
17 | rm "${maindir}/${mod_dir}/signed-${capp}"
18 | fi
19 | if [[ -e "${maindir}/${mod_dir}/unsigned-${capp}" ]]; then
20 | rm "$maindir/$mod_dir/unsigned-$capp"
21 | fi
22 | if [[ -e "${maindir}/${prj_dir}/${capp}" ]]; then
23 | rm "$maindir/$prj_dir/$capp"
24 | fi
25 | }
26 |
27 | # Actually extract an apk file
28 | do_extract () {
29 | echo "do_extract (actually extracting apk now) function" 1>> "$log"
30 | decext_rmfiles
31 | if [[ ! -d "${maindir}/${prj_dir}/${capp}" ]]; then
32 | mkdir -p "${maindir}/${prj_dir}/${capp}"
33 | fi
34 | 7za x -o"${maindir}/${prj_dir}/${capp}" "${maindir}/${mod_dir}/${capp}" 1>> "$log" 2>&1
35 | if [[ $? -ne 0 ]]; then
36 | echo $bred"Error extracting ${capp}, please check log"; $rclr;
37 | pressanykey
38 | fi
39 | }
40 |
41 | # Extract an apk file, initial checks
42 | extract_apk () {
43 | echo "extract_apk function" 1>> "$log"
44 | capp_test
45 | if [[ ${capp} = "None" ]]; then
46 | echo "no project selected, aborting" 1>> "$log"
47 | return 1
48 | elif [[ ! ${prjext} = [Aa][Pp][Kk] ]]; then
49 | jarext_err
50 | elif [[ ! -f "${maindir}/${mod_dir}/${capp}" ]]; then
51 | notfound_err
52 | elif [[ ! -d "${maindir}/${prj_dir}/${capp}" ]]; then
53 | do_extract
54 | elif [[ $(ls -1 "${maindir}/${prj_dir}/${capp}" | wc -l) -eq 0 ]]; then
55 | do_extract
56 | elif [[ $(ls -1 "${maindir}/${prj_dir}/${capp}" | wc -l) -ne 0 ]]; then
57 | overwrite_prompt
58 | read input
59 | case "$input" in
60 | [yY]) clean_capp; do_extract ;;
61 | [nN]) ;;
62 | *) input_err; extract_apk ;;
63 | esac
64 | unset input
65 | else
66 | do_extract
67 | fi
68 | echo "extract_apk function complete" 1>> "$log"
69 | }
70 |
71 | # Actually decompile a jar file
72 | decomp_jar () {
73 | echo "decomp_jar, actually decompiling now" 1>> "$log"
74 | decext_rmfiles
75 | echo "Decompiling Jar"
76 | runj baksmali -JXmx"${heapy}""m" "${maindir}/${mod_dir}/${capp}" -o "${maindir}/${prj_dir}/${capp}" 1>> "$log" 2>&1
77 | if [[ $? -ne 0 ]]; then
78 | echo $bred"An error occured while decompiling, please check log."; $rclr;
79 | pressanykey
80 | fi
81 | echo "decomp_jar function complete" 1>> "$log"
82 | }
83 |
84 | # Actually decompile an apk file
85 | decomp_apk () {
86 | echo "decomp_apk, actually decompiling now" 1>> "$log"
87 | decext_rmfiles
88 | echo "Decompiling Apk"
89 | runj apktool -JXmx"${heapy}""m" d "${maindir}/${mod_dir}/${capp}" "${maindir}/${prj_dir}/${capp}" 1>> "$log" 2>&1
90 | if [[ $? -ne 0 ]]; then
91 | echo $bred"An error occured while decompiling, please check log."; $rclr;
92 | pressanykey
93 | fi
94 | echo "decomp_apk function complete" 1>> "$log"
95 | }
96 |
97 | # Determine apk or jar filetype for decompile
98 | decomp_ext_test () {
99 | echo "decomp_ext_test (\"apk\" or \"jar\" file test) function" 1>> "$log"
100 | if [[ ${prjext} = [Jj][Aa][Rr] ]]; then
101 | echo "project is a jar file, launching decomp_jar subroutine" 1>> "$log"
102 | decomp_jar
103 | elif [[ ${prjext} = [Aa][Pp][Kk] ]]; then
104 | echo "project is an apk file, launching decomp_apk subroutine" 1>> "$log"
105 | decomp_apk
106 | fi
107 | }
108 |
109 | # Decompile apk or jar file, initial checks
110 | decompile () {
111 | echo "decompile function" 1>> "$log"
112 | capp_test
113 | if [[ ${capp} = "None" ]]; then
114 | echo "no project selected, aborting" 1>> "$log"
115 | return 1
116 | elif [[ ! -f "${maindir}/${mod_dir}/${capp}" ]]; then
117 | notfound_err
118 | elif [[ ! -d "${maindir}/${prj_dir}/${capp}" ]]; then
119 | decomp_ext_test
120 | elif [[ $(ls -1 "${maindir}/${prj_dir}/${capp}" | wc -l) -eq 0 ]]; then
121 | decomp_ext_test
122 | elif [[ $(ls -1 "${maindir}/${prj_dir}/${capp}" | wc -l) -ne 0 ]]; then
123 | overwrite_prompt
124 | read input
125 | case "$input" in
126 | [yY]) clean_capp; decomp_ext_test ;;
127 | [nN]) ;;
128 | *) input_err; decompile ;;
129 | esac
130 | fi
131 | echo "decompile function complete" 1>> "$log"
132 | }
133 |
134 | # Advanced decompile apk, actual decompile function
135 | decomp_adv () {
136 | echo "decomp_adv, actually decompiling now" 1>> "$log"
137 | decext_rmfiles
138 | echo "decomp_adv, decompiling resources..." 1>> "$log"
139 | echo "Decompiling Resources..."
140 | runj apktool -JXmx"${heapy}""m" d -s "${maindir}/${mod_dir}/${capp}" "${maindir}/${prj_dir}/${capp}" 1>> "$log" 2>&1
141 | if [[ $? -ne 0 ]]; then
142 | echo $bred"An error occured while decompiling resources, please check log."; $rclr;
143 | pressanykey
144 | else
145 | rm -rf "${maindir}/${prj_dir}/${capp}/classes.dex"
146 | echo "decomp_adv, decompiling code..." 1>> "$log"
147 | echo "Decompiling Code..."
148 | runj baksmali -JXmx"${heapy}""m" "${maindir}/${mod_dir}/${capp}" -o "${maindir}/${prj_dir}/${capp}/smali" 1>> "$log" 2>&1
149 | if [[ $? -ne 0 ]]; then
150 | echo $bred"An error occured while decompiling code, please check log."; $rclr;
151 | pressanykey
152 | else
153 | echo "advanced" 1> "${maindir}/${prj_dir}/${capp}/.advanced"
154 | fi
155 | fi
156 | echo "decomp_adv function complete" 1>> "$log"
157 | }
158 |
159 | # Advanced decompile apk, initial checks
160 | decompile_adv () {
161 | echo "decompile_adv (advanced decompile apk) function" 1>> "$log"
162 | capp_test
163 | if [[ ${capp} = "None" ]]; then
164 | echo "no project selected, aborting" 1>> "$log"
165 | return 1
166 | elif [[ ! ${prjext} = [Aa][Pp][Kk] ]]; then
167 | jarext_err
168 | elif [[ ! -f "${maindir}/${mod_dir}/${capp}" ]]; then
169 | notfound_err
170 | elif [[ ! -d "${maindir}/${prj_dir}/${capp}" ]]; then
171 | decomp_adv
172 | elif [[ $(ls -1 "${maindir}/${prj_dir}/${capp}" | wc -l) -eq 0 ]]; then
173 | decomp_adv
174 | elif [[ $(ls -1 "${maindir}/${prj_dir}/${capp}" | wc -l) -ne 0 ]]; then
175 | overwrite_prompt
176 | read input
177 | case "$input" in
178 | [yY]) clean_capp; decomp_adv ;;
179 | [nN]) ;;
180 | *) input_err; decompile_adv ;;
181 | esac
182 | fi
183 | echo "decompile_adv function complete" 1>> "$log"
184 | }
185 |
186 | # View java source, extract original classes.dex
187 | extract_classes_dex () {
188 | echo "extract_classes_dex (extract classes.dex file) function" 1>> "$log"
189 | 7za x -o"${maindir}/${prj_dir}/${capp}/java" "${maindir}/${mod_dir}/${capp}" classes.dex -y 1>> "$log" 2>&1
190 | }
191 |
192 | # View java source, deobfuscate source
193 | decj_jar_deobf () {
194 | echo "d2j_jar_deobf (attempt to deobfuscate jar) function" 1>> "$log"
195 | d2j-init-deobf -f -o "${maindir}/${prj_dir}/${capp}/java/init.txt" "${maindir}/${prj_dir}/${capp}/java/classes-dex2jar.jar"
196 | d2j-jar-remap -f -c "${maindir}/${prj_dir}/${capp}/java/init.txt" -o "${maindir}/${prj_dir}/${capp}/java/classes-deobf.jar" "${maindir}/${prj_dir}/${capp}/java/classes-dex2jar.jar"
197 | rm -r "${maindir}/${prj_dir}/${capp}/java/init.txt"
198 | rm -r "${maindir}/${prj_dir}/${capp}/java/classes-dex2jar.jar"
199 | }
200 |
201 | # View java source - process classes.dex
202 | decj_process_dex () {
203 | echo "decj_process_dex (convert classes.dex to jar file) function" 1>> "$log"
204 | d2j-dex2jar -f "${maindir}/${prj_dir}/${capp}/java/classes.dex" -o "${maindir}/${prj_dir}/${capp}/java/classes-dex2jar.jar"
205 | }
206 |
207 | # View java source, check for/create /java folder
208 | decj_dir_check () {
209 | echo "decj_dir_check (check for project/java dir) function" 1>> "$log"
210 | if [[ ! -d "${maindir}/${prj_dir}/${capp}/java" ]]; then
211 | mkdir -p "${maindir}/${prj_dir}/${capp}/java"
212 | fi
213 | }
214 |
215 | # View java source subroutine
216 | decj_norm_sub () {
217 | echo "decj_norm_sub (decompile java subroutine) function" 1>> "$log"
218 | decj_dir_check
219 | extract_classes_dex
220 | if [[ ! -f "${maindir}/${prj_dir}/${capp}/java/classes.dex" ]]; then
221 | decj_extdex_err
222 | return 1
223 | fi
224 | decj_process_dex
225 | if [[ $? -ne 0 ]]; then
226 | decj_process_dex_err
227 | return 1
228 | fi
229 | echo "decj_norm_sub function complete" 1>> "$log"
230 | }
231 |
232 | # View java source, extrat jar and open with JD-GUI
233 | decj_finish () {
234 | echo "decj_finish (extract decompiled jar) function" 1>> "$log"
235 | if [[ -f "${maindir}/${prj_dir}/${capp}/java/classes-dex2jar.jar" ]]; then
236 | local jarfile="${maindir}/${prj_dir}/${capp}/java/classes-dex2jar.jar"
237 | elif [[ -f "${maindir}/${prj_dir}/${capp}/java/classes-deobf.jar" ]]; then
238 | local jarfile="${maindir}/${prj_dir}/${capp}/java/classes-deobf.jar"
239 | fi
240 | cd "${maindir}/${prj_dir}/${capp}/java"
241 | jar xvf "${jarfile}"
242 | if [[ $? -ne 0 ]]; then
243 | decj_extract_jar_err
244 | return 1
245 | fi
246 | local class_var="$(find . -name '*.class' | grep -m 1 '.class')"
247 | cd "${maindir}/${prj_dir}/${capp}/java"
248 | open -a "${maindir}/other/bin/JD-GUI.app" "${class_var}"
249 | rm -r "${maindir}/${prj_dir}/${capp}/java/classes.dex"
250 | rm -r "${jarfile}"
251 | cd "${maindir}"
252 | echo "decj_finish function complete" 1>> "$log"
253 | }
254 |
255 | # View java source, normal shell function
256 | decj_normal () {
257 | echo "decj_normal (decompile java normal) function" 1>> "$log"
258 | decj_norm_sub
259 | if [[ $? -ne 0 ]]; then
260 | return $?
261 | fi
262 | decj_finish
263 | echo "decj_normal function complete" 1>> "$log"
264 | }
265 |
266 | # View java source, deobfuscate shell function
267 | decj_deobf () {
268 | echo "decj_deobf (decompile java and deobfuscate) function" 1>> "$log"
269 | decj_norm_sub
270 | if [[ $? -ne 0 ]]; then
271 | return $?
272 | fi
273 | decj_jar_deobf
274 | decj_finish
275 | echo "decj_deobf function complete" 1>> "$log"
276 | }
277 |
278 | # Prompt for attempt to deobfuscate java source
279 | decj_deobf_prompt () {
280 | echo "decj_deobf_prompt (decompile java & deobfuscate prompt)" 1>> "$log"
281 | clear
282 | menu_header
283 | echo $bgreen"$apkmspr";
284 | echo ""
285 | echo $white" Some APK files have had "$bgreen"\"Proguard\""$white", an obfuscation"
286 | echo $white" tool, run when compiled to make their code significantly"
287 | echo $white" harder to read when decompiled. The tool APK Manager"
288 | echo $white" uses, dex2jar, has basic support to try and deobfuscate"
289 | echo $white" the decompiled code, but please note that it"
290 | echo $white" does not work on every apk."
291 | echo ""
292 | echo $bgreen"$apkmftr";
293 | printf "$white%s""Attempt to deobfuscate java code? ("$bgreen"y"$white"/"$bgreen"n"$white") "; $rclr;
294 | read input
295 | case "$input" in
296 | [yY]) decj_deobf ;;
297 | [nN]) decj_normal ;;
298 | *) input_err; decj_deobf_prompt ;;
299 | esac
300 | unset input
301 | echo "decj_deobf_prompt complete" 1>> "$log"
302 | }
303 |
304 | # View Java source code initial checks
305 | decompile_java () {
306 | echo "decompile_java (view java source code) function" 1>> "$log"
307 | capp_test
308 | if [[ ${capp} = "None" ]]; then
309 | echo "no project selected, aborting" 1>> "$log"
310 | return 1
311 | elif [[ ! -f "${maindir}/${mod_dir}/${capp}" ]]; then
312 | notfound_err
313 | elif [[ ! -d "${maindir}/${prj_dir}/${capp}/java" ]]; then
314 | decj_deobf_prompt
315 | elif [[ $(ls -1 "${maindir}/${prj_dir}/${capp}/java" | wc -l) -eq 0 ]]; then
316 | decj_deobf_prompt
317 | elif [[ $(ls -1 "${maindir}/${prj_dir}/${capp}/java" | wc -l) -ne 0 ]]; then
318 | overwrite_prompt
319 | read input
320 | case "$input" in
321 | [yY]) clean_capp; decj_deobf_prompt ;;
322 | [nN]) ;;
323 | *) input_err; decompile_java ;;
324 | esac
325 | unset input
326 | fi
327 | clear
328 | echo "decompile_java function complete" 1>> "$log"
329 | }
330 |
331 | # Check proper installation of dex2jar
332 | install_d2j_check () {
333 | if [[ $(command -v dex2jar) ]]; then
334 | echo $bgreen"dex2jar installed succesfully!"
335 | echo ""
336 | echo $bgreen"$apkmftr";
337 | getdex2jarver
338 | local key="dex2jar"
339 | write_preference
340 | genericpanykey
341 | unset key
342 | unset value
343 | decompile_java
344 | else
345 | echo $bred"Something went wrong installing dex2jar"
346 | echo $bred"Please check the log and try again."; $rclr;
347 | pressanykey
348 | fi
349 | }
350 |
351 | # actually installing dex2jar now
352 | install_d2j_sub () {
353 | echo $green"Extracting ${d2j_file}..."
354 | echo ""
355 | cd "${maindir}/other"
356 | echo "==> extracting dex2jar archive" 1>> "$log"
357 | tar -xzvf "${maindir}/other/${d2j_file}" 1>> "$log" 2>&1
358 | echo $green"Removing temporary files."
359 | echo $green"renaming folder to \$maindir/other/dex2jar"
360 | echo "==> renaming folder to \$maindir/other/dex2jar" 1>> "$log"
361 | mv -f "${maindir}/other/${d2j_folder}" "${maindir}/other/dex2jar"
362 | cd "${maindir}/other/dex2jar/"
363 | echo $green"deleting windows .bat files..."
364 | echo "==> deleting windows .bat files..." 1>> "$log"
365 | local f
366 | ls -1 *.bat | while read f ; do
367 | rm -r "${f}"
368 | done
369 | echo $green"making dex2jar directory executable..."
370 | echo "==> removing \".sh\" file extensions..." 1>> "$log"
371 | ls -1 *.sh | while read f ; do
372 | mv "${f}" "${f%\.*}"
373 | done
374 | echo "==> making dex2jar directory executable..." 1>> "$log"
375 | chmod -R ug+x "${maindir}/other/dex2jar/"
376 | echo $green"removing ${d2j_file}"
377 | echo "==> removing ${d2j_file}" 1>> "$log"
378 | rm -r "${maindir}/other/${d2j_file}"
379 | }
380 |
381 | # Download and install dex2jar
382 | install_d2j () {
383 | local d2j_file="dex2jar-0.0.9.15.zip"
384 | local d2j_folder="${d2j_file%%.z*}"
385 | echo "install_d2j (actually installing dex2jar now)" 1>> "$log"
386 | if [[ ! -f "${maindir}/other/${d2j_file}" ]]; then
387 | echo $green" Local copy of archive not found, downloading now..."; $rclr;
388 | echo ""
389 | curl "http://dex2jar.googlecode.com/files/${d2j_file}" > "${maindir}/other/${d2j_file}"
390 | echo ""
391 | fi
392 | local filehash="$(md5 -q "${maindir}/other/${d2j_file}")"
393 | local expected="70f62db86e70318538a5b90df05b954b"
394 | if [[ ${filehash} = ${expected} ]]; then
395 | install_d2j_sub
396 | install_d2j_check
397 | else
398 | echo $bred"ERROR: Corrupt download/file, md5 hash fail:"
399 | echo $bred"download: ${filehash}"
400 | echo $bred"expected: ${expected}"
401 | echo ""
402 | echo $white"press any key to try download again..."
403 | wait
404 | rm -r "${maindir}/other/${d2j_file}"
405 | install_d2j
406 | fi
407 | echo "install_d2j function complete" 1>> "$log"
408 | }
409 |
410 | # Prompt user to install dex2jar
411 | d2j_install_prompt () {
412 | echo "d2j_install_prompt (install dex2jar prompt)" 1>> "$log"
413 | clear
414 | menu_header
415 | echo $bgreen"$apkmspr";
416 | echo ""
417 | echo $white" APK Manager has the ability to decompile most applications to their java source code,"
418 | echo $white" using a combination of the excellent \"dex2jar\" and \"JD-GUI\" tools."
419 | echo ""
420 | echo $white" dex2jar homepage: "$green"http://code.google.com/p/dex2jar/"
421 | echo $white" JD-GUI homepage: "$green"http://java.decompiler.free.fr/?q=jdgui"
422 | echo ""
423 | echo $white" In attempt to cut down on filesize, and redundancy, dex2jar is not included by default"
424 | echo $white" with APK Manager v3.0+. Instead, APK Manager can download it automatically."
425 | echo ""
426 | echo $bgreen"$apkmftr";
427 | printf "$white%s""Download and install dex2jar? ("$bgreen"y"$white"/"$bgreen"n"$white") "; $rclr;
428 | read input
429 | case "$input" in
430 | [yY]) install_d2j ;;
431 | [nN]) ;;
432 | *) input_err; d2j_install_prompt ;;
433 | esac
434 | unset input
435 | echo "d2j_install_prompt complete" 1>> "$log"
436 | }
437 |
438 | # Check for ./other/dex2jar
439 | d2j_check () {
440 | echo "d2j_check (check for dex2jar) function" 1>> "$log"
441 | if [[ -d "${d2jdir}" ]] && [[ $(command -v dex2jar) ]]; then
442 | decompile_java
443 | else
444 | d2j_install_prompt
445 | fi
446 | echo "d2j_check function complete" 1>> "$log"
447 | }
448 |
449 | # Actually decompile with dependancy
450 | dec_ded_sub () {
451 | echo "dec_ded_sub, install dependancy subroutine" 1>> "$log"
452 | rm -f "${HOME}/apktool/framework/2.apk"
453 | local dependee
454 | read dependee
455 | if [[ -z ${dependee} ]]; then :
456 | else
457 | runj apktool if "${dependee}" 1>> "$log" 2>&1
458 | if [[ ! -f "${HOME}/apktool/framework/2.apk" ]]; then
459 | clear
460 | echo $bred"Sorry $(basename "${dependee}") is not the dependee apk, please try again"; $rclr;
461 | dec_ded_prompt
462 | else
463 | echo "Decompiling Apk"
464 | runj apktool -JXmx"${heapy}""m" d "${maindir}/${mod_dir}/${capp}" "${maindir}/${prj_dir}/${capp}" 1>> "$log" 2>&1
465 | if [[ $? -ne 0 ]]; then
466 | echo $bred"An error occured while decompiling, please check log."; $rclr;
467 | pressanykey
468 | fi
469 | fi
470 | fi
471 | }
472 |
473 | # Prompt for dependancy file/location
474 | dec_ded_prompt () {
475 | decext_rmfiles
476 | echo $white"Drag the dependee apk in this window or type its path";
477 | echo $white"Example to decompile Rosie.apk, drag "$bgreen"com.htc.resources.apk"$white" in this window";
478 | echo $green"(leave blank and press enter to return to main menu)"; $rclr;
479 | dec_ded_sub
480 | }
481 |
482 | # Decompile apk with dependancy
483 | decomp_ded () {
484 | echo "decomp_ded (decompile apk with dependancy) function" 1>> "$log"
485 | capp_test
486 | if [[ ${capp} = "None" ]]; then
487 | echo "no project selected, aborting" 1>> "$log"
488 | return 1
489 | elif [[ ! ${prjext} = [Aa][Pp][Kk] ]]; then
490 | jarext_err
491 | elif [[ ! -f "${maindir}/${mod_dir}/${capp}" ]]; then
492 | notfound_err
493 | elif [[ ! -d "${maindir}/${prj_dir}/${capp}" ]]; then
494 | dec_ded_prompt
495 | elif [[ $(ls -1 "${maindir}/${prj_dir}/${capp}" | wc -l) -eq 0 ]]; then
496 | dec_ded_prompt
497 | elif [[ $(ls -1 "${maindir}/${prj_dir}/${capp}" | wc -l) -ne 0 ]]; then
498 | overwrite_prompt
499 | read input
500 | case "$input" in
501 | [yY]) clean_capp; dec_ded_prompt ;;
502 | [nN]) ;;
503 | *) input_err; decomp_ded ;;
504 | esac
505 | fi
506 | echo "decomp_ded function complete" 1>> "$log"
507 | }
508 |
--------------------------------------------------------------------------------
/other/lib/menus.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # -----------------------------------------------------------------------
3 | # Apk Manager OS X v3.0+
4 | # Application menus
5 | #
6 | # by Jocelyn Mallon CC by-nc-sa 2012
7 | # http://girlintroverted.wordpress.com
8 | #
9 | # version: 3.2b
10 | # Mon. Jan 27, 2014
11 | # -----------------------------------------------------------------------
12 |
13 | # Advanced signing menu
14 | sign_menu () {
15 | if [[ -z $keystore ]]; then
16 | storecheck
17 | fi
18 | cd "${maindir}"
19 | clear
20 | menu_header
21 | echo $bgreen"--------------------------------------"$bwhite"Advanced Signing Options"$bgreen"--------------------------------------"
22 | echo $white" Current Keystore: "$bgreen"${keystore}"; $rclr;
23 | echo $green" (if \"None\" displayed, please use create new private key option first)"
24 | echo $bgreen"$apkmspr"
25 | echo $bgreen" 1 "$white"Create a new private key "$blue"(Will be stored in \$HOME/.apkmanager/.keystores)";
26 | echo $bgreen" 2 "$white"Select an existing keystore to use";
27 | echo $bgreen" 3 "$white"Sign an apk/jar file with private key";
28 | echo $bgreen" 4 "$white"Verify signed apk/jar";
29 | echo $bgreen" 5 "$white"Batch sign with private key "$blue"(Inside ${sig_dir} folder)";
30 | echo $bgreen" 6 "$white"Batch Verify signed apk/jar files "$blue"(Inside ${sig_dir} folder)";
31 | echo $bgreen" 7 "$white"Save default keystore selection "$blue"(If you have multiple keystores)";
32 | echo $bgreen" 8 "$white"Delete selected keystore and private key "$bred"(PLEASE USE WITH CAUTION)";
33 | echo $bgreen" Q "$white"Return to main menu";
34 | echo $bgreen"$apkmftr";
35 | printf "$bwhite%s""Please select an option from above: "; $rclr;
36 | read input
37 | case "$input" in
38 | 1) createpkey; sign_menu ;;
39 | 2) listpkeys; sign_menu ;;
40 | 3) sign_apk_pk; sign_menu ;;
41 | 4) single_vrfy; sign_menu ;;
42 | 5) batch_sign_pk; sign_menu ;;
43 | 6) batch_vrfy; sign_menu ;;
44 | 7) savekey; sign_menu ;;
45 | 8) delkey; sign_menu ;;
46 | 96) toggle_trace; sign_menu ;;
47 | 97) toggle_verbose; sign_menu ;;
48 | 98) toggle_error; sign_menu ;;
49 | 99) basic_debug; sign_menu ;;
50 | [sS][sS]) ret_menu="sign_menu"; adb_screenshot; unset ret_menu ;;
51 | [qQ]) signcleanup ;;
52 | [qQ][qQ]) quit ;;
53 | *) input_err; sign_menu ;;
54 | esac
55 | }
56 |
57 | # Clean files/folders menu
58 | clean_menu () {
59 | cd "${maindir}"
60 | clear
61 | menu_header
62 | echo $bgreen"---------------------------------------"$bwhite"Clean Files or Folders"$bgreen"---------------------------------------";
63 | echo $bgreen" 1 "$white"Clean This Project's Folder";
64 | echo $bgreen" 2 "$white"Clean All Files in Modding Folder";
65 | echo $bgreen" 3 "$white"Clean All Files in OGG Folder";
66 | echo $bgreen" 4 "$white"Clean All Files in Batch Optimize Folder";
67 | echo $bgreen" 5 "$white"Clean All Files in Signing Folder";
68 | echo $bgreen" 6 "$white"Clean All Projects";
69 | echo $bgreen" 7 "$white"Clean APKtool framework files";
70 | echo $bgreen" 8 "$white"Clean All Files/Folders "$blue"(Executes options 1-7)";
71 | echo $bgreen" 9 "$white"Clean LOG.txt and adblog.txt Files";
72 | echo $bgreen"--------------------------------------"$bwhite"Reset Persistent Options"$bgreen"--------------------------------------";
73 | echo $bgreen" 10 "$white"Reset log viewer app";
74 | echo $bgreen" 11 "$white"Reset \"persistent\" Java heap memory size"$blue" (If enabled)";
75 | echo $bgreen" 12 "$white"Reset \"persistent\" Zip compression level"$blue" (If enabled)";
76 | echo $bgreen" 13 "$white"Reset \"persistent\" keystore selection"$blue" (If enabled)";
77 | echo $bgreen" 14 "$white"Reset \"persistent\" png optimization tool selection";
78 | echo $bgreen" 15 "$white"Reset \"persistent\" ADB device selection"$blue" (If enabled)";
79 | echo $bgreen" 16 "$white"Reset apktool to newest version"$blue" (Can be set manually in the debug menu)";
80 | echo $bgreen" 17 "$white"Reset \"debug\" information"$blue" (Next launch of debug menu will be slow)";
81 | echo $bgreen" 18 "$white"Reset/Change terminal color scheme selection";
82 | echo $bgreen" Q "$white"Return to Main Menu";
83 | echo $bgreen"$apkmftr";
84 | printf "$bwhite%s""Please select an option from above: "; $rclr;
85 | read input
86 | case "$input" in
87 | 1) clean_capp ;;
88 | 2) clean_modding ;;
89 | 3) clean_ogg ;;
90 | 4) clean_batch ;;
91 | 5) clean_signing ;;
92 | 6) clean_projects ;;
93 | 7) clean_apktool ;;
94 | 8) clean_all ;;
95 | 9) clean_logs ;;
96 | 10) clean_viewer ;;
97 | 11) clean_heapsize ;;
98 | 12) clean_complvl ;;
99 | 13) clean_keystore ;;
100 | 14) clean_pngtool ;;
101 | 15) clean_adb_device ;;
102 | 16) clean_apktjar ;;
103 | 17) clean_debug ;;
104 | 18) clean_color ;;
105 | 96) toggle_trace ;;
106 | 97) toggle_verbose ;;
107 | 98) toggle_error ;;
108 | 99) basic_debug ;;
109 | [sS][sS]) ret_menu="clean_menu"; adb_screenshot; unset ret_menu ;;
110 | [qQ]) cmcleanup ;;
111 | [qQ][qQ]) quit ;;
112 | *) input_err; clean_menu ;;
113 | esac
114 | }
115 |
116 | # Text app/editor menu
117 | textapp_menu () {
118 | cd "${maindir}"
119 | clear
120 | menu_header
121 | debug_header
122 | echo $bgreen"------------------------------------"$bwhite"Set editor for log/txt files"$bgreen"------------------------------------";
123 | echo $bgreen" 1 "$white"Apple TextEdit"$blue" (Default)";
124 | echo $bgreen" 2 "$white"TextMate";
125 | echo $bgreen" 3 "$white"SubEthaEdit";
126 | echo $bgreen" 4 "$white"TextWrangler";
127 | echo $bgreen" 5 "$white"BBEDIT";
128 | echo $bgreen" 6 "$white"Coda";
129 | echo $bgreen" 7 "$white"MacVIM";
130 | echo $bgreen" 8 "$white"Aquamacs";
131 | echo $bgreen" 9 "$white"Smultron";
132 | echo $bgreen" 10 "$white"Vico";
133 | echo $bgreen" 11 "$white"Sublime Text 2 (or 3)";
134 | echo $bgreen" 12 "$white"Chocolat";
135 | echo $bgreen" 13 "$white"Nano "$blue"(In new terminal tab)";
136 | echo $bgreen" 14 "$white"Emacs "$blue"(In new terminal tab)";
137 | echo $bgreen" 15 "$white"vi/vim "$blue"(In new terminal tab)";
138 | echo $bgreen" Q "$white"Return to Debug Menu";
139 | echo $bgreen"$apkmftr";
140 | printf "$bwhite%s""Please select an option from above: "; $rclr;
141 | read input
142 | case "$input" in
143 | 1) logviewer="open"; logvchk ;;
144 | 2) logviewer="mate"; logvchk ;;
145 | 3) logviewer="see"; logvchk ;;
146 | 4) logviewer="edit"; logvchk ;;
147 | 5) logviewer="bbedit"; logvchk ;;
148 | 6) logviewer="coda"; logvchk ;;
149 | 7) logviewer="mvim"; logvchk ;;
150 | 8) logviewer="aquamacs"; logvchk ;;
151 | 9) logviewer="smultron"; logvchk ;;
152 | 10) logviewer="vico"; logvchk ;;
153 | 11) logviewer="subl"; logvchk ;;
154 | 12) logviewer="choc"; logvchk ;;
155 | 13) logviewer="nano"; logvchk ;;
156 | 14) logviewer="emacs"; logvchk ;;
157 | 15) logviewer="vi"; logvchk ;;
158 | 96) toggle_trace ;;
159 | 97) toggle_verbose ;;
160 | 98) toggle_error ;;
161 | 99) basic_debug ;;
162 | [sS][sS]) ret_menu="textapp_menu"; adb_screenshot; unset ret_menu ;;
163 | [qQ]) ;;
164 | [qQ][qQ]) quit ;;
165 | *) input_err; textapp_menu ;;
166 | esac
167 | }
168 |
169 | # Automatic updates menu
170 | updates_menu () {
171 | clear
172 | menu_header
173 | updates_header
174 | echo $bgreen"$apkmspr"
175 | echo $bgreen" 1 "$white"Turn automatic updates "$bgreen"ON";
176 | echo $bgreen" 2 "$white"Turn automatic updates "$bred"OFF";
177 | echo $bgreen" 3 "$white"Turn update prompt "$bgreen"ON"$blue" (default) (must confirm each update)";
178 | echo $bgreen" 4 "$white"Turn update prompt "$bred"OFF"$blue" (no confirmation needed before each update)";
179 | echo $bgreen" 5 "$white"Change update branch/channel "$blue"(master, develop, etc.)";
180 | echo $bgreen" 6 "$white"Change update frequency "$blue"(how many days to wait between updates)";
181 | echo $bgreen" 7 "$white"Check for updates now" $blue"(force an early check for new updates)";
182 | echo $bgreen" 8 "$white"View APK Manager on github "$blue"(https://github.com/jocelynmallon/apkmanager)";
183 | echo $bgreen" Q "$white"Return to Debug Menu";
184 | echo $bgreen"$apkmftr";
185 | printf "$bwhite%s""Please select an option from above: "; $rclr;
186 | read input
187 | case "$input" in
188 | 1) enable_auto_updates; updates_menu ;;
189 | 2) disable_auto_updates; updates_menu ;;
190 | 3) enable_update_prompt; updates_menu ;;
191 | 4) disable_update_prompt; updates_menu ;;
192 | 5) change_update_branch; updates_menu ;;
193 | 6) change_update_freq; updates_menu ;;
194 | 7) force_update_check; updates_menu ;;
195 | 8) open https://github.com/jocelynmallon/apkmanager; updates_menu ;;
196 | 96) toggle_trace; updates_menu ;;
197 | 97) toggle_verbose; updates_menu ;;
198 | 98) toggle_error; updates_menu ;;
199 | 99) basic_debug; updates_menu ;;
200 | [sS][sS]) ret_menu="updates_menu"; adb_screenshot; unset ret_menu ;;
201 | [qQ]) updates_cleanup ;;
202 | [qQ][qQ]) quit ;;
203 | *) input_err; updates_menu ;;
204 | esac
205 | }
206 |
207 | # ADB setup and tools menu
208 | adb_menu () {
209 | clear
210 | menu_header
211 | debug_header
212 | echo $bgreen"--------------------------------------"$bwhite"ADB tools, settings, etc"$bgreen"--------------------------------------";
213 | echo $bgreen" 1 "$white"Select default ADB device "$blue"(temporary, resets on every launch)";
214 | echo $bgreen" 2 "$white"Connect a new device over wireless ADB "$blue"(ensure you know the IP address and port of device)";
215 | echo $bgreen" 3 "$white"Connect to saved device over wireless ADB "$blue"(Only if saved device was using wireless ADB)";
216 | echo $bgreen" 4 "$white"Make default ADB device persistent "$bred"(IF USING WIRELESS ADB, MUST HAVE STATIC IP)";
217 | echo $bgreen" 5 "$white"Quick ADB log file "$blue"(capture ADB logcat for 10 seconds)";
218 | echo $bgreen" 6 "$white"Extended ADB log file "$blue"(capture ADB logcat for a user specified number of seconds)";
219 | echo $bgreen" 7 "$white"Open an ADB shell session "$blue"(select a default ADB device first)";
220 | echo $bgreen" 8 "$white"Manually restart ADB daemon on device as "$bpink"root "$blue"(select a default ADB device first)";
221 | echo $bgreen" 9 "$white"Toggle killing ADB daemon on quit" $blue"(currently: "$(adb_kill_display);
222 | echo $bgreen" 10 "$white"Restart ADB daemon" $blue"(must reconnect wireless ADB sessions afterwards)";
223 | echo $bgreen" 11 "$white"Enable \"hidden\" "$bpink"SS"$white" option to take an ADB screencap from most menus "$blue"(currently: "$(adb_screencap_display);
224 | echo $bgreen" 12 "$white"Toggle checking/connecting to saved ADV device on startup" $blue"(currently: "$(adb_connect_start_display)
225 | echo $bgreen" Q "$white"Return to Debug Menu";
226 | echo $bgreen"$apkmftr";
227 | printf "$bwhite%s""Please select an option from above: "; $rclr;
228 | read input
229 | case "$input" in
230 | 1) adb_devices_menu; adb_menu ;;
231 | 2) adb_wireless_connect; adb_menu ;;
232 | 3) adbsaved=1; adb_wireless_connect; unset adbsaved; adb_menu ;;
233 | 4) adb_save_device_pref; adb_menu ;;
234 | 5) adb_log_device_check; adb_menu ;;
235 | 6) extended_adb_log=1; adb_log_device_check; adb_menu ;;
236 | 7) adb_shell; adb_menu ;;
237 | 8) adbrootforce=1; adb_root_setup; unset adbrootforce; adb_menu ;;
238 | 9) toggle_adb_kill_on_quit; adb_menu ;;
239 | 10) adb kill-server; adb start-server >/dev/null; adb_menu ;;
240 | 11) adb_screencap_toggle; adb_menu ;;
241 | 12) adb_connect_on_start_toggle; adb_menu ;;
242 | 96) toggle_trace; adb_menu ;;
243 | 97) toggle_verbose; adb_menu ;;
244 | 98) toggle_error; adb_menu ;;
245 | 99) basic_debug; adb_menu ;;
246 | [sS][sS]) ret_menu="adb_menu"; adb_screenshot; unset ret_menu ;;
247 | [qQ]) ;;
248 | [qQ][qQ]) quit ;;
249 | *) input_err; adb_menu ;;
250 | esac
251 | }
252 |
253 | # Debug & Settings menu
254 | debug_menu () {
255 | debug_check
256 | if [[ -z $apktool_ver ]]; then
257 | getapktver
258 | fi
259 | cd "${maindir}"
260 | clear
261 | menu_header
262 | debug_header
263 | echo $bgreen"$apkmspr";
264 | echo $bgreen" 1 "$white"Set editor for log/txt files";
265 | echo $bgreen" 2 "$white"View binary info, paths, etc. ";
266 | echo $bgreen" 3 "$white"View README" $blue"(opens wiki on github)";
267 | echo $bgreen" 4 "$white"View CHANGELOG/COMMIT History";
268 | echo $bgreen" 5 "$white"View TIPS" $blue"(opens wiki on github)";
269 | echo $bgreen" 6 "$white"View LOG.txt";
270 | echo $bgreen" 7 "$white"View ADBLOG.txt "$blue"(if file exists)";
271 | echo $bgreen" 8 "$white"Configure automatic updates "$blue"(Requires you have \"git\" installed)";
272 | echo $bgreen" 9 "$white"Toggle command line use "$blue"(create/delete \"apkm\" symlink in /usr/local/bin)";
273 | echo $bgreen"-----------------------------------------"$bwhite"Other misc options"$bgreen"-----------------------------------------";
274 | echo $bgreen" 10 "$white"Enable persistent Java Heap memory size";
275 | echo $bgreen" 11 "$white"Enable persistent Zip Compression Level";
276 | echo $bgreen" 12 "$white"Select tool to use for PNG optimization options "$green"(Persistent)";
277 | echo $bgreen" 13 "$white"Select Android SDK tools version "$bred"(ONLY IF USING ANDROID STUDIO)";
278 | echo $bgreen" 14 "$white"Launch draw9patch "$blue"(Requires you have Android SDK installed)";
279 | echo $bgreen" 15 "$white"Launch Android Device Monitor "$blue"(previously ddms, Requires you have Android SDK installed)";
280 | echo $bgreen" 16 "$white"Launch Android SDK Manager "$blue"(Requires you have Android SDK installed)";
281 | echo $bgreen" 17 "$white"ADB Tools "$blue"(logcat, shell, wireless ADB setup, etc.)";
282 | echo $bgreen" 18 "$white"Choose APKtool version "$blue"(For decompiling/compiling apk files)";
283 | echo $bgreen" Q "$white"Return to Main Menu";
284 | echo $bgreen"$apkmftr";
285 | printf "$bwhite%s""Please select an option from above: "; $rclr;
286 | read input
287 | case "$input" in
288 | 1) textapp_menu ; debug_menu ;;
289 | 2) debug_display; debug_menu ;;
290 | 3) open https://github.com/jocelynmallon/apkmanager/wiki; debug_menu ;;
291 | 4) view_changelog; debug_menu ;;
292 | 5) open https://github.com/jocelynmallon/apkmanager/wiki/General-Tips; debug_menu ;;
293 | 6) txt="$log" 2>> "$log"; read_txt; debug_menu ;;
294 | 7) read_adb_log; debug_menu ;;
295 | 8) updates_git_check; debug_menu ;;
296 | 9) apkm_tool_toggle; debug_menu ;;
297 | 10) local key="heap" && local value="$heapy" && write_preference && heap_size; debug_menu ;;
298 | 11) local key="complvl" && local value="$uscr" && write_preference && comp_level; debug_menu ;;
299 | 12) png_tool_menu; debug_menu ;;
300 | 13) andsdk_tools_check; debug_menu ;;
301 | 14) draw_nine; debug_menu ;;
302 | 15) launch_ddms; debug_menu ;;
303 | 16) launch_sdk_manager; debug_menu ;;
304 | 17) adb_menu; debug_menu ;;
305 | 18) apkt_menu_check; debug_menu ;;
306 | 96) toggle_trace; debug_menu ;;
307 | 97) toggle_verbose; debug_menu ;;
308 | 98) toggle_error; debug_menu ;;
309 | 99) basic_debug; debug_menu ;;
310 | [sS][sS]) ret_menu="debug_menu"; adb_screenshot; unset ret_menu ;;
311 | [qQ]) debug_cleanup ;;
312 | [qQ][qQ]) quit ;;
313 | *) input_err; debug_menu ;;
314 | esac
315 | }
316 |
317 | # Main Menu
318 | restart () {
319 | cd "${maindir}"
320 | menu_header
321 | echo $bgreen"---------------------------------"$bwhite"Simple Tasks Such As Image Editing"$bgreen"---------------------------------";
322 | echo $bgreen" 1 "$white"ADB pull "$blue"(Pulls file into \"${mod_dir}\" folder)";
323 | echo $bgreen" 2 "$white"Extract APK ";
324 | echo $bgreen" 3 "$white"Optimize images inside "$blue"(Only if \"Extract APK\" was selected)";
325 | echo $bgreen" 4 "$white"Compile \".9.png\" and/or binary xml files";
326 | echo $bgreen" 5 "$white"Zip APK ";
327 | echo $bgreen" 6 "$white"Sign APK "$blue"(With test keys) "$bred"(DON'T do this if its a system apk)";
328 | echo $bgreen" 7 "$white"Zipalign APK "$blue"(Do this after apk is zipped / signed)";
329 | echo $bgreen" 8 "$white"Install APK "$bred"(DON'T do this if system apk, do adb push)";
330 | echo $bgreen" 9 "$white"Zip / Sign / Install APK "$blue"(All in one step)" $bred"(apk files only)";
331 | echo $bgreen" 10 "$white"ADB push "$bred"(Only for system apk/jar file)";
332 | echo $bgreen"--------------------------------"$bwhite"Advanced Tasks Such As Code Editing"$bgreen"---------------------------------";
333 | echo $bgreen" 11 "$white"Decompile "$blue"(Supports both apk and jar files)";
334 | echo $bgreen" 12 "$white"Decompile with dependencies"$blue" (For propietary rom APKs)" $bred"(APK files only)";
335 | echo $bgreen" 13 "$white"Advanced Decompile APK "$blue"(Uses baksmali for code, apktool for resources)";
336 | echo $bgreen" 14 "$white"Compile "$blue"(For use with decompile options: 11, 12, 13)";
337 | echo $bgreen" 15 "$white"Compile / Sign / Install "$blue"(All in one step) "$bred"(apk files only)";
338 | echo $bgreen" 16 "$white"Advanced \"All-in-one\" "$blue"(Zip/Compile, sign with private keys, install)";
339 | echo $bgreen" 17 "$white"Uninstall APK "$blue"(Only for non-system apps)";
340 | echo $bgreen" 18 "$white"View Java Source "$blue"(apk and jar support) "$bred"(CANNOT be recompiled)";
341 | echo $bgreen" 19 "$white"Advanced signing options "$blue"(Use your own keystore, verify signatures, etc.)";
342 | echo $bgreen"-------------------------------------------"$bwhite"Other Options"$bgreen"--------------------------------------------";
343 | echo $bgreen" 20 "$white"Batch Optimize files "$blue"(Inside \"${bat_dir}\" folder)";
344 | echo $bgreen" 21 "$white"Batch Sign APK files "$blue"(With test keys, inside \"${sig_dir}\" folder)";
345 | echo $bgreen" 22 "$white"Batch optimize ogg files "$blue"(Inside \"${ogg_dir}\" only)";
346 | echo $bgreen" 23 "$white"Select compression level for zipping files";
347 | echo $bgreen" 24 "$white"Set max Java heap memory size "$blue"(If getting stuck at decompiling/compiling)";
348 | echo $bgreen" 25 "$white"Debug Info and Misc Settings "$blue"(Persistent heap, set log viewing app, etc.)";
349 | echo $bgreen" 26 "$white"Clean Files/Folders, Reset settings, etc. "
350 | echo $bgreen" 27 "$white"Select Current Project";
351 | echo $bgreen" Q "$white"Quit APK Manager";
352 | echo $bgreen"$apkmftr";
353 | printf "$bwhite%s""Please select an option from above: "; $rclr;
354 | read input
355 | case "$input" in
356 | 1) adb_pull ;;
357 | 2) extract_apk ;;
358 | 3) opt_apk_png ;;
359 | 4) compile_9patch ;;
360 | 5) zip_apk ;;
361 | 6) sign_apk_tk ;;
362 | 7) zalign_file ;;
363 | 8) install_apk ;;
364 | 9) zip_sign_install ;;
365 | 10) adb_push ;;
366 | 11) decompile ;;
367 | 12) decomp_ded ;;
368 | 13) decompile_adv ;;
369 | 14) compile ;;
370 | 15) co_sign_install ;;
371 | 16) adv_all_in_one ;;
372 | 17) adb_uninstall_apk ;;
373 | 18) d2j_check ;;
374 | 19) sign_menu ;;
375 | 20) batch_opt; batch_cleanup ;;
376 | 21) batch_sign_tk; batch_cleanup ;;
377 | 22) batch_ogg; batch_cleanup ;;
378 | 23) comp_level ;;
379 | 24) heap_size ;;
380 | 25) debug_menu ;;
381 | 26) clean_menu ;;
382 | 27) projects_menu ;;
383 | 96) toggle_trace ;;
384 | 97) toggle_verbose ;;
385 | 98) toggle_error ;;
386 | 99) basic_debug ;;
387 | [sS][sS]) ret_menu=""; adb_screenshot; unset ret_menu ;;
388 | [qQ]) quit ;;
389 | [qQ][qQ]) quit ;;
390 | *) input_err ;;
391 | esac
392 | }
393 |
--------------------------------------------------------------------------------