diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index c7b2ae6255..1461a3983b 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -3,7 +3,6 @@ package net.osmand.plus; import android.app.Activity; import android.content.Context; import android.graphics.drawable.Drawable; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -104,7 +103,7 @@ public class FavouritesDbHelper { } public int getColor() { - return color; + return color; } public boolean isVisible() { @@ -138,7 +137,7 @@ public class FavouritesDbHelper { if (favoriteGroup != null) { int color = favoriteGroup.getColor() == 0 ? context.getResources().getColor(R.color.color_favorite) : favoriteGroup.getColor(); - return context.getUIUtilities().getPaintedIcon(R.drawable.ic_action_folder, color); + return context.getUIUtilities().getPaintedIcon(R.drawable.ic_action_group_name_16, color); } return null; } @@ -198,10 +197,10 @@ public class FavouritesDbHelper { if (fp.getColor() == 0xFF000000 || fp.getColor() == ContextCompat.getColor(context, R.color.color_favorite)) { fp.setColor(0); } - if (fp.getBackgroundType() == FavouritePoint.DEFAULT_BACKGROUND_TYPE){ + if (fp.getBackgroundType() == FavouritePoint.DEFAULT_BACKGROUND_TYPE) { fp.setBackgroundType(null); } - if(fp.getIconId()== FavouritePoint.DEFAULT_UI_ICON_ID){ + if (fp.getIconId() == FavouritePoint.DEFAULT_UI_ICON_ID) { fp.setIconId(0); } FavoriteGroup group = getOrCreateGroup(fp, 0); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index b29e9e1385..45b6573c8c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -46,7 +46,6 @@ import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; import net.osmand.AndroidUtils; -import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.QuadPoint; @@ -55,11 +54,9 @@ import net.osmand.data.RotatedTileBox; import net.osmand.data.TransportRoute; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuItem; -import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.LockableScrollView; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities.DialogButtonType; @@ -69,19 +66,20 @@ import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.base.ContextMenuFragment; import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; import net.osmand.plus.helpers.FontCache; +import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment.ContextMenuItemClickListener; import net.osmand.plus.mapcontextmenu.MenuController.MenuState; import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController; import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController; import net.osmand.plus.mapcontextmenu.controllers.TransportStopController; -import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment.ContextMenuItemClickListener; import net.osmand.plus.routepreparationmenu.ChooseRouteFragment; import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu; +import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.OsmandMapTileView; -import net.osmand.plus.views.layers.TransportStopsLayer; import net.osmand.plus.views.controls.HorizontalSwipeConfirm; import net.osmand.plus.views.controls.SingleTapConfirm; +import net.osmand.plus.views.layers.TransportStopsLayer; import net.osmand.plus.widgets.style.CustomTypefaceSpan; import net.osmand.router.TransportRouteResult; import net.osmand.util.Algorithms; @@ -91,7 +89,6 @@ import java.util.ArrayList; import java.util.List; import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_MORE_ID; -import static net.osmand.plus.FavouritesDbHelper.FavoriteGroup.convertDisplayNameToGroupIdName; import static net.osmand.plus.mapcontextmenu.MenuBuilder.SHADOW_HEIGHT_TOP_DP; import static net.osmand.plus.settings.fragments.ConfigureMenuItemsFragment.MAIN_BUTTONS_QUANTITY; @@ -177,7 +174,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + Bundle savedInstanceState) { MapActivity mapActivity = getMapActivity(); if (mapActivity == null) { @@ -609,7 +606,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo containerLayoutListener = new OnLayoutChangeListener() { @Override public void onLayoutChange(View view, int left, int top, int right, int bottom, - int oldLeft, int oldTop, int oldRight, int oldBottom) { + int oldLeft, int oldTop, int oldRight, int oldBottom) { if (!transportBadgesCreated) { createTransportBadges(); } @@ -678,11 +675,11 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo } private View getActionView(ContextMenuItem contextMenuItem, - final int position, - final ContextMenuAdapter mainAdapter, - final ContextMenuAdapter additionalAdapter, - final ContextMenuItemClickListener mainListener, - final ContextMenuItemClickListener additionalListener) { + final int position, + final ContextMenuAdapter mainAdapter, + final ContextMenuAdapter additionalAdapter, + final ContextMenuItemClickListener mainListener, + final ContextMenuItemClickListener additionalListener) { UiUtilities uiUtilities = requireMyApplication().getUIUtilities(); LayoutInflater inflater = UiUtilities.getInflater(getMyApplication(), nightMode); View view = inflater.inflate(R.layout.context_menu_action_item, null); @@ -831,7 +828,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo v.setAlpha(alpha); if (visible && v.getVisibility() != View.VISIBLE) { v.setVisibility(View.VISIBLE); - } else if (!visible && v.getVisibility() == View.VISIBLE) { + } else if (!visible && v.getVisibility() == View.VISIBLE) { v.setVisibility(View.INVISIBLE); } } @@ -839,7 +836,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo private void updateVisibility(View v, boolean visible) { if (visible && v.getVisibility() != View.VISIBLE) { v.setVisibility(View.VISIBLE); - } else if (!visible && v.getVisibility() == View.VISIBLE) { + } else if (!visible && v.getVisibility() == View.VISIBLE) { v.setVisibility(View.INVISIBLE); } } @@ -1025,7 +1022,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo } private void applyPosY(final int currentY, final boolean needCloseMenu, boolean needMapAdjust, - final int previousMenuState, final int newMenuState, int dZoom) { + final int previousMenuState, final int newMenuState, int dZoom) { final int posY = getPosY(currentY, needCloseMenu, previousMenuState); if (getViewY() != posY || dZoom != 0) { if (posY < getViewY()) { @@ -1713,7 +1710,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo - (newMenuTopShadowAllHeight - menuTopShadowAllHeight)); } else { menuTopViewHeightExcludingTitle = newMenuTopViewHeight - line1.getMeasuredHeight() - line2MeasuredHeight - - titleButtonHeight - downloadButtonsHeight - titleBottomButtonHeight - additionalButtonsHeight - titleProgressHeight-line3Height; + - titleButtonHeight - downloadButtonsHeight - titleBottomButtonHeight - additionalButtonsHeight - titleProgressHeight - line3Height; menuTitleTopBottomPadding = (line1.getMeasuredHeight() - line1.getLineCount() * line1.getLineHeight()) + (line2MeasuredHeight - line2LineCount * line2LineHeight); menuButtonsHeight = view.findViewById(R.id.context_menu_bottom_buttons).getHeight() @@ -1820,15 +1817,15 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo if (!Algorithms.isEmpty(typeStr)) { line2Str.append(typeStr); Drawable icon = menu.getTypeIcon(); - if (icon != null){ - GravityDrawable gravityIcon = new GravityDrawable(icon); - AndroidUtils.setCompoundDrawablesWithIntrinsicBounds( - line2, gravityIcon, null, null, null); - } - String groupName = convertDisplayNameToGroupIdName(requireContext(), - menu.getTypeStr()); - if (menu.getMyApplication() != null){ - + if (icon != null) { + if (menu.getTypeIcon() instanceof GravityDrawable) { + GravityDrawable line2Icon = (GravityDrawable) menu.getTypeIcon(); + line2Icon.setBoundsFrom(icon); + line2.setCompoundDrawablesWithIntrinsicBounds(line2Icon, null, null, null); + } else { + line2.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); + } + line2.setCompoundDrawablePadding(AndroidUtils.dpToPx(requireContext(), 5f)); } line2.setCompoundDrawablePadding(dpToPx(5f)); } @@ -2211,7 +2208,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo } public static boolean showInstance(final MapContextMenu menu, final MapActivity mapActivity, - final boolean centered) { + final boolean centered) { try { if (menu.getLatLon() == null || mapActivity == null || mapActivity.isActivityDestroyed()) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java index e318bc5aa0..a62535f210 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java @@ -14,6 +14,7 @@ import net.osmand.data.TransportStop; import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.PointImageDrawable; @@ -160,14 +161,19 @@ public class FavouritePointMenuController extends MenuController { @Override public Drawable getSecondLineTypeIcon() { - - FavouritesDbHelper helper = menu.getMyApplication().getFavorites(); - if (helper != null && helper.getGroup(groupName) != null) { - Drawable line2icon = helper.getColoredIconForGroup(groupName); - GravityDrawable line2GravityDrawable = - new GravityDrawable(line2icon); + if (this.getMapActivity() != null) { + OsmandApplication app = this.getMapActivity().getMyApplication(); + if (app != null) { + FavouritesDbHelper helper = app.getFavorites(); + String group = fav.getCategory(); + if (helper != null && helper.getGroup(group) != null) { + Drawable line2icon = helper.getColoredIconForGroup(group); + GravityDrawable gravityIcon = new GravityDrawable(line2icon); + gravityIcon.setBoundsFrom(line2icon); + return gravityIcon; + } + } } - return getIcon(R.drawable.ic_action_group_name_16, isLight() ? R.color.icon_color_default_light : R.color.ctx_menu_bottom_view_icon_dark); } @@ -209,6 +215,6 @@ public class FavouritePointMenuController extends MenuController { if (originObject instanceof Amenity) { AmenityMenuController.addTypeMenuItem((Amenity) originObject, builder); } - } + } } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java index 299a23f95a..cdc766cab7 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java @@ -12,8 +12,6 @@ import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import net.osmand.AndroidUtils; -import net.osmand.data.FavouritePoint; -import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.util.Algorithms; @@ -21,8 +19,6 @@ import net.osmand.view.GravityDrawable; import java.util.List; -import static net.osmand.plus.FavouritesDbHelper.FavoriteGroup.convertDisplayNameToGroupIdName; - public class MultiSelectionArrayAdapter extends ArrayAdapter { private MapMultiSelectionMenu menu; @@ -98,22 +94,15 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter