Merge pull request #4956 from osmandapp/PaulsBranch

Added ability to share point name (#4777)
This commit is contained in:
Alexey 2018-01-27 14:50:00 +03:00 committed by GitHub
commit 0b2d81813a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 0 deletions

View file

@ -2857,4 +2857,6 @@
<string name="winter_and_ski_renderer">Winter and ski</string>
<string name="touring_view_renderer">Touring view (contrast and details)</string>
<string name="nautical_renderer">Nautical</string>
<string name="copy_location_name">Copy Point/POI name</string>
<string name="toast_empty_name_error">Location has no name</string>
</resources>

View file

@ -216,5 +216,7 @@ public class ShareDialog {
public static void sendToClipboard(Activity activity, String text) {
ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Activity.CLIPBOARD_SERVICE);
clipboard.setText(text);
Toast.makeText(activity, R.string.copied_to_clipboard, Toast.LENGTH_LONG)
.show();
}
}

View file

@ -5,6 +5,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.support.v4.text.TextUtilsCompat;
import android.support.v4.view.ViewCompat;
import android.widget.Toast;
import net.osmand.data.LatLon;
import net.osmand.plus.R;
@ -30,6 +31,7 @@ public class ShareMenu extends BaseMenuController {
public enum ShareItem {
MESSAGE(R.drawable.ic_action_message, R.string.shared_string_send),
CLIPBOARD(R.drawable.ic_action_copy, R.string.shared_string_copy),
NAME(R.drawable.ic_action_copy, R.string.copy_location_name),
GEO(R.drawable.ic_world_globe_dark, R.string.share_geo),
QR_CODE(R.drawable.ic_action_qrcode, R.string.shared_string_qr_code);
@ -58,6 +60,7 @@ public class ShareMenu extends BaseMenuController {
List<ShareItem> list = new LinkedList<>();
list.add(ShareItem.MESSAGE);
list.add(ShareItem.CLIPBOARD);
list.add(ShareItem.NAME);
list.add(ShareItem.GEO);
list.add(ShareItem.QR_CODE);
return list;
@ -107,6 +110,15 @@ public class ShareMenu extends BaseMenuController {
case CLIPBOARD:
ShareDialog.sendToClipboard(getMapActivity(), sms);
break;
case NAME:
if (!Algorithms.isEmpty(title)) {
ShareDialog.sendToClipboard(getMapActivity(), title);
} else {
Toast.makeText(getMapActivity(),
R.string.toast_empty_name_error,
Toast.LENGTH_LONG).show();
}
break;
case GEO:
Intent mapIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(geoUrl));
getMapActivity().startActivity(mapIntent);