From 65bc72e0a634442df929255ef29b5b7a48499d34 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 11 Aug 2020 12:11:17 +0300 Subject: [PATCH 01/14] saving work state --- .../plus/mapcontextmenu/MapContextMenuFragment.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 4abe2f71df..9422bc4b2b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -5,6 +5,9 @@ import android.animation.AnimatorListenerAdapter; import android.annotation.TargetApi; import android.content.Context; import android.content.res.Resources; +import android.graphics.ColorFilter; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; @@ -1817,9 +1820,13 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo if (!Algorithms.isEmpty(typeStr)) { line2Str.append(typeStr); Drawable icon = menu.getTypeIcon(); + ColorFilter colorFilter = new PorterDuffColorFilter( + ContextCompat.getColor(requireContext(), menu.getAdditionalInfoColor()), + PorterDuff.Mode.SRC_ATOP); + icon.setColorFilter(colorFilter); AndroidUtils.setCompoundDrawablesWithIntrinsicBounds( line2, icon, null, null, null); - line2.setCompoundDrawablePadding(dpToPx(5f)); + line2.setCompoundDrawablePadding(dpToPx(5f)); // TODO here 2 } if (!Algorithms.isEmpty(streetStr) && !menu.displayStreetNameInTitle()) { if (line2Str.length() > 0) { From d4fa8acb7db2059fd499248963ee2892f1b37caf Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 11 Aug 2020 12:16:53 +0300 Subject: [PATCH 02/14] color for icon favorites added --- .../MapContextMenuFragment.java | 40 ++++++++++++++----- .../other/MultiSelectionArrayAdapter.java | 24 +++++++++++ 2 files changed, 54 insertions(+), 10 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 9422bc4b2b..fd58b6efc6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -45,10 +45,12 @@ import androidx.annotation.Nullable; import androidx.appcompat.content.res.AppCompatResources; import androidx.appcompat.view.ContextThemeWrapper; import androidx.core.content.ContextCompat; +import androidx.core.graphics.drawable.DrawableCompat; 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; @@ -57,6 +59,7 @@ 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; @@ -169,7 +172,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo private int screenOrientation; private boolean created; - + private boolean transportBadgesCreated; private UpdateLocationViewCache updateLocationViewCache; @@ -783,7 +786,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo } return false; } - + private float getToolbarAlpha(int y) { float a = 0; if (menu != null && !menu.isLandscapeLayout()) { @@ -1149,7 +1152,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo Typeface typeface = FontCache.getRobotoRegular(context); title.setSpan(new CustomTypefaceSpan(typeface), startIndex, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); title.setSpan(new ForegroundColorSpan( - ContextCompat.getColor(context, nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light)), + ContextCompat.getColor(context, nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light)), startIndex, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } setupButton(leftTitleButtonView, leftTitleButtonController.enabled, title); @@ -1623,7 +1626,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo return dpToPx(32); } } - + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void runLayoutListener() { if (view != null) { @@ -1806,7 +1809,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo TextView line1 = (TextView) view.findViewById(R.id.context_menu_line1); line1.setText(menu.getTitleStr()); toolbarTextView.setText(menu.getTitleStr()); - // Text line 2 LinearLayout line2layout = (LinearLayout) view.findViewById(R.id.context_menu_line2_layout); TextView line2 = (TextView) view.findViewById(R.id.context_menu_line2); @@ -1819,14 +1821,12 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo StringBuilder line2Str = new StringBuilder(); if (!Algorithms.isEmpty(typeStr)) { line2Str.append(typeStr); + Drawable icon = menu.getTypeIcon(); - ColorFilter colorFilter = new PorterDuffColorFilter( - ContextCompat.getColor(requireContext(), menu.getAdditionalInfoColor()), - PorterDuff.Mode.SRC_ATOP); - icon.setColorFilter(colorFilter); AndroidUtils.setCompoundDrawablesWithIntrinsicBounds( line2, icon, null, null, null); - line2.setCompoundDrawablePadding(dpToPx(5f)); // TODO here 2 + setColoredIconForGroup(line2,menu.getTypeStr()); + line2.setCompoundDrawablePadding(dpToPx(5f)); } if (!Algorithms.isEmpty(streetStr) && !menu.displayStreetNameInTitle()) { if (line2Str.length() > 0) { @@ -1886,6 +1886,26 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo updateAdditionalInfoVisibility(); } + private void setColoredIconForGroup(TextView line2, String groupName) { + OsmandApplication app = getMyApplication(); + if (app != null){ + FavouritesDbHelper helper = app.getFavorites(); + if (helper != null){ + FavouritesDbHelper.FavoriteGroup favoriteGroup = app.getFavorites() + .getGroup( + FavouritesDbHelper.FavoriteGroup. + convertDisplayNameToGroupIdName( + requireContext(),groupName)); + if (favoriteGroup != null) { + int color = favoriteGroup.getColor() == 0 ? view.getResources().getColor(R.color.color_favorite) : favoriteGroup.getColor(); + line2.setCompoundDrawablesWithIntrinsicBounds( + app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_folder, color), + null,null,null); + } + } + } + } + private void updateCompassVisibility() { OsmandApplication app = getMyApplication(); if (app != null && view != null) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java index 1537422e0e..4a37471cbc 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java @@ -1,5 +1,8 @@ package net.osmand.plus.mapcontextmenu.other; +import android.graphics.ColorFilter; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.view.View; import android.view.ViewGroup; @@ -12,6 +15,8 @@ import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import net.osmand.AndroidUtils; +import net.osmand.plus.FavouritesDbHelper; +import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; @@ -87,6 +92,25 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter Date: Tue, 11 Aug 2020 12:47:20 +0300 Subject: [PATCH 03/14] coloured icons in multiple selection --- .../net/osmand/plus/FavouritesDbHelper.java | 19 ++++++++++-- .../MapContextMenuFragment.java | 31 ++++++------------- .../other/MultiSelectionArrayAdapter.java | 29 +++++++---------- 3 files changed, 38 insertions(+), 41 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index 4b9dc43eb3..87787639a2 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -2,6 +2,8 @@ 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; @@ -128,6 +130,19 @@ public class FavouritesDbHelper { } } + public Drawable setColoredIconForGroup(String groupName) { + FavouritesDbHelper.FavoriteGroup favoriteGroup = this.getGroup( + FavouritesDbHelper.FavoriteGroup. + convertDisplayNameToGroupIdName( + this.context, groupName)); + if (favoriteGroup != null) { + int color = favoriteGroup.getColor() == 0 ? + this.context.getResources().getColor(R.color.color_favorite) : favoriteGroup.getColor(); + return this.context.getUIUtilities().getPaintedIcon(R.drawable.ic_action_folder, color); + } + return null; + } + public int getColorWithCategory(FavouritePoint point, int defaultColor) { int color = 0; if (point.getColor() != 0) { @@ -884,7 +899,7 @@ public class FavouritesDbHelper { private static final String FAVOURITE_COL_LAT = "latitude"; //$NON-NLS-1$ private static final String FAVOURITE_COL_LON = "longitude"; //$NON-NLS-1$ private static final String FAVOURITE_TABLE_CREATE = "CREATE TABLE " + FAVOURITE_TABLE_NAME + " (" + //$NON-NLS-1$ //$NON-NLS-2$ - FAVOURITE_COL_NAME + " TEXT, " + FAVOURITE_COL_CATEGORY + " TEXT, " + //$NON-NLS-1$ //$NON-NLS-2$ + FAVOURITE_COL_NAME + " TEXT, " + FAVOURITE_COL_CATEGORY + " TEXT, " + //$NON-NLS-1$ //$NON-NLS-2$ FAVOURITE_COL_LAT + " double, " + FAVOURITE_COL_LON + " double);"; //$NON-NLS-1$ //$NON-NLS-2$ private SQLiteConnection conn; @@ -925,7 +940,7 @@ public class FavouritesDbHelper { try { SQLiteCursor query = db .rawQuery( - "SELECT " + FAVOURITE_COL_NAME + ", " + FAVOURITE_COL_CATEGORY + ", " + FAVOURITE_COL_LAT + "," + FAVOURITE_COL_LON + " FROM " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "SELECT " + FAVOURITE_COL_NAME + ", " + FAVOURITE_COL_CATEGORY + ", " + FAVOURITE_COL_LAT + "," + FAVOURITE_COL_LON + " FROM " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ FAVOURITE_TABLE_NAME, null); cachedFavoritePoints.clear(); if (query != null && query.moveToFirst()) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index fd58b6efc6..c15ac1a8ae 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -94,6 +94,7 @@ 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; @@ -1825,7 +1826,15 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo Drawable icon = menu.getTypeIcon(); AndroidUtils.setCompoundDrawablesWithIntrinsicBounds( line2, icon, null, null, null); - setColoredIconForGroup(line2,menu.getTypeStr()); + String groupName = convertDisplayNameToGroupIdName(requireContext(), + menu.getTypeStr()); + if (menu.getMyApplication() != null){ + FavouritesDbHelper helper = menu.getMyApplication().getFavorites(); + if (helper != null){ + Drawable line2icon = helper.setColoredIconForGroup(groupName); + line2.setCompoundDrawablesWithIntrinsicBounds(line2icon, null, null, null); + } + } line2.setCompoundDrawablePadding(dpToPx(5f)); } if (!Algorithms.isEmpty(streetStr) && !menu.displayStreetNameInTitle()) { @@ -1886,26 +1895,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo updateAdditionalInfoVisibility(); } - private void setColoredIconForGroup(TextView line2, String groupName) { - OsmandApplication app = getMyApplication(); - if (app != null){ - FavouritesDbHelper helper = app.getFavorites(); - if (helper != null){ - FavouritesDbHelper.FavoriteGroup favoriteGroup = app.getFavorites() - .getGroup( - FavouritesDbHelper.FavoriteGroup. - convertDisplayNameToGroupIdName( - requireContext(),groupName)); - if (favoriteGroup != null) { - int color = favoriteGroup.getColor() == 0 ? view.getResources().getColor(R.color.color_favorite) : favoriteGroup.getColor(); - line2.setCompoundDrawablesWithIntrinsicBounds( - app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_folder, color), - null,null,null); - } - } - } - } - private void updateCompassVisibility() { OsmandApplication app = getMyApplication(); if (app != null && view != null) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java index 4a37471cbc..0cb7812e47 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java @@ -16,12 +16,15 @@ import androidx.core.content.ContextCompat; import net.osmand.AndroidUtils; import net.osmand.plus.FavouritesDbHelper; +import net.osmand.plus.OsmAndConstants; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import java.util.List; +import static net.osmand.plus.FavouritesDbHelper.FavoriteGroup.convertDisplayNameToGroupIdName; + public class MultiSelectionArrayAdapter extends ArrayAdapter { private MapMultiSelectionMenu menu; @@ -92,25 +95,15 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter Date: Tue, 11 Aug 2020 17:01:21 +0300 Subject: [PATCH 04/14] colored icons bug fix --- .../MapContextMenuFragment.java | 23 +++++-- .../other/MultiSelectionArrayAdapter.java | 32 ++++++++-- .../src/net/osmand/view/GravityDrawable.java | 60 +++++++++++++++++++ 3 files changed, 104 insertions(+), 11 deletions(-) create mode 100644 OsmAnd/src/net/osmand/view/GravityDrawable.java diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index c15ac1a8ae..90b1752549 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -5,10 +5,12 @@ import android.animation.AnimatorListenerAdapter; import android.annotation.TargetApi; import android.content.Context; import android.content.res.Resources; +import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.Typeface; +import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; import android.os.Build; @@ -89,6 +91,7 @@ import net.osmand.plus.views.controls.SingleTapConfirm; import net.osmand.plus.widgets.style.CustomTypefaceSpan; import net.osmand.router.TransportRouteResult; import net.osmand.util.Algorithms; +import net.osmand.view.GravityDrawable; import java.util.ArrayList; import java.util.List; @@ -1824,22 +1827,32 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo line2Str.append(typeStr); Drawable icon = menu.getTypeIcon(); - AndroidUtils.setCompoundDrawablesWithIntrinsicBounds( - line2, icon, null, null, null); + 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){ FavouritesDbHelper helper = menu.getMyApplication().getFavorites(); - if (helper != null){ + if (helper != null && helper.getGroup(groupName) != null){ Drawable line2icon = helper.setColoredIconForGroup(groupName); - line2.setCompoundDrawablesWithIntrinsicBounds(line2icon, null, null, null); + GravityDrawable line2GravityDrawable = + new GravityDrawable(line2icon); + line2.setCompoundDrawablesWithIntrinsicBounds( + line2GravityDrawable, null, null, null); } } line2.setCompoundDrawablePadding(dpToPx(5f)); } + if (menu.getPointDescription().isFavorite() && + menu.getObject() instanceof FavouritePoint){ + streetStr = ((FavouritePoint)menu.getObject()).getAddress(); + } if (!Algorithms.isEmpty(streetStr) && !menu.displayStreetNameInTitle()) { if (line2Str.length() > 0) { - line2Str.append(": "); + line2Str.append(", "); } line2Str.append(streetStr); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java index 0cb7812e47..868888ef2b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java @@ -15,11 +15,14 @@ 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.OsmAndConstants; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; +import net.osmand.util.Algorithms; +import net.osmand.view.GravityDrawable; import java.util.List; @@ -90,18 +93,35 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter 0) { + line2Str.append(", "); + } + line2Str.append(streetStr); + } + line2.setText(line2Str); Drawable slIcon = item.getTypeIcon(); - line2.setCompoundDrawablesWithIntrinsicBounds(slIcon, null, null, null); - line2.setCompoundDrawablePadding(AndroidUtils.dpToPx(menu.getMapActivity(), 5f)); - + GravityDrawable line2Icon = new GravityDrawable(slIcon); + if (slIcon != null){ + line2Icon.setBoundsFrom(slIcon); + line2.setCompoundDrawablesWithIntrinsicBounds(line2Icon, 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){ + if (helper != null && helper.getGroup(groupName) != null){ Drawable line2icon = helper.setColoredIconForGroup(groupName); - line2.setCompoundDrawablesWithIntrinsicBounds(line2icon, null, null, null); + GravityDrawable line2GravityIcon = new GravityDrawable(line2icon); + line2GravityIcon.setBoundsFrom(line2icon); + line2.setCompoundDrawablesWithIntrinsicBounds(line2GravityIcon, null, null, null); } } // Divider diff --git a/OsmAnd/src/net/osmand/view/GravityDrawable.java b/OsmAnd/src/net/osmand/view/GravityDrawable.java new file mode 100644 index 0000000000..1bb887469f --- /dev/null +++ b/OsmAnd/src/net/osmand/view/GravityDrawable.java @@ -0,0 +1,60 @@ +package net.osmand.view; + +import android.graphics.Canvas; +import android.graphics.ColorFilter; +import android.graphics.PixelFormat; +import android.graphics.drawable.Drawable; + +import androidx.annotation.Nullable; + +public class GravityDrawable extends Drawable { + + // inner Drawable + private final Drawable mDrawable; + + public GravityDrawable(Drawable drawable) { + mDrawable = drawable; + } + + @Override + public int getIntrinsicWidth() { + if (mDrawable != null) return mDrawable.getIntrinsicWidth(); else return 0; + } + + @Override + public int getIntrinsicHeight() { + if (mDrawable != null) return mDrawable.getIntrinsicHeight(); else return 0; + } + + @Override + public void draw(Canvas canvas) { + int halfCanvas= canvas.getHeight() / 2; + int halfDrawable = mDrawable.getIntrinsicHeight() / 2; + + // align to top + canvas.save(); + canvas.translate(0, -halfCanvas + halfDrawable); + mDrawable.draw(canvas); + canvas.restore(); + } + + @Override + public void setAlpha(int i) { + if (mDrawable != null) mDrawable.setAlpha(i); + } + + @Override + public void setColorFilter(@Nullable ColorFilter colorFilter) { + if (mDrawable != null) mDrawable.setColorFilter(colorFilter); + } + + @Override + public int getOpacity() { + if (mDrawable != null) return mDrawable.getOpacity(); else return PixelFormat.UNKNOWN; + } + + public void setBoundsFrom(Drawable line2Icon) { + line2Icon.setBounds(0, 0, line2Icon.getIntrinsicWidth(), line2Icon.getIntrinsicHeight()); + this.setBounds(0, 0, line2Icon.getIntrinsicWidth(), line2Icon.getIntrinsicHeight()); + } +} From 58bf6d35f6599411868eb4894c76692273523c0b Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 17 Aug 2020 11:03:52 +0300 Subject: [PATCH 05/14] style issues fixed --- OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java | 10 +++++----- .../plus/mapcontextmenu/MapContextMenuFragment.java | 8 +------- .../other/MultiSelectionArrayAdapter.java | 7 +------ 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index 87787639a2..7873b3b2cb 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -130,15 +130,15 @@ public class FavouritesDbHelper { } } - public Drawable setColoredIconForGroup(String groupName) { - FavouritesDbHelper.FavoriteGroup favoriteGroup = this.getGroup( + public Drawable getColoredIconForGroup(String groupName) { + FavouritesDbHelper.FavoriteGroup favoriteGroup = getGroup( FavouritesDbHelper.FavoriteGroup. convertDisplayNameToGroupIdName( - this.context, groupName)); + context, groupName)); if (favoriteGroup != null) { int color = favoriteGroup.getColor() == 0 ? - this.context.getResources().getColor(R.color.color_favorite) : favoriteGroup.getColor(); - return this.context.getUIUtilities().getPaintedIcon(R.drawable.ic_action_folder, color); + context.getResources().getColor(R.color.color_favorite) : favoriteGroup.getColor(); + return context.getUIUtilities().getPaintedIcon(R.drawable.ic_action_folder, color); } return null; } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 90b1752549..ff38d8441c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -5,12 +5,7 @@ import android.animation.AnimatorListenerAdapter; import android.annotation.TargetApi; import android.content.Context; import android.content.res.Resources; -import android.graphics.Canvas; -import android.graphics.ColorFilter; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffColorFilter; import android.graphics.Typeface; -import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; import android.os.Build; @@ -47,7 +42,6 @@ import androidx.annotation.Nullable; import androidx.appcompat.content.res.AppCompatResources; import androidx.appcompat.view.ContextThemeWrapper; import androidx.core.content.ContextCompat; -import androidx.core.graphics.drawable.DrawableCompat; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; @@ -1837,7 +1831,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo if (menu.getMyApplication() != null){ FavouritesDbHelper helper = menu.getMyApplication().getFavorites(); if (helper != null && helper.getGroup(groupName) != null){ - Drawable line2icon = helper.setColoredIconForGroup(groupName); + Drawable line2icon = helper.getColoredIconForGroup(groupName); GravityDrawable line2GravityDrawable = new GravityDrawable(line2icon); line2.setCompoundDrawablesWithIntrinsicBounds( diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java index 868888ef2b..36262e2fb8 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java @@ -1,8 +1,5 @@ package net.osmand.plus.mapcontextmenu.other; -import android.graphics.ColorFilter; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.view.View; import android.view.ViewGroup; @@ -17,8 +14,6 @@ import androidx.core.content.ContextCompat; import net.osmand.AndroidUtils; import net.osmand.data.FavouritePoint; import net.osmand.plus.FavouritesDbHelper; -import net.osmand.plus.OsmAndConstants; -import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.util.Algorithms; @@ -118,7 +113,7 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter Date: Mon, 17 Aug 2020 13:39:53 +0300 Subject: [PATCH 06/14] street str refactoring --- .../plus/mapcontextmenu/MapContextMenuFragment.java | 11 +++-------- .../controllers/FavouritePointMenuController.java | 6 ++++++ .../other/MultiSelectionArrayAdapter.java | 6 +----- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index ff38d8441c..1fb45a0c88 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -1804,12 +1804,12 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo private void setAddressLocation() { if (view != null) { // Text line 1 - TextView line1 = (TextView) view.findViewById(R.id.context_menu_line1); + TextView line1 = view.findViewById(R.id.context_menu_line1); line1.setText(menu.getTitleStr()); toolbarTextView.setText(menu.getTitleStr()); // Text line 2 - LinearLayout line2layout = (LinearLayout) view.findViewById(R.id.context_menu_line2_layout); - TextView line2 = (TextView) view.findViewById(R.id.context_menu_line2); + LinearLayout line2layout = view.findViewById(R.id.context_menu_line2_layout); + TextView line2 = view.findViewById(R.id.context_menu_line2); if (menu.hasCustomAddressLine()) { line2layout.removeAllViews(); menu.buildCustomAddressLine(line2layout); @@ -1819,7 +1819,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo StringBuilder line2Str = new StringBuilder(); if (!Algorithms.isEmpty(typeStr)) { line2Str.append(typeStr); - Drawable icon = menu.getTypeIcon(); if (icon != null){ GravityDrawable gravityIcon = new GravityDrawable(icon); @@ -1840,10 +1839,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo } line2.setCompoundDrawablePadding(dpToPx(5f)); } - if (menu.getPointDescription().isFavorite() && - menu.getObject() instanceof FavouritePoint){ - streetStr = ((FavouritePoint)menu.getObject()).getAddress(); - } if (!Algorithms.isEmpty(streetStr) && !menu.displayStreetNameInTitle()) { if (line2Str.length() > 0) { line2Str.append(", "); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java index 7dea6105ef..ca01bf246e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java @@ -150,6 +150,12 @@ public class FavouritePointMenuController extends MenuController { } } + @NonNull + @Override + public String getSubtypeStr() { + return fav.getAddress(); + } + @Override public Drawable getSecondLineTypeIcon() { return getIcon(R.drawable.ic_action_group_name_16, isLight() ? R.color.icon_color_default_light : R.color.ctx_menu_bottom_view_icon_dark); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java index 36262e2fb8..299a23f95a 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java @@ -89,11 +89,7 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter 0) { line2Str.append(", "); From 8f0c7341cfb4aec92564e3e945c3b53eda7495b3 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 17 Aug 2020 17:28:33 +0300 Subject: [PATCH 07/14] favorite screen changes --- .../res/layout/point_editor_fragment_new.xml | 982 ++++++++++-------- OsmAnd/res/values/strings.xml | 3 + .../FavoritePointEditorFragmentNew.java | 6 + .../editors/PointEditorFragmentNew.java | 52 +- .../editors/WptPtEditorFragmentNew.java | 3 + 5 files changed, 582 insertions(+), 464 deletions(-) diff --git a/OsmAnd/res/layout/point_editor_fragment_new.xml b/OsmAnd/res/layout/point_editor_fragment_new.xml index edb092f31e..4dcaa46680 100644 --- a/OsmAnd/res/layout/point_editor_fragment_new.xml +++ b/OsmAnd/res/layout/point_editor_fragment_new.xml @@ -1,528 +1,586 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:osmand="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/point_edit_layout" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@android:color/transparent" + android:fitsSystemWindows="true"> - + - + - + - + - + - + - + - + - + android:id="@+id/name_caption" + style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:hint="@string/shared_string_name" + app:boxBackgroundColor="@color/material_text_input_layout_bg"> - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + + - + - + - + - - + - + - - + - - + - + - + + - + - + + - + + - + - + - - + - - + - + - + - - + - + + - + - + - + - + - + + - + - + - + - + - + - - + - + - + - + - + - + - - + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 0981dc27a2..42178c713b 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,9 @@ Thx - Hardy --> + Enter address + Add address + Delete address Street-level imagery Select a track file for which a new segment will be added. Navigation profile diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java index b3159922cf..091b93f9a0 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java @@ -405,6 +405,12 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { return favorite != null ? favorite.getDescription() : ""; } + @Override + public String getAddressInitValue() { + FavouritePoint favourite = getFavorite(); + return favorite != null ? favorite.getAddress() : ""; + } + @Override public Drawable getNameIcon() { FavouritePoint favorite = getFavorite(); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java index 6751c9181c..69b4ea524a 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java @@ -75,6 +75,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { private View view; private EditText nameEdit; private TextView addDelDescription; + private TextView addAddressBtn; private TextView addToHiddenGroupInfo; private boolean cancelled; private boolean nightMode; @@ -91,7 +92,9 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { private LinkedHashMap iconCategories; private OsmandApplication app; private View descriptionCaption; + private View addressCaption; private EditText descriptionEdit; + private EditText addressEdit; private int layoutHeightPrevious = 0; @SuppressLint("ClickableViewAccessibility") @@ -142,11 +145,12 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { hideKeyboard(); descriptionEdit.clearFocus(); nameEdit.clearFocus(); + addressEdit.clearFocus(); } } }); - int activeColorResId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light; + final int activeColorResId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light; ImageView toolbarAction = (ImageView) view.findViewById(R.id.toolbar_action); view.findViewById(R.id.background_layout).setBackgroundResource(nightMode ? R.color.app_bar_color_dark : R.color.list_background_color_light); @@ -218,38 +222,73 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { } descriptionEdit = (EditText) view.findViewById(R.id.description_edit); + addressEdit = (EditText) view.findViewById(R.id.address_edit); AndroidUtils.setTextPrimaryColor(view.getContext(), descriptionEdit, nightMode); + AndroidUtils.setTextPrimaryColor(view.getContext(), addressEdit, nightMode); AndroidUtils.setHintTextSecondaryColor(view.getContext(), descriptionEdit, nightMode); + AndroidUtils.setHintTextSecondaryColor(view.getContext(), addressEdit, nightMode); if (getDescriptionInitValue() != null) { descriptionEdit.setText(getDescriptionInitValue()); } + if (getAddressInitValue() != null){ + addressEdit.setText(getAddressInitValue()); + } descriptionCaption = view.findViewById(R.id.description); + addressCaption = view.findViewById(R.id.address); addDelDescription = (TextView) view.findViewById(R.id.description_button); + addAddressBtn = view.findViewById(R.id.address_button); addDelDescription.setTextColor(getResources().getColor(activeColorResId)); + addAddressBtn.setTextColor(getResources().getColor(activeColorResId)); + addAddressBtn.setCompoundDrawablesWithIntrinsicBounds( + app.getUIUtilities().getIcon(R.drawable.ic_action_location_off, activeColorResId),null,null,null); + addDelDescription.setCompoundDrawablesWithIntrinsicBounds( + app.getUIUtilities().getIcon(R.drawable.ic_action_description, activeColorResId),null,null,null); addDelDescription.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (descriptionCaption.getVisibility() != View.VISIBLE) { descriptionCaption.setVisibility(View.VISIBLE); addDelDescription.setText(view.getResources().getString(R.string.delete_description)); + addDelDescription.setCompoundDrawablesWithIntrinsicBounds( + app.getUIUtilities().getIcon(R.drawable.ic_action_delete_item, + activeColorResId),null,null,null); View descriptionEdit = view.findViewById(R.id.description_edit); descriptionEdit.requestFocus(); AndroidUtils.softKeyboardDelayed(descriptionEdit); } else { descriptionCaption.setVisibility(View.GONE); addDelDescription.setText(view.getResources().getString(R.string.add_description)); + addDelDescription.setCompoundDrawablesWithIntrinsicBounds( + app.getUIUtilities().getIcon(R.drawable.ic_action_location_off, + activeColorResId),null,null,null); AndroidUtils.hideSoftKeyboard(requireActivity(), descriptionEdit); descriptionEdit.clearFocus(); } } }); + addAddressBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (addressCaption.getVisibility() != View.VISIBLE) { + addressCaption.setVisibility(View.VISIBLE); + addAddressBtn.setText(view.getResources().getString(R.string.delete_address)); + View addressEdit = view.findViewById(R.id.address_edit); + addressEdit.requestFocus(); + AndroidUtils.softKeyboardDelayed(addressEdit); + } else { + addressCaption.setVisibility(View.GONE); + addAddressBtn.setText(view.getResources().getString(R.string.add_address)); + AndroidUtils.hideSoftKeyboard(requireActivity(), addressEdit); + addressEdit.clearFocus(); + } + } + }); nameIcon.setImageDrawable(getNameIcon()); if (app.accessibilityEnabled()) { nameCaption.setFocusable(true); nameEdit.setHint(R.string.access_hint_enter_name); - descriptionEdit.setHint(R.string.access_hint_enter_description); } View deleteButton = view.findViewById(R.id.button_delete_container); @@ -348,6 +387,13 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { descriptionCaption.setVisibility(View.GONE); addDelDescription.setText(app.getString(R.string.add_description)); } + if (!addressEdit.getText().toString().isEmpty() || addressEdit.hasFocus()) { + addressCaption.setVisibility(View.VISIBLE); + addAddressBtn.setText(app.getString(R.string.delete_address)); + } else { + addressCaption.setVisibility(View.GONE); + addAddressBtn.setText(app.getString(R.string.add_address)); + } } private void createGroupSelector() { @@ -754,6 +800,8 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { public abstract String getDescriptionInitValue(); + public abstract String getAddressInitValue(); + public abstract Drawable getNameIcon(); public abstract Drawable getCategoryIcon(); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java index 9142e13d6f..92d6368a04 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java @@ -402,6 +402,9 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew { return wpt != null ? wpt.desc : ""; } + @Override + public String getAddressInitValue() { return ""; } + @Override public Drawable getNameIcon() { WptPt wptPt = getWpt(); From 39b97a110e96372b629cc5a0e274ff33779f9f60 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 18 Aug 2020 11:34:55 +0300 Subject: [PATCH 08/14] address field added --- .../osmand/aidlapi/favorite/AFavorite.java | 5 +++++ OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 6 +++--- .../net/osmand/aidl/OsmandAidlService.java | 2 +- .../net/osmand/aidl/OsmandAidlServiceV2.java | 2 +- .../net/osmand/aidl/favorite/AFavorite.java | 8 +++++++- .../net/osmand/plus/FavouritesDbHelper.java | 3 ++- .../plus/mapcontextmenu/MapContextMenu.java | 2 +- .../editors/FavoritePointEditor.java | 4 +++- .../editors/FavoritePointEditorFragment.java | 18 ++++++++++-------- .../FavoritePointEditorFragmentNew.java | 19 +++++++++++-------- .../editors/PointEditorFragment.java | 6 ++++++ .../editors/PointEditorFragmentNew.java | 16 +++++++++++----- 12 files changed, 61 insertions(+), 30 deletions(-) diff --git a/OsmAnd-api/src/net/osmand/aidlapi/favorite/AFavorite.java b/OsmAnd-api/src/net/osmand/aidlapi/favorite/AFavorite.java index 1e645d2fae..ed2dabe064 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/favorite/AFavorite.java +++ b/OsmAnd-api/src/net/osmand/aidlapi/favorite/AFavorite.java @@ -11,6 +11,7 @@ public class AFavorite extends AidlParams { private double lon; private String name; private String description; + private String address; private String category; private String color; private boolean visible; @@ -58,6 +59,8 @@ public class AFavorite extends AidlParams { return description; } + public String getAddress() { return description; } + public String getCategory() { return category; } @@ -76,6 +79,7 @@ public class AFavorite extends AidlParams { bundle.putDouble("lon", lon); bundle.putString("name", name); bundle.putString("description", description); + bundle.putString("address", address); bundle.putString("category", category); bundle.putString("color", color); bundle.putBoolean("visible", visible); @@ -87,6 +91,7 @@ public class AFavorite extends AidlParams { lon = bundle.getDouble("lon"); name = bundle.getString("name"); description = bundle.getString("description"); + address = bundle.getString("address"); category = bundle.getString("category"); color = bundle.getString("color"); visible = bundle.getBoolean("visible"); diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 5e606801ef..3bdf3862a7 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -967,7 +967,7 @@ public class OsmandAidlApi { return false; } - boolean updateFavorite(String prevName, String prevCategory, double prevLat, double prevLon, String newName, String newCategory, String newDescription, double newLat, double newLon) { + boolean updateFavorite(String prevName, String prevCategory, double prevLat, double prevLon, String newName, String newCategory, String newDescription, String newAddress, double newLat, double newLon) { FavouritesDbHelper favoritesHelper = app.getFavorites(); List favorites = favoritesHelper.getFavouritePoints(); for (FavouritePoint f : favorites) { @@ -977,8 +977,8 @@ public class OsmandAidlApi { favoritesHelper.editFavourite(f, newLat, newLon); } if (!newName.equals(f.getName()) || !newDescription.equals(f.getDescription()) || - !newCategory.equals(f.getCategory())) { - favoritesHelper.editFavouriteName(f, newName, newCategory, newDescription); + !newCategory.equals(f.getCategory()) || !newAddress.equals(f.getAddress())) { + favoritesHelper.editFavouriteName(f, newName, newCategory, newDescription,newAddress); } refreshMap(); return true; diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java index 38966b37f0..f1c9493fc8 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java @@ -311,7 +311,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener { AFavorite newFav = params.getFavoriteNew(); if (prevFav != null && newFav != null) { return api.updateFavorite(prevFav.getName(), prevFav.getCategory(), prevFav.getLat(), prevFav.getLon(), - newFav.getName(), newFav.getCategory(), newFav.getDescription(), newFav.getLat(), newFav.getLon()); + newFav.getName(), newFav.getCategory(), newFav.getDescription(), newFav.getAddress(), newFav.getLat(), newFav.getLon()); } } return false; diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java index 1a4f675d52..01be4752b9 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java @@ -314,7 +314,7 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener AFavorite newFav = params.getFavoriteNew(); if (prevFav != null && newFav != null) { return api.updateFavorite(prevFav.getName(), prevFav.getCategory(), prevFav.getLat(), prevFav.getLon(), - newFav.getName(), newFav.getCategory(), newFav.getDescription(), newFav.getLat(), newFav.getLon()); + newFav.getName(), newFav.getCategory(), newFav.getDescription(), newFav.getAddress(), newFav.getLat(), newFav.getLon()); } } return false; diff --git a/OsmAnd/src/net/osmand/aidl/favorite/AFavorite.java b/OsmAnd/src/net/osmand/aidl/favorite/AFavorite.java index b7fc057249..376a958add 100644 --- a/OsmAnd/src/net/osmand/aidl/favorite/AFavorite.java +++ b/OsmAnd/src/net/osmand/aidl/favorite/AFavorite.java @@ -9,16 +9,18 @@ public class AFavorite implements Parcelable { private double lon; private String name; private String description; + private String address; private String category; private String color; private boolean visible; - public AFavorite(double lat, double lon, String name, String description, + public AFavorite(double lat, double lon, String name, String description, String address, String category, String color, boolean visible) { this.lat = lat; this.lon = lon; this.name = name; this.description = description; + this.address = address; this.category = category; this.color = color; this.visible = visible; @@ -56,6 +58,8 @@ public class AFavorite implements Parcelable { return description; } + public String getAddress() { return address; } + public String getCategory() { return category; } @@ -74,6 +78,7 @@ public class AFavorite implements Parcelable { out.writeDouble(lon); out.writeString(name); out.writeString(description); + out.writeString(address); out.writeString(category); out.writeString(color); out.writeByte((byte) (visible ? 1 : 0)); @@ -84,6 +89,7 @@ public class AFavorite implements Parcelable { lon = in.readDouble(); name = in.readString(); description = in.readString(); + address = in.readString(); category = in.readString(); color = in.readString(); visible = in.readByte() != 0; diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index 7873b3b2cb..c7b2ae6255 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -487,11 +487,12 @@ public class FavouritesDbHelper { return builder.toString(); } - public boolean editFavouriteName(FavouritePoint p, String newName, String category, String descr) { + public boolean editFavouriteName(FavouritePoint p, String newName, String category, String descr, String address) { String oldCategory = p.getCategory(); p.setName(newName); p.setCategory(category); p.setDescription(descr); + p.setAddress(address); if (!oldCategory.equals(category)) { FavoriteGroup old = flatGroups.get(oldCategory); if (old != null) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index bfc8838ef0..6b11c35b29 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -1042,7 +1042,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL } FavoritePointEditor favoritePointEditor = getFavoritePointEditor(); if (favoritePointEditor != null) { - favoritePointEditor.add(getLatLon(), title, originObjectName); + favoritePointEditor.add(getLatLon(), title, getStreetStr(), originObjectName); } } }); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java index edff9ef6fb..db68cef5c5 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java @@ -27,7 +27,7 @@ public class FavoritePointEditor extends PointEditor { return favorite; } - public void add(LatLon latLon, String title, String originObjectName) { + public void add(LatLon latLon, String title, String address, String originObjectName) { MapActivity mapActivity = getMapActivity(); if (latLon == null || mapActivity == null) { return; @@ -39,6 +39,7 @@ public class FavoritePointEditor extends PointEditor { } favorite = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), title, lastCategory); favorite.setDescription(""); + favorite.setAddress(address); favorite.setOriginObjectName(originObjectName); FavoritePointEditorFragmentNew.showInstance(mapActivity); } @@ -61,6 +62,7 @@ public class FavoritePointEditor extends PointEditor { favorite = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), title, categoryName); favorite.setDescription(""); + favorite.setAddress(title); favorite.setOriginObjectName(originObjectName); FavoritePointEditorFragmentNew.showAutoFillInstance(mapActivity, autoFill); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java index d3f6ea52c6..fe05bf4296 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java @@ -192,12 +192,13 @@ public class FavoritePointEditorFragment extends PointEditorFragment { final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(), getNameTextValue(), getCategoryTextValue()); point.setDescription(getDescriptionTextValue()); + point.setAddress(getAddressTextValue()); AlertDialog.Builder builder = FavouritesDbHelper.checkDuplicates(point, helper, getMapActivity()); if (favorite.getName().equals(point.getName()) && favorite.getCategory().equals(point.getCategory()) && - Algorithms.stringsEqual(favorite.getDescription(), point.getDescription())) { - + Algorithms.stringsEqual(favorite.getDescription(), point.getDescription()) && + Algorithms.stringsEqual(favorite.getAddress(),point.getAddress())) { if (needDismiss) { dismiss(false); } @@ -208,25 +209,25 @@ public class FavoritePointEditorFragment extends PointEditorFragment { builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - doSave(favorite, point.getName(), point.getCategory(), point.getDescription(), needDismiss); + doSave(favorite, point.getName(), point.getCategory(), point.getDescription(),point.getAddress(), needDismiss); } }); builder.create().show(); } else { - doSave(favorite, point.getName(), point.getCategory(), point.getDescription(), needDismiss); + doSave(favorite, point.getName(), point.getCategory(), point.getDescription(), point.getAddress(), needDismiss); } saved = true; } } - private void doSave(FavouritePoint favorite, String name, String category, String description, boolean needDismiss) { + private void doSave(FavouritePoint favorite, String name, String category, String description, String address, boolean needDismiss) { FavouritesDbHelper helper = getHelper(); FavoritePointEditor editor = getFavoritePointEditor(); if (editor != null && helper != null) { if (editor.isNew()) { - doAddFavorite(name, category, description); + doAddFavorite(name, category, description,address); } else { - helper.editFavouriteName(favorite, name, category, description); + helper.editFavouriteName(favorite, name, category, description,address); } } MapActivity mapActivity = getMapActivity(); @@ -245,7 +246,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment { } } - private void doAddFavorite(String name, String category, String description) { + private void doAddFavorite(String name, String category, String description, String address) { OsmandApplication app = getMyApplication(); FavouritesDbHelper helper = getHelper(); FavouritePoint favorite = getFavorite(); @@ -253,6 +254,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment { favorite.setName(name); favorite.setCategory(category); favorite.setDescription(description); + favorite.setAddress(address); app.getSettings().LAST_FAV_CATEGORY_ENTERED.set(category); helper.addFavourite(favorite); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java index 091b93f9a0..b29d0e7be8 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java @@ -244,6 +244,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(), getNameTextValue(), getCategoryTextValue()); point.setDescription(getDescriptionTextValue()); + point.setAddress(getAddressTextValue()); point.setColor(color); point.setBackgroundType(backgroundType); point.setIconId(iconId); @@ -259,6 +260,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(), getNameTextValue(), getCategoryTextValue()); point.setDescription(getDescriptionTextValue()); + point.setAddress(getAddressTextValue()); point.setColor(color); point.setBackgroundType(backgroundType); point.setIconId(iconId); @@ -276,13 +278,13 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - doSave(favorite, point.getName(), point.getCategory(), point.getDescription(), + doSave(favorite, point.getName(), point.getCategory(), point.getDescription(), point.getAddress(), point.getColor(), point.getBackgroundType(), point.getIconId(), needDismiss); } }); builder.create().show(); } else { - doSave(favorite, point.getName(), point.getCategory(), point.getDescription(), + doSave(favorite, point.getName(), point.getCategory(), point.getDescription(), point.getAddress(), point.getColor(), point.getBackgroundType(), point.getIconId(), needDismiss); } saved = true; @@ -295,10 +297,11 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { favorite.getName().equals(point.getName()) && favorite.getCategory().equals(point.getCategory()) && favorite.getBackgroundType().equals(point.getBackgroundType()) && - Algorithms.stringsEqual(favorite.getDescription(), point.getDescription()); + Algorithms.stringsEqual(favorite.getDescription(), point.getDescription()) && + Algorithms.stringsEqual(favorite.getAddress(), point.getAddress()); } - private void doSave(FavouritePoint favorite, String name, String category, String description, + private void doSave(FavouritePoint favorite, String name, String category, String description, String address, @ColorInt int color, BackgroundType backgroundType, @DrawableRes int iconId, boolean needDismiss) { FavouritesDbHelper helper = getHelper(); FavoritePointEditor editor = getFavoritePointEditor(); @@ -306,7 +309,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { if (editor.isNew()) { doAddFavorite(name, category, description, color, backgroundType, iconId); } else { - doEditFavorite(favorite, name, category, description, color, backgroundType, iconId, helper); + doEditFavorite(favorite, name, category, description, address, color, backgroundType, iconId, helper); } } MapActivity mapActivity = getMapActivity(); @@ -325,7 +328,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { } } - private void doEditFavorite(FavouritePoint favorite, String name, String category, String description, + private void doEditFavorite(FavouritePoint favorite, String name, String category, String description, String address, @ColorInt int color, BackgroundType backgroundType, @DrawableRes int iconId, FavouritesDbHelper helper) { OsmandApplication app = getMyApplication(); @@ -334,7 +337,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { favorite.setColor(color); favorite.setBackgroundType(backgroundType); favorite.setIconId(iconId); - helper.editFavouriteName(favorite, name, category, description); + helper.editFavouriteName(favorite, name, category, description, address); } } @@ -408,7 +411,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { @Override public String getAddressInitValue() { FavouritePoint favourite = getFavorite(); - return favorite != null ? favorite.getAddress() : ""; + return favourite != null ? favourite.getAddress() : ""; } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java index 44e9e8546e..c24a29ff71 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java @@ -373,6 +373,12 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment { return Algorithms.isEmpty(res) ? null : res; } + public String getAddressTextValue() { + EditText addressEdit = (EditText) view.findViewById(R.id.address_edit); + String res = addressEdit.getText().toString().trim(); + return Algorithms.isEmpty(res) ? null : res; + } + protected Drawable getPaintedIcon(int iconId, int color) { return getPaintedContentIcon(iconId, color); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java index 792aa08e84..4cf98456be 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java @@ -241,9 +241,9 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { addDelDescription.setTextColor(getResources().getColor(activeColorResId)); addAddressBtn.setTextColor(getResources().getColor(activeColorResId)); addAddressBtn.setCompoundDrawablesWithIntrinsicBounds( - app.getUIUtilities().getIcon(R.drawable.ic_action_location_off, activeColorResId),null,null,null); + app.getUIUtilities().getIcon(R.drawable.ic_action_location_16, activeColorResId),null,null,null); addDelDescription.setCompoundDrawablesWithIntrinsicBounds( - app.getUIUtilities().getIcon(R.drawable.ic_action_description, activeColorResId),null,null,null); + app.getUIUtilities().getIcon(R.drawable.ic_action_description_16, activeColorResId),null,null,null); addDelDescription.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -251,7 +251,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { descriptionCaption.setVisibility(View.VISIBLE); addDelDescription.setText(view.getResources().getString(R.string.delete_description)); addDelDescription.setCompoundDrawablesWithIntrinsicBounds( - app.getUIUtilities().getIcon(R.drawable.ic_action_delete_item, + app.getUIUtilities().getIcon(R.drawable.ic_action_trash_basket_16, activeColorResId),null,null,null); View descriptionEdit = view.findViewById(R.id.description_edit); descriptionEdit.requestFocus(); @@ -260,7 +260,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { descriptionCaption.setVisibility(View.GONE); addDelDescription.setText(view.getResources().getString(R.string.add_description)); addDelDescription.setCompoundDrawablesWithIntrinsicBounds( - app.getUIUtilities().getIcon(R.drawable.ic_action_location_off, + app.getUIUtilities().getIcon(R.drawable.ic_action_description_16, activeColorResId),null,null,null); AndroidUtils.hideSoftKeyboard(requireActivity(), descriptionEdit); descriptionEdit.clearFocus(); @@ -275,7 +275,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { addAddressBtn.setText(view.getResources().getString(R.string.delete_address)); View addressEdit = view.findViewById(R.id.address_edit); addressEdit.requestFocus(); - AndroidUtils.softKeyboardDelayed(addressEdit); + AndroidUtils.softKeyboardDelayed(requireActivity(),addressEdit); } else { addressCaption.setVisibility(View.GONE); addAddressBtn.setText(view.getResources().getString(R.string.add_address)); @@ -848,6 +848,12 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { return Algorithms.isEmpty(res) ? null : res; } + String getAddressTextValue() { + EditText addressEdit = view.findViewById(R.id.address_edit); + String res = addressEdit.getText().toString().trim(); + return Algorithms.isEmpty(res) ? null : res; + } + protected Drawable getPaintedIcon(int iconId, int color) { return getPaintedContentIcon(iconId, color); } From c757ef3a0b7a2b134d19761943974282dbaf54fc Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 18 Aug 2020 11:50:44 +0300 Subject: [PATCH 09/14] address display issue fixed --- .../osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java index db68cef5c5..021d8908e1 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java @@ -39,7 +39,7 @@ public class FavoritePointEditor extends PointEditor { } favorite = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), title, lastCategory); favorite.setDescription(""); - favorite.setAddress(address); + favorite.setAddress(address.isEmpty() ? title : address); favorite.setOriginObjectName(originObjectName); FavoritePointEditorFragmentNew.showInstance(mapActivity); } From 1c1a60863ce572244ddc19bdafac13effb54ceaf Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 20 Aug 2020 10:23:35 +0300 Subject: [PATCH 10/14] favorite changes --- .../osmand/aidlapi/favorite/AFavorite.java | 5 +- OsmAnd/build.gradle | 1 + .../res/layout/point_editor_fragment_new.xml | 1164 ++++++++--------- OsmAnd/src/androidhttpweb/ServerActivity.java | 59 + .../net/osmand/aidl/favorite/AFavorite.java | 4 +- .../MapContextMenuFragment.java | 9 +- .../FavouritePointMenuController.java | 10 + .../editors/FavoritePointEditor.java | 2 +- 8 files changed, 659 insertions(+), 595 deletions(-) create mode 100644 OsmAnd/src/androidhttpweb/ServerActivity.java diff --git a/OsmAnd-api/src/net/osmand/aidlapi/favorite/AFavorite.java b/OsmAnd-api/src/net/osmand/aidlapi/favorite/AFavorite.java index ed2dabe064..39daf1d2a2 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/favorite/AFavorite.java +++ b/OsmAnd-api/src/net/osmand/aidlapi/favorite/AFavorite.java @@ -16,12 +16,13 @@ public class AFavorite extends AidlParams { private String color; private boolean visible; - public AFavorite(double lat, double lon, String name, String description, + public AFavorite(double lat, double lon, String name, String description, String address, String category, String color, boolean visible) { this.lat = lat; this.lon = lon; this.name = name; this.description = description; + this.address = address; this.category = category; this.color = color; this.visible = visible; @@ -59,7 +60,7 @@ public class AFavorite extends AidlParams { return description; } - public String getAddress() { return description; } + public String getAddress() { return address; } public String getCategory() { return category; diff --git a/OsmAnd/build.gradle b/OsmAnd/build.gradle index e33b1ca75f..48d2895f25 100644 --- a/OsmAnd/build.gradle +++ b/OsmAnd/build.gradle @@ -542,6 +542,7 @@ dependencies { //implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0' implementation 'com.squareup.picasso:picasso:2.71828' implementation 'me.zhanghai.android.materialprogressbar:library:1.4.2' + implementation 'org.nanohttpd:nanohttpd:2.2.0' // JS core implementation group: 'org.mozilla', name: 'rhino', version: '1.7.9' // size restrictions diff --git a/OsmAnd/res/layout/point_editor_fragment_new.xml b/OsmAnd/res/layout/point_editor_fragment_new.xml index 4dcaa46680..e20eabf662 100644 --- a/OsmAnd/res/layout/point_editor_fragment_new.xml +++ b/OsmAnd/res/layout/point_editor_fragment_new.xml @@ -1,586 +1,586 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:osmand="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/point_edit_layout" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@android:color/transparent" + android:fitsSystemWindows="true"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/src/androidhttpweb/ServerActivity.java b/OsmAnd/src/androidhttpweb/ServerActivity.java new file mode 100644 index 0000000000..30ac61b6b4 --- /dev/null +++ b/OsmAnd/src/androidhttpweb/ServerActivity.java @@ -0,0 +1,59 @@ +package androidhttpweb; + +import android.net.TrafficStats; +import android.os.Bundle; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import net.osmand.plus.R; + +public class ServerActivity extends AppCompatActivity { + private boolean initialized = false; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.server_activity); + findViewById(R.id.Button01).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (!initialized) { + ((TextView) findViewById(R.id.TextView02)).setText("Click second button to deactivate server"); + initServer(); + } + } + }); + findViewById(R.id.Button03).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (initialized) { + ((TextView) findViewById(R.id.TextView02)).setText("Click first button to activate server"); + deInitServer(); + } + } + }); + } + + private void initServer() { + final String ip = "localhost"; + final int port = 24990; + final int THREAD_ID = 10000; + TrafficStats.setThreadStatsTag(THREAD_ID); + TinyWebServer.startServer(ip, port, "/web/public_html"); + TinyWebServer.object = ServerActivity.this; + } + + private void deInitServer() { + TinyWebServer.stopServer(); + initialized = false; + } + + @Override + protected void onDestroy() { + deInitServer(); + super.onDestroy(); + } +} diff --git a/OsmAnd/src/net/osmand/aidl/favorite/AFavorite.java b/OsmAnd/src/net/osmand/aidl/favorite/AFavorite.java index 376a958add..ebd1818c9b 100644 --- a/OsmAnd/src/net/osmand/aidl/favorite/AFavorite.java +++ b/OsmAnd/src/net/osmand/aidl/favorite/AFavorite.java @@ -78,10 +78,10 @@ public class AFavorite implements Parcelable { out.writeDouble(lon); out.writeString(name); out.writeString(description); - out.writeString(address); out.writeString(category); out.writeString(color); out.writeByte((byte) (visible ? 1 : 0)); + out.writeString(address); } private void readFromParcel(Parcel in) { @@ -89,10 +89,10 @@ public class AFavorite implements Parcelable { lon = in.readDouble(); name = in.readString(); description = in.readString(); - address = in.readString(); category = in.readString(); color = in.readString(); visible = in.readByte() != 0; + address = in.readString(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 1fb45a0c88..b29e9e1385 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -1828,14 +1828,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo String groupName = convertDisplayNameToGroupIdName(requireContext(), menu.getTypeStr()); if (menu.getMyApplication() != null){ - FavouritesDbHelper helper = menu.getMyApplication().getFavorites(); - if (helper != null && helper.getGroup(groupName) != null){ - Drawable line2icon = helper.getColoredIconForGroup(groupName); - GravityDrawable line2GravityDrawable = - new GravityDrawable(line2icon); - line2.setCompoundDrawablesWithIntrinsicBounds( - line2GravityDrawable, null, null, null); - } + } line2.setCompoundDrawablePadding(dpToPx(5f)); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java index ca01bf246e..e318bc5aa0 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java @@ -11,6 +11,7 @@ import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; 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.R; @@ -23,6 +24,7 @@ import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragment; import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragmentNew; import net.osmand.plus.transport.TransportStopRoute; import net.osmand.util.OpeningHoursParser; +import net.osmand.view.GravityDrawable; import java.util.List; @@ -158,6 +160,14 @@ 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); + } + return getIcon(R.drawable.ic_action_group_name_16, isLight() ? R.color.icon_color_default_light : R.color.ctx_menu_bottom_view_icon_dark); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java index 021d8908e1..513cd707d5 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java @@ -62,7 +62,7 @@ public class FavoritePointEditor extends PointEditor { favorite = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), title, categoryName); favorite.setDescription(""); - favorite.setAddress(title); + favorite.setAddress(""); favorite.setOriginObjectName(originObjectName); FavoritePointEditorFragmentNew.showAutoFillInstance(mapActivity, autoFill); From 67f19eb9ceed4425a93981c35c2983ccd32ea248 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 20 Aug 2020 10:27:47 +0300 Subject: [PATCH 11/14] favorites changes --- OsmAnd/src/androidhttpweb/ServerActivity.java | 59 ------------------- 1 file changed, 59 deletions(-) delete mode 100644 OsmAnd/src/androidhttpweb/ServerActivity.java diff --git a/OsmAnd/src/androidhttpweb/ServerActivity.java b/OsmAnd/src/androidhttpweb/ServerActivity.java deleted file mode 100644 index 30ac61b6b4..0000000000 --- a/OsmAnd/src/androidhttpweb/ServerActivity.java +++ /dev/null @@ -1,59 +0,0 @@ -package androidhttpweb; - -import android.net.TrafficStats; -import android.os.Bundle; -import android.view.View; -import android.widget.TextView; - -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; - -import net.osmand.plus.R; - -public class ServerActivity extends AppCompatActivity { - private boolean initialized = false; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.server_activity); - findViewById(R.id.Button01).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (!initialized) { - ((TextView) findViewById(R.id.TextView02)).setText("Click second button to deactivate server"); - initServer(); - } - } - }); - findViewById(R.id.Button03).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (initialized) { - ((TextView) findViewById(R.id.TextView02)).setText("Click first button to activate server"); - deInitServer(); - } - } - }); - } - - private void initServer() { - final String ip = "localhost"; - final int port = 24990; - final int THREAD_ID = 10000; - TrafficStats.setThreadStatsTag(THREAD_ID); - TinyWebServer.startServer(ip, port, "/web/public_html"); - TinyWebServer.object = ServerActivity.this; - } - - private void deInitServer() { - TinyWebServer.stopServer(); - initialized = false; - } - - @Override - protected void onDestroy() { - deInitServer(); - super.onDestroy(); - } -} From 2f36b59ae78ba82dc65ca6436fc8cc030e11c496 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 20 Aug 2020 12:55:29 +0300 Subject: [PATCH 12/14] icons fixed and refactored --- .../net/osmand/plus/FavouritesDbHelper.java | 9 ++-- .../MapContextMenuFragment.java | 51 +++++++++---------- .../FavouritePointMenuController.java | 22 +++++--- .../other/MultiSelectionArrayAdapter.java | 27 +++------- 4 files changed, 50 insertions(+), 59 deletions(-) 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 Date: Thu, 20 Aug 2020 12:58:01 +0300 Subject: [PATCH 13/14] unused import removed --- OsmAnd/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/OsmAnd/build.gradle b/OsmAnd/build.gradle index 48d2895f25..e33b1ca75f 100644 --- a/OsmAnd/build.gradle +++ b/OsmAnd/build.gradle @@ -542,7 +542,6 @@ dependencies { //implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0' implementation 'com.squareup.picasso:picasso:2.71828' implementation 'me.zhanghai.android.materialprogressbar:library:1.4.2' - implementation 'org.nanohttpd:nanohttpd:2.2.0' // JS core implementation group: 'org.mozilla', name: 'rhino', version: '1.7.9' // size restrictions From b2b2064993e4ee3035237ea33c4ecfc9f7179ac5 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 20 Aug 2020 17:29:38 +0300 Subject: [PATCH 14/14] Minor fixes --- .../net/osmand/plus/FavouritesDbHelper.java | 6 +- .../MapContextMenuFragment.java | 13 +-- .../FavouritePointMenuController.java | 26 +++-- .../other/MultiSelectionArrayAdapter.java | 13 +-- .../src/net/osmand/view/GravityDrawable.java | 103 +++++++++++------- 5 files changed, 82 insertions(+), 79 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index 1461a3983b..ad0eb9d359 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -130,10 +130,8 @@ public class FavouritesDbHelper { } public Drawable getColoredIconForGroup(String groupName) { - FavouritesDbHelper.FavoriteGroup favoriteGroup = getGroup( - FavouritesDbHelper.FavoriteGroup. - convertDisplayNameToGroupIdName( - context, groupName)); + String groupIdName = FavoriteGroup.convertDisplayNameToGroupIdName(context, groupName); + FavoriteGroup favoriteGroup = getGroup(groupIdName); if (favoriteGroup != null) { int color = favoriteGroup.getColor() == 0 ? context.getResources().getColor(R.color.color_favorite) : favoriteGroup.getColor(); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 45b6573c8c..5721885ab6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -83,7 +83,6 @@ import net.osmand.plus.views.layers.TransportStopsLayer; import net.osmand.plus.widgets.style.CustomTypefaceSpan; import net.osmand.router.TransportRouteResult; import net.osmand.util.Algorithms; -import net.osmand.view.GravityDrawable; import java.util.ArrayList; import java.util.List; @@ -1817,16 +1816,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo if (!Algorithms.isEmpty(typeStr)) { line2Str.append(typeStr); Drawable icon = menu.getTypeIcon(); - 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)); - } + AndroidUtils.setCompoundDrawablesWithIntrinsicBounds( + line2, icon, null, null, null); line2.setCompoundDrawablePadding(dpToPx(5f)); } if (!Algorithms.isEmpty(streetStr) && !menu.displayStreetNameInTitle()) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java index a62535f210..65a7fa469e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java @@ -161,20 +161,22 @@ public class FavouritePointMenuController extends MenuController { @Override public Drawable getSecondLineTypeIcon() { - 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; - } + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + OsmandApplication app = mapActivity.getMyApplication(); + FavouritesDbHelper helper = app.getFavorites(); + String group = fav.getCategory(); + if (helper.getGroup(group) != null) { + Drawable line2icon = helper.getColoredIconForGroup(group); + GravityDrawable gravityIcon = new GravityDrawable(line2icon); + gravityIcon.setBoundsFrom(line2icon); + return gravityIcon; + } else { + int colorId = isLight() ? R.color.icon_color_default_light : R.color.ctx_menu_bottom_view_icon_dark; + return getIcon(R.drawable.ic_action_group_name_16, colorId); } } - return getIcon(R.drawable.ic_action_group_name_16, isLight() ? R.color.icon_color_default_light : R.color.ctx_menu_bottom_view_icon_dark); + return null; } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java index cdc766cab7..3df3d6a5a0 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java @@ -15,7 +15,6 @@ import net.osmand.AndroidUtils; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.util.Algorithms; -import net.osmand.view.GravityDrawable; import java.util.List; @@ -94,16 +93,8 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter