nano: Add File Manager option to edit selected file
Change-Id: Ie7d940545569e6de976d2a51666b692f3fc23798
diff --git a/gui/Android.mk b/gui/Android.mk
index b49b94d..59a2624 100755
--- a/gui/Android.mk
+++ b/gui/Android.mk
@@ -113,6 +113,9 @@
ifeq ($(TW_ROUND_SCREEN), true)
LOCAL_CFLAGS += -DTW_ROUND_SCREEN
endif
+ifeq ($(TW_EXCLUDE_NANO), true)
+ LOCAL_CFLAGS += -DTW_EXCLUDE_NANO
+endif
LOCAL_C_INCLUDES += \
bionic \
diff --git a/gui/action.cpp b/gui/action.cpp
index 4783937..238327f 100755
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -242,6 +242,9 @@
ADD_ACTION(uninstalltwrpsystemapp);
ADD_ACTION(repackimage);
ADD_ACTION(fixabrecoverybootloop);
+#ifndef TW_EXCLUDE_NANO
+ ADD_ACTION(editfile);
+#endif
}
// First, get the action
@@ -2272,3 +2275,15 @@
gui_changePage("terminalcommand");
return 0;
}
+#ifndef TW_EXCLUDE_NANO
+int GUIAction::editfile(std::string arg) {
+ if (term != NULL) {
+ for (uint8_t iter = 0; iter < arg.size(); iter++)
+ term->NotifyCharInput(arg.at(iter));
+ term->NotifyCharInput(13);
+ }
+ else
+ LOGINFO("Unable to switch to Terminal\n");
+ return 0;
+}
+#endif
diff --git a/gui/objects.hpp b/gui/objects.hpp
index 48a2e89..0f2fae5 100755
--- a/gui/objects.hpp
+++ b/gui/objects.hpp
@@ -374,6 +374,9 @@
int enableadb(std::string arg);
int enablefastboot(std::string arg);
int changeterminal(std::string arg);
+#ifndef TW_EXCLUDE_NANO
+ int editfile(std::string arg);
+#endif
int simulate;
};
diff --git a/gui/theme/common/landscape.xml b/gui/theme/common/landscape.xml
index 6693108..a3437fb 100755
--- a/gui/theme/common/landscape.xml
+++ b/gui/theme/common/landscape.xml
@@ -4238,6 +4238,19 @@
</button>
<button style="main_button_half_width">
+edi <conditions>
+ <condition var1="tw_include_nano" var2="1"/>
+ <condition var1="tw_fm_isfolder" var2="0"/>
+ </conditions>
+ <placement x="%col1_x_left%" y="%row15a_y%"/>
+ <text>{@fm_edit_file=Edit File}</text>
+ <actions>
+ <action function="editfile">nano "%tw_filename1%"</action>
+ <action function="page">terminalcommand</action>
+ </actions>
+ </button>
+
+ <button style="main_button_half_width">
<placement x="%col2_x_left%" y="%row11_y%"/>
<text>{@fm_move_btn=Move}</text>
<actions>
diff --git a/gui/theme/common/languages/en.xml b/gui/theme/common/languages/en.xml
index 5d313a3..3fd485d 100755
--- a/gui/theme/common/languages/en.xml
+++ b/gui/theme/common/languages/en.xml
@@ -460,6 +460,7 @@
<string name="fm_perms">Permissions:</string>
<string name="fm_complete">File Operation Complete</string>
<string name="fm_open_terminal_btn">Open Terminal Here</string>
+ <string name="fm_edit_file">Edit File</string>
<string name="decrypt_data_hdr">Decrypt Data</string>
<string name="decrypt_data_enter_pass">Enter Password.</string>
<string name="decrypt_data_failed">Password failed, please try again!</string>
diff --git a/gui/theme/common/portrait.xml b/gui/theme/common/portrait.xml
index cd2f3be..b90902b 100755
--- a/gui/theme/common/portrait.xml
+++ b/gui/theme/common/portrait.xml
@@ -4340,6 +4340,19 @@
</text>
<button style="main_button_half_height">
+ <conditions>
+ <condition var1="tw_include_nano" var2="1"/>
+ <condition var1="tw_fm_isfolder" var2="0"/>
+ </conditions>
+ <placement x="%indent%" y="%row12a_y%"/>
+ <text>{@fm_edit_file=Edit File}</text>
+ <actions>
+ <action function="editfile">nano "%tw_filename1%"</action>
+ <action function="page">terminalcommand</action>
+ </actions>
+ </button>
+
+ <button style="main_button_half_height">
<condition var1="tw_fm_isfolder" var2="1"/>
<placement x="%center_x%" y="%row12a_y%"/>
<text>{@fm_open_terminal_btn=Open Terminal Here}</text>