From 52b6946c98dd5a1fbb893b9e00291c9107c56bc5 Mon Sep 17 00:00:00 2001 From: vng Date: Mon, 17 Sep 2012 19:03:50 +0300 Subject: [PATCH] [android] Fix needed disk size for update confirmation. --- android/src/com/mapswithme/maps/DownloadUI.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/android/src/com/mapswithme/maps/DownloadUI.java b/android/src/com/mapswithme/maps/DownloadUI.java index 96f5f9877b..634c6ef011 100644 --- a/android/src/com/mapswithme/maps/DownloadUI.java +++ b/android/src/com/mapswithme/maps/DownloadUI.java @@ -149,13 +149,14 @@ public class DownloadUI extends ListActivity implements MapStorage.Listener fillList(); } + private final long MB = 1024 * 1024; + private String getSizeString(long size) { - final long Mb = 1024 * 1024; - if (size > Mb) + if (size > MB) { - // do the correct rounding of Mb - return (size + 512 * 1024) / Mb + " " + m_mb; + // do the correct rounding of MB + return (size + 512 * 1024) / MB + " " + m_mb; } else { @@ -250,9 +251,8 @@ public class DownloadUI extends ListActivity implements MapStorage.Listener @Override public void onClick(DialogInterface dlg, int which) { - final long size = remoteSize - m_storage.countryLocalSizeInBytes(idx); - if (size > getFreeSpace()) - showNotEnoughFreeSpaceDialog(getSizeString(size), name); + if (remoteSize + MB > getFreeSpace()) + showNotEnoughFreeSpaceDialog(getSizeString(remoteSize), name); else m_storage.downloadCountry(idx); @@ -276,7 +276,7 @@ public class DownloadUI extends ListActivity implements MapStorage.Listener case MapStorage.NOT_DOWNLOADED: // Check for available free space final long size = m_storage.countryRemoteSizeInBytes(idx); - if (size > getFreeSpace()) + if (size + MB > getFreeSpace()) { showNotEnoughFreeSpaceDialog(getSizeString(size), name); }