Merge branch 'r3.5'

This commit is contained in:
Chumva 2019-11-27 10:08:57 +02:00
commit 21ac829a3d
22 changed files with 244 additions and 141 deletions

View file

@ -310,7 +310,9 @@
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="content"/>
<data android:scheme="file"/> <data android:scheme="file"/>
<data android:scheme="data"/>
<data android:host="*"/> <data android:host="*"/>
<data android:mimeType="*/*"/> <data android:mimeType="*/*"/>
<data android:pathPattern=".*\\.osf" /> <data android:pathPattern=".*\\.osf" />

View file

@ -2627,7 +2627,7 @@
\n \n
\n\'Ayarlar\' → \'Gizlilik ve Güvenlik\' bölümünde istediğiniz zaman yapılandırın.</string> \n\'Ayarlar\' → \'Gizlilik ve Güvenlik\' bölümünde istediğiniz zaman yapılandırın.</string>
<string name="downloaded_maps_collect_descr">Ülke ve bölge haritası popülaritesini anlamamıza yardımcı olur.</string> <string name="downloaded_maps_collect_descr">Ülke ve bölge haritası popülaritesini anlamamıza yardımcı olur.</string>
<string name="privacy_and_security_change_descr">%1$\'lerimizi kabul ediyorsanız \"İzin Ver\"e dokunun</string> <string name="privacy_and_security_change_descr">%1$s\'lerimizi kabul ediyorsanız \"İzin Ver\"e dokunun</string>
<string name="nav_type_hint">Navigasyon türü</string> <string name="nav_type_hint">Navigasyon türü</string>
<string name="osmand_routing_promo">routing.xml dosyasının değiştirilmiş versiyonunu ..osmand/routing dizinine ekleyebilirsiniz</string> <string name="osmand_routing_promo">routing.xml dosyasının değiştirilmiş versiyonunu ..osmand/routing dizinine ekleyebilirsiniz</string>
<string name="show_compass_ruler">Pusula cetvelini göster</string> <string name="show_compass_ruler">Pusula cetvelini göster</string>

View file

@ -22,8 +22,9 @@
tools:icon="@drawable/ic_action_alert" /> tools:icon="@drawable/ic_action_alert" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx <net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="speak_routing_alarms" android:key="voice_mute"
android:layout="@layout/preference_with_descr_dialog_and_switch" android:layout="@layout/preference_with_descr_dialog_and_switch"
android:persistent="false"
android:summary="@string/voice_announces_descr" android:summary="@string/voice_announces_descr"
android:title="@string/voice_announces" android:title="@string/voice_announces"
app:fragment="net.osmand.plus.settings.VoiceAnnouncesFragment" app:fragment="net.osmand.plus.settings.VoiceAnnouncesFragment"

View file

@ -769,7 +769,6 @@ public class OsmandAidlApi {
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
MapActivity mapActivity = mapActivityRef.get(); MapActivity mapActivity = mapActivityRef.get();
if (mapActivity != null) { if (mapActivity != null) {
mapActivity.getMyApplication().getSettings().VOICE_MUTE.set(true);
mapActivity.getRoutingHelper().getVoiceRouter().setMute(true); mapActivity.getRoutingHelper().getVoiceRouter().setMute(true);
} }
} }
@ -784,7 +783,6 @@ public class OsmandAidlApi {
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
MapActivity mapActivity = mapActivityRef.get(); MapActivity mapActivity = mapActivityRef.get();
if (mapActivity != null) { if (mapActivity != null) {
mapActivity.getMyApplication().getSettings().VOICE_MUTE.set(false);
mapActivity.getRoutingHelper().getVoiceRouter().setMute(false); mapActivity.getRoutingHelper().getVoiceRouter().setMute(false);
} }
} }

View file

@ -190,8 +190,9 @@ public class AppInitializer implements IProgress {
app.getSettings().BILLING_PURCHASE_TOKENS_SENT.set(""); app.getSettings().BILLING_PURCHASE_TOKENS_SENT.set("");
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_2).commit(); startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_2).commit();
} }
if (prevAppVersion < VERSION_3_5 || Version.getAppVersion(app).equals("3.5.3")) { if (prevAppVersion < VERSION_3_5 || Version.getAppVersion(app).equals("3.5.3")
app.getSettings().migrateGlobalPrefsToProfile(); || Version.getAppVersion(app).equals("3.5.4")) {
app.getSettings().migratePreferences();
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_5).commit(); startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_5).commit();
} }
startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit(); startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();

View file

@ -229,24 +229,31 @@ public class OsmandSettings {
return globalPreferences != null && globalPreferences.getBoolean(SETTING_CUSTOMIZED_ID, false); return globalPreferences != null && globalPreferences.getBoolean(SETTING_CUSTOMIZED_ID, false);
} }
public void migrateGlobalPrefsToProfile() { public void migratePreferences() {
SharedPreferences sharedPreferences = (SharedPreferences) globalPreferences; SharedPreferences globalSharedPreferences = (SharedPreferences) globalPreferences;
Map<String, ?> map = sharedPreferences.getAll(); Map<String, ?> globalPrefsMap = globalSharedPreferences.getAll();
for (String key : map.keySet()) { for (String key : globalPrefsMap.keySet()) {
OsmandPreference pref = getPreference(key); OsmandPreference pref = getPreference(key);
if (pref instanceof CommonPreference) { if (pref instanceof CommonPreference) {
CommonPreference commonPreference = (CommonPreference) pref; CommonPreference commonPreference = (CommonPreference) pref;
if (!commonPreference.global) { if (!commonPreference.global) {
List<ApplicationMode> modes = commonPreference.general ? Collections.singletonList(ApplicationMode.DEFAULT) : ApplicationMode.allPossibleValues(); List<ApplicationMode> modes = commonPreference.general ? Collections.singletonList(ApplicationMode.DEFAULT) : ApplicationMode.allPossibleValues();
boolean valueSaved = false;
for (ApplicationMode mode : modes) { for (ApplicationMode mode : modes) {
if (!commonPreference.isSetForMode(mode)) { if (!commonPreference.isSetForMode(mode)) {
valueSaved = setPreference(key, map.get(key), mode) || valueSaved; setPreference(key, globalPrefsMap.get(key), mode);
} }
} }
if (valueSaved) { }
settingsAPI.edit(globalPreferences).remove(key).commit(); }
} }
SharedPreferences defaultProfilePreferences = (SharedPreferences) this.defaultProfilePreferences;
Map<String, ?> defaultPrefsMap = defaultProfilePreferences.getAll();
for (String key : defaultPrefsMap.keySet()) {
OsmandPreference pref = getPreference(key);
if (pref instanceof CommonPreference) {
CommonPreference commonPreference = (CommonPreference) pref;
if (commonPreference.global && !commonPreference.isSet()) {
setPreference(key, defaultPrefsMap.get(key));
} }
} }
} }
@ -1643,7 +1650,6 @@ public class OsmandSettings {
public final OsmandPreference<Boolean> SHOW_NEARBY_FAVORITES = new BooleanPreference("show_nearby_favorites", false).makeProfile().cache(); public final OsmandPreference<Boolean> SHOW_NEARBY_FAVORITES = new BooleanPreference("show_nearby_favorites", false).makeProfile().cache();
public final OsmandPreference<Boolean> SHOW_NEARBY_POI = new BooleanPreference("show_nearby_poi", false).makeProfile().cache(); public final OsmandPreference<Boolean> SHOW_NEARBY_POI = new BooleanPreference("show_nearby_poi", false).makeProfile().cache();
public final OsmandPreference<Boolean> SPEAK_ROUTING_ALARMS = new BooleanPreference("speak_routing_alarms", true).makeProfile().cache();
public final OsmandPreference<Boolean> SPEAK_STREET_NAMES = new BooleanPreference("speak_street_names", true).makeProfile().cache(); public final OsmandPreference<Boolean> SPEAK_STREET_NAMES = new BooleanPreference("speak_street_names", true).makeProfile().cache();
public final CommonPreference<Boolean> SPEAK_TRAFFIC_WARNINGS = new BooleanPreference("speak_traffic_warnings", true).makeProfile().cache(); public final CommonPreference<Boolean> SPEAK_TRAFFIC_WARNINGS = new BooleanPreference("speak_traffic_warnings", true).makeProfile().cache();
{ {
@ -3130,7 +3136,7 @@ public class OsmandSettings {
public final OsmandPreference<Boolean> USE_OSM_LIVE_FOR_PUBLIC_TRANSPORT = new BooleanPreference("enable_osmc_public_transport", false).makeGlobal(); public final OsmandPreference<Boolean> USE_OSM_LIVE_FOR_PUBLIC_TRANSPORT = new BooleanPreference("enable_osmc_public_transport", false).makeGlobal();
public final OsmandPreference<Boolean> VOICE_MUTE = new BooleanPreference("voice_mute", false).makeGlobal(); public final OsmandPreference<Boolean> VOICE_MUTE = new BooleanPreference("voice_mute", false).makeProfile().cache();
// for background service // for background service
public final OsmandPreference<Boolean> MAP_ACTIVITY_ENABLED = new BooleanPreference("map_activity_enabled", false).makeGlobal(); public final OsmandPreference<Boolean> MAP_ACTIVITY_ENABLED = new BooleanPreference("map_activity_enabled", false).makeGlobal();

View file

@ -8,6 +8,7 @@ import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.util.Log; import android.util.Log;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -18,7 +19,9 @@ import android.widget.TextView;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
import net.osmand.plus.download.DownloadIndexesThread; import net.osmand.plus.download.DownloadIndexesThread;
import net.osmand.plus.srtmplugin.SRTMPlugin;
public class PluginActivity extends OsmandActionBarActivity implements DownloadIndexesThread.DownloadEvents { public class PluginActivity extends OsmandActionBarActivity implements DownloadIndexesThread.DownloadEvents {
private static final String TAG = "PluginActivity"; private static final String TAG = "PluginActivity";
@ -94,11 +97,19 @@ public class PluginActivity extends OsmandActionBarActivity implements Download
} }
}); });
Button getButton = (Button)findViewById(R.id.plugin_get); Button getButton = (Button)findViewById(R.id.plugin_get);
getButton.setText(plugin.isPaid() ? R.string.get_plugin : R.string.shared_string_install);
getButton.setOnClickListener(new View.OnClickListener() { getButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
try { try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL()))); if (plugin instanceof SRTMPlugin) {
FragmentManager fragmentManager = getSupportFragmentManager();
if (fragmentManager != null) {
ChoosePlanDialogFragment.showHillshadeSrtmPluginInstance(fragmentManager);
}
} else {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL())));
}
} catch (Exception e) { } catch (Exception e) {
//ignored //ignored
} }

View file

@ -238,17 +238,21 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
} }
} }
SQLiteDatabase db = getWritableDatabase(); if (warnings.isEmpty()) {
if (db != null && warnings.isEmpty() && db.isOpen()) { SQLiteDatabase db = getWritableDatabase();
try { if (db != null) {
// remove all from db try {
db.execSQL("DELETE FROM " + TRACK_NAME + " WHERE " + TRACK_COL_DATE + " <= ?", new Object[] { System.currentTimeMillis() }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (db.isOpen()) {
db.execSQL("DELETE FROM " + POINT_NAME + " WHERE " + POINT_COL_DATE + " <= ?", new Object[] { System.currentTimeMillis() }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ // remove all from db
// delete all db.execSQL("DELETE FROM " + TRACK_NAME + " WHERE " + TRACK_COL_DATE + " <= ?", new Object[]{System.currentTimeMillis()}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
// db.execSQL("DELETE FROM " + TRACK_NAME + " WHERE 1 = 1", new Object[] { }); //$NON-NLS-1$ //$NON-NLS-2$ db.execSQL("DELETE FROM " + POINT_NAME + " WHERE " + POINT_COL_DATE + " <= ?", new Object[]{System.currentTimeMillis()}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
// db.execSQL("DELETE FROM " + POINT_NAME + " WHERE 1 = 1", new Object[] { }); //$NON-NLS-1$ //$NON-NLS-2$ // delete all
} finally { // db.execSQL("DELETE FROM " + TRACK_NAME + " WHERE 1 = 1", new Object[] { }); //$NON-NLS-1$ //$NON-NLS-2$
db.close(); // db.execSQL("DELETE FROM " + POINT_NAME + " WHERE 1 = 1", new Object[] { }); //$NON-NLS-1$ //$NON-NLS-2$
}
} finally {
db.close();
}
} }
} }
distance = 0; distance = 0;
@ -609,14 +613,12 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
private synchronized void execWithClose(String script, Object[] objects) { private synchronized void execWithClose(String script, Object[] objects) {
SQLiteDatabase db = getWritableDatabase(); SQLiteDatabase db = getWritableDatabase();
try { if (db != null) {
if (db != null) { try {
db.execSQL(script, objects); db.execSQL(script, objects);
} } catch (RuntimeException e) {
} catch (RuntimeException e) { log.error(e.getMessage(), e);
log.error(e.getMessage(), e); } finally {
} finally {
if (db != null) {
db.close(); db.close();
} }
} }

View file

@ -4,7 +4,6 @@ import android.Manifest;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.content.ClipData; import android.content.ClipData;
import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnClickListener;
@ -408,8 +407,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
Method saveAttributes = exClass.getMethod("saveAttributes", new Class[]{}); Method saveAttributes = exClass.getMethod("saveAttributes", new Class[]{});
saveAttributes.invoke(exInstance); saveAttributes.invoke(exInstance);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); log.error(e.getMessage(), e);
log.error(e);
} }
} }
@ -425,8 +423,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
Integer it = (Integer) getAttributeInt.invoke(exInstance, "Orientation", 1); Integer it = (Integer) getAttributeInt.invoke(exInstance, "Orientation", 1);
orientation = it; orientation = it;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); log.error(e.getMessage(), e);
log.error(e);
} }
return orientation; return orientation;
} }
@ -1136,7 +1133,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
try { try {
mediaRec.stop(); mediaRec.stop();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
e.printStackTrace(); log.error(e.getMessage(), e);
} }
indexFile(true, mediaRecFile); indexFile(true, mediaRecFile);
mediaRec.release(); mediaRec.release();
@ -1167,7 +1164,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
} catch (Exception e) { } catch (Exception e) {
Toast.makeText(app, e.getMessage(), Toast.LENGTH_LONG).show(); Toast.makeText(app, e.getMessage(), Toast.LENGTH_LONG).show();
e.printStackTrace(); log.error(e.getMessage(), e);
res = false; res = false;
} }
} }
@ -1383,7 +1380,6 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
closeRecordingMenu(); closeRecordingMenu();
closeCamera(); closeCamera();
finishRecording(); finishRecording();
e.printStackTrace();
} }
} }
@ -1418,7 +1414,6 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
closeRecordingMenu(); closeRecordingMenu();
closeCamera(); closeCamera();
finishRecording(); finishRecording();
e.printStackTrace();
} }
} }
}); });
@ -1900,7 +1895,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
try { try {
ctx.startActivity(vint); ctx.startActivity(vint);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); log.error(e.getMessage(), e);
} }
return; return;
} else if (r.isPhoto()) { } else if (r.isPhoto()) {
@ -1908,7 +1903,11 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
vint.setDataAndType(AndroidUtils.getUriForFile(ctx, r.file), "image/*"); vint.setDataAndType(AndroidUtils.getUriForFile(ctx, r.file), "image/*");
vint.setFlags(0x10000000); vint.setFlags(0x10000000);
vint.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); vint.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
ctx.startActivity(vint); try {
ctx.startActivity(vint);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return; return;
} }
@ -2063,7 +2062,6 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
closeRecordingMenu(); closeRecordingMenu();
closeCamera(); closeCamera();
finishRecording(); finishRecording();
e.printStackTrace();
} }
} }
} }

View file

@ -5,6 +5,7 @@ import android.content.res.TypedArray;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -17,8 +18,12 @@ import android.widget.TextView;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.PluginActivity; import net.osmand.plus.activities.PluginActivity;
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.development.OsmandDevelopmentPlugin; import net.osmand.plus.development.OsmandDevelopmentPlugin;
import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin;
import net.osmand.plus.skimapsplugin.SkiMapsPlugin;
import net.osmand.plus.srtmplugin.SRTMPlugin;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -45,7 +50,14 @@ public class DashPluginsFragment extends DashBaseFragment {
return new View.OnClickListener() { return new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL()))); if (plugin instanceof SRTMPlugin) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
ChoosePlanDialogFragment.showHillshadeSrtmPluginInstance(fragmentManager);
}
} else {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL())));
}
closeDashboard(); closeDashboard();
} }
}; };
@ -82,10 +94,17 @@ public class DashPluginsFragment extends DashBaseFragment {
private void initPlugins() { private void initPlugins() {
List<OsmandPlugin> notActivePlugins = OsmandPlugin.getNotEnabledVisiblePlugins(); List<OsmandPlugin> notActivePlugins = OsmandPlugin.getNotEnabledVisiblePlugins();
notActivePlugins.remove(OsmandPlugin.getPlugin(SkiMapsPlugin.class));
notActivePlugins.remove(OsmandPlugin.getPlugin(NauticalMapsPlugin.class));
Collections.shuffle(notActivePlugins); Collections.shuffle(notActivePlugins);
List<OsmandPlugin> enabledPlugins = OsmandPlugin.getEnabledVisiblePlugins();
enabledPlugins.remove(OsmandPlugin.getPlugin(SkiMapsPlugin.class));
enabledPlugins.remove(OsmandPlugin.getPlugin(NauticalMapsPlugin.class));
plugins = new ArrayList<OsmandPlugin>(); plugins = new ArrayList<OsmandPlugin>();
Iterator<OsmandPlugin> nit = notActivePlugins.iterator(); Iterator<OsmandPlugin> nit = notActivePlugins.iterator();
Iterator<OsmandPlugin> it = OsmandPlugin.getEnabledVisiblePlugins().iterator(); Iterator<OsmandPlugin> it = enabledPlugins.iterator();
addPluginsToLimit(nit, 1); addPluginsToLimit(nit, 1);
addPluginsToLimit(it, 5); addPluginsToLimit(it, 5);
addPluginsToLimit(nit, 5); addPluginsToLimit(nit, 5);
@ -152,6 +171,7 @@ public class DashPluginsFragment extends DashBaseFragment {
CompoundButton enableDisableButton = (CompoundButton) view.findViewById(R.id.plugin_enable_disable); CompoundButton enableDisableButton = (CompoundButton) view.findViewById(R.id.plugin_enable_disable);
Button getButton = (Button) view.findViewById(R.id.get_plugin); Button getButton = (Button) view.findViewById(R.id.get_plugin);
getButton.setText(plugin.isPaid() ? R.string.get_plugin : R.string.shared_string_install);
getButton.setOnClickListener(getListener(plugin)); getButton.setOnClickListener(getListener(plugin));
enableDisableButton.setOnCheckedChangeListener(null); enableDisableButton.setOnCheckedChangeListener(null);
updatePluginState(view, plugin); updatePluginState(view, plugin);

View file

@ -77,7 +77,8 @@ import android.widget.Toast;
public class LocalIndexesFragment extends OsmandExpandableListFragment implements DownloadEvents { public class LocalIndexesFragment extends OsmandExpandableListFragment implements DownloadEvents {
public static final Pattern ILLEGAL_FILE_NAME_CHARACTERS = Pattern.compile("[?:\"*|/\\<>]"); public static final Pattern ILLEGAL_FILE_NAME_CHARACTERS = Pattern.compile("[?:\"*|/<>]");
public static final Pattern ILLEGAL_PATH_NAME_CHARACTERS = Pattern.compile("[?:\"*|<>]");
private LoadLocalIndexTask asyncLoader; private LoadLocalIndexTask asyncLoader;
private Map<String, IndexItem> filesToUpdate = new HashMap<>(); private Map<String, IndexItem> filesToUpdate = new HashMap<>();
@ -301,7 +302,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
@Override @Override
public void onClick(View v) { public void onClick(View v) {
OsmandApplication app = (OsmandApplication) a.getApplication(); OsmandApplication app = (OsmandApplication) a.getApplication();
if (renameGpxFile(app, f, editText.getText().toString() + ext, callback) != null) { if (renameGpxFile(app, f, editText.getText().toString() + ext, false, callback) != null) {
alertDialog.dismiss(); alertDialog.dismiss();
} }
} }
@ -312,12 +313,13 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
} }
} }
public static File renameGpxFile(OsmandApplication ctx, File source, String newName, RenameCallback callback) { public static File renameGpxFile(OsmandApplication ctx, File source, String newName, boolean dirAllowed, RenameCallback callback) {
if (Algorithms.isEmpty(newName)) { if (Algorithms.isEmpty(newName)) {
Toast.makeText(ctx, R.string.empty_filename, Toast.LENGTH_LONG).show(); Toast.makeText(ctx, R.string.empty_filename, Toast.LENGTH_LONG).show();
return null; return null;
} }
if (ILLEGAL_FILE_NAME_CHARACTERS.matcher(newName).find()) { Pattern illegalCharactersPattern = dirAllowed ? ILLEGAL_PATH_NAME_CHARACTERS : ILLEGAL_FILE_NAME_CHARACTERS;
if (illegalCharactersPattern.matcher(newName).find()) {
Toast.makeText(ctx, R.string.file_name_containes_illegal_char, Toast.LENGTH_LONG).show(); Toast.makeText(ctx, R.string.file_name_containes_illegal_char, Toast.LENGTH_LONG).show();
return null; return null;
} }

View file

@ -403,11 +403,9 @@ public class ExternalApiHelper {
resultCode = Activity.RESULT_OK; resultCode = Activity.RESULT_OK;
} }
} else if (API_CMD_MUTE_NAVIGATION.equals(cmd)) { } else if (API_CMD_MUTE_NAVIGATION.equals(cmd)) {
mapActivity.getMyApplication().getSettings().VOICE_MUTE.set(true);
mapActivity.getRoutingHelper().getVoiceRouter().setMute(true); mapActivity.getRoutingHelper().getVoiceRouter().setMute(true);
resultCode = Activity.RESULT_OK; resultCode = Activity.RESULT_OK;
} else if (API_CMD_UNMUTE_NAVIGATION.equals(cmd)) { } else if (API_CMD_UNMUTE_NAVIGATION.equals(cmd)) {
mapActivity.getMyApplication().getSettings().VOICE_MUTE.set(false);
mapActivity.getRoutingHelper().getVoiceRouter().setMute(false); mapActivity.getRoutingHelper().getVoiceRouter().setMute(false);
resultCode = Activity.RESULT_OK; resultCode = Activity.RESULT_OK;
} else if (API_CMD_RECORD_AUDIO.equals(cmd) } else if (API_CMD_RECORD_AUDIO.equals(cmd)

View file

@ -37,15 +37,20 @@ public class DestinationReachedMenuFragment extends Fragment {
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (menu == null) { MapActivity mapActivity = getMapActivity();
menu = new DestinationReachedMenu(getMapActivity()); if (menu == null && mapActivity != null) {
menu = new DestinationReachedMenu(mapActivity);
} }
} }
@Nullable @Nullable
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ContextThemeWrapper ctx = new ContextThemeWrapper(getMapActivity(), menu.isLight() ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme); MapActivity mapActivity = getMapActivity();
if (mapActivity == null || menu == null) {
return null;
}
ContextThemeWrapper ctx = new ContextThemeWrapper(mapActivity, menu.isLight() ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
LayoutInflater inf = LayoutInflater.from(ctx); LayoutInflater inf = LayoutInflater.from(ctx);
View view = inf.inflate(R.layout.dest_reached_menu_fragment, container, false); View view = inf.inflate(R.layout.dest_reached_menu_fragment, container, false);
AndroidUtils.addStatusBarPadding21v(ctx, view); AndroidUtils.addStatusBarPadding21v(ctx, view);
@ -56,7 +61,7 @@ public class DestinationReachedMenuFragment extends Fragment {
} }
}); });
UiUtilities iconsCache = getMapActivity().getMyApplication().getUIUtilities(); UiUtilities iconsCache = mapActivity.getMyApplication().getUIUtilities();
ImageButton closeImageButton = (ImageButton) view.findViewById(R.id.closeImageButton); ImageButton closeImageButton = (ImageButton) view.findViewById(R.id.closeImageButton);
closeImageButton.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_remove_dark, menu.isLight())); closeImageButton.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_remove_dark, menu.isLight()));
@ -83,23 +88,26 @@ public class DestinationReachedMenuFragment extends Fragment {
recalcDestButton.setOnClickListener(new View.OnClickListener() { recalcDestButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
TargetPointsHelper helper = getMapActivity().getMyApplication().getTargetPointsHelper(); MapActivity mapActivity = getMapActivity();
TargetPoint target = helper.getPointToNavigate(); if (mapActivity != null) {
TargetPointsHelper helper = mapActivity.getMyApplication().getTargetPointsHelper();
TargetPoint target = helper.getPointToNavigate();
dismissMenu(); dismissMenu();
if (target != null) { if (target != null) {
helper.navigateToPoint(new LatLon(target.getLatitude(), target.getLongitude()), helper.navigateToPoint(new LatLon(target.getLatitude(), target.getLongitude()),
true, -1, target.getOriginalPointDescription()); true, -1, target.getOriginalPointDescription());
getMapActivity().getMapActions().recalculateRoute(false); mapActivity.getMapActions().recalculateRoute(false);
getMapActivity().getMapLayers().getMapControlsLayer().startNavigation(); mapActivity.getMapLayers().getMapControlsLayer().startNavigation();
}
} }
} }
}); });
Button findParkingButton = (Button) view.findViewById(R.id.findParkingButton); Button findParkingButton = (Button) view.findViewById(R.id.findParkingButton);
ApplicationMode appMode = getMapActivity().getMyApplication().getRoutingHelper().getAppMode(); ApplicationMode appMode = mapActivity.getMyApplication().getRoutingHelper().getAppMode();
if (!appMode.isDerivedRoutingFrom(ApplicationMode.CAR)) { if (!appMode.isDerivedRoutingFrom(ApplicationMode.CAR)) {
findParkingButton.setVisibility(View.GONE); findParkingButton.setVisibility(View.GONE);
@ -112,7 +120,7 @@ public class DestinationReachedMenuFragment extends Fragment {
public void onClick(View v) { public void onClick(View v) {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) { if (mapActivity != null) {
PoiFiltersHelper helper = getMapActivity().getMyApplication().getPoiFilters(); PoiFiltersHelper helper = mapActivity.getMyApplication().getPoiFilters();
PoiUIFilter parkingFilter = helper.getFilterById(PoiUIFilter.STD_PREFIX + "parking"); PoiUIFilter parkingFilter = helper.getFilterById(PoiUIFilter.STD_PREFIX + "parking");
mapActivity.showQuickSearch(parkingFilter); mapActivity.showQuickSearch(parkingFilter);
} }
@ -134,13 +142,19 @@ public class DestinationReachedMenuFragment extends Fragment {
@Override @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
getMapActivity().getContextMenu().setBaseFragmentVisibility(false); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.getContextMenu().setBaseFragmentVisibility(false);
}
} }
@Override @Override
public void onStop() { public void onStop() {
super.onStop(); super.onStop();
getMapActivity().getContextMenu().setBaseFragmentVisibility(true); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.getContextMenu().setBaseFragmentVisibility(true);
}
} }
@Override @Override
@ -150,19 +164,22 @@ public class DestinationReachedMenuFragment extends Fragment {
} }
private void finishNavigation() { private void finishNavigation() {
getMapActivity().getMyApplication().getTargetPointsHelper().removeWayPoint(true, -1); MapActivity mapActivity = getMapActivity();
Object contextMenuObj = getMapActivity().getContextMenu().getObject(); if (mapActivity != null) {
if (getMapActivity().getContextMenu().isActive() mapActivity.getMyApplication().getTargetPointsHelper().removeWayPoint(true, -1);
&& contextMenuObj instanceof TargetPoint) { Object contextMenuObj = mapActivity.getContextMenu().getObject();
TargetPoint targetPoint = (TargetPoint) contextMenuObj; if (mapActivity.getContextMenu().isActive()
if (!targetPoint.start && !targetPoint.intermediate) { && contextMenuObj instanceof TargetPoint) {
getMapActivity().getContextMenu().close(); TargetPoint targetPoint = (TargetPoint) contextMenuObj;
if (!targetPoint.start && !targetPoint.intermediate) {
mapActivity.getContextMenu().close();
}
} }
OsmandSettings settings = mapActivity.getMyApplication().getSettings();
settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get());
mapActivity.getMapActions().stopNavigationWithoutConfirm();
dismissMenu();
} }
OsmandSettings settings = getMapActivity().getMyApplication().getSettings();
settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get());
getMapActivity().getMapActions().stopNavigationWithoutConfirm();
dismissMenu();
} }
public static boolean isExists() { public static boolean isExists() {
@ -175,19 +192,26 @@ public class DestinationReachedMenuFragment extends Fragment {
DestinationReachedMenuFragment fragment = new DestinationReachedMenuFragment(); DestinationReachedMenuFragment fragment = new DestinationReachedMenuFragment();
fragment.menu = menu; fragment.menu = menu;
menu.getMapActivity().getSupportFragmentManager().beginTransaction() MapActivity mapActivity = menu.getMapActivity();
.setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim) if (mapActivity != null) {
.add(R.id.fragmentContainer, fragment, TAG) mapActivity.getSupportFragmentManager().beginTransaction()
.addToBackStack(TAG).commitAllowingStateLoss(); .setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim)
.add(R.id.fragmentContainer, fragment, TAG)
.addToBackStack(TAG).commitAllowingStateLoss();
}
} }
public void dismissMenu() { public void dismissMenu() {
getMapActivity().getSupportFragmentManager().popBackStack(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null && !mapActivity.isActivityDestroyed()) {
mapActivity.getSupportFragmentManager().popBackStack();
}
} }
@Nullable
public MapActivity getMapActivity() { public MapActivity getMapActivity() {
Activity activity = getActivity(); Activity activity = getActivity();
if (activity != null && activity instanceof MapActivity) { if (activity instanceof MapActivity) {
return (MapActivity) activity; return (MapActivity) activity;
} else { } else {
return null; return null;

View file

@ -25,7 +25,6 @@ import android.widget.Toast;
import net.osmand.GPXUtilities; import net.osmand.GPXUtilities;
import net.osmand.GPXUtilities.WptPt; import net.osmand.GPXUtilities.WptPt;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.UiUtilities.DialogButtonType; import net.osmand.plus.UiUtilities.DialogButtonType;
@ -52,6 +51,7 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
private boolean showOnMap = true; private boolean showOnMap = true;
private boolean openTrack = false; private boolean openTrack = false;
private File file; private File file;
private String savedGpxDir = "";
private String savedGpxName = ""; private String savedGpxName = "";
private String newGpxName = ""; private String newGpxName = "";
@ -63,8 +63,10 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
if (args != null && args.containsKey(SAVED_TRACKS_KEY)) { if (args != null && args.containsKey(SAVED_TRACKS_KEY)) {
ArrayList<String> savedGpxNames = args.getStringArrayList(SAVED_TRACKS_KEY); ArrayList<String> savedGpxNames = args.getStringArrayList(SAVED_TRACKS_KEY);
if (savedGpxNames != null && savedGpxNames.size() > 0) { if (savedGpxNames != null && savedGpxNames.size() > 0) {
savedGpxName = savedGpxNames.get(savedGpxNames.size() - 1); String fileName = savedGpxNames.get(savedGpxNames.size() - 1);
newGpxName = savedGpxName; savedGpxDir = new File(fileName).getParent();
savedGpxName = new File(fileName).getName();
newGpxName = this.savedGpxName;
} }
} else { } else {
dismiss(); dismiss();
@ -160,15 +162,20 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
if (showOnMap) { if (showOnMap) {
showOnMap(file, !openTrack); showOnMap(file, !openTrack);
} }
if (openTrack) { FragmentActivity activity = getActivity();
AvailableGPXFragment.openTrack(getActivity(), file); if (openTrack && activity != null) {
AvailableGPXFragment.openTrack(activity, file);
} }
} }
} }
private File renameGpxFile() { private File renameGpxFile() {
OsmandApplication app = requiredMyApplication(); FragmentActivity activity = getActivity();
File savedFile = new File(app.getAppCustomization().getTracksDir(), savedGpxName + ".gpx"); if (activity == null) {
return null;
}
OsmandApplication app = (OsmandApplication) activity.getApplication();
File savedFile = new File(app.getAppCustomization().getTracksDir(), new File(savedGpxDir, savedGpxName + ".gpx").getPath());
if (savedGpxName.equalsIgnoreCase(newGpxName)) { if (savedGpxName.equalsIgnoreCase(newGpxName)) {
return savedFile; return savedFile;
} }
@ -176,18 +183,22 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
Toast.makeText(app, R.string.empty_filename, Toast.LENGTH_LONG).show(); Toast.makeText(app, R.string.empty_filename, Toast.LENGTH_LONG).show();
return null; return null;
} }
return LocalIndexesFragment.renameGpxFile(app, savedFile, newGpxName + ".gpx", null); return LocalIndexesFragment.renameGpxFile(app, savedFile, newGpxName + ".gpx", true, null);
} }
private void showOnMap(File f, boolean animated) { private void showOnMap(File f, boolean animated) {
OsmandApplication app = requiredMyApplication(); FragmentActivity activity = getActivity();
if (activity == null) {
return;
}
OsmandApplication app = (OsmandApplication) activity.getApplication();
GpxInfo gpxInfo = new GpxInfo(); GpxInfo gpxInfo = new GpxInfo();
gpxInfo.setGpx(GPXUtilities.loadGPXFile(f)); gpxInfo.setGpx(GPXUtilities.loadGPXFile(f));
if (gpxInfo.gpx != null) { if (gpxInfo.gpx != null) {
WptPt loc = gpxInfo.gpx.findPointToShow(); WptPt loc = gpxInfo.gpx.findPointToShow();
if (loc != null) { if (loc != null) {
app.getSelectedGpxHelper().setGpxFileToDisplay(gpxInfo.gpx); app.getSelectedGpxHelper().setGpxFileToDisplay(gpxInfo.gpx);
FragmentActivity activity = getActivity();
if (activity instanceof MapActivity) { if (activity instanceof MapActivity) {
MapActivity mapActivity = (MapActivity) activity; MapActivity mapActivity = (MapActivity) activity;
if (animated) { if (animated) {

View file

@ -23,16 +23,12 @@ public class NavVoiceAction extends QuickAction {
@Override @Override
public void execute(MapActivity activity) { public void execute(MapActivity activity) {
boolean mute = activity.getMyApplication().getSettings().VOICE_MUTE.get();
boolean voice = activity.getMyApplication().getSettings().VOICE_MUTE.get(); activity.getMyApplication().getSettings().VOICE_MUTE.set(!mute);
activity.getMyApplication().getSettings().VOICE_MUTE.set(!voice);
activity.getRoutingHelper().getVoiceRouter().setMute(!voice);
} }
@Override @Override
public void drawUI(ViewGroup parent, MapActivity activity) { public void drawUI(ViewGroup parent, MapActivity activity) {
View view = LayoutInflater.from(parent.getContext()) View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.quick_action_with_text, parent, false); .inflate(R.layout.quick_action_with_text, parent, false);
@ -44,7 +40,6 @@ public class NavVoiceAction extends QuickAction {
@Override @Override
public String getActionText(OsmandApplication application) { public String getActionText(OsmandApplication application) {
return application.getSettings().VOICE_MUTE.get() return application.getSettings().VOICE_MUTE.get()
? application.getString(R.string.quick_action_navigation_voice_off) ? application.getString(R.string.quick_action_navigation_voice_off)
: application.getString(R.string.quick_action_navigation_voice_on); : application.getString(R.string.quick_action_navigation_voice_on);
@ -52,7 +47,6 @@ public class NavVoiceAction extends QuickAction {
@Override @Override
public boolean isActionWithSlash(OsmandApplication application) { public boolean isActionWithSlash(OsmandApplication application) {
return !application.getSettings().VOICE_MUTE.get(); return !application.getSettings().VOICE_MUTE.get();
} }
} }

View file

@ -1054,10 +1054,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
} }
private void createMuteSoundRoutingParameterButton(MapActivity mapActivity, final MuteSoundRoutingParameter parameter, final RouteMenuAppModes mode, LinearLayout optionsContainer) { private void createMuteSoundRoutingParameterButton(MapActivity mapActivity, final MuteSoundRoutingParameter parameter, final RouteMenuAppModes mode, LinearLayout optionsContainer) {
final ApplicationMode appMode = mapActivity.getRoutingHelper().getAppMode();
final int colorActive = ContextCompat.getColor(mapActivity, nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light); final int colorActive = ContextCompat.getColor(mapActivity, nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light);
final int colorDisabled = ContextCompat.getColor(mapActivity, R.color.description_font_and_bottom_sheet_icons); final int colorDisabled = ContextCompat.getColor(mapActivity, R.color.description_font_and_bottom_sheet_icons);
String text = null; String text = null;
final boolean active = !mapActivity.getRoutingHelper().getVoiceRouter().isMute(); boolean active = !mapActivity.getRoutingHelper().getVoiceRouter().isMuteForMode(appMode);
if (mode.parameters.size() <= 2) { if (mode.parameters.size() <= 2) {
text = mapActivity.getString(active ? R.string.shared_string_on : R.string.shared_string_off); text = mapActivity.getString(active ? R.string.shared_string_on : R.string.shared_string_off);
} }
@ -1067,7 +1068,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
OsmandApplication app = getApp(); OsmandApplication app = getApp();
if (app != null) { if (app != null) {
app.getRoutingOptionsHelper().switchSound(); app.getRoutingOptionsHelper().switchSound();
boolean active = !app.getRoutingHelper().getVoiceRouter().isMute(); boolean active = !app.getRoutingHelper().getVoiceRouter().isMuteForMode(appMode);
String text = app.getString(active ? R.string.shared_string_on : R.string.shared_string_off); String text = app.getString(active ? R.string.shared_string_on : R.string.shared_string_off);
Drawable itemDrawable = app.getUIUtilities().getIcon(active ? parameter.getActiveIconId() : parameter.getDisabledIconId(), nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light); Drawable itemDrawable = app.getUIUtilities().getIcon(active ? parameter.getActiveIconId() : parameter.getDisabledIconId(), nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);

View file

@ -134,22 +134,22 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
} }
private BaseBottomSheetItem createMuteSoundItem(final LocalRoutingParameter optionsItem) { private BaseBottomSheetItem createMuteSoundItem(final LocalRoutingParameter optionsItem) {
boolean active = !routingHelper.getVoiceRouter().isMuteForMode(applicationMode);
final BottomSheetItemWithCompoundButton[] muteSoundItem = new BottomSheetItemWithCompoundButton[1]; final BottomSheetItemWithCompoundButton[] muteSoundItem = new BottomSheetItemWithCompoundButton[1];
muteSoundItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() muteSoundItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setChecked(!routingHelper.getVoiceRouter().isMute()) .setChecked(active)
.setDescription(getString(R.string.voice_announcements)) .setDescription(getString(R.string.voice_announcements))
.setIcon(getContentIcon((routingHelper.getVoiceRouter().isMute() ? optionsItem.getDisabledIconId() : optionsItem.getActiveIconId()))) .setIcon(getContentIcon(active ? optionsItem.getActiveIconId() : optionsItem.getDisabledIconId()))
.setTitle(getString(R.string.shared_string_sound)) .setTitle(getString(R.string.shared_string_sound))
.setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp) .setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp)
.setOnClickListener(new View.OnClickListener() { .setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem); routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
boolean mt = !routingHelper.getVoiceRouter().isMute(); boolean active = !routingHelper.getVoiceRouter().isMuteForMode(applicationMode);
settings.VOICE_MUTE.set(mt); routingHelper.getVoiceRouter().setMuteForMode(applicationMode, active);
routingHelper.getVoiceRouter().setMute(mt); muteSoundItem[0].setChecked(!active);
muteSoundItem[0].setChecked(!routingHelper.getVoiceRouter().isMute()); muteSoundItem[0].setIcon(getContentIcon(!active ? optionsItem.getActiveIconId() : optionsItem.getDisabledIconId()));
muteSoundItem[0].setIcon(getContentIcon((routingHelper.getVoiceRouter().isMute() ? optionsItem.getDisabledIconId() : optionsItem.getActiveIconId())));
updateMenu(); updateMenu();
} }
}) })

View file

@ -95,9 +95,9 @@ public class RoutingOptionsHelper {
public void switchSound() { public void switchSound() {
RoutingHelper routingHelper = app.getRoutingHelper(); RoutingHelper routingHelper = app.getRoutingHelper();
boolean mt = !routingHelper.getVoiceRouter().isMute(); ApplicationMode mode = routingHelper.getAppMode();
settings.VOICE_MUTE.set(mt); boolean mute = !routingHelper.getVoiceRouter().isMuteForMode(mode);
routingHelper.getVoiceRouter().setMute(mt); routingHelper.getVoiceRouter().setMuteForMode(mode, mute);
} }
public void switchMusic() { public void switchMusic() {

View file

@ -49,7 +49,6 @@ public class VoiceRouter {
protected static CommandPlayer player; protected static CommandPlayer player;
protected final OsmandSettings settings; protected final OsmandSettings settings;
private static boolean mute = false;
private static int currentStatus = STATUS_UNKNOWN; private static int currentStatus = STATUS_UNKNOWN;
private static boolean playedAndArriveAtTarget = false; private static boolean playedAndArriveAtTarget = false;
private static float playGoAheadDist = 0; private static float playGoAheadDist = 0;
@ -87,7 +86,6 @@ public class VoiceRouter {
VoiceRouter(RoutingHelper router, final OsmandSettings settings) { VoiceRouter(RoutingHelper router, final OsmandSettings settings) {
this.router = router; this.router = router;
this.settings = settings; this.settings = settings;
mute = settings.VOICE_MUTE.get();
} }
public void setPlayer(CommandPlayer player) { public void setPlayer(CommandPlayer player) {
@ -104,13 +102,21 @@ public class VoiceRouter {
public CommandPlayer getPlayer() { public CommandPlayer getPlayer() {
return player; return player;
} }
public void setMute(boolean mute) { public void setMute(boolean mute) {
this.mute = mute; settings.VOICE_MUTE.set(mute);
} }
public void setMuteForMode(ApplicationMode mode, boolean mute) {
settings.VOICE_MUTE.setModeValue(mode, mute);
}
public boolean isMute() { public boolean isMute() {
return mute; return settings.VOICE_MUTE.get();
}
public boolean isMuteForMode(ApplicationMode mode) {
return settings.VOICE_MUTE.getModeValue(mode);
} }
private CommandBuilder getNewCommandPlayerToPlay() { private CommandBuilder getNewCommandPlayerToPlay() {
@ -907,13 +913,11 @@ public class VoiceRouter {
} }
private void play(CommandBuilder p) { private void play(CommandBuilder p) {
if (settings.SPEAK_ROUTING_ALARMS.get()) { if (p != null) {
if (p != null) { List<String> played = p.play();
List<String> played = p.play(); notifyOnVoiceMessage(p.getListCommands(), played);
notifyOnVoiceMessage(p.getListCommands(), played); } else {
} else { notifyOnVoiceMessage(Collections.EMPTY_LIST, Collections.EMPTY_LIST);
notifyOnVoiceMessage(Collections.EMPTY_LIST, Collections.EMPTY_LIST);
}
} }
} }

View file

@ -481,8 +481,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
List<HistoryEntry> historyEntries = new ArrayList<HistoryEntry>(); List<HistoryEntry> historyEntries = new ArrayList<HistoryEntry>();
List<QuickSearchListItem> selectedItems = historySearchFragment.getListAdapter().getSelectedItems(); List<QuickSearchListItem> selectedItems = historySearchFragment.getListAdapter().getSelectedItems();
for (QuickSearchListItem searchListItem : selectedItems) { for (QuickSearchListItem searchListItem : selectedItems) {
HistoryEntry historyEntry = (HistoryEntry) searchListItem.getSearchResult().object; Object object = searchListItem.getSearchResult().object;
historyEntries.add(historyEntry); if (object instanceof HistoryEntry) {
historyEntries.add((HistoryEntry) object);
}
} }
if (historyEntries.size() > 0) { if (historyEntries.size() > 0) {
shareHistory(historyEntries); shareHistory(historyEntries);

View file

@ -4,6 +4,7 @@ import android.support.v7.preference.Preference;
import android.support.v7.preference.SwitchPreferenceCompat; import android.support.v7.preference.SwitchPreferenceCompat;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.settings.preferences.SwitchPreferenceEx; import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
public class NavigationFragment extends BaseSettingsFragment { public class NavigationFragment extends BaseSettingsFragment {
@ -14,7 +15,7 @@ public class NavigationFragment extends BaseSettingsFragment {
protected void setupPreferences() { protected void setupPreferences() {
Preference routeParameters = findPreference("route_parameters"); Preference routeParameters = findPreference("route_parameters");
SwitchPreferenceCompat showRoutingAlarms = (SwitchPreferenceCompat) findPreference(settings.SHOW_ROUTING_ALARMS.getId()); SwitchPreferenceCompat showRoutingAlarms = (SwitchPreferenceCompat) findPreference(settings.SHOW_ROUTING_ALARMS.getId());
SwitchPreferenceCompat speakRoutingAlarms = (SwitchPreferenceCompat) findPreference(settings.SPEAK_ROUTING_ALARMS.getId()); SwitchPreferenceCompat speakRoutingAlarms = (SwitchPreferenceCompat) findPreference(settings.VOICE_MUTE.getId());
SwitchPreferenceCompat turnScreenOn = (SwitchPreferenceCompat) findPreference(settings.TURN_SCREEN_ON_ENABLED.getId()); SwitchPreferenceCompat turnScreenOn = (SwitchPreferenceCompat) findPreference(settings.TURN_SCREEN_ON_ENABLED.getId());
SwitchPreferenceEx animateMyLocation = (SwitchPreferenceEx) findPreference(settings.ANIMATE_MY_LOCATION.getId()); SwitchPreferenceEx animateMyLocation = (SwitchPreferenceEx) findPreference(settings.ANIMATE_MY_LOCATION.getId());
@ -24,13 +25,31 @@ public class NavigationFragment extends BaseSettingsFragment {
turnScreenOn.setIcon(getContentIcon(R.drawable.ic_action_turn_screen_on)); turnScreenOn.setIcon(getContentIcon(R.drawable.ic_action_turn_screen_on));
setupVehicleParametersPref(); setupVehicleParametersPref();
speakRoutingAlarms.setChecked(!settings.VOICE_MUTE.getModeValue(getSelectedAppMode()));
animateMyLocation.setDescription(getString(R.string.animate_my_location_desc)); animateMyLocation.setDescription(getString(R.string.animate_my_location_desc));
} }
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String key = preference.getKey();
if (settings.VOICE_MUTE.getId().equals(key) && newValue instanceof Boolean) {
settings.VOICE_MUTE.setModeValue(getSelectedAppMode(), !(Boolean) newValue);
updateMenu();
return true;
}
return super.onPreferenceChange(preference, newValue);
}
private void setupVehicleParametersPref() { private void setupVehicleParametersPref() {
Preference vehicleParameters = findPreference("vehicle_parameters"); Preference vehicleParameters = findPreference("vehicle_parameters");
int iconRes = getSelectedAppMode().getIconRes(); int iconRes = getSelectedAppMode().getIconRes();
vehicleParameters.setIcon(getContentIcon(iconRes)); vehicleParameters.setIcon(getContentIcon(iconRes));
} }
private void updateMenu() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.getMapRouteInfoMenu().updateMenu();
}
}
} }

View file

@ -20,6 +20,7 @@ import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.Version; import net.osmand.plus.Version;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.FileNameTranslationHelper;
@ -41,10 +42,11 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
ApplicationMode selectedMode = getSelectedAppMode(); ApplicationMode selectedMode = getSelectedAppMode();
boolean checked = !settings.SPEAK_ROUTING_ALARMS.getModeValue(selectedMode); boolean checked = !settings.VOICE_MUTE.getModeValue(selectedMode);
settings.SPEAK_ROUTING_ALARMS.setModeValue(selectedMode, checked); settings.VOICE_MUTE.setModeValue(selectedMode, checked);
updateToolbarSwitch(); updateToolbarSwitch();
enableDisablePreferences(checked); enableDisablePreferences(!checked);
updateMenu();
} }
}); });
} }
@ -60,7 +62,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
if (view == null) { if (view == null) {
return; return;
} }
boolean checked = settings.SPEAK_ROUTING_ALARMS.getModeValue(getSelectedAppMode()); boolean checked = !settings.VOICE_MUTE.getModeValue(getSelectedAppMode());
int color = checked ? getActiveProfileColor() : ContextCompat.getColor(app, R.color.preference_top_switch_off); int color = checked ? getActiveProfileColor() : ContextCompat.getColor(app, R.color.preference_top_switch_off);
View switchContainer = view.findViewById(R.id.toolbar_switch_container); View switchContainer = view.findViewById(R.id.toolbar_switch_container);
@ -88,7 +90,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
setupAudioStreamGuidancePref(); setupAudioStreamGuidancePref();
setupInterruptMusicPref(); setupInterruptMusicPref();
} }
enableDisablePreferences(settings.SPEAK_ROUTING_ALARMS.getModeValue(getSelectedAppMode())); enableDisablePreferences(!settings.VOICE_MUTE.getModeValue(getSelectedAppMode()));
} }
private void setupSpeedLimitExceedPref() { private void setupSpeedLimitExceedPref() {
@ -218,6 +220,13 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
bld.show(); bld.show();
} }
private void updateMenu() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.getMapRouteInfoMenu().updateMenu();
}
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
String prefId = preference.getKey(); String prefId = preference.getKey();