Update waypoints card
This commit is contained in:
parent
d37e3dda08
commit
f9943a6e97
5 changed files with 105 additions and 20 deletions
|
@ -103,6 +103,14 @@
|
||||||
android:layout_marginLeft="@dimen/dashFavIconMargin"
|
android:layout_marginLeft="@dimen/dashFavIconMargin"
|
||||||
android:background="?attr/dashboard_button"
|
android:background="?attr/dashboard_button"
|
||||||
android:src="@drawable/ic_action_gdirections_light" />
|
android:src="@drawable/ic_action_gdirections_light" />
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/options"
|
||||||
|
android:layout_width="@dimen/dashListItemHeight"
|
||||||
|
android:layout_height="@dimen/dashListItemHeight"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:background="?attr/options_button_background"
|
||||||
|
android:src="?attr/list_settings_icon" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -9,6 +9,8 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
<string name="waypoint_visit_after">Visit after</string>
|
||||||
|
<string name="waypoint_visit_before">Visit before</string>
|
||||||
<string name="simulate_your_location">Simulate your location</string>
|
<string name="simulate_your_location">Simulate your location</string>
|
||||||
<string name="drawer">Flat list</string>
|
<string name="drawer">Flat list</string>
|
||||||
<string name="short_location_on_map">Lat %1$s\n Lon %2$s</string>
|
<string name="short_location_on_map">Lat %1$s\n Lon %2$s</string>
|
||||||
|
|
|
@ -188,6 +188,13 @@ public class TargetPointsHelper {
|
||||||
} else {
|
} else {
|
||||||
settings.deleteIntermediatePoint(index);
|
settings.deleteIntermediatePoint(index);
|
||||||
intermediatePoints.remove(index);
|
intermediatePoints.remove(index);
|
||||||
|
int ind = 0;
|
||||||
|
for(TargetPoint tp : intermediatePoints) {
|
||||||
|
tp.index = ind++;
|
||||||
|
}
|
||||||
|
if(pointToNavigate != null) {
|
||||||
|
pointToNavigate.index = ind++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
updateRouteAndReferesh(updateRoute);
|
updateRouteAndReferesh(updateRoute);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,10 @@ import net.osmand.plus.TargetPointsHelper;
|
||||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||||
|
import net.osmand.plus.dialogs.FavoriteDialogs;
|
||||||
import net.osmand.plus.helpers.FontCache;
|
import net.osmand.plus.helpers.FontCache;
|
||||||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||||
|
import android.app.Dialog;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
@ -24,6 +26,7 @@ import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -34,7 +37,7 @@ import android.widget.TextView;
|
||||||
public class DashWaypointsFragment extends DashLocationFragment {
|
public class DashWaypointsFragment extends DashLocationFragment {
|
||||||
public static final String TAG = "DASH_WAYPOINTS_FRAGMENT";
|
public static final String TAG = "DASH_WAYPOINTS_FRAGMENT";
|
||||||
List<TargetPoint> points = new ArrayList<TargetPoint>();
|
List<TargetPoint> points = new ArrayList<TargetPoint>();
|
||||||
private boolean showAll;
|
private static boolean SHOW_ALL;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
@ -47,7 +50,7 @@ public class DashWaypointsFragment extends DashLocationFragment {
|
||||||
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
showAll = !showAll;
|
SHOW_ALL = !SHOW_ALL;
|
||||||
setupTargets();
|
setupTargets();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -68,10 +71,12 @@ public class DashWaypointsFragment extends DashLocationFragment {
|
||||||
} else {
|
} else {
|
||||||
(mainView.findViewById(R.id.main_fav)).setVisibility(View.VISIBLE);
|
(mainView.findViewById(R.id.main_fav)).setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
points = showAll ? Collections.singletonList(helper.getPointToNavigate()) :
|
points = SHOW_ALL ? helper.getIntermediatePointsWithTarget() :
|
||||||
helper.getIntermediatePointsWithTarget();
|
Collections.singletonList(helper.getPointToNavigate());
|
||||||
((Button) mainView.findViewById(R.id.show_all)).setText(showAll? getString(R.string.shared_string_collapse) :
|
((Button) mainView.findViewById(R.id.show_all)).setText(SHOW_ALL? getString(R.string.shared_string_collapse) :
|
||||||
getString(R.string.shared_string_show_all));
|
getString(R.string.shared_string_show_all));
|
||||||
|
((Button) mainView.findViewById(R.id.show_all)).setVisibility(
|
||||||
|
helper.getIntermediatePoints().size() == 0 ? View.INVISIBLE : View.VISIBLE);
|
||||||
((TextView) mainView.findViewById(R.id.fav_text)).setText(getString(R.string.waypoints) + " (" +
|
((TextView) mainView.findViewById(R.id.fav_text)).setText(getString(R.string.waypoints) + " (" +
|
||||||
helper.getIntermediatePointsWithTarget().size()+")");
|
helper.getIntermediatePointsWithTarget().size()+")");
|
||||||
LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items);
|
LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items);
|
||||||
|
@ -96,13 +101,27 @@ public class DashWaypointsFragment extends DashLocationFragment {
|
||||||
distances.add(dv);
|
distances.add(dv);
|
||||||
|
|
||||||
name.setText(PointDescription.getSimpleName(point, getActivity()));
|
name.setText(PointDescription.getSimpleName(point, getActivity()));
|
||||||
view.findViewById(R.id.navigate_to).setVisibility(View.VISIBLE);
|
ImageButton options = ((ImageButton)view.findViewById(R.id.options));
|
||||||
view.findViewById(R.id.navigate_to).setOnClickListener(new View.OnClickListener() {
|
options.setVisibility(View.VISIBLE);
|
||||||
|
options.setImageDrawable(getMyApplication().getIconsCache().
|
||||||
|
getContentIcon(R.drawable.ic_overflow_menu_white));
|
||||||
|
options.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
selectModel(point, view);
|
selectModel(point, view);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ImageButton navigate = ((ImageButton)view.findViewById(R.id.navigate_to));
|
||||||
|
navigate.setImageDrawable(getMyApplication().getIconsCache().
|
||||||
|
getContentIcon(R.drawable.ic_action_gdirections_dark));
|
||||||
|
navigate.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
dashboard.navigationAction();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
view.setOnClickListener(new View.OnClickListener() {
|
view.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -117,15 +136,59 @@ public class DashWaypointsFragment extends DashLocationFragment {
|
||||||
this.distances = distances;
|
this.distances = distances;
|
||||||
}
|
}
|
||||||
private void selectModel(final TargetPoint model, View v) {
|
private void selectModel(final TargetPoint model, View v) {
|
||||||
PointDescription name = model.getOriginalPointDescription();
|
|
||||||
boolean light = ((OsmandApplication) getActivity().getApplication()).getSettings().isLightContent();
|
boolean light = ((OsmandApplication) getActivity().getApplication()).getSettings().isLightContent();
|
||||||
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
|
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
|
||||||
OsmandSettings settings = ((OsmandApplication) getActivity().getApplication()).getSettings();
|
MenuItem
|
||||||
DirectionsDialogs.createDirectionsActionsPopUpMenu(optionsMenu, new LatLon(model.getLatitude(), model.getLongitude()),
|
item = optionsMenu.getMenu().add(
|
||||||
model, name, settings.getLastKnownMapZoom(), getActivity(), true);
|
R.string.shared_string_add_to_favorites).setIcon(light ?
|
||||||
MenuItem item = optionsMenu.getMenu().add(
|
R.drawable.ic_action_fav_light : R.drawable.ic_action_fav_dark);
|
||||||
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
Dialog dlg = FavoriteDialogs.createAddFavouriteDialog(getActivity(), args);
|
||||||
|
dlg.show();
|
||||||
|
FavoriteDialogs.prepareAddFavouriteDialog(getActivity(), dlg, args, model.getLatitude(), model.getLongitude(),
|
||||||
|
model.getOriginalPointDescription());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(SHOW_ALL && getMyApplication().getTargetPointsHelper().getIntermediatePoints().size() > 0) {
|
||||||
|
final List<TargetPoint> allTargets = getMyApplication().getTargetPointsHelper().getIntermediatePointsWithTarget();
|
||||||
|
boolean target = model == getMyApplication().getTargetPointsHelper().getPointToNavigate();
|
||||||
|
if (model.index > 0 || target) {
|
||||||
|
final int ind = target ? allTargets.size() - 1 : model.index;
|
||||||
|
item = optionsMenu.getMenu().add(R.string.waypoint_visit_before)
|
||||||
|
.setIcon(light ? R.drawable.ic_action_up_light : R.drawable.ic_action_up_dark);
|
||||||
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
TargetPoint remove = allTargets.remove(ind - 1);
|
||||||
|
allTargets.add(ind, remove);
|
||||||
|
getMyApplication().getTargetPointsHelper().reorderAllTargetPoints(allTargets, true);
|
||||||
|
setupTargets();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!target) {
|
||||||
|
item = optionsMenu.getMenu().add(R.string.waypoint_visit_after)
|
||||||
|
.setIcon(light ? R.drawable.ic_action_down_light : R.drawable.ic_action_down_dark);
|
||||||
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
TargetPoint remove = allTargets.remove(model.index + 1);
|
||||||
|
allTargets.add(model.index, remove);
|
||||||
|
getMyApplication().getTargetPointsHelper().reorderAllTargetPoints(allTargets, true);
|
||||||
|
setupTargets();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
item = optionsMenu.getMenu().add(
|
||||||
R.string.shared_string_delete).setIcon(light ?
|
R.string.shared_string_delete).setIcon(light ?
|
||||||
R.drawable.ic_action_delete_light : R.drawable.ic_action_delete_dark);
|
R.drawable.ic_action_gdiscard_light: R.drawable.ic_action_gdiscard_dark);
|
||||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
|
|
@ -264,13 +264,7 @@ public class DashboardOnMap {
|
||||||
getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.set(false);
|
getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.set(false);
|
||||||
mapActivity.getMapActions().toggleDrawer();
|
mapActivity.getMapActions().toggleDrawer();
|
||||||
} else if(item.getItemId() == DIRECTIONS_ID) {
|
} else if(item.getItemId() == DIRECTIONS_ID) {
|
||||||
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
|
navigationAction();
|
||||||
if(!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
|
|
||||||
mapActivity.getMapActions().enterRoutePlanningMode(null, null, false);
|
|
||||||
} else {
|
|
||||||
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
|
|
||||||
mapActivity.refreshMap();
|
|
||||||
}
|
|
||||||
} else if(item.getItemId() == CONFIGURE_SCREEN_ID) {
|
} else if(item.getItemId() == CONFIGURE_SCREEN_ID) {
|
||||||
mapActivity.getMapActions().prepareConfigureScreen();
|
mapActivity.getMapActions().prepareConfigureScreen();
|
||||||
mapActivity.getMapActions().toggleDrawer();
|
mapActivity.getMapActions().toggleDrawer();
|
||||||
|
@ -285,6 +279,17 @@ public class DashboardOnMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void navigationAction() {
|
||||||
|
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
|
||||||
|
if(!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
|
||||||
|
mapActivity.getMapActions().enterRoutePlanningMode(null, null, false);
|
||||||
|
} else {
|
||||||
|
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
|
||||||
|
mapActivity.refreshMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// To animate view slide out from right to left
|
// To animate view slide out from right to left
|
||||||
private void open(View view){
|
private void open(View view){
|
||||||
TranslateAnimation animate = new TranslateAnimation(-mapActivity.findViewById(R.id.ParentLayout).getWidth(),0,0,0);
|
TranslateAnimation animate = new TranslateAnimation(-mapActivity.findViewById(R.id.ParentLayout).getWidth(),0,0,0);
|
||||||
|
|
Loading…
Reference in a new issue