forked from organicmaps/organicmaps
[android] Review fixes
This commit is contained in:
parent
6078611b4d
commit
1b68b78ab3
4 changed files with 50 additions and 20 deletions
|
@ -180,6 +180,11 @@ public class MapObject implements Parcelable
|
|||
addMetadata(types[i], values[i]);
|
||||
}
|
||||
|
||||
public boolean hasPhoneNumber()
|
||||
{
|
||||
return !TextUtils.isEmpty(getMetadata(Metadata.MetadataType.FMD_PHONE_NUMBER));
|
||||
}
|
||||
|
||||
public static boolean isOfType(@MapObjectType int type, MapObject object)
|
||||
{
|
||||
return object != null && object.getMapObjectType() == type;
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.List;
|
|||
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.routing.RoutingController;
|
||||
import com.mapswithme.util.BottomSheetHelper;
|
||||
import com.mapswithme.util.ThemeUtils;
|
||||
|
||||
|
@ -199,11 +200,30 @@ final class PlacePageButtons
|
|||
int to = res.indexOf(Item.ROUTE_TO);
|
||||
if (to > from && to >= MAX_BUTTONS)
|
||||
Collections.swap(res, from, to);
|
||||
|
||||
preserveNavigationButtons(res, Item.CALL);
|
||||
preserveNavigationButtons(res, Item.BOOKING);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private void preserveNavigationButtons(@NonNull List<Item> items, @NonNull Item itemToShift)
|
||||
{
|
||||
if (!RoutingController.get().isNavigating() && !RoutingController.get().isPlanning())
|
||||
return;
|
||||
|
||||
int pos = items.indexOf(itemToShift);
|
||||
if (pos > -1)
|
||||
{
|
||||
items.remove(pos);
|
||||
items.add(MAX_BUTTONS, itemToShift);
|
||||
int to = items.indexOf(Item.ROUTE_TO);
|
||||
items.remove(Item.ROUTE_FROM);
|
||||
items.add(to + 1, Item.ROUTE_FROM);
|
||||
}
|
||||
}
|
||||
|
||||
private void showPopup(final List<Item> buttons)
|
||||
{
|
||||
BottomSheetHelper.Builder bs = new BottomSheetHelper.Builder(mPlacePage.getActivity());
|
||||
|
|
|
@ -446,7 +446,7 @@ public class PlacePageView extends RelativeLayout
|
|||
break;
|
||||
|
||||
case CALL:
|
||||
callPhone();
|
||||
Utils.callPhone(getContext(), mTvPhone.getText().toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1159,7 +1159,7 @@ public class PlacePageView extends RelativeLayout
|
|||
}
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(mMapObject.getMetadata(Metadata.MetadataType.FMD_PHONE_NUMBER)))
|
||||
if (mMapObject.hasPhoneNumber())
|
||||
buttons.add(PlacePageButtons.Item.CALL);
|
||||
|
||||
buttons.add(PlacePageButtons.Item.BOOKMARK);
|
||||
|
@ -1317,7 +1317,7 @@ public class PlacePageView extends RelativeLayout
|
|||
refreshLatLon();
|
||||
break;
|
||||
case R.id.ll__place_phone:
|
||||
callPhone();
|
||||
Utils.callPhone(getContext(), mTvPhone.getText().toString());
|
||||
break;
|
||||
case R.id.ll__place_website:
|
||||
followUrl(mTvWebsite.getText().toString());
|
||||
|
@ -1332,10 +1332,7 @@ public class PlacePageView extends RelativeLayout
|
|||
showBigDirection();
|
||||
break;
|
||||
case R.id.ll__place_email:
|
||||
Intent intent;
|
||||
intent = new Intent(Intent.ACTION_SENDTO);
|
||||
intent.setData(Utils.buildMailUri(mTvEmail.getText().toString(), "", ""));
|
||||
getContext().startActivity(intent);
|
||||
Utils.sendTo(getContext(), mTvEmail.getText().toString());
|
||||
break;
|
||||
case R.id.tv__bookmark_edit:
|
||||
Bookmark bookmark = (Bookmark) mMapObject;
|
||||
|
@ -1364,19 +1361,6 @@ public class PlacePageView extends RelativeLayout
|
|||
}
|
||||
}
|
||||
|
||||
private void callPhone()
|
||||
{
|
||||
Intent intent = new Intent(Intent.ACTION_DIAL);
|
||||
intent.setData(Uri.parse("tel:" + mTvPhone.getText()));
|
||||
try
|
||||
{
|
||||
getContext().startActivity(intent);
|
||||
} catch (ActivityNotFoundException e)
|
||||
{
|
||||
AlohaHelper.logException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void followUrl(String url)
|
||||
{
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
|
|
|
@ -429,4 +429,25 @@ public class Utils
|
|||
}
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void sendTo(@NonNull Context context, @NonNull String email)
|
||||
{
|
||||
Intent intent = new Intent(Intent.ACTION_SENDTO);
|
||||
intent.setData(Utils.buildMailUri(email, "", ""));
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void callPhone(@NonNull Context context, @NonNull String phone)
|
||||
{
|
||||
Intent intent = new Intent(Intent.ACTION_DIAL);
|
||||
intent.setData(Uri.parse("tel:" + phone));
|
||||
try
|
||||
{
|
||||
context.startActivity(intent);
|
||||
}
|
||||
catch (ActivityNotFoundException e)
|
||||
{
|
||||
AlohaHelper.logException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue