Fix #7735 Introduce formatting for MB/Gb for RTL

This commit is contained in:
Victor Shcherb 2020-01-10 19:12:43 +01:00
parent fa84c5acf9
commit 74f73e2cf3
74 changed files with 66 additions and 96 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,020 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,011 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 951 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 879 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 935 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -3425,5 +3425,5 @@ Lon %2$s</string>
<string name="reset_confirmation_descr">Durch das Auswählen von %1$s werden alle Änderungen verlorengehen.</string>
<string name="reset_all_profile_settings_descr">Alle Profil-Einstellungen werden auf den Ausgangszustand nach App-Installation zurückgesetzt.</string>
<string name="reset_all_profile_settings">Alle Profil-Einstellungen auf den Standard zurücksetzen\?</string>
<string name="ltr_or_rtl_combine">%1$s: %2$s</string>
<string name="ltr_or_rtl_combine_via_colon">%1$s: %2$s</string>
</resources>

View file

@ -3400,5 +3400,5 @@ Indikas lokon: %1$s x %2$s"</string>
<string name="reset_confirmation_descr">Per klaki “%1$s”, ĉiuj viaj ŝanĝoj perdiĝos.</string>
<string name="reset_all_profile_settings_descr">Ĉiuj agordoj pri profiloj revenos al la post-instala stato.</string>
<string name="reset_all_profile_settings">Ĉu rekomencigi ĉiujn agordojn pri profiloj\?</string>
<string name="ltr_or_rtl_combine">%1$s: %2$s</string>
<string name="ltr_or_rtl_combine_via_colon">%1$s: %2$s</string>
</resources>

View file

@ -3352,5 +3352,5 @@
<string name="reset_confirmation_descr">Vajutades nupul %1$s kaovad kõik muudatused.</string>
<string name="reset_all_profile_settings_descr">Kõik profiiliseaded lähtestatakse paigaldusjärgsesse olekusse.</string>
<string name="reset_all_profile_settings">Taasta kõikide profiiliseadete vaikeväärtused\?</string>
<string name="ltr_or_rtl_combine">%1$s: %2$s</string>
<string name="ltr_or_rtl_combine_via_colon">%1$s: %2$s</string>
</resources>

View file

@ -3393,5 +3393,5 @@ représentant la zone : %1$s x %2$s</string>
<string name="reset_confirmation_descr">En cliquant sur %1$s, toutes vos modifications seront perdues.</string>
<string name="reset_all_profile_settings_descr">Tous les paramètres de profil vont être ré-initialisés aux valeurs par défaut.</string>
<string name="reset_all_profile_settings">Ré-initialiser tous les paramètres de profil \?</string>
<string name="ltr_or_rtl_combine">%1$s : %2$s</string>
<string name="ltr_or_rtl_combine_via_colon">%1$s : %2$s</string>
</resources>

View file

@ -3411,5 +3411,5 @@
<string name="reset_confirmation_descr">לחיצה על %1$s תוביל לאבדן כל השינויים שערכת.</string>
<string name="reset_all_profile_settings_descr">כל הגדרות הפרופיל יאופסו למצב כמו שלאחר ההתקנה.</string>
<string name="reset_all_profile_settings">לאפס את הגדרות הפרופיל לבררת המחדל\?</string>
<string name="ltr_or_rtl_combine">%1$s: %2$s</string>
<string name="ltr_or_rtl_combine_via_colon">%1$s: %2$s</string>
</resources>

View file

@ -3420,5 +3420,5 @@ Ha szereted az OsmAndot és az OSM-et, és szeretnéd támogatni a fejlődésük
<string name="reset_all_profile_settings_descr">Minden profilbeállítás vissza fog állni a telepítést követő állapotba.</string>
<string name="reset_all_profile_settings">Minden profil visszaálljon az alapértelmezett helyzetbe\?</string>
<string name="app_mode_wagon">Családi autó</string>
<string name="ltr_or_rtl_combine">%1$s: %2$s</string>
<string name="ltr_or_rtl_combine_via_colon">%1$s: %2$s</string>
</resources>

View file

@ -3427,5 +3427,5 @@
<string name="reset_confirmation_descr">Ved å klikke %1$s vil alle endringene dine gå tapt.</string>
<string name="reset_all_profile_settings_descr">Alle profilinnstillinger må tilbakestilles til forvalg.</string>
<string name="reset_all_profile_settings">Tilbakestill alle innstillinger til forvalg\?</string>
<string name="ltr_or_rtl_combine">%1$s: %2$s</string>
<string name="ltr_or_rtl_combine_via_colon">%1$s: %2$s</string>
</resources>

View file

@ -3419,5 +3419,5 @@ Reprezentuje obszar: %1$s x %2$s</string>
<string name="reset_confirmation_descr">Kliknięcie %1$s spowoduje utratę wszystkich zmian.</string>
<string name="reset_all_profile_settings_descr">Wszystkie ustawienia profilu zostaną przywrócone do stanu po instalacji.</string>
<string name="reset_all_profile_settings">Czy zresetować wszystkie ustawienia profilu do wartości domyślnych\?</string>
<string name="ltr_or_rtl_combine">%1$s: %2$s</string>
<string name="ltr_or_rtl_combine_via_colon">%1$s: %2$s</string>
</resources>

View file

@ -3407,5 +3407,5 @@ Pôr do Sol: %2$s</string>
<string name="reset_confirmation_descr">Ao clicar em %1$s, você perderá todas as suas alterações.</string>
<string name="reset_all_profile_settings_descr">Todas as configurações de perfil serão redefinidas para o estado após a instalação.</string>
<string name="reset_all_profile_settings">Redefinir todas as configurações de perfil para o padrão\?</string>
<string name="ltr_or_rtl_combine">%1$s: %2$s</string>
<string name="ltr_or_rtl_combine_via_colon">%1$s: %2$s</string>
</resources>

View file

@ -3412,5 +3412,5 @@
<string name="reset_confirmation_descr">Нажимая %1$s, вы потеряете все свои изменения.</string>
<string name="reset_all_profile_settings_descr">Все настройки профиля будут сброшены в значения по умолчанию после установки.</string>
<string name="reset_all_profile_settings">Сбросить все настройки профиля в значения по умолчанию\?</string>
<string name="ltr_or_rtl_combine">%1$s: %2$s</string>
<string name="ltr_or_rtl_combine_via_colon">%1$s: %2$s</string>
</resources>

View file

@ -3420,5 +3420,5 @@ Pro praghere iscrie su còdighe intreu</string>
<string name="reset_confirmation_descr">Incarchende %1$s, as a pèrdere totu sas modìficas tuas.</string>
<string name="reset_all_profile_settings_descr">Totu sas impostatziones de su profilu ant a torrare a s\'istadu chi teniant in antis de s\'installatzione.</string>
<string name="reset_all_profile_settings">Ripristinare totu sas impostatziones de su profilu a sos valores predefinidos\?</string>
<string name="ltr_or_rtl_combine">%1$s: %2$s</string>
<string name="ltr_or_rtl_combine_via_colon">%1$s: %2$s</string>
</resources>

View file

@ -3408,5 +3408,5 @@ Zodpovedá oblasti: %1$s x %2$s</string>
<string name="reset_confirmation_descr">Stlačením %1$s stratíte všetky zmeny.</string>
<string name="reset_all_profile_settings_descr">Všetky nastavenia profilu budú vrátené do východzieho stavu.</string>
<string name="reset_all_profile_settings">Resetovať nastavenia profilu na predvolené hodnoty\?</string>
<string name="ltr_or_rtl_combine">%1$s: %2$s</string>
<string name="ltr_or_rtl_combine_via_colon">%1$s: %2$s</string>
</resources>

View file

@ -3371,5 +3371,5 @@
<string name="reset_confirmation_descr">%1$s\'e tıkladığınızda, tüm değişikliklerinizi kaybedeceksiniz.</string>
<string name="reset_all_profile_settings_descr">Tüm profil ayarları kurulumdan sonraki duruma sıfırlanacaktır.</string>
<string name="reset_all_profile_settings">Tüm profil ayarları varsayılana sıfırlansın mı\?</string>
<string name="ltr_or_rtl_combine">%1$s: %2$s</string>
<string name="ltr_or_rtl_combine_via_colon">%1$s: %2$s</string>
</resources>

View file

@ -3411,5 +3411,5 @@
<string name="reset_confirmation_descr">Натискаючи %1$s, ви втратите всі свої зміни.</string>
<string name="reset_all_profile_settings_descr">Усі налаштування профілю буде скинуто після встановлення.</string>
<string name="reset_all_profile_settings">Скинути всі усталені налаштування профілю\?</string>
<string name="ltr_or_rtl_combine">%1$s: %2$s</string>
<string name="ltr_or_rtl_combine_via_colon">%1$s: %2$s</string>
</resources>

View file

@ -3408,5 +3408,5 @@
<string name="reset_confirmation_descr">點擊 %1$s您將會失去您所有的變更。</string>
<string name="reset_all_profile_settings_descr">所有設定檔都將被重設為安裝後的狀態。</string>
<string name="reset_all_profile_settings">將所有設定檔重設為預設值?</string>
<string name="ltr_or_rtl_combine">%1$s%2$s</string>
<string name="ltr_or_rtl_combine_via_colon">%1$s%2$s</string>
</resources>

View file

@ -11,7 +11,8 @@
Thx - Hardy
-->
<string name="ltr_or_rtl_combine">%1$s: %2$s</string>
<string name="ltr_or_rtl_combine_via_space">%1$s %2$s</string>
<string name="ltr_or_rtl_combine_via_colon">%1$s: %2$s</string>
<string name="reset_confirmation_descr">By clicking %1$s, you will lose all your changes.</string>
<string name="reset_all_profile_settings_descr">All profile settings will be reset to the state after installation.</string>
<string name="reset_all_profile_settings">Reset all profile settings to default?</string>

View file

@ -60,6 +60,7 @@ import net.osmand.plus.download.DownloadActivity;
import net.osmand.util.Algorithms;
import java.io.File;
import java.text.MessageFormat;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
@ -76,6 +77,9 @@ import static android.util.TypedValue.COMPLEX_UNIT_SP;
public class AndroidUtils {
public static final String STRING_PLACEHOLDER = "%s";
public static final MessageFormat formatKb = new MessageFormat("{0, number,##.#}", Locale.US);
public static final MessageFormat formatGb = new MessageFormat("{0, number,#.##}", Locale.US);
public static final MessageFormat formatMb = new MessageFormat("{0, number,##.#}", Locale.US);
/**
* @param context
@ -211,16 +215,26 @@ public class AndroidUtils {
return DateFormat.getTimeFormat(ctx).format(new Date(time));
}
public static String formatSize(long sizeBytes) {
public static String formatSize(Context ctx, long sizeBytes) {
int sizeKb = (int) ((sizeBytes + 512) >> 10);
if (sizeKb > 0) {
String size = "";
String numSuffix = "MB";
if (sizeKb > 1 << 20) {
return DownloadActivity.formatGb.format(new Object[]{(float) sizeKb / (1 << 20)});
size = formatGb.format(new Object[]{(float) sizeKb / (1 << 20)});
numSuffix = "GB";
} else if (sizeBytes > (100 * (1 << 10))) {
return DownloadActivity.formatMb.format(new Object[]{(float) sizeBytes / (1 << 20)});
size = formatMb.format(new Object[]{(float) sizeBytes / (1 << 20)});
} else {
return DownloadActivity.formatKb.format(new Object[]{(float) sizeBytes / (1 << 10)});
size = formatKb.format(new Object[]{(float) sizeBytes / (1 << 10)});
numSuffix = "kB";
}
if(ctx == null) {
return size + " " + numSuffix;
}
return ctx.getString(R.string.ltr_or_rtl_combine_via_colon, size, numSuffix);
}
return "";
}

View file

@ -467,7 +467,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
public String getExtendedDescription(Context ctx) {
DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(ctx);
String date = dateFormat.format(file.lastModified());
String size = AndroidUtils.formatSize(file.length());
String size = AndroidUtils.formatSize(ctx, file.length());
if (isPhoto()) {
return date + "" + size;
}

View file

@ -28,6 +28,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.ValueHolder;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
@ -313,19 +314,10 @@ public class DashChooseAppDirFragment {
@SuppressLint("StaticFieldLeak")
MoveFilesToDifferentDirectory task = new MoveFilesToDifferentDirectory(activity, currentAppFile, selectedFile) {
private MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US);
@NonNull
private String getFormattedSize(long sizeBytes) {
int size = (int) ((sizeBytes + 512) >> 10);
if (size >= 0) {
if (size > 100) {
return formatMb.format(new Object[]{(float) size / (1 << 10)});
} else {
return size + " kB";
}
}
return "";
return AndroidUtils.formatSize(activity, sizeBytes);
}
private void showResultsDialog() {

View file

@ -34,6 +34,7 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
@ -103,9 +104,8 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
public static final String DOWNLOAD_TAB = "download";
public static final String UPDATES_TAB = "updates";
public static final String REGION_TO_SEARCH = "search_region";
public static final MessageFormat formatGb = new MessageFormat("{0, number,#.##} GB", Locale.US);
public static final MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US);
public static final MessageFormat formatKb = new MessageFormat("{0, number,##.#} kB", Locale.US);
private static boolean SUGGESTED_TO_DOWNLOAD_BASEMAP = false;
private BannerAndDownloadFreeVersion visibleBanner;
@ -666,11 +666,11 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
ProgressBar sizeProgress = (ProgressBar) view.findViewById(R.id.progressBar);
File dir = activity.getMyApplication().getAppPath("").getParentFile();
String size = formatGb.format(new Object[]{0});
String size = "";
int percent = 0;
if (dir.canRead()) {
StatFs fs = new StatFs(dir.getAbsolutePath());
size = formatGb.format(new Object[]{(float) (fs.getAvailableBlocks()) * fs.getBlockSize() / (1 << 30)});
size = AndroidUtils.formatSize(activity, ((long)fs.getAvailableBlocks()) * fs.getBlockSize());
percent = 100 - fs.getAvailableBlocks() * 100 / fs.getBlockCount();
}
sizeProgress.setIndeterminate(false);

View file

@ -89,7 +89,7 @@ public class IndexItem implements Comparable<IndexItem> {
}
public String getSizeDescription(Context ctx) {
return size + " MB";
return ctx.getString(R.string.ltr_or_rtl_combine_via_colon, size, "MB");
}

View file

@ -19,6 +19,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.IProgress;
import net.osmand.plus.OnDismissDialogFragmentListener;
import net.osmand.plus.OsmandApplication;
@ -188,13 +189,9 @@ public class DataStoragePlaceDialogFragment extends BottomSheetDialogFragment {
if (dir != null && dir.canRead()) {
StatFs fs = new StatFs(dir.getAbsolutePath());
@SuppressWarnings("deprecation")
float size = (float) fs.getAvailableBlocks() * fs.getBlockSize();
long size = (long) fs.getAvailableBlocks() * fs.getBlockSize();
if (size > 0) {
if (size > 1 << 20) {
sz = DownloadActivity.formatGb.format(new Object[]{size / (1 << 30)});
} else {
sz = DownloadActivity.formatMb.format(new Object[]{size / (1 << 20)});
}
sz = AndroidUtils.formatSize(getActivity(), size);
}
}
return sz;

View file

@ -1036,11 +1036,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
}
String sz = "";
if (size > 0) {
if (size > 1 << 20) {
sz = DownloadActivity.formatGb.format(new Object[]{(float) size / (1 << 20)});
} else {
sz = DownloadActivity.formatMb.format(new Object[]{(float) size / (1 << 10)});
}
sz = AndroidUtils.formatSize(v.getContext(), size * 1024l);
}
sizeView.setText(sz);
sizeView.setVisibility(View.VISIBLE);
@ -1157,11 +1153,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
if (builder.length() > 0) {
builder.append("");
}
if (child.getSize() > 100) {
builder.append(DownloadActivity.formatMb.format(new Object[]{(float) child.getSize() / (1 << 10)}));
} else {
builder.append(child.getSize()).append(" KB");
}
builder.append(AndroidUtils.formatSize(ctx, child.getSize() * 1024l));
}
if (!Algorithms.isEmpty(child.getDescription())) {

View file

@ -123,8 +123,6 @@ import static net.osmand.plus.OsmAndFormatter.YARDS_IN_ONE_METER;
import static net.osmand.plus.UiUtilities.CompoundButtonType.PROFILE_DEPENDENT;
import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR;
import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR;
import static net.osmand.plus.download.DownloadActivity.formatKb;
import static net.osmand.plus.download.DownloadActivity.formatMb;
public class GpxUiHelper {
@ -812,11 +810,7 @@ public class GpxUiHelper {
String date = "";
String size = "";
if (info.getFileSize() >= 0) {
if (info.getFileSize() > (100 * (1 << 10))) {
size = formatMb.format(new Object[]{(float) info.getFileSize() / (1 << 20)});
} else {
size = formatKb.format(new Object[]{(float) info.getFileSize() / (1 << 10)});
}
size = AndroidUtils.formatSize(v.getContext(), info.getFileSize());
}
DateFormat df = app.getResourceManager().getDateFormat();
long fd = info.getLastModified();

View file

@ -19,6 +19,7 @@ import android.widget.CheckBox;
import android.widget.Spinner;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
@ -104,7 +105,7 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment {
downloadOverWiFiCheckBox.setChecked(!liveUpdatePreference.get() || downloadViaWiFiPreference.get());
sizeTextView.setText(getUpdatesSize(fileNameWithoutExtension, changesManager));
sizeTextView.setText(getUpdatesSize(getMyActivity(), fileNameWithoutExtension, changesManager));
TimeOfDay[] timeOfDays = TimeOfDay.values();
String[] timeOfDaysStrings = new String[timeOfDays.length];
@ -194,7 +195,7 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment {
} else {
runLiveUpdate(getActivity(), fileName, true);
final IncrementalChangesManager changesManager = getMyApplication().getResourceManager().getChangesManager();
sizeTextView.setText(getUpdatesSize(fileNameWithoutExtension, changesManager));
sizeTextView.setText(getUpdatesSize(getMyActivity(), fileNameWithoutExtension, changesManager));
dialog.dismiss();
}
}
@ -214,17 +215,10 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment {
}
}
private static String getUpdatesSize(String fileNameWithoutExtension,
private static String getUpdatesSize(Context ctx, String fileNameWithoutExtension,
IncrementalChangesManager changesManager) {
String size;
long updatesSize = changesManager.getUpdatesSize(fileNameWithoutExtension);
updatesSize /= (1 << 10);
if (updatesSize > 100) {
size = DownloadActivity.formatMb.format(new Object[]{(float) updatesSize / (1 << 10)});
} else {
size = updatesSize + " KB";
}
return size;
return AndroidUtils.formatSize(ctx, updatesSize);
}
private LiveUpdatesFragment getLiveUpdatesFragment() {
@ -263,8 +257,10 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment {
final String fileNameWithoutExtension =
Algorithms.getFileNameWithoutExtension(new File(localIndexInfo));
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(getString(R.string.clear_updates_proposition_message)
+ " " + getUpdatesSize(fileNameWithoutExtension, changesManager))
builder.setMessage(
getString(R.string.ltr_or_rtl_combine_via_space,
getString(R.string.clear_updates_proposition_message),
getUpdatesSize(getContext(), fileNameWithoutExtension, changesManager)))
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {

View file

@ -9,6 +9,7 @@ import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
import net.osmand.data.LatLon;
@ -311,11 +312,7 @@ public class MapDataMenuController extends MenuController {
}
StringBuilder sizeStr = new StringBuilder();
if (localIndexInfo.getSize() >= 0) {
if (localIndexInfo.getSize() > 100) {
sizeStr.append(DownloadActivity.formatMb.format(new Object[]{(float) localIndexInfo.getSize() / (1 << 10)}));
} else {
sizeStr.append(localIndexInfo.getSize()).append(" KB");
}
sizeStr.append(AndroidUtils.formatSize(mapActivity, localIndexInfo.getSize() * 1024l));
}
if (backuped) {
if (sizeStr.length() > 0) {

View file

@ -118,7 +118,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
private ActionMode actionMode;
private LoadGpxTask asyncLoader;
private GpxIndexesAdapter allGpxAdapter;
private static MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US);
private ContextMenuAdapter optionsMenuAdapter;
private AsyncTask<GpxInfo, ?, ?> operationTask;
private GpxSelectionHelper selectedGpxHelper;
@ -1802,12 +1801,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
v.findViewById(R.id.unknown_section).setVisibility(View.VISIBLE);
String date = "";
String size = "";
if (child.getSize() >= 0) {
if (child.getSize() > 100) {
size = formatMb.format(new Object[]{(float) child.getSize() / (1 << 10)});
} else {
size = child.getSize() + " kB";
}
size = AndroidUtils.formatSize(v.getContext(), child.getSize() * 1024l);
}
DateFormat df = app.getResourceManager().getDateFormat();
long fd = child.getFileDate();

View file

@ -77,7 +77,7 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment {
String formattedCoordinates = OsmAndFormatter.getFormattedCoordinates(lat, lon, format);
if (format == PointDescription.UTM_FORMAT) {
SpannableStringBuilder spannableBuilder = new SpannableStringBuilder();
String combined = getString(R.string.ltr_or_rtl_combine, getString(R.string.shared_string_example), formattedCoordinates);
String combined = getString(R.string.ltr_or_rtl_combine_via_colon, getString(R.string.shared_string_example), formattedCoordinates);
spannableBuilder.append(combined);
spannableBuilder.append("\n");
spannableBuilder.append(getString(R.string.utm_format_descr));
@ -105,7 +105,7 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment {
return spannableBuilder;
}
return getString(R.string.ltr_or_rtl_combine, getString(R.string.shared_string_example), formattedCoordinates);
return getString(R.string.ltr_or_rtl_combine_via_colon, getString(R.string.shared_string_example), formattedCoordinates);
}
@Override

View file

@ -341,19 +341,10 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
@SuppressLint("StaticFieldLeak")
MoveFilesToDifferentDirectory task = new MoveFilesToDifferentDirectory(activity, fromDirectory, toDirectory) {
private MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US);
@NonNull
private String getFormattedSize(long sizeBytes) {
int size = (int) ((sizeBytes + 512) >> 10);
if (size >= 0) {
if (size > 100) {
return formatMb.format(new Object[]{(float) size / (1 << 10)});
} else {
return size + " kB";
}
}
return "";
return AndroidUtils.formatSize(activity.get(), sizeBytes);
}
private void showResultsDialog() {