Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
37cdb45f45
14 changed files with 346 additions and 93 deletions
|
@ -380,78 +380,92 @@
|
|||
tools:visibility="visible">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/widget_top_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/dashboard_map_toolbar"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/widget_top_bar_back_button"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="top"
|
||||
android:contentDescription="@string/back_to_search"
|
||||
android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"/>
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/widget_top_bar_title_layout"
|
||||
android:layout_width="0dp"
|
||||
android:id="@+id/widget_top_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingTop="10dp">
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/dashboard_map_toolbar"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/widget_top_bar_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@null"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:lines="1"
|
||||
android:singleLine="true"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/abc_text_size_medium_material"
|
||||
tools:text="OsmAnd+ 50% discount"/>
|
||||
<ImageButton
|
||||
android:id="@+id/widget_top_bar_back_button"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="top"
|
||||
android:contentDescription="@string/back_to_search"
|
||||
android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/widget_top_bar_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@null"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
android:visibility="gone"
|
||||
tools:text="New version of OsmAnd+ with 50% discount"/>
|
||||
<LinearLayout
|
||||
android:id="@+id/widget_top_bar_title_layout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingTop="10dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/widget_top_bar_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@null"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:lines="1"
|
||||
android:singleLine="true"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/abc_text_size_medium_material"
|
||||
tools:text="OsmAnd+ 50% discount"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/widget_top_bar_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@null"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
android:visibility="gone"
|
||||
tools:text="New version of OsmAnd+ with 50% discount"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/widget_top_bar_refresh_button"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="top"
|
||||
android:contentDescription="@string/shared_string_refresh"
|
||||
android:src="@drawable/ic_action_refresh_dark"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/widget_top_bar_close_button"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="top"
|
||||
android:contentDescription="@string/shared_string_close"
|
||||
android:src="@drawable/ic_action_remove_dark"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/widget_top_bar_refresh_button"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="top"
|
||||
android:contentDescription="@string/shared_string_refresh"
|
||||
android:src="@drawable/ic_action_refresh_dark"
|
||||
<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"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/widget_top_bar_close_button"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="top"
|
||||
android:contentDescription="@string/shared_string_close"
|
||||
android:src="@drawable/ic_action_remove_dark"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:padding="16dp"
|
||||
android:background="?attr/bg_color"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
android:visibility="gone"
|
||||
|
|
|
@ -236,6 +236,13 @@
|
|||
|
||||
</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
|
||||
android:id="@+id/widget_top_bar_shadow"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -180,6 +180,10 @@ public class MenuBuilder {
|
|||
this.plainMenuItems = new LinkedList<>();
|
||||
}
|
||||
|
||||
public MapActivity getMapActivity() {
|
||||
return mapActivity;
|
||||
}
|
||||
|
||||
public OsmandApplication getApplication() {
|
||||
return app;
|
||||
}
|
||||
|
@ -302,7 +306,7 @@ public class MenuBuilder {
|
|||
private void startLoadingImages(final MenuBuilder menuBuilder) {
|
||||
onlinePhotoCards = new ArrayList<>();
|
||||
onlinePhotoCardsRow.setProgressCard();
|
||||
ImageCard.execute(new GetImageCardsTask(app, menuBuilder.getLatLon(),
|
||||
ImageCard.execute(new GetImageCardsTask(mapActivity, menuBuilder.getLatLon(),
|
||||
new GetImageCardsListener() {
|
||||
@Override
|
||||
public void onFinish(List<ImageCard> cardList) {
|
||||
|
@ -310,7 +314,7 @@ public class MenuBuilder {
|
|||
List<AbstractCard> cards = new ArrayList<>();
|
||||
cards.addAll(cardList);
|
||||
if (cardList.size() == 0) {
|
||||
cards.add(new NoImagesCard(app));
|
||||
cards.add(new NoImagesCard(mapActivity));
|
||||
}
|
||||
onlinePhotoCardsRow.setCards(cards);
|
||||
onlinePhotoCards = cards;
|
||||
|
|
|
@ -5,16 +5,19 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
public abstract class AbstractCard {
|
||||
|
||||
private MapActivity mapActivity;
|
||||
private OsmandApplication app;
|
||||
protected View view;
|
||||
|
||||
public abstract int getCardLayoutId();
|
||||
|
||||
public AbstractCard(OsmandApplication app) {
|
||||
this.app = app;
|
||||
public AbstractCard(MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
this.app = mapActivity.getMyApplication();
|
||||
}
|
||||
|
||||
public View build(Context ctx) {
|
||||
|
@ -25,6 +28,10 @@ public abstract class AbstractCard {
|
|||
|
||||
public abstract void update();
|
||||
|
||||
public MapActivity getMapActivity() {
|
||||
return mapActivity;
|
||||
}
|
||||
|
||||
public OsmandApplication getMyApplication() {
|
||||
return app;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.osmand.AndroidUtils;
|
|||
import net.osmand.plus.LockableViewPager;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -21,6 +22,7 @@ public class CardsRowBuilder {
|
|||
|
||||
private MenuBuilder menuBuilder;
|
||||
private View view;
|
||||
private MapActivity mapActivity;
|
||||
private OsmandApplication app;
|
||||
private boolean addToLayout;
|
||||
private List<AbstractCard> cards = new ArrayList<>();
|
||||
|
@ -32,6 +34,7 @@ public class CardsRowBuilder {
|
|||
this.menuBuilder = menuBuilder;
|
||||
this.view = view;
|
||||
this.addToLayout = addToLayout;
|
||||
this.mapActivity = menuBuilder.getMapActivity();
|
||||
this.app = menuBuilder.getApplication();
|
||||
this.dp10 = AndroidUtils.dpToPx(app, 10f);
|
||||
}
|
||||
|
@ -60,7 +63,7 @@ public class CardsRowBuilder {
|
|||
}
|
||||
|
||||
public void setProgressCard() {
|
||||
setCards(new ProgressCard(app));
|
||||
setCards(new ProgressCard(mapActivity));
|
||||
}
|
||||
|
||||
public void build() {
|
||||
|
|
|
@ -17,6 +17,7 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapillary.MapillaryContributeCard;
|
||||
import net.osmand.plus.mapillary.MapillaryImageCard;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -67,8 +68,8 @@ public abstract class ImageCard extends AbstractCard {
|
|||
private float bearingDiff = Float.NaN;
|
||||
private float distance = Float.NaN;
|
||||
|
||||
public ImageCard(OsmandApplication app, JSONObject imageObject) {
|
||||
super(app);
|
||||
public ImageCard(MapActivity mapActivity, JSONObject imageObject) {
|
||||
super(mapActivity);
|
||||
try {
|
||||
if (imageObject.has("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;
|
||||
try {
|
||||
if (imageObject.has("type")) {
|
||||
String type = imageObject.getString("type");
|
||||
if ("mapillary-photo".equals(type)) {
|
||||
imageCard = new MapillaryImageCard(app, imageObject);
|
||||
imageCard = new MapillaryImageCard(mapActivity, imageObject);
|
||||
} else if ("mapillary-contribute".equals(type)) {
|
||||
imageCard = new MapillaryContributeCard(app, imageObject);
|
||||
imageCard = new MapillaryContributeCard(mapActivity, imageObject);
|
||||
} else {
|
||||
imageCard = new UrlImageCard(app, imageObject);
|
||||
imageCard = new UrlImageCard(mapActivity, imageObject);
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
|
@ -257,6 +258,7 @@ public abstract class ImageCard extends AbstractCard {
|
|||
|
||||
public static class GetImageCardsTask extends AsyncTask<Void, Void, List<ImageCard>> {
|
||||
|
||||
private MapActivity mapActivity;
|
||||
private OsmandApplication app;
|
||||
private LatLon latLon;
|
||||
private GetImageCardsListener listener;
|
||||
|
@ -266,8 +268,9 @@ public abstract class ImageCard extends AbstractCard {
|
|||
void onFinish(List<ImageCard> cardList);
|
||||
}
|
||||
|
||||
public GetImageCardsTask(@NonNull OsmandApplication app, LatLon latLon, GetImageCardsListener listener) {
|
||||
this.app = app;
|
||||
public GetImageCardsTask(@NonNull MapActivity mapActivity, LatLon latLon, GetImageCardsListener listener) {
|
||||
this.mapActivity = mapActivity;
|
||||
this.app = mapActivity.getMyApplication();
|
||||
this.latLon = latLon;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
@ -295,7 +298,7 @@ public abstract class ImageCard extends AbstractCard {
|
|||
try {
|
||||
JSONObject imageObject = (JSONObject) images.get(i);
|
||||
if (imageObject != JSONObject.NULL) {
|
||||
ImageCard imageCard = ImageCard.createCard(app, imageObject);
|
||||
ImageCard imageCard = ImageCard.createCard(mapActivity, imageObject);
|
||||
if (imageCard != null) {
|
||||
result.add(imageCard);
|
||||
}
|
||||
|
|
|
@ -2,14 +2,14 @@ package net.osmand.plus.mapcontextmenu.builders.cards;
|
|||
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapillary.MapillaryPlugin;
|
||||
|
||||
public class NoImagesCard extends AbstractCard {
|
||||
|
||||
public NoImagesCard(OsmandApplication app) {
|
||||
super(app);
|
||||
public NoImagesCard(MapActivity mapActivity) {
|
||||
super(mapActivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package net.osmand.plus.mapcontextmenu.builders.cards;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
public class ProgressCard extends AbstractCard {
|
||||
|
||||
public ProgressCard(OsmandApplication app) {
|
||||
super(app);
|
||||
public ProgressCard(MapActivity mapActivity) {
|
||||
super(mapActivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,17 +6,17 @@ import android.view.View;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class UrlImageCard extends ImageCard {
|
||||
|
||||
public UrlImageCard(OsmandApplication app, JSONObject imageObject) {
|
||||
super(app, imageObject);
|
||||
this.icon = app.getIconsCache().getIcon(R.drawable.ic_action_osmand_logo, R.color.osmand_orange);
|
||||
public UrlImageCard(MapActivity mapActivity, JSONObject imageObject) {
|
||||
super(mapActivity, imageObject);
|
||||
this.icon = getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_osmand_logo, R.color.osmand_orange);
|
||||
if (!Algorithms.isEmpty(getImageUrl())) {
|
||||
this.onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -2,16 +2,16 @@ package net.osmand.plus.mapillary;
|
|||
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class MapillaryContributeCard extends ImageCard {
|
||||
|
||||
public MapillaryContributeCard(OsmandApplication app, JSONObject imageObject) {
|
||||
super(app, imageObject);
|
||||
public MapillaryContributeCard(MapActivity mapActivity, JSONObject imageObject) {
|
||||
super(mapActivity, imageObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,23 +1,144 @@
|
|||
package net.osmand.plus.mapillary;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
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.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
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;
|
||||
|
||||
public class MapillaryImageCard extends ImageCard {
|
||||
|
||||
public MapillaryImageCard(OsmandApplication app, JSONObject imageObject) {
|
||||
super(app, imageObject);
|
||||
this.icon = app.getIconsCache().getIcon(R.drawable.ic_logo_mapillary);
|
||||
private int prevMapPosition = OsmandSettings.CENTER_CONSTANT;
|
||||
|
||||
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() {
|
||||
@Override
|
||||
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;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
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.plus.R;
|
||||
import net.osmand.plus.views.MapTileLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
||||
public class MapillaryLayer extends MapTileLayer {
|
||||
|
||||
private LatLon selectedImageLocation;
|
||||
private Float selectedImageCameraAngle;
|
||||
private Bitmap selectedImage;
|
||||
private Bitmap headingImage;
|
||||
private Paint paintIcon;
|
||||
|
||||
public MapillaryLayer() {
|
||||
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
|
||||
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings 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;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.Location;
|
||||
|
@ -40,6 +42,7 @@ public class MapInfoWidgetsFactory {
|
|||
CONTEXT_MENU,
|
||||
TRACK_DETAILS,
|
||||
DISCOUNT,
|
||||
ONLINE_IMAGE,
|
||||
}
|
||||
|
||||
public TextInfoWidget createAltitudeControl(final MapActivity map) {
|
||||
|
@ -123,6 +126,7 @@ public class MapInfoWidgetsFactory {
|
|||
int closeBtnIconDarkId = R.drawable.ic_action_remove_dark;
|
||||
int closeBtnIconClrLightId = R.color.icon_color;
|
||||
int closeBtnIconClrDarkId = 0;
|
||||
boolean closeBtnVisible = true;
|
||||
|
||||
int refreshBtnIconLightId = R.drawable.ic_action_refresh_dark;
|
||||
int refreshBtnIconDarkId = R.drawable.ic_action_refresh_dark;
|
||||
|
@ -147,6 +151,9 @@ public class MapInfoWidgetsFactory {
|
|||
OnClickListener onCloseButtonClickListener;
|
||||
OnClickListener onRefreshButtonClickListener;
|
||||
|
||||
Runnable onCloseToolbarListener;
|
||||
|
||||
View bottomView = null;
|
||||
|
||||
public TopToolbarController(TopToolbarControllerType type) {
|
||||
this.type = type;
|
||||
|
@ -160,6 +167,10 @@ public class MapInfoWidgetsFactory {
|
|||
this.title = title;
|
||||
}
|
||||
|
||||
public void setBottomView(View bottomView) {
|
||||
this.bottomView = bottomView;
|
||||
}
|
||||
|
||||
public void setSingleLineTitle(boolean singleLineTitle) {
|
||||
this.singleLineTitle = singleLineTitle;
|
||||
}
|
||||
|
@ -205,6 +216,10 @@ public class MapInfoWidgetsFactory {
|
|||
this.refreshBtnIconClrDarkId = refreshBtnIconClrDarkId;
|
||||
}
|
||||
|
||||
public void setCloseBtnVisible(boolean closeBtnVisible) {
|
||||
this.closeBtnVisible = closeBtnVisible;
|
||||
}
|
||||
|
||||
public void setRefreshBtnVisible(boolean visible) {
|
||||
this.refreshBtnVisible = visible;
|
||||
}
|
||||
|
@ -235,9 +250,14 @@ public class MapInfoWidgetsFactory {
|
|||
this.onRefreshButtonClickListener = onRefreshButtonClickListener;
|
||||
}
|
||||
|
||||
public void setOnCloseToolbarListener(Runnable onCloseToolbarListener) {
|
||||
this.onCloseToolbarListener = onCloseToolbarListener;
|
||||
}
|
||||
|
||||
public void updateToolbar(TopToolbarView view) {
|
||||
TextView titleView = view.getTitleView();
|
||||
TextView descrView = view.getDescrView();
|
||||
LinearLayout bottomViewLayout = view.getBottomViewLayout();
|
||||
if (title != null) {
|
||||
titleView.setText(title);
|
||||
view.updateVisibility(titleView, true);
|
||||
|
@ -250,6 +270,13 @@ public class MapInfoWidgetsFactory {
|
|||
} else {
|
||||
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) {
|
||||
view.getShadowView().setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
@ -262,6 +289,7 @@ public class MapInfoWidgetsFactory {
|
|||
private TopToolbarController defaultController = new TopToolbarController(TopToolbarControllerType.CONTEXT_MENU);
|
||||
private View topbar;
|
||||
private View topBarLayout;
|
||||
private View topBarBottomView;
|
||||
private View topBarTitleLayout;
|
||||
private ImageButton backButton;
|
||||
private TextView titleView;
|
||||
|
@ -276,6 +304,7 @@ public class MapInfoWidgetsFactory {
|
|||
|
||||
topbar = map.findViewById(R.id.widget_top_bar);
|
||||
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);
|
||||
backButton = (ImageButton) map.findViewById(R.id.widget_top_bar_back_button);
|
||||
refreshButton = (ImageButton) map.findViewById(R.id.widget_top_bar_refresh_button);
|
||||
|
@ -306,6 +335,10 @@ public class MapInfoWidgetsFactory {
|
|||
return titleView;
|
||||
}
|
||||
|
||||
public LinearLayout getBottomViewLayout() {
|
||||
return (LinearLayout) topBarBottomView;
|
||||
}
|
||||
|
||||
public TextView getDescrView() {
|
||||
return descrView;
|
||||
}
|
||||
|
@ -343,6 +376,9 @@ public class MapInfoWidgetsFactory {
|
|||
for (Iterator ctrlIter = controllers.iterator(); ctrlIter.hasNext(); ) {
|
||||
TopToolbarController ctrl = (TopToolbarController) ctrlIter.next();
|
||||
if (ctrl.getType() == controller.getType()) {
|
||||
if (controller.onCloseToolbarListener != null) {
|
||||
controller.onCloseToolbarListener.run();
|
||||
}
|
||||
ctrlIter.remove();
|
||||
}
|
||||
}
|
||||
|
@ -352,6 +388,9 @@ public class MapInfoWidgetsFactory {
|
|||
}
|
||||
|
||||
public void removeController(TopToolbarController controller) {
|
||||
if (controller.onCloseToolbarListener != null) {
|
||||
controller.onCloseToolbarListener.run();
|
||||
}
|
||||
controllers.remove(controller);
|
||||
updateColors();
|
||||
updateInfo();
|
||||
|
@ -444,6 +483,12 @@ public class MapInfoWidgetsFactory {
|
|||
} else {
|
||||
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) {
|
||||
refreshButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue