Waypoint menu in progress

This commit is contained in:
Alexey Kulish 2016-01-02 11:09:33 +03:00
parent 03d4173131
commit 4cb2a3ef10
9 changed files with 175 additions and 43 deletions

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom"/>
</LinearLayout>

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_width="match_parent"
android:layout_height="6dp"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_top"/>
</LinearLayout>

View file

@ -91,6 +91,14 @@ public class AndroidUtils {
setBackground(ctx, view, night, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
}
public static void setBackgroundColor(Context ctx, View view, boolean night, int lightResId, int darkResId) {
view.setBackgroundColor(ctx.getResources().getColor(night ? darkResId : lightResId));
}
public static void setListItemBackground(Context ctx, View view, boolean night) {
setBackgroundColor(ctx, view, night, R.color.bg_color_light, R.color.bg_color_dark);
}
public static void setTextPrimaryColor(Context ctx, TextView textView, boolean night) {
textView.setTextColor(night ?
ctx.getResources().getColor(R.color.primary_text_dark)

View file

@ -346,6 +346,7 @@ public class ContextMenuAdapter {
}
if (convertView == null || (!lid.equals(convertView.getTag()))) {
convertView = activity.getLayoutInflater().inflate(lid, parent, false);
AndroidUtils.setListItemBackground(ctx, convertView, !holoLight);
convertView.setTag(lid);
}
TextView tv = (TextView) convertView.findViewById(R.id.title);

View file

@ -46,6 +46,13 @@ public class AppModeDialog {
public static View prepareAppModeView(Activity a, final List<ApplicationMode> values , final Set<ApplicationMode> selected,
ViewGroup parent, final boolean singleSelection, boolean drawer, boolean useMapTheme, final View.OnClickListener onClickListener) {
View ll = a.getLayoutInflater().inflate(R.layout.mode_toggles, parent);
if (useMapTheme) {
AndroidUtils.setListItemBackground(a, ll,
((OsmandApplication) a.getApplication()).getDaynightHelper().isNightModeForMapControls());
} else {
AndroidUtils.setListItemBackground(a, ll,
!((OsmandApplication) a.getApplication()).getSettings().isLightContent());
}
final View[] buttons = new View[values.size()];
int k = 0;
for(ApplicationMode ma : values) {

View file

@ -154,7 +154,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
public enum DashboardActionButtonType {
MY_LOCATION,
NAVIGATE
NAVIGATE,
ROUTE
}
private class DashboardActionButton {
@ -191,13 +192,26 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
mFlexibleBlurSpaceHeight = mapActivity.getResources().getDimensionPixelSize(
R.dimen.dashboard_map_toolbar);
// Set padding view for ListView. This is the flexible space.
paddingView = new View(mapActivity);
paddingView = new FrameLayout(mapActivity);
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
mFlexibleSpaceImageHeight);
paddingView.setLayoutParams(lp);
// This is required to disable header's list selector effect
paddingView.setClickable(true);
paddingView.setOnClickListener(listener);
FrameLayout shadowContainer = new FrameLayout(mapActivity);
FrameLayout.LayoutParams fl = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT);
fl.gravity = Gravity.BOTTOM;
shadowContainer.setLayoutParams(fl);
ImageView shadow = new ImageView(mapActivity);
shadow.setImageDrawable(mapActivity.getResources().getDrawable(R.drawable.bg_shadow_onmap));
shadow.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM));
shadow.setScaleType(ScaleType.FIT_XY);
shadowContainer.addView(shadow);
((FrameLayout)paddingView).addView(shadowContainer);
listView.addHeaderView(paddingView);
listBackgroundView = mapActivity.findViewById(R.id.dash_list_background);
}
@ -378,8 +392,19 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
}
};
DashboardActionButton routeButton = new DashboardActionButton();
routeButton.icon = mapActivity.getResources().getDrawable(R.drawable.map_directions);
routeButton.onClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
mapActivity.getMapLayers().getMapControlsLayer().doRoute();
hideDashboard();
}
};
actionButtons.put(DashboardActionButtonType.MY_LOCATION, myLocationButton);
actionButtons.put(DashboardActionButtonType.NAVIGATE, navigateButton);
actionButtons.put(DashboardActionButtonType.ROUTE, routeButton);
}
private void setActionButton(DashboardType type) {
@ -391,6 +416,21 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
button = actionButtons.get(DashboardActionButtonType.MY_LOCATION);
} else if (type == DashboardType.ROUTE_PREFERENCES) {
button = actionButtons.get(DashboardActionButtonType.NAVIGATE);
} else if (type == DashboardType.WAYPOINTS || type == DashboardType.WAYPOINTS_EDIT || type == DashboardType.WAYPOINTS_FLAT) {
boolean routePlanningMode = false;
RoutingHelper rh = mapActivity.getRoutingHelper();
if (rh.isRoutePlanningMode()) {
routePlanningMode = true;
} else if ((rh.isRouteCalculated() || rh.isRouteBeingCalculated()) && !rh.isFollowingMode()) {
routePlanningMode = true;
}
boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode();
if (routePlanningMode || routeFollowingMode) {
button = actionButtons.get(DashboardActionButtonType.NAVIGATE);
} else {
button = actionButtons.get(DashboardActionButtonType.ROUTE);
}
}
if (button != null) {
@ -528,22 +568,30 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
private void applyDayNightMode() {
if (nightMode) {
if (listBackgroundView != null) {
listBackgroundView.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_dark));
listBackgroundView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_dark));
} else {
listView.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_dark));
listView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_dark));
}
if (visibleType != DashboardType.WAYPOINTS) {
Drawable d = new ColorDrawable(mapActivity.getResources().getColor(R.color.dashboard_divider_dark));
listView.setDivider(d);
listView.setDividerHeight(dpToPx(1f));
} else {
listView.setDivider(null);
}
Drawable d = new ColorDrawable(mapActivity.getResources().getColor(R.color.dashboard_divider_dark));
listView.setDivider(d);
listView.setDividerHeight(dpToPx(1f));
} else {
if (listBackgroundView != null) {
listBackgroundView.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_light));
listBackgroundView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_light));
} else {
listView.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_light));
listView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_light));
}
if (visibleType != DashboardType.WAYPOINTS) {
Drawable d = new ColorDrawable(mapActivity.getResources().getColor(R.color.dashboard_divider_light));
listView.setDivider(d);
listView.setDividerHeight(dpToPx(1f));
} else {
listView.setDivider(null);
}
Drawable d = new ColorDrawable(mapActivity.getResources().getColor(R.color.dashboard_divider_light));
listView.setDivider(d);
listView.setDividerHeight(dpToPx(1f));
}
}
@ -865,6 +913,9 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
private boolean isActionButtonVisible() {
return visibleType == DashboardType.DASHBOARD
|| visibleType == DashboardType.WAYPOINTS
|| visibleType == DashboardType.WAYPOINTS_EDIT
|| visibleType == DashboardType.WAYPOINTS_FLAT
|| visibleType == DashboardType.LIST_MENU
|| visibleType == DashboardType.ROUTE_PREFERENCES
|| visibleType == DashboardType.CONFIGURE_SCREEN;

View file

@ -4,6 +4,8 @@ import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnDismissListener;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AlertDialog;
@ -59,7 +61,7 @@ public class WaypointDialogHelper {
}
public static void updatePointInfoView(final OsmandApplication app, final Activity activity,
View localView, final LocationPointWrapper ps,
View localView, final LocationPointWrapper ps,
final boolean mapCenter, final boolean nightMode) {
WaypointHelper wh = app.getWaypointHelper();
final LocationPoint point = ps.getPoint();
@ -101,11 +103,11 @@ public class WaypointDialogHelper {
descr = pd.getName();
}
if(textShadow != null) {
if (textShadow != null) {
textShadow.setText(descr);
}
text.setText(descr);
// ((Spannable) text.getText()).setSpan(
// new ForegroundColorSpan(ctx.getResources().getColor(R.color.color_distance)), 0, distance.length() - 1,
// 0);
@ -116,7 +118,7 @@ public class WaypointDialogHelper {
final boolean edit, final List<LocationPointWrapper> deletedPoints,
final MapActivity ctx, final int[] running, final boolean flat, final boolean nightMode) {
final List<Object> points;
if(flat) {
if (flat) {
points = new ArrayList<Object>(waypointHelper.getAllPoints());
} else {
points = getPoints();
@ -129,15 +131,38 @@ public class WaypointDialogHelper {
// User super class to create the View
View v = convertView;
final ArrayAdapter<Object> thisAdapter = this;
boolean labelView = (getItem(position) instanceof Integer);
if (getItem(position) instanceof RadiusItem) {
final int type = ((RadiusItem) getItem(position)).type;
Object obj = getItem(position);
boolean labelView = (obj instanceof Integer);
boolean topDividerView = (obj instanceof Boolean) && ((Boolean) obj);
boolean bottomDividerView = (obj instanceof Boolean) && !((Boolean) obj);
if (obj instanceof RadiusItem) {
final int type = ((RadiusItem) obj).type;
v = createItemForRadiusProximity(ctx, type, running, position, thisAdapter, nightMode);
//Drawable d = new ColorDrawable(mapActivity.getResources().getColor(R.color.dashboard_divider_light));
if (nightMode) {
v.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_dark));
} else {
v.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_light));
}
} else if (labelView) {
v = createItemForCategory(ctx, (Integer) getItem(position), running, position, thisAdapter, nightMode);
} else {
LocationPointWrapper point = (LocationPointWrapper) getItem(position);
v = createItemForCategory(ctx, (Integer) obj, running, position, thisAdapter, nightMode);
if (nightMode) {
v.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_dark));
} else {
v.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_light));
}
} else if (topDividerView) {
v = ctx.getLayoutInflater().inflate(R.layout.card_top_divider, null);
} else if (bottomDividerView) {
v = ctx.getLayoutInflater().inflate(R.layout.card_bottom_divider, null);
} else if (obj instanceof LocationPointWrapper) {
LocationPointWrapper point = (LocationPointWrapper) obj;
v = updateWaypointItemView(edit, deletedPoints, app, ctx, v, point, this, nightMode);
if (nightMode) {
v.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_dark));
} else {
v.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_light));
}
}
return v;
}
@ -146,11 +171,10 @@ public class WaypointDialogHelper {
};
}
public static View updateWaypointItemView(final boolean edit, final List<LocationPointWrapper> deletedPoints,
final OsmandApplication app, final Activity ctx, View v, final LocationPointWrapper point,
final ArrayAdapter adapter, final boolean nightMode) {
final OsmandApplication app, final Activity ctx, View v, final LocationPointWrapper point,
final ArrayAdapter adapter, final boolean nightMode) {
if (v == null || v.findViewById(R.id.info_close) == null) {
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
}
@ -161,12 +185,12 @@ public class WaypointDialogHelper {
} else {
remove.setVisibility(View.VISIBLE);
((ImageButton) remove).setImageDrawable(app.getIconsCache().getContentIcon(
R.drawable.ic_action_gremove_dark, !nightMode));
R.drawable.ic_action_gremove_dark, !nightMode));
remove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
deletedPoints.add(point);
if(adapter != null) {
if (adapter != null) {
adapter.remove(point);
adapter.notifyDataSetChanged();
}
@ -177,12 +201,10 @@ public class WaypointDialogHelper {
}
protected View createItemForRadiusProximity(final FragmentActivity ctx, final int type, final int[] running,
final int position, final ArrayAdapter<Object> thisAdapter, boolean nightMode) {
View v;
IconsCache iconsCache = app.getIconsCache();
IconsCache iconsCache = app.getIconsCache();
v = ctx.getLayoutInflater().inflate(R.layout.drawer_list_radius, null);
AndroidUtils.setTextPrimaryColor(mapActivity, (TextView) v.findViewById(R.id.title), nightMode);
final TextView radius = (TextView) v.findViewById(R.id.description);
@ -230,7 +252,7 @@ public class WaypointDialogHelper {
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (type == WaypointHelper.POI && btn.isChecked()){
if (type == WaypointHelper.POI && btn.isChecked()) {
running[0] = position;
thisAdapter.notifyDataSetInvalidated();
MapActivity map = (MapActivity) ctx;
@ -293,7 +315,7 @@ public class WaypointDialogHelper {
}
public AdapterView.OnItemClickListener getDrawerItemClickListener(final FragmentActivity ctx, final int[] running,
final ArrayAdapter<Object> listAdapter) {
final ArrayAdapter<Object> listAdapter) {
return new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
@ -390,7 +412,10 @@ public class WaypointDialogHelper {
if (!rc && i != WaypointHelper.WAYPOINTS && i != WaypointHelper.TARGETS) {
// skip
} else if (waypointHelper.isTypeVisible(i)) {
points.add(new Integer(i));
if (points.size() > 0) {
points.add(true);
}
points.add(i);
if ((i == WaypointHelper.POI || i == WaypointHelper.FAVORITES || i == WaypointHelper.WAYPOINTS)
&& rc) {
if (waypointHelper.isTypeEnabled(i)) {
@ -400,6 +425,7 @@ public class WaypointDialogHelper {
if (tp != null && tp.size() > 0) {
points.addAll(tp);
}
points.add(false);
}
}
return points;
@ -414,7 +440,7 @@ public class WaypointDialogHelper {
int fZoom = ctx.getMapView().getZoom() < 15 ? 15 : ctx.getMapView().getZoom();
double flat = locationPoint.getLatitude();
double flon = locationPoint.getLongitude();
if(!center) {
if (!center) {
RotatedTileBox cp = ctx.getMapView().getCurrentRotatedTileBox().copy();
cp.setCenterLocation(0.5f, 0.25f);
cp.setLatLonCenter(flat, flon);
@ -434,7 +460,7 @@ public class WaypointDialogHelper {
} else {
thread.startMoving(flat, flon, fZoom, true);
}
if(ctx.getDashboard().isVisible()) {
if (ctx.getDashboard().isVisible()) {
ctx.getDashboard().hideDashboard();
ctx.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().hide();
ctx.getContextMenu().show(

View file

@ -275,6 +275,7 @@ public class RoutePreferencesMenu {
LocalRoutingParameter parameter = getItem(position);
if (parameter instanceof MuteSoundRoutingParameter) {
View v = mapActivity.getLayoutInflater().inflate(R.layout.switch_select_list_item, null);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
v.findViewById(R.id.description_text).setVisibility(View.GONE);
v.findViewById(R.id.select_button).setVisibility(View.GONE);
((ImageView) v.findViewById(R.id.icon))
@ -296,6 +297,7 @@ public class RoutePreferencesMenu {
}
if (parameter instanceof AvoidRoadsRoutingParameter) {
View v = mapActivity.getLayoutInflater().inflate(R.layout.switch_select_list_item, null);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
((ImageView) v.findViewById(R.id.icon))
.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.ic_action_road_works_dark, !nightMode));
v.findViewById(R.id.check_item).setVisibility(View.GONE);
@ -320,6 +322,7 @@ public class RoutePreferencesMenu {
}
if (parameter instanceof VoiceGuidanceRoutingParameter) {
View v = mapActivity.getLayoutInflater().inflate(R.layout.switch_select_list_item, null);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
v.findViewById(R.id.icon).setVisibility(View.GONE);
v.findViewById(R.id.description_text).setVisibility(View.GONE);
v.findViewById(R.id.check_item).setVisibility(View.GONE);
@ -360,6 +363,7 @@ public class RoutePreferencesMenu {
}
if (parameter instanceof InterruptMusicRoutingParameter) {
View v = mapActivity.getLayoutInflater().inflate(R.layout.switch_select_list_item, null);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
v.findViewById(R.id.select_button).setVisibility(View.GONE);
v.findViewById(R.id.icon).setVisibility(View.GONE);
final CompoundButton btn = (CompoundButton) v.findViewById(R.id.check_item);
@ -383,6 +387,7 @@ public class RoutePreferencesMenu {
}
if (parameter instanceof GpxLocalRoutingParameter) {
View v = mapActivity.getLayoutInflater().inflate(R.layout.plan_route_gpx, null);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
AndroidUtils.setTextPrimaryColor(mapActivity, (TextView) v.findViewById(R.id.GPXRouteTitle), nightMode);
final TextView gpxSpinner = (TextView) v.findViewById(R.id.GPXRouteSpinner);
AndroidUtils.setTextPrimaryColor(mapActivity, gpxSpinner, nightMode);
@ -393,6 +398,7 @@ public class RoutePreferencesMenu {
}
if (parameter instanceof OtherSettingsRoutingParameter) {
View v = mapActivity.getLayoutInflater().inflate(R.layout.layers_list_activity_item, null);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
final ImageView icon = (ImageView) v.findViewById(R.id.icon);
icon.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.map_action_settings, !nightMode));
icon.setVisibility(View.VISIBLE);
@ -407,6 +413,7 @@ public class RoutePreferencesMenu {
private View inflateRoutingParameter(final int position) {
View v = mapActivity.getLayoutInflater().inflate(R.layout.layers_list_activity_item, null);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
final TextView tv = (TextView) v.findViewById(R.id.title);
final CheckBox ch = ((CheckBox) v.findViewById(R.id.check_item));
final LocalRoutingParameter rp = getItem(position);

View file

@ -358,17 +358,21 @@ public class MapControlsLayer extends OsmandMapLayer {
routePlanButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
onNavigationClick();
} else {
ActivityCompat.requestPermissions(mapActivity,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
REQUEST_LOCATION_FOR_NAVIGATION_PERMISSION);
}
doRoute();
}
});
}
public void doRoute() {
if (OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
onNavigationClick();
} else {
ActivityCompat.requestPermissions(mapActivity,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
REQUEST_LOCATION_FOR_NAVIGATION_PERMISSION);
}
}
public void doNavigate() {
mapRouteInfoMenu.hide();
startNavigation();