icons fixed and refactored
This commit is contained in:
parent
67f19eb9ce
commit
2f36b59ae7
4 changed files with 50 additions and 59 deletions
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -1821,14 +1818,14 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
line2Str.append(typeStr);
|
||||
Drawable icon = menu.getTypeIcon();
|
||||
if (icon != null) {
|
||||
GravityDrawable gravityIcon = new GravityDrawable(icon);
|
||||
AndroidUtils.setCompoundDrawablesWithIntrinsicBounds(
|
||||
line2, gravityIcon, null, null, 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);
|
||||
}
|
||||
String groupName = convertDisplayNameToGroupIdName(requireContext(),
|
||||
menu.getTypeStr());
|
||||
if (menu.getMyApplication() != null){
|
||||
|
||||
line2.setCompoundDrawablePadding(AndroidUtils.dpToPx(requireContext(), 5f));
|
||||
}
|
||||
line2.setCompoundDrawablePadding(dpToPx(5f));
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<MapMultiSelectionMenu.MenuObject> {
|
||||
|
||||
private MapMultiSelectionMenu menu;
|
||||
|
@ -98,23 +94,16 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter<MapMultiSelectionMe
|
|||
}
|
||||
line2.setText(line2Str);
|
||||
Drawable slIcon = item.getTypeIcon();
|
||||
GravityDrawable line2Icon = new GravityDrawable(slIcon);
|
||||
if (slIcon != null) {
|
||||
if (item.getTypeIcon() instanceof GravityDrawable) {
|
||||
GravityDrawable line2Icon = (GravityDrawable) item.getTypeIcon();
|
||||
line2Icon.setBoundsFrom(slIcon);
|
||||
line2.setCompoundDrawablesWithIntrinsicBounds(line2Icon, null, null, null);
|
||||
} else {
|
||||
line2.setCompoundDrawablesWithIntrinsicBounds(slIcon, null, null, null);
|
||||
}
|
||||
line2.setCompoundDrawablePadding(AndroidUtils.dpToPx(menu.getMapActivity(), 5f));
|
||||
}
|
||||
String groupName = convertDisplayNameToGroupIdName(getContext(),
|
||||
item.getTypeStr());
|
||||
if (item.getMyApplication() != null){
|
||||
FavouritesDbHelper helper = item.getMyApplication().getFavorites();
|
||||
if (helper != null && helper.getGroup(groupName) != null){
|
||||
Drawable line2icon = helper.getColoredIconForGroup(groupName);
|
||||
GravityDrawable line2GravityIcon = new GravityDrawable(line2icon);
|
||||
line2GravityIcon.setBoundsFrom(line2icon);
|
||||
line2.setCompoundDrawablesWithIntrinsicBounds(line2GravityIcon, null, null, null);
|
||||
}
|
||||
}
|
||||
// Divider
|
||||
View divider = convertView.findViewById(R.id.divider);
|
||||
divider.setBackgroundColor(ContextCompat.getColor(getContext(), menu.isLight() ? R.color.multi_selection_menu_divider_light : R.color.multi_selection_menu_divider_dark));
|
||||
|
|
Loading…
Reference in a new issue