diff --git a/OsmAnd/res/layout/map_marker_item_header.xml b/OsmAnd/res/layout/map_marker_item_header.xml
index fa432973d6..361683626b 100644
--- a/OsmAnd/res/layout/map_marker_item_header.xml
+++ b/OsmAnd/res/layout/map_marker_item_header.xml
@@ -38,6 +38,20 @@
android:textColor="?android:textColorPrimary"
tools:text="Today"/>
+
+
= Build.VERSION_CODES.KITKAT) {
+ drawable.setAutoMirrored(true);
+ return drawable;
+ }
Bitmap bitmap = drawableToBitmap(drawable);
return new BitmapDrawable(ctx.getResources(), flipBitmapHorizontally(bitmap));
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java
index 89137c3473..d3c1c37705 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java
@@ -284,7 +284,7 @@ public class MapMarkersDbHelper {
if (db != null) {
try {
for (MapMarker marker : markers) {
- insertLast(db, marker, false);
+ insertLast(db, marker);
}
} finally {
db.close();
@@ -293,36 +293,24 @@ public class MapMarkersDbHelper {
}
public void addMarker(MapMarker marker) {
- addMarker(marker, false);
- }
-
- private void addMarker(MapMarker marker, boolean saveExisting) {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
- insertLast(db, marker, saveExisting);
+ insertLast(db, marker);
} finally {
db.close();
}
}
}
- private void insertLast(SQLiteConnection db, MapMarker marker, boolean saveExisting) {
- long currentTime;
- if (saveExisting) {
- Calendar cal = Calendar.getInstance();
- cal.add(Calendar.MONTH, -1);
- currentTime = cal.getTimeInMillis();
- } else {
- currentTime = System.currentTimeMillis();
- }
+ private void insertLast(SQLiteConnection db, MapMarker marker) {
+ long currentTime = System.currentTimeMillis();
if (marker.id == null) {
marker.id = String.valueOf(currentTime) + String.valueOf(new Random().nextInt(900) + 100);
}
marker.creationDate = currentTime;
String descr = PointDescription.serializeToString(marker.getOriginalPointDescription());
int active = marker.history ? 0 : 1;
- long visited = saveExisting ? currentTime : 0;
PointDescription pointDescription = marker.getOriginalPointDescription();
if (pointDescription != null && !pointDescription.isSearchingAddress(context)) {
@@ -352,7 +340,7 @@ public class MapMarkersDbHelper {
MARKERS_COL_MAP_OBJECT_NAME + ") " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
new Object[]{marker.id, marker.getLatitude(), marker.getLongitude(), descr, active,
- currentTime, visited, marker.groupName, marker.groupKey, marker.colorIndex,
+ currentTime, marker.visitedDate, marker.groupName, marker.groupKey, marker.colorIndex,
marker.history ? HISTORY_NEXT_VALUE : TAIL_NEXT_VALUE, 0, 0, marker.mapObjectName});
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java
index 4e5c77dd89..5d368b7580 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java
@@ -1,12 +1,9 @@
package net.osmand.plus.mapmarkers;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
-import android.graphics.PorterDuff;
-import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -48,9 +45,9 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
public static final String TAG = "MapMarkersGroupsFragment";
+ private OsmandApplication app;
private MapMarkersGroupsAdapter adapter;
private Paint backgroundPaint = new Paint();
- private Paint iconPaint = new Paint();
private Paint textPaint = new Paint();
private Snackbar snackbar;
private View mainView;
@@ -60,6 +57,12 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
private boolean locationUpdateStarted;
private boolean compassUpdateAllowed = true;
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ app = getMyApplication();
+ }
+
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -89,9 +92,6 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
backgroundPaint.setColor(ContextCompat.getColor(getActivity(), night ? R.color.divider_color_dark : R.color.divider_color_light));
backgroundPaint.setStyle(Paint.Style.FILL_AND_STROKE);
backgroundPaint.setAntiAlias(true);
- iconPaint.setAntiAlias(true);
- iconPaint.setFilterBitmap(true);
- iconPaint.setDither(true);
textPaint.setTextSize(getResources().getDimension(R.dimen.default_desc_text_size));
textPaint.setFakeBoldText(true);
textPaint.setAntiAlias(true);
@@ -106,8 +106,6 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
private float marginSides = getResources().getDimension(R.dimen.list_content_padding);
- private Bitmap deleteBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_delete_dark);
- private Bitmap historyBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_history);
private boolean iconHidden;
@Override
@@ -149,24 +147,27 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
colorIcon = night ? R.color.icon_color_default_dark : R.color.icon_color_default_light;
colorText = night ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light;
}
- if (colorIcon != 0) {
- iconPaint.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(getActivity(), colorIcon), PorterDuff.Mode.SRC_IN));
- }
- textPaint.setColor(ContextCompat.getColor(getActivity(), colorText));
+ textPaint.setColor(ContextCompat.getColor(app, colorText));
+ Drawable icon = app.getUIUtilities().getIcon(
+ dX > 0 ? R.drawable.ic_action_history : R.drawable.ic_action_delete_dark,
+ colorIcon);
+ int iconWidth = icon.getIntrinsicWidth();
+ int iconHeight = icon.getIntrinsicHeight();
float textMarginTop = ((float) itemView.getHeight() - (float) textHeight) / 2;
+ float iconMarginTop = ((float) itemView.getHeight() - (float) iconHeight) / 2;
+ int iconTopY = itemView.getTop() + (int) iconMarginTop;
+ int iconLeftX;
if (dX > 0) {
+ iconLeftX = itemView.getLeft() + (int) marginSides;
c.drawRect(itemView.getLeft(), itemView.getTop(), dX, itemView.getBottom(), backgroundPaint);
- float iconMarginTop = ((float) itemView.getHeight() - (float) historyBitmap.getHeight()) / 2;
- c.drawBitmap(historyBitmap, itemView.getLeft() + marginSides, itemView.getTop() + iconMarginTop, iconPaint);
- c.drawText(moveToHistoryStr, itemView.getLeft() + 2 * marginSides + historyBitmap.getWidth(),
- itemView.getTop() + textMarginTop + textHeight, textPaint);
+ c.drawText(moveToHistoryStr, itemView.getLeft() + 2 * marginSides + iconWidth, itemView.getTop() + textMarginTop + textHeight, textPaint);
} else {
+ iconLeftX = itemView.getRight() - iconWidth - (int) marginSides;
c.drawRect(itemView.getRight() + dX, itemView.getTop(), itemView.getRight(), itemView.getBottom(), backgroundPaint);
- float iconMarginTop = ((float) itemView.getHeight() - (float) deleteBitmap.getHeight()) / 2;
- c.drawBitmap(deleteBitmap, itemView.getRight() - deleteBitmap.getWidth() - marginSides, itemView.getTop() + iconMarginTop, iconPaint);
- c.drawText(delStr, itemView.getRight() - deleteBitmap.getWidth() - 2 * marginSides - delStrWidth,
- itemView.getTop() + textMarginTop + textHeight, textPaint);
+ c.drawText(delStr, itemView.getRight() - iconWidth - 2 * marginSides - delStrWidth, itemView.getTop() + textMarginTop + textHeight, textPaint);
}
+ icon.setBounds(iconLeftX, iconTopY, iconLeftX + iconWidth, iconTopY + iconHeight);
+ icon.draw(c);
}
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
}
@@ -189,10 +190,10 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
final MapMarker marker = (MapMarker) item;
int snackbarStringRes;
if (direction == ItemTouchHelper.RIGHT) {
- mapActivity.getMyApplication().getMapMarkersHelper().moveMapMarkerToHistory((MapMarker) item);
+ app.getMapMarkersHelper().moveMapMarkerToHistory((MapMarker) item);
snackbarStringRes = R.string.marker_moved_to_history;
} else {
- mapActivity.getMyApplication().getMapMarkersHelper().removeMarker((MapMarker) item);
+ app.getMapMarkersHelper().removeMarker((MapMarker) item);
snackbarStringRes = R.string.item_removed;
}
updateAdapter();
@@ -201,9 +202,9 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
@Override
public void onClick(View view) {
if (direction == ItemTouchHelper.RIGHT) {
- mapActivity.getMyApplication().getMapMarkersHelper().restoreMarkerFromHistory(marker, 0);
+ app.getMapMarkersHelper().restoreMarkerFromHistory(marker, 0);
} else {
- mapActivity.getMyApplication().getMapMarkersHelper().addMarker(marker);
+ app.getMapMarkersHelper().addMarker(marker);
}
updateAdapter();
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java
index d7efc365f6..a472dbf3a7 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java
@@ -1,12 +1,9 @@
package net.osmand.plus.mapmarkers;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
-import android.graphics.PorterDuff;
-import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -39,7 +36,6 @@ public class MapMarkersHistoryFragment extends Fragment implements MapMarkersHel
private MapMarkersHistoryAdapter adapter;
private OsmandApplication app;
private Paint backgroundPaint = new Paint();
- private Paint iconPaint = new Paint();
private Paint textPaint = new Paint();
private Snackbar snackbar;
@@ -58,9 +54,6 @@ public class MapMarkersHistoryFragment extends Fragment implements MapMarkersHel
backgroundPaint.setColor(ContextCompat.getColor(getActivity(), night ? R.color.divider_color_dark : R.color.divider_color_light));
backgroundPaint.setStyle(Paint.Style.FILL_AND_STROKE);
backgroundPaint.setAntiAlias(true);
- iconPaint.setAntiAlias(true);
- iconPaint.setFilterBitmap(true);
- iconPaint.setDither(true);
textPaint.setTextSize(getResources().getDimension(R.dimen.default_desc_text_size));
textPaint.setFakeBoldText(true);
textPaint.setAntiAlias(true);
@@ -84,8 +77,6 @@ public class MapMarkersHistoryFragment extends Fragment implements MapMarkersHel
ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
private float marginSides = getResources().getDimension(R.dimen.list_content_padding);
- private Bitmap deleteBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_delete_dark);
- private Bitmap resetBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_reset_to_default_dark);
private boolean iconHidden;
@Override
@@ -118,22 +109,27 @@ public class MapMarkersHistoryFragment extends Fragment implements MapMarkersHel
colorIcon = night ? R.color.icon_color_default_dark : R.color.icon_color_default_light;
colorText = night ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light;
}
- if (colorIcon != 0) {
- iconPaint.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(getActivity(), colorIcon), PorterDuff.Mode.SRC_IN));
- }
- textPaint.setColor(ContextCompat.getColor(getActivity(), colorText));
+ textPaint.setColor(ContextCompat.getColor(app, colorText));
+ Drawable icon = app.getUIUtilities().getIcon(
+ dX > 0 ? R.drawable.ic_action_delete_dark : R.drawable.ic_action_reset_to_default_dark,
+ colorIcon);
+ int iconWidth = icon.getIntrinsicWidth();
+ int iconHeight = icon.getIntrinsicHeight();
float textMarginTop = ((float) itemView.getHeight() - (float) textHeight) / 2;
+ float iconMarginTop = ((float) itemView.getHeight() - (float) iconHeight) / 2;
+ int iconTopY = itemView.getTop() + (int) iconMarginTop;
+ int iconLeftX;
if (dX > 0) {
+ iconLeftX = itemView.getLeft() + (int) marginSides;
c.drawRect(itemView.getLeft(), itemView.getTop(), dX, itemView.getBottom(), backgroundPaint);
- float iconMarginTop = ((float) itemView.getHeight() - (float) deleteBitmap.getHeight()) / 2;
- c.drawBitmap(deleteBitmap, itemView.getLeft() + marginSides, itemView.getTop() + iconMarginTop, iconPaint);
- c.drawText(delStr, itemView.getLeft() + 2 * marginSides + deleteBitmap.getWidth(), itemView.getTop() + textMarginTop + textHeight, textPaint);
+ c.drawText(delStr, itemView.getLeft() + 2 * marginSides + iconWidth, itemView.getTop() + textMarginTop + textHeight, textPaint);
} else {
+ iconLeftX = itemView.getRight() - iconWidth - (int) marginSides;
c.drawRect(itemView.getRight() + dX, itemView.getTop(), itemView.getRight(), itemView.getBottom(), backgroundPaint);
- float iconMarginTop = ((float) itemView.getHeight() - (float) resetBitmap.getHeight()) / 2;
- c.drawBitmap(resetBitmap, itemView.getRight() - resetBitmap.getWidth() - marginSides, itemView.getTop() + iconMarginTop, iconPaint);
- c.drawText(activateStr, itemView.getRight() - resetBitmap.getWidth() - 2 * marginSides - activateStrWidth, itemView.getTop() + textMarginTop + textHeight, textPaint);
+ c.drawText(activateStr, itemView.getRight() - iconWidth - 2 * marginSides - activateStrWidth, itemView.getTop() + textMarginTop + textHeight, textPaint);
}
+ icon.setBounds(iconLeftX, iconTopY, iconLeftX + iconWidth, iconTopY + iconHeight);
+ icon.draw(c);
}
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkerHeaderViewHolder.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkerHeaderViewHolder.java
index 54bc803920..70d1106679 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkerHeaderViewHolder.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkerHeaderViewHolder.java
@@ -15,6 +15,7 @@ public class MapMarkerHeaderViewHolder extends RecyclerView.ViewHolder {
final View iconSpace;
final TextView title;
final TextView content;
+ final TextView clearButton;
final TextView button;
final SwitchCompat disableGroupSwitch;
final View bottomShadow;
@@ -28,6 +29,7 @@ public class MapMarkerHeaderViewHolder extends RecyclerView.ViewHolder {
disableGroupSwitch = (SwitchCompat) itemView.findViewById(R.id.disable_group_switch);
bottomShadow = itemView.findViewById(R.id.bottom_shadow);
content = itemView.findViewById(R.id.content);
+ clearButton = itemView.findViewById(R.id.clear_button);
button = itemView.findViewById(R.id.text_button);
articleDescription = itemView.findViewById(R.id.article_description);
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java
index ba54fa46d1..b73e06de68 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java
@@ -20,8 +20,10 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
public class MapMarkersHistoryAdapter extends RecyclerView.Adapter {
@@ -35,6 +37,7 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter items = new ArrayList<>();
+ private Map> markerGroups = new HashMap<>();
private MapMarkersHistoryAdapterListener listener;
private Snackbar snackbar;
private boolean night;
@@ -47,6 +50,7 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter();
+ markerGroups = new HashMap<>();
List markersHistory = app.getMapMarkersHelper().getMapMarkersHistory();
int previousHeader = -1;
int monthsDisplayed = 0;
@@ -85,10 +89,22 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter group = markerGroups.get(groupHeader);
+ if (group != null) {
+ group.add(marker);
+ } else {
+ group = new ArrayList<>();
+ group.add(marker);
+ markerGroups.put(groupHeader, group);
+ }
+ }
+
public void setAdapterListener(MapMarkersHistoryAdapterListener listener) {
this.listener = listener;
}
@@ -113,7 +129,7 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter group = markerGroups.get(dateHeader);
+ if (group == null) {
+ return;
+ }
+ for (MapMarker marker : group) {
+ app.getMapMarkersHelper().removeMarker((MapMarker) marker);
+ }
+ snackbar = Snackbar.make(holder.itemView, app.getString(R.string.n_items_removed), Snackbar.LENGTH_LONG)
+ .setAction(R.string.shared_string_undo, new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ for (MapMarker marker : group) {
+ app.getMapMarkersHelper().addMarker(marker);
+ }
+ }
+ });
+ UiUtilities.setupSnackbar(snackbar, night);
+ snackbar.show();
+ }
+ });
}
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersItemTouchHelperCallback.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersItemTouchHelperCallback.java
index ee19d38c48..2150bf246d 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersItemTouchHelperCallback.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersItemTouchHelperCallback.java
@@ -1,18 +1,16 @@
package net.osmand.plus.mapmarkers.adapters;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
-import android.graphics.PorterDuff;
-import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
import android.view.View;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;
+import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@@ -23,12 +21,9 @@ public class MapMarkersItemTouchHelperCallback extends ItemTouchHelper.Callback
private boolean swipeEnabled = true;
private Paint backgroundPaint = new Paint();
- private Paint iconPaint = new Paint();
private Paint textPaint = new Paint();
private float marginSides;
- private Bitmap deleteBitmap;
- private Bitmap historyBitmap;
private boolean iconHidden;
private boolean night;
@@ -47,16 +42,11 @@ public class MapMarkersItemTouchHelperCallback extends ItemTouchHelper.Callback
this.mapActivity = mapActivity;
this.adapter = adapter;
marginSides = mapActivity.getResources().getDimension(R.dimen.list_content_padding);
- deleteBitmap = BitmapFactory.decodeResource(mapActivity.getResources(), R.drawable.ic_action_delete_dark);
- historyBitmap = BitmapFactory.decodeResource(mapActivity.getResources(), R.drawable.ic_action_history);
night = !mapActivity.getMyApplication().getSettings().isLightContent();
backgroundPaint.setColor(ContextCompat.getColor(mapActivity, night ? R.color.divider_color_dark : R.color.divider_color_light));
backgroundPaint.setStyle(Paint.Style.FILL_AND_STROKE);
backgroundPaint.setAntiAlias(true);
- iconPaint.setAntiAlias(true);
- iconPaint.setFilterBitmap(true);
- iconPaint.setDither(true);
textPaint.setTextSize(mapActivity.getResources().getDimension(R.dimen.default_desc_text_size));
textPaint.setFakeBoldText(true);
textPaint.setAntiAlias(true);
@@ -100,6 +90,7 @@ public class MapMarkersItemTouchHelperCallback extends ItemTouchHelper.Callback
@Override
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE && viewHolder instanceof MapMarkerItemViewHolder) {
+ OsmandApplication app = mapActivity.getMyApplication();
if (!iconHidden && isCurrentlyActive) {
((MapMarkerItemViewHolder) viewHolder).optionsBtn.setVisibility(View.GONE);
iconHidden = true;
@@ -115,17 +106,19 @@ public class MapMarkersItemTouchHelperCallback extends ItemTouchHelper.Callback
colorIcon = night ? R.color.icon_color_default_dark : R.color.icon_color_default_light;
colorText = night ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light;
}
- if (colorIcon != 0) {
- iconPaint.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(mapActivity, colorIcon), PorterDuff.Mode.SRC_IN));
- }
textPaint.setColor(ContextCompat.getColor(mapActivity, colorText));
+ Drawable icon = app.getUIUtilities().getIcon(R.drawable.ic_action_history, colorIcon);
+ int iconWidth = icon.getIntrinsicWidth();
+ int iconHeight = icon.getIntrinsicHeight();
float textMarginTop = ((float) itemView.getHeight() - (float) textHeight) / 2;
+ float iconMarginTop = ((float) itemView.getHeight() - (float) iconHeight) / 2;
+ int iconTopY = itemView.getTop() + (int) iconMarginTop;
+ int iconLeftX = itemView.getLeft() + (int) marginSides;
c.drawRect(itemView.getLeft(), itemView.getTop(), dX, itemView.getBottom(), backgroundPaint);
- float iconMarginTop = ((float) itemView.getHeight() - (float) historyBitmap.getHeight()) / 2;
- c.drawBitmap(historyBitmap, itemView.getLeft() + marginSides, itemView.getTop() + iconMarginTop, iconPaint);
- c.drawText(moveToHistoryStr, itemView.getLeft() + 2 * marginSides + historyBitmap.getWidth(),
+ c.drawText(moveToHistoryStr, itemView.getLeft() + 2 * marginSides + iconWidth,
itemView.getTop() + textMarginTop + textHeight, textPaint);
-
+ icon.setBounds(iconLeftX, iconTopY, iconLeftX + iconWidth, iconTopY + iconHeight);
+ icon.draw(c);
}
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
}
diff --git a/OsmAnd/src/net/osmand/plus/render/UnscaledBitmapLoader.java b/OsmAnd/src/net/osmand/plus/render/UnscaledBitmapLoader.java
deleted file mode 100644
index 59ce504107..0000000000
--- a/OsmAnd/src/net/osmand/plus/render/UnscaledBitmapLoader.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package net.osmand.plus.render;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.BitmapFactory.Options;
-import android.os.Build;
-import android.util.DisplayMetrics;
-
-public abstract class UnscaledBitmapLoader {
-
- public static final UnscaledBitmapLoader instance;
-
- static {
- instance = Integer.parseInt(Build.VERSION.SDK) < 4 ? new Old() : new New();
- }
-
- public static Bitmap loadFromResource(Resources resources, int resId, BitmapFactory.Options options, DisplayMetrics densityDpi) {
- return instance.load(resources, resId, options, densityDpi);
- }
-
- private static class Old extends UnscaledBitmapLoader {
-
- @Override
- Bitmap load(Resources resources, int resId, Options options, DisplayMetrics densityDpi) {
- return BitmapFactory.decodeResource(resources, resId, options);
- }
-
- }
-
- private static class New extends UnscaledBitmapLoader {
-
- @Override
- Bitmap load(Resources resources, int resId, Options options, DisplayMetrics dm) {
- options = new BitmapFactory.Options();
- options.inScaled = false;
- options.inTargetDensity = dm.densityDpi;
- options.inDensity = dm.densityDpi;
- return BitmapFactory.decodeResource(resources, resId, options);
- }
-
- }
-
- abstract Bitmap load(Resources resources, int resId, BitmapFactory.Options options, DisplayMetrics densityDpi);
-
-}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java b/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java
index cf25e38814..402fd70fb8 100644
--- a/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java
+++ b/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java
@@ -3,7 +3,6 @@ package net.osmand.plus.views;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
-import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PointF;
import android.graphics.PorterDuff;