diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 8a71d58fac..df21e62f25 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -11,6 +11,9 @@
Thx - Hardy
-->
+ Download map dialog
+ Dialogs and notifications
+ Control popups, dialogs and notifications that OsmAnd show during usage.
Clear %1$s?
Revert
Track saved
diff --git a/OsmAnd/res/xml/dialogs_and_notifications_preferences.xml b/OsmAnd/res/xml/dialogs_and_notifications_preferences.xml
new file mode 100644
index 0000000000..ab29470e9a
--- /dev/null
+++ b/OsmAnd/res/xml/dialogs_and_notifications_preferences.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/xml/global_settings.xml b/OsmAnd/res/xml/global_settings.xml
index db5b667f2d..4cfc5800cb 100644
--- a/OsmAnd/res/xml/global_settings.xml
+++ b/OsmAnd/res/xml/global_settings.xml
@@ -42,14 +42,14 @@
android:summaryOn="@string/shared_string_on"
android:title="@string/analytics_pref_title" />
-
+ android:title="@string/dialogs_and_notifications_title"
+ android:summary="@string/shared_string_all"
+ app:fragment="net.osmand.plus.settings.DialogsAndNotificationsSettingsFragment"
+ tools:icon="@drawable/ic_action_notification" />
USE_KALMAN_FILTER_FOR_COMPASS = new BooleanPreference("use_kalman_filter_compass", true).makeProfile().makeGeneral().cache();
public final OsmandPreference DO_NOT_SHOW_STARTUP_MESSAGES = new BooleanPreference("do_not_show_startup_messages", false).makeGlobal().cache();
+ public final OsmandPreference SHOW_DOWNLOAD_MAP_DIALOG = new BooleanPreference("show_download_map_dialog", true).makeGlobal().cache();
public final OsmandPreference DO_NOT_USE_ANIMATIONS = new BooleanPreference("do_not_use_animations", false).makeProfile().makeGeneral().cache();
public final OsmandPreference SEND_ANONYMOUS_MAP_DOWNLOADS_DATA = new BooleanPreference("send_anonymous_map_downloads_data", false).makeGlobal().cache();
diff --git a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java
index 982985bb54..2545f18932 100644
--- a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java
@@ -96,7 +96,8 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
VEHICLE_PARAMETERS(VehicleParametersFragment.class.getName(), true, R.xml.vehicle_parameters, R.layout.profile_preference_toolbar),
MAP_DURING_NAVIGATION(MapDuringNavigationFragment.class.getName(), true, R.xml.map_during_navigation, R.layout.profile_preference_toolbar),
TURN_SCREEN_ON(TurnScreenOnFragment.class.getName(), true, R.xml.turn_screen_on, R.layout.profile_preference_toolbar_with_switch),
- DATA_STORAGE(DataStorageFragment.class.getName(), false, R.xml.data_storage, R.layout.global_preference_toolbar);
+ DATA_STORAGE(DataStorageFragment.class.getName(), false, R.xml.data_storage, R.layout.global_preference_toolbar),
+ DIALOGS_AND_NOTIFICATIONS_SETTINGS(DialogsAndNotificationsSettingsFragment.class.getName(), false, R.xml.dialogs_and_notifications_preferences, R.layout.global_preferences_toolbar_with_switch);
public final String fragmentName;
public final boolean profileDependent;
diff --git a/OsmAnd/src/net/osmand/plus/settings/DialogsAndNotificationsSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/DialogsAndNotificationsSettingsFragment.java
new file mode 100644
index 0000000000..051c456743
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/settings/DialogsAndNotificationsSettingsFragment.java
@@ -0,0 +1,54 @@
+package net.osmand.plus.settings;
+
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.SwitchPreferenceCompat;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import net.osmand.plus.R;
+import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
+
+public class DialogsAndNotificationsSettingsFragment extends BaseSettingsFragment {
+
+ public static final String TAG = DialogsAndNotificationsSettingsFragment.class.getSimpleName();
+
+ @Override
+ protected void createToolbar(LayoutInflater inflater, View view) {
+ super.createToolbar(inflater, view);
+ view.findViewById(R.id.toolbar_switch_container).setVisibility(View.GONE);
+ }
+
+ @Override
+ protected void setupPreferences() {
+ Preference mapDuringNavigationInfo = findPreference("dialogs_and_notifications_preferences_info");
+ mapDuringNavigationInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
+
+ setupShowStartupMessagesPref();
+ setupShowDownloadMapDialogPref();
+ }
+
+ private void setupShowStartupMessagesPref() {
+ boolean enabled = !settings.DO_NOT_SHOW_STARTUP_MESSAGES.get(); // pref ui was inverted
+ SwitchPreferenceCompat sendAnonymousData = (SwitchPreferenceCompat) findPreference(settings.DO_NOT_SHOW_STARTUP_MESSAGES.getId());
+ sendAnonymousData.setChecked(enabled);
+ }
+
+ private void setupShowDownloadMapDialogPref() {
+ SwitchPreferenceCompat showDownloadMapDialog = (SwitchPreferenceCompat) findPreference(settings.SHOW_DOWNLOAD_MAP_DIALOG.getId());
+ showDownloadMapDialog.setIcon(getContentIcon(R.drawable.ic_action_import));
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ String prefId = preference.getKey();
+
+ if (prefId.equals(settings.DO_NOT_SHOW_STARTUP_MESSAGES.getId())) {
+ if (newValue instanceof Boolean) {
+ boolean enabled = !(Boolean) newValue;
+ return settings.DO_NOT_SHOW_STARTUP_MESSAGES.set(enabled);
+ }
+ }
+ return super.onPreferenceChange(preference, newValue);
+ }
+
+}
diff --git a/OsmAnd/src/net/osmand/plus/settings/GlobalSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/GlobalSettingsFragment.java
index 569d3ba12a..cd07a69928 100644
--- a/OsmAnd/src/net/osmand/plus/settings/GlobalSettingsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/GlobalSettingsFragment.java
@@ -22,6 +22,7 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
public static final String TAG = GlobalSettingsFragment.class.getSimpleName();
private static final String SEND_ANONYMOUS_DATA_PREF_ID = "send_anonymous_data";
+ private static final String DIALOGS_AND_NOTIFICATIONS_PREF_ID = "dialogs_and_notifications";
@Override
protected void setupPreferences() {
@@ -30,7 +31,7 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
setupExternalStorageDirPref();
setupSendAnonymousDataPref();
- setupShowStartupMessagesPref();
+ setupDialogsAndNotificationsPref();
setupEnableProxyPref();
}
@@ -67,11 +68,6 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
}
}
return false;
- } else if (prefId.equals(settings.DO_NOT_SHOW_STARTUP_MESSAGES.getId())) {
- if (newValue instanceof Boolean) {
- boolean enabled = !(Boolean) newValue;
- return settings.DO_NOT_SHOW_STARTUP_MESSAGES.set(enabled);
- }
}
return super.onPreferenceChange(preference, newValue);
@@ -171,11 +167,9 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
sendAnonymousData.setChecked(enabled);
}
- private void setupShowStartupMessagesPref() {
- boolean enabled = !settings.DO_NOT_SHOW_STARTUP_MESSAGES.get(); // pref ui was inverted
-
- SwitchPreferenceCompat sendAnonymousData = (SwitchPreferenceCompat) findPreference(settings.DO_NOT_SHOW_STARTUP_MESSAGES.getId());
- sendAnonymousData.setChecked(enabled);
+ private void setupDialogsAndNotificationsPref() {
+ Preference dialogsAndNotifications = (Preference) findPreference(DIALOGS_AND_NOTIFICATIONS_PREF_ID);
+ dialogsAndNotifications.setIcon(getContentIcon(R.drawable.ic_action_notification));
}
private void setupEnableProxyPref() {
diff --git a/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java b/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java
index 663bd49b1f..ed87be6605 100644
--- a/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java
+++ b/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java
@@ -72,6 +72,9 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
private MapLayerData> data;
private List selectedObjects = new LinkedList<>();
+ private int lastCheckMapCx;
+ private int lastCheckMapCy;
+
private static int ZOOM_TO_SHOW_MAP_NAMES = 6;
private static int ZOOM_AFTER_BASEMAP = 12;
@@ -193,7 +196,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
return;
}
//make sure no maps are loaded for the location
- checkMapToDownload(zoom, data.results);
+ checkMapToDownload(tileBox, data.results);
// draw objects
if (osmandRegions.isInitialized() && zoom >= ZOOM_TO_SHOW_SELECTION_ST && zoom < ZOOM_TO_SHOW_SELECTION) {
final List currentObjects = new LinkedList<>();
@@ -231,12 +234,19 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
}
}
- private void checkMapToDownload(int zoom, List currentObjects) {
- if (zoom >= ZOOM_MIN_TO_SHOW_DOWNLOAD_DIALOG && zoom <= ZOOM_MAX_TO_SHOW_DOWNLOAD_DIALOG
+ private void checkMapToDownload(RotatedTileBox tileBox, List currentObjects) {
+ int zoom = tileBox.getZoom();
+ int cx = tileBox.getCenter31X();
+ int cy = tileBox.getCenter31Y();
+ if (lastCheckMapCx == cx && lastCheckMapCy == cy) {
+ return;
+ }
+ lastCheckMapCx = cx;
+ lastCheckMapCy = cy;
+ if (app.getSettings().SHOW_DOWNLOAD_MAP_DIALOG.get()
+ && zoom >= ZOOM_MIN_TO_SHOW_DOWNLOAD_DIALOG && zoom <= ZOOM_MAX_TO_SHOW_DOWNLOAD_DIALOG
&& currentObjects != null) {
WorldRegion regionData;
- int cx = view.getCurrentRotatedTileBox().getCenter31X();
- int cy = view.getCurrentRotatedTileBox().getCenter31Y();
for (int i = 0; i < currentObjects.size(); i++) {
final BinaryMapDataObject o = currentObjects.get(i);
if (!osmandRegions.contain(o, cx, cy)) {