Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArsentiy Milchakov <milcars@mapswithme.com>2018-04-24 18:39:07 +0300
committerAleksandr Zatsepin <alexzatsepin@users.noreply.github.com>2018-04-25 15:38:50 +0300
commitd0286c1556fd68f8c5b29d298f6c004819862f39 (patch)
treef21813c43a2de5315d3dd64392b49f0466a049f2 /android/src
parent9e93bce37a707ef3b4fadbff4715e59c4c809fb7 (diff)
[android] Auto-update screen. Reload info on resume
Diffstat (limited to 'android/src')
-rw-r--r--android/src/com/mapswithme/maps/downloader/MapManager.java2
-rw-r--r--android/src/com/mapswithme/maps/downloader/UpdaterDialogFragment.java90
2 files changed, 70 insertions, 22 deletions
diff --git a/android/src/com/mapswithme/maps/downloader/MapManager.java b/android/src/com/mapswithme/maps/downloader/MapManager.java
index d16218784c..e119c22f14 100644
--- a/android/src/com/mapswithme/maps/downloader/MapManager.java
+++ b/android/src/com/mapswithme/maps/downloader/MapManager.java
@@ -392,6 +392,8 @@ public final class MapManager
*/
public static native boolean nativeIsDownloading();
+ public static native String nativeGetCurrentDownloadingCountryId();
+
/**
* Enqueues given {@code root} node and its children in downloader.
*/
diff --git a/android/src/com/mapswithme/maps/downloader/UpdaterDialogFragment.java b/android/src/com/mapswithme/maps/downloader/UpdaterDialogFragment.java
index 30768cf599..75fe6f9d00 100644
--- a/android/src/com/mapswithme/maps/downloader/UpdaterDialogFragment.java
+++ b/android/src/com/mapswithme/maps/downloader/UpdaterDialogFragment.java
@@ -107,16 +107,10 @@ public class UpdaterDialogFragment extends BaseMwmDialogFragment
mTotalSizeBytes / Constants.MB);
MapManager.nativeCancel(CountryItem.getRootId());
- final UpdateInfo info = MapManager.nativeGetUpdateInfo(CountryItem.getRootId());
- if (info == null)
- {
- finish();
- return;
- }
+
+ updateTotalSizes();
mAutoUpdate = false;
- mTotalSize = StringUtils.getFileSizeString(info.totalSize);
- mTotalSizeBytes = info.totalSize;
mOutdatedMaps = Framework.nativeGetOutdatedCountries();
if (mStorageCallback != null)
@@ -262,28 +256,39 @@ public class UpdaterDialogFragment extends BaseMwmDialogFragment
{
super.onResume();
- if (isAllUpdated())
+ // The storage callback must be non-null at this point.
+ //noinspection ConstantConditions
+ mStorageCallback.attach(this);
+
+ if (isAllUpdated() || Framework.nativeGetOutdatedCountries().length == 0)
{
finish();
return;
}
- // The storage callback must be non-null at this point.
- //noinspection ConstantConditions
- mStorageCallback.attach(this);
-
- if (mAutoUpdate && !MapManager.nativeIsDownloading())
+ if (mAutoUpdate)
{
- MapManager.warnOn3gUpdate(getActivity(), CountryItem.getRootId(), new Runnable()
+ if (!MapManager.nativeIsDownloading())
{
- @Override
- public void run()
+ MapManager.warnOn3gUpdate(getActivity(), CountryItem.getRootId(), new Runnable()
{
- MapManager.nativeUpdate(CountryItem.getRootId());
- Statistics.INSTANCE.trackDownloaderDialogEvent(DOWNLOADER_DIALOG_DOWNLOAD,
- mTotalSizeBytes / Constants.MB);
- }
- });
+ @Override
+ public void run()
+ {
+ MapManager.nativeUpdate(CountryItem.getRootId());
+ Statistics.INSTANCE.trackDownloaderDialogEvent(DOWNLOADER_DIALOG_DOWNLOAD,
+ mTotalSizeBytes / Constants.MB);
+ }
+ });
+ }
+ else
+ {
+ updateTotalSizes();
+ updateProgress();
+
+ updateProcessedMapInfo();
+ setCommonStatus(mProcessedMapId, mCommonStatusResId);
+ }
}
}
@@ -385,6 +390,47 @@ public class UpdaterDialogFragment extends BaseMwmDialogFragment
String status = getString(mwmStatusResId, MapManager.nativeGetName(mwmId));
mTitle.setText(status);
}
+
+ void updateTotalSizes()
+ {
+ final UpdateInfo info = MapManager.nativeGetUpdateInfo(CountryItem.getRootId());
+ if (info == null)
+ {
+ finish();
+ return;
+ }
+
+ mTotalSize = StringUtils.getFileSizeString(info.totalSize);
+ mTotalSizeBytes = info.totalSize;
+ }
+
+ void updateProgress()
+ {
+ int progress = MapManager.nativeGetOverallProgress(mOutdatedMaps);
+ setProgress(progress, mTotalSizeBytes * progress / 100, mTotalSizeBytes);
+ }
+
+ void updateProcessedMapInfo()
+ {
+ mProcessedMapId = MapManager.nativeGetCurrentDownloadingCountryId();
+
+ CountryItem processedCountryItem = new CountryItem(mProcessedMapId);
+ MapManager.nativeGetAttributes(processedCountryItem);
+
+ switch (processedCountryItem.status)
+ {
+ case CountryItem.STATUS_PROGRESS:
+ mCommonStatusResId = R.string.downloader_process;
+ break;
+ case CountryItem.STATUS_APPLYING:
+ mCommonStatusResId = R.string.downloader_applying;
+ break;
+ default:
+ mCommonStatusResId = 0;
+ break;
+ }
+ }
+
private static class DetachableStorageCallback implements MapManager.StorageCallback
{
@Nullable