This commit is contained in:
max-klaus 2019-11-03 17:56:57 +03:00
parent 0decd1d6e8
commit 5c335cf87d
8 changed files with 81 additions and 123 deletions

View file

@ -4,75 +4,60 @@
android:layout_height="fill_parent"
android:orientation="vertical">
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/radio_route"
android:text="@string/animate_routing_route"
android:checked="true"
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1" />
<RadioButton
android:id="@+id/radio_gpx"
android:text="@string/animate_routing_gpx"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1" />
</RadioGroup>
android:layout_marginLeft="24dp"
android:layout_marginTop="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="8dp"
android:text="@string/animate_routing_gpx" />
<LinearLayout
android:layout_width="fill_parent"
android:id="@+id/layout_animate_gpx"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:visibility="gone">
android:orientation="vertical">
<TextView
android:text="@string/select_animate_speedup"
android:gravity="left"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp" />
android:layout_marginLeft="24dp"
android:layout_marginTop="5dp"
android:layout_marginRight="16dp"
android:gravity="left"
android:text="@string/select_animate_speedup" />
<SeekBar
android:id="@+id/Speedup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp" />
android:layout_marginLeft="24dp"
android:layout_marginTop="5dp"
android:layout_marginRight="16dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp">
android:layout_marginLeft="24dp"
android:layout_marginTop="5dp"
android:layout_marginRight="16dp">
<TextView
android:text="10"
android:gravity="left"
android:layout_weight="0.5"
android:id="@+id/MinSpeedup"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="left"
android:text="10" />
<TextView
android:text="15"
android:gravity="right"
android:layout_weight="0.5"
android:id="@+id/MaxSpeedup"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="right"
android:text="15" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

View file

@ -52,23 +52,13 @@ public class OsmAndLocationSimulation {
// }
public void startStopRouteAnimation(final Activity ma, final Runnable runnable) {
public void startStopRouteAnimation(final Activity ma, boolean useGpx, final Runnable runnable) {
if (!isRouteAnimating()) {
if (app.getSettings().SIMULATE_NAVIGATION_GPX.get()) {
if (useGpx) {
AlertDialog.Builder builder = new AlertDialog.Builder(ma);
builder.setTitle(R.string.animate_route);
final View view = ma.getLayoutInflater().inflate(R.layout.animate_route, null);
final View gpxView = ((LinearLayout) view.findViewById(R.id.layout_animate_gpx));
final RadioButton radioGPX = (RadioButton) view.findViewById(R.id.radio_gpx);
radioGPX.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
gpxView.setVisibility(isChecked ? View.VISIBLE : View.GONE);
}
});
((TextView) view.findViewById(R.id.MinSpeedup)).setText("1"); //$NON-NLS-1$
((TextView) view.findViewById(R.id.MaxSpeedup)).setText("4"); //$NON-NLS-1$
final SeekBar speedup = (SeekBar) view.findViewById(R.id.Speedup);
@ -78,8 +68,6 @@ public class OsmAndLocationSimulation {
@Override
public void onClick(DialogInterface dialog, int which) {
boolean gpxNavigation = radioGPX.isChecked();
if (gpxNavigation) {
boolean nightMode = ma instanceof MapActivity ? app.getDaynightHelper().isNightModeForMapControls() : !app.getSettings().isLightContent();
GpxUiHelper.selectGPXFile(ma, false, false, new CallbackWithObject<GPXUtilities.GPXFile[]>() {
@Override
@ -92,19 +80,6 @@ public class OsmAndLocationSimulation {
return true;
}
}, nightMode);
} else {
List<Location> currentRoute = app.getRoutingHelper().getCurrentCalculatedRoute();
if (currentRoute.isEmpty()) {
Toast.makeText(app, R.string.animate_routing_route_not_calculated,
Toast.LENGTH_LONG).show();
} else {
startAnimationThread(app, new ArrayList<Location>(currentRoute), false, 1);
if (runnable != null) {
runnable.run();
}
}
}
}
});
builder.setNegativeButton(R.string.shared_string_cancel, null);
@ -123,11 +98,18 @@ public class OsmAndLocationSimulation {
}
} else {
stop();
if (runnable != null) {
runnable.run();
}
}
}
public void startStopRouteAnimation(final Activity ma) {
startStopRouteAnimation(ma, null);
startStopRouteAnimation(ma, false, null);
}
public void startStopGpxAnimation(final Activity ma) {
startStopRouteAnimation(ma, true, null);
}
private void startAnimationThread(final OsmandApplication app, final List<Location> directions, final boolean useLocationTime, final float coeff) {

View file

@ -1577,8 +1577,8 @@ public class OsmandSettings {
// dev version
public final CommonPreference<Boolean> DISABLE_COMPLEX_ROUTING = new BooleanPreference("disable_complex_routing", false).makeGlobal();
public final CommonPreference<Boolean> ENABLE_TIME_CONDITIONAL_ROUTING = new BooleanPreference("enable_time_conditional_routing", true).makeProfile();
public final CommonPreference<Boolean> SIMULATE_NAVIGATION = new BooleanPreference("simulate_navigation", false).makeGlobal().cache();
public final CommonPreference<Boolean> SIMULATE_NAVIGATION_GPX = new BooleanPreference("simulate_navigation_gpx", false).makeGlobal().cache();
public boolean simulateNavigation = false;
public final CommonPreference<Boolean> SHOW_ROUTING_ALARMS = new BooleanPreference("show_routing_alarms", true).makeProfile().cache();

View file

@ -2124,7 +2124,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
mapView.fitRectToMap(left, right, top, bottom, tileBoxWidthPx, tileBoxHeightPx, 0);
}
}
if (app.getSettings().SIMULATE_NAVIGATION.get()) {
if (app.getSettings().simulateNavigation) {
OsmAndLocationSimulation sim = app.getLocationProvider().getLocationSimulation();
if (newRoute && rh.isFollowingMode() && !sim.isRouteAnimating()) {
sim.startStopRouteAnimation(this);

View file

@ -61,7 +61,7 @@ public class DashSimulateFragment extends DashBaseFragment {
@Override
public void onClick(View v) {
loc.getLocationSimulation().startStopRouteAnimation(getActivity());
loc.getLocationSimulation().startStopGpxAnimation(getActivity());
dashboard.hideDashboard();
}
};

View file

@ -64,11 +64,6 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
R.string.use_osm_live_public_transport,
R.string.use_osm_live_public_transport_description));
navigation.addPreference(createCheckBoxPreference(settings.SIMULATE_NAVIGATION_GPX,
R.string.simulate_your_location,
R.string.simulate_your_location_gpx_descr));
/*
pref = new Preference(this);
final Preference simulate = pref;
final OsmAndLocationSimulation sim = getMyApplication().getLocationProvider().getLocationSimulation();
@ -77,7 +72,7 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
@Override
public void run() {
simulate.setSummary(sim.isRouteAnimating() ?
R.string.simulate_your_location_stop_descr : R.string.simulate_your_location_descr);
R.string.simulate_your_location_stop_descr : R.string.simulate_your_location_gpx_descr);
}
};
pref.setTitle(R.string.simulate_your_location);
@ -87,12 +82,11 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
@Override
public boolean onPreferenceClick(Preference preference) {
updateTitle.run();
sim.startStopRouteAnimation(SettingsDevelopmentActivity.this, updateTitle);
sim.startStopRouteAnimation(SettingsDevelopmentActivity.this, true, updateTitle);
return true;
}
});
navigation.addPreference(pref);
*/
PreferenceCategory debug = new PreferenceCategory(this);
debug.setTitle(R.string.debugging_and_development);

View file

@ -15,10 +15,8 @@ import net.osmand.AndroidUtils;
import net.osmand.CallbackWithObject;
import net.osmand.GPXUtilities;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmAndLocationSimulation;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -30,7 +28,6 @@ import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerStartItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.plus.development.OsmandDevelopmentPlugin;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter;
@ -207,7 +204,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
private BaseBottomSheetItem createRouteSimulationItem(final LocalRoutingParameter optionsItem) {
final BottomSheetItemWithCompoundButton[] simulateNavigationItem = new BottomSheetItemWithCompoundButton[1];
simulateNavigationItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setChecked(settings.SIMULATE_NAVIGATION.get())
.setChecked(settings.simulateNavigation)
.setIcon(getContentIcon(R.drawable.ic_action_start_navigation))
.setTitle(getString(R.string.simulate_navigation))
// .setDescription(app.getLocationProvider().getLocationSimulation().isRouteAnimating()
@ -216,8 +213,8 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean enabled = !settings.SIMULATE_NAVIGATION.get();
settings.SIMULATE_NAVIGATION.set(enabled);
boolean enabled = !settings.simulateNavigation;
settings.simulateNavigation = enabled;
simulateNavigationItem[0].setChecked(enabled);
OsmAndLocationSimulation sim = app.getLocationProvider().getLocationSimulation();
if (sim.isRouteAnimating()) {

View file

@ -723,7 +723,7 @@ public class MapControlsLayer extends OsmandMapLayer {
routingHelper.setRoutePlanningMode(false);
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
app.getRoutingHelper().notifyIfRouteIsCalculated();
if (!app.getSettings().SIMULATE_NAVIGATION.get()) {
if (!app.getSettings().simulateNavigation) {
routingHelper.setCurrentLocation(app.getLocationProvider().getLastKnownLocation(), false);
} else if (routingHelper.isRouteCalculated() && !routingHelper.isRouteBeingCalculated()) {
OsmAndLocationSimulation sim = app.getLocationProvider().getLocationSimulation();