Merge branch 'r3.5'
This commit is contained in:
commit
21ac829a3d
22 changed files with 244 additions and 141 deletions
|
@ -310,7 +310,9 @@
|
|||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="content"/>
|
||||
<data android:scheme="file"/>
|
||||
<data android:scheme="data"/>
|
||||
<data android:host="*"/>
|
||||
<data android:mimeType="*/*"/>
|
||||
<data android:pathPattern=".*\\.osf" />
|
||||
|
|
|
@ -2627,7 +2627,7 @@
|
|||
\n
|
||||
\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="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="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>
|
||||
|
|
|
@ -22,8 +22,9 @@
|
|||
tools:icon="@drawable/ic_action_alert" />
|
||||
|
||||
<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:persistent="false"
|
||||
android:summary="@string/voice_announces_descr"
|
||||
android:title="@string/voice_announces"
|
||||
app:fragment="net.osmand.plus.settings.VoiceAnnouncesFragment"
|
||||
|
|
|
@ -769,7 +769,6 @@ public class OsmandAidlApi {
|
|||
public void onReceive(Context context, Intent intent) {
|
||||
MapActivity mapActivity = mapActivityRef.get();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.getMyApplication().getSettings().VOICE_MUTE.set(true);
|
||||
mapActivity.getRoutingHelper().getVoiceRouter().setMute(true);
|
||||
}
|
||||
}
|
||||
|
@ -784,7 +783,6 @@ public class OsmandAidlApi {
|
|||
public void onReceive(Context context, Intent intent) {
|
||||
MapActivity mapActivity = mapActivityRef.get();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.getMyApplication().getSettings().VOICE_MUTE.set(false);
|
||||
mapActivity.getRoutingHelper().getVoiceRouter().setMute(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,8 +190,9 @@ public class AppInitializer implements IProgress {
|
|||
app.getSettings().BILLING_PURCHASE_TOKENS_SENT.set("");
|
||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_2).commit();
|
||||
}
|
||||
if (prevAppVersion < VERSION_3_5 || Version.getAppVersion(app).equals("3.5.3")) {
|
||||
app.getSettings().migrateGlobalPrefsToProfile();
|
||||
if (prevAppVersion < VERSION_3_5 || Version.getAppVersion(app).equals("3.5.3")
|
||||
|| Version.getAppVersion(app).equals("3.5.4")) {
|
||||
app.getSettings().migratePreferences();
|
||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_5).commit();
|
||||
}
|
||||
startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
|
||||
|
|
|
@ -229,24 +229,31 @@ public class OsmandSettings {
|
|||
return globalPreferences != null && globalPreferences.getBoolean(SETTING_CUSTOMIZED_ID, false);
|
||||
}
|
||||
|
||||
public void migrateGlobalPrefsToProfile() {
|
||||
SharedPreferences sharedPreferences = (SharedPreferences) globalPreferences;
|
||||
Map<String, ?> map = sharedPreferences.getAll();
|
||||
for (String key : map.keySet()) {
|
||||
public void migratePreferences() {
|
||||
SharedPreferences globalSharedPreferences = (SharedPreferences) globalPreferences;
|
||||
Map<String, ?> globalPrefsMap = globalSharedPreferences.getAll();
|
||||
for (String key : globalPrefsMap.keySet()) {
|
||||
OsmandPreference pref = getPreference(key);
|
||||
if (pref instanceof CommonPreference) {
|
||||
CommonPreference commonPreference = (CommonPreference) pref;
|
||||
if (!commonPreference.global) {
|
||||
List<ApplicationMode> modes = commonPreference.general ? Collections.singletonList(ApplicationMode.DEFAULT) : ApplicationMode.allPossibleValues();
|
||||
boolean valueSaved = false;
|
||||
for (ApplicationMode mode : modes) {
|
||||
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_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 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> VOICE_MUTE = new BooleanPreference("voice_mute", false).makeGlobal();
|
||||
public final OsmandPreference<Boolean> VOICE_MUTE = new BooleanPreference("voice_mute", false).makeProfile().cache();
|
||||
|
||||
// for background service
|
||||
public final OsmandPreference<Boolean> MAP_ACTIVITY_ENABLED = new BooleanPreference("map_activity_enabled", false).makeGlobal();
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.net.Uri;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
@ -18,7 +19,9 @@ import android.widget.TextView;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
|
||||
import net.osmand.plus.download.DownloadIndexesThread;
|
||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||
|
||||
public class PluginActivity extends OsmandActionBarActivity implements DownloadIndexesThread.DownloadEvents {
|
||||
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);
|
||||
getButton.setText(plugin.isPaid() ? R.string.get_plugin : R.string.shared_string_install);
|
||||
getButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
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) {
|
||||
//ignored
|
||||
}
|
||||
|
|
|
@ -238,17 +238,21 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
}
|
||||
}
|
||||
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
if (db != null && warnings.isEmpty() && db.isOpen()) {
|
||||
try {
|
||||
// remove all from db
|
||||
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 " + POINT_NAME + " WHERE " + POINT_COL_DATE + " <= ?", new Object[] { System.currentTimeMillis() }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
// delete all
|
||||
// db.execSQL("DELETE FROM " + TRACK_NAME + " WHERE 1 = 1", new Object[] { }); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// db.execSQL("DELETE FROM " + POINT_NAME + " WHERE 1 = 1", new Object[] { }); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
} finally {
|
||||
db.close();
|
||||
if (warnings.isEmpty()) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
if (db != null) {
|
||||
try {
|
||||
if (db.isOpen()) {
|
||||
// remove all from db
|
||||
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 " + POINT_NAME + " WHERE " + POINT_COL_DATE + " <= ?", new Object[]{System.currentTimeMillis()}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
// delete all
|
||||
// db.execSQL("DELETE FROM " + TRACK_NAME + " WHERE 1 = 1", new Object[] { }); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// db.execSQL("DELETE FROM " + POINT_NAME + " WHERE 1 = 1", new Object[] { }); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
distance = 0;
|
||||
|
@ -609,14 +613,12 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
|
||||
private synchronized void execWithClose(String script, Object[] objects) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
try {
|
||||
if (db != null) {
|
||||
if (db != null) {
|
||||
try {
|
||||
db.execSQL(script, objects);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
} finally {
|
||||
if (db != null) {
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.Manifest;
|
|||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
|
@ -408,8 +407,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
Method saveAttributes = exClass.getMethod("saveAttributes", new Class[]{});
|
||||
saveAttributes.invoke(exInstance);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error(e);
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -425,8 +423,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
Integer it = (Integer) getAttributeInt.invoke(exInstance, "Orientation", 1);
|
||||
orientation = it;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error(e);
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return orientation;
|
||||
}
|
||||
|
@ -1136,7 +1133,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
try {
|
||||
mediaRec.stop();
|
||||
} catch (IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
indexFile(true, mediaRecFile);
|
||||
mediaRec.release();
|
||||
|
@ -1167,7 +1164,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(app, e.getMessage(), Toast.LENGTH_LONG).show();
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage(), e);
|
||||
res = false;
|
||||
}
|
||||
}
|
||||
|
@ -1383,7 +1380,6 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
closeRecordingMenu();
|
||||
closeCamera();
|
||||
finishRecording();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1418,7 +1414,6 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
closeRecordingMenu();
|
||||
closeCamera();
|
||||
finishRecording();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1900,7 +1895,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
try {
|
||||
ctx.startActivity(vint);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return;
|
||||
} else if (r.isPhoto()) {
|
||||
|
@ -1908,7 +1903,11 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
vint.setDataAndType(AndroidUtils.getUriForFile(ctx, r.file), "image/*");
|
||||
vint.setFlags(0x10000000);
|
||||
vint.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
ctx.startActivity(vint);
|
||||
try {
|
||||
ctx.startActivity(vint);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2063,7 +2062,6 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
closeRecordingMenu();
|
||||
closeCamera();
|
||||
finishRecording();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.content.res.TypedArray;
|
|||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -17,8 +18,12 @@ import android.widget.TextView;
|
|||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.PluginActivity;
|
||||
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
|
||||
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||
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.Collections;
|
||||
|
@ -45,7 +50,14 @@ public class DashPluginsFragment extends DashBaseFragment {
|
|||
return new View.OnClickListener() {
|
||||
@Override
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
@ -82,10 +94,17 @@ public class DashPluginsFragment extends DashBaseFragment {
|
|||
|
||||
private void initPlugins() {
|
||||
List<OsmandPlugin> notActivePlugins = OsmandPlugin.getNotEnabledVisiblePlugins();
|
||||
notActivePlugins.remove(OsmandPlugin.getPlugin(SkiMapsPlugin.class));
|
||||
notActivePlugins.remove(OsmandPlugin.getPlugin(NauticalMapsPlugin.class));
|
||||
Collections.shuffle(notActivePlugins);
|
||||
|
||||
List<OsmandPlugin> enabledPlugins = OsmandPlugin.getEnabledVisiblePlugins();
|
||||
enabledPlugins.remove(OsmandPlugin.getPlugin(SkiMapsPlugin.class));
|
||||
enabledPlugins.remove(OsmandPlugin.getPlugin(NauticalMapsPlugin.class));
|
||||
|
||||
plugins = new ArrayList<OsmandPlugin>();
|
||||
Iterator<OsmandPlugin> nit = notActivePlugins.iterator();
|
||||
Iterator<OsmandPlugin> it = OsmandPlugin.getEnabledVisiblePlugins().iterator();
|
||||
Iterator<OsmandPlugin> it = enabledPlugins.iterator();
|
||||
addPluginsToLimit(nit, 1);
|
||||
addPluginsToLimit(it, 5);
|
||||
addPluginsToLimit(nit, 5);
|
||||
|
@ -152,6 +171,7 @@ public class DashPluginsFragment extends DashBaseFragment {
|
|||
|
||||
CompoundButton enableDisableButton = (CompoundButton) view.findViewById(R.id.plugin_enable_disable);
|
||||
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));
|
||||
enableDisableButton.setOnCheckedChangeListener(null);
|
||||
updatePluginState(view, plugin);
|
||||
|
|
|
@ -77,7 +77,8 @@ import android.widget.Toast;
|
|||
|
||||
|
||||
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 Map<String, IndexItem> filesToUpdate = new HashMap<>();
|
||||
|
@ -301,7 +302,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -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)) {
|
||||
Toast.makeText(ctx, R.string.empty_filename, Toast.LENGTH_LONG).show();
|
||||
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();
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -403,11 +403,9 @@ public class ExternalApiHelper {
|
|||
resultCode = Activity.RESULT_OK;
|
||||
}
|
||||
} else if (API_CMD_MUTE_NAVIGATION.equals(cmd)) {
|
||||
mapActivity.getMyApplication().getSettings().VOICE_MUTE.set(true);
|
||||
mapActivity.getRoutingHelper().getVoiceRouter().setMute(true);
|
||||
resultCode = Activity.RESULT_OK;
|
||||
} else if (API_CMD_UNMUTE_NAVIGATION.equals(cmd)) {
|
||||
mapActivity.getMyApplication().getSettings().VOICE_MUTE.set(false);
|
||||
mapActivity.getRoutingHelper().getVoiceRouter().setMute(false);
|
||||
resultCode = Activity.RESULT_OK;
|
||||
} else if (API_CMD_RECORD_AUDIO.equals(cmd)
|
||||
|
|
|
@ -37,15 +37,20 @@ public class DestinationReachedMenuFragment extends Fragment {
|
|||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (menu == null) {
|
||||
menu = new DestinationReachedMenu(getMapActivity());
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (menu == null && mapActivity != null) {
|
||||
menu = new DestinationReachedMenu(mapActivity);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
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);
|
||||
View view = inf.inflate(R.layout.dest_reached_menu_fragment, container, false);
|
||||
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);
|
||||
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() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
TargetPointsHelper helper = getMapActivity().getMyApplication().getTargetPointsHelper();
|
||||
TargetPoint target = helper.getPointToNavigate();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
TargetPointsHelper helper = mapActivity.getMyApplication().getTargetPointsHelper();
|
||||
TargetPoint target = helper.getPointToNavigate();
|
||||
|
||||
dismissMenu();
|
||||
dismissMenu();
|
||||
|
||||
if (target != null) {
|
||||
helper.navigateToPoint(new LatLon(target.getLatitude(), target.getLongitude()),
|
||||
true, -1, target.getOriginalPointDescription());
|
||||
getMapActivity().getMapActions().recalculateRoute(false);
|
||||
getMapActivity().getMapLayers().getMapControlsLayer().startNavigation();
|
||||
if (target != null) {
|
||||
helper.navigateToPoint(new LatLon(target.getLatitude(), target.getLongitude()),
|
||||
true, -1, target.getOriginalPointDescription());
|
||||
mapActivity.getMapActions().recalculateRoute(false);
|
||||
mapActivity.getMapLayers().getMapControlsLayer().startNavigation();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
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)) {
|
||||
findParkingButton.setVisibility(View.GONE);
|
||||
|
@ -112,7 +120,7 @@ public class DestinationReachedMenuFragment extends Fragment {
|
|||
public void onClick(View v) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
PoiFiltersHelper helper = getMapActivity().getMyApplication().getPoiFilters();
|
||||
PoiFiltersHelper helper = mapActivity.getMyApplication().getPoiFilters();
|
||||
PoiUIFilter parkingFilter = helper.getFilterById(PoiUIFilter.STD_PREFIX + "parking");
|
||||
mapActivity.showQuickSearch(parkingFilter);
|
||||
}
|
||||
|
@ -134,13 +142,19 @@ public class DestinationReachedMenuFragment extends Fragment {
|
|||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
getMapActivity().getContextMenu().setBaseFragmentVisibility(false);
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.getContextMenu().setBaseFragmentVisibility(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
getMapActivity().getContextMenu().setBaseFragmentVisibility(true);
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.getContextMenu().setBaseFragmentVisibility(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -150,19 +164,22 @@ public class DestinationReachedMenuFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void finishNavigation() {
|
||||
getMapActivity().getMyApplication().getTargetPointsHelper().removeWayPoint(true, -1);
|
||||
Object contextMenuObj = getMapActivity().getContextMenu().getObject();
|
||||
if (getMapActivity().getContextMenu().isActive()
|
||||
&& contextMenuObj instanceof TargetPoint) {
|
||||
TargetPoint targetPoint = (TargetPoint) contextMenuObj;
|
||||
if (!targetPoint.start && !targetPoint.intermediate) {
|
||||
getMapActivity().getContextMenu().close();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.getMyApplication().getTargetPointsHelper().removeWayPoint(true, -1);
|
||||
Object contextMenuObj = mapActivity.getContextMenu().getObject();
|
||||
if (mapActivity.getContextMenu().isActive()
|
||||
&& contextMenuObj instanceof TargetPoint) {
|
||||
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() {
|
||||
|
@ -175,19 +192,26 @@ public class DestinationReachedMenuFragment extends Fragment {
|
|||
|
||||
DestinationReachedMenuFragment fragment = new DestinationReachedMenuFragment();
|
||||
fragment.menu = menu;
|
||||
menu.getMapActivity().getSupportFragmentManager().beginTransaction()
|
||||
.setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim)
|
||||
.add(R.id.fragmentContainer, fragment, TAG)
|
||||
.addToBackStack(TAG).commitAllowingStateLoss();
|
||||
MapActivity mapActivity = menu.getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.getSupportFragmentManager().beginTransaction()
|
||||
.setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim)
|
||||
.add(R.id.fragmentContainer, fragment, TAG)
|
||||
.addToBackStack(TAG).commitAllowingStateLoss();
|
||||
}
|
||||
}
|
||||
|
||||
public void dismissMenu() {
|
||||
getMapActivity().getSupportFragmentManager().popBackStack();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null && !mapActivity.isActivityDestroyed()) {
|
||||
mapActivity.getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MapActivity getMapActivity() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null && activity instanceof MapActivity) {
|
||||
if (activity instanceof MapActivity) {
|
||||
return (MapActivity) activity;
|
||||
} else {
|
||||
return null;
|
||||
|
|
|
@ -25,7 +25,6 @@ import android.widget.Toast;
|
|||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.UiUtilities.DialogButtonType;
|
||||
|
@ -52,6 +51,7 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
|
|||
private boolean showOnMap = true;
|
||||
private boolean openTrack = false;
|
||||
private File file;
|
||||
private String savedGpxDir = "";
|
||||
private String savedGpxName = "";
|
||||
private String newGpxName = "";
|
||||
|
||||
|
@ -63,8 +63,10 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
|
|||
if (args != null && args.containsKey(SAVED_TRACKS_KEY)) {
|
||||
ArrayList<String> savedGpxNames = args.getStringArrayList(SAVED_TRACKS_KEY);
|
||||
if (savedGpxNames != null && savedGpxNames.size() > 0) {
|
||||
savedGpxName = savedGpxNames.get(savedGpxNames.size() - 1);
|
||||
newGpxName = savedGpxName;
|
||||
String fileName = savedGpxNames.get(savedGpxNames.size() - 1);
|
||||
savedGpxDir = new File(fileName).getParent();
|
||||
savedGpxName = new File(fileName).getName();
|
||||
newGpxName = this.savedGpxName;
|
||||
}
|
||||
} else {
|
||||
dismiss();
|
||||
|
@ -160,15 +162,20 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
|
|||
if (showOnMap) {
|
||||
showOnMap(file, !openTrack);
|
||||
}
|
||||
if (openTrack) {
|
||||
AvailableGPXFragment.openTrack(getActivity(), file);
|
||||
FragmentActivity activity = getActivity();
|
||||
if (openTrack && activity != null) {
|
||||
AvailableGPXFragment.openTrack(activity, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private File renameGpxFile() {
|
||||
OsmandApplication app = requiredMyApplication();
|
||||
File savedFile = new File(app.getAppCustomization().getTracksDir(), savedGpxName + ".gpx");
|
||||
FragmentActivity activity = getActivity();
|
||||
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)) {
|
||||
return savedFile;
|
||||
}
|
||||
|
@ -176,18 +183,22 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
|
|||
Toast.makeText(app, R.string.empty_filename, Toast.LENGTH_LONG).show();
|
||||
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) {
|
||||
OsmandApplication app = requiredMyApplication();
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity == null) {
|
||||
return;
|
||||
}
|
||||
OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
|
||||
GpxInfo gpxInfo = new GpxInfo();
|
||||
gpxInfo.setGpx(GPXUtilities.loadGPXFile(f));
|
||||
if (gpxInfo.gpx != null) {
|
||||
WptPt loc = gpxInfo.gpx.findPointToShow();
|
||||
if (loc != null) {
|
||||
app.getSelectedGpxHelper().setGpxFileToDisplay(gpxInfo.gpx);
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity instanceof MapActivity) {
|
||||
MapActivity mapActivity = (MapActivity) activity;
|
||||
if (animated) {
|
||||
|
|
|
@ -23,16 +23,12 @@ public class NavVoiceAction extends QuickAction {
|
|||
|
||||
@Override
|
||||
public void execute(MapActivity activity) {
|
||||
|
||||
boolean voice = activity.getMyApplication().getSettings().VOICE_MUTE.get();
|
||||
|
||||
activity.getMyApplication().getSettings().VOICE_MUTE.set(!voice);
|
||||
activity.getRoutingHelper().getVoiceRouter().setMute(!voice);
|
||||
boolean mute = activity.getMyApplication().getSettings().VOICE_MUTE.get();
|
||||
activity.getMyApplication().getSettings().VOICE_MUTE.set(!mute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawUI(ViewGroup parent, MapActivity activity) {
|
||||
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.quick_action_with_text, parent, false);
|
||||
|
||||
|
@ -44,7 +40,6 @@ public class NavVoiceAction extends QuickAction {
|
|||
|
||||
@Override
|
||||
public String getActionText(OsmandApplication application) {
|
||||
|
||||
return application.getSettings().VOICE_MUTE.get()
|
||||
? application.getString(R.string.quick_action_navigation_voice_off)
|
||||
: application.getString(R.string.quick_action_navigation_voice_on);
|
||||
|
@ -52,7 +47,6 @@ public class NavVoiceAction extends QuickAction {
|
|||
|
||||
@Override
|
||||
public boolean isActionWithSlash(OsmandApplication application) {
|
||||
|
||||
return !application.getSettings().VOICE_MUTE.get();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1054,10 +1054,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
}
|
||||
|
||||
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 colorDisabled = ContextCompat.getColor(mapActivity, R.color.description_font_and_bottom_sheet_icons);
|
||||
String text = null;
|
||||
final boolean active = !mapActivity.getRoutingHelper().getVoiceRouter().isMute();
|
||||
boolean active = !mapActivity.getRoutingHelper().getVoiceRouter().isMuteForMode(appMode);
|
||||
if (mode.parameters.size() <= 2) {
|
||||
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();
|
||||
if (app != null) {
|
||||
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);
|
||||
|
||||
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);
|
||||
|
|
|
@ -134,22 +134,22 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
}
|
||||
|
||||
private BaseBottomSheetItem createMuteSoundItem(final LocalRoutingParameter optionsItem) {
|
||||
boolean active = !routingHelper.getVoiceRouter().isMuteForMode(applicationMode);
|
||||
final BottomSheetItemWithCompoundButton[] muteSoundItem = new BottomSheetItemWithCompoundButton[1];
|
||||
muteSoundItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setChecked(!routingHelper.getVoiceRouter().isMute())
|
||||
.setChecked(active)
|
||||
.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))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
|
||||
boolean mt = !routingHelper.getVoiceRouter().isMute();
|
||||
settings.VOICE_MUTE.set(mt);
|
||||
routingHelper.getVoiceRouter().setMute(mt);
|
||||
muteSoundItem[0].setChecked(!routingHelper.getVoiceRouter().isMute());
|
||||
muteSoundItem[0].setIcon(getContentIcon((routingHelper.getVoiceRouter().isMute() ? optionsItem.getDisabledIconId() : optionsItem.getActiveIconId())));
|
||||
boolean active = !routingHelper.getVoiceRouter().isMuteForMode(applicationMode);
|
||||
routingHelper.getVoiceRouter().setMuteForMode(applicationMode, active);
|
||||
muteSoundItem[0].setChecked(!active);
|
||||
muteSoundItem[0].setIcon(getContentIcon(!active ? optionsItem.getActiveIconId() : optionsItem.getDisabledIconId()));
|
||||
updateMenu();
|
||||
}
|
||||
})
|
||||
|
|
|
@ -95,9 +95,9 @@ public class RoutingOptionsHelper {
|
|||
|
||||
public void switchSound() {
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
boolean mt = !routingHelper.getVoiceRouter().isMute();
|
||||
settings.VOICE_MUTE.set(mt);
|
||||
routingHelper.getVoiceRouter().setMute(mt);
|
||||
ApplicationMode mode = routingHelper.getAppMode();
|
||||
boolean mute = !routingHelper.getVoiceRouter().isMuteForMode(mode);
|
||||
routingHelper.getVoiceRouter().setMuteForMode(mode, mute);
|
||||
}
|
||||
|
||||
public void switchMusic() {
|
||||
|
|
|
@ -49,7 +49,6 @@ public class VoiceRouter {
|
|||
protected static CommandPlayer player;
|
||||
protected final OsmandSettings settings;
|
||||
|
||||
private static boolean mute = false;
|
||||
private static int currentStatus = STATUS_UNKNOWN;
|
||||
private static boolean playedAndArriveAtTarget = false;
|
||||
private static float playGoAheadDist = 0;
|
||||
|
@ -87,7 +86,6 @@ public class VoiceRouter {
|
|||
VoiceRouter(RoutingHelper router, final OsmandSettings settings) {
|
||||
this.router = router;
|
||||
this.settings = settings;
|
||||
mute = settings.VOICE_MUTE.get();
|
||||
}
|
||||
|
||||
public void setPlayer(CommandPlayer player) {
|
||||
|
@ -104,13 +102,21 @@ public class VoiceRouter {
|
|||
public CommandPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
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() {
|
||||
return mute;
|
||||
return settings.VOICE_MUTE.get();
|
||||
}
|
||||
|
||||
public boolean isMuteForMode(ApplicationMode mode) {
|
||||
return settings.VOICE_MUTE.getModeValue(mode);
|
||||
}
|
||||
|
||||
private CommandBuilder getNewCommandPlayerToPlay() {
|
||||
|
@ -907,13 +913,11 @@ public class VoiceRouter {
|
|||
}
|
||||
|
||||
private void play(CommandBuilder p) {
|
||||
if (settings.SPEAK_ROUTING_ALARMS.get()) {
|
||||
if (p != null) {
|
||||
List<String> played = p.play();
|
||||
notifyOnVoiceMessage(p.getListCommands(), played);
|
||||
} else {
|
||||
notifyOnVoiceMessage(Collections.EMPTY_LIST, Collections.EMPTY_LIST);
|
||||
}
|
||||
if (p != null) {
|
||||
List<String> played = p.play();
|
||||
notifyOnVoiceMessage(p.getListCommands(), played);
|
||||
} else {
|
||||
notifyOnVoiceMessage(Collections.EMPTY_LIST, Collections.EMPTY_LIST);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -481,8 +481,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
List<HistoryEntry> historyEntries = new ArrayList<HistoryEntry>();
|
||||
List<QuickSearchListItem> selectedItems = historySearchFragment.getListAdapter().getSelectedItems();
|
||||
for (QuickSearchListItem searchListItem : selectedItems) {
|
||||
HistoryEntry historyEntry = (HistoryEntry) searchListItem.getSearchResult().object;
|
||||
historyEntries.add(historyEntry);
|
||||
Object object = searchListItem.getSearchResult().object;
|
||||
if (object instanceof HistoryEntry) {
|
||||
historyEntries.add((HistoryEntry) object);
|
||||
}
|
||||
}
|
||||
if (historyEntries.size() > 0) {
|
||||
shareHistory(historyEntries);
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.support.v7.preference.Preference;
|
|||
import android.support.v7.preference.SwitchPreferenceCompat;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
||||
|
||||
public class NavigationFragment extends BaseSettingsFragment {
|
||||
|
@ -14,7 +15,7 @@ public class NavigationFragment extends BaseSettingsFragment {
|
|||
protected void setupPreferences() {
|
||||
Preference routeParameters = findPreference("route_parameters");
|
||||
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());
|
||||
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));
|
||||
|
||||
setupVehicleParametersPref();
|
||||
|
||||
speakRoutingAlarms.setChecked(!settings.VOICE_MUTE.getModeValue(getSelectedAppMode()));
|
||||
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() {
|
||||
Preference vehicleParameters = findPreference("vehicle_parameters");
|
||||
int iconRes = getSelectedAppMode().getIconRes();
|
||||
vehicleParameters.setIcon(getContentIcon(iconRes));
|
||||
}
|
||||
|
||||
private void updateMenu() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.getMapRouteInfoMenu().updateMenu();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ import net.osmand.plus.ApplicationMode;
|
|||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.DownloadActivityType;
|
||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||
|
@ -41,10 +42,11 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
ApplicationMode selectedMode = getSelectedAppMode();
|
||||
boolean checked = !settings.SPEAK_ROUTING_ALARMS.getModeValue(selectedMode);
|
||||
settings.SPEAK_ROUTING_ALARMS.setModeValue(selectedMode, checked);
|
||||
boolean checked = !settings.VOICE_MUTE.getModeValue(selectedMode);
|
||||
settings.VOICE_MUTE.setModeValue(selectedMode, checked);
|
||||
updateToolbarSwitch();
|
||||
enableDisablePreferences(checked);
|
||||
enableDisablePreferences(!checked);
|
||||
updateMenu();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -60,7 +62,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
|
|||
if (view == null) {
|
||||
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);
|
||||
View switchContainer = view.findViewById(R.id.toolbar_switch_container);
|
||||
|
@ -88,7 +90,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
|
|||
setupAudioStreamGuidancePref();
|
||||
setupInterruptMusicPref();
|
||||
}
|
||||
enableDisablePreferences(settings.SPEAK_ROUTING_ALARMS.getModeValue(getSelectedAppMode()));
|
||||
enableDisablePreferences(!settings.VOICE_MUTE.getModeValue(getSelectedAppMode()));
|
||||
}
|
||||
|
||||
private void setupSpeedLimitExceedPref() {
|
||||
|
@ -218,6 +220,13 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
|
|||
bld.show();
|
||||
}
|
||||
|
||||
private void updateMenu() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.getMapRouteInfoMenu().updateMenu();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String prefId = preference.getKey();
|
||||
|
|
Loading…
Reference in a new issue