Merge pull request #8358 from osmandapp/Fix_8303_general_logging_interval
Fix #8303 general logging interval
This commit is contained in:
commit
61663bab48
4 changed files with 53 additions and 28 deletions
|
@ -3418,7 +3418,7 @@ Zodpovedá oblasti: %1$s x %2$s</string>
|
|||
<string name="live_monitoring_descr">Umožňuje zdieľanie polohy a zaznamenávanie výletu.</string>
|
||||
<string name="live_monitoring">Sledovanie online</string>
|
||||
<string name="save_track_logging_accuracy">Presnosť záznamu</string>
|
||||
<string name="tracks_view_descr">Všetky vaše zaznamenané stopy sú v \'Menu\' → \'Moje miesta\' → \'Stopy\', alebo v priečinku OsmAnd.</string>
|
||||
<string name="tracks_view_descr">Všetky vaše zaznamenané stopy sú v %1$s, alebo v priečinku OsmAnd.</string>
|
||||
<string name="multimedia_notes_view_descr">Všetky vaše OSM poznámky sú v \'Menu\' → \'Moje miesta\' → \'Zmeny v OSM\'.</string>
|
||||
<string name="video_notes">Video-poznámky</string>
|
||||
<string name="photo_notes">Foto-poznámky</string>
|
||||
|
|
|
@ -33,6 +33,13 @@
|
|||
android:layout="@layout/preference_category_with_descr"
|
||||
android:title="@string/save_track_logging_accuracy" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.ListPreferenceEx
|
||||
android:key="save_global_track_interval"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:title="@string/save_global_track_interval"
|
||||
tools:icon="@drawable/ic_action_time_span"
|
||||
tools:summary="3 seconds" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.ListPreferenceEx
|
||||
android:key="save_track_min_distance"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
|
|
|
@ -26,6 +26,8 @@ import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
|||
import net.osmand.plus.widgets.style.CustomTypefaceSpan;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import static net.osmand.plus.OsmandSettings.DAILY_DIRECTORY;
|
||||
import static net.osmand.plus.OsmandSettings.MONTHLY_DIRECTORY;
|
||||
|
@ -38,12 +40,14 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements
|
|||
private static final String COPY_PLUGIN_SETTINGS = "copy_plugin_settings";
|
||||
private static final String RESET_TO_DEFAULT = "reset_to_default";
|
||||
private static final String OPEN_TRACKS = "open_tracks";
|
||||
private static final String SAVE_GLOBAL_TRACK_INTERVAL = "save_global_track_interval";
|
||||
|
||||
@Override
|
||||
protected void setupPreferences() {
|
||||
setupSaveTrackToGpxPref();
|
||||
setupSaveTrackIntervalPref();
|
||||
|
||||
setupSaveGlobalTrackIntervalPref();
|
||||
setupSaveTrackMinDistancePref();
|
||||
setupSaveTrackPrecisionPref();
|
||||
setupSaveTrackMinSpeedPref();
|
||||
|
@ -69,27 +73,37 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements
|
|||
}
|
||||
|
||||
private void setupSaveTrackIntervalPref() {
|
||||
Integer[] entryValues = new Integer[SECONDS.length + MINUTES.length];
|
||||
String[] entries = new String[entryValues.length];
|
||||
int k = 0;
|
||||
for (int second : SECONDS) {
|
||||
entryValues[k] = second * 1000;
|
||||
entries[k] = second + " " + getString(R.string.int_seconds);
|
||||
k++;
|
||||
}
|
||||
for (int minute : MINUTES) {
|
||||
entryValues[k] = (minute * 60) * 1000;
|
||||
entries[k] = minute + " " + getString(R.string.int_min);
|
||||
k++;
|
||||
}
|
||||
|
||||
HashMap<Object, String> entry = getTimeValues(false);
|
||||
ListPreferenceEx saveTrackInterval = (ListPreferenceEx) findPreference(settings.SAVE_TRACK_INTERVAL.getId());
|
||||
saveTrackInterval.setEntries(entries);
|
||||
saveTrackInterval.setEntryValues(entryValues);
|
||||
saveTrackInterval.setEntries(entry.values().toArray(new String[0]));
|
||||
saveTrackInterval.setEntryValues(entry.keySet().toArray());
|
||||
saveTrackInterval.setIcon(getActiveIcon(R.drawable.ic_action_time_span));
|
||||
saveTrackInterval.setDescription(R.string.save_track_interval_descr);
|
||||
}
|
||||
|
||||
private void setupSaveGlobalTrackIntervalPref() {
|
||||
HashMap<Object, String> entry = getTimeValues(true);
|
||||
ListPreferenceEx saveTrackInterval = (ListPreferenceEx) findPreference(settings.SAVE_GLOBAL_TRACK_INTERVAL.getId());
|
||||
saveTrackInterval.setEntries(entry.values().toArray(new String[0]));
|
||||
saveTrackInterval.setEntryValues(entry.keySet().toArray());
|
||||
saveTrackInterval.setIcon(getActiveIcon(R.drawable.ic_action_time_span));
|
||||
saveTrackInterval.setDescription(R.string.save_global_track_interval_descr);
|
||||
}
|
||||
|
||||
private HashMap<Object, String> getTimeValues(boolean alwaysAskEntry) {
|
||||
HashMap<Object, String> entry = new LinkedHashMap<>();
|
||||
if (alwaysAskEntry) {
|
||||
entry.put(settings.SAVE_GLOBAL_TRACK_REMEMBER.getModeValue(getSelectedAppMode()), getString(R.string.confirm_every_run));
|
||||
}
|
||||
for (int second : SECONDS) {
|
||||
entry.put(second * 1000, second + " " + getString(R.string.int_seconds));
|
||||
}
|
||||
for (int minute : MINUTES) {
|
||||
entry.put((minute * 60) * 1000, minute + " " + getString(R.string.int_min));
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
private void setupSaveTrackMinDistancePref() {
|
||||
Float[] entryValues = new Float[] {0.f, 2.0f, 5.0f, 10.0f, 20.0f, 30.0f, 50.0f};
|
||||
String[] entries = new String[entryValues.length];
|
||||
|
@ -257,6 +271,11 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements
|
|||
String prefId = preference.getKey();
|
||||
|
||||
OsmandSettings.OsmandPreference pref = settings.getPreference(prefId);
|
||||
if (SAVE_GLOBAL_TRACK_INTERVAL.equals(prefId)) {
|
||||
if (newValue instanceof Boolean) {
|
||||
prefId = settings.SAVE_GLOBAL_TRACK_REMEMBER.getId();
|
||||
newValue = Boolean.FALSE;
|
||||
}
|
||||
if (pref instanceof OsmandSettings.CommonPreference && !((OsmandSettings.CommonPreference) pref).hasDefaultValueForMode(getSelectedAppMode())) {
|
||||
FragmentManager fragmentManager = getFragmentManager();
|
||||
if (fragmentManager != null && newValue instanceof Serializable) {
|
||||
|
@ -265,7 +284,7 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -553,19 +553,18 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
ll.addView(sp);
|
||||
if (choice != null) {
|
||||
final AppCompatCheckBox cb = new AppCompatCheckBox(uiCtx);
|
||||
cb.setText(R.string.shared_string_remember_my_choice);
|
||||
cb.setText(R.string.confirm_every_run);
|
||||
cb.setTextColor(textColorPrimary);
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
|
||||
LayoutParams.WRAP_CONTENT);
|
||||
lp.setMargins(dp24, dp8, dp24, 0);
|
||||
cb.setLayoutParams(lp);
|
||||
cb.setPadding(dp8, 0, 0, 0);
|
||||
cb.setChecked(!choice.value);
|
||||
cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
choice.value = isChecked;
|
||||
|
||||
choice.value = !isChecked;
|
||||
}
|
||||
});
|
||||
UiUtilities.setupCompoundButton(cb, nightMode, PROFILE_DEPENDENT);
|
||||
|
|
Loading…
Reference in a new issue