Track appearance UI fixes second part
This commit is contained in:
parent
053c4701ff
commit
ee6e283d03
5 changed files with 53 additions and 12 deletions
|
@ -230,8 +230,12 @@ public class UiUtilities {
|
|||
}
|
||||
|
||||
@ColorInt
|
||||
public static int mixTwoColors(@ColorInt int color1, @ColorInt int color2, float amount )
|
||||
{
|
||||
public static int removeAlpha(@ColorInt int color) {
|
||||
return Color.rgb(Color.red(color), Color.green(color), Color.blue(color));
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public static int mixTwoColors(@ColorInt int color1, @ColorInt int color2, float amount) {
|
||||
final byte ALPHA_CHANNEL = 24;
|
||||
final byte RED_CHANNEL = 16;
|
||||
final byte GREEN_CHANNEL = 8;
|
||||
|
|
|
@ -58,8 +58,12 @@ public class CustomColorBottomSheet extends MenuBottomSheetDialogFragment implem
|
|||
} else {
|
||||
Bundle args = getArguments();
|
||||
if (args != null) {
|
||||
if (args.containsKey(PREV_SELECTED_COLOR)) {
|
||||
prevColor = args.getInt(PREV_SELECTED_COLOR);
|
||||
newColor = prevColor != -1 ? prevColor : Color.RED;
|
||||
} else {
|
||||
prevColor = Color.RED;
|
||||
}
|
||||
newColor = prevColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -390,13 +390,21 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
|||
int strokeColor = UiUtilities.getColorWithAlpha(Color.BLACK, 0.7f);
|
||||
Drawable strokeIcon = app.getUIUtilities().getPaintedIcon(strokeIconId, strokeColor);
|
||||
|
||||
Drawable transparencyIcon = getTransparencyIcon(app, widthAttr, color);
|
||||
if (showArrows) {
|
||||
int arrowsIconId = getArrowsIconId(widthAttr);
|
||||
int contrastColor = UiUtilities.getContrastColor(app, color, false);
|
||||
Drawable arrows = app.getUIUtilities().getPaintedIcon(arrowsIconId, contrastColor);
|
||||
return UiUtilities.getLayeredIcon(widthIcon, strokeIcon, arrows);
|
||||
return UiUtilities.getLayeredIcon(transparencyIcon, widthIcon, strokeIcon, arrows);
|
||||
}
|
||||
return UiUtilities.getLayeredIcon(widthIcon, strokeIcon);
|
||||
return UiUtilities.getLayeredIcon(transparencyIcon, widthIcon, strokeIcon);
|
||||
}
|
||||
|
||||
private Drawable getTransparencyIcon(OsmandApplication app, String widthAttr, @ColorInt int color) {
|
||||
int transparencyIconId = getTransparencyIconId(widthAttr);
|
||||
int colorWithoutAlpha = UiUtilities.removeAlpha(color);
|
||||
int transparencyColor = UiUtilities.getColorWithAlpha(colorWithoutAlpha, 0.8f);
|
||||
return app.getUIUtilities().getPaintedIcon(transparencyIconId, transparencyColor);
|
||||
}
|
||||
|
||||
private void updateCardsLayout() {
|
||||
|
@ -638,6 +646,16 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
|||
}
|
||||
}
|
||||
|
||||
public static int getTransparencyIconId(String widthAttr) {
|
||||
if (TRACK_WIDTH_BOLD.equals(widthAttr)) {
|
||||
return R.drawable.ic_action_track_line_bold_transparency;
|
||||
} else if (TRACK_WIDTH_MEDIUM.equals(widthAttr)) {
|
||||
return R.drawable.ic_action_track_line_medium_transparency;
|
||||
} else {
|
||||
return R.drawable.ic_action_track_line_thin_transparency;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getWidthIconId(String widthAttr) {
|
||||
if (TRACK_WIDTH_BOLD.equals(widthAttr)) {
|
||||
return R.drawable.ic_action_track_line_bold_color;
|
||||
|
|
|
@ -26,6 +26,7 @@ import net.osmand.PlatformUtil;
|
|||
import net.osmand.plus.GPXDatabase;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -143,7 +144,11 @@ public class TrackColoringCard extends BaseCard implements ColorPickerListener {
|
|||
private View createColorItemView(@ColorInt final int color, final FlowLayout rootView, boolean customColor) {
|
||||
View colorItemView = createCircleView(rootView);
|
||||
ImageView backgroundCircle = colorItemView.findViewById(R.id.background);
|
||||
backgroundCircle.setImageDrawable(UiUtilities.tintDrawable(AppCompatResources.getDrawable(app, R.drawable.bg_point_circle), color));
|
||||
|
||||
Drawable transparencyIcon = getTransparencyIcon(app, color);
|
||||
Drawable colorIcon = app.getUIUtilities().getPaintedIcon(R.drawable.bg_point_circle, color);
|
||||
Drawable layeredIcon = UiUtilities.getLayeredIcon(transparencyIcon, colorIcon);
|
||||
backgroundCircle.setImageDrawable(layeredIcon);
|
||||
backgroundCircle.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -173,6 +178,12 @@ public class TrackColoringCard extends BaseCard implements ColorPickerListener {
|
|||
return colorItemView;
|
||||
}
|
||||
|
||||
private Drawable getTransparencyIcon(OsmandApplication app, @ColorInt int color) {
|
||||
int colorWithoutAlpha = UiUtilities.removeAlpha(color);
|
||||
int transparencyColor = UiUtilities.getColorWithAlpha(colorWithoutAlpha, 0.8f);
|
||||
return app.getUIUtilities().getPaintedIcon(R.drawable.ic_bg_transparency, transparencyColor);
|
||||
}
|
||||
|
||||
private View createAddCustomColorItemView(FlowLayout rootView) {
|
||||
View colorItemView = createCircleView(rootView);
|
||||
ImageView backgroundCircle = colorItemView.findViewById(R.id.background);
|
||||
|
@ -183,7 +194,7 @@ public class TrackColoringCard extends BaseCard implements ColorPickerListener {
|
|||
ImageView icon = colorItemView.findViewById(R.id.icon);
|
||||
icon.setVisibility(View.VISIBLE);
|
||||
int activeColorResId = nightMode ? R.color.icon_color_active_dark : R.color.icon_color_active_light;
|
||||
icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_add, activeColorResId));
|
||||
icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_plus, activeColorResId));
|
||||
|
||||
backgroundCircle.setImageDrawable(backgroundIcon);
|
||||
backgroundCircle.setOnClickListener(new View.OnClickListener() {
|
||||
|
|
|
@ -456,12 +456,16 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
|||
int endX = (int) tileBox.getPixXFromLatLon(end.lat, end.lon);
|
||||
int endY = (int) tileBox.getPixYFromLatLon(end.lat, end.lon);
|
||||
|
||||
int iconSize = AndroidUtils.dpToPx(view.getContext(), 14);
|
||||
QuadRect startRectWithoutShadow = calculateRect(startX, startY, iconSize, iconSize);
|
||||
QuadRect endRectWithoutShadow = calculateRect(endX, endY, iconSize, iconSize);
|
||||
|
||||
if (QuadRect.intersects(startRectWithoutShadow, endRectWithoutShadow)) {
|
||||
QuadRect startAndFinishRect = calculateRect(startX, startY, startAndFinishIcon.getIntrinsicWidth(), startAndFinishIcon.getIntrinsicHeight());
|
||||
drawPoint(canvas, startAndFinishRect, startAndFinishIcon);
|
||||
} else {
|
||||
QuadRect startRect = calculateRect(startX, startY, startPointIcon.getIntrinsicWidth(), startPointIcon.getIntrinsicHeight());
|
||||
QuadRect endRect = calculateRect(endX, endY, finishPointIcon.getIntrinsicWidth(), finishPointIcon.getIntrinsicHeight());
|
||||
|
||||
if (QuadRect.intersects(startRect, endRect)) {
|
||||
drawPoint(canvas, startRect, startAndFinishIcon);
|
||||
} else {
|
||||
drawPoint(canvas, startRect, startPointIcon);
|
||||
drawPoint(canvas, endRect, finishPointIcon);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue