From 25f4426625284948f0ed6fdb53b7cb445f69acbe Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 26 Aug 2020 11:15:37 +0300 Subject: [PATCH] Fix #9698 --- .../plus/activities/SettingsBaseActivity.java | 20 ++++++++++--------- .../monitoring/OsmandMonitoringPlugin.java | 4 ++-- .../fragments/LiveMonitoringFragment.java | 5 +++-- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java index 37504315f1..2187e801a2 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java @@ -23,14 +23,15 @@ import androidx.appcompat.app.AlertDialog.Builder; import net.osmand.AndroidUtils; import net.osmand.PlatformUtil; -import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference; -import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference; import net.osmand.plus.R; import net.osmand.plus.profiles.AppProfileArrayAdapter; import net.osmand.plus.profiles.ProfileDataObject; +import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference; +import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference; import org.apache.commons.logging.Log; @@ -287,8 +288,9 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity public ListPreference createTimeListPreference(OsmandPreference b, int[] seconds, int[] minutes, int coeff, int title, int summary) { return createTimeListPreference(b, seconds, minutes, coeff, null, title, summary); } - public ListPreference createTimeListPreference(OsmandPreference b, int[] seconds, int[] minutes, int coeff, CommonPreference disable, int title, - int summary) { + + public ListPreference createTimeListPreference(OsmandPreference b, int[] seconds, int[] minutes, + int coeff, CommonPreference disable, int title, int summary) { int minutesLength = minutes == null ? 0 : minutes.length; int secondsLength = seconds == null ? 0 : seconds.length; Integer[] ints = new Integer[secondsLength + minutesLength]; @@ -299,19 +301,19 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity intDescriptions[k] = seconds[i] + " " + getString(R.string.int_seconds); //$NON-NLS-1$ k++; } + OsmandApplication app = getMyApplication(); for (int i = 0; i < minutesLength; i++) { ints[k] = (minutes[i] * 60) * coeff; - intDescriptions[k] = minutes[i] + " " + getString(R.string.int_min); //$NON-NLS-1$ + intDescriptions[k] = OsmAndFormatter.getFormattedDuration(minutes[i] * 60, app); k++; } ListPreference lp = createListPreference(b, intDescriptions, ints, title, summary); - if(disable != null) { + if (disable != null) { registerDisablePreference(b, getString(R.string.confirm_every_run), disable); } return lp; } - @Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java index aa69457806..94987d1c8a 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java @@ -43,9 +43,9 @@ import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.fragments.BaseSettingsFragment; -import net.osmand.plus.views.layers.MapInfoLayer; import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapTileView; +import net.osmand.plus.views.layers.MapInfoLayer; import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget; import net.osmand.util.Algorithms; @@ -164,7 +164,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { public static final int[] SECONDS = new int[] {0, 1, 2, 3, 5, 10, 15, 20, 30, 60, 90}; public static final int[] MINUTES = new int[] {2, 3, 5}; - public static final int[] MAX_INTERVAL_TO_SEND_MINUTES = new int[] {1, 2, 5, 10, 15, 20, 30, 60}; + public static final int[] MAX_INTERVAL_TO_SEND_MINUTES = new int[] {1, 2, 5, 10, 15, 20, 30, 60, 90, 2 * 60, 3 * 60, 4 * 60, 6 * 60, 12 * 60, 24 * 60}; @Override diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/LiveMonitoringFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/LiveMonitoringFragment.java index 282fb204e3..e664953662 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/LiveMonitoringFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/LiveMonitoringFragment.java @@ -11,6 +11,7 @@ import androidx.core.content.ContextCompat; import androidx.preference.Preference; import net.osmand.AndroidUtils; +import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; @@ -128,10 +129,10 @@ public class LiveMonitoringFragment extends BaseSettingsFragment { for (int i = 0; i < MAX_INTERVAL_TO_SEND_MINUTES.length; i++) { int minute = MAX_INTERVAL_TO_SEND_MINUTES[i]; entryValues[i] = (minute * 60) * 1000; - entries[i] = minute + " " + getString(R.string.int_min); + entries[i] = OsmAndFormatter.getFormattedDuration(minute * 60, app); } - ListPreferenceEx liveMonitoringBuffer = (ListPreferenceEx) findPreference(settings.LIVE_MONITORING_MAX_INTERVAL_TO_SEND.getId()); + ListPreferenceEx liveMonitoringBuffer = findPreference(settings.LIVE_MONITORING_MAX_INTERVAL_TO_SEND.getId()); liveMonitoringBuffer.setEntries(entries); liveMonitoringBuffer.setEntryValues(entryValues); liveMonitoringBuffer.setIcon(getPersistentPrefIcon(R.drawable.ic_action_time_span));