Merge branch 'master' into straight_to

This commit is contained in:
vshcherb 2020-02-11 19:28:14 +01:00 committed by GitHub
commit 6b0595f6a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 381 additions and 166 deletions

View file

@ -1557,6 +1557,8 @@ public class GPXUtilities {
serializer.endTag(null, "wpt"); //$NON-NLS-1$ serializer.endTag(null, "wpt"); //$NON-NLS-1$
} }
writeExtensions(serializer, file);
serializer.endTag(null, "gpx"); //$NON-NLS-1$ serializer.endTag(null, "gpx"); //$NON-NLS-1$
serializer.endDocument(); serializer.endDocument();
serializer.flush(); serializer.flush();

View file

@ -135,12 +135,9 @@ public class GeneralRouter implements VehicleRouter {
for (int i = 0; i < objectAttributes.length; i++) { for (int i = 0; i < objectAttributes.length; i++) {
objectAttributes[i] = new RouteAttributeContext(parent.objectAttributes[i], params); objectAttributes[i] = new RouteAttributeContext(parent.objectAttributes[i], params);
} }
allowPrivate = params.containsKey(ALLOW_PRIVATE) && parseSilentBoolean(params.get(ALLOW_PRIVATE), false) ; allowPrivate = params.containsKey(ALLOW_PRIVATE) && parseSilentBoolean(params.get(ALLOW_PRIVATE), false);
shortestRoute = params.containsKey(USE_SHORTEST_WAY) && parseSilentBoolean(params.get(USE_SHORTEST_WAY), false); shortestRoute = params.containsKey(USE_SHORTEST_WAY) && parseSilentBoolean(params.get(USE_SHORTEST_WAY), false);
heightObstacles = params.containsKey(USE_HEIGHT_OBSTACLES) && parseSilentBoolean(params.get(USE_HEIGHT_OBSTACLES), false); heightObstacles = params.containsKey(USE_HEIGHT_OBSTACLES) && parseSilentBoolean(params.get(USE_HEIGHT_OBSTACLES), false);
if(shortestRoute) {
maxSpeed = Math.min(CAR_SHORTEST_DEFAULT_SPEED, maxSpeed);
}
if (params.containsKey(DEFAULT_SPEED)) { if (params.containsKey(DEFAULT_SPEED)) {
defaultSpeed = parseSilentFloat(params.get(DEFAULT_SPEED), defaultSpeed); defaultSpeed = parseSilentFloat(params.get(DEFAULT_SPEED), defaultSpeed);
} }
@ -150,8 +147,10 @@ public class GeneralRouter implements VehicleRouter {
if (params.containsKey(MAX_SPEED)) { if (params.containsKey(MAX_SPEED)) {
maxSpeed = parseSilentFloat(params.get(MAX_SPEED), maxSpeed); maxSpeed = parseSilentFloat(params.get(MAX_SPEED), maxSpeed);
} }
if (shortestRoute) {
maxSpeed = Math.min(CAR_SHORTEST_DEFAULT_SPEED, maxSpeed);
}
initCaches(); initCaches();
} }
public GeneralRouter(GeneralRouterProfile profile, Map<String, String> attributes) { public GeneralRouter(GeneralRouterProfile profile, Map<String, String> attributes) {

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="shared_string_error_short">ERR</string>
<string name="last_update_from_telegram_date">Last update from Telegram: %1$s</string> <string name="last_update_from_telegram_date">Last update from Telegram: %1$s</string>
<string name="last_response_date">Last response: %1$s</string> <string name="last_response_date">Last response: %1$s</string>
<string name="last_update_from_telegram_duration">Last update from Telegram: %1$s ago</string> <string name="last_update_from_telegram_duration">Last update from Telegram: %1$s ago</string>

View file

@ -207,7 +207,7 @@ class TelegramSettings(private val app: TelegramApplication) {
fun updateLiveTrack(userId: Int, chatId: Long, deviceName: String, enable: Boolean) { fun updateLiveTrack(userId: Int, chatId: Long, deviceName: String, enable: Boolean) {
val tracksInfo = liveTracksInfo.toMutableList() val tracksInfo = liveTracksInfo.toMutableList()
if (enable) { if (enable) {
val colorIndex = if (tracksInfo.size > 0) (tracksInfo.last().colorIndex + 1) % ShowLocationHelper.GPX_COLORS_COUNT else 0 val colorIndex = if (tracksInfo.size > 0) (tracksInfo.last().colorIndex + 1) % ShowLocationHelper.GPX_COLORS.size else 0
tracksInfo.add(LiveTrackInfo(userId, chatId, deviceName, colorIndex)) tracksInfo.add(LiveTrackInfo(userId, chatId, deviceName, colorIndex))
} else { } else {
tracksInfo.removeAll { it.userId == userId && it.chatId == chatId && it.deviceName == deviceName } tracksInfo.removeAll { it.userId == userId && it.chatId == chatId && it.deviceName == deviceName }

View file

@ -43,23 +43,21 @@ class ShowLocationHelper(private val app: TelegramApplication) {
const val LIVE_TRACKS_DIR = "livetracks" const val LIVE_TRACKS_DIR = "livetracks"
const val GPX_COLORS_COUNT = 10
private const val STATUS_WIDGET_ID = "status_widget" private const val STATUS_WIDGET_ID = "status_widget"
private const val STATUS_WIDGET_MENU_ICON = "widget_location_sharing_night" private const val STATUS_WIDGET_MENU_ICON = "widget_location_sharing_night"
private const val STATUS_WIDGET_MENU_ICON_OLD = "ic_action_relative_bearing" private const val STATUS_WIDGET_MENU_ICON_OLD = "ic_action_relative_bearing"
private const val STATUS_WIDGET_ICON_OLD = "widget_relative_bearing_day" private const val STATUS_WIDGET_ICON_OLD = "widget_relative_bearing_day"
private const val STATUS_WIDGET_ANIM_ICON_DAY = "anim_widget_location_sharing_day" private const val STATUS_WIDGET_ICON_DAY = "widget_location_sharing_day"
private const val STATUS_WIDGET_ANIM_ICON_NIGHT = "anim_widget_location_sharing_night" private const val STATUS_WIDGET_ICON_NIGHT = "widget_location_sharing_night"
private const val STATUS_WIDGET_ON_ANIM_ICON_DAY = "anim_widget_location_sharing_on_day" private const val STATUS_WIDGET_ON_ICON_DAY = "widget_location_sharing_on_day"
private const val STATUS_WIDGET_ON_ANIM_ICON_NIGHT = "anim_widget_location_sharing_on_night" private const val STATUS_WIDGET_ON_ICON_NIGHT = "widget_location_sharing_on_night"
private const val STATUS_WIDGET_OFF_ICON_DAY = "widget_location_sharing_off_day" private const val STATUS_WIDGET_OFF_ICON_DAY = "widget_location_sharing_off_day"
private const val STATUS_WIDGET_OFF_ICON_NIGHT = "widget_location_sharing_off_night" private const val STATUS_WIDGET_OFF_ICON_NIGHT = "widget_location_sharing_off_night"
val GPX_COLORS = arrayOf( val GPX_COLORS = arrayOf(
"red", "orange", "lightblue", "blue", "purple", "red", "orange", "lightblue", "blue", "purple", "pink",
"translucent_red", "translucent_orange", "translucent_lightblue", "translucent_red", "translucent_orange", "translucent_lightblue",
"translucent_blue", "translucent_purple" "translucent_blue", "translucent_purple", "translucent_pink"
) )
} }
@ -232,21 +230,27 @@ class ShowLocationHelper(private val app: TelegramApplication) {
STATUS_WIDGET_MENU_ICON_OLD STATUS_WIDGET_MENU_ICON_OLD
} }
val text = when { val text = when {
time > 0L -> { time > 0L && isSending -> {
iconDay = STATUS_WIDGET_ANIM_ICON_DAY iconDay = STATUS_WIDGET_ON_ICON_DAY
iconNight = STATUS_WIDGET_ANIM_ICON_NIGHT iconNight = STATUS_WIDGET_ON_ICON_NIGHT
val diffTime = (System.currentTimeMillis() - time) / 1000
OsmandFormatter.getFormattedDurationForWidget(diffTime)
}
time > 0L && !isSending -> {
iconDay = STATUS_WIDGET_ICON_DAY
iconNight = STATUS_WIDGET_ICON_NIGHT
val diffTime = (System.currentTimeMillis() - time) / 1000 val diffTime = (System.currentTimeMillis() - time) / 1000
OsmandFormatter.getFormattedDurationForWidget(diffTime) OsmandFormatter.getFormattedDurationForWidget(diffTime)
} }
time == 0L && isSending -> { time == 0L && isSending -> {
iconDay = STATUS_WIDGET_ON_ANIM_ICON_DAY iconDay = STATUS_WIDGET_ON_ICON_DAY
iconNight = STATUS_WIDGET_ON_ANIM_ICON_NIGHT iconNight = STATUS_WIDGET_ON_ICON_NIGHT
app.getString(R.string.shared_string_ok) app.getString(R.string.shared_string_ok)
} }
time == 0L && !isSending -> { time == 0L && !isSending -> {
iconDay = STATUS_WIDGET_ANIM_ICON_DAY iconDay = STATUS_WIDGET_ICON_DAY
iconNight = STATUS_WIDGET_ANIM_ICON_NIGHT iconNight = STATUS_WIDGET_ICON_NIGHT
app.getString(R.string.shared_string_ok) app.getString(R.string.shared_string_error_short)
} }
else -> { else -> {
iconDay = STATUS_WIDGET_OFF_ICON_DAY iconDay = STATUS_WIDGET_OFF_ICON_DAY

View file

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M7,19V21C7,22.1046 7.8954,23 9,23H19C20.1046,23 21,22.1046 21,21V7C21,5.8954 20.1046,5 19,5H17V17C17,18.1046 16.1046,19 15,19H7Z"
android:strokeAlpha="0.5"
android:fillColor="#727272"
android:fillAlpha="0.5"/>
<path
android:pathData="M3,3C3,1.8954 3.8954,1 5,1H15C16.1046,1 17,1.8954 17,3V17C17,18.1046 16.1046,19 15,19H5C3.8954,19 3,18.1046 3,17V3ZM9,12V10H7V12H5V14H7L7,16H9V14H11V12H9ZM13,7H15V16H13V10H11V8H13V7Z"
android:fillColor="#727272"
android:fillType="evenOdd"/>
</vector>

View file

@ -0,0 +1,20 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M4,15V18L15,18V16.5C15,16.2239 15.2239,16 15.5,16C15.7761,16 16,16.2239 16,16.5V18H20V15H4Z"
android:strokeAlpha="0.5"
android:fillColor="#727272"
android:fillAlpha="0.5"/>
<path
android:pathData="M18,4H20V20H18V4ZM13,4H4V20H13V4ZM15.5,4C15.7761,4 16,4.2239 16,4.5V7.5C16,7.7761 15.7761,8 15.5,8C15.2239,8 15,7.7761 15,7.5V4.5C15,4.2239 15.2239,4 15.5,4ZM15.5,20C15.7761,20 16,19.7761 16,19.5V16.5C16,16.2239 15.7761,16 15.5,16C15.2239,16 15,16.2239 15,16.5V19.5C15,19.7761 15.2239,20 15.5,20ZM2,4C2,2.8954 2.8954,2 4,2H20C21.1046,2 22,2.8954 22,4V20C22,21.1046 21.1046,22 20,22H4C2.8954,22 2,21.1046 2,20V4ZM15,10.5C15,10.2239 15.2239,10 15.5,10C15.7761,10 16,10.2239 16,10.5V13.5C16,13.7761 15.7761,14 15.5,14C15.2239,14 15,13.7761 15,13.5V10.5Z"
android:fillColor="#727272"
android:fillType="evenOdd"/>
<path
android:pathData="M4,4h9v11h-9z"
android:strokeAlpha="0.2"
android:fillColor="#727272"
android:fillAlpha="0.2"/>
</vector>

View file

@ -0,0 +1,40 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M7,21V19H9V21H11V23H9C7.8954,23 7,22.1046 7,21Z"
android:strokeAlpha="0.5"
android:fillColor="#727272"
android:fillAlpha="0.5"/>
<path
android:pathData="M13,23H15V21H13V23Z"
android:strokeAlpha="0.5"
android:fillColor="#727272"
android:fillAlpha="0.5"/>
<path
android:pathData="M17,21V23H19C20.1046,23 21,22.1046 21,21V19H19V21H17Z"
android:strokeAlpha="0.5"
android:fillColor="#727272"
android:fillAlpha="0.5"/>
<path
android:pathData="M19,17H21V15H19V17Z"
android:strokeAlpha="0.5"
android:fillColor="#727272"
android:fillAlpha="0.5"/>
<path
android:pathData="M19,13H21V11H19V13Z"
android:strokeAlpha="0.5"
android:fillColor="#727272"
android:fillAlpha="0.5"/>
<path
android:pathData="M19,9H21V7C21,5.8954 20.1046,5 19,5H17V7H19V9Z"
android:strokeAlpha="0.5"
android:fillColor="#727272"
android:fillAlpha="0.5"/>
<path
android:pathData="M5,1C3.8954,1 3,1.8954 3,3V17C3,18.1046 3.8954,19 5,19H15C16.1046,19 17,18.1046 17,17V3C17,1.8954 16.1046,1 15,1H5ZM11,10L15,13L11,16V14H6V12H11V10Z"
android:fillColor="#727272"
android:fillType="evenOdd"/>
</vector>

View file

@ -11,7 +11,8 @@
Thx - Hardy Thx - Hardy
--> -->
<string name="routing_profile_direct_to">Direct to point routing</string> <string name="routing_profile_direct_to">Direct-to-point</string>
<string name="clear_recorded_data">Clear recorded data</string>
<string name="release_3_6"> <string name="release_3_6">
• Profiles: now you can change order, set icon for map, change all setting for base profiles and restore them back to defaults\n\n • Profiles: now you can change order, set icon for map, change all setting for base profiles and restore them back to defaults\n\n
• Added exit number in the navigation\n\n • Added exit number in the navigation\n\n

View file

@ -1119,7 +1119,7 @@ public class OsmandAidlApi {
@SuppressLint("StaticFieldLeak") @SuppressLint("StaticFieldLeak")
private void finishGpxImport(boolean destinationExists, File destination, String color, boolean show) { private void finishGpxImport(boolean destinationExists, File destination, String color, boolean show) {
int col = ConfigureMapMenu.GpxAppearanceAdapter.parseTrackColor( final int col = ConfigureMapMenu.GpxAppearanceAdapter.parseTrackColor(
app.getRendererRegistry().getCurrentSelectedRenderer(), color); app.getRendererRegistry().getCurrentSelectedRenderer(), color);
if (!destinationExists) { if (!destinationExists) {
GpxDataItem gpxDataItem = new GpxDataItem(destination, col); GpxDataItem gpxDataItem = new GpxDataItem(destination, col);
@ -1145,6 +1145,9 @@ public class OsmandAidlApi {
@Override @Override
protected void onPostExecute(GPXFile gpx) { protected void onPostExecute(GPXFile gpx) {
if (gpx.error == null) { if (gpx.error == null) {
if (col != -1) {
gpx.setColor(col);
}
selectedGpx.setGpxFile(gpx, app); selectedGpx.setGpxFile(gpx, app);
refreshMap(); refreshMap();
} }

View file

@ -112,23 +112,24 @@ public class OsmAndLocationSimulation {
startStopRouteAnimation(ma, true, null); startStopRouteAnimation(ma, true, null);
} }
private void startAnimationThread(final OsmandApplication app, final List<Location> directions, final boolean useLocationTime, final float coeff) { private void startAnimationThread(final OsmandApplication app, final List<Location> directions, final boolean locTime, final float coeff) {
final float time = 1.5f; final float time = 1.5f;
routeAnimation = new Thread() { routeAnimation = new Thread() {
@Override @Override
public void run() { public void run() {
Location current = directions.isEmpty() ? null : new Location(directions.remove(0)); Location current = directions.isEmpty() ? null : new Location(directions.remove(0));
boolean useLocationTime = locTime && current.getTime() != 0;
Location prev = current; Location prev = current;
long prevTime = current == null ? 0 : current.getTime(); long prevTime = current == null ? 0 : current.getTime();
float meters = metersToGoInFiveSteps(directions, current); float meters = metersToGoInFiveSteps(directions, current);
if(current != null) { if(current != null) {
current.setProvider(OsmAndLocationProvider.SIMULATED_PROVIDER); current.setProvider(OsmAndLocationProvider.SIMULATED_PROVIDER);
} }
while (!directions.isEmpty() && routeAnimation != null) { while (!directions.isEmpty() && routeAnimation != null) {
int timeout = (int) (time * 1000); int timeout = (int) (time * 1000);
float intervalTime = time; float intervalTime = time;
if(useLocationTime) { if (useLocationTime) {
current = directions.remove(0); current = directions.remove(0);
meters = current.distanceTo(prev); meters = current.distanceTo(prev);
if (!directions.isEmpty()) { if (!directions.isEmpty()) {

View file

@ -46,6 +46,7 @@ import net.osmand.plus.activities.DayNightHelper;
import net.osmand.plus.activities.ExitActivity; import net.osmand.plus.activities.ExitActivity;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.activities.actions.OsmAndDialogs;
import net.osmand.plus.api.SQLiteAPI; import net.osmand.plus.api.SQLiteAPI;
import net.osmand.plus.api.SQLiteAPIImpl; import net.osmand.plus.api.SQLiteAPIImpl;
import net.osmand.plus.base.MapViewTrackingUtilities; import net.osmand.plus.base.MapViewTrackingUtilities;
@ -465,7 +466,7 @@ public class OsmandApplication extends MultiDexApplication {
if (voiceProvider == null || OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(voiceProvider)) { if (voiceProvider == null || OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(voiceProvider)) {
if (warningNoneProvider && voiceProvider == null) { if (warningNoneProvider && voiceProvider == null) {
if (uiContext instanceof MapActivity) { if (uiContext instanceof MapActivity) {
((MapActivity) uiContext).showVoiceProviderDialog(applicationMode, applyAllModes); OsmAndDialogs.showVoiceProviderDialog((MapActivity) uiContext, applicationMode, applyAllModes);
} }
} }
} else { } else {

View file

@ -251,7 +251,7 @@ public abstract class OsmandPlugin {
boolean paid = plugin.isPaid(); boolean paid = plugin.isPaid();
if ((Version.isDeveloperVersion(app) || !Version.isProductionVersion(app)) && !paid) { if ((Version.isDeveloperVersion(app) || !Version.isProductionVersion(app)) && !paid) {
// for test reasons // for test reasons
marketEnabled = false; // marketEnabled = false;
} }
if (pckg || (!marketEnabled && !paid)) { if (pckg || (!marketEnabled && !paid)) {
if (pckg && !app.getSettings().getPlugins().contains("-" + plugin.getId())) { if (pckg && !app.getSettings().getPlugins().contains("-" + plugin.getId())) {
@ -681,4 +681,4 @@ public abstract class OsmandPlugin {
pluginPreferences.add(preference); pluginPreferences.add(preference);
return preference; return preference;
} }
} }

View file

@ -25,10 +25,14 @@ import java.util.List;
public class SQLiteTileSource implements ITileSource { public class SQLiteTileSource implements ITileSource {
public static final String EXT = IndexConstants.SQLITE_EXT; public static final String EXT = IndexConstants.SQLITE_EXT;
private static final Log LOG = PlatformUtil.getLog(SQLiteTileSource.class); private static final Log LOG = PlatformUtil.getLog(SQLiteTileSource.class);
private static final String MAXZOOM_FIELD = "maxzoom";
private static final String MINZOOM_FIELD = "minzoom";
private static final String ELLIPSOID_FIELD = "ellipsoid";
private static final String URL_FIELD = "url";
private static final String EXPIREMINUTES_FIELD = "expireminutes";
private ITileSource base; private ITileSource base;
private String urlTemplate = null; private String urlTemplate = null;
private String name; private String name;
@ -163,7 +167,7 @@ public class SQLiteTileSource implements ITileSource {
if(cursor.moveToFirst()) { if(cursor.moveToFirst()) {
String[] columnNames = cursor.getColumnNames(); String[] columnNames = cursor.getColumnNames();
List<String> list = Arrays.asList(columnNames); List<String> list = Arrays.asList(columnNames);
int url = list.indexOf("url"); int url = list.indexOf(URL_FIELD);
if(url != -1) { if(url != -1) {
String template = cursor.getString(url); String template = cursor.getString(url);
if(!Algorithms.isEmpty(template)){ if(!Algorithms.isEmpty(template)){
@ -192,7 +196,7 @@ public class SQLiteTileSource implements ITileSource {
timeSupported = hasTimeColumn(); timeSupported = hasTimeColumn();
addInfoColumn("timecolumn", timeSupported? "yes" : "no"); addInfoColumn("timecolumn", timeSupported? "yes" : "no");
} }
int expireminutes = list.indexOf("expireminutes"); int expireminutes = list.indexOf(EXPIREMINUTES_FIELD);
this.expirationTimeMillis = -1; this.expirationTimeMillis = -1;
if(expireminutes != -1) { if(expireminutes != -1) {
int minutes = (int) cursor.getInt(expireminutes); int minutes = (int) cursor.getInt(expireminutes);
@ -200,14 +204,14 @@ public class SQLiteTileSource implements ITileSource {
this.expirationTimeMillis = minutes * 60 * 1000l; this.expirationTimeMillis = minutes * 60 * 1000l;
} }
} else { } else {
addInfoColumn("expireminutes", "0"); addInfoColumn(EXPIREMINUTES_FIELD, "0");
} }
int tsColumn = list.indexOf("tilesize"); int tsColumn = list.indexOf("tilesize");
this.tileSizeSpecified = tsColumn != -1; this.tileSizeSpecified = tsColumn != -1;
if(tileSizeSpecified) { if(tileSizeSpecified) {
this.tileSize = (int) cursor.getInt(tsColumn); this.tileSize = (int) cursor.getInt(tsColumn);
} }
int ellipsoid = list.indexOf("ellipsoid"); int ellipsoid = list.indexOf(ELLIPSOID_FIELD);
if(ellipsoid != -1) { if(ellipsoid != -1) {
int set = (int) cursor.getInt(ellipsoid); int set = (int) cursor.getInt(ellipsoid);
if(set == 1){ if(set == 1){
@ -225,15 +229,14 @@ public class SQLiteTileSource implements ITileSource {
if(randomsId != -1) { if(randomsId != -1) {
this.randoms = cursor.getString(randomsId); this.randoms = cursor.getString(randomsId);
this.randomsArray = TileSourceTemplate.buildRandomsArray(this.randoms); this.randomsArray = TileSourceTemplate.buildRandomsArray(this.randoms);
} }
//boolean inversiveInfoZoom = tnumbering != -1 && "BigPlanet".equals(cursor.getString(tnumbering)); //boolean inversiveInfoZoom = tnumbering != -1 && "BigPlanet".equals(cursor.getString(tnumbering));
boolean inversiveInfoZoom = inversiveZoom; boolean inversiveInfoZoom = inversiveZoom;
int mnz = list.indexOf("minzoom"); int mnz = list.indexOf(MINZOOM_FIELD);
if(mnz != -1) { if(mnz != -1) {
minZoom = (int) cursor.getInt(mnz); minZoom = (int) cursor.getInt(mnz);
} }
int mxz = list.indexOf("maxzoom"); int mxz = list.indexOf(MAXZOOM_FIELD);
if(mxz != -1) { if(mxz != -1) {
maxZoom = (int) cursor.getInt(mxz); maxZoom = (int) cursor.getInt(mxz);
} }
@ -251,10 +254,37 @@ public class SQLiteTileSource implements ITileSource {
return db; return db;
} }
public void updateFromTileSourceTemplate(TileSourceTemplate r) {
if (!onlyReadonlyAvailable) {
int maxZoom = r.getMaximumZoomSupported();
int minZoom = r.getMinimumZoomSupported();
if (inversiveZoom) {
int mnz = minZoom;
minZoom = 17 - maxZoom;
maxZoom = 17 - mnz;
}
if (getUrlTemplate() != null && !getUrlTemplate().equals(r.getUrlTemplate())) {
db.execSQL("update info set " + URL_FIELD + " = '" + r.getUrlTemplate() + "'");
}
if (r.getMinimumZoomSupported() != minZoom) {
db.execSQL("update info set " + MINZOOM_FIELD + " = '" + minZoom + "'");
}
if (r.getMaximumZoomSupported() != maxZoom) {
db.execSQL("update info set " + MAXZOOM_FIELD + " = '" + maxZoom + "'");
}
if (r.isEllipticYTile() != isEllipticYTile()) {
db.execSQL("update info set " + ELLIPSOID_FIELD + " = '" + (r.isEllipticYTile() ? 1 : 0) + "'");
}
if (r.getExpirationTimeMinutes() != getExpirationTimeMinutes()) {
db.execSQL("update info set " + EXPIREMINUTES_FIELD + " = '" + r.getExpirationTimeMinutes() + "'");
}
}
}
private void addInfoColumn(String columnName, String value) { private void addInfoColumn(String columnName, String value) {
if(!onlyReadonlyAvailable) { if (!onlyReadonlyAvailable) {
db.execSQL("alter table info add column "+columnName+" TEXT"); db.execSQL("alter table info add column " + columnName + " TEXT");
db.execSQL("update info set "+columnName+" = '"+value+"'"); db.execSQL("update info set " + columnName + " = '" + value + "'");
} }
} }
@ -517,7 +547,9 @@ public class SQLiteTileSource implements ITileSource {
return referer; return referer;
} }
public String getUrlTemplate() {
return urlTemplate;
}
} }

View file

@ -1090,75 +1090,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
new XMasDialogFragment().show(getSupportFragmentManager(), XMasDialogFragment.TAG); new XMasDialogFragment().show(getSupportFragmentManager(), XMasDialogFragment.TAG);
} }
public void showVoiceProviderDialog(final ApplicationMode applicationMode, final boolean applyAllModes) {
boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
final RoutingOptionsHelper routingOptionsHelper = app.getRoutingOptionsHelper();
final AlertDialog.Builder builder = new AlertDialog.Builder(UiUtilities.getThemedContext(this, nightMode));
final String[] firstSelectedVoiceProvider = new String[1];
View view = UiUtilities.getInflater(this, nightMode).inflate(R.layout.select_voice_first, null);
((ImageView) view.findViewById(R.id.icon))
.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_volume_up, settings.isLightContent()));
view.findViewById(R.id.spinner).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
routingOptionsHelper.selectVoiceGuidance(MapActivity.this, new CallbackWithObject<String>() {
@Override
public boolean processResult(String result) {
boolean acceptableValue = !RoutePreferencesMenu.MORE_VALUE.equals(firstSelectedVoiceProvider[0]);
if (acceptableValue) {
((TextView) v.findViewById(R.id.selectText))
.setText(routingOptionsHelper.getVoiceProviderName(v.getContext(), result));
firstSelectedVoiceProvider[0] = result;
}
return acceptableValue;
}
}, applicationMode);
}
});
((ImageView) view.findViewById(R.id.dropDownIcon))
.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down, settings.isLightContent()));
builder.setCancelable(true);
builder.setNegativeButton(R.string.shared_string_cancel, null);
builder.setPositiveButton(R.string.shared_string_apply, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (!Algorithms.isEmpty(firstSelectedVoiceProvider[0])) {
routingOptionsHelper.applyVoiceProvider(MapActivity.this, firstSelectedVoiceProvider[0], applyAllModes);
if (OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(firstSelectedVoiceProvider[0])) {
settings.VOICE_MUTE.setModeValue(applicationMode, true);
} else {
settings.VOICE_MUTE.setModeValue(applicationMode, false);
}
}
}
});
builder.setNeutralButton(R.string.shared_string_do_not_use, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (applyAllModes) {
muteVoiceForAllProfiles();
} else {
settings.VOICE_PROVIDER.setModeValue(applicationMode, OsmandSettings.VOICE_PROVIDER_NOT_USE);
settings.VOICE_MUTE.setModeValue(applicationMode, true);
}
}
});
builder.setView(view);
builder.show();
}
private void muteVoiceForAllProfiles() {
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
settings.VOICE_PROVIDER.setModeValue(mode, OsmandSettings.VOICE_PROVIDER_NOT_USE);
settings.VOICE_MUTE.setModeValue(mode, true);
}
}
private void dismissSecondSplashScreen() { private void dismissSecondSplashScreen() {
if (SecondSplashScreenFragment.VISIBLE) { if (SecondSplashScreenFragment.VISIBLE) {

View file

@ -247,18 +247,18 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
} }
} }
} }
clearRecordedData(warnings.isEmpty());
return new SaveGpxResult(warnings, filenames);
}
if (warnings.isEmpty()) { public void clearRecordedData(boolean isWarningEmpty) {
if (isWarningEmpty) {
SQLiteDatabase db = getWritableDatabase(); SQLiteDatabase db = getWritableDatabase();
if (db != null) { if (db != null) {
try { try {
if (db.isOpen()) { 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 " + 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$ 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 { } finally {
db.close(); db.close();
@ -274,7 +274,6 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
currentTrack.getModifiablePointsToDisplay().clear(); currentTrack.getModifiablePointsToDisplay().clear();
currentTrack.getModifiableGpxFile().modifiedTime = System.currentTimeMillis(); currentTrack.getModifiableGpxFile().modifiedTime = System.currentTimeMillis();
prepareCurrentTrackForRecording(); prepareCurrentTrackForRecording();
return new SaveGpxResult(warnings, filenames);
} }
public Map<String, GPXFile> collectRecordedData() { public Map<String, GPXFile> collectRecordedData() {

View file

@ -5,7 +5,23 @@ import java.util.Map;
import android.app.Activity; import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.CallbackWithObject;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper;
import net.osmand.util.Algorithms;
public class OsmAndDialogs { public class OsmAndDialogs {
@ -24,7 +40,76 @@ public class OsmAndDialogs {
action.prepareDialog(activity, args, dlg); action.prepareDialog(activity, args, dlg);
} }
} }
public static void showVoiceProviderDialog(final MapActivity activity, final ApplicationMode applicationMode, final boolean applyAllModes) {
OsmandApplication app = activity.getMyApplication();
final OsmandSettings settings = app.getSettings();
boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
final RoutingOptionsHelper routingOptionsHelper = app.getRoutingOptionsHelper();
final AlertDialog.Builder builder = new AlertDialog.Builder(UiUtilities.getThemedContext(activity, nightMode));
final String[] firstSelectedVoiceProvider = new String[1];
View view = UiUtilities.getInflater(activity, nightMode).inflate(R.layout.select_voice_first, null);
((ImageView) view.findViewById(R.id.icon))
.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_volume_up, settings.isLightContent()));
view.findViewById(R.id.spinner).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
routingOptionsHelper.selectVoiceGuidance(activity, new CallbackWithObject<String>() {
@Override
public boolean processResult(String result) {
boolean acceptableValue = !RoutePreferencesMenu.MORE_VALUE.equals(firstSelectedVoiceProvider[0]);
if (acceptableValue) {
((TextView) v.findViewById(R.id.selectText))
.setText(routingOptionsHelper.getVoiceProviderName(v.getContext(), result));
firstSelectedVoiceProvider[0] = result;
}
return acceptableValue;
}
}, applicationMode);
}
});
((ImageView) view.findViewById(R.id.dropDownIcon))
.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down, settings.isLightContent()));
builder.setCancelable(true);
builder.setNegativeButton(R.string.shared_string_cancel, null);
builder.setPositiveButton(R.string.shared_string_apply, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (!Algorithms.isEmpty(firstSelectedVoiceProvider[0])) {
routingOptionsHelper.applyVoiceProvider(activity, firstSelectedVoiceProvider[0], applyAllModes);
if (OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(firstSelectedVoiceProvider[0])) {
settings.VOICE_MUTE.setModeValue(applicationMode, true);
} else {
settings.VOICE_MUTE.setModeValue(applicationMode, false);
}
}
}
});
builder.setNeutralButton(R.string.shared_string_do_not_use, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (applyAllModes) {
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
//if (!settings.VOICE_PROVIDER.isSetForMode(mode)) {
settings.VOICE_PROVIDER.setModeValue(mode, OsmandSettings.VOICE_PROVIDER_NOT_USE);
settings.VOICE_MUTE.setModeValue(mode, true);
//}
}
}
settings.VOICE_PROVIDER.setModeValue(applicationMode, OsmandSettings.VOICE_PROVIDER_NOT_USE);
settings.VOICE_MUTE.setModeValue(applicationMode, true);
}
});
builder.setView(view);
builder.show();
}
public static void registerDialogAction(OsmAndAction action) { public static void registerDialogAction(OsmAndAction action) {
if(action.getDialogID() != 0) { if(action.getDialogID() != 0) {

View file

@ -23,6 +23,7 @@ import net.osmand.map.TileSourceManager;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.ItemClickListener; import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
import net.osmand.plus.ContextMenuItem; import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.SQLiteTileSource;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
@ -252,7 +253,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
getDownloadActivity().reloadLocalIndexes(); getDownloadActivity().reloadLocalIndexes();
return true; return true;
} }
}, info.getName()); }, info.getFileName());
} else if (resId == R.string.local_index_mi_restore) { } else if (resId == R.string.local_index_mi_restore) {
new LocalIndexOperationTask(getDownloadActivity(), listAdapter, LocalIndexOperationTask.RESTORE_OPERATION).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, info); new LocalIndexOperationTask(getDownloadActivity(), listAdapter, LocalIndexOperationTask.RESTORE_OPERATION).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, info);
} else if (resId == R.string.shared_string_delete) { } else if (resId == R.string.shared_string_delete) {
@ -1237,7 +1238,9 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
} }
}); });
if (info.getType() == LocalIndexType.TILES_DATA if (info.getType() == LocalIndexType.TILES_DATA
&& (info.getAttachedObject() instanceof TileSourceManager.TileSourceTemplate)) { && ((info.getAttachedObject() instanceof TileSourceManager.TileSourceTemplate)
|| ((info.getAttachedObject() instanceof SQLiteTileSource)
&& ((SQLiteTileSource) info.getAttachedObject()).couldBeDownloadedFromInternet()))) {
item = optionsMenu.getMenu().add(R.string.shared_string_edit) item = optionsMenu.getMenu().add(R.string.shared_string_edit)
.setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_edit_dark)); .setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_edit_dark));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

View file

@ -310,6 +310,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
} }
if (app.getSavingTrackHelper().hasDataToSave()) { if (app.getSavingTrackHelper().hasDataToSave()) {
items.add(R.string.save_current_track); items.add(R.string.save_current_track);
items.add(R.string.clear_recorded_data);
} }
String[] strings = new String[items.size()]; String[] strings = new String[items.size()];
for (int i = 0; i < strings.length; i++) { for (int i = 0; i < strings.length; i++) {
@ -326,6 +327,8 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
if (app.getLocationProvider().checkGPSEnabled(activity)) { if (app.getLocationProvider().checkGPSEnabled(activity)) {
startGPXMonitoring(activity, showTrackSelection); startGPXMonitoring(activity, showTrackSelection);
} }
} else if (item == R.string.clear_recorded_data) {
app.getSavingTrackHelper().clearRecordedData(true);
} else if(item == R.string.gpx_monitoring_stop) { } else if(item == R.string.gpx_monitoring_stop) {
stopRecording(); stopRecording();
} else if(item == R.string.gpx_start_new_segment) { } else if(item == R.string.gpx_start_new_segment) {
@ -338,12 +341,12 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
showIntervalChooseDialog(activity, app.getString(R.string.live_monitoring_interval) + " : %s", showIntervalChooseDialog(activity, app.getString(R.string.live_monitoring_interval) + " : %s",
app.getString(R.string.save_track_to_gpx_globally), SECONDS, MINUTES, app.getString(R.string.save_track_to_gpx_globally), SECONDS, MINUTES,
null, vs, showTrackSelection, new OnClickListener() { null, vs, showTrackSelection, new OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
settings.LIVE_MONITORING_INTERVAL.set(vs.value); settings.LIVE_MONITORING_INTERVAL.set(vs.value);
settings.LIVE_MONITORING.set(true); settings.LIVE_MONITORING.set(true);
} }
}); });
} }
if (monitoringControl != null) { if (monitoringControl != null) {
monitoringControl.updateInfo(null); monitoringControl.updateInfo(null);

View file

@ -36,6 +36,7 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.CommonPreference; import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.OsmandSettings.LayerTransparencySeekbarMode; import net.osmand.plus.OsmandSettings.LayerTransparencySeekbarMode;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.SQLiteTileSource;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.Version; import net.osmand.plus.Version;
import net.osmand.plus.activities.DownloadTilesDialog; import net.osmand.plus.activities.DownloadTilesDialog;
@ -478,10 +479,11 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
t.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); t.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
public static void defineNewEditLayer(final Activity activity, final ResultMatcher<TileSourceTemplate> resultMatcher, String editedLayerName) { public static void defineNewEditLayer(final Activity activity, final ResultMatcher<TileSourceTemplate> resultMatcher, final String editedLayerName) {
final OsmandApplication app = (OsmandApplication) activity.getApplication(); final OsmandApplication app = (OsmandApplication) activity.getApplication();
final OsmandSettings settings = app.getSettings(); final OsmandSettings settings = app.getSettings();
final Map<String, String> entriesMap = settings.getTileSourceEntries(false); final Map<String, String> entriesMap = settings.getTileSourceEntries(true);
final SQLiteTileSource[] sqLiteTileSource = new SQLiteTileSource[1];
boolean nightMode = isNightMode(activity, app); boolean nightMode = isNightMode(activity, app);
final int dp8 = AndroidUtils.dpToPx(app, 8f); final int dp8 = AndroidUtils.dpToPx(app, 8f);
int textColorPrimary = ContextCompat.getColor(app, nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light); int textColorPrimary = ContextCompat.getColor(app, nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light);
@ -512,10 +514,25 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
); );
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
existing.setAdapter(adapter); existing.setAdapter(adapter);
TileSourceTemplate template;
if (editedLayerName != null) { if (editedLayerName != null) {
File f = ((OsmandApplication) activity.getApplication()).getAppPath( if (!editedLayerName.endsWith(IndexConstants.SQLITE_EXT)) {
IndexConstants.TILES_INDEX_DIR + editedLayerName); File f = ((OsmandApplication) activity.getApplication()).getAppPath(
TileSourceTemplate template = TileSourceManager.createTileSourceTemplate(f); IndexConstants.TILES_INDEX_DIR + editedLayerName);
template = TileSourceManager.createTileSourceTemplate(f);
} else {
List<TileSourceTemplate> knownTemplates = TileSourceManager.getKnownSourceTemplates();
File tPath = app.getAppPath(IndexConstants.TILES_INDEX_DIR);
File dir = new File(tPath, editedLayerName);
sqLiteTileSource[0] = new SQLiteTileSource(app, dir, knownTemplates);
sqLiteTileSource[0].couldBeDownloadedFromInternet();
template = new TileSourceManager.TileSourceTemplate(sqLiteTileSource[0].getName(),
sqLiteTileSource[0].getUrlTemplate(), "png", sqLiteTileSource[0].getMaximumZoomSupported(),
sqLiteTileSource[0].getMinimumZoomSupported(), sqLiteTileSource[0].getTileSize(),
sqLiteTileSource[0].getBitDensity(), 32000);
template.setExpirationTimeMinutes(sqLiteTileSource[0].getExpirationTimeMinutes());
template.setEllipticYTile(sqLiteTileSource[0].isEllipticYTile());
}
if (template != null) { if (template != null) {
result[0] = template.copy(); result[0] = template.copy();
updateTileSourceEditView(result[0], name, urlToLoad, minZoom, maxZoom, expire, elliptic); updateTileSourceEditView(result[0], name, urlToLoad, minZoom, maxZoom, expire, elliptic);
@ -558,11 +575,15 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
r.setEllipticYTile(elliptic.isChecked()); r.setEllipticYTile(elliptic.isChecked());
r.setUrlToLoad(urlToLoad.getText().toString().equals("") ? null : urlToLoad.getText().toString().replace("{$x}", "{1}") r.setUrlToLoad(urlToLoad.getText().toString().equals("") ? null : urlToLoad.getText().toString().replace("{$x}", "{1}")
.replace("{$y}", "{2}").replace("{$z}", "{0}")); .replace("{$y}", "{2}").replace("{$z}", "{0}"));
if (r.getName().length() > 0) { if (sqLiteTileSource[0] != null) {
if (settings.installTileSource(r)) { sqLiteTileSource[0].updateFromTileSourceTemplate(r);
Toast.makeText(activity, activity.getString(R.string.edit_tilesource_successfully, r.getName()), } else {
Toast.LENGTH_SHORT).show(); if (r.getName().length() > 0) {
resultMatcher.publish(r); if (settings.installTileSource(r)) {
Toast.makeText(activity, activity.getString(R.string.edit_tilesource_successfully, r.getName()),
Toast.LENGTH_SHORT).show();
resultMatcher.publish(r);
}
} }
} }
} catch (RuntimeException e) { } catch (RuntimeException e) {

View file

@ -62,6 +62,7 @@ import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SettingsBaseActivity; import net.osmand.plus.activities.SettingsBaseActivity;
import net.osmand.plus.activities.actions.AppModeDialog; import net.osmand.plus.activities.actions.AppModeDialog;
import net.osmand.plus.activities.actions.OsmAndDialogs;
import net.osmand.plus.base.ContextMenuFragment.MenuState; import net.osmand.plus.base.ContextMenuFragment.MenuState;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper;
@ -1098,7 +1099,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
if (app != null) { if (app != null) {
String voiceProvider = app.getSettings().VOICE_PROVIDER.getModeValue(appMode); String voiceProvider = app.getSettings().VOICE_PROVIDER.getModeValue(appMode);
if (voiceProvider == null || OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(voiceProvider)) { if (voiceProvider == null || OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(voiceProvider)) {
mapActivity.showVoiceProviderDialog(appMode, false); OsmAndDialogs.showVoiceProviderDialog(mapActivity, appMode, false);
} else { } else {
app.getRoutingOptionsHelper().switchSound(); app.getRoutingOptionsHelper().switchSound();
} }

View file

@ -24,6 +24,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.actions.OsmAndDialogs;
import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
@ -182,7 +183,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
routingHelper.getVoiceRouter().setMuteForMode(applicationMode, active); routingHelper.getVoiceRouter().setMuteForMode(applicationMode, active);
String voiceProvider = app.getSettings().VOICE_PROVIDER.getModeValue(applicationMode); String voiceProvider = app.getSettings().VOICE_PROVIDER.getModeValue(applicationMode);
if (voiceProvider == null || OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(voiceProvider)) { if (voiceProvider == null || OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(voiceProvider)) {
mapActivity.showVoiceProviderDialog(applicationMode, false); OsmAndDialogs.showVoiceProviderDialog(mapActivity, applicationMode, false);
} else { } else {
muteSoundItem[0].setChecked(!active); muteSoundItem[0].setChecked(!active);
muteSoundItem[0].setIcon(getContentIcon(!active ? optionsItem.getActiveIconId() : optionsItem.getDisabledIconId())); muteSoundItem[0].setIcon(getContentIcon(!active ? optionsItem.getActiveIconId() : optionsItem.getDisabledIconId()));

View file

@ -187,13 +187,13 @@ public class RoutingOptionsHelper {
public void applyVoiceProvider(MapActivity mapActivity, String provider, boolean applyAllModes) { public void applyVoiceProvider(MapActivity mapActivity, String provider, boolean applyAllModes) {
OsmandApplication app = mapActivity.getMyApplication(); OsmandApplication app = mapActivity.getMyApplication();
ApplicationMode selectedAppMode = app.getRoutingHelper().getAppMode(); ApplicationMode selectedAppMode = app.getRoutingHelper().getAppMode();
OsmandSettings.OsmandPreference<String> VP = app.getSettings().VOICE_PROVIDER;
if (applyAllModes) { if (applyAllModes) {
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) { for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
app.getSettings().VOICE_PROVIDER.setModeValue(mode, provider); VP.setModeValue(mode, provider);
} }
} else {
app.getSettings().VOICE_PROVIDER.setModeValue(selectedAppMode, provider);
} }
VP.setModeValue(selectedAppMode, provider);
app.initVoiceCommandPlayer(mapActivity, selectedAppMode, false, null, true, false, applyAllModes); app.initVoiceCommandPlayer(mapActivity, selectedAppMode, false, null, true, false, applyAllModes);
} }

View file

@ -35,6 +35,7 @@ public class RouteCalculationResult {
private static double distanceClosestToIntermediate = 3000; private static double distanceClosestToIntermediate = 3000;
private static double distanceThresholdToIntermediate = 25; private static double distanceThresholdToIntermediate = 25;
private static double DISTANCE_THRESHOLD_TO_INTRODUCE_FIRST_AND_LAST_POINTS = 50;
// could not be null and immodifiable! // could not be null and immodifiable!
private final List<Location> locations; private final List<Location> locations;
private final List<RouteDirectionInfo> directions; private final List<RouteDirectionInfo> directions;
@ -696,22 +697,9 @@ public class RouteCalculationResult {
private static void introduceFirstPointAndLastPoint(List<Location> locations, List<RouteDirectionInfo> directions, private static void introduceFirstPointAndLastPoint(List<Location> locations, List<RouteDirectionInfo> directions,
List<RouteSegmentResult> segs, Location start, LatLon end, List<RouteSegmentResult> segs, Location start, LatLon end,
OsmandApplication ctx) { OsmandApplication ctx) {
if (!locations.isEmpty() && locations.get(0).distanceTo(start) > 50) { boolean firstPointIntroduced = introduceFirstPoint(locations, directions, segs, start);
// add start point boolean lastPointIntroduced = introduceLastPoint(locations, directions, segs, end);
locations.add(0, start); if (firstPointIntroduced || lastPointIntroduced) {
if(segs != null) {
segs.add(0, segs.get(0));
}
if (directions != null && !directions.isEmpty()) {
for (RouteDirectionInfo i : directions) {
i.routePointOffset++;
}
RouteDirectionInfo info = new RouteDirectionInfo(directions.get(0).getAverageSpeed(),
TurnType.straight());
info.routePointOffset = 0;
// info.setDescriptionRoute(ctx.getString( R.string.route_head));//; //$NON-NLS-1$
directions.add(0, info);
}
checkForDuplicatePoints(locations, directions); checkForDuplicatePoints(locations, directions);
} }
RouteDirectionInfo lastDirInf = directions.size() > 0 ? directions.get(directions.size() - 1) : null; RouteDirectionInfo lastDirInf = directions.size() > 0 ? directions.get(directions.size() - 1) : null;
@ -746,6 +734,70 @@ public class RouteCalculationResult {
} }
} }
private static boolean introduceFirstPoint(List<Location> locations, List<RouteDirectionInfo> directions,
List<RouteSegmentResult> segs, Location start) {
if (!locations.isEmpty() && locations.get(0).distanceTo(start) > DISTANCE_THRESHOLD_TO_INTRODUCE_FIRST_AND_LAST_POINTS) {
// add start point
locations.add(0, start);
if (segs != null) {
segs.add(0, segs.get(0));
}
if (directions != null && !directions.isEmpty()) {
for (RouteDirectionInfo i : directions) {
i.routePointOffset++;
}
RouteDirectionInfo info = new RouteDirectionInfo(directions.get(0).getAverageSpeed(), TurnType.straight());
info.routePointOffset = 0;
// info.setDescriptionRoute(ctx.getString( R.string.route_head));//; //$NON-NLS-1$
directions.add(0, info);
}
return true;
}
return false;
}
private static boolean introduceLastPoint(List<Location> locations, List<RouteDirectionInfo> directions,
List<RouteSegmentResult> segs, LatLon end) {
if (!locations.isEmpty()) {
Location lastFoundLocation = locations.get(locations.size() - 1);
Location endLocation = new Location(lastFoundLocation.getProvider());
endLocation.setLatitude(end.getLatitude());
endLocation.setLongitude(end.getLongitude());
if (lastFoundLocation.distanceTo(endLocation) > DISTANCE_THRESHOLD_TO_INTRODUCE_FIRST_AND_LAST_POINTS) {
if (directions != null && !directions.isEmpty()) {
if (locations.size() > 2) {
int type = TurnType.C;
Location prevLast = locations.get(locations.size() - 2);
float lastBearing = prevLast.bearingTo(lastFoundLocation);
float bearingToEnd = lastFoundLocation.bearingTo(endLocation);
double diff = MapUtils.degreesDiff(lastBearing, bearingToEnd);
if (Math.abs(diff) > 10) {
if (Math.abs(diff) < 60) {
type = diff > 0 ? TurnType.TSLL : TurnType.TSLR;
} else {
type = diff > 0 ? TurnType.TL : TurnType.TR;
}
}
RouteDirectionInfo lastDirInf = directions.get(directions.size() - 1);
RouteDirectionInfo info = new RouteDirectionInfo(lastDirInf != null ? lastDirInf.getAverageSpeed() : 1, TurnType.valueOf(type, false));
info.routePointOffset = locations.size() - 1;
directions.add(info);
}
}
// add end point
locations.add(endLocation);
if (segs != null) {
segs.add(segs.get(segs.size() - 1));
}
return true;
}
}
return false;
}
/** /**
* PREPARATION * PREPARATION
* At the end always update listDistance local vars and time * At the end always update listDistance local vars and time

View file

@ -96,6 +96,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
private View saveButton; private View saveButton;
private boolean isBaseProfileImported; private boolean isBaseProfileImported;
private boolean isNewProfile;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -118,7 +119,6 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
profile.routeService = baseModeForNewProfile.getRouteService(); profile.routeService = baseModeForNewProfile.getRouteService();
profile.locationIcon = baseModeForNewProfile.getLocationIcon(); profile.locationIcon = baseModeForNewProfile.getLocationIcon();
profile.navigationIcon = baseModeForNewProfile.getNavigationIcon(); profile.navigationIcon = baseModeForNewProfile.getNavigationIcon();
onAppModeChanged(ApplicationMode.valueOfStringKey(baseModeForNewProfile.getStringKey(), null));
} else { } else {
profile.stringKey = getSelectedAppMode().getStringKey(); profile.stringKey = getSelectedAppMode().getStringKey();
profile.parent = getSelectedAppMode().getParent(); profile.parent = getSelectedAppMode().getParent();
@ -148,6 +148,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
changedProfile.locationIcon = profile.locationIcon; changedProfile.locationIcon = profile.locationIcon;
changedProfile.navigationIcon = profile.navigationIcon; changedProfile.navigationIcon = profile.navigationIcon;
} }
isNewProfile = ApplicationMode.valueOfStringKey(changedProfile.stringKey, null) == null;
} }
private String createNonDuplicateName(String oldName) { private String createNonDuplicateName(String oldName) {
@ -189,7 +190,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
findPreference(SELECT_ICON).setIconSpaceReserved(false); findPreference(SELECT_ICON).setIconSpaceReserved(false);
findPreference(SELECT_LOCATION_ICON).setIconSpaceReserved(false); findPreference(SELECT_LOCATION_ICON).setIconSpaceReserved(false);
findPreference(SELECT_NAV_ICON).setIconSpaceReserved(false); findPreference(SELECT_NAV_ICON).setIconSpaceReserved(false);
if (getSelectedAppMode().equals(ApplicationMode.DEFAULT)) { if (getSelectedAppMode().equals(ApplicationMode.DEFAULT) && !isNewProfile) {
findPreference(SELECT_ICON).setVisible(false); findPreference(SELECT_ICON).setVisible(false);
findPreference(ICON_ITEMS).setVisible(false); findPreference(ICON_ITEMS).setVisible(false);
} }
@ -228,10 +229,9 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
if (getActivity() != null) { if (getActivity() != null) {
hideKeyboard(); hideKeyboard();
if (isChanged()) { if (isChanged()) {
boolean isNew = ApplicationMode.valueOfStringKey(changedProfile.stringKey, null) == null; if (saveProfile()) {
if (saveProfile(isNew)) {
profile = changedProfile; profile = changedProfile;
if (isNew) { if (isNewProfile) {
ProfileAppearanceFragment.this.dismiss(); ProfileAppearanceFragment.this.dismiss();
BaseSettingsFragment.showInstance(getMapActivity(), SettingsScreenType.CONFIGURE_PROFILE, BaseSettingsFragment.showInstance(getMapActivity(), SettingsScreenType.CONFIGURE_PROFILE,
ApplicationMode.valueOfStringKey(changedProfile.stringKey, null)); ApplicationMode.valueOfStringKey(changedProfile.stringKey, null));
@ -645,7 +645,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
} }
} }
private boolean saveProfile(boolean isNew) { private boolean saveProfile() {
if (changedProfile.name.replace(" ", "").length() < 1) { if (changedProfile.name.replace(" ", "").length() < 1) {
if (getActivity() != null) { if (getActivity() != null) {
createWarningDialog(getActivity(), createWarningDialog(getActivity(),
@ -653,7 +653,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
} }
return false; return false;
} }
if (isNew) { if (isNewProfile) {
ApplicationMode.ApplicationModeBuilder builder = ApplicationMode ApplicationMode.ApplicationModeBuilder builder = ApplicationMode
.createCustomMode(changedProfile.parent, changedProfile.stringKey, app) .createCustomMode(changedProfile.parent, changedProfile.stringKey, app)
.setIconResName(ProfileIcons.getResStringByResId(changedProfile.iconRes)) .setIconResName(ProfileIcons.getResStringByResId(changedProfile.iconRes))