#
# AROMA Installer 2.00 - AROMA Installer Test Script Configuration
#       (c) 2011-2012 by Ahmad Amarullah
#           amarullz - xda-developers
#           http://www.amarullz.com/
#
#       Binary Version  : 2.50
#       Binary Codename : Edelweis
#
### INFO:
#
# * AROMA Resource Dir  = META-INF/com/google/android/aroma
#
# * AROMA Temporary Dir = /tmp/aroma/
#
# * About Icon          = @alert - show <AROMA Resource Dir>/icons/alert.png
#                         or if theme used it will find <themedir>/icon.alert.png
#                         you can still access it via "icons/alert"
#
# * dp                  = Device Pixelate. WVGA/QHD = 3, HVGA = 2.
#                         dp calculated with = round(min(width,height) / 160)
#
###

##
# Fix Colorspace Issue
#
# For device which have a problem with color ( not display the correct color )
# try to set "force_colorspace" with ini_set. It may caused by wrong framebuffer
# information that passed by kernel into framebuffer device.
#
# You can use one of following values:
#   "rgba", "abgr", "argb", "bgra"
#
# NOTE: It must be in top most script, or you will got the color flicker
#
# ini_set("force_colorspace","rgba");
#

##
# Forcing Device Pixelate Size
#  defaut: floor( min( width, height ) / 160 )
#
# Usefull for tablet device, if interface was too big, you can
# force dp size for smaller UI size.

ini_set("dp","2"); 
#-- MDPI ( 340x480 / HVGA )

##[ REQUIRED ]
# Calibrate Touchscreen - MATRIX METHOD
#
# For other device, run the installer, then press "menu"
# and select Calibrating Tools. Follow Instructions, and make
# sure the touch screen has been valid in the testing step.
#
# In the end, there will be alert dialog with calibration data
# ( green ), replace this calibrate_matrix() function with that data.
#
#-------- Change the value with your device calibration data:
calibrate_matrix(
 "194280.00","6660.00","-9638210.00","-8050.00",
 "196500.00","-14199226.00","2123868.50","0"
);

##[ DEPRECATED ]
# Calibrate Touchscreen
#  defaut: HTC Desire Touch Screen Calibrate Data [7.90,20,7.90,20]
#
# In the end, there will be alert dialog with calibration data
# ( green ), replace this calibrate() function with that data.
#
#-------- Uncomment This to insert calibrating data:
# calibrate("7.90","20","7.90","20");
#


##
# Custom Key Code - Usefull For Some Device which not used
#                   Standard key code for up/down/select/back/menu
#
# You can capture the keycode in
# recovery using "aroma-keycapture-flashable.zip" Available in
# AROMA Installer Thread.
#
# Press some key when it run, it will return key code,
# that key can override up/down/select/back/menu actions in
# AROMA Installer, you can even set your home key for up, or
# volume down for select item
#
#-------- Uncomment & Modify this Code:
#
# ini_set("customkeycode_up",     "115");
# ini_set("customkeycode_down",   "114");
# ini_set("customkeycode_select", "116");
# ini_set("customkeycode_menu",   "229");
# ini_set("customkeycode_back",   "158");
#

##
# Initializing Rom Information
#
ini_set("rom_name",             "HTX Zero");
ini_set("rom_version",          "0.33");
ini_set("rom_author",           "Hintay");
ini_set("rom_device",           "Magic&Hero");
ini_set("rom_date",             "2012/10/1");


##
# Show Simple Splash
#
splash(
  #-- Duration 2000ms / 2 seconds
    5000,
  
  #-- <AROMA Resource Dir>/sample.png
    "HTX"
);

##
# Show Calibrating Tools Directly before show any UI
#
#--- Remove this calibtool if you already know the calibrate data
#calibtool("");

#
# Set Small Font to Support all fonts
#
fontresload( "0", "ttf/Roboto-Regular.ttf;ttf/DroidSansArabic.ttf;ttf/DroidSansFallback.ttf;", "12" ); #-- Use sets of font (Font Family)

###################################################################################################################
#
# SHOW LANGUAGE SELECTION
#
selectbox(
  #-- Title
    "Select Language",
  
  #-- Sub Title
    "Please select installer language that you want to use in this installation test:",
  
  #-- Icon: <AROMA Resource Dir>/icons/personalize.png or <ThemeDir>/icon.personalize.png
    "@default",
  
  #-- Will be saved in /tmp/aroma/theme.prop
    "lang.prop",
  
  #---------------------------------[ Selectbox Without Group ]----------------------------------#
  # TITLE            |  SUBTITLE                                                 | Initial Value #
  #------------------+-----------------------------------------------------------+---------------#

    "English",            "Welcome to HTX Zero Installer",                                        1,      #-- selected.0 = 1
    "Simplified Chinesse","欢迎来到HTX Zero安装器",                                               0,      #-- selected.0 = 2
	"Traditional Chinese","歡迎來到HTX Zero安裝器",                                               0      #-- selected.0 = 3
  #--------[ Initial Value = 0: Unselected, 1: Selected, 2: Group Item, 3: Not Visible ]---------#
);

##
# SET LANGUAGE & FONT FAMILY
#
if prop("lang.prop","selected.0")=="1" then
  loadlang("langs/en.lang");
  fontresload( "0", "ttf/Roboto-Regular.ttf", "12" ); #-- "0" = Small Font ( Look at Fonts & UNICODE Demo Below )
  fontresload( "1", "ttf/Roboto-Regular.ttf", "18" ); #-- "1" = Big Font
endif;

if prop("lang.prop","selected.0")=="2" then
  loadlang("langs/cn.lang");
  fontresload( "0", "ttf/DroidSansFallback.ttf;ttf/Roboto-Regular.ttf", "12" ); #-- Use sets of font (Font Family)
  fontresload( "1", "ttf/DroidSansFallback.ttf;ttf/Roboto-Regular.ttf", "18" );
endif;

if prop("lang.prop","selected.0")=="3" then
  loadlang("langs/tw.lang");
  fontresload( "0", "ttf/DroidSansFallback.ttf;ttf/Roboto-Regular.ttf", "12" ); #-- Use sets of font (Font Family)
  fontresload( "1", "ttf/DroidSansFallback.ttf;ttf/Roboto-Regular.ttf", "18" );
endif;


###################################################################################################################
#
# 步骤2 - 显示ROM信息
#
viewbox(
  #-- Title
  "<~welcome.title>",
  
  #-- Text
    "<~welcome.text1><#f00>HTX Zero "+ini_get("rom_version")+"</#><~welcome.text2><#f00>HTC Magic</#><~welcome.text3><#f00>HTC Hero</#>.\n\n"+
    "<~welcome.text4>\n\n"+
	   "<b><~welcome.version>: <#f00>"+ini_get("rom_version")+"</#></b>\n"+
	   "<b><~welcome.codename>: <#f00>Hintay</#> & <#f00>idogx</#></b>\n"+
	   "<b><~welcome.updated>: <#f00>"+ini_get("rom_date")+"</#></b>\n\n"+
    "<#f00><~welcome.thanks></#>\n"+
                 "SebastianFM\n\n"+
    "<#f00><~welcome.warring></#>\n"+
    "<~welcome.warringtext1>\n"+
    "<~welcome.warringtext2>",
	
  #-- Icon
	"@welcome"
);

###################################################################################################################
#
# STEP 3 - LICENSE
#
if prop("lang.prop","selected.0")=="1" then
agreebox(
  #-- Title
    "<~terms.title>",
  
  #-- Subtitle / Description
    "<~terms.desc>",
  
  #-- Icon
    "@license",
  
  #-- Text Content ( Read from <AROMA Resource Dir>/license.txt )
    resread("licenseen.txt"),
  
  #-- Checkbox Text
    "<~terms.check>",
  
  #-- Unchecked Alert Message
    "<~terms.confirm>"
);
endif;

if prop("lang.prop","selected.0")=="2" then
agreebox(
  #-- Title
    "<~terms.title>",
  
  #-- Subtitle / Description
    "<~terms.desc>",
  
  #-- Icon
    "@license",
  
  #-- Text Content ( Read from <AROMA Resource Dir>/license.txt )
    resread("licensecn.txt"),
  
  #-- Checkbox Text
    "<~terms.check>",
  
  #-- Unchecked Alert Message
    "<~terms.confirm>"
);
endif;

if prop("lang.prop","selected.0")=="3" then
agreebox(
  #-- Title
    "<~terms.title>",
  
  #-- Subtitle / Description
    "<~terms.desc>",
  
  #-- Icon
    "@license",
  
  #-- Text Content ( Read from <AROMA Resource Dir>/license.txt )
    resread("licensetw.txt"),
  
  #-- Checkbox Text
    "<~terms.check>",
  
  #-- Unchecked Alert Message
    "<~terms.confirm>"
);
endif;

###################################################################################################################
#
#  步骤4 - 更新日志
#
if prop("lang.prop","selected.0")=="1" then
textbox(
  #-- Title
    "<~changelog.title>",
  
  #-- Subtitle
    "<~changelog.desc>",
  
  #-- Icon
    "@update",
  
  #-- Arg 4
    resread("changelogen.txt")
);
endif;

if prop("lang.prop","selected.0")=="2" then
textbox(
  #-- Title
    "<~changelog.title>",
  
  #-- Subtitle
    "<~changelog.desc>",
  
  #-- Icon
    "@update",
  
  #-- Arg 4
    resread("changelogcn.txt")
);
endif;

if prop("lang.prop","selected.0")=="3" then
textbox(
  #-- Title
    "<~changelog.title>",
  
  #-- Subtitle
    "<~changelog.desc>",
  
  #-- Icon
    "@update",
  
  #-- Arg 4
    resread("changelogtw.txt")
);
endif;

###################################################################################################################
#
# STEP 5 - SHOW MENUBOX - INSTALLATION TYPE
#
menubox(
  #-- Title
    "<~type.title>",
  
  #-- Sub Title
    "<~type.desc>",
  
  #-- Icon
    "@install",
    
  #-- Will be saved in /tmp/aroma/type.prop
    "type.prop",
    
  #-------------------------+-----------------[ Menubox Items ]-------------------------+---------------#
  # TITLE                   |  SUBTITLE                                                 |   Item Icons  #
  #-------------------------+-----------------------------------------------------------+---------------#
	
	"<~type.st1>",            "<~type.su1>",                                               "@install",      #-- selected = 1
    "<~type.st2>",            "<~type.su2>",                                               "@customize"     #-- selected = 2
);

###################################################################################################################
#
# STEP 8 - 自定义程序
#
if
    file_getprop("/tmp/aroma-data/type.prop","selected") == "2"
then
checkbox(
  "<~customize.title>",
  "<~customize.desc>",
  
  #-- Icon: <AROMA Resource Dir>/icons/personalize.png or <ThemeDir>/icon.personalize.png
  "@personalize",
  
  #-- Will be saved in /tmp/aroma/customize.prop
  "customize.prop",

# Applications:
	  #-----------------------------------[ Selectbox With Groups ]----------------------------------#
	  # TITLE            |  SUBTITLE                                                 | Initial Value #
	  #------------------+-----------------------------------------------------------+---------------#
	   "<~customize.gt1>","",2,
		"Appsharing",              "<~customize.gt1su1>",0,
		"Gmail",                   "<~customize.gt1su2>",1,
		"Google Talk",             "<~customize.gt1su3>",1,
        "Google Search",           "<~customize.gt1su4>",1,
		"Voice Search",            "<~customize.gt1su5>",0,
		"Youtube",                 "Youtube",0,
		"TTS",                     "TTS",1,
		"Dreye",                   "<~customize.gt1su8>",0,
		
	  "<~customize.gt2>","",2,
		"tools KeyboadLight",       "<~customize.gt2su1>",1,

	  "<~customize.gt3>","",2,
		"HTC Friendstream",        "<~customize.gt3su1>", 0,
		"HTC Hub&Likes",           "HTC Hub&Liks",0,
		"HTC Market",              "<~customize.gt3su3>",1,
		"HTC FaceBook",            "FaceBook for Sense",0,
		"HTC Renren",              "<~customize.gt3su5>" ,0,
		"HTC Weibo",               "<~customize.gt3su6>" ,0,
		"HTC QuickLookup",         "<~customize.gt3su7>" ,1,
		"HTC Transfer",            "<~customize.gt3su8>" ,1,
		
	  "<~customize.gt4>","",2,
		"Browser",        "<~customize.gt4su1>", 1,
		"Calculator",        "<~customize.gt4su2>", 1,
		"Calendar",        "<~customize.gt4su3>", 1,
		"MyHTC",        "<~customize.gt4su4>", 1,
		"Download",        "<~customize.gt4su5>", 1,
		"GoogleCalendarSyncAdapter",        "<~customize.gt4su6>", 1,
		"GoogleContactsSyncAdapter",        "<~customize.gt4su7>", 1,
		"GooglePartnerSetup",        "<~customize.gt4su8>", 1,
		"GoogleServicesFramework",        "<~customize.gt4su9>", 1,
		"hFileManager",        "<~customize.gt4su10>", 1,
		"HTC_IME",        "<~customize.gt4su11>", 1,
		"HTCAlbum",        "<~customize.gt4su12>", 1,
		"HtcWeatherWallpaper",        "<~customize.gt4su13>", 1,
		"HTCCamera",        "<~customize.gt4su14>", 1,
		"HtcCompressViewer",        "<~customize.gt4su15>", 1,
		"HtcContacts",        "<~customize.gt4su16>", 1,
		"HtcDialer",        "<~customize.gt4su17>", 1,
		"HtcMusic",        "<~customize.gt4su18>", 1,
		"HtcSoundRecorder",        "<~customize.gt4su19>", 1,
		"HtcStreamPlayer",        "<~customize.gt4su20>", 1,
		"HtcVideoPlayer",        "<~customize.gt4su21>", 1,
		"HTMLViewer",        "<~customize.gt4su22>", 1,
		"Mail",        "<~customize.gt4su23>", 1,
		"Mms",        "<~customize.gt4su24>", 1,
		"ScreenFlashlight",        "<~customize.gt4su25>", 1,
		"SpareParts",        "<~customize.gt4su26>", 1,
		"Stk",        "<~customize.gt4su27>", 1,
		"Street",        "<~customize.gt4su28>", 1,
		"TaskManager",        "<~customize.gt4su29>", 1,
		"Weather",        "<~customize.gt4su30>", 1,
		"UsageMonitor",        "<~customize.gt4su31>", 1,
		"WorldClock",        "<~customize.gt4su32>", 1,
	
	  "<~customize.gt5>","",2,
		"MusicWidget",        "<~customize.gt5su1>", 1,
		"htccalendarwidgets",        "<~customize.gt5su2>", 1,
		"HtcClockWidget",        "<~customize.gt5su3>", 1,
		"HtcContactWidgets",        "<~customize.gt5su4>", 1,
		"htcmsgwidgets",        "<~customize.gt5su5>", 1,
		"HtcQuickLaunchWidget",        "<~customize.gt5su6>", 1,
		"htcsettingwidgets",        "<~customize.gt5su7>", 1,
		"WeatherWidget",        "<~customize.gt5su8>", 1,
		
	  "<~customize.gt6>","",2,
		"Original Clockwight",        "<~customize.gt6su1>", 0,
		"Chinese CallerLocation",        "<~customize.gt6su2>", 1
		
		
	#--------[ Initial Value = 0: Unselected, 1: Selected, 2: Group Item, 3: Not Visible ]---------#
);
else
  # Default .prop
  writetmpfile(
    "customize.prop",
      "item.1.1=0\n"+
      "item.1.2=1\n"+
      "item.1.3=1\n"+
      "item.1.4=1\n"+
      "item.1.5=0\n"+
      "item.1.6=0\n"+
	  "item.1.7=1\n"+
	  "item.1.8=0\n"+
      
      "item.2.1=1\n"+
      
      "item.3.1=0\n"+
      "item.3.2=0\n"+
      "item.3.3=1\n"+
	  "item.3.4=0\n"+
	  "item.3.5=0\n"+
	  "item.3.6=0\n"+
	  "item.3.7=1\n"+
      "item.3.8=1\n"+
	  
	  "item.4.1=1\n"+
	  "item.4.2=1\n"+
	  "item.4.3=1\n"+
	  "item.4.4=1\n"+
	  "item.4.5=1\n"+
	  "item.4.6=1\n"+
	  "item.4.7=1\n"+
	  "item.4.8=1\n"+
	  "item.4.9=1\n"+
	  "item.4.10=1\n"+
	  "item.4.11=1\n"+
	  "item.4.12=1\n"+
	  "item.4.13=1\n"+
	  "item.4.14=1\n"+
	  "item.4.15=1\n"+
	  "item.4.16=1\n"+
	  "item.4.17=1\n"+
	  "item.4.18=1\n"+
	  "item.4.19=1\n"+
	  "item.4.20=1\n"+
	  "item.4.21=1\n"+
	  "item.4.22=1\n"+
	  "item.4.23=1\n"+
	  "item.4.24=1\n"+
	  "item.4.25=1\n"+
	  "item.4.26=1\n"+
	  "item.4.27=1\n"+
	  "item.4.28=1\n"+
	  "item.4.29=1\n"+
	  "item.4.30=1\n"+
	  "item.4.31=1\n"+
	  "item.4.32=1\n"+
	  
	  "item.5.1=1\n"+
	  "item.5.2=1\n"+
	  "item.5.3=1\n"+
	  "item.5.4=1\n"+
	  "item.5.5=1\n"+
	  "item.5.6=1\n"+
	  "item.5.7=1\n"+
	  "item.5.8=1\n"+
	  
	  "item.6.1=0\n"+
	  "item.6.2=1\n"
  );
endif;

##
#
# Next Screen is Installation UI, So change the next button text to "Install Now"
#
ini_set("text_next", "<~text_install>");

###################################################################################################################
#
# STEP 9 - MAKE SURE USER KNOW THAT NEXT STEP WAS INSTALLATION PROCESS
#
viewbox(
  #-- Title
    "<~ready.title>",

  #-- Text
    "<~ready.desc1>\n\n"+
	"<~ready.desc2>\n\n"+
	"<~ready.desc3>",

  #-- Icon
    "@install"
);

##
#
# Next Button in successfull installation should be back to "Next >"
#
ini_set("text_next", "<~text_next2>");

###################################################################################################################
#
# STEP 10 - INSTALLATION PROCESS
#
setvar("retstatus",
  install(
	#-- Title
      "<~installation.title>",
	
	#-- Installation Process message
	  "<~installation.desc1>\n\n"+
      "<~installation.desc2>",
	
	#-- Installation Icon
      "@install",
	
	#-- Installation Finish Message
      "<~installation.finish1>"+
	  "<~installation.finish2>"
  )
);

##
#
# Next Button is "Finish"
#
ini_set("text_next", "<~text_finish>");

###################################################################################################################
#
# STEP 11 - FINISH MESSAGE, Add Checkbox to Reboot or No. Save in "reboot_it" variable
#
# You can use return value or "reboot_it" variable to retrive checkbox value
# Example:
# if (checkviewbox(....)=="1" then
#    ... checked ...
# endif;
#
checkviewbox(
  #-- Title
    "<~completed.title>",
  
  #-- Text
    "<#selectbg_g><b><~completed.desc1></b></#>\n\n"+
    "<#f00><b>"+ini_get("rom_name")+"</b></#><~completed.desc2>\n\n"+
    "<~completed.desc3>\n\n",
	
  #-- Icon
    "@welcome",

  #-- Checkbox Text
    "<~completed.reboot>",

  #-- Initial Checkbox value ( 0=unchecked, 1=checked ) -  (Optional, default:0)
    "1",

  #-- Save checked value in variable "reboot_it" (Optional)
    "reboot_it"
);

###
#
# Check if reboot checkbox was checked
if
  getvar("reboot_it")=="1"
then
  #
  # reboot("onfinish");   - Reboot if anything finished
  # reboot("now");        - Reboot Directly
  # reboot("disable");    - If you set reboot("onfinish") before, use this command to revert it.
  #
  reboot("onfinish");
endif;

#---- FINISH
