diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index c497ffda36..14e08c0176 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,9 @@ Thx - Hardy --> + Name: A – Z + Name: Z – A + Last modified • Updated "Plan a route" function: allows using different navigation types per segment and the inclusion of tracks\n\n • New "Appearance" menu for tracks: select color, thickness, display direction arrows, start/finish icons\n\n diff --git a/OsmAnd/src/net/osmand/plus/base/OsmandExpandableListFragment.java b/OsmAnd/src/net/osmand/plus/base/OsmandExpandableListFragment.java index 1db87051fa..90aabfac7c 100644 --- a/OsmAnd/src/net/osmand/plus/base/OsmandExpandableListFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/OsmandExpandableListFragment.java @@ -88,10 +88,14 @@ public abstract class OsmandExpandableListFragment extends BaseOsmAndFragment public MenuItem createMenuItem(Menu m, int id, int titleRes, int iconId, int menuItemType, boolean flipIconForRtl) { + int color = isLightActionBar() ? R.color.active_buttons_and_links_text_light : R.color.active_buttons_and_links_text_dark; + return createMenuItem(m, id, titleRes, iconId, menuItemType, false, color); + } + + public MenuItem createMenuItem(Menu m, int id, int titleRes, int iconId, int menuItemType, + boolean flipIconForRtl, int iconColor) { OsmandApplication app = requireMyApplication(); - Drawable d = iconId == 0 ? null : app.getUIUtilities().getIcon(iconId, isLightActionBar() ? - R.color.active_buttons_and_links_text_light : - R.color.active_buttons_and_links_text_dark); + Drawable d = iconId == 0 ? null : app.getUIUtilities().getIcon(iconId, iconColor); MenuItem menuItem = m.add(0, id, 0, titleRes); if (d != null) { if (flipIconForRtl) { diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index 136baa81b6..3c396eccf4 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -19,6 +19,7 @@ import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import android.view.SubMenu; import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; @@ -83,7 +84,6 @@ import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.OsmandSettings.TracksSortByMode; -import net.osmand.plus.widgets.IconPopupMenu; import java.io.File; import java.text.Collator; @@ -436,10 +436,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement } @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + public void onCreateOptionsMenu(Menu menu, @NonNull MenuInflater inflater) { menu.clear(); - MenuItem mi = createMenuItem(menu, SEARCH_ID, R.string.search_poi_filter, R.drawable.ic_action_search_dark, MenuItem.SHOW_AS_ACTION_ALWAYS - | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); + MenuItem mi = createMenuItem(menu, SEARCH_ID, R.string.search_poi_filter, R.drawable.ic_action_search_dark, + MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); SearchView searchView = new SearchView(getActivity()); FavoritesActivity.updateSearchView(getActivity(), searchView); mi.setActionView(searchView); @@ -475,6 +475,24 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement } }); + menu.addSubMenu(Menu.NONE, R.string.shared_string_sort, Menu.NONE, R.string.shared_string_sort); + SubMenu sortMenu = menu.findItem(R.string.shared_string_sort).getSubMenu(); + mi = sortMenu.getItem(); + mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); + mi.setIcon(getIcon(R.drawable.ic_sort_waypoint_dark, isLightActionBar() ? R.color.active_buttons_and_links_text_light : R.color.active_buttons_and_links_text_dark)); + + for (final TracksSortByMode mode : TracksSortByMode.values()) { + mi = createMenuItem(sortMenu, mode.getNameId(), mode.getNameId(), mode.getIconId(), + MenuItem.SHOW_AS_ACTION_ALWAYS, false, R.color.icon_color_default_light); + mi.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + updateTracksSort(mode); + return false; + } + }); + } + if (AndroidUiHelper.isOrientationPortrait(getActivity())) { menu = ((FavoritesActivity) getActivity()).getClearToolbar(true).getMenu(); } else { @@ -574,9 +592,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement ((FavoritesActivity) getActivity()).addTrack(); } - private void updateTracksSort() { - sortByName = !sortByName; - app.getSettings().SORT_TRACKS_BY_NAME.set(sortByName); + private void updateTracksSort(TracksSortByMode sortByMode) { + this.sortByMode = sortByMode; + app.getSettings().TRACKS_SORT_BY_MODE.set(sortByMode); reloadTracks(); } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index d8507abacd..e41c7d58df 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -4104,13 +4104,15 @@ public class OsmandSettings { } public enum TracksSortByMode { - BY_DATE(R.drawable.ic_action_time_start), - BY_NAME_ASCENDING(R.drawable.ic_action_sort_by_name_ascending), - BY_NAME_DESCENDING(R.drawable.ic_action_sort_by_name_descending); + BY_DATE(R.string.sort_last_modified, R.drawable.ic_action_time_start), + BY_NAME_ASCENDING(R.string.sort_name_ascending, R.drawable.ic_action_sort_by_name_ascending), + BY_NAME_DESCENDING(R.string.sort_name_descending, R.drawable.ic_action_sort_by_name_descending); private final int iconId; + private final int nameId; - TracksSortByMode(int iconId) { + TracksSortByMode(int nameId, int iconId) { + this.nameId = nameId; this.iconId = iconId; } @@ -4122,6 +4124,11 @@ public class OsmandSettings { return this == BY_DATE; } + @StringRes + public int getNameId() { + return nameId; + } + @DrawableRes public int getIconId() { return iconId;