Share location only by message (this includes sms/email...)

This commit is contained in:
Victor Shcherb 2015-03-30 02:16:47 +02:00
parent d478d8f9b1
commit 02def297d8
3 changed files with 21 additions and 8 deletions

View file

@ -10,6 +10,7 @@
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="agps_info">A-GPS info</string>
<string name="shared_string_message">Message</string>
<string name="agps_data_last_downloaded">A-GPS data last downloaded: %1$s</string>
<string name="confirm_usage_speed_cameras">In many countries (Germany, France, Italy, and others) the use of speed camera warnings is not permitted by law. OsmAnd does assume any liability if you violate the law. Please click yes only if you are eligible to use this feature.</string>
<string name="welmode_download_maps">Download maps</string>

View file

@ -169,6 +169,14 @@ public class ShareDialog {
a.startActivity(Intent.createChooser(intent, a.getString(R.string.send_location)));
}
public static void sendMessage(Activity a, String msg) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, msg);
intent.setType("text/plain");
a.startActivity(Intent.createChooser(intent, a.getString(R.string.send_location)));
}
public static void sendQRCode(final Activity activity, String encodeType, Bundle encodeData, String strEncodeData) {
Intent intent = new Intent();
intent.addCategory(Intent.CATEGORY_DEFAULT);

View file

@ -34,8 +34,9 @@ public class ShareLocation extends OsmAndAction {
mapActivity = (MapActivity) activity;
AlertDialog.Builder builder = new Builder(mapActivity);
builder.setTitle(R.string.send_location_way_choose_title);
// "Email", "SMS",
builder.setItems(new String[]{
"Email", "SMS", "Clipboard", "geo:", "QR-Code"
activity.getString(R.string.shared_string_message), "Clipboard", "geo:", "QR-Code"
}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@ -48,26 +49,29 @@ public class ShareLocation extends OsmAndAction {
final String httpUrl = "http://osmand.net/go?lat=" + ((float) latitude) + "&lon=" + ((float) longitude) + "&z=" + zoom;
String sms = mapActivity.getString(R.string.send_location_sms_pattern, geoUrl, httpUrl);
if (which == 0) {
sendEmail(httpUrl, geoUrl);
sendMessage(sms);
// } else if (which == 1) {
// sendEmail(httpUrl, geoUrl);
// } else if (which == 2) {
// sendSms(sms);
} else if (which == 1) {
sendSms(sms);
} else if (which == 2) {
sendToClipboard(sms);
} else if (which == 3) {
} else if (which == 2) {
sendGeoActivity(geoUrl);
} else if (which == 4) {
} else if (which == 3) {
sendQRCode(latitude, longitude);
}
} catch (RuntimeException e) {
Toast.makeText(mapActivity, R.string.shared_string_io_error, Toast.LENGTH_SHORT).show();
}
}
});
return builder.create();
}
private void sendMessage(String sms) {
ShareDialog.sendMessage(mapActivity, sms);
}
private void sendEmail(final String httpUrl, final String geoUrl) {