[new downloader][android] fix: Migration fixes.

fix: Onmap downloader fixes.
fix: Corrected behavior on tablets.
This commit is contained in:
Alexander Marchuk 2016-03-01 20:24:02 +03:00 committed by Sergey Yershov
parent 8c789588d9
commit a7600f33a1
7 changed files with 60 additions and 43 deletions

View file

@ -107,6 +107,9 @@ static void MigrationStatusChangedCallback(TCountryId const & countryId, bool ke
if (attrs.m_mwmCounter == 1)
OnMigrationError(attrs.m_error);
break;
default:
break;
}
}
@ -326,13 +329,11 @@ Java_com_mapswithme_maps_downloader_MapManager_nativeRetry(JNIEnv * env, jclass
GetStorage().RetryDownloadNode(jni::ToNativeString(env, root));
}
// static boolean nativeUpdate(String root);
JNIEXPORT jboolean JNICALL
// static void nativeUpdate(String root);
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_downloader_MapManager_nativeUpdate(JNIEnv * env, jclass clazz, jstring root)
{
// FIXME (trashkalmar): Uncomment after method is implemented.
//return GetStorage().UpdateNode(jni::ToNativeString(env, root));
return true;
GetStorage().UpdateNode(jni::ToNativeString(env, root));
}
// static void nativeCancel(String root);

View file

@ -39,6 +39,7 @@ import com.mapswithme.maps.bookmarks.data.MapObject;
import com.mapswithme.maps.downloader.DownloaderActivity;
import com.mapswithme.maps.downloader.DownloaderFragment;
import com.mapswithme.maps.downloader.MapManager;
import com.mapswithme.maps.downloader.MigrationFragment;
import com.mapswithme.maps.downloader.OnmapDownloader;
import com.mapswithme.maps.editor.AuthFragment;
import com.mapswithme.maps.editor.EditorActivity;
@ -98,6 +99,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
private static final String[] DOCKED_FRAGMENTS = { SearchFragment.class.getName(),
DownloaderFragment.class.getName(),
MigrationFragment.class.getName(),
RoutingPlanFragment.class.getName(),
EditorHostFragment.class.getName(),
AuthFragment.class.getName() };
@ -291,7 +293,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
{
SearchEngine.cancelSearch();
mSearchController.refreshToolbar();
replaceFragment(DownloaderFragment.class, args, null);
replaceFragment(MapManager.nativeIsLegacyMode() ? MigrationFragment.class : DownloaderFragment.class, args, null);
}
else
{
@ -641,11 +643,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
if (intent.hasExtra(EXTRA_TASK))
addTask(intent);
else if (intent.hasExtra(EXTRA_UPDATE_COUNTRIES))
{
// TODO (trashkalmar): Update all maps in downloader
//OldActiveCountryTree.updateAll();
showDownloader(true);
}
}
private void addTask(Intent intent)

View file

@ -112,10 +112,10 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
Statistics.INSTANCE.trackEvent(Statistics.EventName.DOWNLOADER_ACTION,
Statistics.params().add(Statistics.EventParam.ACTION, "update")
.add(Statistics.EventParam.FROM, "downloader")
.add("is_auto", "false")
.add("scenario", (item.isExpandable() ? "update_group"
: "update")));
.add(Statistics.EventParam.FROM, "downloader")
.add("is_auto", "false")
.add("scenario", (item.isExpandable() ? "update_group"
: "update")));
}
};

View file

@ -88,7 +88,8 @@ class DownloaderToolbarController extends SearchToolbarController
@Override
public void onUpClick()
{
mFragment.onBackPressed();
if (!mFragment.onBackPressed())
super.onUpClick();
}
public void update()

View file

@ -142,7 +142,7 @@ public final class MapManager
/**
* Enqueues given {@code root} node with its children in downloader.
*/
public static native boolean nativeUpdate(String root);
public static native void nativeUpdate(String root);
/**
* Removes given currently downloading {@code root} node and its children from downloader.

View file

@ -10,6 +10,7 @@ import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import com.mapswithme.maps.MwmActivity;
import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseMwmFragment;
import com.mapswithme.maps.base.OnBackPressListener;
@ -140,6 +141,14 @@ public class MigrationFragment extends BaseMwmFragment
@Override
public void onComplete()
{
if (!isAdded())
return;
if (getActivity() instanceof MwmActivity)
((MwmActivity)getActivity()).showDownloader(false);
else
getActivity().recreate();
Statistics.INSTANCE.trackEvent(Statistics.EventName.DOWNLOADER_MIGRATION_COMPLETE);
}
@ -152,7 +161,6 @@ public class MigrationFragment extends BaseMwmFragment
@Override
public boolean onBackPressed()
{
// TODO
return false;
}
}

View file

@ -66,48 +66,57 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener
boolean showFrame = (mCurrentCountry != null);
if (showFrame)
{
boolean showProgress = (mCurrentCountry.status == CountryItem.STATUS_ENQUEUED ||
mCurrentCountry.status == CountryItem.STATUS_PROGRESS);
boolean enqueued = (mCurrentCountry.status == CountryItem.STATUS_ENQUEUED);
boolean progress = (mCurrentCountry.status == CountryItem.STATUS_PROGRESS);
boolean failed = (mCurrentCountry.status == CountryItem.STATUS_FAILED);
showFrame = (showProgress ||
mCurrentCountry.status == CountryItem.STATUS_DOWNLOADABLE ||
mCurrentCountry.status == CountryItem.STATUS_FAILED);
showFrame = (enqueued || progress || failed ||
mCurrentCountry.status == CountryItem.STATUS_DOWNLOADABLE);
if (showFrame)
{
boolean hasParent = !TextUtils.isEmpty(mCurrentCountry.parentName);
UiUtils.showIf(showProgress, mProgress);
UiUtils.showIf(!showProgress, mButton);
UiUtils.showIf(progress || enqueued, mProgress);
UiUtils.showIf(!progress && !enqueued, mButton);
UiUtils.showIf(hasParent, mParent);
if (hasParent)
mParent.setText(mCurrentCountry.parentName);
mTitle.setText(mCurrentCountry.name);
mSize.setText(StringUtils.getFileSizeString(mCurrentCountry.totalSize));
if (showProgress)
mProgress.setProgress((int)(mCurrentCountry.progress * 100L / mCurrentCountry.totalSize));
if (progress)
{
mSize.setText(StringUtils.getFileSizeString(mCurrentCountry.totalSize));
mProgress.setProgress((int) (mCurrentCountry.progress * 100L / mCurrentCountry.totalSize));
}
else
{
boolean success = (mCurrentCountry.status != CountryItem.STATUS_FAILED);
if (success &&
!MapManager.nativeIsLegacyMode() &&
Config.isAutodownloadMaps() &&
ConnectionState.isWifiConnected())
if (enqueued)
{
MapManager.nativeDownload(mCurrentCountry.id);
Statistics.INSTANCE.trackEvent(Statistics.EventName.DOWNLOADER_ACTION,
Statistics.params().add(Statistics.EventParam.ACTION, "download")
.add(Statistics.EventParam.FROM, "map")
.add("is_auto", "true")
.add("scenario", "download"));
mSize.setText(R.string.downloader_queued);
mProgress.setProgress(0);
}
else
{
if (!failed &&
!MapManager.nativeIsLegacyMode() &&
Config.isAutodownloadMaps() &&
ConnectionState.isWifiConnected())
{
MapManager.nativeDownload(mCurrentCountry.id);
mButton.setText(success ? R.string.download
: R.string.downloader_retry);
Statistics.INSTANCE.trackEvent(Statistics.EventName.DOWNLOADER_ACTION,
Statistics.params().add(Statistics.EventParam.ACTION, "download")
.add(Statistics.EventParam.FROM, "map")
.add("is_auto", "true")
.add("scenario", "download"));
}
mButton.setText(failed ? R.string.downloader_retry
: R.string.download);
}
}
}
}
@ -115,7 +124,7 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener
UiUtils.showIf(showFrame, mFrame);
}
public OnmapDownloader(MwmActivity activity)
public OnmapDownloader(final MwmActivity activity)
{
mFrame = activity.findViewById(R.id.onmap_downloader);
mParent = (TextView)mFrame.findViewById(R.id.downloader_parent);
@ -144,7 +153,7 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener
{
if (MapManager.nativeIsLegacyMode())
{
// TODO
activity.showDownloader(false);
return;
}