Example: ring on
</string>
<string name="photo_help">
- Usage: photo hostname port\n
- Takes a photo and uploads it to <hostname>:<port>\n
- Example: photo 1.1.1.1 8888
+ Usage: photo camera hostname port\n
+ Takes a photo with the given camera and uploads it to <hostname>:<port>\n
+ The camera is a number, usually 0 for the rear camera and 1 for the front one\n
+ Example: photo 0 1.1.1.1 8888
</string>
<string name="nolocation_help">
Usage: nolocation\n
</string>
<string name="toggling_torch_state">Toggling torch stateā¦</string>
<string name="device_booted">Your device has been turned on</string>
+ <string name="cannot_parse_camera_number">Cannot parse camera number</string>
</resources>
* @param context Context instance
* @param replyTo reply Address
*/
- private static void startCamera(final Context context, final Address replyTo){
+ private static void startCamera(final Context context, final Address replyTo, final int cameraNumber){
if(camera!=null)
return;
try{
- camera=Camera.open();
+ try{
+ camera=Camera.open(cameraNumber);
+ } catch (Exception ex){
+ camera=Camera.open();
+ }
} catch (Exception e){
Utils.sendMessage(context, replyTo, cannot_grab_camera);
}
* @param on requested flashlight state
*/
public static void flash(final Context context, final Address replyTo, final boolean on){
- startCamera(context, replyTo);
+ startCamera(context, replyTo, 0);
if(camera==null)
return;
final Camera.Parameters parms=camera.getParameters();
*
* @param context Context instance
* @param replyTo reply Address
+ * @param cameraNumber camera to take photo with
* @param hostname server hostname
* @param port server port
*/
- public static void photo(final Context context, final Address replyTo, final String hostname, final int port){
- startCamera(context, replyTo);
+ public static void photo(final Context context, final Address replyTo, final int cameraNumber, final String hostname, final int port){
+ startCamera(context, replyTo, cameraNumber);
if(camera==null)
return;
final Camera.Parameters parms=camera.getParameters();
package ro.ieval.fonbot;
-import static ro.ieval.fonbot.R.string.cannot_parse_count;
-import static ro.ieval.fonbot.R.string.cannot_parse_interval;
-import static ro.ieval.fonbot.R.string.cannot_parse_min_distance;
-import static ro.ieval.fonbot.R.string.cannot_parse_min_time;
-import static ro.ieval.fonbot.R.string.cannot_parse_port;
-import static ro.ieval.fonbot.R.string.cannot_parse_provider_allowed_values_are;
-import static ro.ieval.fonbot.R.string.command_disabled;
-import static ro.ieval.fonbot.R.string.could_not_parse_argument_allowed_values_are;
-import static ro.ieval.fonbot.R.string.could_not_parse_ms;
-import static ro.ieval.fonbot.R.string.error_while_processing_command;
-import static ro.ieval.fonbot.R.string.invalid_length_allowed_values_are;
-import static ro.ieval.fonbot.R.string.invalid_ringer_mode_valid_values_are;
-import static ro.ieval.fonbot.R.string.location_tracking_is_active;
-import static ro.ieval.fonbot.R.string.messagetype_should_be_one_of;
-import static ro.ieval.fonbot.R.string.no_such_command_command_list;
-import static ro.ieval.fonbot.R.string.notification_disabled;
-import static ro.ieval.fonbot.R.string.notification_enabled;
-import static ro.ieval.fonbot.R.string.ringing;
-import static ro.ieval.fonbot.R.string.security_exception;
-import static ro.ieval.fonbot.R.string.the_polling_service_is_running;
-import static ro.ieval.fonbot.R.string.the_second_argument_to_wipe_must_be;
-import static ro.ieval.fonbot.R.string.unknown_command;
-import static ro.ieval.fonbot.R.string.wipetype_should_be_one_of;
+import static ro.ieval.fonbot.R.string.*;
import java.net.MalformedURLException;
import java.net.URL;
break;
case PHOTO:
- if(args.length!=2){
+ if(args.length!=3){
Heavy.help(context, replyTo, toNonNull(Command.PHOTO));
break;
}
+
+ final int cameraNumber;
+ try{
+ cameraNumber=Integer.parseInt(args[0]);
+ } catch (NumberFormatException e){
+ sendMessage(context, replyTo, cannot_parse_camera_number);
+ break;
+ }
+
final int photoPort;
try{
- photoPort=Integer.parseInt(args[1]);
+ photoPort=Integer.parseInt(args[2]);
} catch (NumberFormatException e){
sendMessage(context, replyTo, cannot_parse_port);
break;
}
- Heavy.photo(context, replyTo, toNonNull(args[0]), photoPort);
+ Heavy.photo(context, replyTo, cameraNumber, toNonNull(args[1]), photoPort);
break;
case SETNOTIFICATION: