From b17293247821d4b5bc2951d0a584f83fb5f859d4 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 20 Jan 2020 17:44:08 +0100 Subject: [PATCH] Fix #7735 --- OsmAnd/src/net/osmand/AndroidUtils.java | 2 +- .../net/osmand/plus/audionotes/MultimediaNotesFragment.java | 4 ++-- .../osmand/plus/audionotes/SettingsAudioVideoActivity.java | 4 ++-- .../net/osmand/plus/dashboard/DashChooseAppDirFragment.java | 4 +--- OsmAnd/src/net/osmand/plus/download/IndexItem.java | 1 + .../net/osmand/plus/firstusage/FirstUsageWizardFragment.java | 3 +-- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java index 9e733fa186..c2d5f95d04 100644 --- a/OsmAnd/src/net/osmand/AndroidUtils.java +++ b/OsmAnd/src/net/osmand/AndroidUtils.java @@ -234,7 +234,7 @@ public class AndroidUtils { if(ctx == null) { return size + " " + numSuffix; } - return ctx.getString(R.string.ltr_or_rtl_combine_via_colon, size, numSuffix); + return ctx.getString(R.string.ltr_or_rtl_combine_via_space, size, numSuffix); } return ""; } diff --git a/OsmAnd/src/net/osmand/plus/audionotes/MultimediaNotesFragment.java b/OsmAnd/src/net/osmand/plus/audionotes/MultimediaNotesFragment.java index 3abdb37e56..6447ed34e6 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/MultimediaNotesFragment.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/MultimediaNotesFragment.java @@ -8,6 +8,7 @@ import android.os.Build; import android.os.StatFs; import android.support.v7.preference.Preference; +import net.osmand.AndroidUtils; import net.osmand.PlatformUtil; import net.osmand.plus.OsmAndAppCustomization; import net.osmand.plus.OsmandPlugin; @@ -306,13 +307,12 @@ public class MultimediaNotesFragment extends BaseSettingsFragment { if (value != size) { gbList.add((int) size); } - MessageFormat formatGb = new MessageFormat("{0, number,#.##} GB", Locale.US); String[] entries = new String[gbList.size()]; Integer[] entryValues = new Integer[gbList.size()]; int i = 0; for (int v : gbList) { entryValues[i] = v; - entries[i] = formatGb.format(new Object[] {(float) v}); + entries[i] = AndroidUtils.formatSize(getActivity(), v * (1l << 30)); i++; } diff --git a/OsmAnd/src/net/osmand/plus/audionotes/SettingsAudioVideoActivity.java b/OsmAnd/src/net/osmand/plus/audionotes/SettingsAudioVideoActivity.java index babd535218..a19e9d09cb 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/SettingsAudioVideoActivity.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/SettingsAudioVideoActivity.java @@ -11,6 +11,7 @@ import android.preference.ListPreference; import android.preference.PreferenceCategory; import android.preference.PreferenceScreen; +import net.osmand.AndroidUtils; import net.osmand.PlatformUtil; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; @@ -272,13 +273,12 @@ public class SettingsAudioVideoActivity extends SettingsBaseActivity { if (value != size) { gbList.add((int) size); } - MessageFormat formatGb = new MessageFormat("{0, number,#.##} GB", Locale.US); entries = new String[gbList.size()]; intValues = new Integer[gbList.size()]; i = 0; for (int v : gbList) { intValues[i] = v; - entries[i] = formatGb.format(new Object[]{(float) v}); + entries[i] = AndroidUtils.formatSize(this, v * (1l << 30)); i++; } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java index 9026efb2d1..8b1d946172 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java @@ -57,7 +57,6 @@ public class DashChooseAppDirFragment { public static final int VERSION_DEFAULTLOCATION_CHANGED = 19; private TextView locationPath; private TextView locationDesc; - MessageFormat formatGb = new MessageFormat("{0, number,#.##} GB", Locale.US); private View copyMapsBtn; private ImageView editBtn; private View dontCopyMapsBtn; @@ -93,8 +92,7 @@ public class DashChooseAppDirFragment { private String getFreeSpace(File dir) { if (dir.canRead()) { StatFs fs = new StatFs(dir.getAbsolutePath()); - return formatGb - .format(new Object[] { (float) (fs.getAvailableBlocks()) * fs.getBlockSize() / (1 << 30) }); + return AndroidUtils.formatSize(activity, (long) fs.getAvailableBlocks()) * fs.getBlockSize() ); } return ""; } diff --git a/OsmAnd/src/net/osmand/plus/download/IndexItem.java b/OsmAnd/src/net/osmand/plus/download/IndexItem.java index c5c87f88c8..7e315eea71 100644 --- a/OsmAnd/src/net/osmand/plus/download/IndexItem.java +++ b/OsmAnd/src/net/osmand/plus/download/IndexItem.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.text.DateFormat; import java.util.Date; +import net.osmand.AndroidUtils; import net.osmand.IndexConstants; import net.osmand.PlatformUtil; import net.osmand.map.OsmandRegions; diff --git a/OsmAnd/src/net/osmand/plus/firstusage/FirstUsageWizardFragment.java b/OsmAnd/src/net/osmand/plus/firstusage/FirstUsageWizardFragment.java index 55dba41bcf..8016624153 100644 --- a/OsmAnd/src/net/osmand/plus/firstusage/FirstUsageWizardFragment.java +++ b/OsmAnd/src/net/osmand/plus/firstusage/FirstUsageWizardFragment.java @@ -77,7 +77,6 @@ public class FirstUsageWizardFragment extends BaseOsmAndFragment implements OsmA private View view; private DownloadIndexesThread downloadThread; private DownloadValidationManager validationManager; - private MessageFormat formatGb = new MessageFormat("{0, number,#.##} GB", Locale.US); private static WizardType wizardType; private static final WizardType DEFAULT_WIZARD_TYPE = WizardType.SEARCH_LOCATION; @@ -739,7 +738,7 @@ public class FirstUsageWizardFragment extends BaseOsmAndFragment implements OsmA private String getFreeSpace(File dir) { if (dir.canRead()) { StatFs fs = new StatFs(dir.getAbsolutePath()); - return formatGb.format(new Object[]{(float) (fs.getAvailableBlocks()) * fs.getBlockSize() / (1 << 30)}); + return AndroidUtils.formatSize(getActivity(), (long) fs.getAvailableBlocks()) * fs.getBlockSize() ); } return ""; }