Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
37cdb45f45
14 changed files with 346 additions and 93 deletions
|
@ -379,6 +379,11 @@
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible">
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/widget_top_bar_layout"
|
android:id="@+id/widget_top_bar_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -454,6 +459,15 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/widget_top_bar_bottom_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<!-- CENTER -->
|
<!-- CENTER -->
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
|
android:background="?attr/bg_color"
|
||||||
android:textColor="?attr/color_dialog_buttons"
|
android:textColor="?attr/color_dialog_buttons"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:textSize="@dimen/default_list_text_size"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
|
|
@ -236,6 +236,13 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/widget_top_bar_bottom_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/widget_top_bar_shadow"
|
android:id="@+id/widget_top_bar_shadow"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -180,6 +180,10 @@ public class MenuBuilder {
|
||||||
this.plainMenuItems = new LinkedList<>();
|
this.plainMenuItems = new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MapActivity getMapActivity() {
|
||||||
|
return mapActivity;
|
||||||
|
}
|
||||||
|
|
||||||
public OsmandApplication getApplication() {
|
public OsmandApplication getApplication() {
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
@ -302,7 +306,7 @@ public class MenuBuilder {
|
||||||
private void startLoadingImages(final MenuBuilder menuBuilder) {
|
private void startLoadingImages(final MenuBuilder menuBuilder) {
|
||||||
onlinePhotoCards = new ArrayList<>();
|
onlinePhotoCards = new ArrayList<>();
|
||||||
onlinePhotoCardsRow.setProgressCard();
|
onlinePhotoCardsRow.setProgressCard();
|
||||||
ImageCard.execute(new GetImageCardsTask(app, menuBuilder.getLatLon(),
|
ImageCard.execute(new GetImageCardsTask(mapActivity, menuBuilder.getLatLon(),
|
||||||
new GetImageCardsListener() {
|
new GetImageCardsListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFinish(List<ImageCard> cardList) {
|
public void onFinish(List<ImageCard> cardList) {
|
||||||
|
@ -310,7 +314,7 @@ public class MenuBuilder {
|
||||||
List<AbstractCard> cards = new ArrayList<>();
|
List<AbstractCard> cards = new ArrayList<>();
|
||||||
cards.addAll(cardList);
|
cards.addAll(cardList);
|
||||||
if (cardList.size() == 0) {
|
if (cardList.size() == 0) {
|
||||||
cards.add(new NoImagesCard(app));
|
cards.add(new NoImagesCard(mapActivity));
|
||||||
}
|
}
|
||||||
onlinePhotoCardsRow.setCards(cards);
|
onlinePhotoCardsRow.setCards(cards);
|
||||||
onlinePhotoCards = cards;
|
onlinePhotoCards = cards;
|
||||||
|
|
|
@ -5,16 +5,19 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
|
||||||
public abstract class AbstractCard {
|
public abstract class AbstractCard {
|
||||||
|
|
||||||
|
private MapActivity mapActivity;
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
protected View view;
|
protected View view;
|
||||||
|
|
||||||
public abstract int getCardLayoutId();
|
public abstract int getCardLayoutId();
|
||||||
|
|
||||||
public AbstractCard(OsmandApplication app) {
|
public AbstractCard(MapActivity mapActivity) {
|
||||||
this.app = app;
|
this.mapActivity = mapActivity;
|
||||||
|
this.app = mapActivity.getMyApplication();
|
||||||
}
|
}
|
||||||
|
|
||||||
public View build(Context ctx) {
|
public View build(Context ctx) {
|
||||||
|
@ -25,6 +28,10 @@ public abstract class AbstractCard {
|
||||||
|
|
||||||
public abstract void update();
|
public abstract void update();
|
||||||
|
|
||||||
|
public MapActivity getMapActivity() {
|
||||||
|
return mapActivity;
|
||||||
|
}
|
||||||
|
|
||||||
public OsmandApplication getMyApplication() {
|
public OsmandApplication getMyApplication() {
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import net.osmand.AndroidUtils;
|
||||||
import net.osmand.plus.LockableViewPager;
|
import net.osmand.plus.LockableViewPager;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -21,6 +22,7 @@ public class CardsRowBuilder {
|
||||||
|
|
||||||
private MenuBuilder menuBuilder;
|
private MenuBuilder menuBuilder;
|
||||||
private View view;
|
private View view;
|
||||||
|
private MapActivity mapActivity;
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private boolean addToLayout;
|
private boolean addToLayout;
|
||||||
private List<AbstractCard> cards = new ArrayList<>();
|
private List<AbstractCard> cards = new ArrayList<>();
|
||||||
|
@ -32,6 +34,7 @@ public class CardsRowBuilder {
|
||||||
this.menuBuilder = menuBuilder;
|
this.menuBuilder = menuBuilder;
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.addToLayout = addToLayout;
|
this.addToLayout = addToLayout;
|
||||||
|
this.mapActivity = menuBuilder.getMapActivity();
|
||||||
this.app = menuBuilder.getApplication();
|
this.app = menuBuilder.getApplication();
|
||||||
this.dp10 = AndroidUtils.dpToPx(app, 10f);
|
this.dp10 = AndroidUtils.dpToPx(app, 10f);
|
||||||
}
|
}
|
||||||
|
@ -60,7 +63,7 @@ public class CardsRowBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProgressCard() {
|
public void setProgressCard() {
|
||||||
setCards(new ProgressCard(app));
|
setCards(new ProgressCard(mapActivity));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build() {
|
public void build() {
|
||||||
|
|
|
@ -17,6 +17,7 @@ import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.mapillary.MapillaryContributeCard;
|
import net.osmand.plus.mapillary.MapillaryContributeCard;
|
||||||
import net.osmand.plus.mapillary.MapillaryImageCard;
|
import net.osmand.plus.mapillary.MapillaryImageCard;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -67,8 +68,8 @@ public abstract class ImageCard extends AbstractCard {
|
||||||
private float bearingDiff = Float.NaN;
|
private float bearingDiff = Float.NaN;
|
||||||
private float distance = Float.NaN;
|
private float distance = Float.NaN;
|
||||||
|
|
||||||
public ImageCard(OsmandApplication app, JSONObject imageObject) {
|
public ImageCard(MapActivity mapActivity, JSONObject imageObject) {
|
||||||
super(app);
|
super(mapActivity);
|
||||||
try {
|
try {
|
||||||
if (imageObject.has("type")) {
|
if (imageObject.has("type")) {
|
||||||
this.type = imageObject.getString("type");
|
this.type = imageObject.getString("type");
|
||||||
|
@ -105,17 +106,17 @@ public abstract class ImageCard extends AbstractCard {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ImageCard createCard(OsmandApplication app, JSONObject imageObject) {
|
private static ImageCard createCard(MapActivity mapActivity, JSONObject imageObject) {
|
||||||
ImageCard imageCard = null;
|
ImageCard imageCard = null;
|
||||||
try {
|
try {
|
||||||
if (imageObject.has("type")) {
|
if (imageObject.has("type")) {
|
||||||
String type = imageObject.getString("type");
|
String type = imageObject.getString("type");
|
||||||
if ("mapillary-photo".equals(type)) {
|
if ("mapillary-photo".equals(type)) {
|
||||||
imageCard = new MapillaryImageCard(app, imageObject);
|
imageCard = new MapillaryImageCard(mapActivity, imageObject);
|
||||||
} else if ("mapillary-contribute".equals(type)) {
|
} else if ("mapillary-contribute".equals(type)) {
|
||||||
imageCard = new MapillaryContributeCard(app, imageObject);
|
imageCard = new MapillaryContributeCard(mapActivity, imageObject);
|
||||||
} else {
|
} else {
|
||||||
imageCard = new UrlImageCard(app, imageObject);
|
imageCard = new UrlImageCard(mapActivity, imageObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
@ -257,6 +258,7 @@ public abstract class ImageCard extends AbstractCard {
|
||||||
|
|
||||||
public static class GetImageCardsTask extends AsyncTask<Void, Void, List<ImageCard>> {
|
public static class GetImageCardsTask extends AsyncTask<Void, Void, List<ImageCard>> {
|
||||||
|
|
||||||
|
private MapActivity mapActivity;
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private LatLon latLon;
|
private LatLon latLon;
|
||||||
private GetImageCardsListener listener;
|
private GetImageCardsListener listener;
|
||||||
|
@ -266,8 +268,9 @@ public abstract class ImageCard extends AbstractCard {
|
||||||
void onFinish(List<ImageCard> cardList);
|
void onFinish(List<ImageCard> cardList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GetImageCardsTask(@NonNull OsmandApplication app, LatLon latLon, GetImageCardsListener listener) {
|
public GetImageCardsTask(@NonNull MapActivity mapActivity, LatLon latLon, GetImageCardsListener listener) {
|
||||||
this.app = app;
|
this.mapActivity = mapActivity;
|
||||||
|
this.app = mapActivity.getMyApplication();
|
||||||
this.latLon = latLon;
|
this.latLon = latLon;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
@ -295,7 +298,7 @@ public abstract class ImageCard extends AbstractCard {
|
||||||
try {
|
try {
|
||||||
JSONObject imageObject = (JSONObject) images.get(i);
|
JSONObject imageObject = (JSONObject) images.get(i);
|
||||||
if (imageObject != JSONObject.NULL) {
|
if (imageObject != JSONObject.NULL) {
|
||||||
ImageCard imageCard = ImageCard.createCard(app, imageObject);
|
ImageCard imageCard = ImageCard.createCard(mapActivity, imageObject);
|
||||||
if (imageCard != null) {
|
if (imageCard != null) {
|
||||||
result.add(imageCard);
|
result.add(imageCard);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,14 @@ package net.osmand.plus.mapcontextmenu.builders.cards;
|
||||||
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.mapillary.MapillaryPlugin;
|
import net.osmand.plus.mapillary.MapillaryPlugin;
|
||||||
|
|
||||||
public class NoImagesCard extends AbstractCard {
|
public class NoImagesCard extends AbstractCard {
|
||||||
|
|
||||||
public NoImagesCard(OsmandApplication app) {
|
public NoImagesCard(MapActivity mapActivity) {
|
||||||
super(app);
|
super(mapActivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package net.osmand.plus.mapcontextmenu.builders.cards;
|
package net.osmand.plus.mapcontextmenu.builders.cards;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
|
||||||
public class ProgressCard extends AbstractCard {
|
public class ProgressCard extends AbstractCard {
|
||||||
|
|
||||||
public ProgressCard(OsmandApplication app) {
|
public ProgressCard(MapActivity mapActivity) {
|
||||||
super(app);
|
super(mapActivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,17 +6,17 @@ import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
public class UrlImageCard extends ImageCard {
|
public class UrlImageCard extends ImageCard {
|
||||||
|
|
||||||
public UrlImageCard(OsmandApplication app, JSONObject imageObject) {
|
public UrlImageCard(MapActivity mapActivity, JSONObject imageObject) {
|
||||||
super(app, imageObject);
|
super(mapActivity, imageObject);
|
||||||
this.icon = app.getIconsCache().getIcon(R.drawable.ic_action_osmand_logo, R.color.osmand_orange);
|
this.icon = getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_osmand_logo, R.color.osmand_orange);
|
||||||
if (!Algorithms.isEmpty(getImageUrl())) {
|
if (!Algorithms.isEmpty(getImageUrl())) {
|
||||||
this.onClickListener = new View.OnClickListener() {
|
this.onClickListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,16 +2,16 @@ package net.osmand.plus.mapillary;
|
||||||
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard;
|
import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
public class MapillaryContributeCard extends ImageCard {
|
public class MapillaryContributeCard extends ImageCard {
|
||||||
|
|
||||||
public MapillaryContributeCard(OsmandApplication app, JSONObject imageObject) {
|
public MapillaryContributeCard(MapActivity mapActivity, JSONObject imageObject) {
|
||||||
super(app, imageObject);
|
super(mapActivity, imageObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,23 +1,144 @@
|
||||||
package net.osmand.plus.mapillary;
|
package net.osmand.plus.mapillary;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.webkit.JavascriptInterface;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard;
|
import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard;
|
||||||
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
||||||
|
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
public class MapillaryImageCard extends ImageCard {
|
public class MapillaryImageCard extends ImageCard {
|
||||||
|
|
||||||
public MapillaryImageCard(OsmandApplication app, JSONObject imageObject) {
|
private int prevMapPosition = OsmandSettings.CENTER_CONSTANT;
|
||||||
super(app, imageObject);
|
|
||||||
this.icon = app.getIconsCache().getIcon(R.drawable.ic_logo_mapillary);
|
public MapillaryImageCard(final MapActivity mapActivity, final JSONObject imageObject) {
|
||||||
|
super(mapActivity, imageObject);
|
||||||
|
this.icon = getMyApplication().getIconsCache().getIcon(R.drawable.ic_logo_mapillary);
|
||||||
this.onClickListener = new View.OnClickListener() {
|
this.onClickListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
// todo
|
final MapillaryImageViewerController toolbarController = new MapillaryImageViewerController();
|
||||||
|
toolbarController.setTitle(getMyApplication().getString(R.string.mapillary));
|
||||||
|
toolbarController.setCloseBtnVisible(false);
|
||||||
|
toolbarController.setBottomView(getWebView(getUrl()));
|
||||||
|
toolbarController.setOnBackButtonClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getMapActivity().hideTopToolbar(toolbarController);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
toolbarController.setOnCloseToolbarListener(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
restoreMapPosition();
|
||||||
|
setSelectedImageLocation(null, Double.NaN);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
getMapActivity().getContextMenu().hideMenues();
|
||||||
|
getMapActivity().showTopToolbar(toolbarController);
|
||||||
|
setSelectedImageLocation(getLocation(), getCa());
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"})
|
||||||
|
private WebView getWebView(String url) {
|
||||||
|
final WebView webView = new WebView(view.getContext());
|
||||||
|
webView.setBackgroundColor(Color.BLACK);
|
||||||
|
//webView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
|
||||||
|
webView.setScrollContainer(false);
|
||||||
|
webView.getSettings().setJavaScriptEnabled(true);
|
||||||
|
webView.addJavascriptInterface(new WebAppInterface(view.getContext()), "Android");
|
||||||
|
boolean portrait = AndroidUiHelper.isOrientationPortrait(getMapActivity());
|
||||||
|
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||||
|
portrait ? ViewGroup.LayoutParams.MATCH_PARENT : AndroidUtils.dpToPx(getMyApplication(), 360f),
|
||||||
|
AndroidUtils.dpToPx(getMyApplication(), 200f));
|
||||||
|
webView.setLayoutParams(lp);
|
||||||
|
webView.loadUrl(url);
|
||||||
|
return webView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shiftMapPosition() {
|
||||||
|
OsmandMapTileView mapView = getMapActivity().getMapView();
|
||||||
|
if (AndroidUiHelper.isOrientationPortrait(getMapActivity())) {
|
||||||
|
if (mapView.getMapPosition() != OsmandSettings.MIDDLE_CONSTANT) {
|
||||||
|
prevMapPosition = mapView.getMapPosition();
|
||||||
|
mapView.setMapPosition(OsmandSettings.MIDDLE_CONSTANT);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mapView.setMapPositionX(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restoreMapPosition() {
|
||||||
|
if (AndroidUiHelper.isOrientationPortrait(getMapActivity())) {
|
||||||
|
getMapActivity().getMapView().setMapPosition(prevMapPosition);
|
||||||
|
} else {
|
||||||
|
getMapActivity().getMapView().setMapPositionX(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setSelectedImageLocation(LatLon latLon, double ca) {
|
||||||
|
MapillaryLayer layer = getMapActivity().getMapView().getLayerByClass(MapillaryLayer.class);
|
||||||
|
if (layer != null) {
|
||||||
|
layer.setSelectedImageLocation(latLon);
|
||||||
|
if (!Double.isNaN(ca)) {
|
||||||
|
layer.setSelectedImageCameraAngle((float) ca);
|
||||||
|
} else {
|
||||||
|
layer.setSelectedImageCameraAngle(null);
|
||||||
|
}
|
||||||
|
if (latLon != null) {
|
||||||
|
shiftMapPosition();
|
||||||
|
getMapActivity().setMapLocation(latLon.getLatitude(), latLon.getLongitude());
|
||||||
|
} else {
|
||||||
|
getMapActivity().refreshMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class WebAppInterface {
|
||||||
|
Context mContext;
|
||||||
|
|
||||||
|
WebAppInterface(Context c) {
|
||||||
|
mContext = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JavascriptInterface
|
||||||
|
public void onNodeChanged(double latitude, double longitude, double ca) {
|
||||||
|
LatLon latLon = null;
|
||||||
|
if (!Double.isNaN(latitude) && !Double.isNaN(longitude)) {
|
||||||
|
latLon = new LatLon(latitude, longitude);
|
||||||
|
}
|
||||||
|
setSelectedImageLocation(latLon, ca);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class MapillaryImageViewerController extends TopToolbarController {
|
||||||
|
|
||||||
|
MapillaryImageViewerController() {
|
||||||
|
super(TopToolbarControllerType.ONLINE_IMAGE);
|
||||||
|
setBackBtnIconIds(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_dark);
|
||||||
|
setBackBtnIconClrIds(0, 0);
|
||||||
|
setTitleTextClrIds(R.color.primary_text_dark, R.color.primary_text_dark);
|
||||||
|
setDescrTextClrIds(R.color.primary_text_dark, R.color.primary_text_dark);
|
||||||
|
setBgIds(R.color.osmand_orange, R.color.osmand_orange,
|
||||||
|
R.color.osmand_orange, R.color.osmand_orange);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,69 @@
|
||||||
package net.osmand.plus.mapillary;
|
package net.osmand.plus.mapillary;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.PorterDuffColorFilter;
|
||||||
|
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.views.MapTileLayer;
|
import net.osmand.plus.views.MapTileLayer;
|
||||||
import net.osmand.plus.views.OsmandMapLayer;
|
import net.osmand.plus.views.OsmandMapLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
|
||||||
public class MapillaryLayer extends MapTileLayer {
|
public class MapillaryLayer extends MapTileLayer {
|
||||||
|
|
||||||
|
private LatLon selectedImageLocation;
|
||||||
|
private Float selectedImageCameraAngle;
|
||||||
|
private Bitmap selectedImage;
|
||||||
|
private Bitmap headingImage;
|
||||||
|
private Paint paintIcon;
|
||||||
|
|
||||||
public MapillaryLayer() {
|
public MapillaryLayer() {
|
||||||
super(false);
|
super(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initLayer(OsmandMapTileView view) {
|
||||||
|
super.initLayer(view);
|
||||||
|
paintIcon = new Paint();
|
||||||
|
selectedImage = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_default_location);
|
||||||
|
headingImage = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pedestrian_location_view_angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LatLon getSelectedImageLocation() {
|
||||||
|
return selectedImageLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectedImageLocation(LatLon selectedImageLocation) {
|
||||||
|
this.selectedImageLocation = selectedImageLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Float getSelectedImageCameraAngle() {
|
||||||
|
return selectedImageCameraAngle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectedImageCameraAngle(Float selectedImageCameraAngle) {
|
||||||
|
this.selectedImageCameraAngle = selectedImageCameraAngle;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings drawSettings) {
|
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings drawSettings) {
|
||||||
super.onPrepareBufferImage(canvas, tileBox, drawSettings);
|
super.onPrepareBufferImage(canvas, tileBox, drawSettings);
|
||||||
// todo draw
|
if (selectedImageLocation != null) {
|
||||||
|
float x = tileBox.getPixXFromLatLon(selectedImageLocation.getLatitude(), selectedImageLocation.getLongitude());
|
||||||
|
float y = tileBox.getPixYFromLatLon(selectedImageLocation.getLatitude(), selectedImageLocation.getLongitude());
|
||||||
|
if (selectedImageCameraAngle != null) {
|
||||||
|
canvas.save();
|
||||||
|
canvas.rotate(selectedImageCameraAngle - 180, x, y);
|
||||||
|
canvas.drawBitmap(headingImage, x - headingImage.getWidth() / 2,
|
||||||
|
y - headingImage.getHeight() / 2, paintIcon);
|
||||||
|
canvas.restore();
|
||||||
|
}
|
||||||
|
canvas.drawBitmap(selectedImage, x - selectedImage.getWidth() / 2, y - selectedImage.getHeight() / 2, paintIcon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package net.osmand.plus.views.mapwidgets;
|
package net.osmand.plus.views.mapwidgets;
|
||||||
|
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
|
@ -40,6 +42,7 @@ public class MapInfoWidgetsFactory {
|
||||||
CONTEXT_MENU,
|
CONTEXT_MENU,
|
||||||
TRACK_DETAILS,
|
TRACK_DETAILS,
|
||||||
DISCOUNT,
|
DISCOUNT,
|
||||||
|
ONLINE_IMAGE,
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextInfoWidget createAltitudeControl(final MapActivity map) {
|
public TextInfoWidget createAltitudeControl(final MapActivity map) {
|
||||||
|
@ -123,6 +126,7 @@ public class MapInfoWidgetsFactory {
|
||||||
int closeBtnIconDarkId = R.drawable.ic_action_remove_dark;
|
int closeBtnIconDarkId = R.drawable.ic_action_remove_dark;
|
||||||
int closeBtnIconClrLightId = R.color.icon_color;
|
int closeBtnIconClrLightId = R.color.icon_color;
|
||||||
int closeBtnIconClrDarkId = 0;
|
int closeBtnIconClrDarkId = 0;
|
||||||
|
boolean closeBtnVisible = true;
|
||||||
|
|
||||||
int refreshBtnIconLightId = R.drawable.ic_action_refresh_dark;
|
int refreshBtnIconLightId = R.drawable.ic_action_refresh_dark;
|
||||||
int refreshBtnIconDarkId = R.drawable.ic_action_refresh_dark;
|
int refreshBtnIconDarkId = R.drawable.ic_action_refresh_dark;
|
||||||
|
@ -147,6 +151,9 @@ public class MapInfoWidgetsFactory {
|
||||||
OnClickListener onCloseButtonClickListener;
|
OnClickListener onCloseButtonClickListener;
|
||||||
OnClickListener onRefreshButtonClickListener;
|
OnClickListener onRefreshButtonClickListener;
|
||||||
|
|
||||||
|
Runnable onCloseToolbarListener;
|
||||||
|
|
||||||
|
View bottomView = null;
|
||||||
|
|
||||||
public TopToolbarController(TopToolbarControllerType type) {
|
public TopToolbarController(TopToolbarControllerType type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -160,6 +167,10 @@ public class MapInfoWidgetsFactory {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBottomView(View bottomView) {
|
||||||
|
this.bottomView = bottomView;
|
||||||
|
}
|
||||||
|
|
||||||
public void setSingleLineTitle(boolean singleLineTitle) {
|
public void setSingleLineTitle(boolean singleLineTitle) {
|
||||||
this.singleLineTitle = singleLineTitle;
|
this.singleLineTitle = singleLineTitle;
|
||||||
}
|
}
|
||||||
|
@ -205,6 +216,10 @@ public class MapInfoWidgetsFactory {
|
||||||
this.refreshBtnIconClrDarkId = refreshBtnIconClrDarkId;
|
this.refreshBtnIconClrDarkId = refreshBtnIconClrDarkId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCloseBtnVisible(boolean closeBtnVisible) {
|
||||||
|
this.closeBtnVisible = closeBtnVisible;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRefreshBtnVisible(boolean visible) {
|
public void setRefreshBtnVisible(boolean visible) {
|
||||||
this.refreshBtnVisible = visible;
|
this.refreshBtnVisible = visible;
|
||||||
}
|
}
|
||||||
|
@ -235,9 +250,14 @@ public class MapInfoWidgetsFactory {
|
||||||
this.onRefreshButtonClickListener = onRefreshButtonClickListener;
|
this.onRefreshButtonClickListener = onRefreshButtonClickListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOnCloseToolbarListener(Runnable onCloseToolbarListener) {
|
||||||
|
this.onCloseToolbarListener = onCloseToolbarListener;
|
||||||
|
}
|
||||||
|
|
||||||
public void updateToolbar(TopToolbarView view) {
|
public void updateToolbar(TopToolbarView view) {
|
||||||
TextView titleView = view.getTitleView();
|
TextView titleView = view.getTitleView();
|
||||||
TextView descrView = view.getDescrView();
|
TextView descrView = view.getDescrView();
|
||||||
|
LinearLayout bottomViewLayout = view.getBottomViewLayout();
|
||||||
if (title != null) {
|
if (title != null) {
|
||||||
titleView.setText(title);
|
titleView.setText(title);
|
||||||
view.updateVisibility(titleView, true);
|
view.updateVisibility(titleView, true);
|
||||||
|
@ -250,6 +270,13 @@ public class MapInfoWidgetsFactory {
|
||||||
} else {
|
} else {
|
||||||
view.updateVisibility(descrView, false);
|
view.updateVisibility(descrView, false);
|
||||||
}
|
}
|
||||||
|
if (bottomView != null) {
|
||||||
|
bottomViewLayout.removeAllViews();
|
||||||
|
bottomViewLayout.addView(bottomView);
|
||||||
|
view.updateVisibility(bottomViewLayout, true);
|
||||||
|
} else {
|
||||||
|
view.updateVisibility(bottomViewLayout, false);
|
||||||
|
}
|
||||||
if (view.getShadowView() != null) {
|
if (view.getShadowView() != null) {
|
||||||
view.getShadowView().setVisibility(View.VISIBLE);
|
view.getShadowView().setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
@ -262,6 +289,7 @@ public class MapInfoWidgetsFactory {
|
||||||
private TopToolbarController defaultController = new TopToolbarController(TopToolbarControllerType.CONTEXT_MENU);
|
private TopToolbarController defaultController = new TopToolbarController(TopToolbarControllerType.CONTEXT_MENU);
|
||||||
private View topbar;
|
private View topbar;
|
||||||
private View topBarLayout;
|
private View topBarLayout;
|
||||||
|
private View topBarBottomView;
|
||||||
private View topBarTitleLayout;
|
private View topBarTitleLayout;
|
||||||
private ImageButton backButton;
|
private ImageButton backButton;
|
||||||
private TextView titleView;
|
private TextView titleView;
|
||||||
|
@ -276,6 +304,7 @@ public class MapInfoWidgetsFactory {
|
||||||
|
|
||||||
topbar = map.findViewById(R.id.widget_top_bar);
|
topbar = map.findViewById(R.id.widget_top_bar);
|
||||||
topBarLayout = map.findViewById(R.id.widget_top_bar_layout);
|
topBarLayout = map.findViewById(R.id.widget_top_bar_layout);
|
||||||
|
topBarBottomView = map.findViewById(R.id.widget_top_bar_bottom_view);
|
||||||
topBarTitleLayout = map.findViewById(R.id.widget_top_bar_title_layout);
|
topBarTitleLayout = map.findViewById(R.id.widget_top_bar_title_layout);
|
||||||
backButton = (ImageButton) map.findViewById(R.id.widget_top_bar_back_button);
|
backButton = (ImageButton) map.findViewById(R.id.widget_top_bar_back_button);
|
||||||
refreshButton = (ImageButton) map.findViewById(R.id.widget_top_bar_refresh_button);
|
refreshButton = (ImageButton) map.findViewById(R.id.widget_top_bar_refresh_button);
|
||||||
|
@ -306,6 +335,10 @@ public class MapInfoWidgetsFactory {
|
||||||
return titleView;
|
return titleView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LinearLayout getBottomViewLayout() {
|
||||||
|
return (LinearLayout) topBarBottomView;
|
||||||
|
}
|
||||||
|
|
||||||
public TextView getDescrView() {
|
public TextView getDescrView() {
|
||||||
return descrView;
|
return descrView;
|
||||||
}
|
}
|
||||||
|
@ -343,6 +376,9 @@ public class MapInfoWidgetsFactory {
|
||||||
for (Iterator ctrlIter = controllers.iterator(); ctrlIter.hasNext(); ) {
|
for (Iterator ctrlIter = controllers.iterator(); ctrlIter.hasNext(); ) {
|
||||||
TopToolbarController ctrl = (TopToolbarController) ctrlIter.next();
|
TopToolbarController ctrl = (TopToolbarController) ctrlIter.next();
|
||||||
if (ctrl.getType() == controller.getType()) {
|
if (ctrl.getType() == controller.getType()) {
|
||||||
|
if (controller.onCloseToolbarListener != null) {
|
||||||
|
controller.onCloseToolbarListener.run();
|
||||||
|
}
|
||||||
ctrlIter.remove();
|
ctrlIter.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -352,6 +388,9 @@ public class MapInfoWidgetsFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeController(TopToolbarController controller) {
|
public void removeController(TopToolbarController controller) {
|
||||||
|
if (controller.onCloseToolbarListener != null) {
|
||||||
|
controller.onCloseToolbarListener.run();
|
||||||
|
}
|
||||||
controllers.remove(controller);
|
controllers.remove(controller);
|
||||||
updateColors();
|
updateColors();
|
||||||
updateInfo();
|
updateInfo();
|
||||||
|
@ -444,6 +483,12 @@ public class MapInfoWidgetsFactory {
|
||||||
} else {
|
} else {
|
||||||
titleView.setSingleLine(false);
|
titleView.setSingleLine(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (controller.closeBtnVisible && closeButton.getVisibility() == View.GONE) {
|
||||||
|
closeButton.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
closeButton.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
if (controller.refreshBtnVisible && refreshButton.getVisibility() == View.GONE) {
|
if (controller.refreshBtnVisible && refreshButton.getVisibility() == View.GONE) {
|
||||||
refreshButton.setVisibility(View.VISIBLE);
|
refreshButton.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue