From d87d24ba0dcb4a7c215252622cfd2bbb0f140175 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Fri, 26 Jul 2013 13:36:35 +0300 Subject: [PATCH] Add torch command --- res/values/strings.xml | 12 +++++++++--- src/ro/ieval/fonbot/Heavy.java | 14 ++++++++++++++ src/ro/ieval/fonbot/Utils.java | 7 ++++++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 6340fb0..59d92a5 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -254,7 +254,7 @@ The help command can be used to get a list of commands and help for them. Exampl Usage: flash on/off\n - Turns the flashlight on or off\n + Turns the flashlight on or off. This is unreliable. If you have the Torch app installed, use the torch command instead.\n Example: flash on @@ -453,8 +453,14 @@ The help command can be used to get a list of commands and help for them. Exampl Screencap successful Screencap failed. Remember: the screencap command requires root access - Usage: screencap filename - Takes a screen capture and saves it to the given filename as a PNG image file. + Usage: screencap filename\n + Takes a screen capture and saves it to the given filename as a PNG image file. This requires root access.\n Example: screencap /storage/sdcard0/screencap.png + + Usage: torch\n + Toggles the torch (flashlight). This is reliable but requires the Torch app. If you don\'t have the Torch app installed, use the flash command instead.\n + Example: torch + + Toggling torch state… diff --git a/src/ro/ieval/fonbot/Heavy.java b/src/ro/ieval/fonbot/Heavy.java index c5c6de7..f1afb0b 100644 --- a/src/ro/ieval/fonbot/Heavy.java +++ b/src/ro/ieval/fonbot/Heavy.java @@ -503,6 +503,9 @@ final class Heavy { case SCREENCAP: Utils.sendMessage(context, replyTo, screencap_help); break; + case TORCH: + Utils.sendMessage(context, replyTo, torch_help); + break; } } @@ -1791,4 +1794,15 @@ final class Heavy { public static void screencap(final Context context, final Address replyTo, final String filename){ new Thread(new ScreencapRunnable(context, replyTo, filename)).start(); } + + /** + * Toggle the torch state using the Torch (net.cactii.torch2) app. + * + * @param context Context instance + * @param replyTo reply Address + */ + public static void torch(final Context context, final Address replyTo){ + context.sendBroadcast(new Intent("net.cactii.flash2.TOGGLE_FLASHLIGHT")); + Utils.sendMessage(context, replyTo, toggling_torch_state); + } } diff --git a/src/ro/ieval/fonbot/Utils.java b/src/ro/ieval/fonbot/Utils.java index b29d245..0c309b0 100644 --- a/src/ro/ieval/fonbot/Utils.java +++ b/src/ro/ieval/fonbot/Utils.java @@ -86,7 +86,8 @@ public final class Utils { NEXT, PREV, BATT, CALLLOG, SMSLOG, LS, RM, CONTACTS, DISABLE, ENABLE, POLL, HANGUP, ANSWER, LAUNCH, DATA, - GPS, GLOCATION, REBOOT, NOTIFY, SCREENCAP + GPS, GLOCATION, REBOOT, NOTIFY, SCREENCAP, + TORCH } /** @@ -1031,6 +1032,10 @@ public final class Utils { Heavy.screencap(context, replyTo, args[0]); break; + + case TORCH: + Heavy.torch(context, replyTo); + break; } } -- 2.39.2