From d1fbe6b4b2f9e45e95b998ecb431ff569026fa0b Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 31 Oct 2016 10:22:57 +0200 Subject: [PATCH] Revert "GPS service now controlled fully automatically - no manual manipulation of back-stage parameters needed any more." This reverts commit 1c4ab5c7afad3f7b977fef9eb355e87be6297d36. --- .../activities/actions/StartGPSStatus.java | 1 - .../mapwidgets/MapInfoWidgetsFactory.java | 104 +++++++++--------- 2 files changed, 51 insertions(+), 54 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java b/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java index 7ff547b3ff..ff46877ed0 100644 --- a/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java +++ b/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java @@ -103,7 +103,6 @@ public class StartGPSStatus extends OsmAndAction { } OsmandMapTileView view = mapActivity.getMapView(); AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity); - builder.setTitle(R.string.gps_status); LinearLayout ll = new LinearLayout(activity); final ListView lv = new ListView(activity); lv.setPadding(7, 3, 7, 0); diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index c7431b88cf..c49e32e72d 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -108,65 +108,63 @@ public class MapInfoWidgetsFactory { gpsInfoControl.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { - // Issue #3185: GPS service now controlled fully automatically - no manual manipulation of back-stage parameters needed any more. - // TODO: Once we use the new notifications only, we can remove strings sleep_mode_stop_dialog, gps_wake_up_timer, keep_navigation_service, stop_navigation_service - //if (app.getNavigationService() != null) { - // AlertDialog.Builder dlg = new AlertDialog.Builder(map); - // dlg.setTitle(app.getString(R.string.sleep_mode_stop_dialog)); + if (app.getNavigationService() != null) { + AlertDialog.Builder dlg = new AlertDialog.Builder(map); + dlg.setTitle(app.getString(R.string.sleep_mode_stop_dialog)); //Show currently active wake-up interval - // int soi = app.getNavigationService().getServiceOffInterval(); - // if (soi == 0) { - // dlg.setMessage(app.getString(R.string.gps_wake_up_timer) + ": " + app.getString(R.string.int_continuosly)); - // } else if (soi <= 90000) { - // dlg.setMessage(app.getString(R.string.gps_wake_up_timer) + ": " + Integer.toString(soi / 1000) + " " + app.getString(R.string.int_seconds)); - // } else { - // dlg.setMessage(app.getString(R.string.gps_wake_up_timer) + ": " + Integer.toString(soi / 1000 / 60) + " " + app.getString(R.string.int_min)); - // } + int soi = app.getNavigationService().getServiceOffInterval(); + if (soi == 0) { + dlg.setMessage(app.getString(R.string.gps_wake_up_timer) + ": " + app.getString(R.string.int_continuosly)); + } else if (soi <= 90000) { + dlg.setMessage(app.getString(R.string.gps_wake_up_timer) + ": " + Integer.toString(soi / 1000) + " " + app.getString(R.string.int_seconds)); + } else { + dlg.setMessage(app.getString(R.string.gps_wake_up_timer) + ": " + Integer.toString(soi / 1000 / 60) + " " + app.getString(R.string.int_min)); + } - // dlg.setPositiveButton(app.getString(R.string.keep_navigation_service), null); - // dlg.setNegativeButton(app.getString(R.string.stop_navigation_service), new DialogInterface.OnClickListener() { - // @Override - // public void onClick(DialogInterface dialogInterface, int i) { - // Intent serviceIntent = new Intent(app, NavigationService.class); - // app.stopService(serviceIntent); - // } - // }); - // dlg.show(); + dlg.setPositiveButton(app.getString(R.string.keep_navigation_service), null); + dlg.setNegativeButton(app.getString(R.string.stop_navigation_service), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + Intent serviceIntent = new Intent(app, NavigationService.class); + app.stopService(serviceIntent); + } + }); + dlg.show(); - //} else { - // final ValueHolder vs = new ValueHolder(); - // vs.value = 0; - // final AlertDialog[] dlgshow = new AlertDialog[1]; - // AlertDialog.Builder dlg = new AlertDialog.Builder(map); - // dlg.setTitle(app.getString(R.string.enable_sleep_mode)); - // WindowManager mgr = (WindowManager) map.getSystemService(Context.WINDOW_SERVICE); - // DisplayMetrics dm = new DisplayMetrics(); - // mgr.getDefaultDisplay().getMetrics(dm); - // LinearLayout ll = OsmandMonitoringPlugin.createIntervalChooseLayout(map, - // app.getString(R.string.gps_wake_up_timer) + " : %s", - // OsmandMonitoringPlugin.SECONDS, - // OsmandMonitoringPlugin.MINUTES, - // null, vs, dm); - // if (Version.isGpsStatusEnabled(app)) { - // dlg.setNeutralButton(R.string.gps_status, new DialogInterface.OnClickListener() { - // @Override - // public void onClick(DialogInterface dialog, int which) { + } else { + final ValueHolder vs = new ValueHolder(); + vs.value = 0; + final AlertDialog[] dlgshow = new AlertDialog[1]; + AlertDialog.Builder dlg = new AlertDialog.Builder(map); + dlg.setTitle(app.getString(R.string.enable_sleep_mode)); + WindowManager mgr = (WindowManager) map.getSystemService(Context.WINDOW_SERVICE); + DisplayMetrics dm = new DisplayMetrics(); + mgr.getDefaultDisplay().getMetrics(dm); + LinearLayout ll = OsmandMonitoringPlugin.createIntervalChooseLayout(map, + app.getString(R.string.gps_wake_up_timer) + " : %s", + OsmandMonitoringPlugin.SECONDS, + OsmandMonitoringPlugin.MINUTES, + null, vs, dm); + if (Version.isGpsStatusEnabled(app)) { + dlg.setNeutralButton(R.string.gps_status, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { new StartGPSStatus(map).run(); - // } - // }); - // } - // dlg.setView(ll); - // dlg.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { - // @Override - // public void onClick(DialogInterface dialog, int which) { - // app.startNavigationService(NavigationService.USED_BY_WAKE_UP, vs.value); - // } - // }); - // dlg.setNegativeButton(R.string.shared_string_cancel, null); - // dlgshow[0] = dlg.show(); + } + }); + } + dlg.setView(ll); + dlg.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + app.startNavigationService(NavigationService.USED_BY_WAKE_UP, vs.value); + } + }); + dlg.setNegativeButton(R.string.shared_string_cancel, null); + dlgshow[0] = dlg.show(); - //} + } } });