Merge pull request #8895 from osmandapp/Fix_my_places_edit_fav

Fix my places and edit favorites
This commit is contained in:
max-klaus 2020-05-06 18:48:43 +03:00 committed by GitHub
commit 778f4aaf3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 199 additions and 168 deletions

View file

@ -160,7 +160,7 @@ public class GPXUtilities {
if (!Algorithms.isEmpty(colorString)) {
if (colorString.charAt(0) == '#') {
long color = Long.parseLong(colorString.substring(1), 16);
if (colorString.length() == 7) {
if (colorString.length() <= 7) {
color |= 0x00000000ff000000;
} else if (colorString.length() != 9) {
return defColor;

View file

@ -1,9 +1,9 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/icon_color_active_light" />
<corners android:radius="18dp" />
<corners android:radius="@dimen/context_menu_progress_padding_left" />
<stroke
android:width="1dp"
android:color="@color/icon_color_active_light"
android:radius="18dp" />
android:radius="@dimen/context_menu_progress_padding_left" />
</shape>

View file

@ -4,7 +4,7 @@
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="36dp"
android:layout_height="@dimen/dialog_button_height"
android:layout_weight="1">
<LinearLayout

View file

@ -5,9 +5,9 @@
android:layout_height="wrap_content"
android:paddingStart="0dp"
android:paddingLeft="0dp"
android:paddingEnd="9dp"
android:paddingRight="9dp"
android:paddingBottom="4dp">
android:paddingEnd="@dimen/favorites_select_icon_button_right_padding"
android:paddingRight="@dimen/favorites_select_icon_button_right_padding"
android:paddingBottom="@dimen/context_menu_buttons_padding_bottom">
<FrameLayout
android:layout_width="wrap_content"
@ -15,22 +15,23 @@
<ImageView
android:id="@+id/outline"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_width="@dimen/context_menu_buttons_bottom_height"
android:layout_height="@dimen/context_menu_buttons_bottom_height"
android:visibility="invisible"
app:srcCompat="@drawable/bg_point_circle_contour" />
<ImageView
android:id="@+id/background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="@dimen/favorites_icon_size"
android:layout_height="@dimen/favorites_icon_size"
android:padding="@dimen/favorites_icon_padding"
android:layout_gravity="center"
android:background="@drawable/bg_point_circle" />
app:srcCompat="@drawable/bg_point_circle" />
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center"
android:clickable="false"
android:visibility="gone"

View file

@ -19,25 +19,26 @@
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="fill_parent"
android:layout_height="@dimen/dashboard_map_toolbar"
android:layout_height="@dimen/toolbar_height"
android:background="?attr/card_and_list_background_basic"
android:minHeight="@dimen/dashboard_map_toolbar"
android:paddingRight="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:minHeight="@dimen/toolbar_height"
osmand:subtitleTextColor="?android:textColorPrimary"
osmand:theme="@style/ThemeOverlay.AppCompat.ActionBar"
osmand:titleTextColor="?android:textColorPrimary">
<ImageView
android:id="@+id/toolbar_action"
android:layout_width="@dimen/list_item_height"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="match_parent"
android:layout_gravity="end"
android:contentDescription="@string/replace_all"
android:scaleType="center"
android:src="@drawable/ic_action_replace"
android:layout_marginRight="@dimen/content_padding_half"
android:layout_marginStart="@dimen/content_padding_half"
android:layout_marginLeft="@dimen/content_padding_half"
android:layout_marginEnd="@dimen/content_padding_half" />
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding" />
</androidx.appcompat.widget.Toolbar>
@ -57,8 +58,8 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding">
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding">
<LinearLayout
@ -83,15 +84,16 @@
android:layout_height="wrap_content"
android:drawableEnd="@drawable/btn_circle_transparent_full"
android:drawableRight="@drawable/btn_circle_transparent_full"
android:drawablePadding="60dp"
android:drawablePadding="@dimen/favorites_list_item_height"
android:inputType="textMultiLine"
android:maxLines="4"
android:minHeight="60dp"
android:paddingStart="12dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:minHeight="@dimen/favorites_list_item_height"
android:paddingStart="@dimen/content_padding_small"
android:paddingLeft="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding_small"
android:paddingEnd="@dimen/content_padding_small"
android:scrollHorizontally="false"
android:textSize="16sp"
android:textSize="@dimen/default_list_text_size"
tools:text="@string/lorem_ipsum" />
</com.google.android.material.textfield.TextInputLayout>
@ -100,11 +102,11 @@
<ImageView
android:id="@+id/name_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="@dimen/favorites_icon_size"
android:layout_height="@dimen/favorites_icon_size"
android:padding="@dimen/favorites_icon_padding"
android:layout_gravity="end"
android:layout_margin="12dp"
android:scaleType="center"
android:layout_margin="@dimen/content_padding_small"
android:contentDescription="@string/icon"
android:src="@drawable/ic_action_home_dark" />
@ -114,7 +116,7 @@
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/card_padding"
android:layout_marginTop="@dimen/content_padding_small"
android:gravity="center_vertical"
android:orientation="horizontal">
@ -123,8 +125,8 @@
android:id="@+id/description_caption"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1"
android:hint="@string/shared_string_description"
app:boxBackgroundColor="#4DCCCCCC">
@ -135,11 +137,12 @@
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:maxLines="4"
android:minHeight="60dp"
android:paddingStart="12dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:textSize="16sp"
android:minHeight="@dimen/favorites_list_item_height"
android:paddingStart="@dimen/content_padding_small"
android:paddingLeft="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding_small"
android:paddingEnd="@dimen/content_padding_small"
android:textSize="@dimen/default_list_text_size"
tools:text="@string/lorem_ipsum" />
</com.google.android.material.textfield.TextInputLayout>
@ -148,7 +151,7 @@
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/description_button"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_height="@dimen/context_menu_buttons_bottom_height"
android:layout_marginStart="@dimen/content_padding_half"
android:layout_marginLeft="@dimen/content_padding_half"
android:paddingLeft="@dimen/content_padding_half"
@ -171,7 +174,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:minHeight="@dimen/toolbar_height"
android:orientation="vertical">
<LinearLayout
@ -185,9 +188,9 @@
android:layout_weight="1"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="14dp"
android:paddingTop="@dimen/context_menu_first_line_top_margin"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="14dp"
android:paddingBottom="@dimen/context_menu_first_line_top_margin"
android:text="@string/select_group"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
@ -217,15 +220,14 @@
<ImageView
android:id="@+id/group_list_button_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center_vertical"
android:paddingStart="@dimen/content_padding_small"
android:paddingLeft="@dimen/content_padding_small"
android:paddingEnd="@dimen/route_info_buttons_padding_top_bottom"
android:paddingRight="@dimen/route_info_buttons_padding_top_bottom"
android:layout_marginStart="@dimen/content_padding_small"
android:layout_marginLeft="@dimen/content_padding_small"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:src="@drawable/ic_action_folder"
tools:src="@drawable/ic_action_group_select_all"
android:contentDescription="@string/shared_string_list" />
</LinearLayout>
@ -235,8 +237,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="6dp"
android:paddingBottom="@dimen/content_padding_half">
android:paddingTop="@dimen/context_menu_padding_margin_tiny"
android:paddingBottom="@dimen/content_padding">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/group_recycler_view"
@ -259,8 +261,6 @@
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="@dimen/content_padding_half"
android:layout_marginBottom="@dimen/content_padding_half"
android:background="?attr/dashboard_divider" />
<net.osmand.plus.widgets.TextViewEx
@ -268,9 +268,9 @@
android:layout_height="wrap_content"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_half"
android:paddingTop="@dimen/context_menu_first_line_top_margin"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="14dp"
android:paddingBottom="@dimen/context_menu_first_line_top_margin"
android:text="@string/select_icon_profile_dialog_title"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
@ -295,15 +295,14 @@
android:id="@+id/select_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginLeft="12dp"
android:layout_marginTop="6dp" />
android:layout_marginStart="@dimen/content_padding_small"
android:layout_marginLeft="@dimen/content_padding_small"
android:layout_marginTop="@dimen/context_menu_padding_margin_tiny"
android:layout_marginBottom="@dimen/content_padding_half" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="@dimen/content_padding_half"
android:layout_marginBottom="@dimen/content_padding_half"
android:background="?attr/dashboard_divider" />
<LinearLayout
@ -317,9 +316,9 @@
android:layout_weight="1"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_half"
android:paddingTop="@dimen/context_menu_first_line_top_margin"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="14dp"
android:paddingBottom="@dimen/context_menu_first_line_top_margin"
android:text="@string/select_color"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
@ -332,9 +331,9 @@
android:gravity="end"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_half"
android:paddingTop="@dimen/context_menu_first_line_top_margin"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="14dp"
android:paddingBottom="@dimen/context_menu_first_line_top_margin"
android:text="@string/select_color"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
@ -345,15 +344,13 @@
android:id="@+id/select_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginLeft="12dp"
android:layout_marginTop="6dp" />
android:layout_marginStart="@dimen/content_padding_small"
android:layout_marginLeft="@dimen/content_padding_small"
android:layout_marginTop="@dimen/context_menu_padding_margin_tiny"
android:layout_marginBottom="@dimen/content_padding_half" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="@dimen/content_padding_half"
android:layout_marginBottom="@dimen/content_padding_half"
android:background="?attr/dashboard_divider" />
<LinearLayout
@ -367,9 +364,9 @@
android:layout_weight="1"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_half"
android:paddingTop="@dimen/context_menu_first_line_top_margin"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="14dp"
android:paddingBottom="@dimen/context_menu_first_line_top_margin"
android:text="@string/select_shape"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
@ -382,9 +379,9 @@
android:gravity="end"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_half"
android:paddingTop="@dimen/context_menu_first_line_top_margin"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="14dp"
android:paddingBottom="@dimen/context_menu_first_line_top_margin"
android:text="@string/select_shape"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
@ -393,18 +390,17 @@
<net.osmand.plus.widgets.FlowLayout
android:id="@+id/select_shape"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="start"
android:layout_marginStart="12dp"
android:layout_marginLeft="12dp"
android:layout_marginTop="6dp" />
android:layout_marginStart="@dimen/content_padding_small"
android:layout_marginLeft="@dimen/content_padding_small"
android:layout_marginTop="@dimen/context_menu_padding_margin_tiny"
android:layout_marginBottom="@dimen/content_padding_half" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="@dimen/content_padding_half"
android:background="?attr/dashboard_divider" />
<LinearLayout
@ -416,22 +412,24 @@
<ImageView
android:id="@+id/replace_action_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:contentDescription="@string/update_existing"
android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="21dp"
android:paddingEnd="32dp"
android:paddingRight="32dp"
android:paddingBottom="21dp"
tools:src="@drawable/ic_action_replace" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="11dp"
android:orientation="vertical">
android:layout_marginStart="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding"
android:orientation="vertical"
android:paddingTop="@dimen/content_padding_half"
android:paddingBottom="@dimen/content_padding_half">
<TextView
android:id="@+id/replace_action_title"
@ -466,21 +464,24 @@
<ImageView
android:id="@+id/delete_action_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_gravity="center_vertical"
android:contentDescription="@string/delete_point"
android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="12dp"
android:paddingEnd="32dp"
android:paddingRight="32dp"
android:paddingBottom="12dp"
android:src="@drawable/ic_action_delete_dark" />
<TextView
android:id="@+id/delete_action_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginTop="@dimen/content_padding_small"
android:layout_marginBottom="@dimen/content_padding_small"
android:maxLines="1"
android:text="@string/shared_string_delete"
android:textAppearance="@style/TextAppearance.ListItemCategoryTitle"

View file

@ -2,8 +2,8 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="142dp"
android:layout_height="76dp"
android:layout_width="@dimen/favorites_select_group_button_width"
android:layout_height="@dimen/favorites_select_group_button_height"
android:layout_marginLeft="@dimen/content_padding_half"
android:layout_marginStart="@dimen/content_padding_half">
@ -19,22 +19,21 @@
<ImageView
android:id="@+id/groupIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingStart="6dp"
android:paddingEnd="6dp"
android:paddingTop="6dp"
android:src="@drawable/ic_action_folder"
tools:src="@drawable/ic_action_folder" />
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_marginLeft="@dimen/context_menu_padding_margin_tiny"
android:layout_marginRight="@dimen/context_menu_padding_margin_tiny"
android:layout_marginStart="@dimen/context_menu_padding_margin_tiny"
android:layout_marginEnd="@dimen/context_menu_padding_margin_tiny"
android:layout_marginTop="@dimen/context_menu_padding_margin_tiny"
android:src="@drawable/ic_action_folder" />
<TextView
android:id="@+id/counter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingTop="6dp"
android:paddingTop="@dimen/context_menu_padding_margin_tiny"
tools:text="255" />
</LinearLayout>
@ -46,7 +45,7 @@
android:paddingStart="@dimen/content_padding_half"
android:paddingRight="@dimen/content_padding_half"
android:paddingEnd="@dimen/content_padding_half"
android:paddingTop="33dp"
android:paddingTop="@dimen/context_menu_transport_grid_item_width"
tools:text="@string/favorite" />
</FrameLayout>

View file

@ -93,15 +93,23 @@
<dimen name="fab_margin_bottom_big">108dp</dimen>
<!-- General -->
<dimen name="dialog_button_height">54dp</dimen>
<dimen name="dialog_button_ex_height">90dp</dimen>
<dimen name="list_item_height">65dp</dimen>
<dimen name="list_header_height">60dp</dimen>
<dimen name="favorites_icon_size">60dp</dimen>
<dimen name="dashboard_map_top_padding">480dp</dimen>
<dimen name="dashboard_land_width">480dp</dimen>
<dimen name="dashboard_map_toolbar">84dp</dimen>
<dimen name="favorites_icon_top_margin">13dp</dimen>
<!-- TextSizes -->
<dimen name="favorites_icon_size">60dp</dimen>
<dimen name="favorites_icon_padding">3dp</dimen>
<dimen name="favorites_list_item_height">90dp</dimen>
<dimen name="favorites_select_group_button_height">114dp</dimen>
<dimen name="favorites_select_group_button_width">213dp</dimen>
<dimen name="favorites_select_icon_button_right_padding">14dp</dimen>
<!-- TextSizes -->
<dimen name="default_list_text_size_large">22sp</dimen>
<dimen name="default_list_text_size">18sp</dimen>
<dimen name="default_desc_text_size">16sp</dimen>

View file

@ -73,9 +73,14 @@
<dimen name="favorites_icon_right_margin">24dp</dimen>
<dimen name="favorites_icon_size">40dp</dimen>
<dimen name="favorites_icon_padding">2dp</dimen>
<dimen name="favorites_list_item_height">60dp</dimen>
<dimen name="local_index_check_right_margin">10dp</dimen>
<dimen name="favorites_select_group_button_height">76dp</dimen>
<dimen name="favorites_select_group_button_width">142dp</dimen>
<dimen name="favorites_icon_top_margin">13dp</dimen>
<dimen name="favorites_select_icon_button_right_padding">9dp</dimen>
<dimen name="local_index_check_right_margin">10dp</dimen>
<dimen name="dialog_elements_vertical_margin">16dp</dimen>
<dimen name="dialog_content_margin">24dp</dimen>
<dimen name="dialog_content_bottom_margin">16dp</dimen>

View file

@ -77,11 +77,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
}
public int getColor() {
if ((color & 0xFF000000) != 0) {
return color;
} else {
return color | 0xFF000000;
}
}
public String getAddress() {

View file

@ -102,11 +102,7 @@ public class FavouritesDbHelper {
}
public int getColor() {
if ((color & 0xFF000000) != 0) {
return color;
} else {
return color | 0xFF000000;
}
}
public boolean isVisible() {
@ -132,6 +128,22 @@ public class FavouritesDbHelper {
}
}
public int getColorWithCategory(FavouritePoint point, int defaultColor) {
int color = 0;
if (point.getColor() != 0) {
color = point.getColor();
} else {
FavoriteGroup favoriteGroup = getGroup(point);
if (favoriteGroup != null) {
color = favoriteGroup.getColor();
}
if (color == 0) {
color = defaultColor;
}
}
return color;
}
public void loadFavorites() {
flatGroups.clear();
favoriteGroups.clear();

View file

@ -232,7 +232,8 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
}
((TextView) row.findViewById(R.id.group_name)).setText(favorite.getCategory());
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, favorite.getColor(), false, favorite));
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, app.getFavorites().getColorWithCategory(favorite,
app.getResources().getColor(R.color.color_favorite)), false, favorite));
app.getUIUtilities().updateLocationView(cache, direction, distanceText,
favorite.getLatitude(), favorite.getLongitude());

View file

@ -462,7 +462,9 @@ public class FavoritesSearchFragment extends DialogFragment {
TextView title = (TextView) view.findViewById(R.id.title);
TextView subtitle = (TextView) view.findViewById(R.id.subtitle);
imageView.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, point.getColor(), false, point));
imageView.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity,
helper.getColorWithCategory(point, getResources().getColor(R.color.color_favorite)),
false, point));
title.setText(point.getDisplayName(app));
int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(),

View file

@ -3,7 +3,6 @@ package net.osmand.plus.activities;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
@ -840,7 +839,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
int enabledColor = light ? R.color.text_color_primary_light : R.color.text_color_primary_dark;
int disabledColor = light ? R.color.text_color_secondary_light : R.color.text_color_secondary_dark;
row.findViewById(R.id.group_divider).setVisibility(groupPosition == 0 ? View.GONE : View.VISIBLE);
int color = model.getColor() == 0 || model.getColor() == Color.BLACK ? getResources().getColor(R.color.color_favorite) : model.getColor();
int color = model.getColor() == 0 ? getResources().getColor(R.color.color_favorite) : model.getColor();
if (!model.isPersonal()) {
setCategoryIcon(app, app.getUIUtilities().getPaintedIcon(
R.drawable.ic_action_folder, visible ? color : getResources().getColor(disabledColor)),
@ -960,15 +959,15 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
if (model.isAddressSpecified()) {
distanceText.setText(String.format(getString(R.string.ltr_or_rtl_combine_via_comma), distance.trim(), model.getAddress()));
}
int color = visible
? app.getFavorites().getColorWithCategory(model, getResources().getColor(R.color.color_favorite))
: ContextCompat.getColor(app, disabledIconColor);
int iconSize = (int) getResources().getDimension(R.dimen.favorites_icon_size);
if(model.getBackgroundType().equals(FavouritePoint.BackgroundType.CIRCLE)){
int color = visible ? model.getColor() : getResources().getColor(disabledIconColor);
int col = color == 0 || color == Color.BLACK ? getResources().getColor(R.color.color_favorite) : color;
icon.setImageDrawable(UiUtilities.createTintedDrawable(getActivity(),model.getIconId(),col));
icon.setImageDrawable(UiUtilities.createTintedDrawable(getActivity(), model.getIconId(), color));
iconSize = (int) getResources().getDimension(R.dimen.standard_icon_size);
}else {
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(),
visible ? model.getColor() : getResources().getColor(disabledIconColor), false, model));
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(), color, false, model));
}
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(iconSize, iconSize, CENTER);
icon.setLayoutParams(lp);

View file

@ -5,7 +5,6 @@ import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PorterDuff;
@ -58,7 +57,7 @@ public class FavoriteImageDrawable extends Drawable {
favIcon = res.getDrawable(R.drawable.mm_special_star);
uiIconId = R.drawable.mx_special_star;
}
int col = color == 0 || color == Color.BLACK ? res.getColor(R.color.color_favorite) : color;
int col = color == 0 ? res.getColor(R.color.color_favorite) : color;
uiListIcon = uiUtilities.getIcon(uiIconId, R.color.color_white);
int uiBackgroundIconId = point != null ? point.getBackgroundType().getIconId() : R.drawable.bg_point_circle;
uiBackgroundIcon = uiUtilities.getPaintedIcon(uiBackgroundIconId, col);

View file

@ -773,7 +773,9 @@ public class WaypointHelper {
}
} else if (type == FAVORITES ) {
return FavoriteImageDrawable.getOrCreate(uiCtx, point.getColor(), false, (FavouritePoint) point);
return FavoriteImageDrawable.getOrCreate(uiCtx,
app.getFavorites().getColorWithCategory((FavouritePoint) point,
app.getResources().getColor(R.color.color_favorite)), false, (FavouritePoint) point);
} else if (type == WAYPOINTS) {
if (point instanceof WptLocationPoint) {
return FavoriteImageDrawable.getOrCreate(uiCtx, point.getColor(), false, ((WptLocationPoint) point).getPt());

View file

@ -1,7 +1,6 @@
package net.osmand.plus.mapcontextmenu.builders;
import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.widget.LinearLayout;
@ -93,7 +92,7 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
FavoriteGroup favoriteGroup = app.getFavorites().getGroup(fav);
List<FavouritePoint> groupFavourites = favoriteGroup.getPoints();
if (groupFavourites.size() > 0) {
int color = favoriteGroup.getColor() == 0 || favoriteGroup.getColor() == Color.BLACK ? view.getResources().getColor(R.color.color_favorite) : favoriteGroup.getColor();
int color = favoriteGroup.getColor() == 0 ? view.getResources().getColor(R.color.color_favorite) : favoriteGroup.getColor();
int disabledColor = light ? R.color.text_color_secondary_light : R.color.text_color_secondary_dark;
color = favoriteGroup.isVisible() ? (color | 0xff000000) : view.getResources().getColor(disabledColor);
String name = view.getContext().getString(R.string.context_menu_points_of_group);

View file

@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import net.osmand.data.Amenity;
@ -125,8 +126,9 @@ public class FavouritePointMenuController extends MenuController {
public Drawable getRightIcon() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
return FavoriteImageDrawable.getOrCreate(mapActivity.getMyApplication(), fav.getColor(),
false, fav);
return FavoriteImageDrawable.getOrCreate(mapActivity.getMyApplication(),
mapActivity.getMyApplication().getFavorites().getColorWithCategory(fav,
ContextCompat.getColor(mapActivity, R.color.color_favorite)), false, fav);
} else {
return null;
}

View file

@ -425,7 +425,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
FavouritePoint favorite = getFavorite();
int color = favorite != null ? getColor() : 0;
FavoriteGroup group = getGroup();
if (group != null && color == 0) {
if (group != null && (color == 0)) {
color = group.getColor();
}
if (color == 0) {
@ -457,17 +457,19 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
OsmandApplication app = getMyApplication();
if (editor.isNew()) {
FavoriteGroup lastUsedGroup = helper.getGroup(getLastUsedGroup());
if (lastUsedGroup != null) {
if (lastUsedGroup != null && lastUsedGroup.isVisible()) {
categories.add(lastUsedGroup.getDisplayName(app));
}
for (FavouritesDbHelper.FavoriteGroup fg : getHelper().getFavoriteGroups()) {
if (lastUsedGroup != null && !fg.equals(lastUsedGroup)) {
if (lastUsedGroup != null && !fg.equals(lastUsedGroup) && fg.isVisible()) {
categories.add(fg.getDisplayName(app));
}
}
} else {
for (FavoriteGroup fg : helper.getFavoriteGroups()) {
categories.add(fg.getDisplayName(app));
if (fg.isVisible()) {
categories.add(fg.getDisplayName(app));
}
}
}
}

View file

@ -327,8 +327,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
nightMode ? R.color.stroked_buttons_and_links_outline_dark
: R.color.stroked_buttons_and_links_outline_light)));
ImageView backgroundCircle = colorItemView.findViewById(R.id.background);
AndroidUtils.setBackground(backgroundCircle,
UiUtilities.tintDrawable(ContextCompat.getDrawable(app, R.drawable.bg_point_circle), color));
backgroundCircle.setImageDrawable(UiUtilities.tintDrawable(ContextCompat.getDrawable(app, R.drawable.bg_point_circle), color));
backgroundCircle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -400,8 +399,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
newShape.findViewById(R.id.outline).setVisibility(View.VISIBLE);
((TextView) rootView.findViewById(R.id.shape_name)).setText(backgroundType.getNameId());
ImageView background = newShape.findViewById(R.id.background);
AndroidUtils.setBackground(background,
UiUtilities.tintDrawable(ContextCompat.getDrawable(app, backgroundType.getIconId()),
background.setImageDrawable(UiUtilities.tintDrawable(ContextCompat.getDrawable(app, backgroundType.getIconId()),
selectedColor));
selectedShape = backgroundType;
setBackgroundType(backgroundType);
@ -409,8 +407,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
}
private void setShapeSelectorBackground(BackgroundType backgroundType, ImageView background) {
AndroidUtils.setBackground(background,
UiUtilities.tintDrawable(ContextCompat.getDrawable(app, backgroundType.getIconId()),
background.setImageDrawable(UiUtilities.tintDrawable(ContextCompat.getDrawable(app, backgroundType.getIconId()),
ContextCompat.getColor(app,
nightMode ? R.color.inactive_buttons_and_links_bg_dark
: R.color.inactive_buttons_and_links_bg_light)));
@ -472,7 +469,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
iconCategoriesRecyclerView.setAdapter(iconCategoriesAdapter);
iconCategoriesRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
iconCategoriesAdapter.notifyDataSetChanged();
iconCategoriesRecyclerView.scrollToPosition(iconCategoriesAdapter.getItemPosition(selectedIconCategory));
iconCategoriesRecyclerView.smoothScrollToPosition(iconCategoriesAdapter.getItemPosition(selectedIconCategory));
for (String name : iconNameList) {
selectIcon.addView(createIconItemView(name, selectIcon), new FlowLayout.LayoutParams(0, 0));
}
@ -521,7 +518,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
ContextCompat.getColor(app, R.color.color_white)));
icon.findViewById(R.id.outline).setVisibility(View.VISIBLE);
ImageView backgroundCircle = icon.findViewById(R.id.background);
AndroidUtils.setBackground(backgroundCircle,
backgroundCircle.setImageDrawable(
UiUtilities.tintDrawable(ContextCompat.getDrawable(view.getContext(), R.drawable.bg_point_circle), selectedColor));
}
selectedIcon = iconRes;
@ -530,8 +527,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
}
private void setIconSelectorBackground(ImageView backgroundCircle) {
AndroidUtils.setBackground(backgroundCircle,
UiUtilities.tintDrawable(ContextCompat.getDrawable(app, R.drawable.bg_point_circle),
backgroundCircle.setImageDrawable(UiUtilities.tintDrawable(ContextCompat.getDrawable(app, R.drawable.bg_point_circle),
ContextCompat.getColor(app, nightMode
? R.color.inactive_buttons_and_links_bg_dark
: R.color.inactive_buttons_and_links_bg_light)));

View file

@ -2,6 +2,7 @@ package net.osmand.plus.mapcontextmenu.editors;
import android.app.Activity;
import android.app.Dialog;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@ -88,8 +89,10 @@ public class SelectCategoryDialogFragment extends DialogFragment {
} else {
List<FavouritesDbHelper.FavoriteGroup> gs = helper.getFavoriteGroups();
for (final FavouritesDbHelper.FavoriteGroup category : gs) {
ll.addView(createCategoryItem(activity, nightMode, category.getDisplayName(getContext()),
category.getColor()));
if (category.isVisible()) {
ll.addView(createCategoryItem(activity, nightMode, category.getDisplayName(getContext()),
category.getColor()));
}
}
}
View itemView = UiUtilities.getInflater(activity, nightMode).inflate(R.layout.favorite_category_dialog_item, null);

View file

@ -6,6 +6,7 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import net.osmand.data.FavouritePoint;
@ -46,7 +47,9 @@ public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
favouritesViewHolder.title.setText(favouritePoint.getDisplayName(app));
favouritesViewHolder.description.setText(favouritePoint.getCategoryDisplayName(app));
favouritesViewHolder.favouriteImage.setImageDrawable(
FavoriteImageDrawable.getOrCreate(app, favouritePoint.getColor(), false, favouritePoint));
FavoriteImageDrawable.getOrCreate(app,
app.getFavorites().getColorWithCategory(favouritePoint,
ContextCompat.getColor(app, R.color.color_favorite)), false, favouritePoint));
app.getUIUtilities().updateLocationView(cache, favouritesViewHolder.arrowImage, favouritesViewHolder.distance,
favouritePoint.getLatitude(), favouritePoint.getLongitude());
}

View file

@ -1,8 +1,8 @@
package net.osmand.plus.mapmarkers.adapters;
import android.content.Context;
import android.graphics.Color;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
@ -28,7 +28,7 @@ public class FavouritesGroupsAdapter extends GroupsAdapter {
} else if (holder instanceof MapMarkersGroupViewHolder) {
FavoriteGroup favoriteGroup = getItem(position);
MapMarkersGroupViewHolder markersGroupViewHolder = (MapMarkersGroupViewHolder) holder;
int color = favoriteGroup.getColor() == 0 || favoriteGroup.getColor() == Color.BLACK ? app.getResources().getColor(R.color.color_favorite) : favoriteGroup.getColor();
int color = favoriteGroup.getColor() == 0 ? ContextCompat.getColor(app, R.color.color_favorite) : favoriteGroup.getColor();
markersGroupViewHolder.icon.setImageDrawable(iconsCache.getPaintedIcon(R.drawable.ic_action_folder, color | 0xff000000));
markersGroupViewHolder.name.setText(favoriteGroup.getName().length() == 0 ? app.getString(R.string.shared_string_favorites) : favoriteGroup.getName());
markersGroupViewHolder.numberCount.setText(String.valueOf(favoriteGroup.getPoints().size()));

View file

@ -3,7 +3,6 @@ package net.osmand.plus.routepreparationmenu;
import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.SpannableString;
@ -656,8 +655,7 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
} else {
favoriteViewHolder.description.setText(point.getCategory());
}
int pointColor = point.getColor();
int color = pointColor == 0 || pointColor == Color.BLACK ? ContextCompat.getColor(app, R.color.color_favorite) : pointColor;
int color = app.getFavorites().getColorWithCategory(point, ContextCompat.getColor(app, R.color.color_favorite));
favoriteViewHolder.icon.setImageDrawable(app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_fav_dark, color));
}
favoriteViewHolder.description.setVisibility(View.VISIBLE);

View file

@ -1,10 +1,11 @@
package net.osmand.plus.search.listitems;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.text.Spannable;
import androidx.core.content.ContextCompat;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.Amenity;
import net.osmand.data.City;
@ -374,10 +375,11 @@ public class QuickSearchListItem {
return getIcon(app, R.drawable.ic_action_world_globe);
case FAVORITE:
FavouritePoint fav = (FavouritePoint) searchResult.object;
return FavoriteImageDrawable.getOrCreate(app, fav.getColor(), false, fav);
return FavoriteImageDrawable.getOrCreate(app,
app.getFavorites().getColorWithCategory(fav, app.getResources().getColor(R.color.color_favorite)), false, fav);
case FAVORITE_GROUP:
FavoriteGroup group = (FavoriteGroup) searchResult.object;
int color = group.getColor() == 0 || group.getColor() == Color.BLACK ? app.getResources().getColor(R.color.color_favorite) : group.getColor();
int color = group.getColor() == 0 ? ContextCompat.getColor(app, R.color.color_favorite) : group.getColor();
return app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_fav_dark, color | 0xff000000);
case REGION:
return getIcon(app, R.drawable.ic_world_globe_dark);

View file

@ -147,7 +147,8 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
if (marker != null && marker.history) {
color = grayColor;
} else {
color = o.getColor() == 0 || o.getColor() == Color.BLACK ? defaultColor : o.getColor();
color = favorites.getColorWithCategory(o,defaultColor);
// color = o.getColor() == 0 ? defaultColor : o.getColor();
}
paintIcon.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
Bitmap pointSmallTop = getBitmap(o, "top");
@ -194,10 +195,10 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
FavoriteImageDrawable fid;
boolean history = false;
if (marker != null) {
fid = FavoriteImageDrawable.getOrCreateSyncedIcon(view.getContext(), o.getColor(), o);
fid = FavoriteImageDrawable.getOrCreateSyncedIcon(view.getContext(), favorites.getColorWithCategory(o,defaultColor), o);
history = marker.history;
} else {
fid = FavoriteImageDrawable.getOrCreate(view.getContext(), o.getColor(), true, o);
fid = FavoriteImageDrawable.getOrCreate(view.getContext(), favorites.getColorWithCategory(o,defaultColor), true, o);
}
fid.drawBitmapInCenter(canvas, x, y, history);
}