Added setting to disable map suggestion
This commit is contained in:
parent
5dad2e5e90
commit
c296b9c0ec
8 changed files with 121 additions and 24 deletions
|
@ -11,6 +11,9 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<string name="download_map_dialog">Download map dialog</string>
|
||||||
|
<string name="dialogs_and_notifications_title">Dialogs and notifications</string>
|
||||||
|
<string name="dialogs_and_notifications_descr">Control popups, dialogs and notifications that OsmAnd show during usage.</string>
|
||||||
<string name="clear_confirmation_msg">Clear %1$s?</string>
|
<string name="clear_confirmation_msg">Clear %1$s?</string>
|
||||||
<string name="shared_string_revert">Revert</string>
|
<string name="shared_string_revert">Revert</string>
|
||||||
<string name="track_saved">Track saved</string>
|
<string name="track_saved">Track saved</string>
|
||||||
|
|
34
OsmAnd/res/xml/dialogs_and_notifications_preferences.xml
Normal file
34
OsmAnd/res/xml/dialogs_and_notifications_preferences.xml
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:description="@string/dialogs_and_notifications_descr"
|
||||||
|
android:key="dialogs_and_notifications"
|
||||||
|
android:title="@string/dialogs_and_notifications_title">
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="dialogs_and_notifications_preferences_info"
|
||||||
|
android:layout="@layout/preference_info"
|
||||||
|
android:persistent="false"
|
||||||
|
android:selectable="false"
|
||||||
|
android:title="@string/dialogs_and_notifications_descr"
|
||||||
|
tools:icon="@drawable/ic_action_info_dark" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:icon="@drawable/ic_action_notification"
|
||||||
|
android:key="do_not_show_startup_messages"
|
||||||
|
android:layout="@layout/preference_switch_with_descr"
|
||||||
|
android:persistent="false"
|
||||||
|
android:summaryOff="@string/shared_string_off"
|
||||||
|
android:summaryOn="@string/shared_string_on"
|
||||||
|
android:title="@string/start_up_message_pref" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:icon="@drawable/ic_action_import"
|
||||||
|
android:key="show_download_map_dialog"
|
||||||
|
android:layout="@layout/preference_switch_with_descr"
|
||||||
|
android:persistent="true"
|
||||||
|
android:summaryOff="@string/shared_string_off"
|
||||||
|
android:summaryOn="@string/shared_string_on"
|
||||||
|
android:title="@string/download_map_dialog" />
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
|
@ -42,14 +42,14 @@
|
||||||
android:summaryOn="@string/shared_string_on"
|
android:summaryOn="@string/shared_string_on"
|
||||||
android:title="@string/analytics_pref_title" />
|
android:title="@string/analytics_pref_title" />
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<Preference
|
||||||
android:icon="@drawable/ic_action_notification"
|
android:key="dialogs_and_notifications"
|
||||||
android:key="do_not_show_startup_messages"
|
android:layout="@layout/preference_with_descr"
|
||||||
android:layout="@layout/preference_switch_with_descr"
|
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:summaryOff="@string/shared_string_off"
|
android:title="@string/dialogs_and_notifications_title"
|
||||||
android:summaryOn="@string/shared_string_on"
|
android:summary="@string/shared_string_all"
|
||||||
android:title="@string/start_up_message_pref" />
|
app:fragment="net.osmand.plus.settings.DialogsAndNotificationsSettingsFragment"
|
||||||
|
tools:icon="@drawable/ic_action_notification" />
|
||||||
|
|
||||||
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
|
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
|
||||||
android:key="enable_proxy"
|
android:key="enable_proxy"
|
||||||
|
|
|
@ -1397,6 +1397,7 @@ public class OsmandSettings {
|
||||||
public final OsmandPreference<Boolean> USE_KALMAN_FILTER_FOR_COMPASS = new BooleanPreference("use_kalman_filter_compass", true).makeProfile().makeGeneral().cache();
|
public final OsmandPreference<Boolean> USE_KALMAN_FILTER_FOR_COMPASS = new BooleanPreference("use_kalman_filter_compass", true).makeProfile().makeGeneral().cache();
|
||||||
|
|
||||||
public final OsmandPreference<Boolean> DO_NOT_SHOW_STARTUP_MESSAGES = new BooleanPreference("do_not_show_startup_messages", false).makeGlobal().cache();
|
public final OsmandPreference<Boolean> DO_NOT_SHOW_STARTUP_MESSAGES = new BooleanPreference("do_not_show_startup_messages", false).makeGlobal().cache();
|
||||||
|
public final OsmandPreference<Boolean> SHOW_DOWNLOAD_MAP_DIALOG = new BooleanPreference("show_download_map_dialog", true).makeGlobal().cache();
|
||||||
public final OsmandPreference<Boolean> DO_NOT_USE_ANIMATIONS = new BooleanPreference("do_not_use_animations", false).makeProfile().makeGeneral().cache();
|
public final OsmandPreference<Boolean> DO_NOT_USE_ANIMATIONS = new BooleanPreference("do_not_use_animations", false).makeProfile().makeGeneral().cache();
|
||||||
|
|
||||||
public final OsmandPreference<Boolean> SEND_ANONYMOUS_MAP_DOWNLOADS_DATA = new BooleanPreference("send_anonymous_map_downloads_data", false).makeGlobal().cache();
|
public final OsmandPreference<Boolean> SEND_ANONYMOUS_MAP_DOWNLOADS_DATA = new BooleanPreference("send_anonymous_map_downloads_data", false).makeGlobal().cache();
|
||||||
|
|
|
@ -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),
|
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),
|
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),
|
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 String fragmentName;
|
||||||
public final boolean profileDependent;
|
public final boolean profileDependent;
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
|
||||||
public static final String TAG = GlobalSettingsFragment.class.getSimpleName();
|
public static final String TAG = GlobalSettingsFragment.class.getSimpleName();
|
||||||
|
|
||||||
private static final String SEND_ANONYMOUS_DATA_PREF_ID = "send_anonymous_data";
|
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
|
@Override
|
||||||
protected void setupPreferences() {
|
protected void setupPreferences() {
|
||||||
|
@ -30,7 +31,7 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
|
||||||
setupExternalStorageDirPref();
|
setupExternalStorageDirPref();
|
||||||
|
|
||||||
setupSendAnonymousDataPref();
|
setupSendAnonymousDataPref();
|
||||||
setupShowStartupMessagesPref();
|
setupDialogsAndNotificationsPref();
|
||||||
setupEnableProxyPref();
|
setupEnableProxyPref();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,11 +68,6 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
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);
|
return super.onPreferenceChange(preference, newValue);
|
||||||
|
@ -171,11 +167,9 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
|
||||||
sendAnonymousData.setChecked(enabled);
|
sendAnonymousData.setChecked(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupShowStartupMessagesPref() {
|
private void setupDialogsAndNotificationsPref() {
|
||||||
boolean enabled = !settings.DO_NOT_SHOW_STARTUP_MESSAGES.get(); // pref ui was inverted
|
Preference dialogsAndNotifications = (Preference) findPreference(DIALOGS_AND_NOTIFICATIONS_PREF_ID);
|
||||||
|
dialogsAndNotifications.setIcon(getContentIcon(R.drawable.ic_action_notification));
|
||||||
SwitchPreferenceCompat sendAnonymousData = (SwitchPreferenceCompat) findPreference(settings.DO_NOT_SHOW_STARTUP_MESSAGES.getId());
|
|
||||||
sendAnonymousData.setChecked(enabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupEnableProxyPref() {
|
private void setupEnableProxyPref() {
|
||||||
|
|
|
@ -72,6 +72,9 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
private MapLayerData<List<BinaryMapDataObject>> data;
|
private MapLayerData<List<BinaryMapDataObject>> data;
|
||||||
private List<BinaryMapDataObject> selectedObjects = new LinkedList<>();
|
private List<BinaryMapDataObject> selectedObjects = new LinkedList<>();
|
||||||
|
|
||||||
|
private int lastCheckMapCx;
|
||||||
|
private int lastCheckMapCy;
|
||||||
|
|
||||||
private static int ZOOM_TO_SHOW_MAP_NAMES = 6;
|
private static int ZOOM_TO_SHOW_MAP_NAMES = 6;
|
||||||
private static int ZOOM_AFTER_BASEMAP = 12;
|
private static int ZOOM_AFTER_BASEMAP = 12;
|
||||||
|
|
||||||
|
@ -193,7 +196,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//make sure no maps are loaded for the location
|
//make sure no maps are loaded for the location
|
||||||
checkMapToDownload(zoom, data.results);
|
checkMapToDownload(tileBox, data.results);
|
||||||
// draw objects
|
// draw objects
|
||||||
if (osmandRegions.isInitialized() && zoom >= ZOOM_TO_SHOW_SELECTION_ST && zoom < ZOOM_TO_SHOW_SELECTION) {
|
if (osmandRegions.isInitialized() && zoom >= ZOOM_TO_SHOW_SELECTION_ST && zoom < ZOOM_TO_SHOW_SELECTION) {
|
||||||
final List<BinaryMapDataObject> currentObjects = new LinkedList<>();
|
final List<BinaryMapDataObject> currentObjects = new LinkedList<>();
|
||||||
|
@ -231,12 +234,19 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkMapToDownload(int zoom, List<BinaryMapDataObject> currentObjects) {
|
private void checkMapToDownload(RotatedTileBox tileBox, List<BinaryMapDataObject> currentObjects) {
|
||||||
if (zoom >= ZOOM_MIN_TO_SHOW_DOWNLOAD_DIALOG && zoom <= ZOOM_MAX_TO_SHOW_DOWNLOAD_DIALOG
|
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) {
|
&& currentObjects != null) {
|
||||||
WorldRegion regionData;
|
WorldRegion regionData;
|
||||||
int cx = view.getCurrentRotatedTileBox().getCenter31X();
|
|
||||||
int cy = view.getCurrentRotatedTileBox().getCenter31Y();
|
|
||||||
for (int i = 0; i < currentObjects.size(); i++) {
|
for (int i = 0; i < currentObjects.size(); i++) {
|
||||||
final BinaryMapDataObject o = currentObjects.get(i);
|
final BinaryMapDataObject o = currentObjects.get(i);
|
||||||
if (!osmandRegions.contain(o, cx, cy)) {
|
if (!osmandRegions.contain(o, cx, cy)) {
|
||||||
|
|
Loading…
Reference in a new issue