From 39a6c19a4033ba23c0602e3dea78481f37e989a6 Mon Sep 17 00:00:00 2001 From: Alexander Marchuk Date: Fri, 25 Mar 2016 17:00:26 +0300 Subject: [PATCH] [new downloader][android] fix: Show "Downloading: 42%" instead of "Preparation" in migration dialog. --- android/jni/com/mapswithme/maps/Framework.cpp | 6 +++--- android/jni/com/mapswithme/maps/Framework.hpp | 4 ++-- .../jni/com/mapswithme/maps/MapManager.cpp | 21 +++++++++++-------- android/res/layout/fragment_migrate.xml | 1 - .../maps/downloader/MapManager.java | 7 ++++--- .../maps/downloader/MigrationController.java | 8 ++++--- .../maps/downloader/MigrationFragment.java | 11 ++++++---- .../maps/downloader/OnmapDownloader.java | 3 ++- 8 files changed, 35 insertions(+), 26 deletions(-) diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index d9cc83eed3..811aebf133 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -422,10 +422,10 @@ void Framework::Migrate(bool keepOldMaps) m_work.Migrate(keepOldMaps); } -bool Framework::PreMigrate(ms::LatLon const & position, Storage::TChangeCountryFunction const & statusChangeListener, - Storage::TProgressFunction const & progressListener) +storage::TCountryId Framework::PreMigrate(ms::LatLon const & position, Storage::TChangeCountryFunction const & statusChangeListener, + Storage::TProgressFunction const & progressListener) { - return (m_work.PreMigrate(position, statusChangeListener, progressListener) != kInvalidCountryId); + return m_work.PreMigrate(position, statusChangeListener, progressListener); } } // namespace android diff --git a/android/jni/com/mapswithme/maps/Framework.hpp b/android/jni/com/mapswithme/maps/Framework.hpp index 75559e7b42..d1e9678b34 100644 --- a/android/jni/com/mapswithme/maps/Framework.hpp +++ b/android/jni/com/mapswithme/maps/Framework.hpp @@ -151,8 +151,8 @@ namespace android place_page::Info & GetPlacePageInfo(); bool HasSpaceForMigration(); - bool PreMigrate(ms::LatLon const & position, storage::Storage::TChangeCountryFunction const & statusChangeListener, - storage::Storage::TProgressFunction const & progressListener); + storage::TCountryId PreMigrate(ms::LatLon const & position, storage::Storage::TChangeCountryFunction const & statusChangeListener, + storage::Storage::TProgressFunction const & progressListener); void Migrate(bool keepOldMaps); private: diff --git a/android/jni/com/mapswithme/maps/MapManager.cpp b/android/jni/com/mapswithme/maps/MapManager.cpp index f39a3264a6..caee7773fb 100644 --- a/android/jni/com/mapswithme/maps/MapManager.cpp +++ b/android/jni/com/mapswithme/maps/MapManager.cpp @@ -121,8 +121,8 @@ static void OnMigrationError(NodeErrorCode error) static void MigrationStatusChangedCallback(TCountryId const & countryId, bool keepOldMaps) { - NodeAttrs attrs; - GetStorage().GetPrefetchStorage()->GetNodeAttrs(countryId, attrs); + NodeStatuses attrs; + GetStorage().GetPrefetchStorage()->GetNodeStatuses(countryId, attrs); switch (attrs.m_status) { @@ -132,7 +132,7 @@ static void MigrationStatusChangedCallback(TCountryId const & countryId, bool ke case NodeStatus::Undefined: case NodeStatus::Error: - if (attrs.m_mwmCounter == 1) + if (!attrs.m_groupNode) OnMigrationError(attrs.m_error); break; @@ -149,8 +149,8 @@ static void MigrationProgressCallback(TCountryId const & countryId, TLocalAndRem env->CallVoidMethod(g_migrationListener, callback, static_cast(sizes.first * 100 / sizes.second)); } -// static boolean nativeMigrate(MigrationListener listener, double lat, double lon, boolean hasLocation, boolean keepOldMaps); -JNIEXPORT jboolean JNICALL +// static @Nullable String nativeMigrate(MigrationListener listener, double lat, double lon, boolean hasLocation, boolean keepOldMaps); +JNIEXPORT jstring JNICALL Java_com_mapswithme_maps_downloader_MapManager_nativeMigrate(JNIEnv * env, jclass clazz, jobject listener, jdouble lat, jdouble lon, jboolean hasLocation, jboolean keepOldMaps) { ms::LatLon position{}; @@ -159,14 +159,17 @@ Java_com_mapswithme_maps_downloader_MapManager_nativeMigrate(JNIEnv * env, jclas g_migrationListener = env->NewGlobalRef(listener); - if (g_framework->PreMigrate(position, bind(&MigrationStatusChangedCallback, _1, keepOldMaps), - bind(&MigrationProgressCallback, _1, _2))) + TCountryId id = g_framework->PreMigrate(position, bind(&MigrationStatusChangedCallback, _1, keepOldMaps), + bind(&MigrationProgressCallback, _1, _2)); + if (id != kInvalidCountryId) { - return true; + NodeAttrs attrs; + GetStorage().GetPrefetchStorage()->GetNodeAttrs(id, attrs); + return jni::ToJavaString(env, attrs.m_nodeLocalName); } OnPrefetchComplete(keepOldMaps); - return false; + return nullptr; } // static void nativeCancelMigration(); diff --git a/android/res/layout/fragment_migrate.xml b/android/res/layout/fragment_migrate.xml index 980d278c47..1da71d514e 100644 --- a/android/res/layout/fragment_migrate.xml +++ b/android/res/layout/fragment_migrate.xml @@ -55,7 +55,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/margin_base" - android:text="@string/migration_prefetch_status" android:textAppearance="@style/MwmTextAppearance.Body3"/> 0) + mProgress.setProgress(percents); } @Override diff --git a/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java b/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java index 61b0a5c7f2..6ffb80a7c0 100644 --- a/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java +++ b/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java @@ -8,6 +8,7 @@ import android.widget.Button; import android.widget.TextView; import java.util.List; +import java.util.Locale; import com.mapswithme.maps.MwmActivity; import com.mapswithme.maps.R; @@ -116,7 +117,7 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener { mProgress.setPending(false); mProgress.setProgress(mCurrentCountry.progress); - sizeText = mCurrentCountry.progress + "%"; + sizeText = String.format(Locale.US, "%1$s %2$d%%", mActivity.getString(R.string.downloader_downloading), mCurrentCountry.progress); } else {