Added show all feature to route points
This commit is contained in:
parent
1b8f0d106f
commit
83e4bf17be
3 changed files with 100 additions and 56 deletions
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/MainLayout"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ExpandableListView
|
||||
android:id="@android:id/list"
|
||||
|
@ -25,4 +25,4 @@
|
|||
|
||||
<include layout="@layout/my_places_fabs"/>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
</RelativeLayout>
|
|
@ -1,8 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/expandable_list_item_background"
|
||||
android:minHeight="@dimen/list_item_height"
|
||||
|
@ -19,14 +20,15 @@
|
|||
android:id="@+id/list_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"
|
||||
android:layout_marginLeft="54dp"
|
||||
android:background="?attr/dashboard_divider"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="@dimen/list_content_padding">
|
||||
|
||||
|
@ -34,7 +36,6 @@
|
|||
android:id="@+id/toggle_item"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:focusable="false"
|
||||
android:visibility="gone"
|
||||
|
@ -44,18 +45,16 @@
|
|||
android:id="@+id/icon"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="@dimen/list_content_padding"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingRight="@dimen/list_content_padding"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
android:paddingTop="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label"
|
||||
|
@ -65,6 +64,18 @@
|
|||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="Point title"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
android:visibility="gone"
|
||||
osmand:textAllCapsCompat="true"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="SHOW ALL"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -78,14 +89,13 @@
|
|||
|
||||
<ImageButton
|
||||
android:id="@+id/options"
|
||||
android:contentDescription="@string/shared_string_more"
|
||||
android:layout_width="@dimen/list_item_height"
|
||||
android:layout_height="@dimen/list_item_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="?attr/dashboard_button"
|
||||
android:contentDescription="@string/shared_string_more"
|
||||
android:src="@drawable/ic_overflow_menu_white"
|
||||
android:visibility="visible"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
|
@ -21,6 +21,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MenuItem.OnActionExpandListener;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
|
@ -59,6 +60,7 @@ import net.osmand.plus.base.FavoriteImageDrawable;
|
|||
import net.osmand.plus.base.OsmandExpandableListFragment;
|
||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
|
||||
import net.osmand.plus.widgets.TextViewEx;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -80,20 +82,22 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
|
|||
public static final int DELETE_ACTION_ID = 3;
|
||||
public static final int SHARE_ID = 4;
|
||||
public static final int SELECT_MAP_MARKERS_ID = 5;
|
||||
public static final int SELECT_MAP_MARKERS_ACTION_MODE_ID = 6;
|
||||
//public static final int SELECT_MAP_MARKERS_ACTION_MODE_ID = 6;
|
||||
public static final int SELECT_FAVORITES_ID = 7;
|
||||
public static final int SELECT_FAVORITES_ACTION_MODE_ID = 8;
|
||||
|
||||
private static final int ROUTE_POINTS_LIMIT = 3;
|
||||
|
||||
private OsmandApplication app;
|
||||
private TrackActivityFragmentAdapter fragmentAdapter;
|
||||
final private PointGPXAdapter adapter = new PointGPXAdapter();
|
||||
|
||||
private boolean selectionMode = false;
|
||||
private boolean selectionMode;
|
||||
private LinkedHashMap<GpxDisplayItemType, Set<GpxDisplayItem>> selectedItems = new LinkedHashMap<>();
|
||||
private Set<Integer> selectedGroups = new LinkedHashSet<>();
|
||||
private ActionMode actionMode;
|
||||
private SearchView searchView;
|
||||
private boolean updateEnable;
|
||||
private boolean routePointsExpanded;
|
||||
|
||||
private View mainView;
|
||||
private PopupMenu popupItemMenu;
|
||||
|
@ -300,10 +304,10 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
|
|||
}
|
||||
|
||||
MenuItem mi = createMenuItem(menu, SEARCH_ID, R.string.search_poi_filter, R.drawable.ic_action_search_dark,
|
||||
R.drawable.ic_action_search_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||
searchView = new SearchView(activity);
|
||||
R.drawable.ic_action_search_dark, MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||
SearchView searchView = new SearchView(activity);
|
||||
FavoritesActivity.updateSearchView(activity, searchView);
|
||||
MenuItemCompat.setActionView(mi, searchView);
|
||||
mi.setActionView(searchView);
|
||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
|
@ -317,7 +321,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
|
|||
return true;
|
||||
}
|
||||
});
|
||||
MenuItemCompat.setOnActionExpandListener(mi, new MenuItemCompat.OnActionExpandListener() {
|
||||
mi.setOnActionExpandListener(new OnActionExpandListener() {
|
||||
@Override
|
||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||
return true;
|
||||
|
@ -329,7 +333,6 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
|
|||
List<GpxDisplayGroup> groups = getOriginalGroups();
|
||||
if (groups != null) {
|
||||
adapter.synchronizeGroups(groups);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
// Needed to hide intermediate progress bar after closing action mode
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
|
@ -341,22 +344,22 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
|
|||
}
|
||||
});
|
||||
|
||||
if (!MenuItemCompat.isActionViewExpanded(mi)) {
|
||||
if (!mi.isActionViewExpanded()) {
|
||||
|
||||
createMenuItem(menu, SHARE_ID, R.string.shared_string_share, R.drawable.ic_action_gshare_dark,
|
||||
R.drawable.ic_action_gshare_dark, MenuItemCompat.SHOW_AS_ACTION_NEVER);
|
||||
R.drawable.ic_action_gshare_dark, MenuItem.SHOW_AS_ACTION_NEVER);
|
||||
GPXFile gpxFile = getGpx();
|
||||
if (gpxFile != null && gpxFile.path != null) {
|
||||
final MapMarkersHelper markersHelper = app.getMapMarkersHelper();
|
||||
final boolean synced = markersHelper.getMarkersGroup(getGpx()) != null;
|
||||
createMenuItem(menu, SELECT_MAP_MARKERS_ID, synced ? R.string.remove_from_map_markers
|
||||
: R.string.shared_string_add_to_map_markers, R.drawable.ic_action_flag_dark,
|
||||
R.drawable.ic_action_flag_dark, MenuItemCompat.SHOW_AS_ACTION_NEVER);
|
||||
R.drawable.ic_action_flag_dark, MenuItem.SHOW_AS_ACTION_NEVER);
|
||||
}
|
||||
createMenuItem(menu, SELECT_FAVORITES_ID, R.string.shared_string_add_to_favorites, R.drawable.ic_action_fav_dark,
|
||||
R.drawable.ic_action_fav_dark, MenuItemCompat.SHOW_AS_ACTION_NEVER);
|
||||
R.drawable.ic_action_fav_dark, MenuItem.SHOW_AS_ACTION_NEVER);
|
||||
createMenuItem(menu, DELETE_ID, R.string.shared_string_delete, R.drawable.ic_action_delete_dark,
|
||||
R.drawable.ic_action_delete_dark, MenuItemCompat.SHOW_AS_ACTION_NEVER);
|
||||
R.drawable.ic_action_delete_dark, MenuItem.SHOW_AS_ACTION_NEVER);
|
||||
}
|
||||
this.optionsMenu = menu;
|
||||
}
|
||||
|
@ -505,7 +508,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
|
|||
setSelectionMode(true);
|
||||
createMenuItem(menu, SELECT_FAVORITES_ACTION_MODE_ID, R.string.shared_string_add_to_favorites,
|
||||
R.drawable.ic_action_fav_dark, R.drawable.ic_action_fav_dark,
|
||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||
MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
selectedItems.clear();
|
||||
selectedGroups.clear();
|
||||
adapter.notifyDataSetInvalidated();
|
||||
|
@ -587,9 +590,12 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
|
|||
|
||||
@Override
|
||||
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
||||
if (selectionMode) {
|
||||
final GpxDisplayItem item = adapter.getChild(groupPosition, childPosition);
|
||||
if (item == null) {
|
||||
routePointsExpanded = true;
|
||||
adapter.notifyDataSetChanged();
|
||||
} else if (selectionMode) {
|
||||
CheckBox ch = (CheckBox) v.findViewById(R.id.toggle_item);
|
||||
GpxDisplayItem item = adapter.getChild(groupPosition, childPosition);
|
||||
ch.setChecked(!ch.isChecked());
|
||||
if (ch.isChecked()) {
|
||||
Set<GpxDisplayItem> set = selectedItems.get(item.group.getType());
|
||||
|
@ -608,21 +614,18 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
|
|||
}
|
||||
updateSelectionMode(actionMode);
|
||||
} else {
|
||||
final GpxDisplayItem item = adapter.getChild(groupPosition, childPosition);
|
||||
if (item != null) {
|
||||
if (item.group.getGpx() != null) {
|
||||
app.getSelectedGpxHelper().setGpxFileToDisplay(item.group.getGpx());
|
||||
}
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
LatLon location = new LatLon(item.locationStart.lat, item.locationStart.lon);
|
||||
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(),
|
||||
settings.getLastKnownMapZoom(),
|
||||
new PointDescription(PointDescription.POINT_TYPE_WPT, item.name),
|
||||
false,
|
||||
item.locationStart);
|
||||
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
if (item.group.getGpx() != null) {
|
||||
app.getSelectedGpxHelper().setGpxFileToDisplay(item.group.getGpx());
|
||||
}
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
LatLon location = new LatLon(item.locationStart.lat, item.locationStart.lon);
|
||||
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(),
|
||||
settings.getLastKnownMapZoom(),
|
||||
new PointDescription(PointDescription.POINT_TYPE_WPT, item.name),
|
||||
false,
|
||||
item.locationStart);
|
||||
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -699,7 +702,14 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
|
|||
|
||||
@Override
|
||||
public GpxDisplayItem getChild(int groupPosition, int childPosition) {
|
||||
return itemGroups.get(groups.get(groupPosition)).get(childPosition);
|
||||
final GpxDisplayGroup group = getGroup(groupPosition);
|
||||
int count = itemGroups.get(group).size();
|
||||
if (group.getType() == GpxDisplayItemType.TRACK_POINTS || routePointsExpanded
|
||||
|| count <= ROUTE_POINTS_LIMIT + 1 || childPosition < ROUTE_POINTS_LIMIT) {
|
||||
return itemGroups.get(groups.get(groupPosition)).get(childPosition);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -709,7 +719,13 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
|
|||
|
||||
@Override
|
||||
public int getChildrenCount(int groupPosition) {
|
||||
return itemGroups.get(groups.get(groupPosition)).size();
|
||||
int count = itemGroups.get(groups.get(groupPosition)).size();
|
||||
final GpxDisplayGroup group = getGroup(groupPosition);
|
||||
if (group.getType() == GpxDisplayItemType.TRACK_POINTS || routePointsExpanded || count <= ROUTE_POINTS_LIMIT + 1) {
|
||||
return count;
|
||||
} else {
|
||||
return ROUTE_POINTS_LIMIT + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -814,12 +830,17 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
|
|||
|
||||
ImageView icon = (ImageView) row.findViewById(R.id.icon);
|
||||
TextView title = (TextView) row.findViewById(R.id.label);
|
||||
TextViewEx button = (TextViewEx) row.findViewById(R.id.button);
|
||||
TextView description = (TextView) row.findViewById(R.id.description);
|
||||
|
||||
final GpxDisplayItem gpxItem = getChild(groupPosition, childPosition);
|
||||
boolean isWpt = gpxItem.group.getType() == GpxDisplayItemType.TRACK_POINTS;
|
||||
boolean isWpt = gpxItem != null && gpxItem.group.getType() == GpxDisplayItemType.TRACK_POINTS;
|
||||
ImageView options = (ImageView) row.findViewById(R.id.options);
|
||||
if (isWpt) {
|
||||
title.setVisibility(View.VISIBLE);
|
||||
description.setVisibility(View.VISIBLE);
|
||||
button.setVisibility(View.GONE);
|
||||
|
||||
options.setFocusable(false);
|
||||
options.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(
|
||||
R.drawable.ic_overflow_menu_white));
|
||||
|
@ -866,19 +887,32 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
|
|||
}
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(), groupColor, false));
|
||||
} else {
|
||||
icon.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_marker_dark));
|
||||
boolean showAll = gpxItem == null;
|
||||
title.setVisibility(showAll ? View.GONE : View.VISIBLE);
|
||||
description.setVisibility(showAll ? View.GONE : View.VISIBLE);
|
||||
button.setVisibility(!showAll ? View.GONE : View.VISIBLE);
|
||||
|
||||
if (showAll) {
|
||||
int count = itemGroups.get(groups.get(groupPosition)).size();
|
||||
button.setText(getString(R.string.shared_string_show_all) + " - " + count);
|
||||
icon.setImageDrawable(null);
|
||||
} else {
|
||||
icon.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_marker_dark));
|
||||
}
|
||||
options.setVisibility(View.GONE);
|
||||
}
|
||||
title.setText(gpxItem.name);
|
||||
if (!Algorithms.isEmpty(gpxItem.description)) {
|
||||
description.setText(gpxItem.description);
|
||||
description.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
description.setVisibility(View.GONE);
|
||||
if (gpxItem != null) {
|
||||
title.setText(gpxItem.name);
|
||||
if (!Algorithms.isEmpty(gpxItem.description)) {
|
||||
description.setText(gpxItem.description);
|
||||
description.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
description.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);
|
||||
if (selectionMode) {
|
||||
if (selectionMode && gpxItem != null) {
|
||||
ch.setVisibility(View.VISIBLE);
|
||||
ch.setChecked(selectedItems.get(gpxItem.group.getType()) != null && selectedItems.get(gpxItem.group.getType()).contains(gpxItem));
|
||||
row.findViewById(R.id.icon).setVisibility(View.GONE);
|
||||
|
|
Loading…
Reference in a new issue