Share menu fix
This commit is contained in:
parent
31fcfab5fc
commit
b656a5c38c
5 changed files with 26 additions and 32 deletions
|
@ -24,7 +24,7 @@
|
|||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/send_location_way_choose_title"
|
||||
android:text="@string/share_menu_title"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"/>
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/send_location_way_choose_title"
|
||||
android:text="@string/share_menu_title"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"/>
|
||||
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
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="share_clipboard">Clipboard</string>
|
||||
<string name="share_menu_title">Share location</string>
|
||||
<string name="share_common_send">Send</string>
|
||||
<string name="share_common_copy">Copy</string>
|
||||
<string name="share_geo">geo:</string>
|
||||
<string name="share_qr_code">QR-Code</string>
|
||||
<string name="favorite_category_dublicate_message">Specified category name already exists. Please define other name.</string>
|
||||
|
|
|
@ -398,7 +398,7 @@ public class MapContextMenu {
|
|||
}
|
||||
|
||||
public void buttonSharePressed() {
|
||||
ShareMenu.show(latLon, pointDescription, mapActivity);
|
||||
ShareMenu.show(latLon, nameStr, mapActivity);
|
||||
}
|
||||
|
||||
public void buttonMorePressed() {
|
||||
|
|
|
@ -5,13 +5,11 @@ import android.net.Uri;
|
|||
import android.os.Bundle;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.MapActivityActions;
|
||||
import net.osmand.plus.activities.actions.ShareDialog;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.mapcontextmenu.details.MenuController;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
@ -22,18 +20,18 @@ public class ShareMenu {
|
|||
private final MapActivity mapActivity;
|
||||
|
||||
private LatLon latLon;
|
||||
private PointDescription pointDescription;
|
||||
private String title;
|
||||
private boolean portraitMode;
|
||||
private boolean largeDevice;
|
||||
|
||||
private static final String KEY_SHARE_MENU_LATLON = "key_share_menu_latlon";
|
||||
private static final String KEY_SHARE_MENU_POINT_DESC = "key_share_menu_point_desc";
|
||||
private static final String KEY_SHARE_MENU_POINT_TITLE = "key_share_menu_point_title";
|
||||
|
||||
public enum ShareItem {
|
||||
MESSAGE(R.drawable.ic_action_aircraft, R.string.shared_string_message),
|
||||
CLIPBOARD(R.drawable.ic_action_aircraft, R.string.share_clipboard),
|
||||
GEO(R.drawable.ic_action_aircraft, R.string.share_geo),
|
||||
QR_CODE(R.drawable.ic_action_aircraft, R.string.share_qr_code);
|
||||
MESSAGE(R.drawable.ic_action_export, R.string.share_common_send),
|
||||
CLIPBOARD(R.drawable.ic_action_export, R.string.share_common_copy),
|
||||
GEO(R.drawable.ic_action_export, R.string.share_geo),
|
||||
QR_CODE(R.drawable.ic_action_export, R.string.share_qr_code);
|
||||
|
||||
final int iconResourceId;
|
||||
final int titleResourceId;
|
||||
|
@ -95,21 +93,16 @@ public class ShareMenu {
|
|||
return latLon;
|
||||
}
|
||||
|
||||
public PointDescription getPointDescription() {
|
||||
return pointDescription;
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public static void show(LatLon latLon, PointDescription pointDescription, MapActivity mapActivity) {
|
||||
public static void show(LatLon latLon, String title, MapActivity mapActivity) {
|
||||
|
||||
ShareMenu menu = new ShareMenu(mapActivity);
|
||||
|
||||
if (pointDescription == null) {
|
||||
menu.pointDescription = new PointDescription(latLon.getLatitude(), latLon.getLongitude());
|
||||
} else {
|
||||
menu.pointDescription = pointDescription;
|
||||
}
|
||||
|
||||
menu.latLon = latLon;
|
||||
menu.title = title;
|
||||
|
||||
ShareMenuFragment.showInstance(menu);
|
||||
}
|
||||
|
@ -119,7 +112,13 @@ public class ShareMenu {
|
|||
final String geoUrl = MapUtils.buildGeoUrl(latLon.getLatitude(), latLon.getLongitude(), zoom);
|
||||
final String httpUrl = "http://osmand.net/go?lat=" + ((float) latLon.getLatitude())
|
||||
+ "&lon=" + ((float) latLon.getLongitude()) + "&z=" + zoom;
|
||||
String sms = mapActivity.getString(R.string.send_location_sms_pattern, geoUrl, httpUrl);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (!Algorithms.isEmpty(title)) {
|
||||
sb.append(title).append("\n");
|
||||
}
|
||||
sb.append(mapActivity.getString(R.string.search_tabs_location)).append(": ");
|
||||
sb.append(geoUrl).append("\n").append(httpUrl);
|
||||
String sms = sb.toString();
|
||||
switch (item) {
|
||||
case MESSAGE:
|
||||
ShareDialog.sendMessage(mapActivity, sms);
|
||||
|
@ -140,23 +139,16 @@ public class ShareMenu {
|
|||
}
|
||||
}
|
||||
|
||||
public float getLandscapeWidthDp() {
|
||||
return MenuController.LANDSCAPE_WIDTH_DP;
|
||||
}
|
||||
|
||||
public void saveMenu(Bundle bundle) {
|
||||
bundle.putSerializable(KEY_SHARE_MENU_LATLON, latLon);
|
||||
bundle.putSerializable(KEY_SHARE_MENU_POINT_DESC, pointDescription);
|
||||
bundle.putString(KEY_SHARE_MENU_POINT_TITLE, title);
|
||||
}
|
||||
|
||||
public static ShareMenu restoreMenu(Bundle bundle, MapActivity mapActivity) {
|
||||
|
||||
ShareMenu menu = new ShareMenu(mapActivity);
|
||||
|
||||
Object pDescObj = bundle.getSerializable(KEY_SHARE_MENU_POINT_DESC);
|
||||
if (pDescObj != null) {
|
||||
menu.pointDescription = (PointDescription) pDescObj;
|
||||
}
|
||||
menu.title = bundle.getString(KEY_SHARE_MENU_POINT_TITLE);
|
||||
Object latLonObj = bundle.getSerializable(KEY_SHARE_MENU_LATLON);
|
||||
if (latLonObj != null) {
|
||||
menu.latLon = (LatLon) latLonObj;
|
||||
|
|
Loading…
Reference in a new issue