Share menu fix

This commit is contained in:
Alexey Kulish 2015-10-22 23:46:00 +03:00
parent 31fcfab5fc
commit b656a5c38c
5 changed files with 26 additions and 32 deletions

View file

@ -24,7 +24,7 @@
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/send_location_way_choose_title" android:text="@string/share_menu_title"
android:textColor="?android:textColorSecondary" android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"/> android:textSize="@dimen/default_list_text_size"/>

View file

@ -25,7 +25,7 @@
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/send_location_way_choose_title" android:text="@string/share_menu_title"
android:textColor="?android:textColorSecondary" android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"/> android:textSize="@dimen/default_list_text_size"/>

View file

@ -9,7 +9,9 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 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 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_geo">geo:</string>
<string name="share_qr_code">QR-Code</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> <string name="favorite_category_dublicate_message">Specified category name already exists. Please define other name.</string>

View file

@ -398,7 +398,7 @@ public class MapContextMenu {
} }
public void buttonSharePressed() { public void buttonSharePressed() {
ShareMenu.show(latLon, pointDescription, mapActivity); ShareMenu.show(latLon, nameStr, mapActivity);
} }
public void buttonMorePressed() { public void buttonMorePressed() {

View file

@ -5,13 +5,11 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityActions;
import net.osmand.plus.activities.actions.ShareDialog; import net.osmand.plus.activities.actions.ShareDialog;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.mapcontextmenu.details.MenuController; import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import java.util.LinkedList; import java.util.LinkedList;
@ -22,18 +20,18 @@ public class ShareMenu {
private final MapActivity mapActivity; private final MapActivity mapActivity;
private LatLon latLon; private LatLon latLon;
private PointDescription pointDescription; private String title;
private boolean portraitMode; private boolean portraitMode;
private boolean largeDevice; private boolean largeDevice;
private static final String KEY_SHARE_MENU_LATLON = "key_share_menu_latlon"; 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 { public enum ShareItem {
MESSAGE(R.drawable.ic_action_aircraft, R.string.shared_string_message), MESSAGE(R.drawable.ic_action_export, R.string.share_common_send),
CLIPBOARD(R.drawable.ic_action_aircraft, R.string.share_clipboard), CLIPBOARD(R.drawable.ic_action_export, R.string.share_common_copy),
GEO(R.drawable.ic_action_aircraft, R.string.share_geo), GEO(R.drawable.ic_action_export, R.string.share_geo),
QR_CODE(R.drawable.ic_action_aircraft, R.string.share_qr_code); QR_CODE(R.drawable.ic_action_export, R.string.share_qr_code);
final int iconResourceId; final int iconResourceId;
final int titleResourceId; final int titleResourceId;
@ -95,21 +93,16 @@ public class ShareMenu {
return latLon; return latLon;
} }
public PointDescription getPointDescription() { public String getTitle() {
return pointDescription; 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); ShareMenu menu = new ShareMenu(mapActivity);
if (pointDescription == null) {
menu.pointDescription = new PointDescription(latLon.getLatitude(), latLon.getLongitude());
} else {
menu.pointDescription = pointDescription;
}
menu.latLon = latLon; menu.latLon = latLon;
menu.title = title;
ShareMenuFragment.showInstance(menu); ShareMenuFragment.showInstance(menu);
} }
@ -119,7 +112,13 @@ public class ShareMenu {
final String geoUrl = MapUtils.buildGeoUrl(latLon.getLatitude(), latLon.getLongitude(), zoom); final String geoUrl = MapUtils.buildGeoUrl(latLon.getLatitude(), latLon.getLongitude(), zoom);
final String httpUrl = "http://osmand.net/go?lat=" + ((float) latLon.getLatitude()) final String httpUrl = "http://osmand.net/go?lat=" + ((float) latLon.getLatitude())
+ "&lon=" + ((float) latLon.getLongitude()) + "&z=" + zoom; + "&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) { switch (item) {
case MESSAGE: case MESSAGE:
ShareDialog.sendMessage(mapActivity, sms); ShareDialog.sendMessage(mapActivity, sms);
@ -140,23 +139,16 @@ public class ShareMenu {
} }
} }
public float getLandscapeWidthDp() {
return MenuController.LANDSCAPE_WIDTH_DP;
}
public void saveMenu(Bundle bundle) { public void saveMenu(Bundle bundle) {
bundle.putSerializable(KEY_SHARE_MENU_LATLON, latLon); 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) { public static ShareMenu restoreMenu(Bundle bundle, MapActivity mapActivity) {
ShareMenu menu = new ShareMenu(mapActivity); ShareMenu menu = new ShareMenu(mapActivity);
Object pDescObj = bundle.getSerializable(KEY_SHARE_MENU_POINT_DESC); menu.title = bundle.getString(KEY_SHARE_MENU_POINT_TITLE);
if (pDescObj != null) {
menu.pointDescription = (PointDescription) pDescObj;
}
Object latLonObj = bundle.getSerializable(KEY_SHARE_MENU_LATLON); Object latLonObj = bundle.getSerializable(KEY_SHARE_MENU_LATLON);
if (latLonObj != null) { if (latLonObj != null) {
menu.latLon = (LatLon) latLonObj; menu.latLon = (LatLon) latLonObj;