X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=src%2Fro%2Fieval%2Ffonbot%2FUtils.java;h=40a5e57dfbf66a93a52b772b4de9fe7201544647;hb=a5259b32f390d9adf8bca1b7a4bbb620bde11479;hp=e2e0dab2319ed86e085e98c52c91972ca8a8bcf7;hpb=251aceaaa3379c65d66a975ff9e7524f7d2f1d73;p=fonbot.git diff --git a/src/ro/ieval/fonbot/Utils.java b/src/ro/ieval/fonbot/Utils.java index e2e0dab..40a5e57 100644 --- a/src/ro/ieval/fonbot/Utils.java +++ b/src/ro/ieval/fonbot/Utils.java @@ -59,7 +59,7 @@ public final class Utils { */ @SuppressWarnings("javadoc") public static enum Command{ - TOAST, ECHO, SMS, FLASH, WIFI, + TOAST, ECHO, SMS, SMSQ, FLASH, WIFI, BLUETOOTH, DIAL, RING, SPEAK, VIBRATE, DIALOG, LOCATION, NOLOCATION, RINGER, NCFILE, PHOTO, SETNOTIFICATION, DELNOTIFICATION, SETPASSWORD, HELP, @@ -271,6 +271,22 @@ public final class Utils { sendMessage(context, address, toNonNull(context.getString(resource, args))); } + /** + * Send a confirmation message to a certain Address. A confirm message is a message that: + * 1) Confers no information (except for confirming that the command was executed). + * 2) May be dropped if the user asked so. + * + * @param context Context instance + * @param address destination Address + * @param resource String resource for the message text + * @param args format parameters for the resource + */ + public static void sendConfirmMessage(final Context context, final Address address, final int resource, final Object... args){ + final SharedPreferences sp=PreferenceManager.getDefaultSharedPreferences(context); + if(address.protocol != Protocol.SMS || !sp.getBoolean("expensive_sms", false)) + sendMessage(context, address, resource, args); + } + /** * Send a notification to the user. * @@ -447,7 +463,15 @@ public final class Utils { Heavy.help(context, replyTo, toNonNull(Command.SMS)); break; } - Heavy.sms(context, replyTo, toNonNull(args[0]), join(" ", 1, args)); + Heavy.sms(context, replyTo, toNonNull(args[0]), join(" ", 1, args), false); + break; + + case SMSQ: + if(args.length < 2){ + Heavy.help(context, replyTo, toNonNull(Command.SMSQ)); + break; + } + Heavy.sms(context, replyTo, toNonNull(args[0]), join(" ", 1, args), true); break; case FLASH: @@ -680,7 +704,7 @@ public final class Utils { PreferenceManager.getDefaultSharedPreferences(context).edit() .putString(MessageType.valueOf(args[0].toUpperCase(Locale.ENGLISH)).toString(), replyTo.toString()) .commit(); - sendMessage(context, replyTo, notification_enabled); + sendConfirmMessage(context, replyTo, notification_enabled); } catch (IllegalArgumentException e){ sendMessage(context, replyTo, messagetype_should_be_one_of, join(", ",toNonNull(MessageType.values()))); break; @@ -698,7 +722,7 @@ public final class Utils { PreferenceManager.getDefaultSharedPreferences(context).edit() .remove(MessageType.valueOf(args[0].toUpperCase(Locale.ENGLISH)).toString()) .commit(); - sendMessage(context, replyTo, notification_disabled); + sendConfirmMessage(context, replyTo, notification_disabled); } catch (IllegalArgumentException e){ sendMessage(context, replyTo, messagetype_should_be_one_of, join(", ",toNonNull(MessageType.values()))); break; @@ -718,7 +742,7 @@ public final class Utils { else Heavy.setPassword(context, replyTo, toNonNull(args[0])); } catch (SecurityException e){ - sendMessage(context, replyTo, security_exception+e.getMessage()); + sendMessage(context, replyTo, security_exception, e.getMessage()); } break;