Fix IU favorite icon size
This commit is contained in:
parent
a91fcad0f2
commit
d4b43304cd
4 changed files with 38 additions and 42 deletions
|
@ -28,7 +28,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingLeft="@dimen/list_content_padding">
|
android:paddingLeft="@dimen/list_header_padding">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -46,10 +46,10 @@
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/favourite_icon"
|
android:id="@+id/favourite_icon"
|
||||||
android:layout_width="34dp"
|
android:layout_width="@dimen/favorites_icon_size"
|
||||||
android:layout_height="34dp"
|
android:layout_height="@dimen/favorites_icon_size"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginRight="@dimen/guide_line_vertical_offset" />
|
android:layout_marginRight="@dimen/list_header_padding" />
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
|
@ -70,6 +70,7 @@
|
||||||
<dimen name="list_header_bottom_margin">8dp</dimen>
|
<dimen name="list_header_bottom_margin">8dp</dimen>
|
||||||
|
|
||||||
<dimen name="favorites_icon_right_margin">24dp</dimen>
|
<dimen name="favorites_icon_right_margin">24dp</dimen>
|
||||||
|
<dimen name="favorites_icon_size">40dp</dimen>
|
||||||
<dimen name="local_index_check_right_margin">10dp</dimen>
|
<dimen name="local_index_check_right_margin">10dp</dimen>
|
||||||
<dimen name="favorites_icon_top_margin">13dp</dimen>
|
<dimen name="favorites_icon_top_margin">13dp</dimen>
|
||||||
<dimen name="dialog_elements_vertical_margin">16dp</dimen>
|
<dimen name="dialog_elements_vertical_margin">16dp</dimen>
|
||||||
|
|
|
@ -8,7 +8,7 @@ import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.ColorFilter;
|
import android.graphics.ColorFilter;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Paint.Style;
|
import android.graphics.PixelFormat;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.PorterDuffColorFilter;
|
import android.graphics.PorterDuffColorFilter;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
|
@ -35,11 +35,10 @@ public class FavoriteImageDrawable extends Drawable {
|
||||||
private Bitmap syncedColor;
|
private Bitmap syncedColor;
|
||||||
private Bitmap syncedShadow;
|
private Bitmap syncedShadow;
|
||||||
private Bitmap syncedIcon;
|
private Bitmap syncedIcon;
|
||||||
private Drawable listDrawable;
|
private Drawable uiListIcon;
|
||||||
|
private Drawable uiBackgroundIcon;
|
||||||
private Paint paintIcon = new Paint();
|
private Paint paintIcon = new Paint();
|
||||||
private Paint paintBackground = new Paint();
|
private Paint paintBackground = new Paint();
|
||||||
private Paint paintOuter = new Paint();
|
|
||||||
private Paint paintInnerCircle = new Paint();
|
|
||||||
private ColorFilter colorFilter;
|
private ColorFilter colorFilter;
|
||||||
private ColorFilter grayFilter;
|
private ColorFilter grayFilter;
|
||||||
|
|
||||||
|
@ -57,21 +56,22 @@ public class FavoriteImageDrawable extends Drawable {
|
||||||
favIcon = res.getDrawable(R.drawable.mm_special_star);
|
favIcon = res.getDrawable(R.drawable.mm_special_star);
|
||||||
uiIconId = R.drawable.mx_special_star;
|
uiIconId = R.drawable.mx_special_star;
|
||||||
}
|
}
|
||||||
listDrawable = ((OsmandApplication) ctx.getApplicationContext()).getUIUtilities()
|
|
||||||
.getIcon(uiIconId, R.color.color_white);
|
|
||||||
int backgroundTopIconId = getMapBackIconId(ctx, point, "top");
|
|
||||||
int backgroundCenterIconId = getMapBackIconId(ctx, point, "center");
|
|
||||||
int backgroundBottomIconId = getMapBackIconId(ctx, point, "bottom");
|
|
||||||
int col = color == 0 || color == Color.BLACK ? res.getColor(R.color.color_favorite) : color;
|
int col = color == 0 || color == Color.BLACK ? res.getColor(R.color.color_favorite) : color;
|
||||||
favBackgroundTop = BitmapFactory.decodeResource(res, backgroundTopIconId);
|
uiListIcon = ((OsmandApplication) ctx.getApplicationContext()).getUIUtilities()
|
||||||
favBackgroundCenter = BitmapFactory.decodeResource(res, backgroundCenterIconId);
|
.getIcon(uiIconId, R.color.color_white);
|
||||||
favBackgroundBottom = BitmapFactory.decodeResource(res, backgroundBottomIconId);
|
int uiBackgroundIconId = point != null ? point.getBackType().getIconId() : R.drawable.bg_point_circle;
|
||||||
|
uiBackgroundIcon = ((OsmandApplication) ctx.getApplicationContext()).getUIUtilities()
|
||||||
|
.getPaintedIcon(uiBackgroundIconId, col);
|
||||||
|
int mapBackgroundIconIdTop = getMapBackIconId(ctx, point, "top");
|
||||||
|
int mapBackgroundIconIdCenter = getMapBackIconId(ctx, point, "center");
|
||||||
|
int mapBackgroundIconIdBottom = getMapBackIconId(ctx, point, "bottom");
|
||||||
|
favBackgroundTop = BitmapFactory.decodeResource(res, mapBackgroundIconIdTop);
|
||||||
|
favBackgroundCenter = BitmapFactory.decodeResource(res, mapBackgroundIconIdCenter);
|
||||||
|
favBackgroundBottom = BitmapFactory.decodeResource(res, mapBackgroundIconIdBottom);
|
||||||
syncedStroke = BitmapFactory.decodeResource(res, R.drawable.map_shield_marker_point_stroke);
|
syncedStroke = BitmapFactory.decodeResource(res, R.drawable.map_shield_marker_point_stroke);
|
||||||
syncedColor = BitmapFactory.decodeResource(res, R.drawable.map_shield_marker_point_color);
|
syncedColor = BitmapFactory.decodeResource(res, R.drawable.map_shield_marker_point_color);
|
||||||
syncedShadow = BitmapFactory.decodeResource(res, R.drawable.map_shield_marker_point_shadow);
|
syncedShadow = BitmapFactory.decodeResource(res, R.drawable.map_shield_marker_point_shadow);
|
||||||
syncedIcon = BitmapFactory.decodeResource(res, R.drawable.map_marker_point_14dp);
|
syncedIcon = BitmapFactory.decodeResource(res, R.drawable.map_marker_point_14dp);
|
||||||
initSimplePaint(paintOuter, color == 0 || color == Color.BLACK ? 0x88555555 : color);
|
|
||||||
initSimplePaint(paintInnerCircle, col);
|
|
||||||
colorFilter = new PorterDuffColorFilter(col, PorterDuff.Mode.SRC_IN);
|
colorFilter = new PorterDuffColorFilter(col, PorterDuff.Mode.SRC_IN);
|
||||||
grayFilter = new PorterDuffColorFilter(res.getColor(R.color.color_favorite_gray), PorterDuff.Mode.MULTIPLY);
|
grayFilter = new PorterDuffColorFilter(res.getColor(R.color.color_favorite_gray), PorterDuff.Mode.MULTIPLY);
|
||||||
}
|
}
|
||||||
|
@ -92,20 +92,14 @@ public class FavoriteImageDrawable extends Drawable {
|
||||||
return R.drawable.map_white_favorite_shield;
|
return R.drawable.map_white_favorite_shield;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initSimplePaint(Paint paint, int color) {
|
|
||||||
paint.setAntiAlias(true);
|
|
||||||
paint.setStyle(Style.FILL_AND_STROKE);
|
|
||||||
paint.setColor(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onBoundsChange(Rect bounds) {
|
protected void onBoundsChange(Rect bounds) {
|
||||||
super.onBoundsChange(bounds);
|
super.onBoundsChange(bounds);
|
||||||
Rect bs = new Rect(bounds);
|
Rect bs = new Rect(bounds);
|
||||||
//bs.inset((int) (4 * density), (int) (4 * density));
|
|
||||||
if (!withShadow && !synced) {
|
if (!withShadow && !synced) {
|
||||||
bs.inset(bs.width() / 4, bs.height() / 4);
|
uiBackgroundIcon.setBounds(bounds);
|
||||||
listDrawable.setBounds(bs);
|
bs.inset(bs.width() / 5, bs.height() / 5);
|
||||||
|
uiListIcon.setBounds(bs);
|
||||||
} else if (withShadow) {
|
} else if (withShadow) {
|
||||||
bs.inset(bs.width() / 3, bs.height() / 3);
|
bs.inset(bs.width() / 3, bs.height() / 3);
|
||||||
favIcon.setBounds(bs);
|
favIcon.setBounds(bs);
|
||||||
|
@ -127,25 +121,26 @@ public class FavoriteImageDrawable extends Drawable {
|
||||||
paintBackground.setColorFilter(history ? grayFilter : colorFilter);
|
paintBackground.setColorFilter(history ? grayFilter : colorFilter);
|
||||||
Rect bs = getBounds();
|
Rect bs = getBounds();
|
||||||
if (synced) {
|
if (synced) {
|
||||||
canvas.drawBitmap(syncedShadow, bs.exactCenterX() - syncedShadow.getWidth() / 2f, bs.exactCenterY() - syncedShadow.getHeight() / 2f, paintBackground);
|
drawBitmap(canvas, bs, syncedShadow, paintBackground);
|
||||||
canvas.drawBitmap(syncedColor, bs.exactCenterX() - syncedColor.getWidth() / 2f, bs.exactCenterY() - syncedColor.getHeight() / 2f, paintBackground);
|
drawBitmap(canvas, bs, syncedColor, paintBackground);
|
||||||
canvas.drawBitmap(syncedStroke, bs.exactCenterX() - syncedStroke.getWidth() / 2f, bs.exactCenterY() - syncedStroke.getHeight() / 2f, paintBackground);
|
drawBitmap(canvas, bs, syncedStroke, paintBackground);
|
||||||
canvas.drawBitmap(syncedIcon, bs.exactCenterX() - syncedIcon.getWidth() / 2f, bs.exactCenterY() - syncedIcon.getHeight() / 2f, paintIcon);
|
drawBitmap(canvas, bs, syncedIcon, paintIcon);
|
||||||
} else if (withShadow) {
|
} else if (withShadow) {
|
||||||
canvas.drawBitmap(favBackgroundBottom, bs.exactCenterX() - favBackgroundBottom.getWidth() / 2f, bs.exactCenterY() - favBackgroundBottom.getHeight() / 2f, new Paint());
|
drawBitmap(canvas, bs, favBackgroundBottom, new Paint());
|
||||||
canvas.drawBitmap(favBackgroundCenter, bs.exactCenterX() - favBackgroundCenter.getWidth() / 2f, bs.exactCenterY() - favBackgroundCenter.getHeight() / 2f, paintBackground);
|
drawBitmap(canvas, bs, favBackgroundCenter, paintBackground);
|
||||||
canvas.drawBitmap(favBackgroundTop, bs.exactCenterX() - favBackgroundTop.getWidth() / 2f, bs.exactCenterY() - favBackgroundTop.getHeight() / 2f, new Paint());
|
drawBitmap(canvas, bs, favBackgroundTop, new Paint());
|
||||||
favIcon.draw(canvas);
|
favIcon.draw(canvas);
|
||||||
} else {
|
} else {
|
||||||
int min = Math.min(bs.width(), bs.height());
|
uiBackgroundIcon.draw(canvas);
|
||||||
int r = (min * 4 / 10);
|
uiListIcon.draw(canvas);
|
||||||
int rs = (r - 1);
|
|
||||||
canvas.drawCircle(min / 2, min / 2, r, paintOuter);
|
|
||||||
canvas.drawCircle(min / 2, min / 2, rs, paintInnerCircle);
|
|
||||||
listDrawable.draw(canvas);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void drawBitmap(@NonNull Canvas canvas, Rect bs, Bitmap syncedShadow, Paint paintBackground) {
|
||||||
|
canvas.drawBitmap(syncedShadow, bs.exactCenterX() - syncedShadow.getWidth() / 2f,
|
||||||
|
bs.exactCenterY() - syncedShadow.getHeight() / 2f, paintBackground);
|
||||||
|
}
|
||||||
|
|
||||||
public void drawBitmapInCenter(Canvas canvas, float x, float y, boolean history) {
|
public void drawBitmapInCenter(Canvas canvas, float x, float y, boolean history) {
|
||||||
this.history = history;
|
this.history = history;
|
||||||
float dx = x - getIntrinsicWidth() / 2f;
|
float dx = x - getIntrinsicWidth() / 2f;
|
||||||
|
@ -157,7 +152,7 @@ public class FavoriteImageDrawable extends Drawable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOpacity() {
|
public int getOpacity() {
|
||||||
return 0;
|
return PixelFormat.UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1282,7 +1282,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
int iconId = menu.getRightIconId();
|
int iconId = menu.getRightIconId();
|
||||||
int sizeId = menu.isBigRightIcon() ? R.dimen.context_menu_big_icon_size : R.dimen.map_widget_icon;
|
int sizeId = menu.isBigRightIcon() ? R.dimen.context_menu_big_icon_size : R.dimen.map_widget_icon;
|
||||||
if (menu.getPointDescription().isFavorite() || menu.getPointDescription().isWpt()) {
|
if (menu.getPointDescription().isFavorite() || menu.getPointDescription().isWpt()) {
|
||||||
sizeId = R.dimen.dialog_button_height;
|
sizeId = R.dimen.favorites_icon_size;
|
||||||
}
|
}
|
||||||
int iconViewSize = getResources().getDimensionPixelSize(sizeId);
|
int iconViewSize = getResources().getDimensionPixelSize(sizeId);
|
||||||
ViewGroup.LayoutParams params = iconView.getLayoutParams();
|
ViewGroup.LayoutParams params = iconView.getLayoutParams();
|
||||||
|
|
Loading…
Reference in a new issue