diff --git a/OsmAnd/AndroidManifest-free.xml b/OsmAnd/AndroidManifest-free.xml index 78feabaa29..6782e2ec24 100644 --- a/OsmAnd/AndroidManifest-free.xml +++ b/OsmAnd/AndroidManifest-free.xml @@ -1,11 +1,19 @@ - - - - + xmlns:tools="http://schemas.android.com/tools"> + + + + + + + \ No newline at end of file diff --git a/OsmAnd/AndroidManifest-freedev.xml b/OsmAnd/AndroidManifest-freedev.xml index addf561555..bc527a3eed 100644 --- a/OsmAnd/AndroidManifest-freedev.xml +++ b/OsmAnd/AndroidManifest-freedev.xml @@ -1,11 +1,17 @@ - - - - + xmlns:tools="http://schemas.android.com/tools"> + + + + + diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index 4b1721d410..088c5652ae 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -64,7 +64,7 @@ - \ No newline at end of file diff --git a/OsmAnd/res/layout/drawer_list_material_item.xml b/OsmAnd/res/layout/list_item_basic.xml similarity index 100% rename from OsmAnd/res/layout/drawer_list_material_item.xml rename to OsmAnd/res/layout/list_item_basic.xml diff --git a/OsmAnd/res/layout/list_item_icon_and_menu.xml b/OsmAnd/res/layout/list_item_icon_and_menu.xml new file mode 100644 index 0000000000..d65b64b129 --- /dev/null +++ b/OsmAnd/res/layout/list_item_icon_and_menu.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/menu/localosm_child.xml b/OsmAnd/res/menu/localosm_child.xml index 1b5b4d1ae8..2be3b870fb 100644 --- a/OsmAnd/res/menu/localosm_child.xml +++ b/OsmAnd/res/menu/localosm_child.xml @@ -1,7 +1,12 @@ - - - - - + + + + \ No newline at end of file diff --git a/OsmAnd/res/menu/refresh_menu.xml b/OsmAnd/res/menu/refresh_menu.xml new file mode 100644 index 0000000000..afc9b60a3d --- /dev/null +++ b/OsmAnd/res/menu/refresh_menu.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java index a07d1ce325..9954699eea 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java @@ -5,6 +5,7 @@ import android.content.Context; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.Build; +import android.support.annotation.LayoutRes; import android.support.annotation.StringRes; import android.view.View; import android.view.ViewGroup; @@ -36,11 +37,11 @@ public class ContextMenuAdapter { public interface OnContextMenuClick { //boolean return type needed to desribe if drawer needed to be close or not - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked); + boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked); } public interface OnIntegerValueChangedListener { - public boolean onIntegerValueChangedListener(int newValue); + boolean onIntegerValueChangedListener(int newValue); } public static abstract class OnRowItemClick implements OnContextMenuClick { @@ -74,6 +75,7 @@ public class ContextMenuAdapter { private final Context ctx; private View anchor; + @LayoutRes private int defaultLayoutId = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB ? R.layout.list_menu_item : R.layout.list_menu_item_native; final TIntArrayList items = new TIntArrayList(); diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java index 880cd07732..27990f182f 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java @@ -580,7 +580,9 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, "Favourites.gpx:\n\n\n" + GPXUtilities.asString(gpxFile, getMyApplication())); sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_fav_subject)); - sendIntent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(getActivity(), "net.osmand.fileprovider", dst)); + sendIntent.putExtra(Intent.EXTRA_STREAM, + FileProvider.getUriForFile(getActivity(), + getActivity().getPackageName() + ".fileprovider", dst)); sendIntent.setType("text/plain"); startActivity(sendIntent); } catch (IOException e) { diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 0f8e10e4e9..1065946f4a 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -13,6 +13,7 @@ import android.support.v4.view.ViewCompat; import android.support.v7.widget.Toolbar; import android.util.TypedValue; import android.view.Gravity; +import android.view.MenuItem; import android.view.View; import android.view.ViewTreeObserver; import android.view.animation.Animation; @@ -74,6 +75,7 @@ import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener; import net.osmand.plus.views.DownloadedRegionsLayer; +import net.osmand.plus.views.MapInfoLayer; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.controls.DynamicListView; import net.osmand.plus.views.controls.DynamicListViewCallbacks; @@ -81,6 +83,7 @@ import net.osmand.plus.views.controls.StableArrayAdapter; import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener; import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.DismissCallbacks; import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.Undoable; +import net.osmand.plus.views.mapwidgets.MapWidgetRegistry; import java.lang.ref.WeakReference; import java.util.ArrayList; @@ -537,6 +540,24 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis } }); } + + toolbar.getMenu().clear(); + toolbar.inflateMenu(R.menu.refresh_menu); + toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem menuItem) { + if (menuItem.getItemId() == R.id.action_refresh) { + MapWidgetRegistry registry = mapActivity.getMapLayers().getMapWidgetRegistry(); + registry.resetToDefault(); + MapInfoLayer mil = mapActivity.getMapLayers().getMapInfoLayer(); + if (mil != null) { + mil.recreateControls(); + } + updateListAdapter(registry.getViewConfigureMenuAdapter(mapActivity)); + } + return false; + } + }); } diff --git a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java index 36f6d8bd5f..b9480550ea 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java @@ -21,7 +21,7 @@ public class RasterMapMenu { public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity, final OsmandRasterMapsPlugin.RasterMapType type) { ContextMenuAdapter adapter = new ContextMenuAdapter(mapActivity, false); - adapter.setDefaultLayoutId(R.layout.drawer_list_material_item); + adapter.setDefaultLayoutId(R.layout.list_item_basic); createLayersItems(adapter, mapActivity, type); return adapter; } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java index b83a6ca6cc..5fd0b33844 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java @@ -1,12 +1,10 @@ package net.osmand.plus.views.mapwidgets; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; +import android.content.Context; +import android.content.DialogInterface; +import android.support.v7.app.AlertDialog; +import android.widget.ArrayAdapter; +import android.widget.LinearLayout; import net.osmand.plus.ApplicationMode; import net.osmand.plus.ContextMenuAdapter; @@ -21,11 +19,13 @@ import net.osmand.plus.views.MapInfoLayer; import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapTileView; -import android.content.Context; -import android.content.DialogInterface; -import android.support.v7.app.AlertDialog; -import android.widget.ArrayAdapter; -import android.widget.LinearLayout; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; public class MapWidgetRegistry { @@ -479,7 +479,7 @@ public class MapWidgetRegistry { public ContextMenuAdapter getViewConfigureMenuAdapter(final MapActivity map) { final ContextMenuAdapter cm = new ContextMenuAdapter(map); - cm.setDefaultLayoutId(R.layout.drawer_list_item); + cm.setDefaultLayoutId(R.layout.list_item_icon_and_menu); cm.item(R.string.app_modes_choose).layout(R.layout.mode_toggles).reg(); cm.setChangeAppModeListener(new ConfigureMapMenu.OnClickListener() { @@ -488,20 +488,6 @@ public class MapWidgetRegistry { map.getDashboard().updateListAdapter(getViewConfigureMenuAdapter(map)); } }); - cm.item(R.string.map_widget_reset).iconColor(R.drawable.ic_action_reset_to_default_dark) - .listen(new OnContextMenuClick() { - - @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { - resetToDefault(); - MapInfoLayer mil = map.getMapLayers().getMapInfoLayer(); - if (mil != null) { - mil.recreateControls(); - } - map.getDashboard().updateListAdapter(getViewConfigureMenuAdapter(map)); - return false; - } - }).reg(); final ApplicationMode mode = settings.getApplicationMode(); addControls(map, cm, mode); return cm;