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_descr">Umožňuje zdieľanie polohy a zaznamenávanie výletu.</string>
|
||||||
<string name="live_monitoring">Sledovanie online</string>
|
<string name="live_monitoring">Sledovanie online</string>
|
||||||
<string name="save_track_logging_accuracy">Presnosť záznamu</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="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="video_notes">Video-poznámky</string>
|
||||||
<string name="photo_notes">Foto-poznámky</string>
|
<string name="photo_notes">Foto-poznámky</string>
|
||||||
|
|
|
@ -33,6 +33,13 @@
|
||||||
android:layout="@layout/preference_category_with_descr"
|
android:layout="@layout/preference_category_with_descr"
|
||||||
android:title="@string/save_track_logging_accuracy" />
|
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
|
<net.osmand.plus.settings.preferences.ListPreferenceEx
|
||||||
android:key="save_track_min_distance"
|
android:key="save_track_min_distance"
|
||||||
android:layout="@layout/preference_with_descr"
|
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 net.osmand.plus.widgets.style.CustomTypefaceSpan;
|
||||||
|
|
||||||
import java.io.Serializable;
|
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.DAILY_DIRECTORY;
|
||||||
import static net.osmand.plus.OsmandSettings.MONTHLY_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 COPY_PLUGIN_SETTINGS = "copy_plugin_settings";
|
||||||
private static final String RESET_TO_DEFAULT = "reset_to_default";
|
private static final String RESET_TO_DEFAULT = "reset_to_default";
|
||||||
private static final String OPEN_TRACKS = "open_tracks";
|
private static final String OPEN_TRACKS = "open_tracks";
|
||||||
|
private static final String SAVE_GLOBAL_TRACK_INTERVAL = "save_global_track_interval";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setupPreferences() {
|
protected void setupPreferences() {
|
||||||
setupSaveTrackToGpxPref();
|
setupSaveTrackToGpxPref();
|
||||||
setupSaveTrackIntervalPref();
|
setupSaveTrackIntervalPref();
|
||||||
|
|
||||||
|
setupSaveGlobalTrackIntervalPref();
|
||||||
setupSaveTrackMinDistancePref();
|
setupSaveTrackMinDistancePref();
|
||||||
setupSaveTrackPrecisionPref();
|
setupSaveTrackPrecisionPref();
|
||||||
setupSaveTrackMinSpeedPref();
|
setupSaveTrackMinSpeedPref();
|
||||||
|
@ -69,27 +73,37 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupSaveTrackIntervalPref() {
|
private void setupSaveTrackIntervalPref() {
|
||||||
Integer[] entryValues = new Integer[SECONDS.length + MINUTES.length];
|
HashMap<Object, String> entry = getTimeValues(false);
|
||||||
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++;
|
|
||||||
}
|
|
||||||
|
|
||||||
ListPreferenceEx saveTrackInterval = (ListPreferenceEx) findPreference(settings.SAVE_TRACK_INTERVAL.getId());
|
ListPreferenceEx saveTrackInterval = (ListPreferenceEx) findPreference(settings.SAVE_TRACK_INTERVAL.getId());
|
||||||
saveTrackInterval.setEntries(entries);
|
saveTrackInterval.setEntries(entry.values().toArray(new String[0]));
|
||||||
saveTrackInterval.setEntryValues(entryValues);
|
saveTrackInterval.setEntryValues(entry.keySet().toArray());
|
||||||
saveTrackInterval.setIcon(getActiveIcon(R.drawable.ic_action_time_span));
|
saveTrackInterval.setIcon(getActiveIcon(R.drawable.ic_action_time_span));
|
||||||
saveTrackInterval.setDescription(R.string.save_track_interval_descr);
|
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() {
|
private void setupSaveTrackMinDistancePref() {
|
||||||
Float[] entryValues = new Float[] {0.f, 2.0f, 5.0f, 10.0f, 20.0f, 30.0f, 50.0f};
|
Float[] entryValues = new Float[] {0.f, 2.0f, 5.0f, 10.0f, 20.0f, 30.0f, 50.0f};
|
||||||
String[] entries = new String[entryValues.length];
|
String[] entries = new String[entryValues.length];
|
||||||
|
@ -257,6 +271,11 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements
|
||||||
String prefId = preference.getKey();
|
String prefId = preference.getKey();
|
||||||
|
|
||||||
OsmandSettings.OsmandPreference pref = settings.getPreference(prefId);
|
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())) {
|
if (pref instanceof OsmandSettings.CommonPreference && !((OsmandSettings.CommonPreference) pref).hasDefaultValueForMode(getSelectedAppMode())) {
|
||||||
FragmentManager fragmentManager = getFragmentManager();
|
FragmentManager fragmentManager = getFragmentManager();
|
||||||
if (fragmentManager != null && newValue instanceof Serializable) {
|
if (fragmentManager != null && newValue instanceof Serializable) {
|
||||||
|
@ -265,7 +284,7 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -553,19 +553,18 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
||||||
ll.addView(sp);
|
ll.addView(sp);
|
||||||
if (choice != null) {
|
if (choice != null) {
|
||||||
final AppCompatCheckBox cb = new AppCompatCheckBox(uiCtx);
|
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);
|
cb.setTextColor(textColorPrimary);
|
||||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
|
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
|
||||||
LayoutParams.WRAP_CONTENT);
|
LayoutParams.WRAP_CONTENT);
|
||||||
lp.setMargins(dp24, dp8, dp24, 0);
|
lp.setMargins(dp24, dp8, dp24, 0);
|
||||||
cb.setLayoutParams(lp);
|
cb.setLayoutParams(lp);
|
||||||
cb.setPadding(dp8, 0, 0, 0);
|
cb.setPadding(dp8, 0, 0, 0);
|
||||||
|
cb.setChecked(!choice.value);
|
||||||
cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
choice.value = isChecked;
|
choice.value = !isChecked;
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
UiUtilities.setupCompoundButton(cb, nightMode, PROFILE_DEPENDENT);
|
UiUtilities.setupCompoundButton(cb, nightMode, PROFILE_DEPENDENT);
|
||||||
|
|
Loading…
Reference in a new issue