Pedestrian icon in routing.

This commit is contained in:
Dmitry Yunitsky 2015-06-11 03:14:11 +03:00 committed by Alex Zolotarev
parent 1f1862623e
commit eca7114aaf
3 changed files with 86 additions and 23 deletions

View file

@ -57,6 +57,7 @@ import com.mapswithme.maps.bookmarks.data.BookmarkManager;
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.location.LocationHelper;
import com.mapswithme.maps.location.LocationPredictor;
@ -997,12 +998,21 @@ public class MWMActivity extends BaseMwmFragmentActivity
startWatchingExternalStorage();
refreshZoomButtonsVisibility();
refreshRouterIcon();
SearchController.getInstance().onResume();
mPlacePage.onResume();
mLikesManager.showLikeDialogForCurrentSession();
}
private void refreshRouterIcon()
{
if (RouterTypes.getRouterType().equals(RouterTypes.ROUTER_VEHICLE))
mIvStartRouting.setImageResource(R.drawable.ic_route);
else
mIvStartRouting.setImageResource(R.drawable.ic_walk);
}
private void refreshZoomButtonsVisibility()
{
UiUtils.showIf(MWMApplication.get().nativeGetBoolean(SettingsActivity.ZOOM_BUTTON_ENABLED, true) ||
@ -1714,6 +1724,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
{
InputUtils.hideKeyboard(mBottomButtons);
mFadeView.fadeOut();
refreshRouterIcon();
}
}

View file

@ -0,0 +1,30 @@
package com.mapswithme.maps.data;
import android.content.Context;
import android.content.SharedPreferences;
import com.mapswithme.maps.MWMApplication;
import com.mapswithme.maps.R;
public class RouterTypes
{
private static final String KEY_ROUTER = "Router";
public static final String ROUTER_PEDESTRIAN = "pedestrian";
public static final String ROUTER_VEHICLE = "vehicle";
private RouterTypes() {}
public static void saveRouterType(String routerType)
{
final MWMApplication application = MWMApplication.get();
final SharedPreferences prefs = application.getSharedPreferences(application.getString(R.string.pref_file_name), Context.MODE_PRIVATE);
prefs.edit().putString(KEY_ROUTER, routerType).commit();
}
public static String getRouterType()
{
final MWMApplication application = MWMApplication.get();
return application.getSharedPreferences(application.getString(R.string.pref_file_name), Context.MODE_PRIVATE).getString(KEY_ROUTER, ROUTER_VEHICLE);
}
}

View file

@ -23,6 +23,7 @@ import com.mapswithme.maps.MWMActivity;
import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseMwmListFragment;
import com.mapswithme.maps.base.OnBackPressListener;
import com.mapswithme.maps.data.RouterTypes;
import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.util.InputUtils;
import com.mapswithme.util.Language;
@ -109,28 +110,6 @@ public class SearchFragment extends BaseMwmListFragment implements View.OnClickL
return mEtSearchQuery.getText().toString();
}
// TODO: This code only for demonstration purposes and will be removed soon
private boolean tryChangeMapStyleCmd(String str)
{
// Hook for shell command on change map style
final boolean isDark = str.equals("mapstyle:dark");
final boolean isLight = isDark ? false : str.equals("mapstyle:light");
if (!isDark && !isLight)
return false;
// close Search panel
mEtSearchQuery.setText(null);
InputUtils.hideKeyboard(mEtSearchQuery);
getActivity().onBackPressed();
// change map style for the Map activity
final int mapStyle = isDark ? Framework.MAP_STYLE_DARK : Framework.MAP_STYLE_LIGHT;
MWMActivity.setMapStyle(getActivity(), mapStyle);
return true;
}
private void setUpView(ViewGroup root)
{
mBtnVoice = root.findViewById(R.id.search_voice_input);
@ -146,7 +125,8 @@ public class SearchFragment extends BaseMwmListFragment implements View.OnClickL
public void afterTextChanged(Editable s)
{
// TODO: This code only for demonstration purposes and will be removed soon
if (tryChangeMapStyleCmd(s.toString()))
if (tryChangeMapStyle(s.toString()) ||
tryChangeRouter(s.toString()))
return;
if (runSearch() == STATUS_QUERY_EMPTY)
@ -221,6 +201,48 @@ public class SearchFragment extends BaseMwmListFragment implements View.OnClickL
listView.addHeaderView(getActivity().getLayoutInflater().inflate(R.layout.header_default, listView, false), null, false);
}
// FIXME: This code only for demonstration purposes and will be removed soon
private boolean tryChangeMapStyle(String str)
{
// Hook for shell command on change map style
final boolean isDark = str.equals("mapstyle:dark");
final boolean isLight = isDark ? false : str.equals("mapstyle:light");
if (!isDark && !isLight)
return false;
// close Search panel
mEtSearchQuery.setText(null);
InputUtils.hideKeyboard(mEtSearchQuery);
getActivity().onBackPressed();
// change map style for the Map activity
final int mapStyle = isDark ? Framework.MAP_STYLE_DARK : Framework.MAP_STYLE_LIGHT;
MWMActivity.setMapStyle(getActivity(), mapStyle);
return true;
}
private boolean tryChangeRouter(String query)
{
final boolean pedestrian = query.equals("pedestrian:on");
final boolean wehicle = query.equals("pedestrian:off");
if (!pedestrian && !wehicle)
return false;
mEtSearchQuery.setText(null);
InputUtils.hideKeyboard(mEtSearchQuery);
getActivity().onBackPressed();
RouterTypes.saveRouterType(pedestrian ? RouterTypes.ROUTER_PEDESTRIAN : RouterTypes.ROUTER_VEHICLE);
return false;
}
// FIXME: This code only for demonstration purposes and will be removed soon
@Override
public void onResume()
{