@echo off
setlocal enabledelayedexpansion
if (%1)==(0) goto skipme
del log.txt
echo -------------------------------------------------------------------------- >> log.txt
echo :. toolAlite_9o .:         ^|%date% -- %time%^| >> log.txt
echo -------------------------------------------------------------------------- >> log.txt
toolAlite_9o 0 2>> log.txt
:skipme
mode con:cols=81 lines=52
cd "%~dp0"
java -version 
if errorlevel 1 ( 
cls
echo Java was not found, you will not be able to sign apks or use apktool
pause
goto errjava
)
adb version
if errorlevel 1 goto setadbpath
goto titleset
:setadbpath 
cls
echo Adb was not found. using adb from toolAlite instead.
path "%~dp0tools\";%path%
adb version
pause
goto titleset
:titleset
title __:. toolAlite_9o .:__    @ %~dp0   
::defaultsettings.ini check
if not exist "%~dp0tools\defaultsettings.ini" goto nodefaultsettingsini
goto readtheinivalue
:nodefaultsettingsini
set usrc=[1
set capp=[None
set heapy=[128
set apkversion=[5
set warnabaru=[0B
type "%~dp0tools\defaultsettings.ini" >> "%~dp0tools\defaultsettings.ini"
echo capp=%capp%>> "%~dp0tools\defaultsettings.ini"
echo apkversion=%apkversion%>> "%~dp0tools\defaultsettings.ini"
echo usrc=%usrc%>> "%~dp0tools\defaultsettings.ini"
echo heapy=%heapy%>> "%~dp0tools\defaultsettings.ini"
echo warnabaru=%warnabaru%>> "%~dp0tools\defaultsettings.ini"
:readtheinivalue
for /f "usebackq tokens=1* delims==[" %%1 in ("%~dp0tools\defaultsettings.ini") do ( 
if "%%1"=="capp" set capp=%%2
if "%%1"=="apkversion" set apkversion=%%2
if "%%1"=="usrc" set usrc=%%2
if "%%1"=="heapy" set heapy=%%2
if "%%1"=="warnabaru" set warnabaru=%%2
)
:gantiapktool
if %apkversion%==1 (
copy /Y "%~dp0tools\apktool_1.3.1.jar"  "%~dp0tools\apktool.jar"
set nowapktoolver=1.3.1
)
if %apkversion%==2 (
copy /Y "%~dp0tools\apktool_1.3.2.jar"  "%~dp0tools\apktool.jar"
set nowapktoolver=1.3.2
)
if %apkversion%==3 (
copy /Y "%~dp0tools\apktool_1.4.1.jar"  "%~dp0tools\apktool.jar"
set nowapktoolver=1.4.1
)
if %apkversion%==4 (
copy /Y "%~dp0tools\apktool_1.4.2.jar"  "%~dp0tools\apktool.jar"
set nowapktoolver=1.4.2
)
if %apkversion%==5 (
copy /Y "%~dp0tools\apktool_1.4.3.jar"  "%~dp0tools\apktool.jar"
set nowapktoolver=1.4.3
)
:: check and create projects folders
if not exist "%~dp0input_apk" mkdir "%~dp0input_apk"
if not exist "%~dp0output_apk" mkdir "%~dp0output_apk"
if not exist "%~dp0projects" mkdir "%~dp0projects"
if not exist "%userprofile%\apktool" mkdir "%userprofile%\apktool"
if not exist "%~dp0to_batch_install" mkdir "%~dp0to_batch_install"
if not exist "%~dp0to_batch_audio_optimize" mkdir "%~dp0to_batch_audio_optimize"
if not exist "%~dp0to_batch_optimize" mkdir "%~dp0to_batch_optimize"
if not exist "%~dp0to_batch_sign" mkdir "%~dp0to_batch_sign"
if exist "%~dp0keep" rmdir /S /Q "%~dp0keep"
if exist "%~dp0temp" rmdir /S /Q "%~dp0temp"
if exist "%~dp0tools\temp" rmdir /S /Q "%~dp0tools\temp"
if exist "%~dp0tools\optimized" rmdir /S /Q "%~dp0tools\optimized"
:: check current apps
if not exist "%~dp0input_apk\%capp%" set capp=None
goto writedefaultininow
:restart
set menunr==biargangulang
color %warnabaru%
cd "%~dp0"
call :toolhead
echo  ---------------------
echo  CHOOSE YOUR PROJECT  ^>^>  %capp%
echo  -------------------------------------------------------------------------------
echo    0  Set Your Current Project  
echo. 
echo  -------------------------------------
echo  BASIC TASK FOR "YOUR CURRENT PROJECT"
echo  -------------------------------------------------------------------------------
echo    1  If Framework                           7  Optimize PNG files
echo    2  Decompile Apk                          8  Optimize Audio ^(ogg/wav^) 
echo    3  Decompile Apk with Dependencies        9  Sign
echo    4  Compile Apk                           10  Zipalign
echo    5  Extract Apk                           11  Install
echo    6  Zip The Apk
echo.
echo  ----------
echo  COMBO TASK
echo  -------------------------------------------------------------------------------
echo   20  Decompile all Apk in input_apk folder
echo   21  Compile all (Build all projects folder and check for original signature^)
echo   22  Combo1 : Compile - Sign ^+ Install (Current project)
echo   23  Combo2 : Optimize png - Compile - Sign ^+ Install (Current project)
echo   24  Combo3 : Zip - Sign ^+ Install (Current project)
echo   25  Combo4 : Optimize png - Zip - Sign ^+ Install (Current project)
echo.
echo  ------------------------------------      -------------------------------------
echo  SIGN, ZIPALIGN, INSTALL ^& BATCH JOB       ADB COMMAND
echo  ------------------------------------      -------------------------------------
echo   30  Signer ^(Drag any Apk/Zip^)             40  ADB Push Apk to system/app/
echo   31  Zipaligner ^(Drag any Apk^)             41  ADB Push framework-res.apk
echo   32  Installer ^(Drag any Apk^)              42  ADB Push Anything to sdcard/
echo                                             43  ADB Pull
echo   33  Batch Install All Apk                 44  ADB Shell
echo   34  Batch Optimize Apk                    45  ADB Logcat to adblog.txt
echo   35  Batch Sign an Apk                     46  ADB Kill Server
echo   36  Batch Optimize Audio ^(ogg/wav^)        47  ADB Reboot
echo.
echo  -----------------
echo  SETTINGS AND MISC
echo  -------------------------------------------------------------------------------
echo   90  Change Apktool Version    [ %nowapktoolver%]    94  Clean Files/Folders
echo   91  Compression Level         [     %usrc%]    95  About toolAlite
echo   92  Set Max Heap Memory Size  [ %heapy% mb]   96  Read Log
echo   93  Set Text ^& Background's Color         99  EXIT
echo.
echo  ===============================================================================
@echo OFF
echo.
set /P menunr=^>Please make your decision : 
if %menunr%==0 (goto doselectapk)
if %menunr%==1 (goto doifframework)
if %menunr%==2 (goto dodecompile)
if %menunr%==3 (goto decdepapk)
if %menunr%==4 (goto compapk)
if %menunr%==5 (goto extractapk)
if %menunr%==6 (goto zipextracted)
if %menunr%==7 (goto optimage)
if %menunr%==8 (goto optiogg)
if %menunr%==9 (goto dosign)
if %menunr%==10 (goto dozipalign)
if %menunr%==11 (goto adbinst)
if %menunr%==20 (goto decallinput)
if %menunr%==21 (goto compallproj)
if %menunr%==22 (goto combo1)
if %menunr%==23 (goto combo2)
if %menunr%==24 (goto combo3)
if %menunr%==25 (goto combo4)
::if %menunr%==15 (goto combo5)
if %menunr%==30 (goto signerany)
if %menunr%==31 (goto zipalignany)
if %menunr%==32 (goto adbinstany)
if %menunr%==33 (goto batchinstall)
if %menunr%==34 (goto batchoptapk)
if %menunr%==35 (goto batchsign)
if %menunr%==36 (goto batchoptaudio)
if %menunr%==40 (goto adbpushsysapp)
if %menunr%==41 (goto adbpushframe)
if %menunr%==42 (goto adbpushsd)
if %menunr%==43 (goto adbpullcase)
if %menunr%==44 (goto calladbshell)
if %menunr%==45 (goto calladblogcat)
if %menunr%==46 (goto calladbkill)
if %menunr%==47 (goto calladbreboot)
if %menunr%==90 (goto setapktoolversion)
if %menunr%==91 (goto setcompress)
if %menunr%==92 (goto setheap)
if %menunr%==93 (goto textnscreen)
if %menunr%==94 (goto cleanfiles)
if %menunr%==95 (goto about)
if %menunr%==96 (goto readlog)
if %menunr%==99 (goto exit)
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
:: Current Applicastion not Extracted / Decompile yet
:noprofolcapp
call :toolhead
echo. %capp% has not been extracted/decompile,
echo. please do so before doing this step
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
:: No Project -- No current Applicastion
:noproj
call :toolhead
echo. Please Select A Project To Work On (Option #0)
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
:: Input apk is missing
:noinputapk
call :toolhead
echo. Your project apk can't be found on in input_apk folder
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
:: 
:iferrorlevel
call :toolhead
echo. An Error Occured, Please Check The Log (Option # 96)
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
:: report no files in to_batch_ folder
:nofiletoopt
call :toolhead
echo. There is no files to batch %whichbatch%
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
:: write default settings ini after changing the value
:writedefaultininow
rename "%~dp0tools\defaultsettings.ini" defaultsettings.bak
::del "%~dp0tools\defaultsettings.ini"
type "%~dp0tools\defaultsettings.ini"
echo capp=[%capp%>> "%~dp0tools\defaultsettings.ini"
echo apkversion=[%apkversion%>> "%~dp0tools\defaultsettings.ini"
echo usrc=[%usrc%>> "%~dp0tools\defaultsettings.ini"
echo heapy=[%heapy%>> "%~dp0tools\defaultsettings.ini"
echo warnabaru=[%warnabaru%>> "%~dp0tools\defaultsettings.ini"
if exist "%~dp0tools\defaultsettings.ini" goto finwritedefault
echo not exist
rename "%~dp0tools\defaultsettings.bak" defaultsettings.ini
goto restart
:finwritedefault
del "%~dp0tools\defaultsettings.bak"
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                SELECT YOUR PROJECT 
:: ------------------------------------------------------------------------------------------------------------------- ::
:doselectapk
call :toolhead
set /A count=0
for %%F in (input_apk/*.apk) do (
set /A count+=1
set a!count!=%%F
if /I !count! LEQ 9 (echo    !count!  %%F )
if /I !count! GTR 9 (echo   !count!  %%F )
)
if /I !count! EQU 0 (goto noapkhere)
echo.
echo. Choose the apk to be set as current project?
echo.
set /P input=^>Enter It's Number : %=%
set capp=!a%input%!
if "%capp%"==""  goto doselectapk
goto writedefaultininow
:noapkhere
set capp=None
echo.
echo. There is no apk in "input_apk" folder. Put your Apk there first.
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                     IF FRAMEWORK
:: ------------------------------------------------------------------------------------------------------------------- ::
:doifframework
call :toolhead
if not exist "%~dp0input_apk\framework-res.apk" goto noframeworkres
echo. ...Installing framework file
if exist "%userprofile%\apktool\framework\1.apk" del /Q "%userprofile%\apktool\framework\1.apk"
java -jar "%~dp0tools\apktool.jar" if "%~dp0input_apk\framework-res.apk"
echo.
echo. Done.
echo  ===============================================================================
echo. Framework installed at %userprofile%\apktool\framework
echo.
pause
goto restart
:noframeworkres
echo.
echo. Please put framework-res.apk in "input_apk" folder first
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                    DECOMPILE APK
:: ------------------------------------------------------------------------------------------------------------------- ::
:dodecompile
call :toolhead
set /A error=0
if %capp%==None goto noproj
if not exist "%~dp0input_apk\%capp%" goto noinputapk
cd %~dp0tools
call decompiler "%capp%"
if /I !error! GTR 0 ( goto decomwitherror )
goto outdecunzip
:outdecunzip
echo  ===============================================================================
echo. %capp% created in projects folder
echo.
pause
goto restart
:outcompzipsys
echo.
echo. Done.
echo  ===============================================================================
echo. %capp% created in output_apk folder
echo.
pause
goto restart
:outcompzipreg
echo.
echo. Done.
echo  ===============================================================================
echo. Unsigned%capp% created in output_apk folder
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                        DECOMPILE APK WITH DEPENDENCY
:: ------------------------------------------------------------------------------------------------------------------- ::
:decdepapk
call :toolhead
set /A input=sampah
if %capp%==None goto noproj
echo. Drag the dependee apk in this window or type its path
echo. Example to decompile Rosie.apk, drag com.htc.resources.apk in this window
echo.
set /P input=_Insert input: %=%
java -jar "%~dp0tools\apktool.jar" if %input%
if exist "%userprofile%\apktool\framework\2.apk" goto founddependee
if not exist "%userprofile%\apktool\framework\2.apk" goto redependee
:founddependee
echo.
echo. Found dependee apk at %userprofile%\apktool\framework\2.apk
goto dodecompile
:redependee
echo.
echo. Sorry thats not the dependee apk, try again (y/n)
echo.
set /P input2=Type input: %=%
if %input2%==y goto decdepapk
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                               COMPILE APK
:: ------------------------------------------------------------------------------------------------------------------- ::
:compapk
set /A error=0
set /A input1=sampah
set /A input2=sampah
if %capp%==None goto noproj
if not exist "%~dp0input_apk\%capp%" goto noinputapk
if not exist "%~dp0projects\%capp%" goto noprofolcapp
cd %~dp0tools
call compiler "%capp%"
if /I !error! GTR 0 goto iferrorlevel
:sysorreg
echo.
echo. Is this a system apk (y/n)
echo. if no, you have to sign your apk after you compiled
echo. if yes, original signatures will be copied to your apk
echo.
set /P input1=_Type input: %=%
if %input1%==n (goto outcompzipreg)
if %input1%==y (goto y1sys)
goto sysorreg
:y1sys
echo.
echo. Aside from the signatures, would you like to copy over any additional
echo. files that you didn't modify from the original apk in order to ensure 
echo. least # of errors (y/n)
echo.
set /P input2=_Type input: %=%
if %input2%==n (goto y1n2sys)
if %input2%==y (goto y1y2sys)
goto y1sys
:y1y2sys
::extract apk to keep folder
mkdir "%~dp0keep"
"%~dp0tools\7za" x -o"%~dp0keep" "%~dp0input_apk\%capp%"
echo.
echo. In the  toolAlite  folder  u'll find  a "keep" folder.  Within it,  DELETE
echo. everything you have modified and leave files that you haven't. If you have
echo. modified  any xml,  then delete  resources.arsc  from that folder as well. 
echo. Once done then press enter on this terminal.
echo.
pause
"%~dp0tools\7za" a -tzip "%~dp0output_apk\Unsigned%capp%" "%~dp0keep\*" -mx%usrc% -r
rmdir /S /Q "%~dp0keep"
rename "%~dp0output_apk\Unsigned%capp%" "%capp%"
goto outcompzipsys
:y1n2sys
::only META-INF copied from original apk
"%~dp0tools\7za" x -o"%~dp0projects\temp" "%~dp0input_apk\%capp%" META-INF -r
"%~dp0tools\7za" a -tzip "%~dp0output_apk\Unsigned%capp%" "%~dp0projects\temp\*" -mx%usrc% -r
rmdir /S /Q "%~dp0projects\temp"
rename "%~dp0output_apk\Unsigned%capp%" "%capp%"
goto outcompzipsys
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                            DECOMPILE ALL APK IN INPUT FOLDER
:: ------------------------------------------------------------------------------------------------------------------- ::
:decallinput
call :toolhead
set /A error=0
:: check if any apk in input_apk folder
if exist "%~dp0input_apk\*.apk" goto dodecallinput
echo.
echo. there is no apk in input_folder
echo.
pause
goto restart
:dodecallinput
cd %~dp0tools
for %%F in ("%~dp0input_apk\*.apk") do call decompiler "%%F"
if /I !error! GTR 0 goto decomwitherror
echo.
echo  ===============================================================================
echo. All output files is in projects folder
echo.
pause
goto restart
:decomwitherror
echo.
echo  ===============================================================================
echo. Done with %error% errors
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                            compile all apk in projects folder
:: ------------------------------------------------------------------------------------------------------------------- ::
:compallproj
call :toolhead
set /A error=0
:: check if any folder projects folder
::if exist "%~dp0project\*" goto docompallproj
::goto noprojectfolder
:docompallproj
cd %~dp0tools
for /D %%F in ("%~dp0projects\*.apk") do call compallapk "%%F"
if /I !error! GTR 0 goto decomwitherror
echo.
echo  ===============================================================================
echo. All output files is in output_apk folder
echo.
pause
goto restart
:noprojectfolder
echo.
echo. There is no projects folder
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                            COMBO-1 - COMPILE REG APK -SIGN-INSTALL
:: ------------------------------------------------------------------------------------------------------------------- ::
:combo1
cls
if %capp%==None goto noproj
if not exist "%~dp0projects\%capp%" goto noprofolcapp
cd %~dp0tools
call compiler "%capp%"
echo.
echo. Done compiling
echo. --------------
echo.
:: start combo signing reg apk and install it
goto combosigning
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                            Combo-2 - PNG_opt-Compile reg apk -Sign-Install
:: ------------------------------------------------------------------------------------------------------------------- ::
:combo2
if %capp%==None goto noproj
if not exist "%~dp0projects\%capp%" goto noprofolcapp
:: png optimizing
mkdir temp
xcopy /S /Y /Q "%~dp0projects\%capp%\res\*.9.png" "%~dp0temp"
echo. ^>^> Optimizing Png's
echo.
cd %~dp0tools
for /r "%~dp0projects\%capp%\" %%F in (*.png) do call optipngizer "%%F"
xcopy /S /Y /Q "%~dp0temp" "%~dp0projects\%capp%\res"
rmdir /S /Q "%~dp0temp"
echo.
echo. Done. PNG checked and optimized
echo. -------------------------------
echo.
:: compiling
cd %~dp0tools
call compiler "%capp%"
echo.
echo. Done compiling
echo. --------------
echo.
:: start combo signing reg apk and install it
goto combosigning
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                              Combo-3 : Zip-Sign-Instal
:: ------------------------------------------------------------------------------------------------------------------- ::
:combo3
cls
if %capp%==None goto noproj
if not exist "%~dp0projects\%capp%" goto noprofolcapp
:: zipping regular apk
:comboziping
if exist "%~dp0output_apk\Unsigned%capp%" del /S /Q "%~dp0output_apk\Unsigned%capp%"
if exist "%~dp0output_apk\Signed%capp%" del /S /Q "%~dp0output_apk\Signed%capp%"
echo. ^>^> Zipping %capp%
mkdir "%~dp0temp\META-INF"
xcopy /S /Y /Q "%~dp0projects\%capp%\META-INF" "%~dp0temp\META-INF"
rmdir /S /Q "%~dp0projects\%capp%\META-INF"
pause
"%~dp0tools\7za" a -tzip "%~dp0output_apk\Unsigned%capp%" "%~dp0projects\%capp%\*" -mx%usrc%
if errorlevel 1 goto iferrorlevel
xcopy /S /Y /Q "%~dp0temp" "%~dp0projects\%capp%"
rmdir /S /Q "%~dp0temp"
echo.
echo. Done zipping Unsigned%capp%
echo. -------------------------------
echo.
:: signing regular apk and install it
goto combosigning
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                          Combo-4 : PNG_Optimize-Zip-Sign-Instal
:: ------------------------------------------------------------------------------------------------------------------- ::
:combo4
cls
if %capp%==None goto noproj
if not exist "%~dp0projects\%capp%" goto noprofolcapp
if exist "%~dp0output_apk\Unsigned%capp%" del /S /Q "%~dp0output_apk\Unsigned%capp%"
if exist "%~dp0output_apk\Signed%capp%" del /S /Q "%~dp0output_apk\Signed%capp%"
:: png optimizing
mkdir temp
xcopy /S /Y /Q "%~dp0projects\%capp%\res\*.9.png" "%~dp0temp"
echo. ^>^> Optimizing Png's (bypass *.9.png)
echo.
cd %~dp0tools
for /r "%~dp0projects\%capp%\" %%F in (*.png) do call optipngizer "%%F"
xcopy /S /Y /Q "%~dp0temp" "%~dp0projects\%capp%\res"
rmdir /S /Q "%~dp0temp"
echo.
echo. Done. PNG checked and optimized
echo. -------------------------------
echo.
:: zipping regular apk
goto comboziping
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                       Combo-5 : Extract-PNG_Optimize-Zip-Sign-Instal
:: ------------------------------------------------------------------------------------------------------------------- ::
:combo5
if %capp%==None goto noproj
if exist "%~dp0output_apk\Unsigned%capp%" del /S /Q "%~dp0output_apk\Unsigned%capp%"
if exist "%~dp0output_apk\Signed%capp%" del /S /Q "%~dp0output_apk\Signed%capp%"
:: extracting apk
echo Extracting apk
if exist "%~dp0projects\%capp%" rmdir /S /Q "%~dp0projects\%capp%"
"%~dp0tools\7za" x -o"%~dp0projects\%capp%" "%~dp0input_apk\%capp%"
if errorlevel 1 goto iferrorlevel
echo.
echo. Done extracting
echo.
:: png optimizing
mkdir temp
xcopy /S /Y /Q "%~dp0projects\%capp%\res\*.9.png" "%~dp0temp"
echo Optimizing Png's (bypass *.9.png)
echo.
cd %~dp0tools
for /r "%~dp0projects\%capp%\" %%F in (*.png) do call optipngizer "%%F"
xcopy /S /Y /Q "%~dp0temp" "%~dp0projects\%capp%\res"
rmdir /S /Q "%~dp0temp"
echo.
echo. Done. PNG checked and optimized
echo.
:: zipping regular apk
goto comboziping
:: ------------------------------------------------------------------------------------------------------------------- ::
::  combo signing and installing
:combosigning
set /A input=sampah
echo. ...Signing Unsigned%capp%
java -Xmx%heapy%m -jar "%~dp0tools\signapk.jar" -w "%~dp0tools\testkey.x509.pem" "%~dp0tools\testkey.pk8" "%~dp0output_apk\Unsigned%capp%" "%~dp0output_apk\Signed%capp%"
if errorlevel 1 goto iferrorlevel
del /Q "%~dp0output_apk\Unsigned%capp%"
echo.
echo. Finish signing apk to Signed%capp%
echo.
:asktoinstall
echo. Do you want to install this ^(y/n^)^?
echo.
set /P input=_Type input : %=%
echo.
if %input%==y goto docomboinstall
if %input%==n goto restart
goto asktoinstall
:docomboinstall
echo Waiting for device
adb wait-for-device
echo Installing Apk
adb install "%~dp0output_apk\Signed%capp%"
if errorlevel 1 goto iferrorlevel
echo.
echo Done.. 
pause
adb kill-server
goto restart
:::quitcombo
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                EXTRACTING APK
:: ------------------------------------------------------------------------------------------------------------------- ::
:extractapk
call :toolhead
echo. ^>^> Extracting %capp%
echo.
if %capp%==None goto noproj
if not exist "%~dp0input_apk\%capp%" goto noinputapk
if exist "%~dp0projects\%capp%" rmdir /S /Q "%~dp0projects\%capp%"
"%~dp0tools\7za" x -o"%~dp0projects\%capp%" "%~dp0input_apk\%capp%"
if errorlevel 1 goto iferrorlevel
echo.
goto outdecunzip
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                               ZIPING THE EXTRACTED APK
:: ------------------------------------------------------------------------------------------------------------------- ::
:zipextracted
call :toolhead
echo. ^>^> Zipping %capp%
echo.
if %capp%==None goto noproj
if not exist "%~dp0projects\%capp%" goto noprofolcapp
if exist "%~dp0output_apk\Signed%capp%" del /Q "%~dp0output_apk\Signed%capp%"
if exist "%~dp0output_apk\Unsigned%capp%" del /Q "%~dp0output_apk\Unsigned%capp%"
if exist "%~dp0output_apk\%capp%" del /Q "%~dp0output_apk\%capp%"
echo. 1  System apk (Retains signature)
echo. 2  Regular apk (Removes signature for re-signing)
echo.
set /P input=_Please make your decision : %=%
if %input%==1 (goto zipsys)
if %input%==2 (goto zipreg)
goto zipextracted
:zipsys 
if exist "%~dp0output_apk\%capp%" del /S /Q "%~dp0output_apk\%capp%"
echo Zipping System Apk : %capp%
"%~dp0tools\7za" a -tzip "%~dp0output_apk\%capp%" "%~dp0projects\%capp%\*" -mx%usrc%
if errorlevel 1 goto iferrorlevel
echo.
echo. Done.
echo  ===============================================================================
echo. %capp% is created in output_apk folder
echo.
pause
goto restart
:zipreg
if exist "%~dp0output_apk\Unsigned%capp%" del /S /Q "%~dp0output_apk\Unsigned%capp%"
echo Zipping Regular Apk : Unsigned%capp%
rmdir /S /Q "%~dp0projects\%capp%\META-INF\"
"%~dp0tools\7za" a -tzip "%~dp0output_apk\Unsigned%capp%" "%~dp0projects\%capp%\*" -mx%usrc%
if errorlevel 1 goto iferrorlevel
echo.
echo. Done.
echo  ===============================================================================
echo. Unsigned%capp% is created in output_apk folder
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                               OPTIMIZE PNG FILES
:: ------------------------------------------------------------------------------------------------------------------- ::
:optimage
call :toolhead
echo. ^>^> Otimizing %capp%
echo.
if %capp%==None goto noproj
if not exist "%~dp0projects\%capp%" goto noprofolcapp
echo. Bypass "*.9.png" to ensure least # of errors (y/n)?
echo.
set /P input=_Make your decision : %=%
if %input%==y (goto bypass9png)
if %input%==n (goto optiallpng)
goto optimage
:bypass9png
mkdir temp
xcopy /S /Y /Q "%~dp0projects\%capp%\res\*.9.png" "%~dp0temp"
cd %~dp0tools
for /r "%~dp0projects\%capp%\" %%F in (*.png) do call optipngizer "%%F"
xcopy /S /Y /Q "%~dp0temp" "%~dp0projects\%capp%\res"
rmdir /S /Q "%~dp0temp"
echo Optimizing Png's
goto outoptipng
:optiallpng
cd %~dp0tools
for /r "%~dp0projects\%capp%\" %%F in (*.png) do call optipngizer "%%F"
:outoptipng
echo.
echo  ===============================================================================
echo. Done. All png is checked for optimizing
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                               OPTIMIZE OGG/WAV FILES
:: ------------------------------------------------------------------------------------------------------------------- ::
:optiogg
call :toolhead
echo. ^>^> Optimizing %capp%
echo.
set /A input=sampah
set /A audio=sampah
if %capp%==None goto noproj
if not exist "%~dp0projects\%capp%" goto noprofolcapp
echo. Which audio file that you want to optimize
echo. 1  ogg
echo. 2  wav
echo.
set /P input=_Please make your decision : %=%
echo.
if %input%==1 ( set audio=ogg 
goto dooptiogg
)
if %input%==2 ( set audio=wav
goto dooptiogg
)
goto optiogg
:dooptiogg
for /r "%~dp0projects\%capp%\" %%F in (*.%audio%) do call :procoggopt "%%F"
goto outoptiogg
:procoggopt
echo. Optimizing %~n1.%audio%
echo.
"%~dp0tools\sox" %1 -C 0 %1.opt.%audio%
del %1
rename %1.opt.%audio% "%~n1%~x1"
goto quit
:outoptiogg
echo.
echo  ===============================================================================
echo. Done. all %audio% is checked for optimizing
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                             SIGN THE PROJECT
:: ------------------------------------------------------------------------------------------------------------------- ::
:dosign
call :toolhead
if %capp%==None goto noproj
if exist "%~dp0output_apk\%capp%" goto resignsystemapk
if exist "%~dp0output_apk\Unsigned%capp%" goto signunsigned
:: kalau tidak ada
echo.
echo. There is no %capp% or Unsigned%capp% 
echo. in the output_apk folder to sign
echo.
pause
goto restart
:: buat signing system apk 
:resignsystemapk
echo. Re-signing system apk : %capp%
echo.
java -Xmx%heapy%m -jar "%~dp0tools\signapk.jar" -w "%~dp0tools\testkey.x509.pem" "%~dp0tools\testkey.pk8" "%~dp0output_apk\%capp%" "%~dp0output_apk\Signed%capp%"
if errorlevel 1 goto iferrorlevel
del /S /Q "%~dp0output_apk\%capp%"
goto outdosign
:signunsigned
echo. Signing Unsigned%capp%
echo.
java -Xmx%heapy%m -jar "%~dp0tools\signapk.jar" -w "%~dp0tools\testkey.x509.pem" "%~dp0tools\testkey.pk8" "%~dp0output_apk\Unsigned%capp%" "%~dp0output_apk\Signed%capp%"
if errorlevel 1 goto iferrorlevel
del /S /Q "%~dp0output_apk\Unsigned%capp%"
:outdosign
echo.
echo. Done.
echo  ===============================================================================
echo. Signed%capp% created in output_apk folder
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                     ZIPALIGN
:: ------------------------------------------------------------------------------------------------------------------- ::
:dozipalign
call :toolhead
if %capp%==None goto noproj
if exist "%~dp0output_apk\%capp%" goto alignsys
if exist "%~dp0output_apk\Signed%capp%" goto alignsigned
if exist "%~dp0output_apk\Unsigned%capp%" goto alignunsigned
echo.
echo. There is no %capp% or Signed%capp% 
echo. in the output_apk folder, please try again
echo.
pause
goto restart
:alignsys
cd %~dp0tools
call zipaligner %capp%
echo.
echo. Done.
echo  ===============================================================================
echo. Aligned%capp% created in output_apk folder
echo.
pause
goto restart
:alignsigned
cd %~dp0tools
call zipaligner Signed%capp%
echo.
echo. Done.
echo  ===============================================================================
echo. AlignedSigned%capp% created in output_apk folder
echo.
pause
goto restart
:alignunsigned
cd %~dp0tools
call zipaligner Unsigned%capp%
cls
echo.
echo. Done.
echo  ===============================================================================
echo. AlignedUnsigned%capp% created in output_apk folder
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                       ADB INSTALL YOUR SIGNED PROJECT APK
:: ------------------------------------------------------------------------------------------------------------------- ::
:adbinst
call :toolhead
if %capp%==None goto noproj
if exist "%~dp0output_apk\%capp%" goto doinst1
if exist "%~dp0output_apk\Aligned%capp%" goto doinst2
if exist "%~dp0output_apk\Signed%capp%" goto doinst3
if exist "%~dp0output_apk\AlignedSigned%capp%" goto doinst4
if exist "%~dp0output_apk\Unsigned%capp%" goto doinst5
if exist "%~dp0output_apk\AlignedUnsigned%capp%" goto doinst6
echo. There is no Signed / Unsigned / Aligned %capp% 
echo. in the output_apk folder. Please compile again
echo.
pause
goto restart
echo.
:doinst1
echo.
echo. ...installing %capp%
echo.
echo. Waiting for device
echo.
adb wait-for-device
adb install "%~dp0output_apk\%capp%"
if errorlevel 1 goto iferrorlevel
goto outadbinst
:doinst2
echo.
echo. ...installing Aligned%capp%
echo.
echo. Waiting for device
echo.
adb wait-for-device
echo.
adb install "%~dp0output_apk\Aligned%capp%"
if errorlevel 1 goto iferrorlevel
goto outadbinst
:doinst3
echo.
echo. ...installing Signed%capp%
echo.
echo. Waiting for device
echo.
adb wait-for-device
echo.
adb install "%~dp0output_apk\Signed%capp%"
if errorlevel 1 goto iferrorlevel
goto outadbinst
:doinst4
echo. ...installing AlignedSigned%capp%
echo.
echo. Waiting for device
adb wait-for-device
echo.
adb install "%~dp0output_apk\AlignedSigned%capp%"
if errorlevel 1 goto iferrorlevel
goto outadbinst
:doinst5
echo. ...installing Unsigned%capp%
echo.
echo. Waiting for device
adb wait-for-device
echo.
adb install "%~dp0output_apk\Unsigned%capp%"
if errorlevel 1 goto iferrorlevel
goto outadbinst
:doinst6
echo. ...installing Unsigned%capp%
echo.
echo. Waiting for device
adb wait-for-device
echo.
adb install "%~dp0output_apk\AlignedUnsigned%capp%"
if errorlevel 1 goto iferrorlevel
goto outadbinst
:outadbinst
echo.
echo. Done
echo  ===============================================================================
echo. Your project is installed
echo.
pause
adb kill-server
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                SIGNER APK / ZIP
:: ------------------------------------------------------------------------------------------------------------------- ::
:signerany
call :toolhead
set /A input=sampah
echo. Drag any Apk or Zip file here to sign
set /P input=_: %=%
if not exist "%input%" goto signerany
for /f "tokens=* delims= " %%f in ("%input%") do (
set filename=%%~nxf
)
java -Xmx%heapy%m -jar "%~dp0tools\signapk.jar" -w "%~dp0tools\testkey.x509.pem" "%~dp0tools\testkey.pk8" %input% %input:~0,-4%Signed.%input:~-4%
if errorlevel 1 goto iferrorlevel
rename %input:~0,-4%Signed.%input:~-4% Signed%filename%
del /Q %input%
echo.
echo  ===============================================================================
echo. Done. Output is Signed%filename%
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                ZIPALIGN ANY
:: ------------------------------------------------------------------------------------------------------------------- ::
:zipalignany
call :toolhead
set /A input=sampah
echo. Drag any Apk file here to zipalign
set /P input=_: %=%
if not exist %input% goto zipalignany
for /f "tokens=* delims= " %%f in ("%input%") do (
set filename=%%~nxf
)
"%~dp0tools\zipalign" -f -v 4 %input% %input:~0,-4%Aligned.%input:~-4%
if errorlevel 1 goto iferrorlevel
rename %input:~0,-4%Aligned.%input:~-4% Aligned%filename%
del /Q %input%
echo.
echo  ===============================================================================
echo. Done. Output is Aligned%filename%
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                 BATCH INSTALL ALL
:: ------------------------------------------------------------------------------------------------------------------- ::
:batchinstall
call :toolhead
set whichbatch=install
if not exist "%~dp0to_batch_install\*.apk" goto nofiletoopt
cd %~dp0tools
for %%F in ("%~dp0to_batch_install\*.apk") do call adbinall "%%F"
adb kill-server
echo.
echo  ===============================================================================
echo. Done batch installing apk
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                 BATCH OPTIMIZE
:: ------------------------------------------------------------------------------------------------------------------- ::
:batchoptapk
call :toolhead
set whichbatch=optimize
if not exist "%~dp0to_batch_optimize\*.apk" goto nofiletoopt
echo. Do you want to optimize png(p), zipalign(z) or both(b)?
echo.
set /P input= : %=%
for %%F in (to_batch_optimize\*.apk) do call :dan "%%F"
move "tools\optimized\*.apk" "to_batch_optimize"
rmdir /S /Q "tools\optimized"
echo.
echo  ===============================================================================
echo. Done batch optimizing
echo.
pause
goto restart
:dan
if (%input%)==(b) goto zipb
if (%input%)==(z) goto zipo
:zipb
echo. Optimizing %~1...
cd tools
md "apkopt_temp_%~n1"
md optimized
dir /b
7za x -o"apkopt_temp_%~n1" "../to_batch_optimize/%~n1%~x1"
mkdir temp
xcopy "apkopt_temp_%~n1\res\*.9.png" "temp" /S /Y /Q
roptipng -o99 "apkopt_temp_%~n1\**\*.png"
del /q "..\to_batch_optimize\%~n1%~x1"
xcopy "temp" "apkopt_temp_%~n1\res" /S /Y /Q
rmdir "temp" /S /Q
if (%input%)==(p) GOTO ponly
7za a -tzip "optimized\%~n1.unaligned.apk" "%~dp0tools\apkopt_temp_%~n1\*" -mx%usrc% 
rd /s /q "apkopt_temp_%~n1"
zipalign -v 4 "optimized\%~n1.unaligned.apk" "optimized\%~n1.apk"
del /q "optimized\%~n1.unaligned.apk"
echo.
echo. Done optipng and zipalign 
echo.
goto endab
:ponly
7za a -tzip "optimized\%~n1.apk" "%~dp0tools\apkopt_temp_%~n1\*" -mx%usrc%
rd /s /q "apkopt_temp_%~n1"
echo.
echo. Done batch optimizing png
echo. -------------------------
echo.
goto endab
:zipo
echo. Optimizing %~1...
echo.
cd %~dp0tools
zipalign -v 4 "%~dp0to_batch_optimize\%~n1%~x1" "%~dp0to_batch_optimize\u%~n1%~x1"
del /Q "%~dp0to_batch_optimize\%~n1%~x1"
rename "%~dp0to_batch_optimize\u%~n1%~x1" "%~n1%~x1"
echo.
echo. Done batch zipaligning
echo. ----------------------
echo.
goto endab
:endab
cd ..
echo. Optimization complete for %~1
goto quit
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                  BATCH SIGN
:: ------------------------------------------------------------------------------------------------------------------- ::
:batchsign
call :toolhead
set whichbatch=sign
if not exist "%~dp0to_batch_sign\*.apk" goto nofiletoopt
mkdir "%~dp0to_batch_sign\temp"
move /Y "%~dp0to_batch_sign\*.apk" "%~dp0to_batch_sign\temp"
for %%F in ("%~dp0to_batch_sign\temp\*.apk") do call :dobatchsign "%%F"
del /S /Q "%~dp0to_batch_sign\%~n1%~x1"
rmdir /S /Q "%~dp0to_batch_sign\temp"
echo.
echo  ===============================================================================
echo. Done batch signing apk
echo.
pause
goto restart
:dobatchsign
echo.
echo. Signing %~n1.apk
java -Xmx%heapy%m -jar "%~dp0tools\signapk.jar" -w "%~dp0tools\testkey.x509.pem" "%~dp0tools\testkey.pk8" "%~dp0to_batch_sign\temp\%~n1%~x1" "%~dp0to_batch_sign\Signed%~n1%~x1"
goto quit
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                               BATCH OPTIMIZE OGG/WAV
:: ------------------------------------------------------------------------------------------------------------------- ::
:batchoptaudio
call :toolhead
set /A input=sampah
set /A audio=sampah
set whichbatch=audio optimize
echo. Which audio file that you want to optimize
echo. 1  ogg
echo. 2  wav
echo.
set /P input=_Please make your decision : %=%
echo.
if %input%==1 ( set audio=ogg 
goto dobatchoptaudio
)
if %input%==2 ( set audio=wav
goto dobatchoptaudio
)
goto batchoptaudio
:dobatchoptaudio
if not exist "%~dp0to_batch_audio_optimize\*.%audio%" goto nofiletoopt
for %%F in ("%~dp0to_batch_audio_optimize\*.%audio%") do call :procoggopt "%%F"
goto outoptiogg
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                      ADB INSTALL ANY APK
:: ------------------------------------------------------------------------------------------------------------------- ::
:adbinstany
call :toolhead
set /A input=sampah
echo. Drag APK to install here
echo.
set /P input=^>^> : %=%
if not exist "%input%" goto adbinstany
echo.
echo. Waiting for device
echo.
adb wait-for-device
adb install %input%
if errorlevel 1 goto iferrorlevel
echo.
echo. Done.
echo.
pause
adb kill-server
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                       ADB PUSH TO SYSTEM/APP
:: ------------------------------------------------------------------------------------------------------------------- ::
:adbpushsysapp
call :toolhead
set /A input=sampah
echo. Drag file to push here
echo.
set /P input=^>^> : %=%
echo.
if not exist "%input%" goto adbpushsysapp
echo. Waiting for device
adb wait-for-device
adb remount
echo.
echo. ..Pushing %input%
echo.
adb push %input% /system/app
if errorlevel 1 goto iferrorlevel
adb kill-server
echo.
echo. Done.
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                       ADB PUSH system/framework
:: ------------------------------------------------------------------------------------------------------------------- ::
:adbpushframe
call :toolhead
set /A input=sampah
echo. Drag framework-res.apk to push here
echo.
set /P input=^>^> : %=%
if not exist %input% goto adbpushframe
for /f "tokens=* delims= " %%f in ("%input%") do (
set filename=%%~nxf
)
if "%filename%"=="framework-res.apk" goto pushframenow
echo.
echo. That's not a framework-res.apk file
echo.
pause
:pushframenow
echo.
echo. Waiting for device
adb wait-for-device
adb remount
echo.
echo. Pushing %input%
echo.
adb push %input% /system/framework
if errorlevel 1 goto iferrorlevel
echo.
echo. Rebooting now
echo.
adb reboot
echo.
echo. Done.
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                       ADB PUSH /SDCARD
:: ------------------------------------------------------------------------------------------------------------------- ::
:adbpushsd
call :toolhead
set /A filename=sampah
set /A input=sampah
echo. Drag file to push here
echo.
set /P input=^>^> : %=%
if not exist %input% goto adbpushsd
for /f "tokens=* delims= " %%f in ("%input%") do (
set filename=%%~nxf
)
echo.
echo. ...Pushing %%~nxf to /sdcard/
echo.
echo. Waiting for device
echo.
adb wait-for-device
adb push %input% "/sdcard/%filename%"
if errorlevel 1 goto iferrorlevel
adb kill-server
echo.
echo. Done.
echo.
pause
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                       ADB PULL system/app/*..apk or framework-res.apk
:: ------------------------------------------------------------------------------------------------------------------- ::
:adbpullcase
call :toolhead
set /A case=sampah
echo. You can choose to pull system app or framework-res.apk
echo.
echo. Are you going to pull framework-res.apk (y/n)?
echo.
set /P Case1=^>^> : %=%
if %Case1%==y goto pullframe
if %Case1%==n goto pullsysap
goto adbpullcase
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                 ADB PULL system/app
:: ------------------------------------------------------------------------------------------------------------------- ::
:pullsysap
call :toolhead
set /A input=sampah
set /A input2=sampah
set /A inap=sampah
echo. What apk that you want to pull^? 
echo. Example of input : CMParts.apk
echo.
set /P input=^>^> : %=%
echo.
echo. ...Pulling %input%
echo.
adb pull system/app/%input% "%~dp0input_apk\something.apk"
if errorlevel 1 goto iferrorlevel
if not exist "%~dp0input_apk\%input%" goto storeit
:storedassys
echo.
echo. File Already Exists, Rename this one you pull
echo. What filename would you like this app to be stored as ^?
echo. Eg (copy_%input%)
echo.
set /P input2=^>^>: %=%
if exist "%~dp0input_apk\%input%" (
echo.
echo. already exist
echo.
goto storedassys
)
rename "%~dp0input_apk\something.apk" %input2%
echo.
echo. Would you like to set this as your current project ^(y/n^)^?
echo.
set /P inab=^>^> : %=%
if %inab%==y (set capp=%input2%)
echo.
echo. Done. %input2% stored in "input_apk" folder
echo. ----------------------------------------------
echo.
pause
adb kill-server
goto restart
:storeit
rename "%~dp0input_apk\something.apk" %input%
echo Would you like to set this as your current project ^(y/n^)^?
set /P inab=Type input: %=%
if %inab%==y (set capp=%input%)
echo.
echo. Done. %input% stored in "input_apk" folder
echo. ---------------------------------------------
echo.
pause
adb kill-server
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                 ADB PULL FRAMEWORK-RES
:: ------------------------------------------------------------------------------------------------------------------- ::
:pullframe
call :toolhead
set /A input=framework-res.apk
set /A inab=sampah
echo. ...Pulling framework-res.apk
echo.
adb pull system/framework/framework-res.apk "%~dp0input_apk\something.apk"
if errorlevel 1 goto iferrorlevel
if not exist "%~dp0input_apk\framework-res.apk" goto storeframe
:storedas
echo.
echo. framework-res.apk already exists, Rename this one you pull.
echo. What filename would you like this app to be stored as ^?
echo. Eg (framework-res_2.apk)
echo.
set /P input=^>^> : %=%
if exist "%~dp0input_apk\%input%" (
echo.
echo. already exist
echo.
goto storedas
)
rename "%~dp0input_apk\something.apk" %input%
:cappcase
echo.
echo. Would you like to set this as your current project ^(y/n^)^?
set /P inab=Type input: %=%
if %inab%==y goto storeframe2
if %inab%==n goto endpullcase1
goto cappcase
:storeframe2
set capp=%input%
goto endpullcase2
:storeframe
rename "%~dp0input_apk\something.apk" framework-res.apk
:cappcase2
echo.
echo. Would you like to set this as your current project ^(y/n^)^?
set /P inab=^>^>: %=%
if %inab%==y goto storeframe3
if %inab%==n goto endpullcase1
goto cappcase2
:storeframe3
set capp=framework-res.apk
goto endpullcase1
:endpullcase2
echo.
echo. Done. %input% stored in input_apk folder
echo. ---------------------------------------------
echo.
pause
adb kill-server
goto restart
:endpullcase1
echo.
echo. Done. %input% stored in input_apk folder
echo. ---------------------------------------------
echo.
pause
adb kill-server
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                 ADB PULL any
:: ------------------------------------------------------------------------------------------------------------------- ::
:adbpullany
call :toolhead
echo. Pulling framework-res.apk 
adb pull system/framework/framework-res.apk "%~dp0output_apk\something.apk"
if errorlevel 1 goto iferrorlevel
if not exist "%~dp0output_apk\framework-res.apk" goto storeframe
echo.
echo framework-res.apk already exists, Rename this one you pull.
echo What filename would you like this app to be stored as ^?
echo Eg (framework-res_2.apk)
set /P input=Type input: %=%
rename "%~dp0output_apk\something.apk" %input%
:cappcase
echo Would you like to set this as your current project ^(y/n^)^?
set /P inab=Type input: %=%
if %inab%==y goto storeframe2
if %inab%==n goto endpullcase
goto cappcase
:storeframe2
set capp=%input%
goto endpullcase
:storeframe
rename "%~dp0output_apk\something.apk" framework-res.apk
:cappcase2
echo Would you like to set this as your current project ^(y/n^)^?
set /P inab=Type input: %=%
if %inab%==y goto storeframe3
if %inab%==n goto endpullcase
goto cappcase2
:storeframe3
set capp=framework-res.apk
:endpullcase
echo.
echo Done... the apk stored in "output_apk" folder
echo.
pause
adb kill-server
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                   ADB SHELL
:: ------------------------------------------------------------------------------------------------------------------- ::
:calladbshell
call :toolhead
echo. Waiting for device
adb wait-for-device
echo.
adb shell
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                   ADB logcat to text
:: ------------------------------------------------------------------------------------------------------------------- ::
:calladblogcat
call :toolhead
start "Adb Log" tools\signer 2
echo. adblog.txt will be created in root folder ( toolAlite/adblog.txt )
echo.
pause
adb kill-server
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                 ADB KILL-SERVER
:: ------------------------------------------------------------------------------------------------------------------- ::
:calladbkill
call :toolhead
echo. Waiting for device
adb wait-for-device
echo.
echo. waiting to kill adb now
echo.
adb kill-server
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                   ADB REBOOT
:: ------------------------------------------------------------------------------------------------------------------- ::
:calladbreboot
call :toolhead
echo. Waiting for device
adb wait-for-device
echo.
echo. Wait for adb to reboot your phone now
echo.
adb reboot
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                              SET APK TOOL VERSION
:: ------------------------------------------------------------------------------------------------------------------- ::
:setapktoolversion
call :toolhead
cd %~dp0tools
del /Q apktool.jar
echo.  Set Apktool Version: 
echo.    1  apktool 1.3.1
echo.    2  apktool 1.3.2
echo.    3  apktool 1.4.1
echo.    4  apktool 1.4.2
echo.    5  apktool 1.4.3
echo.
set /P apkversion=_Please choose apktool version:
if %apkversion%==1 (
copy /Y apktool_1.3.1.jar  apktool.jar
set nowapktoolver=1.3.1
goto endsetapktool
)
if %apkversion%==2 (
copy /Y apktool_1.3.2.jar  apktool.jar
set nowapktoolver=1.3.2
goto endsetapktool
)
if %apkversion%==3 (
copy /Y apktool_1.4.1.jar  apktool.jar
set nowapktoolver=1.4.1
goto endsetapktool
)
if %apkversion%==4 (
copy /Y apktool_1.4.2.jar  apktool.jar
set nowapktoolver=1.4.2
goto endsetapktool
)
if %apkversion%==5 (
copy /Y apktool_1.4.3.jar  apktool.jar
set nowapktoolver=1.4.3
goto endsetapktool
)
goto :setapktoolversion
:endsetapktool
echo.
echo. Done.. now using apktool version %nowapktoolver%
echo. --------------------------------------------------
echo.
pause
goto writedefaultininow
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                            SELECT COMPRESSION LEVEL
:: ------------------------------------------------------------------------------------------------------------------- ::
:setcompress
call :toolhead
set /A input=sampah
set /P input=_Enter Compression Level (0-9) : %=%
if /I %input% GTR 9 (goto setcompress)
if /I %input% LSS 0 (goto setcompress)
set usrc=%input%
echo.
echo. Done.. now Compression Level is %input%
echo. --------------------------------------------------
echo.
pause
goto writedefaultininow
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                               CLEAN FILES/FOLDERS
:: ------------------------------------------------------------------------------------------------------------------- ::
:cleanfiles
call :toolhead
echo   1. Clean This Project's Folder/Files ^(except apk in input_apk folder^)
echo   2. Clean All Apk's in input_apk Folder
echo   3. Clean All Apk's in to_batch_optimize Folder
echo   4. Clean All Apk's in to_batch_signing Folder
echo   5. Clean All Apk's in to_batch_install Folder
echo   6. Clean All ogg/wav in to_batch_audio_optimize Folder
echo   7. Clean All files inside project Folder
echo   8. Clean All Folders/Files
echo   9. Go Back To Main Menu
echo.
set /P menuclean=_Please make your decision : %=%
echo.
if %menuclean%==1 (
if %capp%==None goto noproj
rmdir /S /Q projects\%capp% > nul
rmdir /S /Q %userprofile%\apktool > nul
if exist "%~dp0output_apk\%capp%" del /S /Q "%~dp0output_apk\%capp%"
if exist "%~dp0output_apk\Signed%capp%" del /S /Q "%~dp0output_apk\Signed%capp%"
if exist "%~dp0output_apk\Unsigned%capp%" del /S /Q "%~dp0output_apk\Unsigned%capp%"
goto donecleaning
)
if %menuclean%==2 (
rmdir /S /Q "%~dp0input_apk" > nul
goto donecleaning
)
if %menuclean%==3 (
rmdir /S /Q "%~dp0to_batch_optimize" > nul
goto donecleaning
)
if %menuclean%==4 (
rmdir /S /Q "%~dp0to_batch_sign" > nul
goto donecleaning
)
if %menuclean%==5 (
rmdir /S /Q "%~dp0to_batch_install" > nul
goto donecleaning
)
if %menuclean%==6 (
rmdir /S /Q "%~dp0to_batch_audio_optimize" > nul
goto donecleaning
)
if %menuclean%==7 (
rmdir /S /Q "%~dp0projects" > nul
goto donecleaning
)
if %menuclean%==8 (
rmdir /S /Q "%userprofile%\apktool" > nul
rmdir /S /Q "%~dp0input_apk" > nul
rmdir /S /Q "%~dp0output_apk" > nul
rmdir /S /Q "%~dp0projects" > nul
rmdir /S /Q "%~dp0to_batch_optimize" > nul
rmdir /S /Q "%~dp0to_batch_sign" > nul
rmdir /S /Q "%~dp0to_batch_install" > nul
rmdir /S /Q "%~dp0to_batch_audio_optimize" > nul
if exist "%~dp0tools\defaultsettings.ini" del /S /Q "%~dp0tools\defaultsettings.ini"
goto donecleaning
)
if %menuclean%==9 ( goto restart )
goto cleanfiles
:donecleaning
echo.
echo. Done cleaning. Back to main menu
echo. --------------------------------
echo.
pause
:: folder re-check
if not exist "%~dp0input_apk" mkdir "%~dp0input_apk"
if not exist "%~dp0output_apk" mkdir "%~dp0output_apk"
if not exist "%~dp0projects" mkdir "%~dp0projects"
if not exist "%userprofile%\apktool" mkdir "%userprofile%\apktool"
if not exist "%~dp0to_batch_install" mkdir "%~dp0to_batch_install"
if not exist "%~dp0to_batch_audio_optimize" mkdir "%~dp0to_batch_audio_optimize"
if not exist "%~dp0to_batch_optimize" mkdir "%~dp0to_batch_optimize"
if not exist "%~dp0to_batch_sign" mkdir "%~dp0to_batch_sign"
if exist "%~dp0temp" rmdir /S /Q "%~dp0temp"
if exist "%~dp0tools\temp" rmdir /S /Q "%~dp0tools\temp"
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                  SET HEAP
:: ------------------------------------------------------------------------------------------------------------------- ::
:setheap
call :toolhead
echo. Enter max size for java heap space in megabytes (eg 512)
echo.
set /P input=_: %=%
set heapy=%input%
echo.
echo. Done.. Max merory Size %input% 
echo. ------------------------
echo.
pause
goto writedefaultininow
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                  TEXT AND SCREEN
:: ------------------------------------------------------------------------------------------------------------------- ::
:textnscreen
call :toolhead
echo. Select your text and background color
echo     1  Gray on Black               6  Light Purple on Black
echo     2  Light Blue on Black         7  Light Yellow on Black
echo     3  Light Green on Black        8  Bright White on Black
echo     4  Light Agua on Black         9  Set your own mix
echo     5  Light Red on Black
echo.
set /P input=_Please make your decision :
echo.
if /I %input% GTR 9 (goto textnscreen)
if /I %input% LSS 1 (goto textnscreen)
:setthecolor
if %input%==1 (set  warnabaru=08)
if %input%==2 (set  warnabaru=09)
if %input%==3 (set  warnabaru=0A)
if %input%==4 (set  warnabaru=0B)
if %input%==5 (set  warnabaru=0C)
if %input%==6 (set  warnabaru=0D)
if %input%==7 (set  warnabaru=0E)
if %input%==8 (set  warnabaru=0F)
if %input%==9 (goto advsetcolor)
echo.
echo. Done..
goto writedefaultininow
:advsetcolor
echo.
echo. Here is the colors that you can choose :
echo     0  Black          8  Gray
echo     1  Blue           9  Light Blue
echo     2  Green          A  Light Green
echo     3  Aqua           B  Light Aqua
echo     4  Red            C  Light Red
echo     5  Purple         D  Light Purple
echo     6  Yellow         E  Light Yellow
echo     7  White          F  Bright White
echo.
set /P inputB=Set Background color :
echo.
set /P inputT=Set Text color :
echo.
if %inputB% NEQ %inputT% goto advsetcolorright
echo. you choose the same color text and background :
goto advsetcolor
:advsetcolorright
set warnabaru=%inputB%%inputT%
echo.
echo. Done.
echo. -----
echo.
goto writedefaultininow
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                    READ LOG
:: ------------------------------------------------------------------------------------------------------------------- ::
:readlog
call :toolhead
cd tools
Start "Read The Log - Main script is still running, close this to return" signer 1
goto restart
:: ------------------------------------------------------------------------------------------------------------------- ::
::                                                   ABOUT
:: ------------------------------------------------------------------------------------------------------------------- ::
:about
call :toolhead
echo. About toolAlite.9o
echo. ------------------
echo. toolAlite is a tool to modified Apk. The Idea and based on APK Manager 4.9
echo. I added new option like If framework, set apktool version, optipng, 
echo. ogg/wav optimation, set color, combo job, signer, zipaligner,
echo. installer, adb command to pull, push, reboot and to kill-server.
echo. I rearranged the option structure, folder, the output file name,
echo. also clean up and fix the program error handling structure.
echo. 
echo. Tools in this version (big thanks to the creator)
echo. ---------------------
echo. - Apktool 1.3.1, 1.3.2, 1.4.1, 1.4.2 and 1.4.3 (choose one)
echo. - adb, aapt and zipalign from SDK R16
echo. - 7za v9.20
echo. - Optipng v0.6.5 (not using rOptipng anymore)
echo. - Sox v14.3.2
echo.
echo. just a Hint
echo. -------------
echo.  1. Put your apk in input_apk folder
echo.  2. Decompiled or unzipped apk in projects folder
echo.  3. Compiled/ziped apk in output_apk
echo.  4. Do your job step by step, example
echo.      - decompile - (edit xml/smali, optimize png/sound) - compile - sign/not
echo.      - unzip - optimize png/sound - zip - sign/not - zipalign
echo.      - etc
echo.  5. Here is how your apk will be named (example for yyx.apk)
echo.     input_apk   : yyz.apk
echo.     projects    : yyz.apk (folder) (same for decompile and unzip)
echo.     compile/zip : a. as system apk - yyz.apk
echo.                   b. as regular apk - Unsignedyyz.apk (no signature)
echo.     signing     : it will search apk in output_apk in this order
echo.                   a. yyz.apk. if not exist than
echo.                   b. Unsignedyyz.apk.
echo.                   c. output is Signedyyz.apk
echo.     zipaligning : same as signing it will search for system apk first.
echo.  7. So be sure your apk/folder in the right place for every step
echo.  8. Decompiling/Compiling, Unzip/Zip will delete previous apk/folder
echo.     so be sure to make a backup if you do a different job for the same apk
echo.  9. Every job will provide you the info about how your job done.
echo. 10. Have fun
echo.                                                           toolAlite by kuyagaol
echo.
pause
goto restart
:: job header toolAlite
:toolhead
cls
echo  ^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^> toolAlite_9o ^<^<^<
echo  ===============================================================================
echo.
goto quit
:: exit
:exit
exit
:: Quit
:quit
:eof