forked from organicmaps/organicmaps
[android] Used correct string in routing dialogs.
This commit is contained in:
parent
954f332076
commit
9f572dbaec
6 changed files with 111 additions and 83 deletions
|
@ -21,7 +21,7 @@
|
|||
android:id="@+id/tv__size"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/margin_double"
|
||||
android:layout_weight="0"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body1"/>
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/base_green"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="60dp"
|
||||
android:orientation="horizontal"
|
||||
|
@ -22,7 +23,7 @@
|
|||
android:id="@+id/tv__size"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/margin_double"
|
||||
android:layout_weight="0"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body1"
|
||||
android:textColor="@color/text_green"/>
|
||||
|
|
|
@ -54,7 +54,7 @@ import com.mapswithme.maps.bookmarks.data.MapObject;
|
|||
import com.mapswithme.maps.bookmarks.data.MapObject.ApiPoint;
|
||||
import com.mapswithme.maps.bookmarks.data.ParcelablePoint;
|
||||
import com.mapswithme.maps.data.RouterTypes;
|
||||
import com.mapswithme.maps.data.RoutingResultCodes;
|
||||
import com.mapswithme.maps.data.RoutingResultCodesProcessor;
|
||||
import com.mapswithme.maps.dialog.RoutingErrorDialogFragment;
|
||||
import com.mapswithme.maps.location.LocationHelper;
|
||||
import com.mapswithme.maps.location.LocationPredictor;
|
||||
|
@ -1433,8 +1433,14 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
|
||||
private void showRoutingDisclaimer()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int resId : new int[] {R.string.dialog_routing_disclaimer_priority, R.string.dialog_routing_disclaimer_precision,
|
||||
R.string.dialog_routing_disclaimer_recommendations, R.string.dialog_routing_disclaimer_beware})
|
||||
builder.append(getString(resId)).append("\n\n");
|
||||
|
||||
new AlertDialog.Builder(this)
|
||||
.setMessage(getString(R.string.routing_disclaimer))
|
||||
.setTitle(R.string.dialog_routing_disclaimer_title)
|
||||
.setMessage(builder.toString())
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
|
@ -1534,7 +1540,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (resultCode == RoutingResultCodes.NO_ERROR)
|
||||
if (resultCode == RoutingResultCodesProcessor.NO_ERROR)
|
||||
{
|
||||
mRlTurnByTurnBox.setVisibility(View.GONE);
|
||||
ViewCompat.setAlpha(mLayoutRoutingGo, 1);
|
||||
|
@ -1578,7 +1584,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
public void onOk()
|
||||
{
|
||||
closeRouting();
|
||||
if (RoutingResultCodes.isDownloadable(resultCode))
|
||||
if (RoutingResultCodesProcessor.isDownloadable(resultCode))
|
||||
showDownloader(false);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
package com.mapswithme.maps.data;
|
||||
|
||||
import android.util.Pair;
|
||||
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
|
||||
// Codes correspond to native routing::IRouter::ResultCode
|
||||
public class RoutingResultCodes
|
||||
{
|
||||
public static final int NO_ERROR = 0;
|
||||
public static final int CANCELLED = 1;
|
||||
public static final int NO_POSITION = 2;
|
||||
public static final int INCONSISTENT_MWM_ROUTE = 3;
|
||||
public static final int ROUTING_FILE_NOT_EXIST = 4;
|
||||
public static final int START_POINT_NOT_FOUND = 5;
|
||||
public static final int END_POINT_NOT_FOUND = 6;
|
||||
public static final int DIFFERENT_MWM = 7;
|
||||
public static final int ROUTE_NOT_FOUND = 8;
|
||||
public static final int INTERNAL_ERROR = 9;
|
||||
|
||||
public static Pair<String, String> getDialogTitleSubtitle(int errorCode)
|
||||
{
|
||||
int titleRes = 0, messageRes = 0;
|
||||
switch (errorCode)
|
||||
{
|
||||
case NO_POSITION:
|
||||
// TODO add title translations
|
||||
// titleRes =
|
||||
messageRes = R.string.routing_failed_unknown_my_position;
|
||||
break;
|
||||
case INCONSISTENT_MWM_ROUTE:
|
||||
case ROUTING_FILE_NOT_EXIST:
|
||||
titleRes = R.string.routing_download_maps_along;
|
||||
messageRes = R.string.routing_requires_all_map;
|
||||
break;
|
||||
case START_POINT_NOT_FOUND:
|
||||
// TODO add title translations
|
||||
// titleRes =
|
||||
messageRes = R.string.routing_failed_start_point_not_found;
|
||||
break;
|
||||
case END_POINT_NOT_FOUND:
|
||||
// TODO add title translations
|
||||
// titleRes =
|
||||
messageRes = R.string.routing_failed_dst_point_not_found;
|
||||
break;
|
||||
case DIFFERENT_MWM:
|
||||
// TODO add title translations
|
||||
// titleRes =
|
||||
messageRes = R.string.routing_failed_cross_mwm_building;
|
||||
break;
|
||||
case ROUTE_NOT_FOUND:
|
||||
// TODO add title translations
|
||||
// titleRes =
|
||||
messageRes = R.string.routing_failed_route_not_found;
|
||||
break;
|
||||
case INTERNAL_ERROR:
|
||||
// TODO add title translations
|
||||
// titleRes =
|
||||
messageRes = R.string.routing_failed_internal_error;
|
||||
break;
|
||||
}
|
||||
|
||||
return new Pair<>(titleRes == 0 ? "" : MWMApplication.get().getString(titleRes), MWMApplication.get().getString(messageRes));
|
||||
}
|
||||
|
||||
public static boolean isDownloadable(int resultCode)
|
||||
{
|
||||
return resultCode == INCONSISTENT_MWM_ROUTE || resultCode == ROUTING_FILE_NOT_EXIST;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package com.mapswithme.maps.data;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.mapswithme.maps.LocationState;
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// Codes correspond to native routing::IRouter::ResultCode
|
||||
public class RoutingResultCodesProcessor
|
||||
{
|
||||
public static final int NO_ERROR = 0;
|
||||
public static final int CANCELLED = 1;
|
||||
public static final int NO_POSITION = 2;
|
||||
public static final int INCONSISTENT_MWM_ROUTE = 3;
|
||||
public static final int ROUTING_FILE_NOT_EXIST = 4;
|
||||
public static final int START_POINT_NOT_FOUND = 5;
|
||||
public static final int END_POINT_NOT_FOUND = 6;
|
||||
public static final int DIFFERENT_MWM = 7;
|
||||
public static final int ROUTE_NOT_FOUND = 8;
|
||||
public static final int NEED_MORE_MAPS = 9;
|
||||
public static final int INTERNAL_ERROR = 10;
|
||||
|
||||
public static Pair<String, String> getDialogTitleSubtitle(int errorCode)
|
||||
{
|
||||
Resources resources = MWMApplication.get().getResources();
|
||||
int titleRes = 0;
|
||||
List<String> messages = new ArrayList<>();
|
||||
switch (errorCode)
|
||||
{
|
||||
case NO_POSITION:
|
||||
if (LocationState.INSTANCE.getLocationStateMode() == LocationState.UNKNOWN_POSITION)
|
||||
{
|
||||
titleRes = R.string.dialog_routing_location_turn_on;
|
||||
messages.add(resources.getString(R.string.dialog_routing_location_unknown_turn_on));
|
||||
}
|
||||
else
|
||||
{
|
||||
titleRes = R.string.dialog_routing_check_gps;
|
||||
messages.add(resources.getString(R.string.dialog_routing_error_location_not_found));
|
||||
messages.add(resources.getString(R.string.dialog_routing_location_turn_wifi));
|
||||
}
|
||||
break;
|
||||
case INCONSISTENT_MWM_ROUTE:
|
||||
case ROUTING_FILE_NOT_EXIST:
|
||||
titleRes = R.string.routing_download_maps_along;
|
||||
messages.add(resources.getString(R.string.routing_requires_all_map));
|
||||
break;
|
||||
case START_POINT_NOT_FOUND:
|
||||
titleRes = R.string.dialog_routing_change_start;
|
||||
messages.add(resources.getString(R.string.dialog_routing_start_not_determined));
|
||||
messages.add(resources.getString(R.string.dialog_routing_select_closer_start));
|
||||
break;
|
||||
case END_POINT_NOT_FOUND:
|
||||
titleRes = R.string.dialog_routing_change_end;
|
||||
messages.add(resources.getString(R.string.dialog_routing_end_not_determined));
|
||||
messages.add(resources.getString(R.string.dialog_routing_select_closer_end));
|
||||
break;
|
||||
case DIFFERENT_MWM:
|
||||
messages.add(resources.getString(R.string.routing_failed_cross_mwm_building));
|
||||
break;
|
||||
case ROUTE_NOT_FOUND:
|
||||
titleRes = R.string.dialog_routing_unable_locate_route;
|
||||
messages.add(resources.getString(R.string.dialog_routing_cant_build_route));
|
||||
messages.add(resources.getString(R.string.dialog_routing_change_start_or_end));
|
||||
break;
|
||||
case INTERNAL_ERROR:
|
||||
titleRes = R.string.dialog_routing_system_error;
|
||||
messages.add(resources.getString(R.string.dialog_routing_application_error));
|
||||
messages.add(resources.getString(R.string.dialog_routing_try_again));
|
||||
break;
|
||||
case NEED_MORE_MAPS:
|
||||
titleRes = R.string.dialog_routing_download_and_build_cross_route;
|
||||
messages.add(resources.getString(R.string.dialog_routing_application_error));
|
||||
messages.add(resources.getString(R.string.dialog_routing_try_again));
|
||||
break;
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (String messagePart : messages)
|
||||
builder.append(messagePart).append("\n\n");
|
||||
|
||||
return new Pair<>(titleRes == 0 ? "" : resources.getString(titleRes), builder.toString());
|
||||
}
|
||||
|
||||
public static boolean isDownloadable(int resultCode)
|
||||
{
|
||||
return resultCode == INCONSISTENT_MWM_ROUTE || resultCode == ROUTING_FILE_NOT_EXIST;
|
||||
}
|
||||
}
|
|
@ -20,7 +20,7 @@ import com.mapswithme.maps.MapStorage;
|
|||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.adapter.DisabledChildSimpleExpandableListAdapter;
|
||||
import com.mapswithme.maps.base.BaseMwmDialogFragment;
|
||||
import com.mapswithme.maps.data.RoutingResultCodes;
|
||||
import com.mapswithme.maps.data.RoutingResultCodesProcessor;
|
||||
import com.mapswithme.util.StringUtils;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class RoutingErrorDialogFragment extends BaseMwmDialogFragment
|
|||
public Dialog onCreateDialog(Bundle savedInstanceState)
|
||||
{
|
||||
parseArguments();
|
||||
final Pair<String, String> titleMessage = RoutingResultCodes.getDialogTitleSubtitle(mResultCode);
|
||||
final Pair<String, String> titleMessage = RoutingResultCodesProcessor.getDialogTitleSubtitle(mResultCode);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
|
||||
.setTitle(titleMessage.first)
|
||||
.setCancelable(true);
|
||||
|
@ -178,14 +178,12 @@ public class RoutingErrorDialogFragment extends BaseMwmDialogFragment
|
|||
final List<Map<String, String>> groupData = new ArrayList<>();
|
||||
|
||||
final Map<String, String> countriesGroup = new HashMap<>();
|
||||
// TODO translations
|
||||
countriesGroup.put(GROUP_NAME, "Countries (" + mMissingCountries.length + ")");
|
||||
countriesGroup.put(GROUP_NAME, getString(R.string.maps) + " (" + mMissingCountries.length + ") ");
|
||||
countriesGroup.put(GROUP_SIZE, StringUtils.getFileSizeString(getCountriesSizeInBytes(StorageOptions.MAP_OPTION_MAP_ONLY)));
|
||||
groupData.add(countriesGroup);
|
||||
|
||||
final Map<String, String> routesGroup = new HashMap<>();
|
||||
// TODO translations
|
||||
routesGroup.put(GROUP_NAME, "Routes (" + mMissingCountries.length + ")");
|
||||
routesGroup.put(GROUP_NAME, getString(R.string.dialog_routing_routes_size) + " (" + mMissingCountries.length + ") ");
|
||||
routesGroup.put(GROUP_SIZE, StringUtils.getFileSizeString(getCountriesSizeInBytes(StorageOptions.MAP_OPTION_CAR_ROUTING)));
|
||||
groupData.add(routesGroup);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue