Normalized digest check before installing zip

Change-Id: I5a3e82f103e7a80800be7790f1c8dc33c76413da
diff --git a/data.cpp b/data.cpp
index d7c77ab..ffb9b42 100755
--- a/data.cpp
+++ b/data.cpp
@@ -755,6 +755,7 @@
 	mPersist.SetValue(TW_GUI_SORT_ORDER, "1");
 	mPersist.SetValue(TW_RM_RF_VAR, "0");
 	mPersist.SetValue(TW_SKIP_DIGEST_CHECK_VAR, "0");
+	mPersist.SetValue(TW_SKIP_DIGEST_CHECK_ZIP_VAR, "1");
 	mPersist.SetValue(TW_SKIP_DIGEST_GENERATE_VAR, "0");
 	mPersist.SetValue(TW_SDEXT_SIZE, "0");
 	mPersist.SetValue(TW_SWAP_SIZE, "0");
diff --git a/gui/action.cpp b/gui/action.cpp
index 1212026..87e9f30 100755
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -403,7 +403,7 @@
 	if (simulate) {
 		simulate_progress_bar();
 	} else {
-		ret_val = TWinstall_zip(filename.c_str(), wipe_cache, (bool) DataManager::GetIntValue(TW_SKIP_DIGEST_CHECK_VAR));
+		ret_val = TWinstall_zip(filename.c_str(), wipe_cache, (bool) !DataManager::GetIntValue(TW_SKIP_DIGEST_CHECK_ZIP_VAR));
 		PartitionManager.Unlock_Block_Partitions();
 		// Now, check if we need to ensure TWRP remains installed...
 		struct stat st;
diff --git a/gui/theme/common/landscape.xml b/gui/theme/common/landscape.xml
index 3af7da6..3ac0d28 100755
--- a/gui/theme/common/landscape.xml
+++ b/gui/theme/common/landscape.xml
@@ -175,6 +175,15 @@
 			<font resource="font_m" spacing="%fileselector_spacing%" color="%text_color%" highlightcolor="%accent_color%"/>
 		</style>
 
+		<style name="options_listbox">
+			<highlight color="%fileselector_highlight_color%"/>
+			<fastscroll linecolor="%fileselector_linecolor%" rectcolor="%accent_color%" w="%fastscroll_w%" linew="%fastscroll_linew%" rectw="%fastscroll_rectw%" recth="%fastscroll_recth%"/>
+			<separator color="%background_color%" height="%fileselector_separatorheight%"/>
+			<dimensions lineh="%slidervalue_lineh%" linepadding="%slidervalue_padding%" sliderw="%slidervalue_sliderw%" sliderh="%slidervalue_sliderh%"/>
+			<background color="%background_color%"/>
+			<font resource="font_m" spacing="%fileselector_spacing%" color="%text_color%" highlightcolor="%accent_color%"/>
+		</style>
+
 		<style name="slider">
 			<placement x="%col2_x_right%" y="%row17a_y%"/>
 			<font resource="font_m" color="%text_color%"/>
@@ -442,24 +451,23 @@
 				<text>{@options=Options:}</text>
 			</text>
 
-			<checkbox>
-				<placement x="%col1_x_right%" y="%row9_y%"/>
-				<text>{@zip_sig_chk=Zip signature verification}</text>
-				<data variable="tw_signed_zip_verify"/>
-			</checkbox>
-
-			<checkbox>
-				<condition var1="tw_has_injecttwrp" var2="1"/>
-				<placement x="%col1_x_right%" y="%row10a_y%"/>
-				<text>{@inject_twrp_chk=Inject TWRP after install}</text>
-				<data variable="tw_inject_after_zip"/>
-			</checkbox>
-
-			<checkbox>
-				<placement x="%col1_x_right%" y="%row12_y%"/>
-				<text>{@install_reboot_chk=Reboot after installation is complete}</text>
-				<data variable="tw_install_reboot"/>
-			</checkbox>
+			<listbox style="options_listbox">
+				<placement x="%col1_x_right%" y="%row9_y%" w="%content_half_width%" h="%listbox_options_height%"/>
+				<icon selected="checkbox_true" unselected="checkbox_false"/>
+				<listitem name="{@zip_sig_chk=Zip signature verification}">
+					<data variable="tw_signed_zip_verify"/>
+				</listitem>
+				<listitem name="{@skip_digest_zip_chk=Skip Digest check before installing zip}">
+					<data variable="tw_skip_digest_check_zip"/>
+				</listitem>
+				<listitem name="{@install_reboot_chk=Reboot after installation is complete}">
+					<data variable="tw_install_reboot"/>
+				</listitem>
+				<listitem name="{@inject_twrp_chk=Inject TWRP after install}">
+					<condition var1="tw_has_injecttwrp" var2="1"/>
+					<data variable="tw_inject_after_zip"/>
+				</listitem>
+			</listbox>
 
 			<button style="main_button_half_width">
 				<placement x="%col1_x_left%" y="%row15a_y%"/>
@@ -3206,6 +3214,9 @@
 				<listitem name="{@restore_enable_digest_chk=Enable Digest verification of backup files}">
 					<data variable="tw_skip_digest_check"/>
 				</listitem>
+				<listitem name="{@skip_digest_zip_chk=Skip Digest check before installing zip}">
+					<data variable="tw_skip_digest_check_zip"/>
+				</listitem>
 				<listitem name="{@use24clock_chk=Use 24-hour clock}">
 					<data variable="tw_military_time"/>
 				</listitem>
diff --git a/gui/theme/common/languages/en.xml b/gui/theme/common/languages/en.xml
index d445adf..35b2bbe 100755
--- a/gui/theme/common/languages/en.xml
+++ b/gui/theme/common/languages/en.xml
@@ -226,6 +226,7 @@
 		<string name="enable_backup_comp_chk">Enable compression</string>
 		<string name="skip_digest_backup_chk" version="2">Skip Digest generation during backup</string>
 		<string name="disable_backup_space_chk" version="2">Disable free space check before backup</string>
+		<string name="skip_digest_zip_chk">Skip Digest check before installing zip</string>
 		<string name="current_boot_slot">Current Slot: %tw_active_slot%</string>
 		<string name="boot_slot_a">Slot A</string>
 		<string name="boot_slot_b">Slot B</string>
diff --git a/gui/theme/common/portrait.xml b/gui/theme/common/portrait.xml
index 9d47855..78677cb 100755
--- a/gui/theme/common/portrait.xml
+++ b/gui/theme/common/portrait.xml
@@ -146,6 +146,15 @@
 			<font resource="font_m" spacing="%fileselector_spacing%" color="%text_color%" highlightcolor="%accent_color%"/>
 		</style>
 
+		<style name="options_listbox">
+			<highlight color="%fileselector_highlight_color%"/>
+			<fastscroll linecolor="%fileselector_linecolor%" rectcolor="%accent_color%" w="%fastscroll_w%" linew="%fastscroll_linew%" rectw="%fastscroll_rectw%" recth="%fastscroll_recth%"/>
+			<separator color="%background_color%" height="%fileselector_separatorheight%"/>
+			<dimensions lineh="%slidervalue_lineh%" linepadding="%slidervalue_padding%" sliderw="%slidervalue_sliderw%" sliderh="%slidervalue_sliderh%"/>
+			<background color="%background_color%"/>
+			<font resource="font_m" spacing="%fileselector_spacing%" color="%text_color%" highlightcolor="%accent_color%"/>
+		</style>
+
 		<style name="slider">
 			<placement x="%center_x%" y="%row23_y%"/>
 			<font resource="font_s" color="%text_color%"/>
@@ -394,24 +403,23 @@
 				<text>%tw_file%</text>
 			</text>
 
-			<checkbox>
-				<placement x="%indent%" y="%row12_y%"/>
-				<text>{@zip_sig_chk=Zip signature verification}</text>
-				<data variable="tw_signed_zip_verify"/>
-			</checkbox>
-
-			<checkbox>
-				<placement x="%indent%" y="%row13a_y%"/>
-				<text>{@install_reboot_chk=Reboot after installation is complete}</text>
-				<data variable="tw_install_reboot"/>
-			</checkbox>
-
-			<checkbox>
-				<condition var1="tw_has_injecttwrp" var2="1"/>
-				<placement x="%indent%" y="%row15_y%"/>
-				<text>{@inject_twrp_chk=Inject TWRP after install}</text>
-				<data variable="tw_inject_after_zip"/>
-			</checkbox>
+			<listbox style="options_listbox">
+				<placement x="%indent%" y="%row12_y%" w="%content_width%" h="%listbox_options_height%"/>
+				<icon selected="checkbox_true" unselected="checkbox_false"/>
+				<listitem name="{@zip_sig_chk=Zip signature verification}">
+					<data variable="tw_signed_zip_verify"/>
+				</listitem>
+				<listitem name="{@skip_digest_zip_chk=Skip Digest check before installing zip}">
+					<data variable="tw_skip_digest_check_zip"/>
+				</listitem>
+				<listitem name="{@install_reboot_chk=Reboot after installation is complete}">
+					<data variable="tw_install_reboot"/>
+				</listitem>
+				<listitem name="{@inject_twrp_chk=Inject TWRP after install}">
+					<condition var1="tw_has_injecttwrp" var2="1"/>
+					<data variable="tw_inject_after_zip"/>
+				</listitem>
+			</listbox>
 
 			<button style="main_button_half_height">
 				<placement x="%indent%" y="%row18a_y%"/>
@@ -3377,6 +3385,9 @@
 				<listitem name="{@restore_enable_digest_chk=Enable Digest verification of backup files}">
 					<data variable="tw_skip_digest_check"/>
 				</listitem>
+				<listitem name="{@skip_digest_zip_chk=Skip Digest check before installing zip}">
+					<data variable="tw_skip_digest_check_zip"/>
+				</listitem>
 				<listitem name="{@use24clock_chk=Use 24-hour clock}">
 					<data variable="tw_military_time"/>
 				</listitem>
diff --git a/gui/theme/common/watch.xml b/gui/theme/common/watch.xml
index c12cbf8..165f329 100755
--- a/gui/theme/common/watch.xml
+++ b/gui/theme/common/watch.xml
@@ -176,6 +176,15 @@
 			<font resource="font_m" spacing="%fileselector_spacing%" color="%text_color%" highlightcolor="%accent_color%"/>
 		</style>
 
+		<style name="options_listbox">
+			<highlight color="%fileselector_highlight_color%"/>
+			<fastscroll linecolor="%fileselector_linecolor%" rectcolor="%accent_color%" w="%fastscroll_w%" linew="%fastscroll_linew%" rectw="%fastscroll_rectw%" recth="%fastscroll_recth%"/>
+			<separator color="%background_color%" height="%fileselector_separatorheight%"/>
+			<dimensions lineh="%slidervalue_lineh%" linepadding="%slidervalue_padding%" sliderw="%slidervalue_sliderw%" sliderh="%slidervalue_sliderh%"/>
+			<background color="%background_color%"/>
+			<font resource="font_m" spacing="%fileselector_spacing%" color="%text_color%" highlightcolor="%accent_color%"/>
+		</style>
+
 		<style name="slider">
 			<placement x="%center_x%" y="%slider_y%"/>
 			<font resource="font_l" color="%text_color%"/>
@@ -550,24 +559,23 @@
 				<text>{@install_zip_hdr=Install Zip} &gt; {@options_hdr=Options}</text>
 			</text>
 
-			<checkbox>
-				<placement x="%indent%" y="%row1_y%"/>
-				<text>{@zip_sig_chk=Zip file signature verification}</text>
-				<data variable="tw_signed_zip_verify"/>
-			</checkbox>
-
-			<checkbox>
-				<condition var1="tw_has_injecttwrp" var2="1"/>
-				<placement x="%indent%" y="%row2a_y%"/>
-				<text>{@inject_twrp_chk=Inject TWRP after install}</text>
-				<data variable="tw_inject_after_zip"/>
-			</checkbox>
-
-			<checkbox>
-				<placement x="%indent%" y="%row4_y%"/>
-				<text>{@install_reboot_chk=Reboot after installation is complete}</text>
-				<data variable="tw_install_reboot"/>
-			</checkbox>
+			<listbox style="options_listbox">
+				<placement x="%indent%" y="%row1_y%" w="%content_width%" h="%listbox_options_height%"/>
+				<icon selected="checkbox_true" unselected="checkbox_false"/>
+				<listitem name="{@zip_sig_chk=Zip signature verification}">
+					<data variable="tw_signed_zip_verify"/>
+				</listitem>
+				<listitem name="{@skip_digest_zip_chk=Skip Digest check before installing zip}">
+					<data variable="tw_skip_digest_check_zip"/>
+				</listitem>
+				<listitem name="{@install_reboot_chk=Reboot after installation is complete}">
+					<data variable="tw_install_reboot"/>
+				</listitem>
+				<listitem name="{@inject_twrp_chk=Inject TWRP after install}">
+					<condition var1="tw_has_injecttwrp" var2="1"/>
+					<data variable="tw_inject_after_zip"/>
+				</listitem>
+			</listbox>
 
 			<button>
 				<placement x="%col1_x_left%" y="%row11_y%"/>
@@ -3738,6 +3746,9 @@
 				<listitem name="{@restore_enable_digest_chk=Enable Digest verification of backup files}">
 					<data variable="tw_skip_digest_check"/>
 				</listitem>
+				<listitem name="{@skip_digest_zip_chk=Skip Digest check before installing zip}">
+					<data variable="tw_skip_digest_check_zip"/>
+				</listitem>
 				<listitem name="{@use24clock_chk=Use 24-hour clock}">
 					<data variable="tw_military_time"/>
 				</listitem>
diff --git a/gui/theme/landscape_hdpi/ui.xml b/gui/theme/landscape_hdpi/ui.xml
index 45aa82b..7f89443 100755
--- a/gui/theme/landscape_hdpi/ui.xml
+++ b/gui/theme/landscape_hdpi/ui.xml
@@ -199,6 +199,7 @@
 		<variable name="listbox_timezone_height" value="768"/>
 		<variable name="listbox_settings_height" value="648"/>
 		<variable name="listbox_advanced_height" value="700"/>
+		<variable name="listbox_options_height" value="304"/>
 		<variable name="fastscroll_w" value="18"/>
 		<variable name="fastscroll_linew" value="2"/>
 		<variable name="fastscroll_rectw" value="18"/>
diff --git a/gui/theme/landscape_mdpi/ui.xml b/gui/theme/landscape_mdpi/ui.xml
index 8b7b6d3..65751ee 100755
--- a/gui/theme/landscape_mdpi/ui.xml
+++ b/gui/theme/landscape_mdpi/ui.xml
@@ -199,6 +199,7 @@
 		<variable name="listbox_timezone_height" value="306"/>
 		<variable name="listbox_settings_height" value="243"/>
 		<variable name="listbox_advanced_height" value="300"/>
+		<variable name="listbox_options_height" value="110"/>
 		<variable name="fastscroll_w" value="7"/>
 		<variable name="fastscroll_linew" value="1"/>
 		<variable name="fastscroll_rectw" value="7"/>
diff --git a/gui/theme/portrait_hdpi/ui.xml b/gui/theme/portrait_hdpi/ui.xml
index abb1960..95c227a 100755
--- a/gui/theme/portrait_hdpi/ui.xml
+++ b/gui/theme/portrait_hdpi/ui.xml
@@ -203,6 +203,7 @@
 		<variable name="listbox_timezone_height" value="756"/>
 		<variable name="listbox_settings_height" value="960"/>
 		<variable name="listbox_advanced_height" value="700"/>
+		<variable name="listbox_options_height" value="384"/>
 		<variable name="fastscroll_w" value="24"/>
 		<variable name="fastscroll_linew" value="2"/>
 		<variable name="fastscroll_rectw" value="24"/>
diff --git a/gui/theme/portrait_mdpi/ui.xml b/gui/theme/portrait_mdpi/ui.xml
index 3de99ce..c2cbd44 100755
--- a/gui/theme/portrait_mdpi/ui.xml
+++ b/gui/theme/portrait_mdpi/ui.xml
@@ -203,6 +203,7 @@
 		<variable name="listbox_timezone_height" value="306"/>
 		<variable name="listbox_settings_height" value="400"/>
 		<variable name="listbox_advanced_height" value="290"/>
+		<variable name="listbox_options_height" value="160"/>
 		<variable name="fastscroll_w" value="10"/>
 		<variable name="fastscroll_linew" value="2"/>
 		<variable name="fastscroll_rectw" value="10"/>
diff --git a/gui/theme/watch_mdpi/ui.xml b/gui/theme/watch_mdpi/ui.xml
index 491de1c..2af1249 100644
--- a/gui/theme/watch_mdpi/ui.xml
+++ b/gui/theme/watch_mdpi/ui.xml
@@ -160,6 +160,7 @@
 		<variable name="partitionlist_wipe_height" value="160"/>
 		<variable name="listbox_timezone_height" value="248"/>
 		<variable name="listbox_settings_height" value="248"/>
+		<variable name="listbox_options_height" value="160"/>
 		<variable name="fastscroll_w" value="10"/>
 		<variable name="fastscroll_linew" value="1"/>
 		<variable name="fastscroll_rectw" value="10"/>
diff --git a/twrpDigestDriver.cpp b/twrpDigestDriver.cpp
index 0f8eb63..af31417 100755
--- a/twrpDigestDriver.cpp
+++ b/twrpDigestDriver.cpp
@@ -70,8 +70,8 @@
 
 	if (!TWFunc::Path_Exists(digestfile)) {
 		delete digest;
-		gui_msg(Msg(msg::kError, "no_digest_found=No digest file found for '{1}'. Please unselect Enable Digest verification to restore.")(Filename));
-		return false;
+		gui_msg(Msg(msg::kWarning, "no_digest=Skipping Digest check: no Digest file found"));
+		return true;
 	}
 
 
diff --git a/variables.h b/variables.h
index 82a02e3..f010413 100755
--- a/variables.h
+++ b/variables.h
@@ -74,6 +74,7 @@
 #define TW_FORCE_DIGEST_CHECK_VAR   "tw_force_digest_check"
 #define TW_SKIP_DIGEST_CHECK_VAR    "tw_skip_digest_check"
 #define TW_SKIP_DIGEST_GENERATE_VAR "tw_skip_digest_generate"
+#define TW_SKIP_DIGEST_CHECK_ZIP_VAR    "tw_skip_digest_check_zip"
 #define TW_SIGNED_ZIP_VERIFY_VAR    "tw_signed_zip_verify"
 #define TW_INSTALL_REBOOT_VAR       "tw_install_reboot"
 #define TW_TIME_ZONE_VAR            "tw_time_zone"