Add torch command
authorMarius Gavrilescu <marius@ieval.ro>
Fri, 26 Jul 2013 10:36:35 +0000 (13:36 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Fri, 26 Jul 2013 10:36:35 +0000 (13:36 +0300)
res/values/strings.xml
src/ro/ieval/fonbot/Heavy.java
src/ro/ieval/fonbot/Utils.java

index 6340fb062413ed1944ded531a3175143ed2693e8..59d92a5d8b76d50a11f5f5dece1fb19d6db7ca38 100644 (file)
@@ -254,7 +254,7 @@ The help command can be used to get a list of commands and help for them. Exampl
     </string>
     <string name="flash_help">
         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
     </string>
     <string name="echo_help">
@@ -453,8 +453,14 @@ The help command can be used to get a list of commands and help for them. Exampl
        <string name="screencap_successful">Screencap successful</string>
        <string name="screencap_failed">Screencap failed. Remember: the screencap command requires root access</string>
        <string name="screencap_help">
-         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
        </string>
+       <string name="torch_help">
+         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
+       </string>
+       <string name="toggling_torch_state">Toggling torch stateā€¦</string>
 </resources>
index c5c6de7462450b04f5529aaf38dc6621216e7991..f1afb0b3842f4f458ea489b74a94813c8be46247 100644 (file)
@@ -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);
+       }
 }
index b29d2454a8e29fc4d0bdefd8d432fd97e867c774..0c309b0ac2e9f67742b8488e6ebbab825b4e61a9 100644 (file)
@@ -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;
                }
 
        }
This page took 0.014944 seconds and 4 git commands to generate.