Remove TWRP app prompt from reboot flow

Add option to install TWRP app as a list menu item on the
advanced page and as a button on the reboot page (except for
watch theme). Now when a user reboots the device, they no longer
will be prompted to install the TWRP app, which interrupts the
flow of rebooting the device.

Change-Id: I00559d0be6e7d0b00d469a5960e4b14e32a3fc5f
diff --git a/gui/theme/common/landscape.xml b/gui/theme/common/landscape.xml
index 23e5338..ba6073e 100755
--- a/gui/theme/common/landscape.xml
+++ b/gui/theme/common/landscape.xml
@@ -1015,7 +1015,7 @@
 		<page name="rebootcheck">
 			<action>
 				<condition var1="tw_backup_system_size" op="&gt;=" var2="%tw_min_system%"/>
-				<action function="page">appcheck</action>
+				<action function="reboot">%tw_reboot_param%</action>
 			</action>
 
 			<action>
@@ -1024,28 +1024,6 @@
 			</action>
 		</page>
 
-		<page name="appcheck">
-			<action>
-				<condition var1="tw_app_prompt" var2="1"/>
-				<action function="checkforapp"></action>
-			</action>
-
-			<action>
-				<condition var1="tw_app_prompt" op="!=" var2="1"/>
-				<action function="reboot">%tw_reboot_param%</action>
-			</action>
-
-			<action>
-				<condition var1="tw_app_install_status" var2="1"/>
-				<action function="page">rebootapp</action>
-			</action>
-
-			<action>
-				<condition var1="tw_app_install_status" var2="2"/>
-				<action function="reboot">%tw_reboot_param%</action>
-			</action>
-		</page>
-
 		<page name="wipe">
 			<template name="page"/>
 
@@ -2846,6 +2824,13 @@
 		</page>
 
 		<page name="reboot">
+			<action>
+				<action function="checkforapp"></action>
+				<action function="page">reboot2</action>
+			</action>
+		</page>
+
+		<page name="reboot2">
 			<template name="page"/>
 
 			<text style="text_l">
@@ -2968,9 +2953,20 @@
 				</button>
 			</listbox>
 
+			<button style="main_button">
+				<condition var1="tw_app_install_status" var2="1"/>
+				<placement x="%center_x%" y="%row12_y%"/>
+				<text>{@reboot_install_app_hdr=Install TWRP App}</text>
+				<actions>
+					<action function="set">tw_back=reboot</action>
+					<action function="set">tw_appinstall_title={@reboot_hdr=Reboot}</action>
+					<action function="page">installapp</action>
+				</actions>
+			</button>
+
 			<text style="text_m">
 				<condition var1="tw_has_boot_slots" var2="1"/>
-				<placement x="%center_x%" y="%row14_y%" placement="5"/>
+				<placement x="%col1_x_header%" y="%row14_y%"/>
 				<text>{@current_boot_slot=Current Slot: %tw_active_slot%}</text>
 			</text>
 
@@ -3017,17 +3013,17 @@
 			</action>
 		</page>
 
-		<page name="rebootapp">
+		<page name="installapp">
 			<template name="page"/>
 
 			<text style="text_l">
 				<placement x="%col1_x_header%" y="%row3_header_y%"/>
-				<text>{@reboot_hdr=Reboot}</text>
+				<text>%tw_appinstall_title%</text>
 			</text>
 
 			<text style="text_m">
 				<placement x="%col1_x_header%" y="%row4_header_y%"/>
-				<text>{@reboot_install_app_hdr=Install TWRP App?}</text>
+				<text>{@reboot_install_app_hdr=Install TWRP App}</text>
 			</text>
 
 			<text style="text_m_accent">
@@ -3041,12 +3037,6 @@
 			</text>
 
 			<checkbox>
-				<placement x="%indent%" y="%row5_y%"/>
-				<text>{@reboot_install_app_prompt_install=Prompt to install TWRP app if not installed}</text>
-				<data variable="tw_app_prompt"/>
-			</checkbox>
-
-			<checkbox>
 				<condition var1="tw_mount_system_ro" var2="0"/>
 				<placement x="%indent%" y="%row7_y%"/>
 				<text>{@reboot_install_app_system=Install as a System App}</text>
@@ -3056,20 +3046,16 @@
 			<button style="main_button_half_width">
 				<placement x="%col2_x_left%" y="%row15a_y%"/>
 				<text>{@install_cancel=Do not Install}</text>
-				<action function="reboot">%tw_reboot_param%</action>
+				<action function="page">%tw_back%</action>
 			</button>
 
 			<slider>
 				<text>{@swipe_to_install_app=Swipe to Install TWRP App}</text>
 				<actions>
-					<action function="set">tw_back=reboot</action>
 					<action function="set">tw_action=installapp</action>
 					<action function="set">tw_action_text1={@reboot_installing_app=Installing App...}</action>
 					<action function="set">tw_action_text2=</action>
-					<action function="set">tw_has_action2=1</action>
-					<action function="set">tw_action2=reboot</action>
-					<action function="set">tw_action2_param=%tw_reboot_param%</action>
-					<action function="set">tw_complete_text1={@rebooting=Rebooting...}</action>
+					<action function="set">tw_complete_text1={@successful=Successful}</action>
 					<action function="page">action_page</action>
 				</actions>
 			</slider>
@@ -3086,7 +3072,7 @@
 				<touch key="back"/>
 				<actions>
 					<action function="set">tw_app_install_status=0</action>
-					<action function="page">reboot</action>
+					<action function="page">%tw_back%</action>
 				</actions>
 			</action>
 		</page>
@@ -3195,9 +3181,6 @@
 				<listitem name="{@use24clock_chk=Use 24-hour clock}">
 					<data variable="tw_military_time"/>
 				</listitem>
-				<listitem name="{@reboot_install_app_prompt_install=Prompt to install TWRP app on every reboot}">
-					<data variable="tw_app_prompt"/>
-				</listitem>
 				<listitem name="{@simact_chk=Simulate actions for theme testing}">
 					<data variable="tw_simulate_actions"/>
 				</listitem>
@@ -3610,6 +3593,13 @@
 		</page>
 
 		<page name="advanced">
+			<action>
+				<action function="checkforapp"></action>
+				<action function="page">advanced1</action>
+			</action>
+		</page>
+
+		<page name="advanced1">
 			<template name="page"/>
 
 			<text style="text_l">
@@ -3718,6 +3708,14 @@
 						<action function="page">confirm_action</action>
 					</actions>
 				</listitem>
+				<listitem name="{@reboot_install_app_hdr=Install TWRP App}">
+					<condition var1="tw_app_install_status" var2="1"/>
+					<actions>
+						<action function="set">tw_back=advanced</action>
+						<action function="set">tw_appinstall_title={@advanced_hdr=Advanced}</action>
+						<action function="page">installapp</action>
+					</actions>
+				</listitem>
 				<listitem name="{@uninstall_twrp_system_app=Uninstall TWRP App from System}">
 					<condition var1="tw_app_installed_in_system" var2="1"/>
 					<actions>
diff --git a/gui/theme/common/languages/en.xml b/gui/theme/common/languages/en.xml
index 32afd3f..d8bf2c5 100755
--- a/gui/theme/common/languages/en.xml
+++ b/gui/theme/common/languages/en.xml
@@ -119,7 +119,7 @@
 		<string name="rebooting">Rebooting...</string>
 		<string name="swipe_reboot">Swipe to Reboot</string>
 		<string name="swipe_reboot_s">   Reboot</string>
-		<string name="reboot_install_app_hdr">Install TWRP App?</string>
+		<string name="reboot_install_app_hdr">Install TWRP App</string>
 		<string name="reboot_install_app1">Would you like to install the Official TWRP App?</string>
 		<string name="reboot_install_app2">The app can check for new TWRP versions.</string>
 		<string name="reboot_install_app_prompt_install">Prompt to install TWRP app if not installed</string>
diff --git a/gui/theme/common/portrait.xml b/gui/theme/common/portrait.xml
index 9208a57..e5be1e3 100755
--- a/gui/theme/common/portrait.xml
+++ b/gui/theme/common/portrait.xml
@@ -966,7 +966,7 @@
 		<page name="rebootcheck">
 			<action>
 				<condition var1="tw_backup_system_size" op="&gt;=" var2="%tw_min_system%"/>
-				<action function="page">appcheck</action>
+				<action function="reboot">%tw_reboot_param%</action>
 			</action>
 
 			<action>
@@ -975,28 +975,6 @@
 			</action>
 		</page>
 
-		<page name="appcheck">
-			<action>
-				<condition var1="tw_app_prompt" var2="1"/>
-				<action function="checkforapp"></action>
-			</action>
-
-			<action>
-				<condition var1="tw_app_prompt" op="!=" var2="1"/>
-				<action function="reboot">%tw_reboot_param%</action>
-			</action>
-
-			<action>
-				<condition var1="tw_app_install_status" var2="1"/>
-				<action function="page">rebootapp</action>
-			</action>
-
-			<action>
-				<condition var1="tw_app_install_status" var2="2"/>
-				<action function="reboot">%tw_reboot_param%</action>
-			</action>
-		</page>
-
 		<page name="wipe">
 			<template name="page"/>
 
@@ -3003,6 +2981,13 @@
 		</page>
 
 		<page name="reboot">
+			<action>
+				<action function="checkforapp"></action>
+				<action function="page">reboot2</action>
+			</action>
+		</page>
+
+		<page name="reboot2">
 			<template name="page"/>
 
 			<text style="text_l">
@@ -3162,6 +3147,17 @@
 				</actions>
 			</button>
 
+			<button style="main_button_half_height">
+				<condition var1="tw_app_install_status" var2="1"/>
+				<placement x="%indent%" y="%row22_y%"/>
+				<text>{@reboot_install_app_hdr=Install TWRP App}</text>
+				<actions>
+					<action function="set">tw_back=reboot</action>
+					<action function="set">tw_appinstall_title={@reboot_hdr=Reboot}</action>
+					<action function="page">installapp</action>
+				</actions>
+			</button>
+
 			<action>
 				<touch key="home"/>
 				<action function="page">main</action>
@@ -3173,17 +3169,17 @@
 			</action>
 		</page>
 
-		<page name="rebootapp">
+		<page name="installapp">
 			<template name="page"/>
 
 			<text style="text_l">
 				<placement x="%col1_x_header%" y="%row3_header_y%"/>
-				<text>{@reboot_hdr=Reboot}</text>
+				<text>%tw_appinstall_title%</text>
 			</text>
 
 			<text style="text_m">
 				<placement x="%col1_x_header%" y="%row4_header_y%"/>
-				<text>{@reboot_install_app_hdr=Install TWRP App?}</text>
+				<text>{@reboot_install_app_hdr=Install TWRP App}</text>
 			</text>
 
 			<text style="text_m_accent">
@@ -3197,12 +3193,6 @@
 			</text>
 
 			<checkbox>
-				<placement x="%indent%" y="%row5_y%"/>
-				<text>{@reboot_install_app_prompt_install=Prompt to install TWRP app if not installed}</text>
-				<data variable="tw_app_prompt"/>
-			</checkbox>
-
-			<checkbox>
 				<condition var1="tw_mount_system_ro" var2="0"/>
 				<placement x="%indent%" y="%row7_y%"/>
 				<text>{@reboot_install_app_system=Install as a System App}</text>
@@ -3212,20 +3202,16 @@
 			<button style="main_button_half_height">
 				<placement x="%indent%" y="%row16_y%"/>
 				<text>{@install_cancel=Do not Install}</text>
-				<action function="reboot">%tw_reboot_param%</action>
+				<action function="page">%tw_back%</action>
 			</button>
 
 			<slider>
 				<text>{@swipe_to_install_app=Swipe to Install TWRP App}</text>
 				<actions>
-					<action function="set">tw_back=reboot</action>
 					<action function="set">tw_action=installapp</action>
 					<action function="set">tw_action_text1={@reboot_installing_app=Installing App...}</action>
 					<action function="set">tw_action_text2=</action>
-					<action function="set">tw_has_action2=1</action>
-					<action function="set">tw_action2=reboot</action>
-					<action function="set">tw_action2_param=%tw_reboot_param%</action>
-					<action function="set">tw_complete_text1={@rebooting=Rebooting...}</action>
+					<action function="set">tw_complete_text1={@successful=Successful}</action>
 					<action function="page">action_page</action>
 				</actions>
 			</slider>
@@ -3242,7 +3228,7 @@
 				<touch key="back"/>
 				<actions>
 					<action function="set">tw_app_install_status=0</action>
-					<action function="page">reboot</action>
+					<action function="page">%tw_back%</action>
 				</actions>
 			</action>
 		</page>
@@ -3369,9 +3355,6 @@
 				<listitem name="{@rev_navbar_chk=Reversed navbar layout}">
 					<data variable="tw_samsung_navbar"/>
 				</listitem>
-				<listitem name="{@reboot_install_app_prompt_install=Prompt to install TWRP app on every reboot}">
-					<data variable="tw_app_prompt"/>
-				</listitem>
 				<listitem name="{@simact_chk=Simulate actions for theme testing}">
 					<data variable="tw_simulate_actions"/>
 				</listitem>
@@ -3731,6 +3714,13 @@
 		</page>
 
 		<page name="advanced">
+			<action>
+				<action function="checkforapp"></action>
+				<action function="page">advanced1</action>
+			</action>
+		</page>
+
+		<page name="advanced1">
 			<template name="page"/>
 
 			<text style="text_l">
@@ -3840,6 +3830,14 @@
 						<action function="page">confirm_action</action>
 					</actions>
 				</listitem>
+				<listitem name="{@reboot_install_app_hdr=Install TWRP App}">
+					<condition var1="tw_app_install_status" var2="1"/>
+					<actions>
+						<action function="set">tw_back=advanced</action>
+						<action function="set">tw_appinstall_title={@advanced_hdr=Advanced}</action>
+						<action function="page">installapp</action>
+					</actions>
+				</listitem>
 				<listitem name="{@uninstall_twrp_system_app=Uninstall TWRP App from System}">
 					<condition var1="tw_app_installed_in_system" var2="1"/>
 					<actions>
diff --git a/gui/theme/common/watch.xml b/gui/theme/common/watch.xml
index cc68b1e..046707b 100755
--- a/gui/theme/common/watch.xml
+++ b/gui/theme/common/watch.xml
@@ -1234,7 +1234,7 @@
 		<page name="rebootcheck">
 			<action>
 				<condition var1="tw_backup_system_size" op="&gt;=" var2="%tw_min_system%"/>
-				<action function="page">appcheck</action>
+				<action function="reboot">%tw_reboot_param%</action>
 			</action>
 
 			<action>
@@ -1243,28 +1243,6 @@
 			</action>
 		</page>
 
-		<page name="appcheck">
-			<action>
-				<condition var1="tw_app_prompt" var2="1"/>
-				<action function="checkforapp"></action>
-			</action>
-
-			<action>
-				<condition var1="tw_app_prompt" op="!=" var2="1"/>
-				<action function="reboot">%tw_reboot_param%</action>
-			</action>
-
-			<action>
-				<condition var1="tw_app_install_status" var2="1"/>
-				<action function="page">rebootapp</action>
-			</action>
-
-			<action>
-				<condition var1="tw_app_install_status" var2="2"/>
-				<action function="reboot">%tw_reboot_param%</action>
-			</action>
-		</page>
-
 		<page name="wipe_type1">
 			<template name="page"/>
 
@@ -3371,6 +3349,13 @@
 		</page>
 
 		<page name="reboot">
+			<action>
+				<action function="checkforapp"></action>
+				<action function="page">reboot2</action>
+			</action>
+		</page>
+
+		<page name="reboot2">
 			<template name="page"/>
 
 			<template name="statusbar"/>
@@ -3465,6 +3450,7 @@
 					<action function="page">rebootcheck</action>
 				</actions>
 			</button>
+
 			<button style="main_button">
 				<condition var1="tw_edl_mode" var2="1"/>
 				<placement x="%col1_x_right%" y="%row11_y%"/>
@@ -3495,14 +3481,14 @@
 			</action>
 		</page>
 
-		<page name="rebootapp">
+		<page name="installapp">
 			<template name="page"/>
 
 			<template name="statusbar"/>
 
 			<text style="text_m">
 				<placement x="%col1_x_left%" y="%row1_header_y%"/>
-				<text>{@reboot_hdr=Reboot} &gt; {@reboot_install_app_hdr=Install TWRP App?}</text>
+				<text>%tw_appinstall_title% &gt; {@reboot_install_app_hdr=Install TWRP App}</text>
 			</text>
 
 			<text style="text_m_accent">
@@ -3516,12 +3502,6 @@
 			</text>
 
 			<checkbox>
-				<placement x="%indent%" y="%row3_y%"/>
-				<text>{@reboot_install_app_prompt_install=Prompt to install TWRP app if not installed}</text>
-				<data variable="tw_app_prompt"/>
-			</checkbox>
-
-			<checkbox>
 				<condition var1="tw_mount_system_ro" var2="0"/>
 				<placement x="%indent%" y="%row5_y%"/>
 				<text>{@reboot_install_app_system=Install as a System App}</text>
@@ -3531,9 +3511,20 @@
 			<button style="main_button_half_height">
 				<placement x="%indent%" y="%row7_y%"/>
 				<text>{@install_cancel=Do not Install}</text>
-				<action function="reboot">%tw_reboot_param%</action>
+				<action function="page">%tw_back%</action>
 			</button>
 
+			<slider>
+				<text>{@swipe_confirm=   Confirm}</text>
+				<actions>
+					<action function="set">tw_action=installapp</action>
+					<action function="set">tw_action_text1={@reboot_installing_app=Installing App...}</action>
+					<action function="set">tw_action_text2=</action>
+					<action function="set">tw_complete_text1={@successful=Successful}</action>
+					<action function="page">action_page</action>
+				</actions>
+			</slider>
+
 			<action>
 				<touch key="home"/>
 				<actions>
@@ -3546,7 +3537,7 @@
 				<touch key="back"/>
 				<actions>
 					<action function="set">tw_app_install_status=0</action>
-					<action function="page">reboot</action>
+					<action function="page">%tw_back%</action>
 				</actions>
 			</action>
 		</page>
@@ -3722,9 +3713,6 @@
 				<listitem name="{@use24clock_chk=Use 24-hour clock}">
 					<data variable="tw_military_time"/>
 				</listitem>
-				<listitem name="{@reboot_install_app_prompt_install=Prompt to install TWRP app on every reboot}">
-					<data variable="tw_app_prompt"/>
-				</listitem>
 				<listitem name="{@simact_chk=Simulate actions for theme testing}">
 					<data variable="tw_simulate_actions"/>
 				</listitem>
@@ -4232,6 +4220,13 @@
 		</page>
 
 		<page name="advanced2">
+			<action>
+				<action function="checkforapp"></action>
+				<action function="page">advanced3</action>
+			</action>
+		</page>
+
+		<page name="advanced3">
 			<template name="page"/>
 
 			<template name="statusbar"/>
@@ -4314,6 +4309,14 @@
 						<action function="page">confirm_action</action>
 					</actions>
 				</listitem>
+				<listitem name="{@reboot_install_app_hdr=Install TWRP App}">
+					<condition var1="tw_app_install_status" var2="1"/>
+					<actions>
+						<action function="set">tw_back=advanced2</action>
+						<action function="set">tw_appinstall_title={@advanced_hdr=Advanced}</action>
+						<action function="page">installapp</action>
+					</actions>
+				</listitem>
 				<listitem name="{@uninstall_twrp_system_app=Uninstall TWRP App from System}">
 					<condition var1="tw_app_installed_in_system" var2="1"/>
 					<actions>