From 7badd3dfd7ecd1a8a1267591fe8fdc24046cb6a0 Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 15 Jul 2014 15:34:11 +0400 Subject: [PATCH 1/5] Moved sleep mode to GPS info plugin --- OsmAnd/res/values/strings.xml | 7 ++- .../SettingsMonitoringActivity.java | 6 +-- .../mapwidgets/MapInfoWidgetsFactory.java | 48 +++++++++++++++++-- 3 files changed, 52 insertions(+), 9 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 2eb0676d05..36b811ee21 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -471,11 +471,11 @@ \n\t* Additional settings for stabilizing compass \n\t* Top left button on the map screen replaces Menu button - Logging services & Sleep mode + Logging services Configure how to record trips and enable sleep mode 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. - Logging services & Sleep Mode + Logging services Show settings to enable tracking and navigation in sleep (screen off) mode via periodically waking up the GPS device. Install version Choose application theme @@ -1919,4 +1919,7 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A Play sound on photo shot Choose whether to play a sound when shooting photos Invalid format: %s + Do you want to stop service? + Keep + Stop diff --git a/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java b/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java index 6b1962949a..ee457a6314 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java @@ -46,9 +46,9 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity { createLoggingSection(grp); createLiveSection(grp); - if(REGISTER_BG_SETTINGS) { - registerBackgroundSettings(); - } +// if(REGISTER_BG_SETTINGS) { +// registerBackgroundSettings(); +// } profileDialog(); } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index 0e748d570c..f82a7843c2 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -1,16 +1,18 @@ package net.osmand.plus.views.mapwidgets; +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.content.Intent; import net.osmand.Location; import net.osmand.access.AccessibleToast; import net.osmand.binary.RouteDataObject; -import net.osmand.plus.OsmAndFormatter; -import net.osmand.plus.OsmAndLocationProvider; +import net.osmand.plus.*; import net.osmand.plus.OsmAndLocationProvider.GPSInfo; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.routing.RouteDirectionInfo; import net.osmand.plus.routing.RoutingHelper; +import net.osmand.plus.views.MonitoringInfoControl; import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.ShadowText; @@ -94,6 +96,44 @@ public class MapInfoWidgetsFactory { }; gpsInfoControl.setImageDrawable(app.getResources().getDrawable(R.drawable.widget_gps_info)); gpsInfoControl.setText(null, null); + gpsInfoControl.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (app.getNavigationService() != null){ + AlertDialog.Builder dlg = new AlertDialog.Builder(map); + dlg.setTitle(app.getString(R.string.navigation_stop_dialog)); + 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 MonitoringInfoControl.ValueHolder vs = new MonitoringInfoControl.ValueHolder(); + vs.value = app.getSettings().SAVE_GLOBAL_TRACK_INTERVAL.get(); + OsmandMonitoringPlugin.showIntervalChooseDialog(map, app.getString(R.string.save_track_interval) + " : %s", + app.getString(R.string.save_track_to_gpx), + OsmandMonitoringPlugin.SECONDS, + OsmandMonitoringPlugin.MINUTES, + vs, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + app.getSettings().SAVE_GLOBAL_TRACK_INTERVAL.set(vs.value); + app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.set(true); + if (app.getNavigationService() == null) { + app.getSettings().SERVICE_OFF_INTERVAL.set(0); + } + app.startNavigationService(NavigationService.USED_BY_GPX); + } + }); + } + + } + }); return gpsInfoControl; } From a34fc80999181f9dd7ee36783ad1cf1e35cd9fde Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 15 Jul 2014 16:00:11 +0400 Subject: [PATCH 2/5] Updated new sleep mode functionality --- OsmAnd/res/values/strings.xml | 4 +++- .../views/mapwidgets/MapInfoWidgetsFactory.java | 14 +++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 36b811ee21..40061edb64 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -1919,7 +1919,9 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A Play sound on photo shot Choose whether to play a sound when shooting photos Invalid format: %s - Do you want to stop service? + Do you want to stop sleep mode service? Keep Stop + Enable sleep mode + Service off interval diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index f82a7843c2..140d2557eb 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -101,7 +101,7 @@ public class MapInfoWidgetsFactory { public void onClick(View view) { if (app.getNavigationService() != null){ AlertDialog.Builder dlg = new AlertDialog.Builder(map); - dlg.setTitle(app.getString(R.string.navigation_stop_dialog)); + dlg.setTitle(app.getString(R.string.sleep_mode_stop_dialog)); dlg.setPositiveButton(app.getString(R.string.keep_navigation_service), null); dlg.setNegativeButton(app.getString(R.string.stop_navigation_service), new DialogInterface.OnClickListener() { @Override @@ -114,19 +114,15 @@ public class MapInfoWidgetsFactory { } else { final MonitoringInfoControl.ValueHolder vs = new MonitoringInfoControl.ValueHolder(); - vs.value = app.getSettings().SAVE_GLOBAL_TRACK_INTERVAL.get(); - OsmandMonitoringPlugin.showIntervalChooseDialog(map, app.getString(R.string.save_track_interval) + " : %s", - app.getString(R.string.save_track_to_gpx), + vs.value = app.getSettings().SERVICE_OFF_INTERVAL.get(); + OsmandMonitoringPlugin.showIntervalChooseDialog(map, app.getString(R.string.gps_wake_up_timer) + " : %s", + app.getString(R.string.enable_sleep_mode), OsmandMonitoringPlugin.SECONDS, OsmandMonitoringPlugin.MINUTES, vs, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - app.getSettings().SAVE_GLOBAL_TRACK_INTERVAL.set(vs.value); - app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.set(true); - if (app.getNavigationService() == null) { - app.getSettings().SERVICE_OFF_INTERVAL.set(0); - } + app.getSettings().SERVICE_OFF_INTERVAL.set(vs.value); app.startNavigationService(NavigationService.USED_BY_GPX); } }); From 960816bcbbfe8b048806960ffd392731fd8a4813 Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 15 Jul 2014 17:39:51 +0400 Subject: [PATCH 3/5] moved string to start of file --- OsmAnd/res/values/strings.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 40061edb64..daf896126f 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,10 @@ 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 --> + Keep + Stop + Enable sleep mode + Service off interval Preferred lanaguage for labels on the map (if it is not available will switch to English or to local names) Map prefferred language Local names @@ -1920,8 +1924,4 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A Choose whether to play a sound when shooting photos Invalid format: %s Do you want to stop sleep mode service? - Keep - Stop - Enable sleep mode - Service off interval From 71aabff6b8579c6fd916a62a4896ba2b4707bd38 Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 15 Jul 2014 17:42:36 +0400 Subject: [PATCH 4/5] Setted boolean value of constant to false --- .../plus/monitoring/SettingsMonitoringActivity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java b/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java index ee457a6314..e019245a45 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java @@ -28,7 +28,7 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity { public static final int[] BG_SECONDS = new int[]{0, 30, 60, 90}; public static final int[] BG_MINUTES = new int[]{2, 3, 5, 10, 15, 30, 60, 90}; - private final static boolean REGISTER_BG_SETTINGS = true; + private final static boolean REGISTER_BG_SETTINGS = false; private static final int[] SECONDS = OsmandMonitoringPlugin.SECONDS; private static final int[] MINUTES = OsmandMonitoringPlugin.MINUTES; @@ -46,9 +46,9 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity { createLoggingSection(grp); createLiveSection(grp); -// if(REGISTER_BG_SETTINGS) { -// registerBackgroundSettings(); -// } + if(REGISTER_BG_SETTINGS) { + registerBackgroundSettings(); + } profileDialog(); } From b0aa769dfb674b230ccd7803107f8674a6092323 Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 15 Jul 2014 17:53:16 +0400 Subject: [PATCH 5/5] updated strings --- OsmAnd/res/values/strings.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index daf896126f..52961783f9 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -12,8 +12,9 @@ Keep Stop Enable sleep mode - Service off interval - Preferred lanaguage for labels on the map (if it is not available will switch to English or to local names) + GPS wake up interval + Keep GPS on? + Preferred lanaguage for labels on the map (if it is not available will switch to English or to local names) Map prefferred language Local names Swahili @@ -1923,5 +1924,4 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A Play sound on photo shot Choose whether to play a sound when shooting photos Invalid format: %s - Do you want to stop sleep mode service?