Merge pull request #8992 from osmandapp/configure_menu_items_fix
Configure menu items fix
This commit is contained in:
commit
6ae95c14bd
4 changed files with 22 additions and 11 deletions
|
@ -43,6 +43,7 @@ import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
|
|||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.ContextMenuItem.ItemBuilder;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmAndLocationProvider;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
|
@ -349,14 +350,14 @@ public class MapActivityActions implements DialogProvider {
|
|||
adapter.addItem(itemBuilder
|
||||
.setTitleId(selectedObj instanceof FavouritePoint ? R.string.favourites_context_menu_edit : R.string.shared_string_add, mapActivity)
|
||||
.setId(MAP_CONTEXT_MENU_ADD_ID)
|
||||
.setIcon(R.drawable.ic_action_favorite_stroke)
|
||||
.setIcon(selectedObj instanceof FavouritePoint ? R.drawable.ic_action_edit_dark : R.drawable.ic_action_favorite_stroke)
|
||||
.setOrder(10)
|
||||
.createItem());
|
||||
adapter.addItem(itemBuilder
|
||||
.setTitleId(R.string.shared_string_marker, mapActivity)
|
||||
.setTitleId(selectedObj instanceof MapMarker ? R.string.shared_string_edit : R.string.shared_string_marker, mapActivity)
|
||||
.setId(MAP_CONTEXT_MENU_MARKER_ID)
|
||||
.setOrder(20)
|
||||
.setIcon(R.drawable.ic_action_flag_stroke)
|
||||
.setIcon(selectedObj instanceof MapMarker ? R.drawable.ic_action_edit_dark : R.drawable.ic_action_flag_stroke)
|
||||
.createItem());
|
||||
adapter.addItem(itemBuilder
|
||||
.setTitleId(R.string.shared_string_share, mapActivity)
|
||||
|
@ -478,7 +479,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
getMyApplication().getAvoidSpecificRoads().addImpassableRoad(mapActivity, new LatLon(latitude, longitude), true, false, null);
|
||||
} else if (standardId == R.string.shared_string_add || standardId == R.string.favourites_context_menu_edit) {
|
||||
mapActivity.getContextMenu().buttonFavoritePressed();
|
||||
} else if (standardId == R.string.shared_string_marker) {
|
||||
} else if (standardId == R.string.shared_string_marker || standardId == R.string.shared_string_edit) {
|
||||
mapActivity.getContextMenu().buttonWaypointPressed();
|
||||
} else if (standardId == R.string.shared_string_share) {
|
||||
mapActivity.getContextMenu().buttonSharePressed();
|
||||
|
|
|
@ -409,8 +409,8 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
|
|||
}
|
||||
items.add(new RearrangeMenuAdapterItem(HEADER, new RearrangeMenuItemsAdapter.HeaderItem(R.string.main_actions, R.string.main_actions_descr)));
|
||||
items.addAll(main);
|
||||
if (!additional.isEmpty()) {
|
||||
items.add(new RearrangeMenuAdapterItem(HEADER, new RearrangeMenuItemsAdapter.HeaderItem(R.string.additional_actions, R.string.additional_actions_descr)));
|
||||
if (!additional.isEmpty()) {
|
||||
items.addAll(additional);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -29,8 +29,8 @@ import net.osmand.AndroidUtils;
|
|||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -47,8 +47,11 @@ import org.apache.commons.logging.Log;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_DIVIDER_ID;
|
||||
|
||||
public class ConfigureMenuRootFragment extends BaseOsmAndFragment {
|
||||
|
||||
public static final String TAG = ConfigureMenuRootFragment.class.getName();
|
||||
|
@ -287,7 +290,16 @@ public class ConfigureMenuRootFragment extends BaseOsmAndFragment {
|
|||
break;
|
||||
}
|
||||
int hiddenCount = ConfigureMenuItemsFragment.getSettingForScreen(app, type).getModeValue(appMode).getHiddenIds().size();
|
||||
int allCount = ConfigureMenuItemsFragment.getCustomizableDefaultItems(contextMenuAdapter.getDefaultItems()).size();
|
||||
List<ContextMenuItem> allItems = ConfigureMenuItemsFragment.getCustomizableDefaultItems(contextMenuAdapter.getDefaultItems());
|
||||
if (type == ScreenType.DRAWER) {
|
||||
Iterator<ContextMenuItem> iterator = allItems.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (DRAWER_DIVIDER_ID.equals(iterator.next().getId())) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
int allCount = allItems.size();
|
||||
String amount = getString(R.string.n_items_of_z, String.valueOf(allCount - hiddenCount), String.valueOf(allCount));
|
||||
return getString(R.string.ltr_or_rtl_combine_via_colon, getString(R.string.shared_string_items), amount);
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView
|
|||
h.title.setText(menuItem.getTitle());
|
||||
h.title.setTypeface(FontCache.getFont(app, app.getString(R.string.font_roboto_medium)));
|
||||
h.title.setTextSize(TypedValue.COMPLEX_UNIT_PX, app.getResources().getDimension(R.dimen.default_list_text_size));
|
||||
h.description.setText(R.string.move_inside_category);
|
||||
h.description.setVisibility(View.GONE);
|
||||
h.icon.setVisibility(View.GONE);
|
||||
h.actionIcon.setVisibility(View.GONE);
|
||||
h.moveButton.setVisibility(View.GONE);
|
||||
|
@ -276,9 +276,7 @@ public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView
|
|||
int orderFrom = menuItemFrom.getOrder();
|
||||
int orderTo = menuItemTo.getOrder();
|
||||
|
||||
if (menuItemFrom.getId().startsWith(SHOW_ITEMS_ID_SCHEME) && menuItemTo.getId().startsWith(RENDERING_ITEMS_ID_SCHEME)
|
||||
|| menuItemFrom.getId().startsWith(RENDERING_ITEMS_ID_SCHEME) && menuItemTo.getId().startsWith(SHOW_ITEMS_ID_SCHEME)
|
||||
|| menuItemTo.isHidden()) {
|
||||
if (menuItemTo.isHidden()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue