summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorbigbiff <bigbiff@teamw.in>2015-01-17 22:53:12 +0100
committerDees Troy <dees_troy@teamw.in>2015-01-27 15:07:19 +0100
commit7abc5fe195cfa203d215781e2a04672cebecca1e (patch)
tree45ea351d11d26a7881441b1451d77f5cfef37ebb /gui
parentUse /twres instead of /res for theme resources (diff)
downloadandroid_bootable_recovery-7abc5fe195cfa203d215781e2a04672cebecca1e.tar
android_bootable_recovery-7abc5fe195cfa203d215781e2a04672cebecca1e.tar.gz
android_bootable_recovery-7abc5fe195cfa203d215781e2a04672cebecca1e.tar.bz2
android_bootable_recovery-7abc5fe195cfa203d215781e2a04672cebecca1e.tar.lz
android_bootable_recovery-7abc5fe195cfa203d215781e2a04672cebecca1e.tar.xz
android_bootable_recovery-7abc5fe195cfa203d215781e2a04672cebecca1e.tar.zst
android_bootable_recovery-7abc5fe195cfa203d215781e2a04672cebecca1e.zip
Diffstat (limited to 'gui')
-rw-r--r--gui/action.cpp52
-rw-r--r--gui/devices/480x854/res/ui.xml1
-rw-r--r--gui/devices/landscape/res/landscape.xml25
-rw-r--r--gui/devices/portrait/res/portrait.xml23
-rw-r--r--gui/devices/watch/res/watch.xml27
-rw-r--r--gui/objects.hpp1
6 files changed, 119 insertions, 10 deletions
diff --git a/gui/action.cpp b/gui/action.cpp
index d75843044..e7f74d48a 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -56,6 +56,7 @@ extern "C" {
#include "rapidxml.hpp"
#include "objects.hpp"
+#include "../tw_atomic.hpp"
void curtainClose(void);
@@ -169,6 +170,7 @@ GUIAction::GUIAction(xml_node<>* node)
mf["fixsu"] = &GUIAction::fixsu;
mf["startmtp"] = &GUIAction::startmtp;
mf["stopmtp"] = &GUIAction::stopmtp;
+ mf["cancelbackup"] = &GUIAction::cancelbackup;
// remember actions that run in the caller thread
for (mapFunc::const_iterator it = mf.begin(); it != mf.end(); ++it)
@@ -314,6 +316,13 @@ void GUIAction::simulate_progress_bar(void)
gui_print("Simulating actions...\n");
for (int i = 0; i < 5; i++)
{
+ if (PartitionManager.stop_backup.get_value()) {
+ DataManager::SetValue("tw_cancel_backup", 1);
+ gui_print("Backup Canceled.\n");
+ DataManager::SetValue("ui_progress", 0);
+ PartitionManager.stop_backup.set_value(0);
+ return;
+ }
usleep(500000);
DataManager::SetValue("ui_progress", i * 20);
}
@@ -1087,13 +1096,13 @@ int GUIAction::refreshsizes(std::string arg)
int GUIAction::nandroid(std::string arg)
{
- operation_start("Nandroid");
- int ret = 0;
-
if (simulate) {
DataManager::SetValue("tw_partition", "Simulation");
simulate_progress_bar();
} else {
+ operation_start("Nandroid");
+ int ret = 0;
+
if (arg == "backup") {
string Backup_Name;
DataManager::GetValue(TW_BACKUP_NAME, Backup_Name);
@@ -1103,7 +1112,6 @@ int GUIAction::nandroid(std::string arg)
else {
operation_end(1);
return -1;
-
}
DataManager::SetValue(TW_BACKUP_NAME, "(Auto Generate)");
} else if (arg == "restore") {
@@ -1112,16 +1120,42 @@ int GUIAction::nandroid(std::string arg)
ret = PartitionManager.Run_Restore(Restore_Name);
} else {
operation_end(1);
- return -1;
- }
- }
- DataManager::SetValue("tw_encrypt_backup", 0);
+ return -1;
+ }
+ DataManager::SetValue("tw_encrypt_backup", 0);
+ if (!PartitionManager.stop_backup.get_value()) {
if (ret == false)
ret = 1; // 1 for failure
else
ret = 0; // 0 for success
+ DataManager::SetValue("tw_cancel_backup", 0);
operation_end(ret);
- return 0;
+ }
+ else {
+ DataManager::SetValue("tw_cancel_backup", 1);
+ gui_print("Backup Canceled.\n");
+ ret = 0;
+ }
+ return ret;
+ }
+ return 0;
+}
+
+int GUIAction::cancelbackup(std::string arg) {
+ if (simulate) {
+ simulate_progress_bar();
+ PartitionManager.stop_backup.set_value(1);
+ operation_end(0);
+ }
+ else {
+ operation_start("Cancel Backup");
+ int op_status = PartitionManager.Cancel_Backup();
+ if (op_status != 0)
+ op_status = 1; // failure
+ operation_end(op_status);
+ }
+
+ return 0;
}
int GUIAction::fixpermissions(std::string arg)
diff --git a/gui/devices/480x854/res/ui.xml b/gui/devices/480x854/res/ui.xml
index dd7efd720..c4ce65f35 100644
--- a/gui/devices/480x854/res/ui.xml
+++ b/gui/devices/480x854/res/ui.xml
@@ -50,6 +50,7 @@
<variable name="col1_x" value="10" />
<variable name="col2_x" value="240" />
<variable name="col_center_x" value="128" />
+ <variable name="col_center_medium_x" value="183" />
<variable name="center_x" value="240" />
<variable name="row1_y" value="140" />
<variable name="row2_y" value="290" />
diff --git a/gui/devices/landscape/res/landscape.xml b/gui/devices/landscape/res/landscape.xml
index f66eb8bb6..eb6d9ddd6 100644
--- a/gui/devices/landscape/res/landscape.xml
+++ b/gui/devices/landscape/res/landscape.xml
@@ -670,7 +670,7 @@
<object type="button">
<highlight color="%highlight_color%" />
<condition var1="tw_has_cancel" var2="1" />
- <placement x="%col4_x%" y="%slider_y%" />
+ <placement x="%col_center_x%" y="%cancel_button_y%" />
<font resource="font" color="%button_text_color%" />
<text>Cancel</text>
<image resource="main_button" />
@@ -2157,6 +2157,17 @@
<object type="template" name="action_page_console" />
+ <object type="button">
+ <highlight color="%highlight_color%" />
+ <placement x="%col_center_medium_x%" y="%row3_y%" />
+ <font resource="font" color="%button_text_color%" />
+ <text>Cancel</text>
+ <image resource="medium_button" />
+ <actions>
+ <action function="cancelbackup"></action>
+ </actions>
+ </object>
+
<object type="template" name="progress_bar" />
<object type="action">
@@ -2165,6 +2176,7 @@
<object type="action">
<condition var1="tw_operation_state" var2="1" />
+ <condition var1="tw_cancel_backup" var2="0" />
<actions>
<action function="set">tw_back=backup</action>
<action function="set">tw_complete_text1=Backup Complete</action>
@@ -2173,6 +2185,17 @@
</actions>
</object>
+ <object type="action">
+ <condition var1="tw_operation_state" var2="1" />
+ <condition var1="tw_cancel_backup" var2="1" />
+ <actions>
+ <action function="set">tw_back=backup</action>
+ <action function="set">tw_complete_text1=Backup Cancelled</action>
+ <action function="set">tw_show_reboot=1</action>
+ <action function="page">action_complete</action>
+ </actions>
+ </object>
+
<object type="template" name="footer" />
</page>
diff --git a/gui/devices/portrait/res/portrait.xml b/gui/devices/portrait/res/portrait.xml
index bb8e37217..fe6167155 100644
--- a/gui/devices/portrait/res/portrait.xml
+++ b/gui/devices/portrait/res/portrait.xml
@@ -1867,6 +1867,17 @@
<object type="template" name="action_page_console" />
+ <object type="button">
+ <highlight color="%highlight_color%" />
+ <placement x="%col_center_medium_x%" y="%row4_y%" />
+ <font resource="font" color="%button_text_color%" />
+ <text>Cancel</text>
+ <image resource="medium_button" />
+ <actions>
+ <action function="cancelbackup"></action>
+ </actions>
+ </object>
+
<object type="template" name="progress_bar" />
<object type="action">
@@ -1875,6 +1886,7 @@
<object type="action">
<condition var1="tw_operation_state" var2="1" />
+ <condition var1="tw_cancel_backup" var2="0" />
<actions>
<action function="set">tw_back=backup</action>
<action function="set">tw_complete_text1=Backup Complete</action>
@@ -1882,6 +1894,17 @@
<action function="page">action_complete</action>
</actions>
</object>
+
+ <object type="action">
+ <condition var1="tw_operation_state" var2="1" />
+ <condition var1="tw_cancel_backup" var2="1" />
+ <actions>
+ <action function="set">tw_back=backup</action>
+ <action function="set">tw_complete_text1=Backup Cancelled</action>
+ <action function="set">tw_show_reboot=1</action>
+ <action function="page">action_complete</action>
+ </actions>
+ </object>
</page>
<page name="restore">
diff --git a/gui/devices/watch/res/watch.xml b/gui/devices/watch/res/watch.xml
index dc787b37c..49e172e3a 100644
--- a/gui/devices/watch/res/watch.xml
+++ b/gui/devices/watch/res/watch.xml
@@ -1859,6 +1859,21 @@
<object type="template" name="action_page_console" />
+
+
+ <object type="template" name="progress_bar" />
+
+ <object type="button">
+ <highlight color="%highlight_color%" />
+ <placement x="%col_center_medium_x%" y="%row4_y%" />
+ <font resource="font" color="%button_text_color%" />
+ <text>Cancel</text>
+ <image resource="medium_button" />
+ <actions>
+ <action function="cancelbackup"></action>
+ </actions>
+ </object>
+
<object type="template" name="progress_bar" />
<object type="action">
@@ -1867,6 +1882,7 @@
<object type="action">
<condition var1="tw_operation_state" var2="1" />
+ <condition var1="tw_cancel_backup" var2="0" />
<actions>
<action function="set">tw_back=backup</action>
<action function="set">tw_complete_text1=Backup Complete</action>
@@ -1874,6 +1890,17 @@
<action function="page">action_complete</action>
</actions>
</object>
+
+ <object type="action">
+ <condition var1="tw_operation_state" var2="1" />
+ <condition var1="tw_cancel_backup" var2="1" />
+ <actions>
+ <action function="set">tw_back=backup</action>
+ <action function="set">tw_complete_text1=Backup Cancelled</action>
+ <action function="set">tw_show_reboot=1</action>
+ <action function="page">action_complete</action>
+ </actions>
+ </object>
</page>
<page name="restore">
diff --git a/gui/objects.hpp b/gui/objects.hpp
index 99b585507..832569c1d 100644
--- a/gui/objects.hpp
+++ b/gui/objects.hpp
@@ -360,6 +360,7 @@ protected:
int startmtp(std::string arg);
int stopmtp(std::string arg);
int flashimage(std::string arg);
+ int cancelbackup(std::string arg);
int simulate;
};