[Old map downloader] [android] add: Migration suggest dialog.

del: Removed "download routing" options.
This commit is contained in:
Alexander Marchuk 2016-01-22 13:08:52 +03:00 committed by Sergey Yershov
parent cbab6c65d5
commit d56a1eb67f
7 changed files with 152 additions and 190 deletions

View file

@ -145,4 +145,20 @@ extern "C"
{
GetMapLayout().DownloadMap(storage::ToNative(index), ToOptions(options));
}
// FIXME (trashkalmar): Include proper logic
static bool legacy_mode = true;
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_country_ActiveCountryTree_isLegacyMode(JNIEnv * env, jclass clazz)
{
return legacy_mode;
}
JNIEXPORT void JNICALL
Java_com_mapswithme_country_ActiveCountryTree_migrate(JNIEnv * env, jclass clazz)
{
legacy_mode = false;
}
}

View file

@ -1,102 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?windowBackgroundForced">
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/ll__select_download"
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingLeft="@dimen/margin_base"
android:paddingRight="@dimen/margin_base"
android:paddingTop="@dimen/margin_half_plus"
tools:ignore="UnusedAttribute">
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/search_without_internet_advertisement"
android:textAppearance="@style/MwmTextAppearance.Body2"/>
<LinearLayout
android:id="@+id/ll__location_determined"
<LinearLayout
android:id="@+id/ll__select_download"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
android:orientation="vertical"
android:paddingLeft="@dimen/margin_base"
android:paddingRight="@dimen/margin_base"
android:paddingTop="@dimen/margin_half_plus"
tools:ignore="UnusedAttribute">
<TextView
android:id="@+id/tv__country_name"
<TextView
android:layout_width="match_parent"
android:layout_height="@dimen/base_block_size"
android:layout_marginTop="@dimen/margin_half"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="@style/MwmTextAppearance.Title"/>
<Button
android:id="@+id/btn__download_map"
style="@style/MwmWidget.Button.Green"
android:layout_width="280dp"
android:layout_height="@dimen/base_block_size"
android:layout_marginTop="@dimen/margin_quarter"
android:text="@string/downloader_download_map"
android:textAllCaps="true"
android:textAppearance="@style/MwmTextAppearance.Body1.Light"/>
<CheckBox
android:id="@+id/chb__routing_too"
android:layout_width="wrap_content"
android:layout_height="@dimen/base_block_size"
android:layout_marginTop="@dimen/margin_quarter"
android:text="@string/search_vehicle_routes"
android:text="@string/search_without_internet_advertisement"
android:textAppearance="@style/MwmTextAppearance.Body2"/>
<LinearLayout
android:id="@+id/ll__location_determined"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/tv__country_name"
android:layout_width="match_parent"
android:layout_height="@dimen/base_block_size"
android:layout_marginTop="@dimen/margin_half"
android:gravity="center"
android:textAppearance="@style/MwmTextAppearance.Title"/>
<Button
android:id="@+id/btn__select_other_map"
android:layout_width="280dp"
android:layout_height="@dimen/base_block_size"
android:layout_marginTop="@dimen/margin_base_plus"
android:background="?clickableBackground"
android:text="@string/search_select_other_map"
android:textAllCaps="true"
android:textAppearance="@style/MwmTextAppearance.Body3"
android:textColor="?colorAccent"/>
android:id="@+id/btn__download_map"
style="@style/MwmWidget.Button.Green"
android:layout_width="280dp"
android:layout_height="@dimen/base_block_size"
android:layout_marginTop="@dimen/margin_quarter"
android:text="@string/downloader_download_map"
android:textAllCaps="true"
android:textAppearance="@style/MwmTextAppearance.Body1.Light"/>
<Button
android:id="@+id/btn__select_other_map"
android:layout_width="280dp"
android:layout_height="@dimen/base_block_size"
android:layout_marginTop="@dimen/margin_base_plus"
android:background="?clickableBackground"
android:text="@string/search_select_other_map"
android:textAllCaps="true"
android:textAppearance="@style/MwmTextAppearance.Body3"
android:textColor="?colorAccent"/>
</LinearLayout>
<LinearLayout
android:id="@+id/ll__location_unknown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
android:id="@+id/ll__location_unknown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="@dimen/base_block_size"
android:layout_marginTop="@dimen/margin_half"
android:gravity="center"
android:text="@string/unknown_current_position"
android:textAppearance="@style/MwmTextAppearance.Body3"/>
android:layout_width="match_parent"
android:layout_height="@dimen/base_block_size"
android:layout_marginTop="@dimen/margin_half"
android:gravity="center"
android:text="@string/unknown_current_position"
android:textAppearance="@style/MwmTextAppearance.Body3"/>
<Button
android:id="@+id/btn__select_map"
style="@style/MwmWidget.Button.Green"
android:layout_width="280dp"
android:layout_height="@dimen/base_block_size"
android:layout_marginTop="@dimen/margin_half"
android:text="@string/search_select_map"
android:textAllCaps="true"
android:textAppearance="@style/MwmTextAppearance.Body1.Light"/>
android:id="@+id/btn__select_map"
style="@style/MwmWidget.Button.Green"
android:layout_width="280dp"
android:layout_height="@dimen/base_block_size"
android:layout_marginTop="@dimen/margin_half"
android:text="@string/search_select_map"
android:textAllCaps="true"
android:textAppearance="@style/MwmTextAppearance.Body1.Light"/>
</LinearLayout>
@ -105,31 +96,31 @@
</ScrollView>
<LinearLayout
android:id="@+id/ll__active_download"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="@dimen/margin_double_and_half"
android:visibility="gone">
android:id="@+id/ll__active_download"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="@dimen/margin_double_and_half"
android:visibility="gone">
<TextView
android:id="@+id/tv__active_country_name"
android:layout_width="wrap_content"
android:layout_height="@dimen/base_block_size"
android:textAppearance="@style/MwmTextAppearance.Title"/>
android:id="@+id/tv__active_country_name"
android:layout_width="wrap_content"
android:layout_height="@dimen/base_block_size"
android:textAppearance="@style/MwmTextAppearance.Title"/>
<com.mapswithme.maps.widget.WheelProgressView
xmlns:wheel="http://schemas.android.com/apk/res-auto"
android:id="@+id/wpv__download_progress"
android:layout_width="@dimen/progress_wheel_height"
android:layout_height="@dimen/progress_wheel_height"
android:layout_marginTop="@dimen/margin_half_plus"
android:background="?clickableBackground"
wheel:wheelProgressColor="@color/base_green"
wheel:wheelSecondaryColor="?dividerHorizontal"
wheel:wheelThickness="@dimen/margin_quarter"/>
android:id="@+id/wpv__download_progress"
xmlns:wheel="http://schemas.android.com/apk/res-auto"
android:layout_width="@dimen/progress_wheel_height"
android:layout_height="@dimen/progress_wheel_height"
android:layout_marginTop="@dimen/margin_half_plus"
android:background="?clickableBackground"
wheel:wheelProgressColor="@color/base_green"
wheel:wheelSecondaryColor="?dividerHorizontal"
wheel:wheelThickness="@dimen/margin_quarter"/>
</LinearLayout>
</FrameLayout>
</FrameLayout>

View file

@ -57,14 +57,6 @@
android:textAllCaps="true"
android:textAppearance="@style/MwmTextAppearance.Body1.Light"/>
<CheckBox
android:id="@+id/chb__routing_too"
android:layout_width="wrap_content"
android:layout_height="@dimen/base_block_size"
android:layout_marginTop="@dimen/margin_half"
android:text="@string/search_vehicle_routes"
android:textAppearance="@style/MwmTextAppearance.Body2"/>
<Button
android:id="@+id/btn__select_other_map"
android:layout_width="match_parent"

View file

@ -82,4 +82,8 @@ public class ActiveCountryTree
for (Index index : indices)
downloadMapForIndex(index, options);
}
public static native boolean isLegacyMode();
public static native void migrate();
}

View file

@ -348,7 +348,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
return 0;
}
protected void bindCountry(final int position, final ViewHolder holder)
private void bindCountry(final int position, final ViewHolder holder)
{
final CountryItem item = getItem(position);
if (item == null)
@ -665,7 +665,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
}
}
protected void setItemName(int position, ViewHolder holder)
private void setItemName(int position, ViewHolder holder)
{
// set name and style
final CountryItem item = getItem(position);
@ -715,26 +715,20 @@ abstract class BaseDownloadAdapter extends BaseAdapter
}
}
protected void showCountryContextMenu(final CountryItem countryItem, final View anchor, final int position)
void showCountryContextMenu(final CountryItem countryItem, final View anchor, final int position)
{
if (countryItem == null || anchor.getParent() == null)
return;
final int MENU_CANCEL = 0;
final int MENU_DOWNLOAD = 1;
final int MENU_UPDATE_MAP_AND_ROUTING = 2;
final int MENU_DOWNLOAD_MAP_AND_ROUTING = 3;
final int MENU_UPDATE_MAP_DOWNLOAD_ROUTING = 4;
final int MENU_UPDATE = 5;
final int MENU_DOWNLOAD_ROUTING = 6;
final int MENU_SHOW = 7;
final int MENU_DELETE_ROUTING = 9;
final int MENU_DELETE = 10;
final int MENU_RETRY = 11;
final int MENU_UPDATE = 1;
final int MENU_DOWNLOAD = 2;
final int MENU_EXPLORE = 3;
final int MENU_DELETE = 4;
final int MENU_RETRY = 5;
final int status = countryItem.getStatus();
final String name = countryItem.getName();
final int options = countryItem.getOptions();
OnMenuItemClickListener menuItemClickListener = new OnMenuItemClickListener()
{
@ -749,31 +743,16 @@ abstract class BaseDownloadAdapter extends BaseAdapter
case MENU_DELETE:
processOnDisk(name, position, StorageOptions.MAP_OPTION_MAP_ONLY);
break;
case MENU_UPDATE:
processOutOfDate(name, position, StorageOptions.MAP_OPTION_MAP_ONLY);
break;
case MENU_DOWNLOAD:
processNotDownloaded(name, position, StorageOptions.MAP_OPTION_MAP_ONLY, holder);
break;
case MENU_CANCEL:
confirmDownloadCancellation(holder, position, name);
break;
case MENU_SHOW:
case MENU_EXPLORE:
showCountry(position);
break;
case MENU_DELETE_ROUTING:
processOnDisk(name, position, StorageOptions.MAP_OPTION_CAR_ROUTING);
break;
case MENU_DOWNLOAD_ROUTING:
processNotDownloaded(name, position, StorageOptions.MAP_OPTION_CAR_ROUTING, holder);
break;
case MENU_DOWNLOAD_MAP_AND_ROUTING:
case MENU_DOWNLOAD:
processNotDownloaded(name, position, StorageOptions.MAP_OPTION_MAP_AND_CAR_ROUTING, holder);
break;
case MENU_UPDATE_MAP_DOWNLOAD_ROUTING:
processNotDownloaded(name, position, StorageOptions.MAP_OPTION_MAP_AND_CAR_ROUTING, holder);
break;
case MENU_UPDATE_MAP_AND_ROUTING:
case MENU_UPDATE:
processOutOfDate(name, position, StorageOptions.MAP_OPTION_MAP_AND_CAR_ROUTING);
break;
case MENU_RETRY:
@ -792,37 +771,14 @@ abstract class BaseDownloadAdapter extends BaseAdapter
if (status == MapStorage.ON_DISK_OUT_OF_DATE)
{
switch (options)
{
case StorageOptions.MAP_OPTION_MAP_ONLY:
BottomSheetHelper.sheet(bs, MENU_UPDATE_MAP_DOWNLOAD_ROUTING, R.drawable.ic_download_routing,
mFragment.getString(R.string.downloader_download_routing) + ", " +
StringUtils.getFileSizeString(remoteSizes[1]));
BottomSheetHelper.sheet(bs, MENU_UPDATE, R.drawable.ic_update,
mFragment.getString(R.string.downloader_update_map) + ", " +
StringUtils.getFileSizeString(remoteSizes[0]));
break;
case StorageOptions.MAP_OPTION_MAP_AND_CAR_ROUTING:
BottomSheetHelper.sheet(bs, MENU_UPDATE_MAP_AND_ROUTING, R.drawable.ic_update,
mFragment.getString(R.string.downloader_update_map) + ", " +
StringUtils.getFileSizeString(remoteSizes[1]));
break;
}
BottomSheetHelper.sheet(bs, MENU_UPDATE, R.drawable.ic_update,
mFragment.getString(R.string.downloader_update_map) + ", " +
StringUtils.getFileSizeString(remoteSizes[0]));
}
if (status == MapStorage.ON_DISK && options == StorageOptions.MAP_OPTION_MAP_ONLY)
BottomSheetHelper.sheet(bs, MENU_DOWNLOAD_ROUTING, R.drawable.ic_download_routing,
mFragment.getString(R.string.downloader_download_routing) + ", " +
StringUtils.getFileSizeString(remoteSizes[1] - remoteSizes[0]));
if (status == MapStorage.ON_DISK || status == MapStorage.ON_DISK_OUT_OF_DATE)
{
bs.sheet(MENU_SHOW, R.drawable.ic_explore, R.string.zoom_to_country);
if (options != StorageOptions.MAP_OPTION_MAP_ONLY)
bs.sheet(MENU_DELETE_ROUTING, R.drawable.ic_no_routing, R.string.downloader_delete_routing);
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);
}
@ -835,18 +791,13 @@ abstract class BaseDownloadAdapter extends BaseAdapter
break;
case MapStorage.NOT_DOWNLOADED:
BottomSheetHelper.sheet(bs, MENU_DOWNLOAD_MAP_AND_ROUTING, R.drawable.ic_download_map,
BottomSheetHelper.sheet(bs, MENU_DOWNLOAD, R.drawable.ic_download_map,
mFragment.getString(R.string.downloader_download_map) + ", " +
StringUtils.getFileSizeString(remoteSizes[1]));
BottomSheetHelper.sheet(bs, MENU_DOWNLOAD, R.drawable.ic_no_routing,
mFragment.getString(R.string.downloader_download_map_no_routing) + ", " +
StringUtils.getFileSizeString(remoteSizes[0]));
StringUtils.getFileSizeString(remoteSizes[1]));
break;
case MapStorage.DOWNLOAD_FAILED:
bs.sheet(MENU_RETRY, R.drawable.ic_retry, R.string.downloader_retry);
bs.sheet(MENU_DOWNLOAD_MAP_AND_ROUTING, R.drawable.ic_download_routing, R.string.downloader_download_map_and_routing);
break;
}

View file

@ -8,7 +8,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -40,7 +39,6 @@ public class CountrySuggestFragment extends BaseMwmFragment implements View.OnCl
private WheelProgressView mWpvDownloadProgress;
private TextView mTvCountry;
private TextView mTvActiveCountry;
private CheckBox mChbRoutes;
private Button mBtnDownloadMap;
@Nullable
@ -148,9 +146,6 @@ public class CountrySuggestFragment extends BaseMwmFragment implements View.OnCl
mWpvDownloadProgress.setOnClickListener(this);
mTvCountry = (TextView) view.findViewById(R.id.tv__country_name);
mTvActiveCountry = (TextView) view.findViewById(R.id.tv__active_country_name);
mChbRoutes = (CheckBox) view.findViewById(R.id.chb__routing_too);
mChbRoutes.setOnCheckedChangeListener(this);
mChbRoutes.setChecked(true);
}
private void refreshViews()
@ -218,7 +213,7 @@ public class CountrySuggestFragment extends BaseMwmFragment implements View.OnCl
private int storageOptionsRequested()
{
return mChbRoutes.isChecked() ? StorageOptions.MAP_OPTION_MAP_AND_CAR_ROUTING : StorageOptions.MAP_OPTION_MAP_ONLY;
return StorageOptions.MAP_OPTION_MAP_AND_CAR_ROUTING;
}
private void selectMapForDownload()

View file

@ -24,9 +24,6 @@ import android.widget.ImageButton;
import android.widget.LinearLayout;
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;
@ -77,6 +74,10 @@ import com.mapswithme.util.sharing.SharingHelper;
import com.mapswithme.util.statistics.AlohaHelper;
import com.mapswithme.util.statistics.MytargetHelper;
import com.mapswithme.util.statistics.Statistics;
import java.io.Serializable;
import java.util.Stack;
import ru.mail.android.mytarget.nativeads.NativeAppwallAd;
import ru.mail.android.mytarget.nativeads.banners.NativeAppwallBanner;
@ -276,19 +277,31 @@ public class MwmActivity extends BaseMwmFragmentActivity
new AlertDialog.Builder(MwmActivity.this)
.setMessage(R.string.unknown_current_position)
.setCancelable(true)
.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
dialog.dismiss();
}
}).show();
.setPositiveButton(android.R.string.ok, null)
.show();
}
@Override
public void showDownloader(boolean openDownloadedList)
public void showDownloader(final boolean openDownloadedList)
{
if (ActiveCountryTree.isLegacyMode())
{
new AlertDialog.Builder(MwmActivity.this)
.setTitle(R.string.migrate_title)
.setMessage(R.string.migrate_subtitle)
.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
ActiveCountryTree.migrate();
showDownloader(openDownloadedList);
}
}).show();
return;
}
final Bundle args = new Bundle();
args.putBoolean(DownloadActivity.EXTRA_OPEN_DOWNLOADED_LIST, openDownloadedList);
if (mIsFragmentContainer)