Permalink
Browse files

Added validation to SMS number, when sent was triggered.

Minor changes:
- Location source was fixed to be received from LocationListener.

Signed-off-by: Israel Buitron <israel.buitron@gmail.com>
  • Loading branch information...
1 parent c100dfa commit cb5adbe5b6606a9cc918b0e6383c7decd458e760 @neoriddle committed Mar 27, 2012
Showing with 16 additions and 6 deletions.
  1. +2 −0 res/values/strings.xml
  2. +14 −6 src/com/neoriddle/locationshare/io/GetGPSCurrentLocation.java
View
@@ -31,6 +31,8 @@
<string name="default_subject_for_email_alert">LocationShare Alert</string>
<string name="default_sms_emergency_number">5538274486</string>
+ <string name="not_valid_sms_number_msg">\'%s\' is not a valid SMS number</string>
+
<!-- About dialog -->
<string name="close">Close</string>
<string name="send_me_bugs_msg">If you find some error, or you have comments or suggestions, please send me an email.</string>
@@ -283,8 +283,8 @@ protected boolean isRouteDisplayed() {
}
protected void sendBySms() {
- //final Location lastLocation = overlay.getLastFix();
- final Location lastLocation = listener.getBestFix();
+ final Location lastLocation = listener.getLastFix();
+ //final Location lastLocation = listener.getBestFix();
if (lastLocation == null)
Toast.makeText(this, R.string.last_location_info_not_available, Toast.LENGTH_SHORT).show();
@@ -299,10 +299,18 @@ protected void sendBySms() {
startActivity(sendIntent);
} else {
final String smsNumber = activityPreferences.getString("sms_emergency_number", "");
- final SmsManager manager = SmsManager.getDefault();
- final PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(this, GetGPSCurrentLocation.class), 0);
- // TODO Check if send sms works (COST NEEDED)
- manager.sendTextMessage(smsNumber, null, smsMessage, pi, null);
+
+ // Validate SMS number
+ if(AndroidUtils.isValidSMSnumber(smsNumber)) {
+ final SmsManager manager = SmsManager.getDefault();
+ final PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(this, GetGPSCurrentLocation.class), 0);
+ // TODO Check if send sms works (COST NEEDED)
+ manager.sendTextMessage(smsNumber, null, smsMessage, pi, null);
+ } else {
+ Toast.makeText(this,
+ getString(R.string.not_valid_sms_number_msg, smsNumber),
+ Toast.LENGTH_SHORT).show();
+ }
}
}
}

0 comments on commit cb5adbe

Please sign in to comment.