diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java index 6e1eb94c98..a46f98e7c1 100644 --- a/OsmAnd/src/net/osmand/AndroidUtils.java +++ b/OsmAnd/src/net/osmand/AndroidUtils.java @@ -284,6 +284,12 @@ public class AndroidUtils { decorView.setSystemUiVisibility(uiOptions); } + public static int[] getViewLocation(View view) { + int[] coordinates = new int[2]; + view.getLocationOnScreen(coordinates); + return coordinates; + } + public static void enterToFullScreen(Activity activity) { if (Build.VERSION.SDK_INT >= 21) { activity.getWindow().getDecorView() diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java index fae8f03a3b..b011f05e68 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java @@ -252,7 +252,7 @@ public class ContextMenuAdapter { ItemClickListener ca = item.getItemClickListener(); item.setSelected(isChecked); if (ca != null) { - ca.onContextMenuClick(la, item.getTitleId(), position, isChecked); + ca.onContextMenuClick(la, item.getTitleId(), position, isChecked, null); } } }; @@ -348,7 +348,8 @@ public class ContextMenuAdapter { boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, - boolean isChecked); + boolean isChecked, + int[] viewCoordinates); } public interface ProgressListener { @@ -372,7 +373,7 @@ public class ContextMenuAdapter { btn.setChecked(!btn.isChecked()); return false; } else { - return onContextMenuClick(adapter, itemId, position, false); + return onContextMenuClick(adapter, itemId, position, false, null); } } } diff --git a/OsmAnd/src/net/osmand/plus/activities/HelpActivity.java b/OsmAnd/src/net/osmand/plus/activities/HelpActivity.java index 4cb50d9832..961c14e01b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/HelpActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/HelpActivity.java @@ -74,7 +74,7 @@ public class HelpActivity extends OsmandActionBarActivity implements AdapterView ContextMenuAdapter.ItemClickListener listener = mAdapter.getItem(position).getItemClickListener(); if (listener != null) { - listener.onContextMenuClick(mAdapter, position, position, false); + listener.onContextMenuClick(mAdapter, position, position, false, null); } } @@ -200,7 +200,8 @@ public class HelpActivity extends OsmandActionBarActivity implements AdapterView public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, - boolean isChecked) { + boolean isChecked, + int[] viewCoordinates) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); return false; @@ -227,7 +228,7 @@ public class HelpActivity extends OsmandActionBarActivity implements AdapterView } @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) { String title = mTitle == null ? adapter.getItem(position).getTitle() : mTitle; HelpArticleDialogFragment.instantiateWithAsset(filename, title) .show(ctx.getSupportFragmentManager(), "DIALOG_HELP_ARTICLE"); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 08c96f6330..ab55d0f5e5 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -18,6 +18,7 @@ import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; +import net.osmand.AndroidUtils; import net.osmand.IndexConstants; import net.osmand.Location; import net.osmand.PlatformUtil; @@ -282,7 +283,7 @@ public class MapActivityActions implements DialogProvider { ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int resId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int resId, int pos, boolean isChecked, int[] viewCoordinates) { if (resId == R.string.context_menu_item_add_waypoint) { mapActivity.getContextMenu().addWptPt(); } else if (resId == R.string.context_menu_item_edit_waypoint) { @@ -322,7 +323,7 @@ public class MapActivityActions implements DialogProvider { int standardId = item.getTitleId(); ItemClickListener click = item.getItemClickListener(); if (click != null) { - click.onContextMenuClick(listAdapter, standardId, which, false); + click.onContextMenuClick(listAdapter, standardId, which, false, null); } else if (standardId == R.string.context_menu_item_last_intermediate_point) { mapActivity.getContextMenu().addAsLastIntermediate(); } else if (standardId == R.string.context_menu_item_search) { @@ -612,11 +613,11 @@ public class MapActivityActions implements DialogProvider { .setIcon(R.drawable.map_dashboard) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { app.logEvent(mapActivity, "drawer_dashboard_open"); MapActivity.clearPrevActivityIntent(); mapActivity.closeDrawer(); - mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD); + mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD, viewCoordinates); return true; } }).createItem()); @@ -625,7 +626,7 @@ public class MapActivityActions implements DialogProvider { .setIcon(R.drawable.ic_action_flag_dark) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { app.logEvent(mapActivity, "drawer_markers_open"); MapActivity.clearPrevActivityIntent(); MapMarkersDialogFragment.showInstance(mapActivity); @@ -637,10 +638,10 @@ public class MapActivityActions implements DialogProvider { .setIcon(R.drawable.ic_action_intermediate) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { app.logEvent(mapActivity, "drawer_waypoints_open"); MapActivity.clearPrevActivityIntent(); - mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS); + mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS, viewCoordinates); return false; } }).createItem()); @@ -650,7 +651,7 @@ public class MapActivityActions implements DialogProvider { .setIcon(R.drawable.ic_action_fav_dark) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { app.logEvent(mapActivity, "drawer_myplaces_open"); Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization() .getFavoritesActivity()); @@ -664,7 +665,7 @@ public class MapActivityActions implements DialogProvider { .setIcon(R.drawable.ic_action_search_dark) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { app.logEvent(mapActivity, "drawer_search_open"); mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.NEW_IF_EXPIRED, false); return true; @@ -676,7 +677,7 @@ public class MapActivityActions implements DialogProvider { .setIcon(R.drawable.ic_action_search_dark) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { app.logEvent(mapActivity, "drawer_legacy_search_open"); Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization() .getSearchActivity()); @@ -697,7 +698,7 @@ public class MapActivityActions implements DialogProvider { .setIcon(R.drawable.ic_action_gdirections_dark) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { app.logEvent(mapActivity, "drawer_directions_open"); MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer(); if (mapControlsLayer != null) { @@ -724,10 +725,10 @@ public class MapActivityActions implements DialogProvider { .setIcon(R.drawable.ic_action_layers_dark) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { app.logEvent(mapActivity, "drawer_config_map_open"); MapActivity.clearPrevActivityIntent(); - mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP); + mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP, viewCoordinates); return false; } }).createItem()); @@ -743,7 +744,7 @@ public class MapActivityActions implements DialogProvider { .setTitle(d).setIcon(R.drawable.ic_type_archive) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { app.logEvent(mapActivity, "drawer_download_maps_open"); Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization() .getDownloadActivity()); @@ -758,7 +759,7 @@ public class MapActivityActions implements DialogProvider { .setIcon(R.drawable.ic_action_osm_live) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { app.logEvent(mapActivity, "drawer_osm_live_open"); Intent intent = new Intent(mapActivity, OsmLiveActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); @@ -772,7 +773,7 @@ public class MapActivityActions implements DialogProvider { .setIcon(R.drawable.ic_action_ruler) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) { MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager()); return true; } @@ -782,10 +783,10 @@ public class MapActivityActions implements DialogProvider { .setIcon(R.drawable.ic_configure_screen_dark) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { app.logEvent(mapActivity, "drawer_config_screen_open"); MapActivity.clearPrevActivityIntent(); - mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN); + mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN, viewCoordinates); return false; } }).createItem()); @@ -794,7 +795,7 @@ public class MapActivityActions implements DialogProvider { .setIcon(R.drawable.ic_extension_dark) .setListener(new ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { app.logEvent(mapActivity, "drawer_plugins_open"); Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization() .getPluginsActivity()); @@ -808,7 +809,7 @@ public class MapActivityActions implements DialogProvider { .setIcon(R.drawable.ic_action_settings) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { app.logEvent(mapActivity, "drawer_settings_open"); final Intent settings = new Intent(mapActivity, getMyApplication().getAppCustomization() .getSettingsActivity()); @@ -835,7 +836,7 @@ public class MapActivityActions implements DialogProvider { .setIcon(R.drawable.ic_action_help) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { app.logEvent(mapActivity, "drawer_help_open"); Intent intent = new Intent(mapActivity, HelpActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); @@ -946,7 +947,7 @@ public class MapActivityActions implements DialogProvider { ContextMenuItem item = contextMenuAdapter.getItem(position); ContextMenuAdapter.ItemClickListener click = item.getItemClickListener(); if (click != null && click.onContextMenuClick(simpleListAdapter, item.getTitleId(), - position, false)) { + position, false, AndroidUtils.getViewLocation(view))) { mapActivity.closeDrawer(); } } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java index 37b8949691..3a44bbaf61 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java @@ -293,7 +293,7 @@ public class MapActivityLayers { public void onItemClick(AdapterView parent, View view, int position, long id) { ContextMenuItem item = listAdapter.getItem(position); item.setSelected(!item.getSelected()); - item.getItemClickListener().onContextMenuClick(listAdapter, position, position, item.getSelected()); + item.getItemClickListener().onContextMenuClick(listAdapter, position, position, item.getSelected(), null); listAdapter.notifyDataSetChanged(); } }); @@ -416,7 +416,7 @@ public class MapActivityLayers { builder.setListener(new ContextMenuAdapter.ItemClickListener() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, - int itemId, int position, boolean isChecked) { + int itemId, int position, boolean isChecked, int[] viewCoordinates) { ContextMenuItem item = adapter.getItem(position); item.setSelected(isChecked); return false; diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index ae599d4142..55ccbd0e60 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -623,7 +623,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { public void registerLayerContextMenuActions(final OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) { ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { if (itemId == R.string.layer_recordings) { SHOW_RECORDINGS.set(!SHOW_RECORDINGS.get()); adapter.getItem(pos).setColorRes(SHOW_RECORDINGS.get() ? @@ -653,7 +653,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { recordAudio(latitude, longitude, mapActivity); return true; } @@ -664,7 +664,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { .setListener(new ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { recordVideo(latitude, longitude, mapActivity, false); return true; } @@ -674,7 +674,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { .setIcon(R.drawable.ic_action_photo_dark) .setListener(new ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { takePhoto(latitude, longitude, mapActivity, false, false); return true; } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java index de22aa7425..9ffa04673a 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java @@ -15,6 +15,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; +import net.osmand.AndroidUtils; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.plus.R; @@ -85,7 +86,7 @@ public class DashWaypointsFragment extends DashLocationFragment { @Override public void onClick(View v) { - dashboard.setDashboardVisibility(true, DashboardType.WAYPOINTS); + dashboard.setDashboardVisibility(true, DashboardType.WAYPOINTS, AndroidUtils.getViewLocation(v)); } }); LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items); diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 13c5472ca6..68b05c9ebb 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -1,5 +1,9 @@ package net.osmand.plus.dashboard; +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.AnimatorSet; +import android.animation.ObjectAnimator; import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; @@ -19,9 +23,6 @@ import android.view.Gravity; import android.view.MenuItem; import android.view.View; import android.view.ViewTreeObserver; -import android.view.animation.Animation; -import android.view.animation.Animation.AnimationListener; -import android.view.animation.TranslateAnimation; import android.view.inputmethod.InputMethodManager; import android.widget.AbsListView; import android.widget.AdapterView; @@ -510,7 +511,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis @Override public void onClick(View v) { setDashboardVisibility(true, flatNow ? DashboardType.WAYPOINTS : DashboardType.WAYPOINTS_FLAT, - previousVisibleType, false); + previousVisibleType, false, AndroidUtils.getViewLocation(v)); } }); } @@ -661,7 +662,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis markersSelectionButton.onClickListener = new View.OnClickListener() { @Override public void onClick(View v) { - setDashboardVisibility(true, DashboardType.MAP_MARKERS_SELECTION); + setDashboardVisibility(true, DashboardType.MAP_MARKERS_SELECTION, AndroidUtils.getViewLocation(v)); } }; @@ -759,12 +760,20 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis } public void setDashboardVisibility(boolean visible, DashboardType type) { + setDashboardVisibility(visible, type, null); + } + + public void setDashboardVisibility(boolean visible, DashboardType type, int[] animationCoordinates) { boolean animate = !getMyApplication().getSettings().DO_NOT_USE_ANIMATIONS.get(); - setDashboardVisibility(visible, type, this.visible ? visibleType : null, animate); + setDashboardVisibility(visible, type, this.visible ? visibleType : null, animate, animationCoordinates); } public void setDashboardVisibility(boolean visible, DashboardType type, boolean animation) { - setDashboardVisibility(visible, type, this.visible ? visibleType : null, animation); + setDashboardVisibility(visible, type, animation, null); + } + + public void setDashboardVisibility(boolean visible, DashboardType type, boolean animation, int[] animationCoordinates) { + setDashboardVisibility(visible, type, this.visible ? visibleType : null, animation, animationCoordinates); } public void refreshDashboardFragments() { @@ -776,7 +785,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis return R.color.status_bar_transparent_gradient; } - public void setDashboardVisibility(boolean visible, DashboardType type, DashboardType prevItem, boolean animation) { + public void setDashboardVisibility(boolean visible, DashboardType type, DashboardType prevItem, boolean animation, int[] animationCoordinates) { if (visible == this.visible && type == visibleType) { return; } @@ -868,7 +877,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis updateToolbarActions(); //fabButton.showFloatingActionButton(); - open(dashboardView.findViewById(R.id.animateContent), animation); + open(dashboardView.findViewById(R.id.animateContent), animation, animationCoordinates); updateLocation(true, true, false); // addOrUpdateDashboardFragments(); mapActivity.getRoutingHelper().addListener(this); @@ -1121,7 +1130,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis if (btn != null && btn.getVisibility() == View.VISIBLE) { btn.setChecked(!btn.isChecked()); } else { - if (click.onContextMenuClick(listAdapter, item.getTitleId(), which, false)) { + if (click.onContextMenuClick(listAdapter, item.getTitleId(), which, false, null)) { hideDashboard(); } } @@ -1202,51 +1211,58 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis // To animate view slide out from right to left - private void open(View view, boolean animation) { + private void open(final View view, boolean animation, int[] animationCoordinates) { if (animation) { - TranslateAnimation animate = new TranslateAnimation(-mapActivity.findViewById(R.id.MapHudButtonsOverlay) - .getWidth(), 0, 0, 0); - animate.setDuration(500); - animate.setFillAfter(true); - view.startAnimation(animate); - view.setVisibility(View.VISIBLE); + AnimatorSet set = new AnimatorSet(); + List animators = new ArrayList<>(); + if (animationCoordinates != null) { + int screenHeight = mapActivity.getResources().getDisplayMetrics().heightPixels; + int screenWidth = mapActivity.getResources().getDisplayMetrics().widthPixels; + animators.add(ObjectAnimator.ofFloat(view, View.TRANSLATION_X, animationCoordinates[0] - screenWidth / 2, 0)); + animators.add(ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, animationCoordinates[1] - screenHeight / 2, 0)); + } + animators.add(ObjectAnimator.ofFloat(view, View.ALPHA, 0f, 1f)); + animators.add(ObjectAnimator.ofFloat(view, View.SCALE_X, 0.2f, 1f)); + animators.add(ObjectAnimator.ofFloat(view, View.SCALE_Y, 0.2f, 1f)); + set.setDuration(300).playTogether(animators); + set.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(Animator animation) { + super.onAnimationStart(animation); + view.setVisibility(View.VISIBLE); + } + }); + set.start(); } else { view.setVisibility(View.VISIBLE); } } - private void hide(View view, boolean animation) { + private void hide(final View view, boolean animation) { if (compassButton != null) { mapActivity.getMapLayers().getMapControlsLayer().restoreCompassButton(nightMode); compassButton = null; } if (!animation) { dashboardView.setVisibility(View.GONE); + view.setVisibility(View.GONE); } else { - TranslateAnimation animate = new TranslateAnimation(0, -mapActivity.findViewById(R.id.MapHudButtonsOverlay) - .getWidth(), 0, 0); - animate.setDuration(500); - animate.setFillAfter(true); - animate.setAnimationListener(new AnimationListener() { - + AnimatorSet set = new AnimatorSet(); + set.setDuration(300).playTogether( + ObjectAnimator.ofFloat(view, View.ALPHA, 1f, 0f), + ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, 0, view.getHeight()) + ); + set.addListener(new AnimatorListenerAdapter() { @Override - public void onAnimationStart(Animation animation) { - - } - - @Override - public void onAnimationRepeat(Animation animation) { - - } - - @Override - public void onAnimationEnd(Animation animation) { + public void onAnimationEnd(Animator animation) { + super.onAnimationEnd(animation); dashboardView.setVisibility(View.GONE); + view.setVisibility(View.GONE); + view.setTranslationY(0); } }); - view.startAnimation(animate); + set.start(); } - view.setVisibility(View.GONE); } diff --git a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java index 55b6cf6d1a..3113e2cf09 100644 --- a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java +++ b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java @@ -61,7 +61,7 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin { .setIcon(R.drawable.ic_action_gabout_dark) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { final Intent mapIntent = new Intent(mapActivity, ContributionVersionActivity.class); mapActivity.startActivityForResult(mapIntent, 0); return true; diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java index 9bf8c5d691..95d1d8e61b 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java @@ -157,13 +157,13 @@ public class ConfigureMapMenu { adapter.notifyDataSetChanged(); return false; } else { - return onContextMenuClick(adapter, itemId, pos, false); + return onContextMenuClick(adapter, itemId, pos, false, null); } } } @Override - public boolean onContextMenuClick(final ArrayAdapter adapter, int itemId, final int pos, boolean isChecked) { + public boolean onContextMenuClick(final ArrayAdapter adapter, int itemId, final int pos, boolean isChecked, int[] viewCoordinates) { final OsmandSettings settings = ma.getMyApplication().getSettings(); final PoiFiltersHelper poiFiltersHelper = ma.getMyApplication().getPoiFilters(); final ContextMenuItem item = cm.getItem(pos); @@ -331,14 +331,14 @@ public class ConfigureMapMenu { adapter.notifyDataSetChanged(); return false; } else { - return onContextMenuClick(adapter, itemId, position, false); + return onContextMenuClick(adapter, itemId, position, false, null); } } } @Override public boolean onContextMenuClick(final ArrayAdapter ad, int itemId, - final int pos, boolean isChecked) { + final int pos, boolean isChecked, int[] viewCoordinates) { if (transportSelectedInner) { for (int i = 0; i < transportPrefs.size(); i++) { transportPrefs.get(i).set(false); @@ -499,7 +499,7 @@ public class ConfigureMapMenu { .setIcon(R.drawable.ic_map).setListener(new ContextMenuAdapter.ItemClickListener() { @Override public boolean onContextMenuClick(final ArrayAdapter ad, int itemId, - final int pos, boolean isChecked) { + final int pos, boolean isChecked, int[] viewCoordinates) { AlertDialog.Builder bld = new AlertDialog.Builder(activity); bld.setTitle(R.string.renderers); final OsmandApplication app = activity.getMyApplication(); @@ -552,7 +552,7 @@ public class ConfigureMapMenu { .setIcon(getDayNightIcon(activity)).setListener(new ItemClickListener() { @Override public boolean onContextMenuClick(final ArrayAdapter ad, int itemId, - final int pos, boolean isChecked) { + final int pos, boolean isChecked, int[] viewCoordinates) { final OsmandMapTileView view = activity.getMapView(); AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext()); bld.setTitle(R.string.daynight); @@ -588,7 +588,7 @@ public class ConfigureMapMenu { .setIcon(R.drawable.ic_action_map_magnifier).setListener(new ContextMenuAdapter.ItemClickListener() { @Override public boolean onContextMenuClick(final ArrayAdapter ad, int itemId, - final int pos, boolean isChecked) { + final int pos, boolean isChecked, int[] viewCoordinates) { final OsmandMapTileView view = activity.getMapView(); final OsmandSettings.OsmandPreference mapDensity = view.getSettings().MAP_DENSITY; final AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext()); @@ -651,7 +651,7 @@ public class ConfigureMapMenu { .setIcon(R.drawable.ic_action_map_text_size).setListener(new ContextMenuAdapter.ItemClickListener() { @Override public boolean onContextMenuClick(final ArrayAdapter ad, int itemId, - final int pos, boolean isChecked) { + final int pos, boolean isChecked, int[] viewCoordinates) { final OsmandMapTileView view = activity.getMapView(); AlertDialog.Builder b = new AlertDialog.Builder(view.getContext()); // test old descr as title @@ -690,7 +690,7 @@ public class ConfigureMapMenu { .setListener(new ContextMenuAdapter.ItemClickListener() { @Override public boolean onContextMenuClick(final ArrayAdapter ad, int itemId, - final int pos, boolean isChecked) { + final int pos, boolean isChecked, int[] viewCoordinates) { final OsmandMapTileView view = activity.getMapView(); final AlertDialog.Builder b = new AlertDialog.Builder(view.getContext()); @@ -889,7 +889,7 @@ public class ConfigureMapMenu { final ItemClickListener clickListener = new ContextMenuAdapter.ItemClickListener() { @Override public boolean onContextMenuClick(ArrayAdapter a, int itemId, int pos, - boolean isChecked) { + boolean isChecked, int[] viewCoordinates) { if (!isChecked && !useDescription) { if (defaultSettings != null) { defaultSettings.set(""); @@ -939,8 +939,8 @@ public class ConfigureMapMenu { } else { builder.setListener(new OnRowItemClick() { @Override - public boolean onContextMenuClick(ArrayAdapter a, int itemId, int pos, boolean isChecked) { - return clickListener.onContextMenuClick(a, itemId, pos, isChecked); + public boolean onContextMenuClick(ArrayAdapter a, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { + return clickListener.onContextMenuClick(a, itemId, pos, isChecked, null); } @Override @@ -1210,7 +1210,7 @@ public class ConfigureMapMenu { .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { pref.set(!pref.get()); refreshMapComplete(activity); return false; @@ -1233,7 +1233,7 @@ public class ConfigureMapMenu { @Override public boolean onContextMenuClick(final ArrayAdapter ad, - final int itemId, final int pos, boolean isChecked) { + final int itemId, final int pos, boolean isChecked, int[] viewCoordinates) { AlertDialog.Builder b = new AlertDialog.Builder(view.getContext()); // test old descr as title b.setTitle(propertyDescr); diff --git a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java index 411f0a140c..92e154210c 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java @@ -99,7 +99,7 @@ public class RasterMapMenu { @Override public boolean onContextMenuClick(final ArrayAdapter adapter, - final int itemId, final int pos, final boolean isChecked) { + final int itemId, final int pos, final boolean isChecked, int[] viewCoordinates) { if (itemId == toggleActionStringId) { app.runInUIThread(new Runnable() { @Override diff --git a/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java b/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java index f346b95d0c..c4d2b65033 100644 --- a/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java +++ b/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java @@ -658,7 +658,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin { ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { if (itemId == R.string.delete_point) { for (int i = 0; i < measurementPoints.size(); i++) { Iterator it = measurementPoints.get(i).iterator(); diff --git a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java index 577fa38c67..8dae91467b 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java @@ -166,7 +166,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement ContextMenuItem item = adapter.getItem(which); if (item.getItemClickListener() != null) { item.getItemClickListener().onContextMenuClick(null, - item.getTitleId(), which, false); + item.getTitleId(), which, false, null); } } @@ -178,7 +178,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement private void basicFileOperation(final LocalIndexInfo info, ContextMenuAdapter adapter) { ItemClickListener listener = new ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int resId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int resId, int pos, boolean isChecked, int[] viewCoordinates) { return performBasicOperation(resId, info); } }; @@ -619,7 +619,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, - int itemId, int pos, boolean isChecked) { + int itemId, int pos, boolean isChecked, int[] viewCoordinates) { localOptionsMenu(itemId); return true; } @@ -681,7 +681,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement for (int i = 0; i < optionsMenuAdapter.length(); i++) { ContextMenuItem contextMenuItem = optionsMenuAdapter.getItem(i); if (itemId == contextMenuItem.getTitleId()) { - contextMenuItem.getItemClickListener().onContextMenuClick(null, itemId, i, false); + contextMenuItem.getItemClickListener().onContextMenuClick(null, itemId, i, false, null); return true; } } diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java index fc2c8a977e..04424812f3 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java @@ -14,6 +14,7 @@ import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.CompoundButton; +import net.osmand.AndroidUtils; import net.osmand.map.ITileSource; import net.osmand.map.TileSourceManager; import net.osmand.plus.ApplicationMode; @@ -150,14 +151,14 @@ public class MapillaryPlugin extends OsmandPlugin { @Override public boolean onRowItemClick(ArrayAdapter adapter, View view, int itemId, int position) { if (itemId == R.string.mapillary) { - mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.MAPILLARY); + mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.MAPILLARY, AndroidUtils.getViewLocation(view)); return false; } return true; } @Override - public boolean onContextMenuClick(final ArrayAdapter adapter, int itemId, final int pos, boolean isChecked) { + public boolean onContextMenuClick(final ArrayAdapter adapter, int itemId, final int pos, boolean isChecked, int[] viewCoordinates) { final OsmandSettings settings = mapActivity.getMyApplication().getSettings(); if (itemId == R.string.mapillary) { OsmandMapTileView mapView = mapActivity.getMapView(); diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index f2f09c3519..d50a6983ca 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -450,7 +450,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { optionsMenuAdapter = new ContextMenuAdapter(); ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, final int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, final int itemId, int pos, boolean isChecked, int[] viewCoordinates) { if (itemId == R.string.local_index_mi_reload) { reloadTracks(); } else if (itemId == R.string.shared_string_show_on_map) { @@ -521,7 +521,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { for (int i = 0; i < optionsMenuAdapter.length(); i++) { ContextMenuItem contextMenuItem = optionsMenuAdapter.getItem(i); if (itemId == contextMenuItem.getTitleId()) { - contextMenuItem.getItemClickListener().onContextMenuClick(null, itemId, i, false); + contextMenuItem.getItemClickListener().onContextMenuClick(null, itemId, i, false, null); return true; } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index f2ac87d344..7c3aa390ab 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -173,7 +173,7 @@ public class OsmEditingPlugin extends OsmandPlugin { final Object selectedObj) { ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int resId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int resId, int pos, boolean isChecked, int[] viewCoordinates) { if (resId == R.string.context_menu_item_create_poi) { //getPoiActions(mapActivity).showCreateDialog(latitude, longitude); EditPoiDialogFragment editPoiDialogFragment = @@ -273,7 +273,7 @@ public class OsmEditingPlugin extends OsmandPlugin { .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { if (itemId == R.string.layer_osm_bugs) { OsmandSettings.OsmandPreference showOsmBugs = settings.SHOW_OSM_BUGS; showOsmBugs.set(isChecked); @@ -303,7 +303,7 @@ public class OsmEditingPlugin extends OsmandPlugin { .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { sendGPXFiles(la, (AvailableGPXFragment) fragment, (GpxInfo) info); return true; } @@ -321,7 +321,7 @@ public class OsmEditingPlugin extends OsmandPlugin { .setListener(new ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { f.openSelectionMode(R.string.local_index_mi_upload_gpx, R.drawable.ic_action_export, R.drawable.ic_action_export, new OnClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java index f1975651ee..aefb249d3c 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java @@ -282,7 +282,7 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor { .setIcon(R.drawable.ic_osmo_dark) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { Intent intent = new Intent(mapActivity, OsMoGroupsActivity.class); mapActivity.startActivity(intent); return true; diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java index 1079cf1980..65017e4121 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java @@ -220,7 +220,7 @@ public class ParkingPositionPlugin extends OsmandPlugin { ItemClickListener addListener = new ItemClickListener() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int resId, - int pos, boolean isChecked) { + int pos, boolean isChecked, int[] viewCoordinates) { if (resId == R.string.context_menu_item_add_parking_point) { showAddParkingDialog(mapActivity, latitude, longitude); } diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java index 59b321ac4b..cd868a8e67 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java @@ -15,6 +15,7 @@ import android.widget.EditText; import android.widget.Spinner; import android.widget.Toast; +import net.osmand.AndroidUtils; import net.osmand.IndexConstants; import net.osmand.ResultMatcher; import net.osmand.StateChangedListener; @@ -241,18 +242,19 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.OnRowItemClick() { @Override public boolean onRowItemClick(ArrayAdapter adapter, View view, int itemId, int position) { + int[] viewCoordinates = AndroidUtils.getViewLocation(view); if (itemId == R.string.layer_overlay) { - mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.OVERLAY_MAP); + mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.OVERLAY_MAP, viewCoordinates); return false; } else if (itemId == R.string.layer_underlay) { - mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.UNDERLAY_MAP); + mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.UNDERLAY_MAP, viewCoordinates); return false; } return true; } @Override - public boolean onContextMenuClick(final ArrayAdapter adapter, int itemId, final int pos, boolean isChecked) { + public boolean onContextMenuClick(final ArrayAdapter adapter, int itemId, final int pos, boolean isChecked, int[] viewCoordinates) { final OsmandSettings settings = mapActivity.getMyApplication().getSettings(); switch (itemId) { case R.string.layer_overlay: @@ -346,7 +348,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { if (mapView.getMainLayer() instanceof MapTileLayer) { ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int resId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int resId, int pos, boolean isChecked, int[] viewCoordinates) { if (resId == R.string.context_menu_item_update_map) { mapActivity.getMapActions().reloadTile(mapView.getZoom(), latitude, longitude); } else if (resId == R.string.shared_string_download_map) { diff --git a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsLayer.java b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsLayer.java index c8ac99da18..13b8620a13 100644 --- a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsLayer.java +++ b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsLayer.java @@ -88,7 +88,7 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye final GPXUtilities.WptPt point = (GPXUtilities.WptPt) o; ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { if (itemId == R.string.mark_as_not_visited){ plugin.getCurrentRoute().markPoint(point,false); plugin.saveCurrentRoute(); diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java index d09832bb7a..f7e5099b9f 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java @@ -96,7 +96,7 @@ public class ContourLinesMenu { @Override public boolean onContextMenuClick(final ArrayAdapter adapter, - final int itemId, final int pos, final boolean isChecked) { + final int itemId, final int pos, final boolean isChecked, int[] viewCoordinates) { if (itemId == toggleActionStringId) { app.runInUIThread(new Runnable() { @Override @@ -268,7 +268,7 @@ public class ContourLinesMenu { .setIcon(DownloadActivityType.SRTM_COUNTRY_FILE.getIconResource()) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) { ContextMenuItem item = adapter.getItem(position); if (downloadThread.isDownloading(indexItem)) { downloadThread.cancelDownload(indexItem); diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/HillshadeMenu.java b/OsmAnd/src/net/osmand/plus/srtmplugin/HillshadeMenu.java index 8935f5d161..2a1979fefc 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/HillshadeMenu.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/HillshadeMenu.java @@ -56,7 +56,7 @@ public class HillshadeMenu { @Override public boolean onContextMenuClick(final ArrayAdapter adapter, - final int itemId, final int pos, final boolean isChecked) { + final int itemId, final int pos, final boolean isChecked, int[] viewCoordinates) { if (itemId == toggleActionStringId) { app.runInUIThread(new Runnable() { @Override @@ -146,7 +146,7 @@ public class HillshadeMenu { .setIcon(DownloadActivityType.HILLSHADE_FILE.getIconResource()) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) { ContextMenuItem item = adapter.getItem(position); if (downloadThread.isDownloading(indexItem)) { downloadThread.cancelDownload(indexItem); diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java index d6e24a5c4b..832be4c298 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java @@ -7,6 +7,7 @@ import android.support.v7.app.AlertDialog; import android.view.View; import android.widget.ArrayAdapter; +import net.osmand.AndroidUtils; import net.osmand.plus.ApplicationMode; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuItem; @@ -129,11 +130,12 @@ public class SRTMPlugin extends OsmandPlugin { @Override public boolean onRowItemClick(ArrayAdapter adapter, View view, int itemId, int position) { + int[] viewCoordinates = AndroidUtils.getViewLocation(view); if (itemId == R.string.srtm_plugin_name) { - mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.CONTOUR_LINES); + mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.CONTOUR_LINES, viewCoordinates); return false; } else if (itemId == R.string.layer_hillshade) { - mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.HILLSHADE); + mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.HILLSHADE, viewCoordinates); return false; } return true; @@ -143,7 +145,8 @@ public class SRTMPlugin extends OsmandPlugin { public boolean onContextMenuClick(final ArrayAdapter adapter, final int itemId, final int position, - final boolean isChecked) { + final boolean isChecked, + final int[] viewCoordinates) { if (itemId == R.string.srtm_plugin_name) { toggleContourLines(mapActivity, isChecked, new Runnable() { @Override diff --git a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java index ac4aae0893..87aa4c7bd9 100644 --- a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java @@ -242,7 +242,7 @@ public class ContextMenuLayer extends OsmandMapLayer { if (menu.hasHiddenBottomInfo()) { ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { menu.openMenuFullScreen(); return true; } @@ -256,7 +256,7 @@ public class ContextMenuLayer extends OsmandMapLayer { if (isObjectMoveable(o)) { ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { RotatedTileBox tileBox = activity.getMapView().getCurrentRotatedTileBox(); enterMovingMode(tileBox); return true; diff --git a/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java b/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java index 9fd7c62e70..452fbf5181 100644 --- a/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java @@ -218,7 +218,7 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { if (itemId == R.string.avoid_road) { activity.getMyApplication().getAvoidSpecificRoads().addImpassableRoad( activity, latLon, false, null, false); diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index cbc21d5c21..7eb6ad64e1 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -249,7 +249,7 @@ public class MapControlsLayer extends OsmandMapLayer { @Override public void onClick(View v) { MapActivity.clearPrevActivityIntent(); - mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP); + mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP, AndroidUtils.getViewLocation(v)); } }); @@ -410,7 +410,7 @@ public class MapControlsLayer extends OsmandMapLayer { public void onClick(View v) { MapActivity.clearPrevActivityIntent(); if (dash) { - mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD); + mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD, AndroidUtils.getViewLocation(v)); } else { mapActivity.openDrawer(); } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index 831714dc50..18bc20a05a 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -10,6 +10,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; +import net.osmand.AndroidUtils; import net.osmand.Location; import net.osmand.binary.RouteDataObject; import net.osmand.data.LatLon; @@ -881,7 +882,7 @@ public class MapInfoWidgetsFactory { all.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { - map.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS); + map.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS, AndroidUtils.getViewLocation(view)); } }); remove.setOnClickListener(new OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java index dc22e5394c..d3e66e0994 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java @@ -326,7 +326,7 @@ public class MapWidgetRegistry { .setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map)) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(final ArrayAdapter adapter, int itemId, final int position, boolean isChecked) { + public boolean onContextMenuClick(final ArrayAdapter adapter, int itemId, final int position, boolean isChecked, int[] viewCoordinates) { DirectionIndicationDialogFragment fragment = new DirectionIndicationDialogFragment(); fragment.setListener(new DirectionIndicationDialogFragment.DirectionIndicationFragmentListener() { @Override @@ -418,7 +418,7 @@ public class MapWidgetRegistry { .setSecondaryIcon( R.drawable.ic_action_additional_option) .setListener(new ContextMenuAdapter.OnRowItemClick() { @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, boolean isChecked) { + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) { setVisibility(adapter, position, isChecked); return false; } @@ -557,7 +557,7 @@ public class MapWidgetRegistry { @Override public boolean onContextMenuClick(ArrayAdapter a, - int itemId, int pos, boolean isChecked) { + int itemId, int pos, boolean isChecked, int[] viewCoordinates) { setVisibility(a, pos, isChecked, false); return false; } @@ -780,7 +780,7 @@ public class MapWidgetRegistry { @Override public boolean onContextMenuClick(ArrayAdapter a, - int itemId, int pos, boolean isChecked) { + int itemId, int pos, boolean isChecked, int[] viewCoordinates) { pref.set(!pref.get()); map.updateApplicationModeSettings(); a.notifyDataSetChanged();