Add settings for maximum interval to send

This commit is contained in:
PavelRatushny 2017-07-20 17:16:34 +03:00
parent 67c8fbb549
commit 7fad69288b
5 changed files with 12 additions and 1 deletions

View file

@ -1936,6 +1936,8 @@
<string name="live_monitoring_interval">Online tracking interval</string>
<string name="live_monitoring_url_descr">Specify the web address with parameter syntax: lat={0}, lon={1}, timestamp={2}, hdop={3}, altitude={4}, speed={5}, bearing={6}</string>
<string name="live_monitoring_url">Online tracking web address</string>
<string name="live_monitoring_max_interval_to_send">Maximum online tracking interval to send</string>
<string name="live_monitoring_max_interval_to_send_desrc">Specify maximum online tracking interval to send</string>
<string name="gpx_monitoring_disabled_warn">Log track using GPX widget or via \'Trip recording\' settings.</string>
<string name="show_current_gpx_title">Show current track</string>
<string name="free_version_message">This free OsmAnd version is limited to %1$s downloads and does not support offline Wikipedia articles.</string>

View file

@ -1121,6 +1121,9 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<Integer> LIVE_MONITORING_INTERVAL = new IntPreference("live_monitoring_interval", 5000).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<Integer> LIVE_MONITORING_MAX_INTERVAL_TO_SEND = new IntPreference("live_monitoring_maximum_interval_to_send", 300000).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<String> LIVE_MONITORING_URL = new StringPreference("live_monitoring_url",
"http://example.com?lat={0}&lon={1}&timestamp={2}&hdop={3}&altitude={4}&speed={5}").makeGlobal();

View file

@ -119,10 +119,12 @@ public class LiveMonitoringHelper {
for (ConcurrentLinkedQueue queue : concurrentLinkedQueues) {
if (!queue.isEmpty()) {
LiveMonitoringData data = (LiveMonitoringData) queue.poll();
if (!(System.currentTimeMillis() - data.time > settings.LIVE_MONITORING_MAX_INTERVAL_TO_SEND.get())) {
sendData(data);
}
}
}
}
return null;
}
}

View file

@ -131,6 +131,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
public static final int[] SECONDS = new int[] {0, 1, 2, 3, 5, 10, 15, 30, 60, 90};
public static final int[] MINUTES = new int[] {2, 3, 5};
public static final int[] MAX_INTERVAL_TO_SEND_MINUTES = new int[] {5, 10, 15};
@Override

View file

@ -25,6 +25,7 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity {
public static final int[] BG_MINUTES = new int[]{2, 3, 5, 10, 15, 30, 60, 90};
private static final int[] SECONDS = OsmandMonitoringPlugin.SECONDS;
private static final int[] MINUTES = OsmandMonitoringPlugin.MINUTES;
private static final int[] MAX_INTERVAL_TO_SEND_MINUTES = OsmandMonitoringPlugin.MAX_INTERVAL_TO_SEND_MINUTES;
public SettingsMonitoringActivity() {
super(true);
@ -136,6 +137,8 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity {
cat.addPreference(liveMonitoring);
cat.addPreference(createTimeListPreference(settings.LIVE_MONITORING_INTERVAL, SECONDS,
MINUTES, 1000, R.string.live_monitoring_interval, R.string.live_monitoring_interval_descr));
cat.addPreference(createTimeListPreference(settings.LIVE_MONITORING_MAX_INTERVAL_TO_SEND, null,
MAX_INTERVAL_TO_SEND_MINUTES, 1000, R.string.live_monitoring_max_interval_to_send, R.string.live_monitoring_max_interval_to_send_desrc));
}
private void createNotificationSection(PreferenceScreen grp) {