diff --git a/OsmAnd/res/layout/mapillary_first_dialog.xml b/OsmAnd/res/layout/mapillary_first_dialog.xml
new file mode 100644
index 0000000000..07e5af5d91
--- /dev/null
+++ b/OsmAnd/res/layout/mapillary_first_dialog.xml
@@ -0,0 +1,130 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml
index 85d0ba21b2..9263f147cc 100644
--- a/OsmAnd/res/values/colors.xml
+++ b/OsmAnd/res/values/colors.xml
@@ -1,6 +1,7 @@
+ #3db878
#50ae55
#b5e5b9
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 9bb808ebe2..96763474db 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +9,9 @@
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
-->
+ Mapillary widget
+ Allow you to quick contribute to Mapillary
+ Online Street-Photos for everyone. Discover places, collaborate, capture the world.
Mapillary
Your destination is located in the area with a private access. Do you want to allow access to the private roads for this trip?
Restart search
diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
index ff0a1c971b..26411794ee 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
@@ -894,6 +894,7 @@ public class OsmandSettings {
public final OsmandPreference SHOW_POI_LABEL = new BooleanPreference("show_poi_label", false).makeGlobal();
public final OsmandPreference SHOW_MAPILLARY = new BooleanPreference("show_mapillary", false).makeGlobal();
+ public final OsmandPreference MAPILLARY_FIRST_DIALOG_SHOWN = new BooleanPreference("mapillary_first_dialog_shown", false).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference PREFERRED_LOCALE = new StringPreference("preferred_locale", "").makeGlobal();
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
index 0eb6b92156..2e91bf64c4 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
@@ -74,6 +74,8 @@ import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu;
import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu.LocalRoutingParameter;
+import net.osmand.plus.mapillary.MapillaryPlugin;
+import net.osmand.plus.mapillary.MapillaryPlugin.MapillaryFirstDialogFragment;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
@@ -866,6 +868,13 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
df.get().onCloseDash();
}
}
+
+ OsmandSettings settings = getMyApplication().getSettings();
+ if (settings.SHOW_MAPILLARY.get() && !settings.MAPILLARY_FIRST_DIALOG_SHOWN.get()) {
+ MapillaryFirstDialogFragment fragment = new MapillaryFirstDialogFragment();
+ fragment.show(mapActivity.getSupportFragmentManager(), MapillaryFirstDialogFragment.TAG);
+ settings.MAPILLARY_FIRST_DIALOG_SHOWN.set(true);
+ }
}
}
diff --git a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java
index 8dedbad5bc..06ee3cbe90 100644
--- a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java
+++ b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java
@@ -76,6 +76,7 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
public boolean onPreferenceClick(Preference preference) {
getMyApplication().getAppInitializer().resetFirstTimeRun();
getMyApplication().getSettings().FIRST_MAP_IS_DOWNLOADED.set(false);
+ getMyApplication().getSettings().MAPILLARY_FIRST_DIALOG_SHOWN.set(false);
getMyApplication().showToastMessage(R.string.shared_string_ok);
return true;
}
diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java
index 3c199999c8..eb96155f4c 100644
--- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java
@@ -1,10 +1,18 @@
package net.osmand.plus.mapillary;
import android.app.Activity;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.v4.app.FragmentActivity;
+import android.support.v7.widget.SwitchCompat;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import net.osmand.map.ITileSource;
import net.osmand.map.TileSourceManager;
+import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmandApplication;
@@ -13,16 +21,24 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityLayers;
+import net.osmand.plus.base.BottomSheetDialogFragment;
+import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.MapTileLayer;
import net.osmand.plus.views.OsmandMapTileView;
+import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo;
+import net.osmand.plus.views.mapwidgets.TextInfoWidget;
import net.osmand.util.Algorithms;
+import java.util.List;
+
public class MapillaryPlugin extends OsmandPlugin {
public static final String ID = "osmand.mapillary";
private OsmandSettings settings;
private OsmandApplication app;
private MapillaryLayer rasterLayer;
+ private TextInfoWidget mapillaryControl;
+ private MapWidgetRegInfo mapillaryWidgetRegInfo;
public MapillaryPlugin(OsmandApplication app) {
this.app = app;
@@ -57,6 +73,7 @@ public class MapillaryPlugin extends OsmandPlugin {
@Override
public void registerLayers(MapActivity activity) {
createLayers();
+ registerWidget(activity);
}
private void createLayers() {
@@ -138,4 +155,75 @@ public class MapillaryPlugin extends OsmandPlugin {
.setPosition(11)
.createItem());
}
+
+ private void registerWidget(MapActivity activity) {
+ MapInfoLayer layer = activity.getMapLayers().getMapInfoLayer();
+ mapillaryControl = createMonitoringControl(activity);
+ mapillaryWidgetRegInfo = layer.registerSideWidget(mapillaryControl,
+ R.drawable.ic_action_mapillary, R.string.mapillary, "mapillary", false, 19);
+ layer.recreateControls();
+ }
+
+ private TextInfoWidget createMonitoringControl(final MapActivity map) {
+ mapillaryControl = new TextInfoWidget(map);
+ mapillaryControl.setText(map.getString(R.string.mapillary), "");
+ mapillaryControl.setIcons(R.drawable.widget_mapillary_day, R.drawable.widget_mapillary_night);
+ mapillaryControl.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ // todo open mapillary app
+ }
+ });
+
+ return mapillaryControl;
+ }
+
+ public void setWidgetVisible(MapActivity mapActivity, boolean visible) {
+ if (mapillaryWidgetRegInfo != null) {
+ final List allModes = ApplicationMode.allPossibleValues();
+ for (ApplicationMode mode : allModes) {
+ mapActivity.getMapLayers().getMapWidgetRegistry().setVisibility(mode, mapillaryWidgetRegInfo, visible, false);
+ }
+ MapInfoLayer mil = mapActivity.getMapLayers().getMapInfoLayer();
+ if (mil != null) {
+ mil.recreateControls();
+ }
+ mapActivity.refreshMap();
+ }
+ }
+
+ public static class MapillaryFirstDialogFragment extends BottomSheetDialogFragment {
+ public static final String TAG = "MapillaryFirstDialogFragment";
+
+ private static final String KEY_SHOW_WIDGET = "key_show_widget";
+ private boolean showWidget = true;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ if (savedInstanceState != null) {
+ showWidget = savedInstanceState.getBoolean(KEY_SHOW_WIDGET, true);
+ }
+
+ View view = inflater.inflate(R.layout.mapillary_first_dialog, container, false);
+ final SwitchCompat widgetSwitch = (SwitchCompat) view.findViewById(R.id.widget_switch);
+ widgetSwitch.setChecked(showWidget);
+ view.findViewById(R.id.actionButton).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ FragmentActivity activity = getActivity();
+ MapillaryPlugin plugin = OsmandPlugin.getPlugin(MapillaryPlugin.class);
+ if (plugin != null && activity instanceof MapActivity) {
+ plugin.setWidgetVisible((MapActivity) activity, widgetSwitch.isChecked());
+ }
+ dismiss();
+ }
+ });
+ return view;
+ }
+
+ @Override
+ public void onSaveInstanceState(@NonNull Bundle outState) {
+ outState.putBoolean(KEY_SHOW_WIDGET, showWidget);
+ }
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java
index ceb66670f4..8fdd297411 100644
--- a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java
+++ b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java
@@ -87,10 +87,11 @@ public class MapInfoLayer extends OsmandMapLayer {
recreateControls();
}
- public void registerSideWidget(TextInfoWidget widget, int drawableMenu,
+ public MapWidgetRegInfo registerSideWidget(TextInfoWidget widget, int drawableMenu,
int messageId, String key, boolean left, int priorityOrder) {
MapWidgetRegInfo reg = mapInfoControls.registerSideWidgetInternal(widget, drawableMenu, messageId, key, left, priorityOrder);
updateReg(calculateTextState(), reg);
+ return reg;
}
public MapWidgetRegInfo registerSideWidget(TextInfoWidget widget, int drawableMenu,
diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java
index 9e6865f6b0..47ba7537d3 100644
--- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java
+++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java
@@ -240,6 +240,10 @@ public class MapWidgetRegistry {
public void setVisibility(MapWidgetRegInfo m, boolean visible, boolean collapsed) {
ApplicationMode mode = settings.APPLICATION_MODE.get();
+ setVisibility(mode, m, visible, collapsed);
+ }
+
+ public void setVisibility(ApplicationMode mode, MapWidgetRegInfo m, boolean visible, boolean collapsed) {
defineDefaultSettingsElement(mode);
// clear everything
this.visibleElementsFromSettings.get(mode).remove(m.key);