Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-10-18 18:52:53 +02:00
commit 3c764cbecb
25 changed files with 444 additions and 232 deletions

View file

@ -1429,16 +1429,16 @@ public class RouteResultPreparation {
} }
} }
} }
// remove all non-slight turns // remove all non-slight turns // TEST don't pass
if(possibleTurns.size() > 1) { // if(possibleTurns.size() > 1) {
TIntIterator it = possibleTurns.iterator(); // TIntIterator it = possibleTurns.iterator();
while(it.hasNext()) { // while(it.hasNext()) {
int nxt = it.next(); // int nxt = it.next();
if(!TurnType.isSlightTurn(nxt)) { // if(!TurnType.isSlightTurn(nxt)) {
it.remove(); // it.remove();
} // }
} // }
} // }
int infer = 0; int infer = 0;
if (possibleTurns.size() == 1) { if (possibleTurns.size() == 1) {
infer = possibleTurns.iterator().next(); infer = possibleTurns.iterator().next();

View file

@ -229,8 +229,14 @@
<data android:scheme="https" /> <data android:scheme="https" />
<data android:host="maps.yandex.ru" /> <data android:host="maps.yandex.ru" />
<data android:host="maps.yandex.com" /> <data android:host="maps.yandex.com" />
<data android:host="www.openstreetmap.org" /> <data android:host="www.openstreetmap.org" android:path="/"/> <!-- catches /#map=... -->
<data android:host="openstreetmap.org" /> <data android:host="www.openstreetmap.org" android:pathPrefix="/query"/>
<data android:host="www.openstreetmap.org" android:pathPrefix="/go"/>
<data android:host="www.openstreetmap.org" android:pathPrefix="/search"/>
<data android:host="openstreetmap.org" android:path="/"/> <!-- catches /#map=... -->
<data android:host="openstreetmap.org" android:pathPrefix="/query"/>
<data android:host="openstreetmap.org" android:pathPrefix="/go"/>
<data android:host="openstreetmap.org" android:pathPrefix="/search"/>
<data android:host="osm.org" /> <data android:host="osm.org" />
<data android:host="map.baidu.cn" /> <data android:host="map.baidu.cn" />
<data android:host="map.baidu.com" /> <data android:host="map.baidu.com" />

View file

@ -1,163 +1,161 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" xmlns:tools="http://schemas.android.com/tools"
android:layout_height="wrap_content" android:layout_width="match_parent"
xmlns:osmand="http://schemas.android.com/apk/res-auto" android:layout_height="wrap_content"
android:background="?attr/bg_color" android:background="?attr/bg_color"
android:orientation="vertical"> android:orientation="vertical">
<ScrollView <ScrollView
android:id="@+id/history_marker_scroll_view" android:id="@+id/history_marker_scroll_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingBottom="8dp"> android:paddingBottom="8dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_selected_item_title_height" android:layout_height="@dimen/bottom_sheet_selected_item_title_height"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height" android:gravity="center_vertical"
android:gravity="center_vertical" android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingEnd="@dimen/bottom_sheet_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding"> android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <ImageView
android:id="@+id/map_marker_icon" android:id="@+id/map_marker_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_flag_dark"/> tools:src="@drawable/ic_action_flag_dark"/>
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="vertical"> android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx <android.support.v7.widget.AppCompatTextView
osmand:typeface="@string/font_roboto_regular" android:id="@+id/map_marker_title"
android:id="@+id/map_marker_title" android:layout_width="wrap_content"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:textSize="@dimen/default_list_text_size"
android:textColor="?android:textColorPrimary"
tools:text="Bloemstraat 179"/>
<net.osmand.plus.widgets.TextViewEx
osmand:typeface="@string/font_roboto_regular"
android:id="@+id/map_marker_passed_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size" android:textSize="@dimen/default_list_text_size"
android:textColor="?android:textColorSecondary" tools:text="Bloemstraat 179"/>
tools:text="Passed: July 28"/>
</LinearLayout> <android.support.v7.widget.AppCompatTextView
android:id="@+id/map_marker_passed_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
tools:text="Passed: July 28"/>
</LinearLayout> </LinearLayout>
<View </LinearLayout>
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout <View
android:id="@+id/make_active_row" android:layout_width="match_parent"
android:layout_width="match_parent" android:layout_height="1dp"
android:layout_height="@dimen/bottom_sheet_list_item_height" android:background="?attr/dashboard_divider"/>
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:layout_marginTop="@dimen/bottom_sheet_content_margin_small"
android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <LinearLayout
android:id="@+id/make_active_icon" android:id="@+id/make_active_row"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin" android:layout_marginTop="@dimen/bottom_sheet_content_margin_small"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin" android:background="?attr/selectableItemBackground"
tools:src="@drawable/ic_action_reset_to_default_dark"/> android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding">
<TextView <ImageView
android:layout_width="wrap_content" android:id="@+id/make_active_icon"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:maxLines="1" android:layout_height="wrap_content"
android:text="@string/make_active" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:textAppearance="@style/TextAppearance.ListItemTitle"/> android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
</LinearLayout> tools:src="@drawable/ic_action_reset_to_default_dark"/>
<LinearLayout <TextView
android:id="@+id/delete_row" android:layout_width="wrap_content"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="@dimen/bottom_sheet_list_item_height" android:maxLines="1"
android:background="?attr/selectableItemBackground" android:text="@string/make_active"
android:gravity="center_vertical" android:textAppearance="@style/TextAppearance.ListItemTitle"/>
android:minHeight="@dimen/bottom_sheet_list_item_height" </LinearLayout>
android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <LinearLayout
android:id="@+id/delete_icon" android:id="@+id/delete_row"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin" android:background="?attr/selectableItemBackground"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin" android:gravity="center_vertical"
tools:src="@drawable/ic_action_delete_dark"/> android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding">
<TextView <ImageView
android:layout_width="wrap_content" android:id="@+id/delete_icon"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:maxLines="1" android:layout_height="wrap_content"
android:text="@string/shared_string_delete" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:textAppearance="@style/TextAppearance.ListItemTitle"/> android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
</LinearLayout> tools:src="@drawable/ic_action_delete_dark"/>
</LinearLayout> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="@string/shared_string_delete"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</LinearLayout>
</ScrollView> </LinearLayout>
<View </ScrollView>
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<FrameLayout <View
android:id="@+id/cancel_row" android:layout_width="match_parent"
android:layout_width="match_parent" android:layout_height="1dp"
android:layout_height="@dimen/bottom_sheet_cancel_button_height" android:background="?attr/dashboard_divider"/>
android:background="?attr/selectableItemBackground">
<TextView <FrameLayout
android:id="@+id/cancel_row_text" android:id="@+id/cancel_row"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:layout_gravity="center" android:background="?attr/selectableItemBackground">
android:text="@string/shared_string_close"
android:textAllCaps="true" <TextView
android:textColor="?attr/color_dialog_buttons" android:id="@+id/cancel_row_text"
android:textSize="@dimen/default_desc_text_size" android:layout_width="wrap_content"
android:textStyle="bold"/> android:layout_height="wrap_content"
</FrameLayout> android:layout_gravity="center"
android:text="@string/shared_string_close"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"/>
</FrameLayout>
</LinearLayout> </LinearLayout>

View file

@ -436,6 +436,35 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<LinearLayout
android:id="@+id/context_menu_zoom_buttons"
android:layout_width="@dimen/fab_size_with_shadow"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="center"
android:layout_marginRight="@dimen/fab_margin_right"
android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible">
<ImageButton
android:id="@+id/context_menu_zoom_in_button"
android:layout_width="@dimen/map_button_size"
android:layout_height="@dimen/map_button_size"
android:background="@drawable/btn_circle"
android:contentDescription="@string/zoomIn"
tools:src="@drawable/ic_action_test_light"/>
<ImageButton
android:id="@+id/context_menu_zoom_out_button"
android:layout_width="@dimen/map_button_size"
android:layout_height="@dimen/map_button_size"
android:layout_marginTop="@dimen/map_button_spacing"
android:background="@drawable/btn_circle"
android:contentDescription="@string/zoomOut"
tools:src="@drawable/ic_action_test_light"/>
</LinearLayout>
<ImageView <ImageView
android:id="@+id/context_menu_fab_view" android:id="@+id/context_menu_fab_view"
android:contentDescription="@string/layer_route" android:contentDescription="@string/layer_route"

View file

@ -2946,7 +2946,7 @@ We slaan geen locatiegegevens, zoektermen of andere gebruikersgegevens op.</stri
\n \n
\n• Afstandmeter kan vastklikken aan wegen en als track opslaan \n• Afstandmeter kan vastklikken aan wegen en als track opslaan
\n \n
\n• OmsAnd Live: bugfixes, data op de server elke 30 minuten ververst, en updates van de navigatie \n• OsmAnd Live: bugfixes, data op de server elke 15 minuten ververst, en updates van de navigatie
\n \n
\n</string> \n</string>
<string name="rendering_value_darkyellow_name">Donkergeel</string> <string name="rendering_value_darkyellow_name">Donkergeel</string>

View file

@ -9,6 +9,7 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 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 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="wrong_format">Wrong format</string>
<string name="shared_string_road">Road</string> <string name="shared_string_road">Road</string>
<string name="show_map">Show map</string> <string name="show_map">Show map</string>
<string name="route_is_calculated">Route is calculated</string> <string name="route_is_calculated">Route is calculated</string>

View file

@ -87,7 +87,7 @@ public class AppInitializer implements IProgress {
private static final String VERSION_INSTALLED = "VERSION_INSTALLED"; //$NON-NLS-1$ private static final String VERSION_INSTALLED = "VERSION_INSTALLED"; //$NON-NLS-1$
private static final String EXCEPTION_FILE_SIZE = "EXCEPTION_FS"; //$NON-NLS-1$ private static final String EXCEPTION_FILE_SIZE = "EXCEPTION_FS"; //$NON-NLS-1$
public static final String LATEST_CHANGES_URL = "https://osmand.net/blog?id=osmand-2-7-released"; public static final String LATEST_CHANGES_URL = "https://osmand.net/blog?id=osmand-2-8-released";
// public static final String LATEST_CHANGES_URL = null; // not enough to read // public static final String LATEST_CHANGES_URL = null; // not enough to read
public static final int APP_EXIT_CODE = 4; public static final int APP_EXIT_CODE = 4;
public static final String APP_EXIT_KEY = "APP_EXIT_KEY"; public static final String APP_EXIT_KEY = "APP_EXIT_KEY";

View file

@ -26,11 +26,20 @@ public class Version {
public static boolean isMarketEnabled(OsmandApplication ctx) { public static boolean isMarketEnabled(OsmandApplication ctx) {
return isGooglePlayEnabled(ctx) || isAmazonEnabled(ctx); return isGooglePlayEnabled(ctx) || isAmazonEnabled(ctx);
} }
public static boolean isGooglePlayInstalled(OsmandApplication ctx) {
try {
ctx.getPackageManager().getPackageInfo("com.android.vending", 0);
} catch (PackageManager.NameNotFoundException e) {
return false;
}
return true;
}
public static String marketPrefix(OsmandApplication ctx) { public static String marketPrefix(OsmandApplication ctx) {
if (isAmazonEnabled(ctx)) { if (isAmazonEnabled(ctx)) {
return "amzn://apps/android?p="; return "amzn://apps/android?p=";
} else if (isGooglePlayEnabled(ctx)) { } else if (isGooglePlayEnabled(ctx) && isGooglePlayInstalled(ctx)) {
return "market://details?id="; return "market://details?id=";
} }
return "https://osmand.net/apps?id="; return "https://osmand.net/apps?id=";

View file

@ -913,6 +913,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
} }
public void readLocationToShow() { public void readLocationToShow() {
mapLayers.getMapControlsLayer().showMapControls();
LatLon cur = new LatLon(mapView.getLatitude(), mapView.getLongitude()); LatLon cur = new LatLon(mapView.getLatitude(), mapView.getLongitude());
LatLon latLonToShow = settings.getAndClearMapLocationToShow(); LatLon latLonToShow = settings.getAndClearMapLocationToShow();
PointDescription mapLabelToShow = settings.getAndClearMapLabelToShow(latLonToShow); PointDescription mapLabelToShow = settings.getAndClearMapLabelToShow(latLonToShow);

View file

@ -42,6 +42,7 @@ import net.osmand.plus.OsmandSettings.DrivingRegion;
import net.osmand.plus.OsmandSettings.MetricsConstants; import net.osmand.plus.OsmandSettings.MetricsConstants;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.Version; import net.osmand.plus.Version;
import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.dashboard.DashChooseAppDirFragment; import net.osmand.plus.dashboard.DashChooseAppDirFragment;
import net.osmand.plus.dashboard.DashChooseAppDirFragment.ChooseAppDirFragment; import net.osmand.plus.dashboard.DashChooseAppDirFragment.ChooseAppDirFragment;
import net.osmand.plus.dashboard.DashChooseAppDirFragment.MoveFilesToDifferentDirectory; import net.osmand.plus.dashboard.DashChooseAppDirFragment.MoveFilesToDifferentDirectory;
@ -58,6 +59,12 @@ import java.util.List;
public class SettingsGeneralActivity extends SettingsBaseActivity implements OnRequestPermissionsResultCallback { public class SettingsGeneralActivity extends SettingsBaseActivity implements OnRequestPermissionsResultCallback {
private static final String IP_ADDRESS_PATTERN =
"^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])$";
private Preference applicationDir; private Preference applicationDir;
private ListPreference applicationModePreference; private ListPreference applicationModePreference;
private Preference drivingRegionPreference; private Preference drivingRegionPreference;
@ -160,7 +167,10 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
if (drs.get(which) == null) { if (drs.get(which) == null) {
settings.DRIVING_REGION_AUTOMATIC.set(true); settings.DRIVING_REGION_AUTOMATIC.set(true);
MapActivity.getSingleMapViewTrackingUtilities().resetDrivingRegionUpdate(); MapViewTrackingUtilities mapViewTrackingUtilities = MapActivity.getSingleMapViewTrackingUtilities();
if (mapViewTrackingUtilities != null) {
mapViewTrackingUtilities.resetDrivingRegionUpdate();
}
} else { } else {
settings.DRIVING_REGION_AUTOMATIC.set(false); settings.DRIVING_REGION_AUTOMATIC.set(false);
settings.DRIVING_REGION.set(drs.get(which)); settings.DRIVING_REGION.set(drs.get(which));
@ -366,9 +376,15 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
hostPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { hostPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
settings.PROXY_HOST.set((String) newValue); String ipAddress = (String) newValue;
enableProxy(NetworkUtils.getProxy() != null); if (ipAddress.matches(IP_ADDRESS_PATTERN)) {
return true; settings.PROXY_HOST.set(ipAddress);
enableProxy(NetworkUtils.getProxy() != null);
return true;
} else {
Toast.makeText(SettingsGeneralActivity.this, getString(R.string.wrong_format), Toast.LENGTH_SHORT).show();
return false;
}
} }
}); });

View file

@ -851,7 +851,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
} }
} }
mapActivity.findViewById(R.id.toolbar_back).setVisibility(isBackButtonVisible() ? View.VISIBLE : View.GONE); mapActivity.findViewById(R.id.toolbar_back).setVisibility(isBackButtonVisible() ? View.VISIBLE : View.GONE);
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE); mapActivity.getMapLayers().getMapControlsLayer().hideMapControls();
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity); boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
if (!portrait) { if (!portrait) {
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin_external), true); AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin_external), true);
@ -875,7 +875,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
mapActivity.getMapView().refreshMap(); mapActivity.getMapView().refreshMap();
} }
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE); mapActivity.getMapLayers().getMapControlsLayer().showMapControls();
hideActionButton(); hideActionButton();
for (WeakReference<DashBaseFragment> df : fragList) { for (WeakReference<DashBaseFragment> df : fragList) {
if (df.get() != null) { if (df.get() != null) {

View file

@ -368,7 +368,6 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
fragmentRef.get().centerMarkerLocation(); fragmentRef.get().centerMarkerLocation();
} }
} }
updateControlsVisibility();
} }
public void show(@NonNull LatLon latLon, public void show(@NonNull LatLon latLon,
@ -377,7 +376,6 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
if (init(latLon, pointDescription, object)) { if (init(latLon, pointDescription, object)) {
showInternal(); showInternal();
} }
updateControlsVisibility();
} }
private void showInternal() { private void showInternal() {
@ -415,7 +413,8 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
init(latLon, pointDescription, object); init(latLon, pointDescription, object);
} }
public void close() { public boolean close() {
boolean result = false;
if (active) { if (active) {
active = false; active = false;
if (object instanceof MapMarker) { if (object instanceof MapMarker) {
@ -430,15 +429,17 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
if (this.object != null) { if (this.object != null) {
clearSelectedObject(this.object); clearSelectedObject(this.object);
} }
hide(); result = hide();
if (menuController != null) { if (menuController != null) {
menuController.setActive(false); menuController.setActive(false);
} }
mapActivity.refreshMap(); mapActivity.refreshMap();
} }
return result;
} }
public void hide() { public boolean hide() {
boolean result = false;
if (mapPosition != 0) { if (mapPosition != 0) {
mapActivity.getMapView().setMapPosition(mapPosition); mapActivity.getMapView().setMapPosition(mapPosition);
mapPosition = 0; mapPosition = 0;
@ -449,20 +450,33 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment(); WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
if (fragmentRef != null) { if (fragmentRef != null) {
fragmentRef.get().dismissMenu(); fragmentRef.get().dismissMenu();
result = true;
} }
updateControlsVisibility(); return result;
} }
public void updateControlsVisibility() { public void updateControlsVisibility(boolean menuVisible) {
int visibility = shouldShowControls() ? View.VISIBLE : View.GONE; int topControlsVisibility = shouldShowTopControls(menuVisible) ? View.VISIBLE : View.GONE;
mapActivity.findViewById(R.id.map_center_info).setVisibility(visibility); mapActivity.findViewById(R.id.map_center_info).setVisibility(topControlsVisibility);
mapActivity.findViewById(R.id.map_left_widgets_panel).setVisibility(visibility); mapActivity.findViewById(R.id.map_left_widgets_panel).setVisibility(topControlsVisibility);
mapActivity.findViewById(R.id.map_right_widgets_panel).setVisibility(visibility); mapActivity.findViewById(R.id.map_right_widgets_panel).setVisibility(topControlsVisibility);
int bottomControlsVisibility = shouldShowBottomControls(menuVisible) ? View.VISIBLE : View.GONE;
mapActivity.findViewById(R.id.bottom_controls_container).setVisibility(bottomControlsVisibility);
mapActivity.refreshMap(); mapActivity.refreshMap();
} }
public boolean shouldShowControls() { public boolean shouldShowTopControls() {
return !isVisible() || isLandscapeLayout() || getCurrentMenuState() == MenuController.MenuState.HEADER_ONLY; return shouldShowTopControls(isVisible());
}
public boolean shouldShowTopControls(boolean menuVisible) {
return !menuVisible || isLandscapeLayout() || getCurrentMenuState() == MenuController.MenuState.HEADER_ONLY;
}
public boolean shouldShowBottomControls(boolean menuVisible) {
return !menuVisible || isLandscapeLayout();
} }
// timeout in msec // timeout in msec
@ -633,18 +647,20 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
} }
} }
public void onSingleTapOnMap() { public boolean onSingleTapOnMap() {
boolean result = false;
if (menuController == null || !menuController.handleSingleTapOnMap()) { if (menuController == null || !menuController.handleSingleTapOnMap()) {
if (menuController != null && !menuController.isClosable()) { if (menuController != null && !menuController.isClosable()) {
hide(); result = hide();
} else { } else {
updateMapCenter(null); updateMapCenter(null);
close(); result = close();
} }
if (mapActivity.getMapLayers().getMapQuickActionLayer().isLayerOn()) { if (mapActivity.getMapLayers().getMapQuickActionLayer().isLayerOn()) {
mapActivity.getMapLayers().getMapQuickActionLayer().refreshLayer(); mapActivity.getMapLayers().getMapQuickActionLayer().refreshLayer();
} }
} }
return result;
} }
@Override @Override
@ -710,6 +726,24 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
mapActivity.getMapLayers().getMapControlsLayer().navigateFab(); mapActivity.getMapLayers().getMapControlsLayer().navigateFab();
} }
public boolean zoomInPressed() {
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
if (fragmentRef != null) {
fragmentRef.get().doZoomIn();
return true;
}
return false;
}
public boolean zoomOutPressed() {
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
if (fragmentRef != null) {
fragmentRef.get().doZoomOut();
return true;
}
return false;
}
public void buttonWaypointPressed() { public void buttonWaypointPressed() {
if (pointDescription.isDestination()) { if (pointDescription.isDestination()) {
mapActivity.getMapActions().editWaypoints(); mapActivity.getMapActions().editWaypoints();
@ -1033,6 +1067,10 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
return menuController == null || menuController.fabVisible(); return menuController == null || menuController.fabVisible();
} }
public boolean zoomButtonsVisible() {
return menuController == null || menuController.zoomButtonsVisible();
}
public boolean isClosable() { public boolean isClosable() {
return menuController == null || menuController.isClosable(); return menuController == null || menuController.isClosable();
} }

View file

@ -66,7 +66,10 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
private View view; private View view;
private View mainView; private View mainView;
ImageView fabView; private ImageView fabView;
private View zoomButtonsView;
private ImageButton zoomInButtonView;
private ImageButton zoomOutButtonView;
private MapContextMenu menu; private MapContextMenu menu;
private OnLayoutChangeListener containerLayoutListener; private OnLayoutChangeListener containerLayoutListener;
@ -83,6 +86,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
private int screenHeight; private int screenHeight;
private int viewHeight; private int viewHeight;
private int zoomButtonsHeight;
private int fabPaddingTopPx; private int fabPaddingTopPx;
private int markerPaddingPx; private int markerPaddingPx;
@ -257,7 +261,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
if (singleTapDetector.onTouchEvent(event)) { if (singleTapDetector.onTouchEvent(event)) {
moving = false; moving = false;
if (hasMoved) { if (hasMoved) {
applyPosY(getViewY(), false, false, 0, 0); applyPosY(getViewY(), false, false, 0, 0, 0);
} }
openMenuHalfScreen(); openMenuHalfScreen();
return true; return true;
@ -386,6 +390,32 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
fabView.setVisibility(View.GONE); fabView.setVisibility(View.GONE);
} }
// Zoom buttons
zoomButtonsView = view.findViewById(R.id.context_menu_zoom_buttons);
zoomInButtonView = (ImageButton) view.findViewById(R.id.context_menu_zoom_in_button);
zoomOutButtonView = (ImageButton) view.findViewById(R.id.context_menu_zoom_out_button);
if (menu.zoomButtonsVisible()) {
updateImageButton(zoomInButtonView, R.drawable.map_zoom_in, R.drawable.map_zoom_in_night,
R.drawable.btn_circle_trans, R.drawable.btn_circle_night, nightMode);
updateImageButton(zoomOutButtonView, R.drawable.map_zoom_out, R.drawable.map_zoom_out_night,
R.drawable.btn_circle_trans, R.drawable.btn_circle_night, nightMode);
zoomInButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
menu.zoomInPressed();
}
});
zoomOutButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
menu.zoomOutPressed();
}
});
zoomButtonsView.setVisibility(View.VISIBLE);
} else {
zoomButtonsView.setVisibility(View.GONE);
}
View buttonsTopBorder = view.findViewById(R.id.buttons_top_border); View buttonsTopBorder = view.findViewById(R.id.buttons_top_border);
AndroidUtils.setBackground(getMapActivity(), buttonsTopBorder, nightMode, AndroidUtils.setBackground(getMapActivity(), buttonsTopBorder, nightMode,
R.color.dashboard_divider_light, R.color.dashboard_divider_dark); R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
@ -481,6 +511,16 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
return view; return view;
} }
private void updateImageButton(ImageButton button, int iconLightId, int iconDarkId, int bgLightId, int bgDarkId, boolean night) {
button.setImageDrawable(getMapActivity().getMyApplication().getIconsCache().getIcon(night ? iconDarkId : iconLightId));
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
button.setBackground(getMapActivity().getResources().getDrawable(night ? bgDarkId : bgLightId,
getMapActivity().getTheme()));
} else {
button.setBackgroundDrawable(getMapActivity().getResources().getDrawable(night ? bgDarkId : bgLightId));
}
}
private void processScreenHeight(ViewParent parent) { private void processScreenHeight(ViewParent parent) {
View container = (View)parent; View container = (View)parent;
if (Build.VERSION.SDK_INT >= 11) { if (Build.VERSION.SDK_INT >= 11) {
@ -525,17 +565,33 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
boolean needMapAdjust = oldMenuState != newMenuState && newMenuState != MenuState.FULL_SCREEN; boolean needMapAdjust = oldMenuState != newMenuState && newMenuState != MenuState.FULL_SCREEN;
if (newMenuState != oldMenuState) { if (newMenuState != oldMenuState) {
menu.updateControlsVisibility(); menu.updateControlsVisibility(true);
doBeforeMenuStateChange(oldMenuState, newMenuState); doBeforeMenuStateChange(oldMenuState, newMenuState);
} }
applyPosY(currentY, needCloseMenu, needMapAdjust, oldMenuState, newMenuState); applyPosY(currentY, needCloseMenu, needMapAdjust, oldMenuState, newMenuState, 0);
}
public void doZoomIn() {
if (!centered) {
centered = true;
calculateCenterLatLon(menu.getLatLon(), getZoom() + 1, true);
}
applyPosY(getViewY(), false, true, 0, 0, 1);
}
public void doZoomOut() {
if (!centered) {
centered = true;
calculateCenterLatLon(menu.getLatLon(), getZoom() - 1, true);
}
applyPosY(getViewY(), false, true, 0, 0, -1);
} }
private void applyPosY(final int currentY, final boolean needCloseMenu, boolean needMapAdjust, private void applyPosY(final int currentY, final boolean needCloseMenu, boolean needMapAdjust,
final int previousMenuState, final int newMenuState) { final int previousMenuState, final int newMenuState, int dZoom) {
final int posY = getPosY(needCloseMenu); final int posY = getPosY(needCloseMenu);
if (currentY != posY) { if (currentY != posY || dZoom != 0) {
if (posY < currentY) { if (posY < currentY) {
updateMainViewLayout(posY); updateMainViewLayout(posY);
} }
@ -574,8 +630,13 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
.setInterpolator(new DecelerateInterpolator()) .setInterpolator(new DecelerateInterpolator())
.start(); .start();
zoomButtonsView.animate().y(getZoomButtonsY(posY))
.setDuration(200)
.setInterpolator(new DecelerateInterpolator())
.start();
if (needMapAdjust) { if (needMapAdjust) {
adjustMapPosition(posY, true, centered); adjustMapPosition(posY, true, centered, dZoom);
} }
} else { } else {
setViewY(posY, false, needMapAdjust); setViewY(posY, false, needMapAdjust);
@ -791,7 +852,8 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
if (parent != null && containerLayoutListener != null) { if (parent != null && containerLayoutListener != null) {
((View) parent).addOnLayoutChangeListener(containerLayoutListener); ((View) parent).addOnLayoutChangeListener(containerLayoutListener);
} }
menu.updateControlsVisibility(true);
getMapActivity().getMapLayers().getMapControlsLayer().showMapControls();
} }
@Override @Override
@ -805,6 +867,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
if (!wasDrawerDisabled) { if (!wasDrawerDisabled) {
getMapActivity().enableDrawer(); getMapActivity().enableDrawer();
} }
menu.updateControlsVisibility(false);
super.onPause(); super.onPause();
} }
@ -874,6 +937,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
menuTopShadowHeight = view.findViewById(R.id.context_menu_top_shadow).getHeight(); menuTopShadowHeight = view.findViewById(R.id.context_menu_top_shadow).getHeight();
int newMenuTopShadowAllHeight = view.findViewById(R.id.context_menu_top_shadow_all).getHeight(); int newMenuTopShadowAllHeight = view.findViewById(R.id.context_menu_top_shadow_all).getHeight();
menuFullHeight = view.findViewById(R.id.context_menu_main).getHeight(); menuFullHeight = view.findViewById(R.id.context_menu_main).getHeight();
zoomButtonsHeight = zoomButtonsView.getHeight();
int dy = 0; int dy = 0;
if (!menu.isLandscapeLayout()) { if (!menu.isLandscapeLayout()) {
@ -960,7 +1024,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
public void centerMarkerLocation() { public void centerMarkerLocation() {
centered = true; centered = true;
showOnMap(menu.getLatLon(), true, true, false); showOnMap(menu.getLatLon(), true, true, false, getZoom());
} }
private int getZoom() { private int getZoom() {
@ -994,21 +1058,20 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
return new LatLon(flat, flon); return new LatLon(flat, flon);
} }
private void showOnMap(LatLon latLon, boolean updateCoords, boolean needMove, boolean alreadyAdjusted) { private void showOnMap(LatLon latLon, boolean updateCoords, boolean needMove, boolean alreadyAdjusted, int zoom) {
AnimateDraggingMapThread thread = map.getAnimatedDraggingThread(); AnimateDraggingMapThread thread = map.getAnimatedDraggingThread();
int fZoom = getZoom(); LatLon calcLatLon = calculateCenterLatLon(latLon, zoom, updateCoords);
LatLon calcLatLon = calculateCenterLatLon(latLon, fZoom, updateCoords);
if (updateCoords) { if (updateCoords) {
mapCenter = calcLatLon; mapCenter = calcLatLon;
menu.setMapCenter(mapCenter); menu.setMapCenter(mapCenter);
} }
if (!alreadyAdjusted) { if (!alreadyAdjusted) {
calcLatLon = getAdjustedMarkerLocation(getPosY(), calcLatLon, true, fZoom); calcLatLon = getAdjustedMarkerLocation(getPosY(), calcLatLon, true, zoom);
} }
if (needMove) { if (needMove) {
thread.startMoving(calcLatLon.getLatitude(), calcLatLon.getLongitude(), fZoom, true); thread.startMoving(calcLatLon.getLatitude(), calcLatLon.getLongitude(), zoom, true);
} }
} }
@ -1137,30 +1200,36 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
if (!oldAndroid()) { if (!oldAndroid()) {
mainView.setY(y); mainView.setY(y);
fabView.setY(getFabY(y)); fabView.setY(getFabY(y));
zoomButtonsView.setY(getZoomButtonsY(y));
} else { } else {
mainView.setPadding(0, y, 0, 0); mainView.setPadding(0, y, 0, 0);
fabView.setPadding(0, getFabY(y), 0, 0); fabView.setPadding(0, getFabY(y), 0, 0);
zoomButtonsView.setPadding(0, getZoomButtonsY(y), 0, 0);
} }
if (!customMapCenter) { if (!customMapCenter) {
if (adjustMapPos) { if (adjustMapPos) {
adjustMapPosition(y, animated, centered); adjustMapPosition(y, animated, centered, 0);
} }
} else { } else {
customMapCenter = false; customMapCenter = false;
} }
} }
private void adjustMapPosition(int y, boolean animated, boolean center) { private void adjustMapPosition(int y, boolean animated, boolean center, int dZoom) {
map.getAnimatedDraggingThread().stopAnimatingSync(); map.getAnimatedDraggingThread().stopAnimatingSync();
LatLon latlon = getAdjustedMarkerLocation(y, menu.getLatLon(), center, getZoom()); int zoom = getZoom() + dZoom;
LatLon latlon = getAdjustedMarkerLocation(y, menu.getLatLon(), center, zoom);
if (map.getLatitude() == latlon.getLatitude() && map.getLongitude() == latlon.getLongitude()) { if (map.getLatitude() == latlon.getLatitude() && map.getLongitude() == latlon.getLongitude() && dZoom == 0) {
return; return;
} }
if (animated) { if (animated) {
showOnMap(latlon, false, true, true); showOnMap(latlon, false, true, true, zoom);
} else { } else {
if (dZoom != 0) {
map.setIntZoom(zoom);
}
map.setLatLon(latlon.getLatitude(), latlon.getLongitude()); map.setLatLon(latlon.getLatitude(), latlon.getLongitude());
} }
} }
@ -1236,6 +1305,10 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
return fabY; return fabY;
} }
private int getZoomButtonsY(int y) {
return y - zoomButtonsHeight - fabPaddingTopPx;
}
private boolean oldAndroid() { private boolean oldAndroid() {
return (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH); return (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH);
} }
@ -1268,7 +1341,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
if (mapCenter != null) { if (mapCenter != null) {
map.setLatLon(mapCenter.getLatitude(), mapCenter.getLongitude()); map.setLatLon(mapCenter.getLatitude(), mapCenter.getLongitude());
} }
adjustMapPosition(getPosY(), true, false); adjustMapPosition(getPosY(), true, false, 0);
} else { } else {
view.setVisibility(View.GONE); view.setVisibility(View.GONE);
} }

View file

@ -353,6 +353,10 @@ public abstract class MenuController extends BaseMenuController {
return true; return true;
} }
public boolean zoomButtonsVisible() {
return !isLandscapeLayout();
}
public boolean buttonsVisible() { public boolean buttonsVisible() {
return true; return true;
} }

View file

@ -55,6 +55,7 @@ public class MapRouteInfoMenuFragment extends Fragment {
if (menu == null) { if (menu == null) {
dismiss(); dismiss();
} }
getMapActivity().getMapLayers().getMapControlsLayer().showMapControls();
} }
@Override @Override

View file

@ -365,6 +365,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
if (mapActivity != null) { if (mapActivity != null) {
mapActivity.getMyApplication().getLocationProvider().addLocationListener(this); mapActivity.getMyApplication().getLocationProvider().addLocationListener(this);
} }
getMapActivity().getMapLayers().getMapControlsLayer().showMapControls();
} }
@Override @Override

View file

@ -282,6 +282,10 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
showDirectionEnabled = false; showDirectionEnabled = false;
break; break;
} }
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.refreshMap();
}
if (listener != null) { if (listener != null) {
listener.onMapMarkersModeChanged(showDirectionEnabled); listener.onMapMarkersModeChanged(showDirectionEnabled);
} }
@ -289,7 +293,7 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
} }
}; };
interface ShowDirectionFragmentListener { public interface ShowDirectionFragmentListener {
void onMapMarkersModeChanged(boolean showDirectionEnabled); void onMapMarkersModeChanged(boolean showDirectionEnabled);
} }
} }

View file

@ -457,6 +457,12 @@ public class MeasurementToolFragment extends Fragment {
return view; return view;
} }
@Override
public void onResume() {
super.onResume();
getMapActivity().getMapLayers().getMapControlsLayer().showMapControls();
}
@Override @Override
public void onDestroyView() { public void onDestroyView() {
super.onDestroyView(); super.onDestroyView();
@ -665,7 +671,7 @@ public class MeasurementToolFragment extends Fragment {
return new SaveAsNewTrackFragmentListener() { return new SaveAsNewTrackFragmentListener() {
@Override @Override
public void saveAsRoutePointOnClick() { public void saveAsRoutePointOnClick() {
saveAsGpx(SaveType.ROUTE_POINT); saveAsGpx(editingCtx.isInSnapToRoadMode() ? SaveType.SNAP_TO_ROAD : SaveType.ROUTE_POINT);
} }
@Override @Override

View file

@ -182,7 +182,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
if (!importing) { if (!importing) {
if (asyncLoader == null || asyncLoader.getResult() == null) { if (asyncLoader == null || asyncLoader.getResult() == null) {
asyncLoader = new LoadGpxTask(); asyncLoader = new LoadGpxTask();
asyncLoader.execute(getActivity()); asyncLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else { } else {
allGpxAdapter.refreshSelected(); allGpxAdapter.refreshSelected();
allGpxAdapter.notifyDataSetChanged(); allGpxAdapter.notifyDataSetChanged();

View file

@ -809,8 +809,11 @@ public class ContextMenuLayer extends OsmandMapLayer {
} }
} }
hideVisibleMenues(); boolean processed = hideVisibleMenues();
menu.onSingleTapOnMap(); processed |= menu.onSingleTapOnMap();
if (!processed) {
activity.getMapLayers().getMapControlsLayer().switchMapControlsVisibility();
}
return false; return false;
} }
@ -854,10 +857,12 @@ public class ContextMenuLayer extends OsmandMapLayer {
return res; return res;
} }
private void hideVisibleMenues() { private boolean hideVisibleMenues() {
if (multiSelectionMenu.isVisible()) { if (multiSelectionMenu.isVisible()) {
multiSelectionMenu.hide(); multiSelectionMenu.hide();
return true;
} }
return false;
} }
private void showContextMenuForSelectedObjects(final LatLon latLon, final Map<Object, IContextMenuProvider> selectedObjects) { private void showContextMenuForSelectedObjects(final LatLon latLon, final Map<Object, IContextMenuProvider> selectedObjects) {

View file

@ -48,6 +48,7 @@ import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu; import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu; import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu;
import net.osmand.plus.measurementtool.MeasurementToolFragment;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.corenative.NativeCoreContext; import net.osmand.plus.views.corenative.NativeCoreContext;
@ -628,12 +629,14 @@ public class MapControlsLayer extends OsmandMapLayer {
zoomInButton.setOnClickListener(new View.OnClickListener() { zoomInButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (mapActivity.getContextMenu().zoomInPressed()) {
return;
}
if (view.isZooming()) { if (view.isZooming()) {
mapActivity.changeZoom(2, System.currentTimeMillis()); mapActivity.changeZoom(2, System.currentTimeMillis());
} else { } else {
mapActivity.changeZoom(1, System.currentTimeMillis()); mapActivity.changeZoom(1, System.currentTimeMillis());
} }
} }
}); });
final View.OnLongClickListener listener = MapControlsLayer.getOnClickMagnifierListener(view); final View.OnLongClickListener listener = MapControlsLayer.getOnClickMagnifierListener(view);
@ -645,12 +648,44 @@ public class MapControlsLayer extends OsmandMapLayer {
zoomOutButton.setOnClickListener(new View.OnClickListener() { zoomOutButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (mapActivity.getContextMenu().zoomOutPressed()) {
return;
}
mapActivity.changeZoom(-1, System.currentTimeMillis()); mapActivity.changeZoom(-1, System.currentTimeMillis());
} }
}); });
zoomOutButton.setOnLongClickListener(listener); zoomOutButton.setOnLongClickListener(listener);
} }
public void showMapControls() {
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE);
}
public void hideMapControls() {
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE);
}
public void setMapControlsVisibility(boolean visible) {
View mapHudButtonsOverlay = mapActivity.findViewById(R.id.MapHudButtonsOverlay);
mapHudButtonsOverlay.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
}
public boolean isMapControlsVisible() {
return mapActivity.findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE;
}
public void switchMapControlsVisibility() {
if (app.getRoutingHelper().isFollowingMode() || app.getRoutingHelper().isPauseNavigation()
|| mapActivity.getMeasurementToolFragment() != null
|| mapActivity.getPlanRouteFragment() != null) {
return;
}
if (isMapControlsVisible()) {
hideMapControls();
} else {
showMapControls();
}
}
public void startNavigation() { public void startNavigation() {
OsmandApplication app = mapActivity.getMyApplication(); OsmandApplication app = mapActivity.getMyApplication();
RoutingHelper routingHelper = app.getRoutingHelper(); RoutingHelper routingHelper = app.getRoutingHelper();
@ -708,7 +743,7 @@ public class MapControlsLayer extends OsmandMapLayer {
boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode(); boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode();
boolean routeDialogOpened = MapRouteInfoMenu.isVisible(); boolean routeDialogOpened = MapRouteInfoMenu.isVisible();
boolean trackDialogOpened = TrackDetailsMenu.isVisible(); boolean trackDialogOpened = TrackDetailsMenu.isVisible();
boolean contextMenuOpened = mapActivity.getContextMenu().shouldShowControls(); boolean contextMenuOpened = mapActivity.getContextMenu().shouldShowTopControls();
boolean showRouteCalculationControls = routePlanningMode || boolean showRouteCalculationControls = routePlanningMode ||
((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode); ((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode);
updateMyLocation(rh, routeDialogOpened || trackDialogOpened || !contextMenuOpened); updateMyLocation(rh, routeDialogOpened || trackDialogOpened || !contextMenuOpened);
@ -790,8 +825,8 @@ public class MapControlsLayer extends OsmandMapLayer {
private boolean shouldShowCompass() { private boolean shouldShowCompass() {
float mapRotate = mapActivity.getMapView().getRotate(); float mapRotate = mapActivity.getMapView().getRotate();
return forceShowCompass || mapRotate != 0 return forceShowCompass || mapRotate != 0
|| settings.ROTATE_MAP.get() != OsmandSettings.ROTATE_MAP_NONE || settings.ROTATE_MAP.get() != OsmandSettings.ROTATE_MAP_NONE
|| mapActivity.getMapLayers().getMapInfoLayer().getMapInfoControls().isVisible("compass"); || mapActivity.getMapLayers().getMapInfoLayer().getMapInfoControls().isVisible("compass");
} }
public CompassDrawable getCompassDrawable(Drawable originalDrawable) { public CompassDrawable getCompassDrawable(Drawable originalDrawable) {
@ -1122,8 +1157,8 @@ public class MapControlsLayer extends OsmandMapLayer {
this.mapQuickActionLayer = mapQuickActionLayer; this.mapQuickActionLayer = mapQuickActionLayer;
} }
private boolean isInMovingMarkerMode(){ private boolean isInMovingMarkerMode() {
return mapQuickActionLayer == null ? contextMenuLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInAddGpxPointMode(): return mapQuickActionLayer == null ? contextMenuLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInAddGpxPointMode() :
mapQuickActionLayer.isInMovingMarkerMode() || contextMenuLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInAddGpxPointMode(); mapQuickActionLayer.isInMovingMarkerMode() || contextMenuLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInAddGpxPointMode();
} }

View file

@ -107,7 +107,6 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
private void initUI() { private void initUI() {
bitmapPaint = new Paint(); bitmapPaint = new Paint();
bitmapPaint.setDither(true);
bitmapPaint.setAntiAlias(true); bitmapPaint.setAntiAlias(true);
bitmapPaint.setFilterBitmap(true); bitmapPaint.setFilterBitmap(true);
markerBitmapBlue = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_marker_blue); markerBitmapBlue = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_marker_blue);

View file

@ -28,8 +28,6 @@ import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.WaypointDialogHelper; import net.osmand.plus.helpers.WaypointDialogHelper;
import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper; import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu; import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
import net.osmand.plus.routing.RouteDirectionInfo; import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
@ -813,7 +811,7 @@ public class MapInfoWidgetsFactory {
} }
} }
} }
if (map.isTopToolbarActive() || !map.getContextMenu().shouldShowControls()) { if (map.isTopToolbarActive() || !map.getContextMenu().shouldShowTopControls()) {
updateVisibility(false); updateVisibility(false);
} else if (!showNextTurn && updateWaypoint()) { } else if (!showNextTurn && updateWaypoint()) {
updateVisibility(true); updateVisibility(true);

View file

@ -200,7 +200,7 @@ public class MapMarkersWidgetsFactory {
|| MapRouteInfoMenu.isVisible() || MapRouteInfoMenu.isVisible()
|| addressTopBar.getVisibility() == View.VISIBLE || addressTopBar.getVisibility() == View.VISIBLE
|| map.isTopToolbarActive() || map.isTopToolbarActive()
|| !map.getContextMenu().shouldShowControls() || !map.getContextMenu().shouldShowTopControls()
|| map.getMapLayers().getMapMarkersLayer().isInPlanRouteMode()) { || map.getMapLayers().getMapMarkersLayer().isInPlanRouteMode()) {
updateVisibility(false); updateVisibility(false);
return; return;

View file

@ -1,11 +1,9 @@
package net.osmand.plus.views.mapwidgets; package net.osmand.plus.views.mapwidgets;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
@ -19,16 +17,15 @@ import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.IconsCache; import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.MapMarkersMode;
import net.osmand.plus.OsmandSettings.OsmandPreference; import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dialogs.ConfigureMapMenu; import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.mapmarkers.ShowDirectionBottomSheetDialogFragment;
import net.osmand.plus.quickaction.QuickActionListFragment; import net.osmand.plus.quickaction.QuickActionListFragment;
import net.osmand.plus.views.MapInfoLayer; import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.MapQuickActionLayer; import net.osmand.plus.views.MapQuickActionLayer;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.widgets.IconPopupMenu; import net.osmand.plus.widgets.IconPopupMenu;
import java.util.Collections; import java.util.Collections;
@ -329,27 +326,17 @@ public class MapWidgetRegistry {
.setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map)) .setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map))
.setListener(new ContextMenuAdapter.ItemClickListener() { .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override @Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId, final int position, boolean isChecked) {
int itemId, final int pos, boolean isChecked) { ShowDirectionBottomSheetDialogFragment fragment = new ShowDirectionBottomSheetDialogFragment();
final OsmandMapTileView view = map.getMapView(); fragment.setListener(new ShowDirectionBottomSheetDialogFragment.ShowDirectionFragmentListener() {
AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
bld.setTitle(R.string.map_markers);
final String[] items = new String[MapMarkersMode.values().length];
for (int i = 0; i < items.length; i++) {
items[i] = MapMarkersMode.values()[i].toHumanString(map);
}
int i = settings.MAP_MARKERS_MODE.get().ordinal();
bld.setSingleChoiceItems(items, i, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onMapMarkersModeChanged(boolean showDirectionEnabled) {
settings.MAP_MARKERS_MODE.set(MapMarkersMode.values()[which]);
updateMapMarkersMode(map); updateMapMarkersMode(map);
dialog.dismiss(); cm.getItem(position).setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map));
cm.getItem(pos).setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map)); adapter.notifyDataSetChanged();
ad.notifyDataSetChanged();
} }
}); });
bld.show(); fragment.show(map.getSupportFragmentManager(), ShowDirectionBottomSheetDialogFragment.TAG);
return false; return false;
} }
}).setLayout(R.layout.list_item_text_button).createItem()); }).setLayout(R.layout.list_item_text_button).createItem());