Fix webgl. Added photo_id to Mapillary start intent.
This commit is contained in:
parent
e3ae8e6493
commit
a6b99f1e41
11 changed files with 89 additions and 30 deletions
|
@ -19,6 +19,7 @@
|
|||
android:minHeight="@dimen/dashboard_map_toolbar"
|
||||
android:background="@color/osmand_orange"
|
||||
android:gravity="center_vertical"
|
||||
android:clickable="true"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<android.support.v7.widget.AppCompatImageView
|
||||
|
@ -69,13 +70,13 @@
|
|||
</LinearLayout>
|
||||
|
||||
<android.support.v7.widget.AppCompatImageView
|
||||
android:id="@+id/refresh_button"
|
||||
android:id="@+id/more_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:contentDescription="@string/shared_string_more"
|
||||
android:src="@drawable/ic_overflow_menu_white"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
android:minHeight="@dimen/dashboard_map_toolbar"
|
||||
android:background="@color/osmand_orange"
|
||||
android:gravity="center_vertical"
|
||||
android:clickable="true"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<android.support.v7.widget.AppCompatImageView
|
||||
|
@ -63,13 +64,13 @@
|
|||
</LinearLayout>
|
||||
|
||||
<android.support.v7.widget.AppCompatImageView
|
||||
android:id="@+id/refresh_button"
|
||||
android:id="@+id/more_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:contentDescription="@string/shared_string_more"
|
||||
android:src="@drawable/ic_overflow_menu_white"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
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="open_mapillary">Open Mapillary</string>
|
||||
<string name="shared_string_install">Install</string>
|
||||
<string name="improve_coverage_mapillary">Improve coverage with Mapillary</string>
|
||||
<string name="improve_coverage_install_mapillary_desc">You can take your own photos or series of photos and add it to this map location.\n\nTo do this you need install Mapillary app from Google Play.</string>
|
||||
|
|
|
@ -23,7 +23,7 @@ public class NoImagesCard extends AbstractCard {
|
|||
view.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MapillaryPlugin.openMapillary(getMapActivity());
|
||||
MapillaryPlugin.openMapillary(getMapActivity(), null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -22,22 +22,10 @@ public class UrlImageCard extends ImageCard {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(getImageUrl()));
|
||||
intent.setData(Uri.parse(getUrl()));
|
||||
v.getContext().startActivity(intent);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
if (view != null) {
|
||||
ImageView image = (ImageView) view.findViewById(R.id.image);
|
||||
image.setVisibility(View.GONE);
|
||||
TextView urlText = (TextView) view.findViewById(R.id.url);
|
||||
urlText.setText(getImageUrl());
|
||||
urlText.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package net.osmand.plus.mapcontextmenu.builders.cards.dialogs;
|
|||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -10,6 +12,8 @@ import net.osmand.plus.helpers.AndroidUiHelper;
|
|||
import net.osmand.plus.mapillary.MapillaryImageDialog;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ContextMenuCardDialog {
|
||||
|
||||
private MapActivity mapActivity;
|
||||
|
@ -56,6 +60,13 @@ public abstract class ContextMenuCardDialog {
|
|||
return description;
|
||||
}
|
||||
|
||||
protected boolean haveMenuItems() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void createMenuItems(Menu menu) {
|
||||
}
|
||||
|
||||
public void saveMenu(Bundle bundle) {
|
||||
bundle.putString(KEY_CARD_DIALOG_TYPE, type.name());
|
||||
if (title != null) {
|
||||
|
|
|
@ -4,6 +4,8 @@ import android.os.Bundle;
|
|||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.widget.AppCompatImageView;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -13,6 +15,7 @@ import android.widget.TextView;
|
|||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
public class ContextMenuCardDialogFragment extends Fragment {
|
||||
|
@ -51,6 +54,21 @@ public class ContextMenuCardDialogFragment extends Fragment {
|
|||
if (!Algorithms.isEmpty(dialog.getDescription())) {
|
||||
((TextView) view.findViewById(R.id.description)).setText(dialog.getDescription());
|
||||
}
|
||||
AppCompatImageView moreButton = (AppCompatImageView) view.findViewById(R.id.more_button);
|
||||
if (dialog.haveMenuItems()) {
|
||||
moreButton.setVisibility(View.VISIBLE);
|
||||
moreButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final PopupMenu optionsMenu = new PopupMenu(getContext(), v);
|
||||
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
|
||||
dialog.createMenuItems(optionsMenu.getMenu());
|
||||
optionsMenu.show();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
moreButton.setVisibility(View.GONE);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public class MapillaryContributeCard extends ImageCard {
|
|||
view.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MapillaryPlugin.openMapillary(getMapActivity());
|
||||
MapillaryPlugin.openMapillary(getMapActivity(), null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class MapillaryImageCard extends ImageCard {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
getMapActivity().getContextMenu().hideMenues();
|
||||
MapillaryImageDialog.show(getMapActivity(), getImageHiresUrl(), getUrl(), getLocation(),
|
||||
MapillaryImageDialog.show(getMapActivity(), getKey(), getImageHiresUrl(), getUrl(), getLocation(),
|
||||
getCa(), getMyApplication().getString(R.string.mapillary), null);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -8,6 +8,8 @@ import android.os.AsyncTask;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.ConsoleMessage;
|
||||
|
@ -21,6 +23,7 @@ import android.widget.ProgressBar;
|
|||
import net.osmand.AndroidNetworkUtils;
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.data.LatLon;
|
||||
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.dialogs.ContextMenuCardDialog;
|
||||
|
@ -30,6 +33,7 @@ import net.osmand.util.Algorithms;
|
|||
|
||||
public class MapillaryImageDialog extends ContextMenuCardDialog {
|
||||
|
||||
private static final String KEY_MAPILLARY_DIALOG_IMAGE_KEY = "key_mapillary_dialog_image_key";
|
||||
private static final String KEY_MAPILLARY_DIALOG_IMAGE_URL = "key_mapillary_dialog_image_url";
|
||||
private static final String KEY_MAPILLARY_DIALOG_VIEWER_URL = "key_mapillary_dialog_viewer_url";
|
||||
private static final String KEY_MAPILLARY_DIALOG_LATLON = "key_mapillary_dialog_latlon";
|
||||
|
@ -42,6 +46,7 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
|
|||
|
||||
private static final String WEBGL_ERROR_MESSAGE = "Error creating WebGL context";
|
||||
|
||||
private String key;
|
||||
private String imageUrl;
|
||||
private String viewerUrl;
|
||||
private LatLon latLon;
|
||||
|
@ -52,17 +57,22 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
|
|||
restoreFields(bundle);
|
||||
}
|
||||
|
||||
public MapillaryImageDialog(MapActivity mapActivity, String imageUrl, String viewerUrl, LatLon latLon, double ca,
|
||||
public MapillaryImageDialog(MapActivity mapActivity, String key, String imageUrl, String viewerUrl, LatLon latLon, double ca,
|
||||
String title, String description) {
|
||||
super(mapActivity, CardDialogType.MAPILLARY);
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.key = key;
|
||||
this.imageUrl = imageUrl;
|
||||
this.viewerUrl = viewerUrl;
|
||||
this.latLon = latLon;
|
||||
this.ca = ca;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getViewerUrl() {
|
||||
return viewerUrl;
|
||||
}
|
||||
|
@ -77,6 +87,7 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
|
|||
|
||||
public void saveMenu(Bundle bundle) {
|
||||
super.saveMenu(bundle);
|
||||
bundle.putSerializable(KEY_MAPILLARY_DIALOG_IMAGE_KEY, key);
|
||||
bundle.putSerializable(KEY_MAPILLARY_DIALOG_IMAGE_URL, imageUrl);
|
||||
bundle.putSerializable(KEY_MAPILLARY_DIALOG_VIEWER_URL, viewerUrl);
|
||||
bundle.putSerializable(KEY_MAPILLARY_DIALOG_LATLON, latLon);
|
||||
|
@ -86,6 +97,7 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
|
|||
@Override
|
||||
protected void restoreFields(Bundle bundle) {
|
||||
super.restoreFields(bundle);
|
||||
this.key = bundle.getString(KEY_MAPILLARY_DIALOG_IMAGE_KEY);
|
||||
this.imageUrl = bundle.getString(KEY_MAPILLARY_DIALOG_IMAGE_URL);
|
||||
this.viewerUrl = bundle.getString(KEY_MAPILLARY_DIALOG_VIEWER_URL);
|
||||
Object latLonObj = bundle.getSerializable(KEY_MAPILLARY_DIALOG_LATLON);
|
||||
|
@ -136,11 +148,31 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean haveMenuItems() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createMenuItems(Menu menu) {
|
||||
MenuItem item = menu.add(R.string.open_mapillary)
|
||||
.setIcon(getMapActivity().getMyApplication().getIconsCache().getThemedIcon(
|
||||
R.drawable.ic_action_mapillary));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
MapillaryPlugin.openMapillary(getMapActivity(), key);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"})
|
||||
private WebView getWebView() {
|
||||
final WebView webView = new WebView(getMapActivity());
|
||||
webView.setBackgroundColor(Color.argb(1, 0, 0, 0));
|
||||
webView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
|
||||
//webView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
|
||||
webView.setScrollContainer(false);
|
||||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
webView.addJavascriptInterface(new MapillaryWebAppInterface(), "Android");
|
||||
|
@ -153,7 +185,7 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
|
|||
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
|
||||
if (!Algorithms.isEmpty(consoleMessage.message()) && consoleMessage.message().contains(WEBGL_ERROR_MESSAGE)) {
|
||||
MapillaryPlugin.setWebGlSupported(false);
|
||||
show(getMapActivity(), imageUrl, viewerUrl, getLatLon(), getCa(), getTitle(), getDescription());
|
||||
show(getMapActivity(), key, imageUrl, viewerUrl, getLatLon(), getCa(), getTitle(), getDescription());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -172,6 +204,7 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
|
|||
MapillaryImageDialog.this.latLon = latLon;
|
||||
MapillaryImageDialog.this.ca = ca;
|
||||
if (!Algorithms.isEmpty(key)) {
|
||||
MapillaryImageDialog.this.key = key;
|
||||
MapillaryImageDialog.this.imageUrl = MAPILLARY_HIRES_IMAGE_URL_TEMPLATE + key;
|
||||
MapillaryImageDialog.this.viewerUrl = MAPILLARY_VIEWER_URL_TEMPLATE + key;
|
||||
}
|
||||
|
@ -182,6 +215,7 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
|
|||
|
||||
private View getStaticImageView() {
|
||||
LinearLayout ll = new LinearLayout(getMapActivity());
|
||||
ll.setClickable(true);
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||
isPortrait() ? ViewGroup.LayoutParams.MATCH_PARENT : AndroidUtils.dpToPx(getMapActivity(), 360f),
|
||||
isPortrait() ? AndroidUtils.dpToPx(getMapActivity(), 270f) : ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
|
@ -205,9 +239,11 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
|
|||
}
|
||||
|
||||
|
||||
public static MapillaryImageDialog show(MapActivity mapActivity, String imageUrl, String viewerUrl, LatLon latLon, double ca,
|
||||
String title, String description) {
|
||||
MapillaryImageDialog dialog = new MapillaryImageDialog(mapActivity, imageUrl, viewerUrl, latLon, ca, title, description);
|
||||
public static MapillaryImageDialog show(MapActivity mapActivity, String key, String imageUrl,
|
||||
String viewerUrl, LatLon latLon, double ca,
|
||||
String title, String description) {
|
||||
MapillaryImageDialog dialog = new MapillaryImageDialog(mapActivity, key, imageUrl, viewerUrl,
|
||||
latLon, ca, title, description);
|
||||
ContextMenuCardDialogFragment.showInstance(dialog);
|
||||
return dialog;
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ public class MapillaryPlugin extends OsmandPlugin {
|
|||
mapillaryControl.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openMapillary(map);
|
||||
openMapillary(map, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -205,12 +205,15 @@ public class MapillaryPlugin extends OsmandPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean openMapillary(FragmentActivity activity) {
|
||||
public static boolean openMapillary(FragmentActivity activity, String imageKey) {
|
||||
boolean success = false;
|
||||
OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
if (isPackageInstalled(MAPILLARY_PACKAGE_ID, app)) {
|
||||
Intent launchIntent = app.getPackageManager().getLaunchIntentForPackage(MAPILLARY_PACKAGE_ID);
|
||||
if (launchIntent != null) {
|
||||
if (imageKey != null) {
|
||||
launchIntent.putExtra("photo_id", imageKey);
|
||||
}
|
||||
app.startActivity(launchIntent);
|
||||
success = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue