Merge pull request #752 from Bars107/master

Moved sleep mode to GPS info plugin
This commit is contained in:
vshcherb 2014-07-15 16:55:43 +02:00
commit b3985d14ed
3 changed files with 49 additions and 8 deletions

View file

@ -9,7 +9,12 @@
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
-->
<string name="map_preferred_locale_descr">Preferred lanaguage for labels on the map (if it is not available will switch to English or to local names)</string>
<string name="keep_navigation_service">Keep</string>
<string name="stop_navigation_service">Stop</string>
<string name="enable_sleep_mode">Enable sleep mode</string>
<string name="gps_wake_up_timer">GPS wake up interval</string>
<string name="sleep_mode_stop_dialog">Keep GPS on?</string>
<string name="map_preferred_locale_descr">Preferred lanaguage for labels on the map (if it is not available will switch to English or to local names)</string>
<string name="map_preferred_locale">Map prefferred language</string>
<string name="local_map_names">Local names</string>
<string name="lang_sw">Swahili</string>
@ -471,11 +476,11 @@
\n\t* Additional settings for stabilizing compass
\n\t* Top left button on the map screen replaces Menu button
</string>
<string name="monitoring_settings">Logging services &amp; Sleep mode</string>
<string name="monitoring_settings">Logging services</string>
<string name="monitoring_settings_descr">Configure how to record trips and enable sleep mode</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 &amp; Sleep Mode</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="contribution_activity">Install version</string>
<string name="choose_osmand_theme_descr">Choose application theme</string>

View file

@ -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;

View file

@ -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,40 @@ 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.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
public void onClick(DialogInterface dialogInterface, int i) {
Intent serviceIntent = new Intent(app, NavigationService.class);
app.stopService(serviceIntent);
}
});
dlg.show();
} else {
final MonitoringInfoControl.ValueHolder<Integer> vs = new MonitoringInfoControl.ValueHolder<Integer>();
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().SERVICE_OFF_INTERVAL.set(vs.value);
app.startNavigationService(NavigationService.USED_BY_GPX);
}
});
}
}
});
return gpsInfoControl;
}