Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2014-08-22 02:40:26 +02:00
commit e68fcd1539
11 changed files with 127 additions and 45 deletions

View file

@ -9,6 +9,9 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="record_plugin_description">Save your tracks with one button touch on the map screen.
Show settings facilitating to record your trips to local GPX files or online using a web service.</string>
<string name="record_plugin_name">Record your trips</string>
<string name="int_hour">h</string> <string name="int_hour">h</string>
<string name="duration">Duration</string> <string name="duration">Duration</string>
<string name="distance">Distance</string> <string name="distance">Distance</string>
@ -507,9 +510,6 @@
</string> </string>
<string name="monitoring_settings">Logging services</string> <string name="monitoring_settings">Logging services</string>
<string name="monitoring_settings_descr">Configure how to record trips</string> <string name="monitoring_settings_descr">Configure how to record trips</string>
<string name="osmand_monitoring_plugin_description">Enable tracking and navigation in sleep (screen off) mode via periodically waking up the GPS device.
Show settings facilitating to record your trips to local GPX files or online using a web service.</string>
<string name="osmand_monitoring_plugin_name">Logging services</string>
<string name="osmand_background_plugin_description">Show settings to enable tracking and navigation in sleep (screen off) mode via periodically waking up the GPS device.</string> <string name="osmand_background_plugin_description">Show settings to enable tracking and navigation in sleep (screen off) mode via periodically waking up the GPS device.</string>
<string name="contribution_activity">Install version</string> <string name="contribution_activity">Install version</string>
<string name="choose_osmand_theme_descr">Choose application theme</string> <string name="choose_osmand_theme_descr">Choose application theme</string>

View file

@ -123,7 +123,9 @@ public class NavigationService extends Service implements LocationListener {
} }
public void stopIfNeeded(Context ctx, int usageIntent) { public void stopIfNeeded(Context ctx, int usageIntent) {
if((usedBy & usageIntent) > 0) {
usedBy -= usageIntent; usedBy -= usageIntent;
}
if (usedBy == 0) { if (usedBy == 0) {
final Intent serviceIntent = new Intent(ctx, NavigationService.class); final Intent serviceIntent = new Intent(ctx, NavigationService.class);
ctx.stopService(serviceIntent); ctx.stopService(serviceIntent);

View file

@ -174,4 +174,8 @@ public class OsmAndAppCustomization {
public boolean onDestinationReached() { public boolean onDestinationReached() {
return true; return true;
} }
public int getWaypointSearchRadius(int searchDeviationRadius, int type) {
return searchDeviationRadius;
}
} }

View file

@ -792,6 +792,7 @@ public class OsmandSettings {
public final CommonPreference<Boolean> SAVE_GLOBAL_TRACK_TO_GPX = new BooleanPreference("save_global_track_to_gpx", false).makeGlobal().cache(); public final CommonPreference<Boolean> SAVE_GLOBAL_TRACK_TO_GPX = new BooleanPreference("save_global_track_to_gpx", false).makeGlobal().cache();
public final CommonPreference<Integer> SAVE_GLOBAL_TRACK_INTERVAL = new IntPreference("save_global_track_interval", 5000).makeGlobal().cache(); public final CommonPreference<Integer> SAVE_GLOBAL_TRACK_INTERVAL = new IntPreference("save_global_track_interval", 5000).makeGlobal().cache();
public final CommonPreference<Boolean> SAVE_GLOBAL_TRACK_REMEMBER = new BooleanPreference("save_global_track_remember", false).makeGlobal().cache();
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<Boolean> SAVE_TRACK_TO_GPX = new BooleanPreference("save_track_to_gpx", false).makeProfile().cache(); public final CommonPreference<Boolean> SAVE_TRACK_TO_GPX = new BooleanPreference("save_track_to_gpx", false).makeProfile().cache();
{ {

View file

@ -8,7 +8,6 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.GPXUtilities; import net.osmand.plus.GPXUtilities;

View file

@ -289,7 +289,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
str = ctx.getString(R.string.waypoints); str = ctx.getString(R.string.waypoints);
break; break;
case WaypointHelper.POI: case WaypointHelper.POI:
str = waypointHelper.getPoiFilter() == null && !checked ? ctx.getString(R.string.poi) : waypointHelper str = waypointHelper.getPoiFilter() == null || !checked ? ctx.getString(R.string.poi) : waypointHelper
.getPoiFilter().getName(); .getPoiFilter().getName();
break; break;
} }

View file

@ -487,7 +487,7 @@ public class WaypointHelper {
PoiFilter pf = getPoiFilter(); PoiFilter pf = getPoiFilter();
if (pf != null) { if (pf != null) {
final List<Location> locs = route.getImmutableAllLocations(); final List<Location> locs = route.getImmutableAllLocations();
List<Amenity> amenities = app.getResourceManager().searchAmenitiesOnThePath(locs, searchDeviationRadius, List<Amenity> amenities = app.getResourceManager().searchAmenitiesOnThePath(locs, getSearchRadius(POI),
pf, new ResultMatcher<Amenity>() { pf, new ResultMatcher<Amenity>() {
@Override @Override
@ -514,6 +514,11 @@ public class WaypointHelper {
} }
protected int getSearchRadius(int type) {
return app.getAppCustomization().getWaypointSearchRadius(searchDeviationRadius, type);
}
private void calculateAlarms(RouteCalculationResult route, List<LocationPointWrapper> array) { private void calculateAlarms(RouteCalculationResult route, List<LocationPointWrapper> array) {
for(AlarmInfo i : route.getAlarmInfo()) { for(AlarmInfo i : route.getAlarmInfo()) {
@ -552,7 +557,7 @@ public class WaypointHelper {
int[] ind = new int[1]; int[] ind = new int[1];
for(LocationPoint p : points) { for(LocationPoint p : points) {
float dist = dist(p, immutableAllLocations, ind); float dist = dist(p, immutableAllLocations, ind);
if(dist <= searchDeviationRadius) { if(dist <= getSearchRadius(type)) {
LocationPointWrapper lpw = new LocationPointWrapper(rt, type, p, dist, ind[0]); LocationPointWrapper lpw = new LocationPointWrapper(rt, type, p, dist, ind[0]);
lpw.setAnnounce(announce); lpw.setAnnounce(announce);
locationPoints.add(lpw); locationPoints.add(lpw);

View file

@ -38,8 +38,12 @@ import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener; import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.view.View; import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.SeekBar; import android.widget.SeekBar;
import android.widget.LinearLayout.LayoutParams;
import android.widget.SeekBar.OnSeekBarChangeListener; import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView; import android.widget.TextView;
@ -50,6 +54,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
private BaseMapWidget monitoringControl; private BaseMapWidget monitoringControl;
private LiveMonitoringHelper liveMonitoringHelper; private LiveMonitoringHelper liveMonitoringHelper;
private boolean ADD_BG_TO_ACTION = true; private boolean ADD_BG_TO_ACTION = true;
private boolean isSaving;
public OsmandMonitoringPlugin(OsmandApplication app) { public OsmandMonitoringPlugin(OsmandApplication app) {
this.app = app; this.app = app;
@ -76,12 +81,12 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
@Override @Override
public String getDescription() { public String getDescription() {
return app.getString(R.string.osmand_monitoring_plugin_description); return app.getString(R.string.record_plugin_description);
} }
@Override @Override
public String getName() { public String getName() {
return app.getString(R.string.osmand_monitoring_plugin_name); return app.getString(R.string.record_plugin_name);
} }
@Override @Override
@ -154,6 +159,11 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
long lastUpdateTime; long lastUpdateTime;
@Override @Override
public boolean updateInfo(DrawSettings drawSettings) { public boolean updateInfo(DrawSettings drawSettings) {
if(isSaving){
setText(map.getString(R.string.import_save), "");
setImageDrawable(monitoringBig);
return true;
}
boolean visible = true; boolean visible = true;
String txt = map.getString(R.string.monitoring_control_start); String txt = map.getString(R.string.monitoring_control_start);
String subtxt = null; String subtxt = null;
@ -227,29 +237,37 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
} else { } else {
items.add(R.string.gpx_monitoring_start); items.add(R.string.gpx_monitoring_start);
} }
if(app.getSavingTrackHelper().hasDataToSave()) {
items.add(R.string.save_current_track); items.add(R.string.save_current_track);
}
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++) {
strings[i] = app.getString(items.get(i)); strings[i] = app.getString(items.get(i));
} }
bld.setItems(strings, new OnClickListener() { final int[] holder = new int[] {0};
@Override final Runnable run = new Runnable() {
public void onClick(DialogInterface dialog, int which) { public void run() {
int which = holder[0];
int item = items.get(which); int item = items.get(which);
if(item == R.string.save_current_track){ if(item == R.string.save_current_track){
app.getTaskManager().runInBackground(new OsmAndTaskRunnable<Void, Void, Void>() { app.getTaskManager().runInBackground(new OsmAndTaskRunnable<Void, Void, Void>() {
@Override @Override
protected Void doInBackground(Void... params) { protected Void doInBackground(Void... params) {
isSaving = true;
try {
SavingTrackHelper helper = app.getSavingTrackHelper(); SavingTrackHelper helper = app.getSavingTrackHelper();
helper.saveDataToGpx(app.getAppCustomization().getTracksDir()); helper.saveDataToGpx(app.getAppCustomization().getTracksDir());
helper.close(); helper.close();
} finally {
isSaving = false;
}
return null; return null;
} }
}, (Void) null); }, (Void) null);
} else if(item == R.string.gpx_monitoring_start) { } else if(item == R.string.gpx_monitoring_start) {
startGPXMonitoring(); startGPXMonitoring(map);
} else if(item == R.string.gpx_monitoring_stop) { } else if(item == R.string.gpx_monitoring_stop) {
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(false); settings.SAVE_GLOBAL_TRACK_TO_GPX.set(false);
if (app.getNavigationService() != null) { if (app.getNavigationService() != null) {
@ -264,7 +282,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
vs.value = settings.LIVE_MONITORING_INTERVAL.get(); vs.value = settings.LIVE_MONITORING_INTERVAL.get();
showIntervalChooseDialog(map, app.getString(R.string.live_monitoring_interval) + " : %s", showIntervalChooseDialog(map, app.getString(R.string.live_monitoring_interval) + " : %s",
app.getString(R.string.save_track_to_gpx), SECONDS, MINUTES, app.getString(R.string.save_track_to_gpx), SECONDS, MINUTES,
vs, new OnClickListener() { null, vs, 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);
@ -274,32 +292,55 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
} }
monitoringControl.updateInfo(null); monitoringControl.updateInfo(null);
} }
};
private void startGPXMonitoring() { if(strings.length == 1) {
app.getSavingTrackHelper().startNewSegment(); run.run();
final ValueHolder<Integer> vs = new ValueHolder<Integer>(); } else {
vs.value = settings.SAVE_GLOBAL_TRACK_INTERVAL.get(); bld.setItems(strings, new OnClickListener() {
showIntervalChooseDialog(map, app.getString(R.string.save_track_interval) + " : %s",
app.getString(R.string.save_track_to_gpx), SECONDS, MINUTES,
vs, new OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
holder[0] = which;
run.run();
}
});
bld.show();
}
}
private void startGPXMonitoring(MapActivity map) {
app.getSavingTrackHelper().startNewSegment();
final ValueHolder<Integer> vs = new ValueHolder<Integer>();
final ValueHolder<Boolean> choice = new ValueHolder<Boolean>();
vs.value = settings.SAVE_GLOBAL_TRACK_INTERVAL.get();
choice.value = settings.SAVE_GLOBAL_TRACK_REMEMBER.get();
final Runnable runnable = new Runnable() {
public void run() {
settings.SAVE_GLOBAL_TRACK_INTERVAL.set(vs.value); settings.SAVE_GLOBAL_TRACK_INTERVAL.set(vs.value);
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(true); settings.SAVE_GLOBAL_TRACK_TO_GPX.set(true);
settings.SAVE_GLOBAL_TRACK_REMEMBER.set(choice.value);
if (app.getNavigationService() == null) { if (app.getNavigationService() == null) {
settings.SERVICE_OFF_INTERVAL.set(0); settings.SERVICE_OFF_INTERVAL.set(0);
} }
app.startNavigationService(NavigationService.USED_BY_GPX); app.startNavigationService(NavigationService.USED_BY_GPX);
} }
}); };
if(choice.value) {
runnable.run();
} else {
showIntervalChooseDialog(map, app.getString(R.string.save_track_interval) + " : %s",
app.getString(R.string.save_track_to_gpx), SECONDS, MINUTES, choice, vs,
new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
runnable.run();
} }
}); });
bld.show(); }
} }
public static void showIntervalChooseDialog(final Context uiCtx, final String patternMsg, public static void showIntervalChooseDialog(final Context uiCtx, final String patternMsg,
String title, final int[] seconds, final int[] minutes, final ValueHolder<Integer> v, OnClickListener onclick){ String title, final int[] seconds, final int[] minutes, final ValueHolder<Boolean> choice, final ValueHolder<Integer> v, OnClickListener onclick){
Builder dlg = new AlertDialog.Builder(uiCtx); Builder dlg = new AlertDialog.Builder(uiCtx);
dlg.setTitle(title); dlg.setTitle(title);
LinearLayout ll = new LinearLayout(uiCtx); LinearLayout ll = new LinearLayout(uiCtx);
@ -356,6 +397,23 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
ll.setOrientation(LinearLayout.VERTICAL); ll.setOrientation(LinearLayout.VERTICAL);
ll.addView(tv); ll.addView(tv);
ll.addView(sp); ll.addView(sp);
if (choice != null) {
final CheckBox cb = new CheckBox(uiCtx);
cb.setText(R.string.remember_choice);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT);
lp.setMargins(7, 10, 7, 0);
cb.setLayoutParams(lp);
cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
choice.value = isChecked;
}
});
ll.addView(cb);
}
dlg.setView(ll); dlg.setView(ll);
dlg.setPositiveButton(R.string.default_buttons_ok, onclick); dlg.setPositiveButton(R.string.default_buttons_ok, onclick);
dlg.setNegativeButton(R.string.default_buttons_cancel, null); dlg.setNegativeButton(R.string.default_buttons_cancel, null);
@ -375,10 +433,11 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) { public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
if (view.getApplication().getNavigationService() == null) { if (view.getApplication().getNavigationService() == null) {
final ValueHolder<Integer> vs = new ValueHolder<Integer>(); final ValueHolder<Integer> vs = new ValueHolder<Integer>();
final ValueHolder<Boolean> choice = new ValueHolder<Boolean>();
vs.value = view.getSettings().SERVICE_OFF_INTERVAL.get(); vs.value = view.getSettings().SERVICE_OFF_INTERVAL.get();
showIntervalChooseDialog(view.getContext(), app.getString(R.string.gps_wakeup_interval), showIntervalChooseDialog(view.getContext(), app.getString(R.string.gps_wakeup_interval),
app.getString(R.string.background_router_service), app.getString(R.string.background_router_service),
SettingsMonitoringActivity.BG_SECONDS, SettingsMonitoringActivity.BG_MINUTES, vs, SettingsMonitoringActivity.BG_SECONDS, SettingsMonitoringActivity.BG_MINUTES, choice, vs,
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {

View file

@ -297,7 +297,9 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
public void markStageAsNotCompleted(StageInformation si) { public void markStageAsNotCompleted(StageInformation si) {
Integer gi = visitedStagesPref.get(); Integer gi = visitedStagesPref.get();
if((gi & (1 << si.getOrder())) > 0) {
gi = gi - (1 << si.getOrder()); gi = gi - (1 << si.getOrder());
}
visitedStagesPref.set(gi); visitedStagesPref.set(gi);
} }
@ -672,4 +674,11 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
a.startActivityForResult(newIntent, 0); a.startActivityForResult(newIntent, 0);
} }
public int getWaypointSearchRadius(int searchDeviationRadius, int type) {
if(type == WaypointHelper.WAYPOINTS) {
return searchDeviationRadius;
}
return searchDeviationRadius;
}
} }

View file

@ -119,7 +119,7 @@ public class MapInfoWidgetsFactory {
app.getString(R.string.enable_sleep_mode), app.getString(R.string.enable_sleep_mode),
OsmandMonitoringPlugin.SECONDS, OsmandMonitoringPlugin.SECONDS,
OsmandMonitoringPlugin.MINUTES, OsmandMonitoringPlugin.MINUTES,
vs, new DialogInterface.OnClickListener() { null, vs, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
app.getSettings().SERVICE_OFF_INTERVAL.set(vs.value); app.getSettings().SERVICE_OFF_INTERVAL.set(vs.value);

View file

@ -53,6 +53,9 @@ public class TextInfoWidget extends BaseMapWidget {
} else { } else {
setContentDescription(subtext); setContentDescription(subtext);
} }
if(this.text != null && this.text.length() > 7) {
this.text = this.text.substring(0, 6) +"..";
}
updateVisibility(text != null); updateVisibility(text != null);
requestLayout(); requestLayout();
invalidate(); invalidate();