forked from organicmaps/organicmaps
[new downloader][android] fix: Old downloader UI moved to separate package and renamed.
This commit is contained in:
parent
8530c724b7
commit
9568925b96
23 changed files with 264 additions and 543 deletions
|
@ -1,247 +0,0 @@
|
|||
package com.mapswithme.country;
|
||||
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MapStorage;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmFragment;
|
||||
import com.mapswithme.maps.location.LocationHelper;
|
||||
import com.mapswithme.maps.search.SearchFragment;
|
||||
import com.mapswithme.maps.widget.WheelProgressView;
|
||||
import com.mapswithme.util.StringUtils;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
|
||||
public class CountrySuggestFragment extends BaseMwmFragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener
|
||||
{
|
||||
private double mLat;
|
||||
private double mLon;
|
||||
private MapStorage.Index mCurrentLocationCountryIndex;
|
||||
private int mCountryListenerId;
|
||||
private CountryItem mDownloadingCountry;
|
||||
private int mDownloadingPosition;
|
||||
private int mDownloadingGroup;
|
||||
|
||||
private LinearLayout mLlWithLocation;
|
||||
private LinearLayout mLlNoLocation;
|
||||
private LinearLayout mLlSelectDownload;
|
||||
private LinearLayout mLlActiveDownload;
|
||||
private WheelProgressView mWpvDownloadProgress;
|
||||
private TextView mTvCountry;
|
||||
private TextView mTvActiveCountry;
|
||||
private Button mBtnDownloadMap;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||
{
|
||||
return inflater.inflate(R.layout.fragment_suggest_country_download, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
initViews(view);
|
||||
mCountryListenerId = ActiveCountryTree.addListener(new ActiveCountryTree.SimpleCountryTreeListener()
|
||||
{
|
||||
@Override
|
||||
public void onCountryProgressChanged(int group, int position, long[] sizes)
|
||||
{
|
||||
if (mDownloadingCountry == null)
|
||||
{
|
||||
mDownloadingCountry = ActiveCountryTree.getCountryItem(group, position);
|
||||
mDownloadingPosition = position;
|
||||
mDownloadingGroup = position;
|
||||
}
|
||||
refreshViews();
|
||||
refreshCountryProgress(sizes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCountryGroupChanged(int oldGroup, int oldPosition, int newGroup, int newPosition)
|
||||
{
|
||||
refreshViews();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCountryStatusChanged(int group, int position, int oldStatus, int newStatus)
|
||||
{
|
||||
if (!isAdded())
|
||||
return;
|
||||
|
||||
refreshViews();
|
||||
final CountryItem countryItem = ActiveCountryTree.getCountryItem(group, position);
|
||||
if (newStatus == MapStorage.DOWNLOAD_FAILED)
|
||||
UiUtils.checkConnectionAndShowAlert(getActivity(), String.format(getString(R.string.download_country_failed), countryItem.getName()));
|
||||
else if (newStatus == MapStorage.DOWNLOADING)
|
||||
mDownloadingCountry = countryItem;
|
||||
else if (newStatus == MapStorage.ON_DISK && oldStatus == MapStorage.DOWNLOADING)
|
||||
exitFragment();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void exitFragment()
|
||||
{
|
||||
// TODO find more elegant way
|
||||
getParentFragment().getChildFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
|
||||
final Location last = LocationHelper.INSTANCE.getLastLocation();
|
||||
if (last != null)
|
||||
setLatLon(last.getLatitude(), last.getLongitude());
|
||||
|
||||
refreshViews();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy()
|
||||
{
|
||||
super.onDestroy();
|
||||
ActiveCountryTree.removeListener(mCountryListenerId);
|
||||
}
|
||||
|
||||
private void setLatLon(double latitude, double longitude)
|
||||
{
|
||||
mLat = latitude;
|
||||
mLon = longitude;
|
||||
mCurrentLocationCountryIndex = Framework.nativeGetCountryIndex(mLat, mLon);
|
||||
}
|
||||
|
||||
private void refreshCountryName(String name)
|
||||
{
|
||||
mTvCountry.setText(name);
|
||||
mTvActiveCountry.setText(name);
|
||||
}
|
||||
|
||||
private void initViews(View view)
|
||||
{
|
||||
mLlSelectDownload = (LinearLayout) view.findViewById(R.id.ll__select_download);
|
||||
mLlActiveDownload = (LinearLayout) view.findViewById(R.id.ll__active_download);
|
||||
mLlWithLocation = (LinearLayout) view.findViewById(R.id.ll__location_determined);
|
||||
mLlNoLocation = (LinearLayout) view.findViewById(R.id.ll__location_unknown);
|
||||
mBtnDownloadMap = (Button) view.findViewById(R.id.btn__download_map);
|
||||
mBtnDownloadMap.setOnClickListener(this);
|
||||
view.findViewById(R.id.btn__select_map).setOnClickListener(this);
|
||||
view.findViewById(R.id.btn__select_other_map).setOnClickListener(this);
|
||||
mWpvDownloadProgress = (WheelProgressView) view.findViewById(R.id.wpv__download_progress);
|
||||
mWpvDownloadProgress.setCenterDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.ic_close));
|
||||
mWpvDownloadProgress.setOnClickListener(this);
|
||||
mTvCountry = (TextView) view.findViewById(R.id.tv__country_name);
|
||||
mTvActiveCountry = (TextView) view.findViewById(R.id.tv__active_country_name);
|
||||
}
|
||||
|
||||
private void refreshViews()
|
||||
{
|
||||
if (ActiveCountryTree.getTotalDownloadedCount() != 0 || !isAdded())
|
||||
return;
|
||||
|
||||
if (ActiveCountryTree.isDownloadingActive())
|
||||
{
|
||||
mLlSelectDownload.setVisibility(View.GONE);
|
||||
mLlActiveDownload.setVisibility(View.VISIBLE);
|
||||
if (mDownloadingCountry != null)
|
||||
refreshCountryName(mDownloadingCountry.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
mLlSelectDownload.setVisibility(View.VISIBLE);
|
||||
mLlActiveDownload.setVisibility(View.GONE);
|
||||
if (mLon == 0 || mLat == 0)
|
||||
{
|
||||
mLlNoLocation.setVisibility(View.VISIBLE);
|
||||
mLlWithLocation.setVisibility(View.GONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
mLlNoLocation.setVisibility(View.GONE);
|
||||
mLlWithLocation.setVisibility(View.VISIBLE);
|
||||
refreshCountryName(MapStorage.INSTANCE.countryName(mCurrentLocationCountryIndex));
|
||||
refreshCountrySize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
switch (v.getId())
|
||||
{
|
||||
case R.id.btn__download_map:
|
||||
downloadCurrentLocationMap();
|
||||
break;
|
||||
case R.id.btn__select_map:
|
||||
case R.id.btn__select_other_map:
|
||||
selectMapForDownload();
|
||||
break;
|
||||
case R.id.wpv__download_progress:
|
||||
cancelCurrentDownload();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
|
||||
{
|
||||
if (mCurrentLocationCountryIndex == null)
|
||||
return;
|
||||
|
||||
refreshCountrySize();
|
||||
}
|
||||
|
||||
private void downloadCurrentLocationMap()
|
||||
{
|
||||
ActiveCountryTree.downloadMapForIndex(mCurrentLocationCountryIndex, storageOptionsRequested());
|
||||
}
|
||||
|
||||
private static int storageOptionsRequested()
|
||||
{
|
||||
return StorageOptions.MAP_OPTION_MAP_ONLY;
|
||||
}
|
||||
|
||||
private void selectMapForDownload()
|
||||
{
|
||||
SearchFragment parent = (SearchFragment)getParentFragment();
|
||||
parent.showDownloader();
|
||||
}
|
||||
|
||||
private void cancelCurrentDownload()
|
||||
{
|
||||
ActiveCountryTree.cancelDownloading(mDownloadingGroup, mDownloadingPosition);
|
||||
}
|
||||
|
||||
private void refreshCountrySize()
|
||||
{
|
||||
if (!isAdded())
|
||||
return;
|
||||
|
||||
mBtnDownloadMap.setText(getString(R.string.downloader_download_map) +
|
||||
" (" + StringUtils.getFileSizeString(MapStorage.INSTANCE.countryRemoteSizeInBytes(mCurrentLocationCountryIndex, storageOptionsRequested())) + ")");
|
||||
}
|
||||
|
||||
private void refreshCountryProgress(long[] sizes)
|
||||
{
|
||||
if (!isAdded())
|
||||
return;
|
||||
|
||||
final int percent = (int) (sizes[0] * 100 / sizes[1]);
|
||||
mWpvDownloadProgress.setProgress(percent);
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ import java.io.OutputStream;
|
|||
|
||||
import com.mapswithme.maps.MwmActivity.MapTask;
|
||||
import com.mapswithme.maps.MwmActivity.OpenUrlTask;
|
||||
import com.mapswithme.maps.OldMapStorage.Index;
|
||||
import com.mapswithme.maps.downloader.country.OldMapStorage.Index;
|
||||
import com.mapswithme.maps.api.Const;
|
||||
import com.mapswithme.maps.api.ParsedMwmRequest;
|
||||
import com.mapswithme.maps.base.BaseMwmFragmentActivity;
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.mapswithme.maps;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.mapswithme.maps.MapStorage.Index;
|
||||
import com.mapswithme.maps.downloader.country.OldMapStorage.Index;
|
||||
import com.mapswithme.maps.bookmarks.data.DistanceAndAzimut;
|
||||
import com.mapswithme.maps.bookmarks.data.MapObject;
|
||||
import com.mapswithme.maps.routing.RoutingInfo;
|
||||
|
|
|
@ -15,9 +15,10 @@ import android.view.SurfaceView;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.mapswithme.country.ActiveCountryTree;
|
||||
import com.mapswithme.maps.base.BaseMwmFragment;
|
||||
import com.mapswithme.maps.downloader.DownloadHelper;
|
||||
import com.mapswithme.maps.downloader.MapManager;
|
||||
import com.mapswithme.maps.downloader.country.OldMapStorage;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.concurrency.UiThread;
|
||||
|
||||
|
@ -191,7 +192,7 @@ public class MapFragment extends BaseMwmFragment
|
|||
nativeDetachSurface();
|
||||
}
|
||||
|
||||
public void destroyEngine()
|
||||
void destroyEngine()
|
||||
{
|
||||
if (!mEngineCreated)
|
||||
return;
|
||||
|
@ -288,21 +289,21 @@ public class MapFragment extends BaseMwmFragment
|
|||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (ActiveCountryTree.isLegacyMode())
|
||||
if (MapManager.nativeIsLegacyMode())
|
||||
{
|
||||
((MwmActivity)getActivity()).showMigrateDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
final MapStorage.Index index = new MapStorage.Index(group, country, region);
|
||||
final OldMapStorage.Index index = new OldMapStorage.Index(group, country, region);
|
||||
if (options == -1)
|
||||
{
|
||||
nativeDownloadCountry(index, options);
|
||||
return;
|
||||
}
|
||||
|
||||
final long size = MapStorage.INSTANCE.countryRemoteSizeInBytes(index, options);
|
||||
DownloadHelper.downloadWithCellularCheck(getActivity(), size, MapStorage.INSTANCE.countryName(index), new DownloadHelper.OnDownloadListener()
|
||||
final long size = OldMapStorage.INSTANCE.countryRemoteSizeInBytes(index, options);
|
||||
DownloadHelper.downloadWithCellularCheck(getActivity(), size, OldMapStorage.INSTANCE.countryName(index), new DownloadHelper.OnDownloadListener()
|
||||
{
|
||||
@Override
|
||||
public void onDownload()
|
||||
|
@ -316,7 +317,7 @@ public class MapFragment extends BaseMwmFragment
|
|||
|
||||
private native void nativeConnectDownloaderListeners();
|
||||
private static native void nativeDisconnectListeners();
|
||||
private static native void nativeDownloadCountry(MapStorage.Index index, int options);
|
||||
private static native void nativeDownloadCountry(OldMapStorage.Index index, int options);
|
||||
static native void nativeCompassUpdated(double magneticNorth, double trueNorth, boolean forceRedraw);
|
||||
static native void nativeScalePlus();
|
||||
static native void nativeScaleMinus();
|
||||
|
|
|
@ -27,11 +27,8 @@ import android.widget.Toast;
|
|||
import java.io.Serializable;
|
||||
import java.util.Stack;
|
||||
|
||||
import com.mapswithme.country.ActiveCountryTree;
|
||||
import com.mapswithme.country.DownloadActivity;
|
||||
import com.mapswithme.country.DownloadFragment;
|
||||
import com.mapswithme.maps.Framework.MapObjectListener;
|
||||
import com.mapswithme.maps.MapStorage.Index;
|
||||
import com.mapswithme.maps.downloader.country.OldMapStorage.Index;
|
||||
import com.mapswithme.maps.activity.CustomNavigateUpListener;
|
||||
import com.mapswithme.maps.ads.LikesManager;
|
||||
import com.mapswithme.maps.api.ParsedMwmRequest;
|
||||
|
@ -41,6 +38,11 @@ import com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity;
|
|||
import com.mapswithme.maps.bookmarks.ChooseBookmarkCategoryFragment;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
||||
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.country.OldActiveCountryTree;
|
||||
import com.mapswithme.maps.downloader.country.OldDownloadFragment;
|
||||
import com.mapswithme.maps.editor.EditorActivity;
|
||||
import com.mapswithme.maps.editor.EditorHostFragment;
|
||||
import com.mapswithme.maps.location.LocationHelper;
|
||||
|
@ -97,7 +99,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
private static final String EXTRA_UPDATE_COUNTRIES = ".extra.update.countries";
|
||||
|
||||
private static final String[] DOCKED_FRAGMENTS = { SearchFragment.class.getName(),
|
||||
DownloadFragment.class.getName(),
|
||||
OldDownloadFragment.class.getName(),
|
||||
RoutingPlanFragment.class.getName(),
|
||||
EditorHostFragment.class.getName() };
|
||||
// Instance state
|
||||
|
@ -298,32 +300,32 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
Statistics.INSTANCE.trackEvent(Statistics.EventName.DOWNLOADER_MIGRATE_PERFORMED);
|
||||
|
||||
RoutingController.get().cancel();
|
||||
ActiveCountryTree.migrate();
|
||||
MapManager.nativeMigrate();
|
||||
showDownloader(false);
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showDownloader(boolean openDownloadedList)
|
||||
public void showDownloader(boolean openDownloaded)
|
||||
{
|
||||
if (ActiveCountryTree.isLegacyMode())
|
||||
if (MapManager.nativeIsLegacyMode())
|
||||
{
|
||||
showMigrateDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
final Bundle args = new Bundle();
|
||||
args.putBoolean(DownloadActivity.EXTRA_OPEN_DOWNLOADED_LIST, openDownloadedList);
|
||||
args.putBoolean(DownloaderActivity.EXTRA_OPEN_DOWNLOADED, openDownloaded);
|
||||
if (mIsFragmentContainer)
|
||||
{
|
||||
SearchEngine.cancelSearch();
|
||||
mSearchController.refreshToolbar();
|
||||
replaceFragment(DownloadFragment.class, args, null);
|
||||
replaceFragment(DownloaderFragment.class, args, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
startActivity(new Intent(this, DownloadActivity.class).putExtras(args));
|
||||
startActivity(new Intent(this, DownloaderActivity.class).putExtras(args));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -661,7 +663,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
addTask(intent);
|
||||
else if (intent.hasExtra(EXTRA_UPDATE_COUNTRIES))
|
||||
{
|
||||
ActiveCountryTree.updateAll();
|
||||
OldActiveCountryTree.updateAll();
|
||||
showDownloader(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,12 @@ import android.util.Log;
|
|||
import java.io.File;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.mapswithme.country.ActiveCountryTree;
|
||||
import com.mapswithme.country.CountryItem;
|
||||
import com.mapswithme.maps.downloader.country.OldActiveCountryTree;
|
||||
import com.mapswithme.maps.downloader.country.OldCountryItem;
|
||||
import com.mapswithme.maps.background.AppBackgroundTracker;
|
||||
import com.mapswithme.maps.background.Notifier;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
||||
import com.mapswithme.maps.downloader.country.OldMapStorage;
|
||||
import com.mapswithme.maps.editor.Editor;
|
||||
import com.mapswithme.maps.location.TrackRecorder;
|
||||
import com.mapswithme.maps.sound.TtsPlayer;
|
||||
|
@ -33,7 +34,7 @@ import com.parse.ParseInstallation;
|
|||
import com.parse.SaveCallback;
|
||||
|
||||
public class MwmApplication extends Application
|
||||
implements ActiveCountryTree.ActiveCountryListener
|
||||
implements OldActiveCountryTree.ActiveCountryListener
|
||||
{
|
||||
private final static String TAG = "MwmApplication";
|
||||
|
||||
|
@ -85,19 +86,19 @@ public class MwmApplication extends Application
|
|||
public void onCountryStatusChanged(int group, int position, int oldStatus, int newStatus)
|
||||
{
|
||||
Notifier.cancelDownloadSuggest();
|
||||
if (newStatus == MapStorage.DOWNLOAD_FAILED)
|
||||
if (newStatus == OldMapStorage.DOWNLOAD_FAILED)
|
||||
{
|
||||
CountryItem item = ActiveCountryTree.getCountryItem(group, position);
|
||||
Notifier.notifyDownloadFailed(ActiveCountryTree.getCoreIndex(group, position), item.getName());
|
||||
OldCountryItem item = OldActiveCountryTree.getCountryItem(group, position);
|
||||
Notifier.notifyDownloadFailed(OldActiveCountryTree.getCoreIndex(group, position), item.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCountryGroupChanged(int oldGroup, int oldPosition, int newGroup, int newPosition)
|
||||
{
|
||||
if (oldGroup == ActiveCountryTree.GROUP_NEW && newGroup == ActiveCountryTree.GROUP_UP_TO_DATE)
|
||||
if (oldGroup == OldActiveCountryTree.GROUP_NEW && newGroup == OldActiveCountryTree.GROUP_UP_TO_DATE)
|
||||
Statistics.INSTANCE.trackMapChanged(Statistics.EventName.MAP_DOWNLOADED);
|
||||
else if (oldGroup == ActiveCountryTree.GROUP_OUT_OF_DATE && newGroup == ActiveCountryTree.GROUP_UP_TO_DATE)
|
||||
else if (oldGroup == OldActiveCountryTree.GROUP_OUT_OF_DATE && newGroup == OldActiveCountryTree.GROUP_UP_TO_DATE)
|
||||
Statistics.INSTANCE.trackMapChanged(Statistics.EventName.MAP_UPDATED);
|
||||
}
|
||||
|
||||
|
@ -127,7 +128,7 @@ public class MwmApplication extends Application
|
|||
return;
|
||||
|
||||
nativeInitFramework();
|
||||
ActiveCountryTree.addListener(this);
|
||||
//OldActiveCountryTree.addListener(this);
|
||||
initNativeStrings();
|
||||
BookmarkManager.nativeLoadBookmarks();
|
||||
TtsPlayer.INSTANCE.init(this);
|
||||
|
@ -209,23 +210,6 @@ public class MwmApplication extends Application
|
|||
System.loadLibrary("mapswithme");
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes native Platform with paths. Should be called before usage of any other native components.
|
||||
*/
|
||||
private native void nativeInitPlatform(String apkPath, String storagePath, String tmpPath, String obbGooglePath,
|
||||
String flavorName, String buildType, boolean isYota, boolean isTablet);
|
||||
|
||||
private native void nativeInitFramework();
|
||||
|
||||
private native void nativeAddLocalization(String name, String value);
|
||||
|
||||
/**
|
||||
* Check if device have at least {@code size} bytes free.
|
||||
*/
|
||||
public native boolean hasFreeSpace(long size);
|
||||
|
||||
private native void runNativeFunctor(final long functorPointer);
|
||||
|
||||
/*
|
||||
* init Parse SDK
|
||||
*/
|
||||
|
@ -276,22 +260,34 @@ public class MwmApplication extends Application
|
|||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void runNativeFunctorOnUiThread(final long functorPointer)
|
||||
void processFunctor(final long functorPointer)
|
||||
{
|
||||
Message m = Message.obtain(mMainLoopHandler, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
runNativeFunctor(functorPointer);
|
||||
nativeProcessFunctor(functorPointer);
|
||||
}
|
||||
});
|
||||
m.obj = mMainQueueToken;
|
||||
mMainLoopHandler.sendMessage(m);
|
||||
}
|
||||
|
||||
public void clearFunctorsOnUiThread()
|
||||
void clearFunctorsOnUiThread()
|
||||
{
|
||||
mMainLoopHandler.removeCallbacksAndMessages(mMainQueueToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes native Platform with paths. Should be called before usage of any other native components.
|
||||
*/
|
||||
private native void nativeInitPlatform(String apkPath, String storagePath, String tmpPath, String obbGooglePath,
|
||||
String flavorName, String buildType, boolean isYota, boolean isTablet);
|
||||
|
||||
private static native void nativeInitFramework();
|
||||
|
||||
private static native void nativeAddLocalization(String name, String value);
|
||||
|
||||
private static native void nativeProcessFunctor(long functorPointer);
|
||||
}
|
|
@ -7,7 +7,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
|
||||
import com.mapswithme.maps.MapStorage.Index;
|
||||
import com.mapswithme.maps.downloader.country.OldMapStorage.Index;
|
||||
import com.mapswithme.maps.MwmActivity;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
|
|
|
@ -9,10 +9,10 @@ import android.location.LocationManager;
|
|||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mapswithme.country.ActiveCountryTree;
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.downloader.MapManager;
|
||||
import com.mapswithme.maps.editor.Editor;
|
||||
import com.mapswithme.util.LocationUtils;
|
||||
|
||||
|
@ -92,7 +92,7 @@ public class WorkerService extends IntentService
|
|||
}
|
||||
private static void handleActionCheckUpdate()
|
||||
{
|
||||
if (!Framework.nativeIsDataVersionChanged() || ActiveCountryTree.isLegacyMode())
|
||||
if (!Framework.nativeIsDataVersionChanged() || MapManager.nativeIsLegacyMode())
|
||||
return;
|
||||
|
||||
final String countriesToUpdate = Framework.nativeGetOutdatedCountriesString();
|
||||
|
@ -104,7 +104,7 @@ public class WorkerService extends IntentService
|
|||
|
||||
private void handleActionCheckLocation()
|
||||
{
|
||||
if (ActiveCountryTree.isLegacyMode())
|
||||
if (MapManager.nativeIsLegacyMode())
|
||||
return;
|
||||
|
||||
final long delayMillis = 60000; // 60 seconds
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package com.mapswithme.country;
|
||||
package com.mapswithme.maps.downloader.country;
|
||||
|
||||
import com.mapswithme.maps.MapStorage.Index;
|
||||
import com.mapswithme.maps.downloader.country.OldMapStorage.Index;
|
||||
|
||||
@Deprecated
|
||||
public class ActiveCountryTree
|
||||
public class OldActiveCountryTree
|
||||
{
|
||||
private ActiveCountryTree() {}
|
||||
private OldActiveCountryTree() {}
|
||||
|
||||
public interface ActiveCountryListener extends CountryTree.BaseListener
|
||||
public interface ActiveCountryListener extends OldCountryTree.BaseListener
|
||||
{
|
||||
void onCountryProgressChanged(int group, int position, long[] sizes);
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class ActiveCountryTree
|
|||
return getCountInGroup(GROUP_OUT_OF_DATE) + getCountInGroup(GROUP_UP_TO_DATE);
|
||||
}
|
||||
|
||||
public static native CountryItem getCountryItem(int group, int position);
|
||||
public static native OldCountryItem getCountryItem(int group, int position);
|
||||
|
||||
// returns array of two elements : local and remote size.
|
||||
public static native long getCountrySize(int group, int position, int options, boolean isLocal);
|
|
@ -1,9 +1,8 @@
|
|||
package com.mapswithme.country;
|
||||
package com.mapswithme.maps.downloader.country;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Color;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
|
@ -21,7 +20,6 @@ import android.widget.TextView;
|
|||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import com.mapswithme.maps.MapStorage;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.downloader.DownloadHelper;
|
||||
import com.mapswithme.maps.widget.WheelProgressView;
|
||||
|
@ -32,7 +30,7 @@ import com.mapswithme.util.UiUtils;
|
|||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
||||
@Deprecated
|
||||
abstract class BaseDownloadAdapter extends BaseAdapter
|
||||
public abstract class OldBaseDownloadAdapter extends BaseAdapter
|
||||
{
|
||||
static final int TYPE_GROUP = 0;
|
||||
static final int TYPE_COUNTRY_GROUP = 1;
|
||||
|
@ -49,9 +47,9 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
|
||||
private static class SafeAdapterRunnable implements Runnable
|
||||
{
|
||||
private final WeakReference<BaseDownloadAdapter> mAdapterReference;
|
||||
private final WeakReference<OldBaseDownloadAdapter> mAdapterReference;
|
||||
|
||||
private SafeAdapterRunnable(BaseDownloadAdapter adapter)
|
||||
private SafeAdapterRunnable(OldBaseDownloadAdapter adapter)
|
||||
{
|
||||
mAdapterReference = new WeakReference<>(adapter);
|
||||
}
|
||||
|
@ -59,7 +57,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
@Override
|
||||
public void run()
|
||||
{
|
||||
final BaseDownloadAdapter adapter = mAdapterReference.get();
|
||||
final OldBaseDownloadAdapter adapter = mAdapterReference.get();
|
||||
if (adapter == null)
|
||||
return;
|
||||
|
||||
|
@ -73,7 +71,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
private final SafeAdapterRunnable mDatasetChangedRunnable = new SafeAdapterRunnable(this);
|
||||
|
||||
final LayoutInflater mInflater;
|
||||
final DownloadFragment mFragment;
|
||||
final OldDownloadFragment mFragment;
|
||||
|
||||
private final String mStatusDownloaded;
|
||||
private final String mStatusFailed;
|
||||
|
@ -86,10 +84,10 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
private final int mColorNotDownloaded;
|
||||
private final int mColorFailed;
|
||||
|
||||
BaseDownloadAdapter(DownloadFragment fragment)
|
||||
OldBaseDownloadAdapter(OldDownloadFragment fragment)
|
||||
{
|
||||
mFragment = fragment;
|
||||
mInflater = mFragment.getLayoutInflater();
|
||||
mInflater = mFragment.getLayoutInflater(null);
|
||||
|
||||
mStatusDownloaded = mFragment.getString(R.string.downloader_downloaded).toUpperCase();
|
||||
mStatusFailed = mFragment.getString(R.string.downloader_status_failed).toUpperCase();
|
||||
|
@ -97,10 +95,10 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
mStatusNotDownloaded = mFragment.getString(R.string.download).toUpperCase();
|
||||
mMapOnly = mFragment.getString(R.string.downloader_map_only).toUpperCase();
|
||||
|
||||
mColorDownloaded = ThemeUtils.getColor(mInflater.getContext(), R.attr.countryDownloaded);
|
||||
mColorOutdated = ThemeUtils.getColor(mInflater.getContext(), R.attr.countryOutdated);
|
||||
mColorNotDownloaded = ThemeUtils.getColor(mInflater.getContext(), R.attr.countryNotDownloaded);
|
||||
mColorFailed = ThemeUtils.getColor(mInflater.getContext(), R.attr.countryFailed);
|
||||
mColorDownloaded = Color.BLACK;
|
||||
mColorOutdated = Color.GRAY;
|
||||
mColorNotDownloaded = Color.MAGENTA;
|
||||
mColorFailed = Color.RED;
|
||||
}
|
||||
|
||||
public abstract void onItemClick(int position, View view);
|
||||
|
@ -137,7 +135,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
public abstract boolean onBackPressed();
|
||||
|
||||
@Override
|
||||
public abstract CountryItem getItem(int position);
|
||||
public abstract OldCountryItem getItem(int position);
|
||||
|
||||
protected int adjustPosition(int position)
|
||||
{
|
||||
|
@ -152,7 +150,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
private void processNotDownloaded(final String name, final int position, final int newOptions, final ViewHolder holder)
|
||||
{
|
||||
final long[] remoteSizes = getRemoteItemSizes(adjustPosition(position));
|
||||
final long size = newOptions > StorageOptions.MAP_OPTION_MAP_ONLY ? remoteSizes[0] : remoteSizes[1];
|
||||
final long size = newOptions > OldStorageOptions.MAP_OPTION_MAP_ONLY ? remoteSizes[0] : remoteSizes[1];
|
||||
DownloadHelper.downloadWithCellularCheck(mFragment.getActivity(), size, name, new DownloadHelper.OnDownloadListener()
|
||||
{
|
||||
@Override
|
||||
|
@ -167,7 +165,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
private void processOutOfDate(final String name, final int position, final int newOptions)
|
||||
{
|
||||
final long[] remoteSizes = getRemoteItemSizes(position);
|
||||
final long size = newOptions > StorageOptions.MAP_OPTION_MAP_ONLY ? remoteSizes[0] : remoteSizes[1];
|
||||
final long size = newOptions > OldStorageOptions.MAP_OPTION_MAP_ONLY ? remoteSizes[0] : remoteSizes[1];
|
||||
DownloadHelper.downloadWithCellularCheck(mFragment.getActivity(), size, name, new DownloadHelper.OnDownloadListener()
|
||||
{
|
||||
@Override
|
||||
|
@ -221,7 +219,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
@Override
|
||||
public int getItemViewType(int position)
|
||||
{
|
||||
final CountryItem item = getItem(position);
|
||||
final OldCountryItem item = getItem(position);
|
||||
if (item != null)
|
||||
return item.getType();
|
||||
return TYPE_GROUP;
|
||||
|
@ -256,7 +254,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
|
||||
void initFromView(View v)
|
||||
{
|
||||
mName = (TextView) v.findViewById(R.id.title);
|
||||
/*mName = (TextView) v.findViewById(R.id.title);
|
||||
mProgress = (WheelProgressView) v.findViewById(R.id.download_progress);
|
||||
mPercent = (TextView) v.findViewById(R.id.tv__percent);
|
||||
mSize = (TextView) v.findViewById(R.id.tv__size);
|
||||
|
@ -265,7 +263,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
mSizeSlided = (TextView) v.findViewById(R.id.tv__size_slided);
|
||||
mInfoSlided = (LinearLayout) v.findViewById(R.id.ll__info_slided);
|
||||
mProgressSlided = (WheelProgressView) v.findViewById(R.id.download_progress_slided);
|
||||
mImageRoutingStatus = (ImageView) v.findViewById(R.id.iv__routing_status_slided);
|
||||
mImageRoutingStatus = (ImageView) v.findViewById(R.id.iv__routing_status_slided);*/
|
||||
}
|
||||
|
||||
void showDownloadingViews(boolean show)
|
||||
|
@ -358,7 +356,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
|
||||
private static int getLayoutForType(int type)
|
||||
{
|
||||
switch (type)
|
||||
/*switch (type)
|
||||
{
|
||||
case TYPE_GROUP:
|
||||
case TYPE_COUNTRY_GROUP:
|
||||
|
@ -367,14 +365,14 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
case TYPE_COUNTRY_READY:
|
||||
case TYPE_COUNTRY_NOT_DOWNLOADED:
|
||||
return R.layout.download_item_country;
|
||||
}
|
||||
}*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void bindCountry(final int position, final ViewHolder holder)
|
||||
{
|
||||
final CountryItem item = getItem(position);
|
||||
final OldCountryItem item = getItem(position);
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
|
@ -387,7 +385,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
long[] sizes;
|
||||
switch (item.getStatus())
|
||||
{
|
||||
case MapStorage.DOWNLOADING:
|
||||
case OldMapStorage.DOWNLOADING:
|
||||
UiUtils.hide(holder.mImageRoutingStatus, holder.mProgress, holder.mInfo, holder.mSize, holder.mProgress);
|
||||
UiUtils.show(holder.mInfoSlided, holder.mProgressSlided);
|
||||
holder.mProgressSlided.setOnClickListener(new View.OnClickListener()
|
||||
|
@ -404,11 +402,10 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
holder.setSizeText(0, sizes[1]);
|
||||
final int percent = (int) (sizes[0] * 100 / sizes[1]);
|
||||
holder.setPercentText(percent + "%");
|
||||
holder.setPercentColor(mFragment.getResources().getColor(R.color.downloader_gray));
|
||||
holder.setProgress(percent);
|
||||
break;
|
||||
|
||||
case MapStorage.ON_DISK_OUT_OF_DATE:
|
||||
case OldMapStorage.ON_DISK_OUT_OF_DATE:
|
||||
UiUtils.hide(holder.mProgress, holder.mProgressSlided, holder.mInfo);
|
||||
UiUtils.show(holder.mInfoSlided, holder.mImageRoutingStatus);
|
||||
holder.mInfoSlided.setOnClickListener(new View.OnClickListener()
|
||||
|
@ -428,22 +425,21 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
holder.setPercentColor(ThemeUtils.getColor(mListView.getContext(), R.attr.colorAccent));
|
||||
break;
|
||||
|
||||
case MapStorage.ON_DISK:
|
||||
case OldMapStorage.ON_DISK:
|
||||
UiUtils.hide(holder.mProgress, holder.mProgressSlided, holder.mInfo);
|
||||
UiUtils.show(holder.mInfoSlided, holder.mImageRoutingStatus);
|
||||
|
||||
bindCarRoutingIcon(holder, item);
|
||||
sizes = getRemoteItemSizes(adjustedPosition);
|
||||
if (item.getOptions() == StorageOptions.MAP_OPTION_MAP_ONLY)
|
||||
if (item.getOptions() == OldStorageOptions.MAP_OPTION_MAP_ONLY)
|
||||
holder.setPercentText(mMapOnly);
|
||||
else
|
||||
holder.setPercentText(mStatusDownloaded);
|
||||
|
||||
holder.setPercentColor(mFragment.getResources().getColor(R.color.downloader_gray));
|
||||
holder.setSizeText(0, sizes[0]);
|
||||
break;
|
||||
|
||||
case MapStorage.DOWNLOAD_FAILED:
|
||||
case OldMapStorage.DOWNLOAD_FAILED:
|
||||
UiUtils.show(holder.mInfoSlided, holder.mProgressSlided);
|
||||
UiUtils.hide(holder.mProgress, holder.mImageRoutingStatus, holder.mInfo, holder.mSize, holder.mPercent);
|
||||
|
||||
|
@ -466,7 +462,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
holder.setPercentColor(mColorFailed);
|
||||
break;
|
||||
|
||||
case MapStorage.IN_QUEUE:
|
||||
case OldMapStorage.IN_QUEUE:
|
||||
UiUtils.show(holder.mInfoSlided, holder.mProgressSlided);
|
||||
UiUtils.hide(holder.mProgress, holder.mImageRoutingStatus, holder.mInfo, holder.mSize, holder.mPercent);
|
||||
|
||||
|
@ -484,10 +480,9 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
sizes = getDownloadableItemSizes(adjustedPosition);
|
||||
holder.setSizeText(0, sizes[1]);
|
||||
holder.setPercentText(mFragment.getString(R.string.downloader_queued));
|
||||
holder.setPercentColor(mFragment.getResources().getColor(R.color.downloader_gray));
|
||||
break;
|
||||
|
||||
case MapStorage.NOT_DOWNLOADED:
|
||||
case OldMapStorage.NOT_DOWNLOADED:
|
||||
UiUtils.show(holder.mInfo, holder.mSize, holder.mPercent);
|
||||
UiUtils.hide(holder.mProgress, holder.mImageRoutingStatus, holder.mProgressSlided);
|
||||
UiUtils.invisible(holder.mInfoSlided);
|
||||
|
@ -500,12 +495,12 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
}
|
||||
}
|
||||
|
||||
private static void bindCarRoutingIcon(ViewHolder holder, CountryItem item)
|
||||
private static void bindCarRoutingIcon(ViewHolder holder, OldCountryItem item)
|
||||
{
|
||||
boolean night = ThemeUtils.isNightTheme();
|
||||
int icon = (item.getOptions() == StorageOptions.MAP_OPTION_MAP_ONLY) ? night ? R.drawable.ic_routing_get_night
|
||||
: R.drawable.ic_routing_get
|
||||
: night ? R.drawable.ic_routing_ok_night
|
||||
int icon = (item.getOptions() == OldStorageOptions.MAP_OPTION_MAP_ONLY) ? night ? R.drawable.ic_routing_get_night
|
||||
: R.drawable.ic_routing_get
|
||||
: night ? R.drawable.ic_routing_ok_night
|
||||
: R.drawable.ic_routing_ok;
|
||||
holder.mImageRoutingStatus.setImageResource(icon);
|
||||
}
|
||||
|
@ -513,10 +508,9 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
private void startItemDownloading(final ViewHolder holder, final int position, int newOptions)
|
||||
{
|
||||
holder.setPercentText(mFragment.getString(R.string.downloader_queued));
|
||||
holder.setPercentColor(mFragment.getResources().getColor(R.color.downloader_gray));
|
||||
holder.setProgress(0);
|
||||
holder.mProgress.setVisibility(View.VISIBLE);
|
||||
|
||||
/*
|
||||
ObjectAnimator animator = ObjectAnimator.ofFloat(holder.mProgress, PROPERTY_TRANSLATION_X, 0,
|
||||
-mFragment.getResources().getDimensionPixelOffset(R.dimen.progress_wheel_width));
|
||||
animator.setDuration(ANIMATION_LENGTH);
|
||||
|
@ -532,7 +526,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
}
|
||||
});
|
||||
|
||||
if (getItem(position).getStatus() == MapStorage.NOT_DOWNLOADED)
|
||||
if (getItem(position).getStatus() == OldMapStorage.NOT_DOWNLOADED)
|
||||
{
|
||||
ObjectAnimator infoAnimator = ObjectAnimator.ofFloat(holder.mInfo, PROPERTY_TRANSLATION_X, 0,
|
||||
-mFragment.getResources().getDimensionPixelOffset(R.dimen.progress_wheel_width));
|
||||
|
@ -546,15 +540,14 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
animatorSet.start();
|
||||
holder.animator = animatorSet;
|
||||
mActiveAnimationsCount++;
|
||||
|
||||
*/
|
||||
downloadCountry(adjustPosition(position), newOptions);
|
||||
}
|
||||
|
||||
private void startItemUpdating(final ViewHolder holder, int position, int options)
|
||||
{
|
||||
holder.setPercentText(mFragment.getString(R.string.downloader_queued));
|
||||
holder.setPercentColor(mFragment.getResources().getColor(R.color.downloader_gray));
|
||||
|
||||
/*
|
||||
final ObjectAnimator animator = ObjectAnimator.ofFloat(holder.mProgress, PROPERTY_TRANSLATION_X, 0,
|
||||
-mFragment.getResources().getDimensionPixelOffset(R.dimen.progress_wheel_width));
|
||||
animator.setDuration(ANIMATION_LENGTH);
|
||||
|
@ -573,15 +566,15 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
animator.start();
|
||||
holder.animator = animator;
|
||||
mActiveAnimationsCount++;
|
||||
|
||||
*/
|
||||
downloadCountry(position, options);
|
||||
}
|
||||
|
||||
private void stopItemDownloading(final ViewHolder holder, final int position)
|
||||
{
|
||||
final CountryItem item = getItem(position);
|
||||
/* final OldCountryItem item = getItem(position);
|
||||
mActiveAnimationsCount++;
|
||||
if (item.getStatus() == MapStorage.NOT_DOWNLOADED)
|
||||
if (item.getStatus() == OldMapStorage.NOT_DOWNLOADED)
|
||||
{
|
||||
ObjectAnimator animator = ObjectAnimator.ofFloat(holder.mInfoSlided, PROPERTY_TRANSLATION_X, 0,
|
||||
mFragment.getResources().getDimensionPixelOffset(R.dimen.progress_wheel_width));
|
||||
|
@ -608,7 +601,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
}
|
||||
else
|
||||
{
|
||||
if (item.getStatus() != MapStorage.DOWNLOADING)
|
||||
if (item.getStatus() != OldMapStorage.DOWNLOADING)
|
||||
{
|
||||
holder.mImageRoutingStatus.setVisibility(View.VISIBLE);
|
||||
bindCarRoutingIcon(holder, item);
|
||||
|
@ -633,7 +626,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
holder.animator = infoAnimator;
|
||||
}
|
||||
|
||||
mHandler.postDelayed(mDatasetChangedRunnable, ANIMATION_LENGTH);
|
||||
mHandler.postDelayed(mDatasetChangedRunnable, ANIMATION_LENGTH);*/
|
||||
cancelDownload(adjustPosition(position)); // cancel download before checking real item status(now its just DOWNLOADING or IN_QUEUE)
|
||||
}
|
||||
|
||||
|
@ -641,13 +634,13 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
{
|
||||
switch (status)
|
||||
{
|
||||
case MapStorage.ON_DISK_OUT_OF_DATE:
|
||||
case OldMapStorage.ON_DISK_OUT_OF_DATE:
|
||||
return mColorOutdated;
|
||||
|
||||
case MapStorage.NOT_DOWNLOADED:
|
||||
case OldMapStorage.NOT_DOWNLOADED:
|
||||
return mColorNotDownloaded;
|
||||
|
||||
case MapStorage.DOWNLOAD_FAILED:
|
||||
case OldMapStorage.DOWNLOAD_FAILED:
|
||||
return mColorFailed;
|
||||
|
||||
default:
|
||||
|
@ -658,7 +651,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
private void setItemName(int position, ViewHolder holder)
|
||||
{
|
||||
// set name and style
|
||||
final CountryItem item = getItem(position);
|
||||
final OldCountryItem item = getItem(position);
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
|
@ -672,13 +665,13 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
*/
|
||||
protected void onCountryStatusChanged(int position)
|
||||
{
|
||||
final CountryItem item = getItem(position);
|
||||
final OldCountryItem item = getItem(position);
|
||||
if (item != null && mFragment.isAdded())
|
||||
{
|
||||
// use this hard reset, because of caching different ViewHolders according to item's type
|
||||
mHandler.postDelayed(mDatasetChangedRunnable, ANIMATION_LENGTH);
|
||||
|
||||
if (item.getStatus() == MapStorage.DOWNLOAD_FAILED && mFragment.getListAdapter() == this)
|
||||
if (item.getStatus() == OldMapStorage.DOWNLOAD_FAILED && mFragment.getListAdapter() == this)
|
||||
UiUtils.checkConnectionAndShowAlert(mFragment.getActivity(), String.format(mFragment.getString(R.string.download_country_failed), item.getName()));
|
||||
}
|
||||
}
|
||||
|
@ -715,7 +708,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
return false;
|
||||
}
|
||||
|
||||
void onCountryClick(CountryItem countryItem, View anchor, final int position)
|
||||
void onCountryClick(OldCountryItem countryItem, View anchor, final int position)
|
||||
{
|
||||
if (countryItem == null || anchor.getParent() == null)
|
||||
return;
|
||||
|
@ -731,16 +724,16 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
|
||||
switch (status)
|
||||
{
|
||||
case MapStorage.DOWNLOADING:
|
||||
case MapStorage.IN_QUEUE:
|
||||
case OldMapStorage.DOWNLOADING:
|
||||
case OldMapStorage.IN_QUEUE:
|
||||
stopItemDownloading(holder, position);
|
||||
return;
|
||||
|
||||
case MapStorage.NOT_DOWNLOADED:
|
||||
processNotDownloaded(name, position, StorageOptions.MAP_OPTION_MAP_ONLY, holder);
|
||||
case OldMapStorage.NOT_DOWNLOADED:
|
||||
processNotDownloaded(name, position, OldStorageOptions.MAP_OPTION_MAP_ONLY, holder);
|
||||
return;
|
||||
|
||||
case MapStorage.DOWNLOAD_FAILED:
|
||||
case OldMapStorage.DOWNLOAD_FAILED:
|
||||
processFailed(holder, adjustedPosition);
|
||||
return;
|
||||
}
|
||||
|
@ -753,7 +746,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
switch (item.getItemId())
|
||||
{
|
||||
case MENU_DELETE:
|
||||
processOnDisk(name, adjustedPosition, StorageOptions.MAP_OPTION_MAP_ONLY);
|
||||
processOnDisk(name, adjustedPosition, OldStorageOptions.MAP_OPTION_MAP_ONLY);
|
||||
break;
|
||||
|
||||
case MENU_EXPLORE:
|
||||
|
@ -761,7 +754,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
break;
|
||||
|
||||
case MENU_UPDATE:
|
||||
processOutOfDate(name, adjustedPosition, StorageOptions.MAP_OPTION_MAP_ONLY);
|
||||
processOutOfDate(name, adjustedPosition, OldStorageOptions.MAP_OPTION_MAP_ONLY);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -775,13 +768,13 @@ abstract class BaseDownloadAdapter extends BaseAdapter
|
|||
.listener(menuItemClickListener);
|
||||
switch (status)
|
||||
{
|
||||
case MapStorage.ON_DISK_OUT_OF_DATE:
|
||||
case OldMapStorage.ON_DISK_OUT_OF_DATE:
|
||||
BottomSheetHelper.sheet(bs, MENU_UPDATE, R.drawable.ic_update,
|
||||
mFragment.getString(R.string.downloader_update_map) + ", " +
|
||||
StringUtils.getFileSizeString(remoteSizes[0]));
|
||||
// No break
|
||||
|
||||
case MapStorage.ON_DISK:
|
||||
case OldMapStorage.ON_DISK:
|
||||
bs.sheet(MENU_EXPLORE, R.drawable.ic_explore, R.string.zoom_to_country);
|
||||
|
||||
bs.sheet(MENU_DELETE, R.drawable.ic_delete, R.string.downloader_delete_map);
|
|
@ -1,13 +1,11 @@
|
|||
package com.mapswithme.country;
|
||||
package com.mapswithme.maps.downloader.country;
|
||||
|
||||
import android.graphics.Typeface;
|
||||
|
||||
import com.mapswithme.maps.MapStorage;
|
||||
|
||||
@Deprecated
|
||||
public class CountryItem
|
||||
public class OldCountryItem
|
||||
{
|
||||
public static final CountryItem EMPTY = new CountryItem("", MapStorage.NOT_DOWNLOADED, StorageOptions.MAP_OPTION_MAP_ONLY, false);
|
||||
public static final OldCountryItem EMPTY = new OldCountryItem("", OldMapStorage.NOT_DOWNLOADED, OldStorageOptions.MAP_OPTION_MAP_ONLY, false);
|
||||
|
||||
private String mName;
|
||||
private int mOptions;
|
||||
|
@ -17,7 +15,7 @@ public class CountryItem
|
|||
private static final Typeface LIGHT = Typeface.create("sans-serif-light", Typeface.NORMAL);
|
||||
private static final Typeface REGULAR = Typeface.create("sans-serif", Typeface.NORMAL);
|
||||
|
||||
public CountryItem(String name, int status, int options, boolean hasChildren)
|
||||
public OldCountryItem(String name, int status, int options, boolean hasChildren)
|
||||
{
|
||||
mName = name;
|
||||
mStatus = status;
|
||||
|
@ -64,10 +62,10 @@ public class CountryItem
|
|||
{
|
||||
switch (mStatus)
|
||||
{
|
||||
case MapStorage.NOT_DOWNLOADED:
|
||||
case MapStorage.DOWNLOADING:
|
||||
case MapStorage.IN_QUEUE:
|
||||
case MapStorage.DOWNLOAD_FAILED:
|
||||
case OldMapStorage.NOT_DOWNLOADED:
|
||||
case OldMapStorage.DOWNLOADING:
|
||||
case OldMapStorage.IN_QUEUE:
|
||||
case OldMapStorage.DOWNLOAD_FAILED:
|
||||
return LIGHT;
|
||||
default:
|
||||
return REGULAR;
|
||||
|
@ -77,21 +75,21 @@ public class CountryItem
|
|||
public int getType()
|
||||
{
|
||||
if (mHasChildren)
|
||||
return DownloadAdapter.TYPE_GROUP;
|
||||
return OldDownloadAdapter.TYPE_GROUP;
|
||||
|
||||
switch (mStatus)
|
||||
{
|
||||
case MapStorage.GROUP:
|
||||
return DownloadAdapter.TYPE_GROUP;
|
||||
case MapStorage.COUNTRY:
|
||||
return DownloadAdapter.TYPE_COUNTRY_GROUP;
|
||||
case MapStorage.NOT_DOWNLOADED:
|
||||
return DownloadAdapter.TYPE_COUNTRY_NOT_DOWNLOADED;
|
||||
case MapStorage.ON_DISK:
|
||||
case MapStorage.ON_DISK_OUT_OF_DATE:
|
||||
return DownloadAdapter.TYPE_COUNTRY_READY;
|
||||
case OldMapStorage.GROUP:
|
||||
return OldDownloadAdapter.TYPE_GROUP;
|
||||
case OldMapStorage.COUNTRY:
|
||||
return OldDownloadAdapter.TYPE_COUNTRY_GROUP;
|
||||
case OldMapStorage.NOT_DOWNLOADED:
|
||||
return OldDownloadAdapter.TYPE_COUNTRY_NOT_DOWNLOADED;
|
||||
case OldMapStorage.ON_DISK:
|
||||
case OldMapStorage.ON_DISK_OUT_OF_DATE:
|
||||
return OldDownloadAdapter.TYPE_COUNTRY_READY;
|
||||
default:
|
||||
return DownloadAdapter.TYPE_COUNTRY_IN_PROCESS;
|
||||
return OldDownloadAdapter.TYPE_COUNTRY_IN_PROCESS;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package com.mapswithme.country;
|
||||
package com.mapswithme.maps.downloader.country;
|
||||
|
||||
@Deprecated
|
||||
public class CountryTree
|
||||
public class OldCountryTree
|
||||
{
|
||||
// interface for listening callbacks from native
|
||||
public interface BaseListener {}
|
||||
|
@ -13,7 +13,7 @@ public class CountryTree
|
|||
void onItemStatusChanged(int position);
|
||||
}
|
||||
|
||||
private CountryTree() {}
|
||||
private OldCountryTree() {}
|
||||
|
||||
public static native void setDefaultRoot();
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class CountryTree
|
|||
|
||||
public static native int getChildCount();
|
||||
|
||||
public static native CountryItem getChildItem(int position);
|
||||
public static native OldCountryItem getChildItem(int position);
|
||||
|
||||
public static native void downloadCountry(int position, int options);
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.mapswithme.country;
|
||||
package com.mapswithme.maps.downloader.country;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
@ -7,7 +7,7 @@ import android.support.v4.app.FragmentTransaction;
|
|||
import com.mapswithme.maps.base.BaseMwmFragmentActivity;
|
||||
|
||||
@Deprecated
|
||||
public class DownloadActivity extends BaseMwmFragmentActivity
|
||||
public class OldDownloadActivity extends BaseMwmFragmentActivity
|
||||
{
|
||||
public static final String EXTRA_OPEN_DOWNLOADED_LIST = "open_downloaded";
|
||||
|
||||
|
@ -16,9 +16,9 @@ public class DownloadActivity extends BaseMwmFragmentActivity
|
|||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final String fragmentClassName = DownloadFragment.class.getName();
|
||||
final String fragmentClassName = OldDownloadFragment.class.getName();
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
DownloadFragment downloadFragment = (DownloadFragment) Fragment.instantiate(this, fragmentClassName, getIntent().getExtras());
|
||||
OldDownloadFragment downloadFragment = (OldDownloadFragment) Fragment.instantiate(this, fragmentClassName, getIntent().getExtras());
|
||||
transaction.replace(android.R.id.content, downloadFragment, fragmentClassName);
|
||||
transaction.commit();
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class DownloadActivity extends BaseMwmFragmentActivity
|
|||
@Override
|
||||
public void onBackPressed()
|
||||
{
|
||||
DownloadFragment fragment = (DownloadFragment) getSupportFragmentManager().findFragmentByTag(DownloadFragment.class.getName());
|
||||
OldDownloadFragment fragment = (OldDownloadFragment) getSupportFragmentManager().findFragmentByTag(OldDownloadFragment.class.getName());
|
||||
if (fragment != null && fragment.onBackPressed())
|
||||
return;
|
||||
|
|
@ -1,15 +1,14 @@
|
|||
package com.mapswithme.country;
|
||||
package com.mapswithme.maps.downloader.country;
|
||||
|
||||
import android.database.DataSetObserver;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.util.Utils;
|
||||
|
||||
@Deprecated
|
||||
class DownloadAdapter extends BaseDownloadAdapter implements CountryTree.CountryTreeListener
|
||||
public class OldDownloadAdapter extends OldBaseDownloadAdapter implements OldCountryTree.CountryTreeListener
|
||||
{
|
||||
private static final int EXTENDED_VIEWS_COUNT = 2; // 3 more views at the top of baseadapter
|
||||
private static final int DOWNLOADED_ITEM_POSITION = 0;
|
||||
|
@ -19,7 +18,7 @@ class DownloadAdapter extends BaseDownloadAdapter implements CountryTree.Country
|
|||
|
||||
private int mLastDownloadedCount = -1;
|
||||
|
||||
private static class ViewHolder extends BaseDownloadAdapter.ViewHolder
|
||||
private static class ViewHolder extends OldBaseDownloadAdapter.ViewHolder
|
||||
{
|
||||
TextView tvCount;
|
||||
|
||||
|
@ -27,7 +26,7 @@ class DownloadAdapter extends BaseDownloadAdapter implements CountryTree.Country
|
|||
void initFromView(View v)
|
||||
{
|
||||
super.initFromView(v);
|
||||
tvCount = (TextView) v.findViewById(R.id.tv__count);
|
||||
//tvCount = (TextView) v.findViewById(R.id.tv__count);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,10 +48,10 @@ class DownloadAdapter extends BaseDownloadAdapter implements CountryTree.Country
|
|||
return position;
|
||||
}
|
||||
|
||||
DownloadAdapter(DownloadFragment fragment)
|
||||
public OldDownloadAdapter(OldDownloadFragment fragment)
|
||||
{
|
||||
super(fragment);
|
||||
CountryTree.setDefaultRoot();
|
||||
OldCountryTree.setDefaultRoot();
|
||||
|
||||
mFragment.getDownloadedAdapter().registerDataSetObserver(new DataSetObserver()
|
||||
{
|
||||
|
@ -117,7 +116,7 @@ class DownloadAdapter extends BaseDownloadAdapter implements CountryTree.Country
|
|||
{
|
||||
final View view = getExtendedView(parent);
|
||||
holder.initFromView(view);
|
||||
final int count = ActiveCountryTree.getOutOfDateCount();
|
||||
final int count = OldActiveCountryTree.getOutOfDateCount();
|
||||
if (count > 0)
|
||||
{
|
||||
holder.tvCount.setVisibility(View.VISIBLE);
|
||||
|
@ -134,12 +133,12 @@ class DownloadAdapter extends BaseDownloadAdapter implements CountryTree.Country
|
|||
|
||||
private View getPlaceholderView(ViewGroup parent)
|
||||
{
|
||||
return mInflater.inflate(R.layout.download_item_placeholder, parent, false);
|
||||
return null;//mInflater.inflate(R.layout.download_item_placeholder, parent, false);
|
||||
}
|
||||
|
||||
private View getExtendedView(ViewGroup parent)
|
||||
{
|
||||
return mInflater.inflate(R.layout.download_item_extended, parent, false);
|
||||
return null;//mInflater.inflate(R.layout.download_item_extended, parent, false);
|
||||
}
|
||||
|
||||
private void onDownloadedCountChanged(int newCount)
|
||||
|
@ -157,7 +156,7 @@ class DownloadAdapter extends BaseDownloadAdapter implements CountryTree.Country
|
|||
if (mLastDownloadedCount == -1)
|
||||
mLastDownloadedCount = mFragment.getDownloadedAdapter().getCount();
|
||||
|
||||
return !CountryTree.hasParent() && (mLastDownloadedCount > 0);
|
||||
return !OldCountryTree.hasParent() && (mLastDownloadedCount > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -166,7 +165,7 @@ class DownloadAdapter extends BaseDownloadAdapter implements CountryTree.Country
|
|||
if (position >= getCount())
|
||||
return; // we have reports at GP that it crashes.
|
||||
|
||||
final CountryItem item = getItem(position);
|
||||
final OldCountryItem item = getItem(position);
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
|
@ -179,7 +178,7 @@ class DownloadAdapter extends BaseDownloadAdapter implements CountryTree.Country
|
|||
@Override
|
||||
public int getCount()
|
||||
{
|
||||
int res = CountryTree.getChildCount();
|
||||
int res = OldCountryTree.getChildCount();
|
||||
|
||||
if (hasHeaderItems())
|
||||
res += EXTENDED_VIEWS_COUNT;
|
||||
|
@ -188,15 +187,15 @@ class DownloadAdapter extends BaseDownloadAdapter implements CountryTree.Country
|
|||
}
|
||||
|
||||
@Override
|
||||
public CountryItem getItem(int position)
|
||||
public OldCountryItem getItem(int position)
|
||||
{
|
||||
return CountryTree.getChildItem(adjustPosition(position));
|
||||
return OldCountryTree.getChildItem(adjustPosition(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showCountry(int position)
|
||||
{
|
||||
CountryTree.showLeafOnMap(position);
|
||||
OldCountryTree.showLeafOnMap(position);
|
||||
resetCountryListener();
|
||||
Utils.navigateToParent(mFragment.getActivity());
|
||||
}
|
||||
|
@ -204,17 +203,17 @@ class DownloadAdapter extends BaseDownloadAdapter implements CountryTree.Country
|
|||
@Override
|
||||
protected void expandGroup(int position)
|
||||
{
|
||||
CountryTree.setChildAsRoot(position);
|
||||
OldCountryTree.setChildAsRoot(position);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed()
|
||||
{
|
||||
if (!CountryTree.hasParent())
|
||||
if (!OldCountryTree.hasParent())
|
||||
return false;
|
||||
|
||||
CountryTree.setParentAsRoot();
|
||||
OldCountryTree.setParentAsRoot();
|
||||
notifyDataSetChanged();
|
||||
return true;
|
||||
}
|
||||
|
@ -222,57 +221,57 @@ class DownloadAdapter extends BaseDownloadAdapter implements CountryTree.Country
|
|||
@Override
|
||||
protected void deleteCountry(int position, int options)
|
||||
{
|
||||
CountryTree.deleteCountry(position, options);
|
||||
OldCountryTree.deleteCountry(position, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long[] getRemoteItemSizes(int position)
|
||||
{
|
||||
long mapOnly = CountryTree.getLeafSize(position, StorageOptions.MAP_OPTION_MAP_ONLY, false);
|
||||
return new long[] { mapOnly, mapOnly + CountryTree.getLeafSize(position, StorageOptions.MAP_OPTION_CAR_ROUTING, false) };
|
||||
long mapOnly = OldCountryTree.getLeafSize(position, OldStorageOptions.MAP_OPTION_MAP_ONLY, false);
|
||||
return new long[] { mapOnly, mapOnly + OldCountryTree.getLeafSize(position, OldStorageOptions.MAP_OPTION_CAR_ROUTING, false) };
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long[] getDownloadableItemSizes(int position)
|
||||
{
|
||||
return new long[] { CountryTree.getLeafSize(position, -1, true),
|
||||
CountryTree.getLeafSize(position, -1, false) };
|
||||
return new long[] { OldCountryTree.getLeafSize(position, -1, true),
|
||||
OldCountryTree.getLeafSize(position, -1, false) };
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cancelDownload(int position)
|
||||
{
|
||||
CountryTree.cancelDownloading(position);
|
||||
OldCountryTree.cancelDownloading(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void retryDownload(int position)
|
||||
{
|
||||
CountryTree.retryDownloading(position);
|
||||
OldCountryTree.retryDownloading(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setCountryListener()
|
||||
{
|
||||
CountryTree.setListener(this);
|
||||
OldCountryTree.setListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void resetCountryListener()
|
||||
{
|
||||
CountryTree.resetListener();
|
||||
OldCountryTree.resetListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateCountry(int position, int options)
|
||||
{
|
||||
CountryTree.downloadCountry(position, options);
|
||||
OldCountryTree.downloadCountry(position, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void downloadCountry(int position, int options)
|
||||
{
|
||||
CountryTree.downloadCountry(position, options);
|
||||
OldCountryTree.downloadCountry(position, options);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,4 +1,4 @@
|
|||
package com.mapswithme.country;
|
||||
package com.mapswithme.maps.downloader.country;
|
||||
|
||||
import android.database.DataSetObserver;
|
||||
import android.os.Bundle;
|
||||
|
@ -12,17 +12,15 @@ import android.widget.TextView;
|
|||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmListFragment;
|
||||
import com.mapswithme.maps.base.OnBackPressListener;
|
||||
import com.mapswithme.util.Config;
|
||||
import com.mapswithme.util.ThemeUtils;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.Utils;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
||||
@Deprecated
|
||||
public class DownloadFragment extends BaseMwmListFragment implements View.OnClickListener, ActiveCountryTree.ActiveCountryListener, OnBackPressListener
|
||||
public class OldDownloadFragment extends BaseMwmListFragment implements View.OnClickListener, OldActiveCountryTree.ActiveCountryListener, OnBackPressListener
|
||||
{
|
||||
private DownloadAdapter mDownloadAdapter;
|
||||
private DownloadedAdapter mDownloadedAdapter;
|
||||
private OldDownloadAdapter mDownloadAdapter;
|
||||
private OldDownloadedAdapter mDownloadedAdapter;
|
||||
private TextView mTvUpdateAll;
|
||||
private View mDownloadAll;
|
||||
private int mMode = MODE_NONE;
|
||||
|
@ -33,30 +31,10 @@ public class DownloadFragment extends BaseMwmListFragment implements View.OnClic
|
|||
private static final int MODE_UPDATE_ALL = 1;
|
||||
private static final int MODE_CANCEL_ALL = 2;
|
||||
|
||||
private static int getTheme()
|
||||
{
|
||||
String theme = Config.getCurrentUiTheme();
|
||||
if (ThemeUtils.isDefaultTheme(theme))
|
||||
return R.style.MwmTheme_Downloader;
|
||||
|
||||
if (ThemeUtils.isNightTheme(theme))
|
||||
return R.style.MwmTheme_Night_Downloader;
|
||||
|
||||
throw new IllegalArgumentException("Attempt to apply unsupported theme: " + theme);
|
||||
}
|
||||
|
||||
LayoutInflater getLayoutInflater()
|
||||
{
|
||||
if (mLayoutInflater == null)
|
||||
mLayoutInflater = ThemeUtils.themedInflater(getActivity().getLayoutInflater(), getTheme());
|
||||
|
||||
return mLayoutInflater;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||
{
|
||||
return getLayoutInflater().inflate(R.layout.fragment_downloader, container, false);
|
||||
return inflater.inflate(R.layout.fragment_downloader, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,14 +42,14 @@ public class DownloadFragment extends BaseMwmListFragment implements View.OnClic
|
|||
{
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
initToolbar();
|
||||
if (getArguments() != null && getArguments().getBoolean(DownloadActivity.EXTRA_OPEN_DOWNLOADED_LIST, false))
|
||||
if (getArguments() != null && getArguments().getBoolean(OldDownloadActivity.EXTRA_OPEN_DOWNLOADED_LIST, false))
|
||||
openDownloadedList();
|
||||
else
|
||||
{
|
||||
mDownloadAdapter = getDownloadAdapter();
|
||||
setListAdapter(mDownloadAdapter);
|
||||
mMode = MODE_NONE;
|
||||
mListenerSlotId = ActiveCountryTree.addListener(this);
|
||||
mListenerSlotId = OldActiveCountryTree.addListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +66,7 @@ public class DownloadFragment extends BaseMwmListFragment implements View.OnClic
|
|||
}
|
||||
});
|
||||
|
||||
mTvUpdateAll = (TextView) toolbar.findViewById(R.id.tv__update_all);
|
||||
//mTvUpdateAll = (TextView) toolbar.findViewById(R.id.tv__update_all);
|
||||
mTvUpdateAll.setOnClickListener(this);
|
||||
|
||||
mDownloadAll = toolbar.findViewById(R.id.download_all);
|
||||
|
@ -101,7 +79,7 @@ public class DownloadFragment extends BaseMwmListFragment implements View.OnClic
|
|||
{
|
||||
super.onDestroy();
|
||||
|
||||
ActiveCountryTree.removeListener(mListenerSlotId);
|
||||
OldActiveCountryTree.removeListener(mListenerSlotId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -128,7 +106,7 @@ public class DownloadFragment extends BaseMwmListFragment implements View.OnClic
|
|||
setSelection(0);
|
||||
updateToolbar();
|
||||
}
|
||||
else if (getListAdapter() instanceof DownloadedAdapter)
|
||||
else if (getListAdapter() instanceof OldDownloadedAdapter)
|
||||
{
|
||||
mMode = MODE_NONE;
|
||||
mDownloadedAdapter.onPause();
|
||||
|
@ -152,7 +130,7 @@ public class DownloadFragment extends BaseMwmListFragment implements View.OnClic
|
|||
if (mMode == MODE_NONE)
|
||||
{
|
||||
mTvUpdateAll.setVisibility(View.GONE);
|
||||
UiUtils.showIf(CountryTree.hasParent() && CountryTree.isDownloadableGroup(), mDownloadAll);
|
||||
UiUtils.showIf(OldCountryTree.hasParent() && OldCountryTree.isDownloadableGroup(), mDownloadAll);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -173,9 +151,9 @@ public class DownloadFragment extends BaseMwmListFragment implements View.OnClic
|
|||
|
||||
private void updateMode()
|
||||
{
|
||||
if (ActiveCountryTree.isDownloadingActive())
|
||||
if (OldActiveCountryTree.isDownloadingActive())
|
||||
mMode = MODE_CANCEL_ALL;
|
||||
else if (ActiveCountryTree.getOutOfDateCount() > 0)
|
||||
else if (OldActiveCountryTree.getOutOfDateCount() > 0)
|
||||
mMode = MODE_UPDATE_ALL;
|
||||
else
|
||||
mMode = MODE_NONE;
|
||||
|
@ -184,7 +162,7 @@ public class DownloadFragment extends BaseMwmListFragment implements View.OnClic
|
|||
@Override
|
||||
public void onListItemClick(ListView l, View v, int position, long id)
|
||||
{
|
||||
if (getListAdapter().getItemViewType(position) == DownloadAdapter.TYPE_EXTENDED)
|
||||
if (getListAdapter().getItemViewType(position) == OldDownloadAdapter.TYPE_EXTENDED)
|
||||
openDownloadedList();
|
||||
}
|
||||
|
||||
|
@ -198,11 +176,11 @@ public class DownloadFragment extends BaseMwmListFragment implements View.OnClic
|
|||
mDownloadedAdapter.onResume(getListView());
|
||||
}
|
||||
|
||||
BaseDownloadAdapter getDownloadedAdapter()
|
||||
OldBaseDownloadAdapter getDownloadedAdapter()
|
||||
{
|
||||
if (mDownloadedAdapter == null)
|
||||
{
|
||||
mDownloadedAdapter = new DownloadedAdapter(this);
|
||||
mDownloadedAdapter = new OldDownloadedAdapter(this);
|
||||
mDownloadedAdapter.registerDataSetObserver(new DataSetObserver()
|
||||
{
|
||||
@Override
|
||||
|
@ -217,11 +195,11 @@ public class DownloadFragment extends BaseMwmListFragment implements View.OnClic
|
|||
return mDownloadedAdapter;
|
||||
}
|
||||
|
||||
private DownloadAdapter getDownloadAdapter()
|
||||
private OldDownloadAdapter getDownloadAdapter()
|
||||
{
|
||||
if (mDownloadAdapter == null)
|
||||
{
|
||||
mDownloadAdapter = new DownloadAdapter(this);
|
||||
mDownloadAdapter = new OldDownloadAdapter(this);
|
||||
mDownloadAdapter.registerDataSetObserver(new DataSetObserver()
|
||||
{
|
||||
@Override
|
||||
|
@ -241,17 +219,17 @@ public class DownloadFragment extends BaseMwmListFragment implements View.OnClic
|
|||
{
|
||||
switch (v.getId())
|
||||
{
|
||||
case R.id.tv__update_all:
|
||||
/*case R.id.tv__update_all:
|
||||
if (mMode == MODE_UPDATE_ALL)
|
||||
ActiveCountryTree.updateAll();
|
||||
OldActiveCountryTree.updateAll();
|
||||
else
|
||||
ActiveCountryTree.cancelAll();
|
||||
OldActiveCountryTree.cancelAll();
|
||||
updateToolbar();
|
||||
break;
|
||||
break;*/
|
||||
|
||||
case R.id.download_all:
|
||||
Statistics.INSTANCE.trackEvent(Statistics.EventName.DOWNLOADER_MAP_DOWNLOAD_ALL);
|
||||
CountryTree.downloadGroup();
|
||||
OldCountryTree.downloadGroup();
|
||||
getDownloadAdapter().notifyDataSetInvalidated();
|
||||
break;
|
||||
}
|
||||
|
@ -266,7 +244,7 @@ public class DownloadFragment extends BaseMwmListFragment implements View.OnClic
|
|||
if (isAdded())
|
||||
{
|
||||
updateToolbar();
|
||||
Utils.keepScreenOn(ActiveCountryTree.isDownloadingActive(), getActivity().getWindow());
|
||||
Utils.keepScreenOn(OldActiveCountryTree.isDownloadingActive(), getActivity().getWindow());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.mapswithme.country;
|
||||
package com.mapswithme.maps.downloader.country;
|
||||
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
@ -12,9 +12,9 @@ import com.mapswithme.util.UiUtils;
|
|||
import com.mapswithme.util.Utils;
|
||||
|
||||
@Deprecated
|
||||
class DownloadedAdapter extends BaseDownloadAdapter implements ActiveCountryTree.ActiveCountryListener
|
||||
public class OldDownloadedAdapter extends OldBaseDownloadAdapter implements OldActiveCountryTree.ActiveCountryListener
|
||||
{
|
||||
private static final String TAG = DownloadedAdapter.class.getSimpleName();
|
||||
private static final String TAG = OldDownloadedAdapter.class.getSimpleName();
|
||||
private static final int TYPE_HEADER = 5;
|
||||
private static final int VIEW_TYPE_COUNT = TYPES_COUNT + 1;
|
||||
|
||||
|
@ -30,7 +30,7 @@ class DownloadedAdapter extends BaseDownloadAdapter implements ActiveCountryTree
|
|||
private int mInProgressCount;
|
||||
private int mListenerSlotId;
|
||||
|
||||
DownloadedAdapter(DownloadFragment fragment)
|
||||
OldDownloadedAdapter(OldDownloadFragment fragment)
|
||||
{
|
||||
super(fragment);
|
||||
}
|
||||
|
@ -41,11 +41,11 @@ class DownloadedAdapter extends BaseDownloadAdapter implements ActiveCountryTree
|
|||
final int viewType = getItemViewType(position);
|
||||
if (viewType == TYPE_HEADER)
|
||||
{
|
||||
View view;
|
||||
View view = null;
|
||||
ViewHolder holder;
|
||||
if (convertView == null)
|
||||
{
|
||||
view = mInflater.inflate(R.layout.download_item_updated, parent, false);
|
||||
//view = mInflater.inflate(R.layout.download_item_updated, parent, false);
|
||||
holder = new ViewHolder();
|
||||
holder.initFromView(view);
|
||||
view.setTag(holder);
|
||||
|
@ -66,7 +66,7 @@ class DownloadedAdapter extends BaseDownloadAdapter implements ActiveCountryTree
|
|||
{
|
||||
final View view = super.getView(position, convertView, parent);
|
||||
final ViewHolder holder = (ViewHolder) view.getTag();
|
||||
UiUtils.showIf(getGroupByAbsPosition(position) == ActiveCountryTree.GROUP_UP_TO_DATE, holder.mPercent);
|
||||
UiUtils.showIf(getGroupByAbsPosition(position) == OldActiveCountryTree.GROUP_UP_TO_DATE, holder.mPercent);
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
@ -77,8 +77,8 @@ class DownloadedAdapter extends BaseDownloadAdapter implements ActiveCountryTree
|
|||
final Pair<Integer, Integer> groupAndPosition = splitAbsolutePosition(position, "getRemoteItemSizes. Cannot get correct positions.");
|
||||
if (groupAndPosition != null)
|
||||
{
|
||||
long mapSize = ActiveCountryTree.getCountrySize(groupAndPosition.first, groupAndPosition.second, StorageOptions.MAP_OPTION_MAP_ONLY, false);
|
||||
long routingSize = ActiveCountryTree.getCountrySize(groupAndPosition.first, groupAndPosition.second, StorageOptions.MAP_OPTION_CAR_ROUTING, false);
|
||||
long mapSize = OldActiveCountryTree.getCountrySize(groupAndPosition.first, groupAndPosition.second, OldStorageOptions.MAP_OPTION_MAP_ONLY, false);
|
||||
long routingSize = OldActiveCountryTree.getCountrySize(groupAndPosition.first, groupAndPosition.second, OldStorageOptions.MAP_OPTION_CAR_ROUTING, false);
|
||||
return new long[]{mapSize, mapSize + routingSize};
|
||||
}
|
||||
|
||||
|
@ -91,8 +91,8 @@ class DownloadedAdapter extends BaseDownloadAdapter implements ActiveCountryTree
|
|||
final Pair<Integer, Integer> groupAndPosition = splitAbsolutePosition(position, "getDownloadableItemSizes. Cannot get correct positions.");
|
||||
if (groupAndPosition != null)
|
||||
{
|
||||
long currentSize = ActiveCountryTree.getCountrySize(groupAndPosition.first, groupAndPosition.second, -1, true);
|
||||
long totalSize = ActiveCountryTree.getCountrySize(groupAndPosition.first, groupAndPosition.second, -1, false);
|
||||
long currentSize = OldActiveCountryTree.getCountrySize(groupAndPosition.first, groupAndPosition.second, -1, true);
|
||||
long totalSize = OldActiveCountryTree.getCountrySize(groupAndPosition.first, groupAndPosition.second, -1, false);
|
||||
return new long[]{currentSize, totalSize};
|
||||
}
|
||||
|
||||
|
@ -108,22 +108,22 @@ class DownloadedAdapter extends BaseDownloadAdapter implements ActiveCountryTree
|
|||
|
||||
private void updateGroupCounters()
|
||||
{
|
||||
mInProgressCount = ActiveCountryTree.getCountInGroup(ActiveCountryTree.GROUP_NEW);
|
||||
mUpdatedCount = ActiveCountryTree.getCountInGroup(ActiveCountryTree.GROUP_UP_TO_DATE);
|
||||
mOutdatedCount = ActiveCountryTree.getCountInGroup(ActiveCountryTree.GROUP_OUT_OF_DATE);
|
||||
mInProgressCount = OldActiveCountryTree.getCountInGroup(OldActiveCountryTree.GROUP_NEW);
|
||||
mUpdatedCount = OldActiveCountryTree.getCountInGroup(OldActiveCountryTree.GROUP_UP_TO_DATE);
|
||||
mOutdatedCount = OldActiveCountryTree.getCountInGroup(OldActiveCountryTree.GROUP_OUT_OF_DATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CountryItem getItem(int position)
|
||||
public OldCountryItem getItem(int position)
|
||||
{
|
||||
if (isHeader(position))
|
||||
return null;
|
||||
|
||||
final Pair<Integer, Integer> groupAndPosition = splitAbsolutePosition(position, "getItem. Cannot get correct positions.");
|
||||
if (groupAndPosition != null)
|
||||
return ActiveCountryTree.getCountryItem(groupAndPosition.first, groupAndPosition.second);
|
||||
return OldActiveCountryTree.getCountryItem(groupAndPosition.first, groupAndPosition.second);
|
||||
|
||||
return CountryItem.EMPTY;
|
||||
return OldCountryItem.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -173,15 +173,15 @@ class DownloadedAdapter extends BaseDownloadAdapter implements ActiveCountryTree
|
|||
{
|
||||
final int newGroupEnd = mInProgressCount;
|
||||
if (position < newGroupEnd)
|
||||
return ActiveCountryTree.GROUP_NEW;
|
||||
return OldActiveCountryTree.GROUP_NEW;
|
||||
|
||||
final int outdatedGroupEnd = containsOutdated() ? newGroupEnd + mOutdatedCount + 1 : newGroupEnd;
|
||||
if (position < outdatedGroupEnd)
|
||||
return ActiveCountryTree.GROUP_OUT_OF_DATE;
|
||||
return OldActiveCountryTree.GROUP_OUT_OF_DATE;
|
||||
|
||||
final int updatedGroupEnd = containsUpdated() ? outdatedGroupEnd + mUpdatedCount + 1 : outdatedGroupEnd;
|
||||
if (position < updatedGroupEnd)
|
||||
return ActiveCountryTree.GROUP_UP_TO_DATE;
|
||||
return OldActiveCountryTree.GROUP_UP_TO_DATE;
|
||||
|
||||
return INVALID_POSITION;
|
||||
}
|
||||
|
@ -207,9 +207,9 @@ class DownloadedAdapter extends BaseDownloadAdapter implements ActiveCountryTree
|
|||
{
|
||||
switch (group)
|
||||
{
|
||||
case ActiveCountryTree.GROUP_NEW:
|
||||
case OldActiveCountryTree.GROUP_NEW:
|
||||
return position;
|
||||
case ActiveCountryTree.GROUP_OUT_OF_DATE:
|
||||
case OldActiveCountryTree.GROUP_OUT_OF_DATE:
|
||||
return position + mInProgressCount + 1;
|
||||
default:
|
||||
return position + mInProgressCount + 1 + (containsOutdated() ? mOutdatedCount + 1 : 0);
|
||||
|
@ -233,7 +233,7 @@ class DownloadedAdapter extends BaseDownloadAdapter implements ActiveCountryTree
|
|||
{
|
||||
final Pair<Integer, Integer> groupAndPosition = splitAbsolutePosition(position, "cancelDownload. Cannot get correct positions.");
|
||||
if (groupAndPosition != null)
|
||||
ActiveCountryTree.cancelDownloading(groupAndPosition.first, groupAndPosition.second);
|
||||
OldActiveCountryTree.cancelDownloading(groupAndPosition.first, groupAndPosition.second);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -241,7 +241,7 @@ class DownloadedAdapter extends BaseDownloadAdapter implements ActiveCountryTree
|
|||
{
|
||||
final Pair<Integer, Integer> groupAndPosition = splitAbsolutePosition(position, "retryDownload. Cannot get correct positions.");
|
||||
if (groupAndPosition != null)
|
||||
ActiveCountryTree.retryDownloading(groupAndPosition.first, groupAndPosition.second);
|
||||
OldActiveCountryTree.retryDownloading(groupAndPosition.first, groupAndPosition.second);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -261,13 +261,13 @@ class DownloadedAdapter extends BaseDownloadAdapter implements ActiveCountryTree
|
|||
protected void setCountryListener()
|
||||
{
|
||||
if (mListenerSlotId == 0)
|
||||
mListenerSlotId = ActiveCountryTree.addListener(this);
|
||||
mListenerSlotId = OldActiveCountryTree.addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void resetCountryListener()
|
||||
{
|
||||
ActiveCountryTree.removeListener(mListenerSlotId);
|
||||
OldActiveCountryTree.removeListener(mListenerSlotId);
|
||||
mListenerSlotId = 0;
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ class DownloadedAdapter extends BaseDownloadAdapter implements ActiveCountryTree
|
|||
{
|
||||
final Pair<Integer, Integer> groupAndPosition = splitAbsolutePosition(position, "updateCountry. Cannot get correct positions.");
|
||||
if (groupAndPosition != null)
|
||||
ActiveCountryTree.downloadMap(groupAndPosition.first, groupAndPosition.second, options);
|
||||
OldActiveCountryTree.downloadMap(groupAndPosition.first, groupAndPosition.second, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -284,7 +284,7 @@ class DownloadedAdapter extends BaseDownloadAdapter implements ActiveCountryTree
|
|||
{
|
||||
final Pair<Integer, Integer> groupAndPosition = splitAbsolutePosition(position, "downloadCountry. Cannot get correct positions.");
|
||||
if (groupAndPosition != null)
|
||||
ActiveCountryTree.downloadMap(groupAndPosition.first, groupAndPosition.second, options);
|
||||
OldActiveCountryTree.downloadMap(groupAndPosition.first, groupAndPosition.second, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -292,7 +292,7 @@ class DownloadedAdapter extends BaseDownloadAdapter implements ActiveCountryTree
|
|||
{
|
||||
final Pair<Integer, Integer> groupAndPosition = splitAbsolutePosition(position, "downloadCountry. Cannot get correct positions.");
|
||||
if (groupAndPosition != null)
|
||||
ActiveCountryTree.deleteMap(groupAndPosition.first, groupAndPosition.second, options);
|
||||
OldActiveCountryTree.deleteMap(groupAndPosition.first, groupAndPosition.second, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -301,7 +301,7 @@ class DownloadedAdapter extends BaseDownloadAdapter implements ActiveCountryTree
|
|||
final Pair<Integer, Integer> groupAndPosition = splitAbsolutePosition(position, "showCountry. Cannot get correct positions.");
|
||||
if (groupAndPosition != null)
|
||||
{
|
||||
ActiveCountryTree.showOnMap(groupAndPosition.first, groupAndPosition.second);
|
||||
OldActiveCountryTree.showOnMap(groupAndPosition.first, groupAndPosition.second);
|
||||
resetCountryListener();
|
||||
Utils.navigateToParent(mFragment.getActivity());
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
package com.mapswithme.maps;
|
||||
package com.mapswithme.maps.downloader.country;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public enum MapStorage
|
||||
@Deprecated
|
||||
public enum OldMapStorage
|
||||
{
|
||||
INSTANCE;
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package com.mapswithme.country;
|
||||
package com.mapswithme.maps.downloader.country;
|
||||
|
||||
@Deprecated
|
||||
public class StorageOptions
|
||||
public class OldStorageOptions
|
||||
{
|
||||
private StorageOptions() {}
|
||||
private OldStorageOptions() {}
|
||||
|
||||
public static final int MAP_OPTION_MAP_ONLY = 1;
|
||||
public static final int MAP_OPTION_CAR_ROUTING = 2;
|
|
@ -5,7 +5,7 @@ import android.util.Pair;
|
|||
|
||||
import com.mapswithme.maps.LocationState;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.MapStorage;
|
||||
import com.mapswithme.maps.downloader.country.OldMapStorage;
|
||||
import com.mapswithme.maps.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -27,7 +27,7 @@ class ResultCodesHelper
|
|||
public static final int INTERNAL_ERROR = 10;
|
||||
public static final int FILE_TOO_OLD = 11;
|
||||
|
||||
public static Pair<String, String> getDialogTitleSubtitle(int errorCode, MapStorage.Index[] missingCountries)
|
||||
public static Pair<String, String> getDialogTitleSubtitle(int errorCode, OldMapStorage.Index[] missingCountries)
|
||||
{
|
||||
int missingCount = 0;
|
||||
if (missingCountries != null)
|
||||
|
|
|
@ -22,8 +22,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.mapswithme.country.StorageOptions;
|
||||
import com.mapswithme.maps.MapStorage;
|
||||
import com.mapswithme.maps.downloader.country.OldMapStorage;
|
||||
import com.mapswithme.maps.downloader.country.OldStorageOptions;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.adapter.DisabledChildSimpleExpandableListAdapter;
|
||||
|
@ -41,8 +41,8 @@ public class RoutingErrorDialogFragment extends BaseMwmDialogFragment
|
|||
private static final String GROUP_SIZE = "GroupSize";
|
||||
private static final String COUNTRY_NAME = "CountryName";
|
||||
|
||||
private MapStorage.Index[] mMissingCountries;
|
||||
private MapStorage.Index[] mMissingRoutes;
|
||||
private OldMapStorage.Index[] mMissingCountries;
|
||||
private OldMapStorage.Index[] mMissingRoutes;
|
||||
private int mResultCode;
|
||||
|
||||
public interface Listener
|
||||
|
@ -72,7 +72,7 @@ public class RoutingErrorDialogFragment extends BaseMwmDialogFragment
|
|||
{
|
||||
View view;
|
||||
if (hasSingleIndex(mMissingCountries) && !hasIndex(mMissingRoutes))
|
||||
view = buildSingleMapView(titleMessage.second, mMissingCountries[0], StorageOptions.MAP_OPTION_MAP_ONLY);
|
||||
view = buildSingleMapView(titleMessage.second, mMissingCountries[0], OldStorageOptions.MAP_OPTION_MAP_ONLY);
|
||||
else
|
||||
view = buildMultipleMapView(titleMessage.second);
|
||||
|
||||
|
@ -111,30 +111,30 @@ public class RoutingErrorDialogFragment extends BaseMwmDialogFragment
|
|||
private void parseArguments()
|
||||
{
|
||||
final Bundle args = getArguments();
|
||||
mMissingCountries = (MapStorage.Index[]) args.getSerializable(EXTRA_MISSING_COUNTRIES);
|
||||
mMissingRoutes = (MapStorage.Index[]) args.getSerializable(EXTRA_MISSING_ROUTES);
|
||||
mMissingCountries = (OldMapStorage.Index[]) args.getSerializable(EXTRA_MISSING_COUNTRIES);
|
||||
mMissingRoutes = (OldMapStorage.Index[]) args.getSerializable(EXTRA_MISSING_ROUTES);
|
||||
mResultCode = args.getInt(EXTRA_RESULT_CODE);
|
||||
}
|
||||
|
||||
private static boolean hasIndex(MapStorage.Index[] indices)
|
||||
private static boolean hasIndex(OldMapStorage.Index[] indices)
|
||||
{
|
||||
return (indices != null && indices.length != 0);
|
||||
}
|
||||
|
||||
private static boolean hasSingleIndex(MapStorage.Index[] indices)
|
||||
private static boolean hasSingleIndex(OldMapStorage.Index[] indices)
|
||||
{
|
||||
return (indices != null && indices.length == 1);
|
||||
}
|
||||
|
||||
private View buildSingleMapView(String message, MapStorage.Index index, int option)
|
||||
private View buildSingleMapView(String message, OldMapStorage.Index index, int option)
|
||||
{
|
||||
@SuppressLint("InflateParams")
|
||||
final View countryView = View.inflate(getActivity(), R.layout.dialog_download_single_item, null);
|
||||
((TextView) countryView.findViewById(R.id.tv__title)).setText(MapStorage.INSTANCE.countryName(index));
|
||||
((TextView) countryView.findViewById(R.id.tv__title)).setText(OldMapStorage.INSTANCE.countryName(index));
|
||||
((TextView) countryView.findViewById(R.id.tv__message)).setText(message);
|
||||
|
||||
final TextView szView = (TextView) countryView.findViewById(R.id.tv__size);
|
||||
szView.setText(StringUtils.getFileSizeString(MapStorage.INSTANCE.countryRemoteSizeInBytes(index, option)));
|
||||
szView.setText(StringUtils.getFileSizeString(OldMapStorage.INSTANCE.countryRemoteSizeInBytes(index, option)));
|
||||
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) szView.getLayoutParams();
|
||||
lp.rightMargin = 0;
|
||||
szView.setLayoutParams(lp);
|
||||
|
@ -179,7 +179,7 @@ public class RoutingErrorDialogFragment extends BaseMwmDialogFragment
|
|||
{
|
||||
final Map<String, String> countriesGroup = new HashMap<>();
|
||||
countriesGroup.put(GROUP_NAME, getString(R.string.maps) + " (" + mMissingCountries.length + ") ");
|
||||
countriesGroup.put(GROUP_SIZE, StringUtils.getFileSizeString(getCountrySizesBytes(mMissingCountries, StorageOptions.MAP_OPTION_MAP_ONLY)));
|
||||
countriesGroup.put(GROUP_SIZE, StringUtils.getFileSizeString(getCountrySizesBytes(mMissingCountries, OldStorageOptions.MAP_OPTION_MAP_ONLY)));
|
||||
groupData.add(countriesGroup);
|
||||
|
||||
countries = getCountryNames(mMissingCountries);
|
||||
|
@ -194,10 +194,10 @@ public class RoutingErrorDialogFragment extends BaseMwmDialogFragment
|
|||
if (countries != null)
|
||||
{
|
||||
routes.addAll(countries);
|
||||
size += getCountrySizesBytes(mMissingCountries, StorageOptions.MAP_OPTION_CAR_ROUTING);
|
||||
size += getCountrySizesBytes(mMissingCountries, OldStorageOptions.MAP_OPTION_CAR_ROUTING);
|
||||
routesCount += mMissingCountries.length;
|
||||
}
|
||||
size += getCountrySizesBytes(mMissingRoutes, StorageOptions.MAP_OPTION_CAR_ROUTING);
|
||||
size += getCountrySizesBytes(mMissingRoutes, OldStorageOptions.MAP_OPTION_CAR_ROUTING);
|
||||
|
||||
routesGroup.put(GROUP_NAME, getString(R.string.dialog_routing_routes_size) + " (" + routesCount + ") ");
|
||||
routesGroup.put(GROUP_SIZE, StringUtils.getFileSizeString(size));
|
||||
|
@ -219,27 +219,27 @@ public class RoutingErrorDialogFragment extends BaseMwmDialogFragment
|
|||
);
|
||||
}
|
||||
|
||||
private static List<Map<String, String>> getCountryNames(MapStorage.Index[] indices)
|
||||
private static List<Map<String, String>> getCountryNames(OldMapStorage.Index[] indices)
|
||||
{
|
||||
final List<Map<String, String>> countries = new ArrayList<>(indices.length);
|
||||
for (MapStorage.Index index : indices)
|
||||
for (OldMapStorage.Index index : indices)
|
||||
{
|
||||
final Map<String, String> countryData = new HashMap<>();
|
||||
countryData.put(COUNTRY_NAME, MapStorage.INSTANCE.countryName(index));
|
||||
countryData.put(COUNTRY_NAME, OldMapStorage.INSTANCE.countryName(index));
|
||||
countries.add(countryData);
|
||||
}
|
||||
return countries;
|
||||
}
|
||||
|
||||
private static long getCountrySizesBytes(MapStorage.Index[] indices, int option)
|
||||
private static long getCountrySizesBytes(OldMapStorage.Index[] indices, int option)
|
||||
{
|
||||
long total = 0;
|
||||
for (MapStorage.Index index : indices)
|
||||
total += MapStorage.INSTANCE.countryRemoteSizeInBytes(index, option);
|
||||
for (OldMapStorage.Index index : indices)
|
||||
total += OldMapStorage.INSTANCE.countryRemoteSizeInBytes(index, option);
|
||||
return total;
|
||||
}
|
||||
|
||||
public static RoutingErrorDialogFragment create(int resultCode, MapStorage.Index[] missingCountries, MapStorage.Index[] missingRoutes)
|
||||
public static RoutingErrorDialogFragment create(int resultCode, OldMapStorage.Index[] missingCountries, OldMapStorage.Index[] missingRoutes)
|
||||
{
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(EXTRA_RESULT_CODE, resultCode);
|
||||
|
|
|
@ -10,7 +10,7 @@ import android.support.v7.app.AlertDialog;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.mapswithme.country.ActiveCountryTree;
|
||||
import com.mapswithme.maps.downloader.country.OldActiveCountryTree;
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.location.TrackRecorder;
|
||||
|
@ -66,7 +66,7 @@ public class MapPrefsFragment extends BaseXmlSettingsFragment
|
|||
@Override
|
||||
public boolean onPreferenceClick(Preference preference)
|
||||
{
|
||||
if (ActiveCountryTree.isDownloadingActive())
|
||||
if (OldActiveCountryTree.isDownloadingActive())
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle(getString(R.string.downloading_is_active))
|
||||
.setMessage(getString(R.string.cant_change_this_setting))
|
||||
|
|
|
@ -11,7 +11,7 @@ import android.util.Log;
|
|||
|
||||
import com.mapswithme.maps.BuildConfig;
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MapStorage;
|
||||
import com.mapswithme.maps.downloader.country.OldMapStorage;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.util.Config;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
|
@ -377,7 +377,7 @@ public class StoragePathManager
|
|||
{
|
||||
for (int i = 0; i < oldFiles.length; ++i)
|
||||
{
|
||||
if (!MapStorage.nativeMoveFile(oldFiles[i].getAbsolutePath(), newFiles[i].getAbsolutePath()))
|
||||
if (!OldMapStorage.nativeMoveFile(oldFiles[i].getAbsolutePath(), newFiles[i].getAbsolutePath()))
|
||||
{
|
||||
File parent = newFiles[i].getParentFile();
|
||||
if (parent != null)
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.Map;
|
|||
|
||||
import com.facebook.appevents.AppEventsLogger;
|
||||
import com.flurry.android.FlurryAgent;
|
||||
import com.mapswithme.country.ActiveCountryTree;
|
||||
import com.mapswithme.maps.downloader.country.OldActiveCountryTree;
|
||||
import com.mapswithme.maps.BuildConfig;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.PrivateVariables;
|
||||
|
@ -302,7 +302,7 @@ public enum Statistics
|
|||
{
|
||||
if (mEnabled)
|
||||
{
|
||||
final ParameterBuilder params = params().add(EventParam.COUNT, String.valueOf(ActiveCountryTree.getTotalDownloadedCount()));
|
||||
final ParameterBuilder params = params().add(EventParam.COUNT, String.valueOf(OldActiveCountryTree.getTotalDownloadedCount()));
|
||||
MRMyTracker.trackEvent(event, params.get());
|
||||
trackEvent(event, params);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue