Add an option to one click flash current booted TWRP ramdisk
Change-Id: I12303696698a5feaa43401bcac9e30d5b3b99a0c
diff --git a/gui/action.cpp b/gui/action.cpp
index a623ccd..c63337c 100755
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -239,6 +239,7 @@
ADD_ACTION(installapp);
ADD_ACTION(uninstalltwrpsystemapp);
ADD_ACTION(repackimage);
+ ADD_ACTION(reflashtwrp);
ADD_ACTION(fixabrecoverybootloop);
ADD_ACTION(applycustomtwrpfolder);
#ifndef TW_EXCLUDE_NANO
@@ -2159,6 +2160,23 @@
return 0;
}
+int GUIAction::reflashtwrp(std::string arg __unused)
+{
+ int op_status = 1;
+ twrpRepacker repacker;
+
+ operation_start("Repack Image");
+ if (!simulate)
+ {
+ if (!repacker.Flash_Current_Twrp())
+ goto exit;
+ } else
+ simulate_progress_bar();
+ op_status = 0;
+exit:
+ operation_end(op_status);
+ return 0;
+}
int GUIAction::fixabrecoverybootloop(std::string arg __unused)
{
int op_status = 1;
diff --git a/gui/objects.hpp b/gui/objects.hpp
index ec550bb..098c480 100755
--- a/gui/objects.hpp
+++ b/gui/objects.hpp
@@ -372,6 +372,7 @@
int installapp(std::string arg);
int uninstalltwrpsystemapp(std::string arg);
int repackimage(std::string arg);
+ int reflashtwrp(std::string arg);
int fixabrecoverybootloop(std::string arg);
int enableadb(std::string arg);
int enablefastboot(std::string arg);
diff --git a/gui/theme/common/landscape.xml b/gui/theme/common/landscape.xml
index bf8912a..369c4d8 100755
--- a/gui/theme/common/landscape.xml
+++ b/gui/theme/common/landscape.xml
@@ -460,6 +460,13 @@
<listitem name="{@skip_digest_zip_chk=Skip Digest check before installing zip}">
<data variable="tw_skip_digest_check_zip"/>
</listitem>
+ <listitem name="{@auto_reflashtwrp_chk=Automatically Reflash TWRP after flashing a ROM}">
+ <conditions>
+ <condition var1="tw_has_boot_slots" var2="1"/>
+ <condition var1="tw_has_repack_tools" var2="1"/>
+ </conditions>
+ <data variable="tw_auto_reflashtwrp"/>
+ </listitem>
<listitem name="{@install_reboot_chk=Reboot after installation is complete}">
<data variable="tw_install_reboot"/>
</listitem>
@@ -3234,6 +3241,13 @@
<listitem name="{@unmount_sys_install=Unmount System before installing a ZIP}">
<data variable="tw_unmount_system"/>
</listitem>
+ <listitem name="{@auto_reflashtwrp_chk=Automatically Reflash TWRP after flashing a ROM}">
+ <conditions>
+ <condition var1="tw_has_boot_slots" var2="1"/>
+ <condition var1="tw_has_repack_tools" var2="1"/>
+ </conditions>
+ <data variable="tw_auto_reflashtwrp"/>
+ </listitem>
</listbox>
<checkbox>
@@ -3719,6 +3733,22 @@
<action function="page">repackselect</action>
</actions>
</listitem>
+ <listitem name="{@reflash_twrp=Flash Current TWRP}">
+ <conditions>
+ <condition var1="tw_has_boot_slots" var2="1"/>
+ <condition var1="tw_has_repack_tools" var2="1"/>
+ </conditions>
+ <actions>
+ <action function="set">tw_repack_kernel=0</action>
+ <action function="set">tw_back=advanced</action>
+ <action function="set">tw_action=reflashtwrp</action>
+ <action function="set">tw_text1={@reflash_twrp_confirm=Flash Current TWRP?}</action>
+ <action function="set">tw_action_text1={@reflashing_twrp=Flashing TWRP...}</action>
+ <action function="set">tw_complete_text1={@reflash_twrp_complete=Done flashing TWRP}</action>
+ <action function="set">tw_slider_text={@swipe_to_confirm=Swipe to Confirm}</action>
+ <action function="page">confirm_action</action>
+ </actions>
+ </listitem>
<listitem name="{@install_kernel=Install Kernel}">
<conditions>
<condition var1="tw_has_boot_slots" var2="1"/>
diff --git a/gui/theme/common/languages/en.xml b/gui/theme/common/languages/en.xml
index 1dca4f6..2ff27b2 100755
--- a/gui/theme/common/languages/en.xml
+++ b/gui/theme/common/languages/en.xml
@@ -317,6 +317,7 @@
<string name="settings_gen_s_hdr">General</string>
<string name="settings_gen_btn">General</string>
<string name="use_rmrf_chk">Use rm -rf instead of formatting</string>
+ <string name="auto_reflashtwrp_chk">Automatically Reflash TWRP after flashing a ROM</string>
<string name="use24clock_chk">Use 24-hour clock</string>
<string name="rev_navbar_chk">Reversed navbar layout</string>
<string name="simact_chk">Simulate actions for theme testing</string>
@@ -506,9 +507,15 @@
<string name="install_complete">Install Complete</string>
<string name="unpack_error">Error unpacking image.</string>
<string name="repack_error">Error repacking image.</string>
+ <string name="modified_ramdisk_error">ramdisk files have been modified, unable to create ramdisk to flash, fastboot boot twrp and try this option again or use the Install Recovery Ramdisk option.</string>
+ <string name="create_ramdisk_error">failed to create ramdisk to flash.</string>
<string name="unpacking_image">Unpacking {1}...</string>
<string name="repacking_image">Repacking {1}...</string>
<string name="repack_image_hdr">Select Image</string>
+ <string name="reflash_twrp">Flash current TWRP</string>
+ <string name="reflash_twrp_confirm">Flash current TWRP?</string>
+ <string name="reflashing_twrp">Flashing TWRP...</string>
+ <string name="reflash_twrp_complete">Done flashing TWRP</string>
<string name="fix_recovery_loop">Fix Recovery Bootloop</string>
<string name="fix_recovery_loop_confirm">Fix Recovery Bootloop?</string>
<string name="fixing_recovery_loop">Fixing Recovery Bootloop...</string>
diff --git a/gui/theme/common/portrait.xml b/gui/theme/common/portrait.xml
index 9e0fec8..3d6bce7 100755
--- a/gui/theme/common/portrait.xml
+++ b/gui/theme/common/portrait.xml
@@ -412,6 +412,13 @@
<listitem name="{@skip_digest_zip_chk=Skip Digest check before installing zip}">
<data variable="tw_skip_digest_check_zip"/>
</listitem>
+ <listitem name="{@auto_reflashtwrp_chk=Automatically Reflash TWRP after flashing a ROM}">
+ <conditions>
+ <condition var1="tw_has_boot_slots" var2="1"/>
+ <condition var1="tw_has_repack_tools" var2="1"/>
+ </conditions>
+ <data variable="tw_auto_reflashtwrp"/>
+ </listitem>
<listitem name="{@install_reboot_chk=Reboot after installation is complete}">
<data variable="tw_install_reboot"/>
</listitem>
@@ -3408,6 +3415,13 @@
<listitem name="{@unmount_sys_install=Unmount System before installing a ZIP}">
<data variable="tw_unmount_system"/>
</listitem>
+ <listitem name="{@auto_reflashtwrp_chk=Automatically Reflash TWRP after flashing a ROM}">
+ <conditions>
+ <condition var1="tw_has_boot_slots" var2="1"/>
+ <condition var1="tw_has_repack_tools" var2="1"/>
+ </conditions>
+ <data variable="tw_auto_reflashtwrp"/>
+ </listitem>
</listbox>
<button style="main_button_half_height">
@@ -3841,6 +3855,22 @@
<action function="page">repackselect</action>
</actions>
</listitem>
+ <listitem name="{@reflash_twrp=Flash Current TWRP}">
+ <conditions>
+ <condition var1="tw_has_boot_slots" var2="1"/>
+ <condition var1="tw_has_repack_tools" var2="1"/>
+ </conditions>
+ <actions>
+ <action function="set">tw_repack_kernel=0</action>
+ <action function="set">tw_back=advanced</action>
+ <action function="set">tw_action=reflashtwrp</action>
+ <action function="set">tw_text1={@reflash_twrp_confirm=Flash Current TWRP?}</action>
+ <action function="set">tw_action_text1={@reflashing_twrp=Flashing TWRP...}</action>
+ <action function="set">tw_complete_text1={@reflash_twrp_complete=Done Flashing TWRP}</action>
+ <action function="set">tw_slider_text={@swipe_to_confirm=Swipe to Confirm}</action>
+ <action function="page">confirm_action</action>
+ </actions>
+ </listitem>
<listitem name="{@install_kernel=Install Kernel}">
<conditions>
<condition var1="tw_has_boot_slots" var2="1"/>
diff --git a/gui/theme/common/watch.xml b/gui/theme/common/watch.xml
index 1b70547..060d50a 100755
--- a/gui/theme/common/watch.xml
+++ b/gui/theme/common/watch.xml
@@ -568,6 +568,13 @@
<listitem name="{@skip_digest_zip_chk=Skip Digest check before installing zip}">
<data variable="tw_skip_digest_check_zip"/>
</listitem>
+ <listitem name="{@auto_reflashtwrp_chk=Automatically Reflash TWRP after flashing a ROM}">
+ <conditions>
+ <condition var1="tw_has_boot_slots" var2="1"/>
+ <condition var1="tw_has_repack_tools" var2="1"/>
+ </conditions>
+ <data variable="tw_auto_reflashtwrp"/>
+ </listitem>
<listitem name="{@install_reboot_chk=Reboot after installation is complete}">
<data variable="tw_install_reboot"/>
</listitem>
@@ -3766,6 +3773,13 @@
<listitem name="{@unmount_sys_install=Unmount System before installing a ZIP}">
<data variable="tw_unmount_system"/>
</listitem>
+ <listitem name="{@auto_reflashtwrp_chk=Automatically Reflash TWRP after flashing a ROM}">
+ <conditions>
+ <condition var1="tw_has_boot_slots" var2="1"/>
+ <condition var1="tw_has_repack_tools" var2="1"/>
+ </conditions>
+ <data variable="tw_auto_reflashtwrp"/>
+ </listitem>
</listbox>
<action>
@@ -4320,6 +4334,22 @@
<action function="page">repackselect</action>
</actions>
</listitem>
+ <listitem name="{@reflash_twrp=Flash Current TWRP}">
+ <conditions>
+ <condition var1="tw_has_boot_slots" var2="1"/>
+ <condition var1="tw_has_repack_tools" var2="1"/>
+ </conditions>
+ <actions>
+ <action function="set">tw_repack_kernel=0</action>
+ <action function="set">tw_back=advanced</action>
+ <action function="set">tw_action=reflashtwrp</action>
+ <action function="set">tw_text1={@reflash_twrp_confirm=Flash Current TWRP?}</action>
+ <action function="set">tw_action_text1={@reflashing_twrp=Flashing TWRP...}</action>
+ <action function="set">tw_complete_text1={@reflash_twrp_complete=Done Flashing TWRP}</action>
+ <action function="set">tw_slider_text={@swipe_to_confirm=Swipe to Confirm}</action>
+ <action function="page">confirm_action</action>
+ </actions>
+ </listitem>
<listitem name="{@install_kernel=Install Kernel}">
<conditions>
<condition var1="tw_has_boot_slots" var2="1"/>