Merge branch 'r3.4'

This commit is contained in:
Victor Shcherb 2019-07-09 17:20:19 +02:00
commit 266d65e87c
6 changed files with 60 additions and 17 deletions

View file

@ -39,13 +39,13 @@ public class OnVoiceNavigationParams implements Parcelable {
@Override @Override
public void writeToParcel(Parcel out, int flags) { public void writeToParcel(Parcel out, int flags) {
out.writeList(cmds); out.writeStringList(cmds);
out.writeList(played); out.writeStringList(played);
} }
private void readFromParcel(Parcel in) { private void readFromParcel(Parcel in) {
in.readList(cmds, getClass().getClassLoader()); in.readStringList(cmds);
in.readList(played, getClass().getClassLoader()); in.readStringList(played);
} }
@Override @Override

View file

@ -123,12 +123,14 @@ public class TransportStopController extends MenuController {
private void processTransportStop(List<TransportStopRoute> routesOnTheSameExit, List<TransportStopRoute> routesNearby) { private void processTransportStop(List<TransportStopRoute> routesOnTheSameExit, List<TransportStopRoute> routesNearby) {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) { if (mapActivity != null) {
List<TransportIndexRepository> reps = mapActivity.getMyApplication() OsmandApplication app = mapActivity.getMyApplication();
.getResourceManager().searchTransportRepositories(transportStop.getLocation().getLatitude(), List<TransportIndexRepository> reps = app.getResourceManager().searchTransportRepositories(transportStop.getLocation().getLatitude(),
transportStop.getLocation().getLongitude()); transportStop.getLocation().getLongitude());
boolean useEnglishNames = mapActivity.getMyApplication().getSettings().usingEnglishNames(); boolean useEnglishNames = app.getSettings().usingEnglishNames();
if (transportStop.getTransportStopAggregated() == null) {
processTransportStopAggregated(app, transportStop);
}
for (TransportIndexRepository t : reps) { for (TransportIndexRepository t : reps) {
if (t.acceptTransportStop(transportStop)) { if (t.acceptTransportStop(transportStop)) {
ArrayList<TransportStop> transportStopsSameExit = new ArrayList<TransportStop>(transportStop.getLocalTransportStops()); ArrayList<TransportStop> transportStopsSameExit = new ArrayList<TransportStop>(transportStop.getLocalTransportStops());
@ -273,6 +275,19 @@ public class TransportStopController extends MenuController {
return null; return null;
} }
public static void processTransportStopAggregated(OsmandApplication app, TransportStop transportStop) {
TransportStopAggregated stopAggregated = new TransportStopAggregated();
transportStop.setTransportStopAggregated(stopAggregated);
stopAggregated.addLocalTransportStop(transportStop);
LatLon loc = transportStop.getLocation();
List<TransportStop> transportStops = findTransportStopsAt(app, loc.getLatitude(), loc.getLongitude(), SHOW_STOPS_RADIUS_METERS);
for (TransportStop stop : transportStops) {
stopAggregated.addNearbyTransportStop(stop);
}
}
public static TransportStopAggregated processTransportStopsForAmenity(List<TransportStop> transportStops, Amenity amenity) { public static TransportStopAggregated processTransportStopsForAmenity(List<TransportStop> transportStops, Amenity amenity) {
TransportStopAggregated stopAggregated = new TransportStopAggregated(); TransportStopAggregated stopAggregated = new TransportStopAggregated();
stopAggregated.setAmenity(amenity); stopAggregated.setAmenity(amenity);

View file

@ -1,7 +1,5 @@
package net.osmand.plus.osmedit; package net.osmand.plus.osmedit;
import static net.osmand.plus.osmedit.EditPoiDialogFragment.AMENITY_TEXT_LENGTH;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
@ -10,8 +8,6 @@ import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.text.Editable; import android.text.Editable;
import android.text.InputFilter; import android.text.InputFilter;
import android.text.InputFilter.LengthFilter;
import android.text.Spanned;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.TypedValue; import android.util.TypedValue;
@ -41,6 +37,8 @@ import java.util.Map;
import gnu.trove.list.array.TIntArrayList; import gnu.trove.list.array.TIntArrayList;
import static net.osmand.plus.osmedit.EditPoiDialogFragment.AMENITY_TEXT_LENGTH;
public class BasicEditPoiFragment extends BaseOsmAndFragment public class BasicEditPoiFragment extends BaseOsmAndFragment
implements EditPoiDialogFragment.OnFragmentActivatedListener { implements EditPoiDialogFragment.OnFragmentActivatedListener {
private static final Log LOG = PlatformUtil.getLog(BasicEditPoiFragment.class); private static final Log LOG = PlatformUtil.getLog(BasicEditPoiFragment.class);
@ -167,6 +165,19 @@ public class BasicEditPoiFragment extends BaseOsmAndFragment
mOpeningHoursAdapter.setOpeningHoursRule(item, position); mOpeningHoursAdapter.setOpeningHoursRule(item, position);
} }
public void removeUnsavedOpeningHours() {
EditPoiData data = getData();
if (data != null) {
OpeningHoursParser.OpeningHours openingHours = OpeningHoursParser.parseOpenedHoursHandleErrors(data.getTagValues()
.get(OSMSettings.OSMTagKey.OPENING_HOURS.getValue()));
if (openingHours == null) {
openingHours = new OpeningHoursParser.OpeningHours();
}
mOpeningHoursAdapter.replaceOpeningHours(openingHours);
mOpeningHoursAdapter.updateViews();
}
}
private EditPoiData getData() { private EditPoiData getData() {
Fragment parent = getParentFragment(); Fragment parent = getParentFragment();
if (parent != null && parent instanceof EditPoiDialogFragment) { if (parent != null && parent instanceof EditPoiDialogFragment) {

View file

@ -83,7 +83,15 @@ public class OpeningHoursHoursDialogFragment extends DialogFragment {
} }
} }
}) })
.setNegativeButton(R.string.shared_string_cancel, null); .setNegativeButton(R.string.shared_string_cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
BasicEditPoiFragment editPoiFragment = ((BasicEditPoiFragment) getParentFragment());
if (editPoiFragment != null) {
editPoiFragment.removeUnsavedOpeningHours();
}
}
});
int paddingInDp = 18; int paddingInDp = 18;
float density = getActivity().getResources().getDisplayMetrics().density; float density = getActivity().getResources().getDisplayMetrics().density;

View file

@ -54,7 +54,7 @@ public class CommandBuilder {
protected final CommandPlayer commandPlayer; protected final CommandPlayer commandPlayer;
protected boolean alreadyExecuted = false; protected boolean alreadyExecuted = false;
private List<Struct> listStruct = new ArrayList<Struct>(); private List<Struct> listStruct = new ArrayList<Struct>();
private List<String> listCommands = new ArrayList<String>(); protected List<String> listCommands = new ArrayList<String>();
public CommandBuilder(CommandPlayer commandPlayer){ public CommandBuilder(CommandPlayer commandPlayer){
this.commandPlayer = commandPlayer; this.commandPlayer = commandPlayer;
@ -71,7 +71,7 @@ public class CommandBuilder {
listStruct.add(struct); listStruct.add(struct);
listCommands.add(name); listCommands.add(name);
for(Object o : args) { for(Object o : args) {
if(o == null) { if(o != null) {
listCommands.add(o.toString()); listCommands.add(o.toString());
} else { } else {
listCommands.add(""); listCommands.add("");

View file

@ -13,6 +13,7 @@ import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject; import org.mozilla.javascript.ScriptableObject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class JSCommandBuilder extends CommandBuilder { public class JSCommandBuilder extends CommandBuilder {
@ -54,6 +55,14 @@ public class JSCommandBuilder extends CommandBuilder {
} }
private JSCommandBuilder addCommand(String name, Object... args){ private JSCommandBuilder addCommand(String name, Object... args){
listCommands.add(name);
for(Object o : args) {
if(o != null) {
listCommands.add(o.toString());
} else {
listCommands.add("");
}
}
Object obj = jsScope.get(name); Object obj = jsScope.get(name);
if (obj instanceof Function) { if (obj instanceof Function) {
Function jsFunction = (Function) obj; Function jsFunction = (Function) obj;