Merge pull request #9619 from osmandapp/9055_allow_to_edit_address

9055 allow to edit address
This commit is contained in:
Vitaliy 2020-08-20 17:35:58 +03:00 committed by GitHub
commit fcf8f94daa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 372 additions and 98 deletions

View file

@ -11,16 +11,18 @@ public class AFavorite extends AidlParams {
private double lon; private double lon;
private String name; private String name;
private String description; private String description;
private String address;
private String category; private String category;
private String color; private String color;
private boolean visible; 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) { String category, String color, boolean visible) {
this.lat = lat; this.lat = lat;
this.lon = lon; this.lon = lon;
this.name = name; this.name = name;
this.description = description; this.description = description;
this.address = address;
this.category = category; this.category = category;
this.color = color; this.color = color;
this.visible = visible; this.visible = visible;
@ -58,6 +60,8 @@ public class AFavorite extends AidlParams {
return description; return description;
} }
public String getAddress() { return address; }
public String getCategory() { public String getCategory() {
return category; return category;
} }
@ -76,6 +80,7 @@ public class AFavorite extends AidlParams {
bundle.putDouble("lon", lon); bundle.putDouble("lon", lon);
bundle.putString("name", name); bundle.putString("name", name);
bundle.putString("description", description); bundle.putString("description", description);
bundle.putString("address", address);
bundle.putString("category", category); bundle.putString("category", category);
bundle.putString("color", color); bundle.putString("color", color);
bundle.putBoolean("visible", visible); bundle.putBoolean("visible", visible);
@ -87,6 +92,7 @@ public class AFavorite extends AidlParams {
lon = bundle.getDouble("lon"); lon = bundle.getDouble("lon");
name = bundle.getString("name"); name = bundle.getString("name");
description = bundle.getString("description"); description = bundle.getString("description");
address = bundle.getString("address");
category = bundle.getString("category"); category = bundle.getString("category");
color = bundle.getString("color"); color = bundle.getString("color");
visible = bundle.getBoolean("visible"); visible = bundle.getBoolean("visible");

View file

@ -21,8 +21,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height" android:layout_height="@dimen/toolbar_height"
android:background="?attr/card_and_list_background_basic" android:background="?attr/card_and_list_background_basic"
osmand:subtitleTextColor="?android:textColorPrimary"
app:contentInsetStartWithNavigation="@dimen/toolbar_inset_start_with_navigation" app:contentInsetStartWithNavigation="@dimen/toolbar_inset_start_with_navigation"
osmand:subtitleTextColor="?android:textColorPrimary"
osmand:theme="@style/ThemeOverlay.AppCompat.ActionBar" osmand:theme="@style/ThemeOverlay.AppCompat.ActionBar"
osmand:titleTextColor="?android:textColorPrimary"> osmand:titleTextColor="?android:textColorPrimary">
@ -69,8 +69,8 @@
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
android:id="@+id/name_caption" android:id="@+id/name_caption"
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
@ -89,8 +89,8 @@
android:minHeight="@dimen/favorites_list_item_height" android:minHeight="@dimen/favorites_list_item_height"
android:paddingStart="@dimen/content_padding_small" android:paddingStart="@dimen/content_padding_small"
android:paddingLeft="@dimen/content_padding_small" android:paddingLeft="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding_small"
android:paddingEnd="@dimen/content_padding_small" android:paddingEnd="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding_small"
android:scrollHorizontally="false" android:scrollHorizontally="false"
android:textSize="@dimen/default_list_text_size" android:textSize="@dimen/default_list_text_size"
tools:text="@string/lorem_ipsum" /> tools:text="@string/lorem_ipsum" />
@ -103,14 +103,69 @@
android:id="@+id/name_icon" android:id="@+id/name_icon"
android:layout_width="@dimen/favorites_icon_size" android:layout_width="@dimen/favorites_icon_size"
android:layout_height="@dimen/favorites_icon_size" android:layout_height="@dimen/favorites_icon_size"
android:padding="@dimen/favorites_icon_padding"
android:layout_gravity="end" android:layout_gravity="end"
android:layout_margin="@dimen/content_padding_small" android:layout_margin="@dimen/content_padding_small"
android:contentDescription="@string/icon" android:contentDescription="@string/icon"
android:padding="@dimen/favorites_icon_padding"
app:srcCompat="@drawable/ic_action_home_dark" /> app:srcCompat="@drawable/ic_action_home_dark" />
</FrameLayout> </FrameLayout>
<LinearLayout
android:id="@+id/address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/content_padding_small"
android:gravity="center_vertical"
android:orientation="horizontal">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/address_caption"
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1"
android:hint="@string/shared_string_address"
app:boxBackgroundColor="@color/material_text_input_layout_bg"
app:hintAnimationEnabled="false">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/address_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="4"
android:minHeight="@dimen/favorites_list_item_height"
android:paddingStart="@dimen/content_padding_small"
android:paddingLeft="@dimen/content_padding_small"
android:paddingEnd="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding_small"
android:textSize="@dimen/default_list_text_size"
tools:text="@string/lorem_ipsum" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/address_button"
android:layout_width="wrap_content"
android:layout_height="@dimen/context_menu_buttons_bottom_height"
android:layout_marginStart="@dimen/content_padding_half"
android:layout_marginLeft="@dimen/content_padding_half"
android:layout_marginTop="@dimen/content_padding_small"
android:drawablePadding="8dp"
android:duplicateParentState="true"
android:gravity="center"
android:paddingStart="@dimen/content_padding_half"
android:paddingLeft="@dimen/content_padding_half"
android:paddingEnd="@dimen/content_padding_half"
android:paddingRight="@dimen/content_padding_half"
android:text="@string/add_address"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="@string/add_address" />
<LinearLayout <LinearLayout
android:id="@+id/description" android:id="@+id/description"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -120,15 +175,16 @@
android:orientation="horizontal"> android:orientation="horizontal">
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
android:id="@+id/description_caption" android:id="@+id/description_caption"
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/content_padding" android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding" android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1" android:layout_weight="1"
android:hint="@string/shared_string_description" android:hint="@string/shared_string_description"
app:boxBackgroundColor="@color/material_text_input_layout_bg"> app:boxBackgroundColor="@color/material_text_input_layout_bg"
app:hintAnimationEnabled="false">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:id="@+id/description_edit" android:id="@+id/description_edit"
@ -139,8 +195,8 @@
android:minHeight="@dimen/favorites_list_item_height" android:minHeight="@dimen/favorites_list_item_height"
android:paddingStart="@dimen/content_padding_small" android:paddingStart="@dimen/content_padding_small"
android:paddingLeft="@dimen/content_padding_small" android:paddingLeft="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding_small"
android:paddingEnd="@dimen/content_padding_small" android:paddingEnd="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding_small"
android:textSize="@dimen/default_list_text_size" android:textSize="@dimen/default_list_text_size"
tools:text="@string/lorem_ipsum" /> tools:text="@string/lorem_ipsum" />
@ -153,16 +209,17 @@
android:layout_height="@dimen/context_menu_buttons_bottom_height" android:layout_height="@dimen/context_menu_buttons_bottom_height"
android:layout_marginStart="@dimen/content_padding_half" android:layout_marginStart="@dimen/content_padding_half"
android:layout_marginLeft="@dimen/content_padding_half" android:layout_marginLeft="@dimen/content_padding_half"
android:paddingLeft="@dimen/content_padding_half" android:drawablePadding="8dp"
android:paddingRight="@dimen/content_padding_half" android:duplicateParentState="true"
android:gravity="center" android:gravity="center"
android:paddingStart="@dimen/content_padding_half"
android:paddingLeft="@dimen/content_padding_half"
android:paddingEnd="@dimen/content_padding_half"
android:paddingRight="@dimen/content_padding_half"
android:text="@string/add_description"
android:textSize="@dimen/default_desc_text_size" android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium" osmand:typeface="@string/font_roboto_medium"
android:duplicateParentState="true" tools:text="@string/add_description" />
android:text="@string/add_description"
tools:text="@string/add_description"
android:paddingStart="@dimen/content_padding_half"
android:paddingEnd="@dimen/content_padding_half"/>
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
@ -174,8 +231,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:gravity="center_vertical"
android:minHeight="@dimen/toolbar_height" android:minHeight="@dimen/toolbar_height"
android:paddingBottom="@dimen/content_padding_half" android:orientation="vertical"
android:orientation="vertical"> android:paddingBottom="@dimen/content_padding_half">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -227,8 +284,8 @@
android:layout_marginLeft="@dimen/content_padding_small" android:layout_marginLeft="@dimen/content_padding_small"
android:layout_marginEnd="@dimen/content_padding" android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding" android:layout_marginRight="@dimen/content_padding"
app:srcCompat="@drawable/ic_action_folder" android:contentDescription="@string/shared_string_list"
android:contentDescription="@string/shared_string_list" /> app:srcCompat="@drawable/ic_action_folder" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
@ -242,18 +299,18 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/group_recycler_view" android:id="@+id/group_recycler_view"
android:paddingLeft="@dimen/content_padding_half"
android:paddingStart="@dimen/content_padding_half"
android:paddingRight="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clipToPadding="false" android:clipToPadding="false"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingStart="@dimen/content_padding_half"
android:paddingLeft="@dimen/content_padding_half"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
tools:itemCount="3" tools:itemCount="3"
tools:orientation="horizontal"
tools:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" tools:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/point_editor_group_select_item" /> tools:listitem="@layout/point_editor_group_select_item"
tools:orientation="horizontal" />
</LinearLayout> </LinearLayout>
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
@ -262,13 +319,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/content_padding" android:layout_marginStart="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding" android:layout_marginEnd="@dimen/content_padding"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular"
android:lineSpacingMultiplier="@dimen/bottom_sheet_text_spacing_multiplier"
android:letterSpacing="@dimen/description_letter_spacing" android:letterSpacing="@dimen/description_letter_spacing"
android:textColor="?android:textColorSecondary" android:lineSpacingMultiplier="@dimen/bottom_sheet_text_spacing_multiplier"
android:text="@string/add_hidden_group_info" android:text="@string/add_hidden_group_info"
android:visibility="gone" /> android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
android:visibility="gone"
osmand:typeface="@string/font_roboto_regular" />
</LinearLayout> </LinearLayout>
<View <View
@ -293,16 +350,16 @@
android:id="@+id/group_name_recycler_view" android:id="@+id/group_name_recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:clipToPadding="false" android:clipToPadding="false"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
tools:itemCount="3" tools:itemCount="3"
tools:orientation="horizontal"
tools:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" tools:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/point_editor_icon_category_item" /> tools:listitem="@layout/point_editor_icon_category_item"
tools:orientation="horizontal" />
<net.osmand.plus.widgets.FlowLayout <net.osmand.plus.widgets.FlowLayout
android:id="@+id/select_icon" android:id="@+id/select_icon"
@ -361,6 +418,7 @@
android:layout_marginLeft="@dimen/content_padding_small" android:layout_marginLeft="@dimen/content_padding_small"
android:layout_marginTop="@dimen/context_menu_padding_margin_tiny" android:layout_marginTop="@dimen/context_menu_padding_margin_tiny"
android:layout_marginBottom="@dimen/content_padding_half" /> android:layout_marginBottom="@dimen/content_padding_half" />
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
@ -405,11 +463,11 @@
android:id="@+id/select_shape" android:id="@+id/select_shape"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="start"
android:layout_marginStart="@dimen/content_padding_small" android:layout_marginStart="@dimen/content_padding_small"
android:layout_marginLeft="@dimen/content_padding_small" android:layout_marginLeft="@dimen/content_padding_small"
android:layout_marginTop="@dimen/context_menu_padding_margin_tiny" android:layout_marginTop="@dimen/context_menu_padding_margin_tiny"
android:layout_marginBottom="@dimen/content_padding_half" /> android:layout_marginBottom="@dimen/content_padding_half"
android:gravity="start" />
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
@ -479,11 +537,11 @@
android:id="@+id/delete_action_icon" android:id="@+id/delete_action_icon"
android:layout_width="@dimen/standard_icon_size" android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size" android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/content_padding" android:layout_marginStart="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding" android:layout_marginLeft="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding" android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding" android:layout_marginRight="@dimen/content_padding"
android:layout_gravity="center_vertical"
android:contentDescription="@string/delete_point" android:contentDescription="@string/delete_point"
app:srcCompat="@drawable/ic_action_delete_dark" /> app:srcCompat="@drawable/ic_action_delete_dark" />

View file

@ -11,6 +11,9 @@
Thx - Hardy Thx - Hardy
--> -->
<string name="access_hint_enter_address">Enter address</string>
<string name="add_address">Add address</string>
<string name="delete_address">Delete address</string>
<string name="attach_to_the_roads">Attach to the roads</string> <string name="attach_to_the_roads">Attach to the roads</string>
<string name="nearest_point">Nearest point</string> <string name="nearest_point">Nearest point</string>
<string name="start_of_the_track">Start of the track</string> <string name="start_of_the_track">Start of the track</string>

View file

@ -967,7 +967,7 @@ public class OsmandAidlApi {
return false; 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(); FavouritesDbHelper favoritesHelper = app.getFavorites();
List<FavouritePoint> favorites = favoritesHelper.getFavouritePoints(); List<FavouritePoint> favorites = favoritesHelper.getFavouritePoints();
for (FavouritePoint f : favorites) { for (FavouritePoint f : favorites) {
@ -977,8 +977,8 @@ public class OsmandAidlApi {
favoritesHelper.editFavourite(f, newLat, newLon); favoritesHelper.editFavourite(f, newLat, newLon);
} }
if (!newName.equals(f.getName()) || !newDescription.equals(f.getDescription()) || if (!newName.equals(f.getName()) || !newDescription.equals(f.getDescription()) ||
!newCategory.equals(f.getCategory())) { !newCategory.equals(f.getCategory()) || !newAddress.equals(f.getAddress())) {
favoritesHelper.editFavouriteName(f, newName, newCategory, newDescription); favoritesHelper.editFavouriteName(f, newName, newCategory, newDescription,newAddress);
} }
refreshMap(); refreshMap();
return true; return true;

View file

@ -311,7 +311,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
AFavorite newFav = params.getFavoriteNew(); AFavorite newFav = params.getFavoriteNew();
if (prevFav != null && newFav != null) { if (prevFav != null && newFav != null) {
return api.updateFavorite(prevFav.getName(), prevFav.getCategory(), prevFav.getLat(), prevFav.getLon(), 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; return false;

View file

@ -314,7 +314,7 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener
AFavorite newFav = params.getFavoriteNew(); AFavorite newFav = params.getFavoriteNew();
if (prevFav != null && newFav != null) { if (prevFav != null && newFav != null) {
return api.updateFavorite(prevFav.getName(), prevFav.getCategory(), prevFav.getLat(), prevFav.getLon(), 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; return false;

View file

@ -9,16 +9,18 @@ public class AFavorite implements Parcelable {
private double lon; private double lon;
private String name; private String name;
private String description; private String description;
private String address;
private String category; private String category;
private String color; private String color;
private boolean visible; 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) { String category, String color, boolean visible) {
this.lat = lat; this.lat = lat;
this.lon = lon; this.lon = lon;
this.name = name; this.name = name;
this.description = description; this.description = description;
this.address = address;
this.category = category; this.category = category;
this.color = color; this.color = color;
this.visible = visible; this.visible = visible;
@ -56,6 +58,8 @@ public class AFavorite implements Parcelable {
return description; return description;
} }
public String getAddress() { return address; }
public String getCategory() { public String getCategory() {
return category; return category;
} }
@ -77,6 +81,7 @@ public class AFavorite implements Parcelable {
out.writeString(category); out.writeString(category);
out.writeString(color); out.writeString(color);
out.writeByte((byte) (visible ? 1 : 0)); out.writeByte((byte) (visible ? 1 : 0));
out.writeString(address);
} }
private void readFromParcel(Parcel in) { private void readFromParcel(Parcel in) {
@ -87,6 +92,7 @@ public class AFavorite implements Parcelable {
category = in.readString(); category = in.readString();
color = in.readString(); color = in.readString();
visible = in.readByte() != 0; visible = in.readByte() != 0;
address = in.readString();
} }
@Override @Override

View file

@ -2,6 +2,7 @@ package net.osmand.plus;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -102,7 +103,7 @@ public class FavouritesDbHelper {
} }
public int getColor() { public int getColor() {
return color; return color;
} }
public boolean isVisible() { public boolean isVisible() {
@ -128,6 +129,17 @@ public class FavouritesDbHelper {
} }
} }
public Drawable getColoredIconForGroup(String 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();
return context.getUIUtilities().getPaintedIcon(R.drawable.ic_action_group_name_16, color);
}
return null;
}
public int getColorWithCategory(FavouritePoint point, int defaultColor) { public int getColorWithCategory(FavouritePoint point, int defaultColor) {
int color = 0; int color = 0;
if (point.getColor() != 0) { if (point.getColor() != 0) {
@ -183,10 +195,10 @@ public class FavouritesDbHelper {
if (fp.getColor() == 0xFF000000 || fp.getColor() == ContextCompat.getColor(context, R.color.color_favorite)) { if (fp.getColor() == 0xFF000000 || fp.getColor() == ContextCompat.getColor(context, R.color.color_favorite)) {
fp.setColor(0); fp.setColor(0);
} }
if (fp.getBackgroundType() == FavouritePoint.DEFAULT_BACKGROUND_TYPE){ if (fp.getBackgroundType() == FavouritePoint.DEFAULT_BACKGROUND_TYPE) {
fp.setBackgroundType(null); fp.setBackgroundType(null);
} }
if(fp.getIconId()== FavouritePoint.DEFAULT_UI_ICON_ID){ if (fp.getIconId() == FavouritePoint.DEFAULT_UI_ICON_ID) {
fp.setIconId(0); fp.setIconId(0);
} }
FavoriteGroup group = getOrCreateGroup(fp, 0); FavoriteGroup group = getOrCreateGroup(fp, 0);
@ -472,11 +484,12 @@ public class FavouritesDbHelper {
return builder.toString(); 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(); String oldCategory = p.getCategory();
p.setName(newName); p.setName(newName);
p.setCategory(category); p.setCategory(category);
p.setDescription(descr); p.setDescription(descr);
p.setAddress(address);
if (!oldCategory.equals(category)) { if (!oldCategory.equals(category)) {
FavoriteGroup old = flatGroups.get(oldCategory); FavoriteGroup old = flatGroups.get(oldCategory);
if (old != null) { if (old != null) {
@ -884,7 +897,7 @@ public class FavouritesDbHelper {
private static final String FAVOURITE_COL_LAT = "latitude"; //$NON-NLS-1$ 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_COL_LON = "longitude"; //$NON-NLS-1$
private static final String FAVOURITE_TABLE_CREATE = "CREATE TABLE " + FAVOURITE_TABLE_NAME + " (" + //$NON-NLS-1$ //$NON-NLS-2$ 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$ FAVOURITE_COL_LAT + " double, " + FAVOURITE_COL_LON + " double);"; //$NON-NLS-1$ //$NON-NLS-2$
private SQLiteConnection conn; private SQLiteConnection conn;
@ -925,7 +938,7 @@ public class FavouritesDbHelper {
try { try {
SQLiteCursor query = db SQLiteCursor query = db
.rawQuery( .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); FAVOURITE_TABLE_NAME, null);
cachedFavoritePoints.clear(); cachedFavoritePoints.clear();
if (query != null && query.moveToFirst()) { if (query != null && query.moveToFirst()) {

View file

@ -1042,7 +1042,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
} }
FavoritePointEditor favoritePointEditor = getFavoritePointEditor(); FavoritePointEditor favoritePointEditor = getFavoritePointEditor();
if (favoritePointEditor != null) { if (favoritePointEditor != null) {
favoritePointEditor.add(getLatLon(), title, originObjectName); favoritePointEditor.add(getLatLon(), title, getStreetStr(), originObjectName);
} }
} }
}); });

View file

@ -57,7 +57,6 @@ import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.LockableScrollView; import net.osmand.plus.LockableScrollView;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.UiUtilities.DialogButtonType; import net.osmand.plus.UiUtilities.DialogButtonType;
@ -67,19 +66,20 @@ import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.base.ContextMenuFragment; import net.osmand.plus.base.ContextMenuFragment;
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.helpers.FontCache; 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.MenuState;
import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController; import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController;
import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController; import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController;
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController; 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.ChooseRouteFragment;
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu; import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.OsmandMapTileView; 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.HorizontalSwipeConfirm;
import net.osmand.plus.views.controls.SingleTapConfirm; import net.osmand.plus.views.controls.SingleTapConfirm;
import net.osmand.plus.views.layers.TransportStopsLayer;
import net.osmand.plus.widgets.style.CustomTypefaceSpan; import net.osmand.plus.widgets.style.CustomTypefaceSpan;
import net.osmand.router.TransportRouteResult; import net.osmand.router.TransportRouteResult;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -166,14 +166,14 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private int screenOrientation; private int screenOrientation;
private boolean created; private boolean created;
private boolean transportBadgesCreated; private boolean transportBadgesCreated;
private UpdateLocationViewCache updateLocationViewCache; private UpdateLocationViewCache updateLocationViewCache;
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
if (mapActivity == null) { if (mapActivity == null) {
@ -605,7 +605,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
containerLayoutListener = new OnLayoutChangeListener() { containerLayoutListener = new OnLayoutChangeListener() {
@Override @Override
public void onLayoutChange(View view, int left, int top, int right, int bottom, 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) { if (!transportBadgesCreated) {
createTransportBadges(); createTransportBadges();
} }
@ -674,11 +674,11 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
} }
private View getActionView(ContextMenuItem contextMenuItem, private View getActionView(ContextMenuItem contextMenuItem,
final int position, final int position,
final ContextMenuAdapter mainAdapter, final ContextMenuAdapter mainAdapter,
final ContextMenuAdapter additionalAdapter, final ContextMenuAdapter additionalAdapter,
final ContextMenuItemClickListener mainListener, final ContextMenuItemClickListener mainListener,
final ContextMenuItemClickListener additionalListener) { final ContextMenuItemClickListener additionalListener) {
UiUtilities uiUtilities = requireMyApplication().getUIUtilities(); UiUtilities uiUtilities = requireMyApplication().getUIUtilities();
LayoutInflater inflater = UiUtilities.getInflater(getMyApplication(), nightMode); LayoutInflater inflater = UiUtilities.getInflater(getMyApplication(), nightMode);
View view = inflater.inflate(R.layout.context_menu_action_item, null); View view = inflater.inflate(R.layout.context_menu_action_item, null);
@ -780,7 +780,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
} }
return false; return false;
} }
private float getToolbarAlpha(int y) { private float getToolbarAlpha(int y) {
float a = 0; float a = 0;
if (menu != null && !menu.isLandscapeLayout()) { if (menu != null && !menu.isLandscapeLayout()) {
@ -827,7 +827,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
v.setAlpha(alpha); v.setAlpha(alpha);
if (visible && v.getVisibility() != View.VISIBLE) { if (visible && v.getVisibility() != View.VISIBLE) {
v.setVisibility(View.VISIBLE); v.setVisibility(View.VISIBLE);
} else if (!visible && v.getVisibility() == View.VISIBLE) { } else if (!visible && v.getVisibility() == View.VISIBLE) {
v.setVisibility(View.INVISIBLE); v.setVisibility(View.INVISIBLE);
} }
} }
@ -835,7 +835,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private void updateVisibility(View v, boolean visible) { private void updateVisibility(View v, boolean visible) {
if (visible && v.getVisibility() != View.VISIBLE) { if (visible && v.getVisibility() != View.VISIBLE) {
v.setVisibility(View.VISIBLE); v.setVisibility(View.VISIBLE);
} else if (!visible && v.getVisibility() == View.VISIBLE) { } else if (!visible && v.getVisibility() == View.VISIBLE) {
v.setVisibility(View.INVISIBLE); v.setVisibility(View.INVISIBLE);
} }
} }
@ -1021,7 +1021,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
} }
private void applyPosY(final int currentY, final boolean needCloseMenu, boolean needMapAdjust, 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); final int posY = getPosY(currentY, needCloseMenu, previousMenuState);
if (getViewY() != posY || dZoom != 0) { if (getViewY() != posY || dZoom != 0) {
if (posY < getViewY()) { if (posY < getViewY()) {
@ -1146,7 +1146,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
Typeface typeface = FontCache.getRobotoRegular(context); Typeface typeface = FontCache.getRobotoRegular(context);
title.setSpan(new CustomTypefaceSpan(typeface), startIndex, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); title.setSpan(new CustomTypefaceSpan(typeface), startIndex, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
title.setSpan(new ForegroundColorSpan( 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); startIndex, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
} }
setupButton(leftTitleButtonView, leftTitleButtonController.enabled, title); setupButton(leftTitleButtonView, leftTitleButtonController.enabled, title);
@ -1620,7 +1620,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
return dpToPx(32); return dpToPx(32);
} }
} }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void runLayoutListener() { private void runLayoutListener() {
if (view != null) { if (view != null) {
@ -1709,7 +1709,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
- (newMenuTopShadowAllHeight - menuTopShadowAllHeight)); - (newMenuTopShadowAllHeight - menuTopShadowAllHeight));
} else { } else {
menuTopViewHeightExcludingTitle = newMenuTopViewHeight - line1.getMeasuredHeight() - line2MeasuredHeight menuTopViewHeightExcludingTitle = newMenuTopViewHeight - line1.getMeasuredHeight() - line2MeasuredHeight
- titleButtonHeight - downloadButtonsHeight - titleBottomButtonHeight - additionalButtonsHeight - titleProgressHeight-line3Height; - titleButtonHeight - downloadButtonsHeight - titleBottomButtonHeight - additionalButtonsHeight - titleProgressHeight - line3Height;
menuTitleTopBottomPadding = (line1.getMeasuredHeight() - line1.getLineCount() * line1.getLineHeight()) menuTitleTopBottomPadding = (line1.getMeasuredHeight() - line1.getLineCount() * line1.getLineHeight())
+ (line2MeasuredHeight - line2LineCount * line2LineHeight); + (line2MeasuredHeight - line2LineCount * line2LineHeight);
menuButtonsHeight = view.findViewById(R.id.context_menu_bottom_buttons).getHeight() menuButtonsHeight = view.findViewById(R.id.context_menu_bottom_buttons).getHeight()
@ -1800,13 +1800,12 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private void setAddressLocation() { private void setAddressLocation() {
if (view != null) { if (view != null) {
// Text line 1 // 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()); line1.setText(menu.getTitleStr());
toolbarTextView.setText(menu.getTitleStr()); toolbarTextView.setText(menu.getTitleStr());
// Text line 2 // Text line 2
LinearLayout line2layout = (LinearLayout) view.findViewById(R.id.context_menu_line2_layout); LinearLayout line2layout = view.findViewById(R.id.context_menu_line2_layout);
TextView line2 = (TextView) view.findViewById(R.id.context_menu_line2); TextView line2 = view.findViewById(R.id.context_menu_line2);
if (menu.hasCustomAddressLine()) { if (menu.hasCustomAddressLine()) {
line2layout.removeAllViews(); line2layout.removeAllViews();
menu.buildCustomAddressLine(line2layout); menu.buildCustomAddressLine(line2layout);
@ -1823,7 +1822,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
} }
if (!Algorithms.isEmpty(streetStr) && !menu.displayStreetNameInTitle()) { if (!Algorithms.isEmpty(streetStr) && !menu.displayStreetNameInTitle()) {
if (line2Str.length() > 0) { if (line2Str.length() > 0) {
line2Str.append(": "); line2Str.append(", ");
} }
line2Str.append(streetStr); line2Str.append(streetStr);
} }
@ -2200,7 +2199,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
} }
public static boolean showInstance(final MapContextMenu menu, final MapActivity mapActivity, public static boolean showInstance(final MapContextMenu menu, final MapActivity mapActivity,
final boolean centered) { final boolean centered) {
try { try {
if (menu.getLatLon() == null || mapActivity == null || mapActivity.isActivityDestroyed()) { if (menu.getLatLon() == null || mapActivity == null || mapActivity.isActivityDestroyed()) {

View file

@ -11,8 +11,10 @@ import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.data.TransportStop; import net.osmand.data.TransportStop;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.PointImageDrawable; import net.osmand.plus.base.PointImageDrawable;
@ -23,6 +25,7 @@ import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragment;
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragmentNew; import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragmentNew;
import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.util.OpeningHoursParser; import net.osmand.util.OpeningHoursParser;
import net.osmand.view.GravityDrawable;
import java.util.List; import java.util.List;
@ -150,9 +153,30 @@ public class FavouritePointMenuController extends MenuController {
} }
} }
@NonNull
@Override
public String getSubtypeStr() {
return fav.getAddress();
}
@Override @Override
public Drawable getSecondLineTypeIcon() { 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); 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 null;
} }
@Override @Override
@ -193,6 +217,6 @@ public class FavouritePointMenuController extends MenuController {
if (originObject instanceof Amenity) { if (originObject instanceof Amenity) {
AmenityMenuController.addTypeMenuItem((Amenity) originObject, builder); AmenityMenuController.addTypeMenuItem((Amenity) originObject, builder);
} }
} }
} }
} }

View file

@ -27,7 +27,7 @@ public class FavoritePointEditor extends PointEditor {
return favorite; 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(); MapActivity mapActivity = getMapActivity();
if (latLon == null || mapActivity == null) { if (latLon == null || mapActivity == null) {
return; return;
@ -39,6 +39,7 @@ public class FavoritePointEditor extends PointEditor {
} }
favorite = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), title, lastCategory); favorite = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), title, lastCategory);
favorite.setDescription(""); favorite.setDescription("");
favorite.setAddress(address.isEmpty() ? title : address);
favorite.setOriginObjectName(originObjectName); favorite.setOriginObjectName(originObjectName);
FavoritePointEditorFragmentNew.showInstance(mapActivity); FavoritePointEditorFragmentNew.showInstance(mapActivity);
} }
@ -61,6 +62,7 @@ public class FavoritePointEditor extends PointEditor {
favorite = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), title, categoryName); favorite = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), title, categoryName);
favorite.setDescription(""); favorite.setDescription("");
favorite.setAddress("");
favorite.setOriginObjectName(originObjectName); favorite.setOriginObjectName(originObjectName);
FavoritePointEditorFragmentNew.showAutoFillInstance(mapActivity, autoFill); FavoritePointEditorFragmentNew.showAutoFillInstance(mapActivity, autoFill);

View file

@ -192,12 +192,13 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(), final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(),
getNameTextValue(), getCategoryTextValue()); getNameTextValue(), getCategoryTextValue());
point.setDescription(getDescriptionTextValue()); point.setDescription(getDescriptionTextValue());
point.setAddress(getAddressTextValue());
AlertDialog.Builder builder = FavouritesDbHelper.checkDuplicates(point, helper, getMapActivity()); AlertDialog.Builder builder = FavouritesDbHelper.checkDuplicates(point, helper, getMapActivity());
if (favorite.getName().equals(point.getName()) && if (favorite.getName().equals(point.getName()) &&
favorite.getCategory().equals(point.getCategory()) && 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) { if (needDismiss) {
dismiss(false); dismiss(false);
} }
@ -208,25 +209,25 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { 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(); builder.create().show();
} else { } else {
doSave(favorite, point.getName(), point.getCategory(), point.getDescription(), needDismiss); doSave(favorite, point.getName(), point.getCategory(), point.getDescription(), point.getAddress(), needDismiss);
} }
saved = true; 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(); FavouritesDbHelper helper = getHelper();
FavoritePointEditor editor = getFavoritePointEditor(); FavoritePointEditor editor = getFavoritePointEditor();
if (editor != null && helper != null) { if (editor != null && helper != null) {
if (editor.isNew()) { if (editor.isNew()) {
doAddFavorite(name, category, description); doAddFavorite(name, category, description,address);
} else { } else {
helper.editFavouriteName(favorite, name, category, description); helper.editFavouriteName(favorite, name, category, description,address);
} }
} }
MapActivity mapActivity = getMapActivity(); 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(); OsmandApplication app = getMyApplication();
FavouritesDbHelper helper = getHelper(); FavouritesDbHelper helper = getHelper();
FavouritePoint favorite = getFavorite(); FavouritePoint favorite = getFavorite();
@ -253,6 +254,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
favorite.setName(name); favorite.setName(name);
favorite.setCategory(category); favorite.setCategory(category);
favorite.setDescription(description); favorite.setDescription(description);
favorite.setAddress(address);
app.getSettings().LAST_FAV_CATEGORY_ENTERED.set(category); app.getSettings().LAST_FAV_CATEGORY_ENTERED.set(category);
helper.addFavourite(favorite); helper.addFavourite(favorite);
} }

View file

@ -244,6 +244,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(), final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(),
getNameTextValue(), getCategoryTextValue()); getNameTextValue(), getCategoryTextValue());
point.setDescription(getDescriptionTextValue()); point.setDescription(getDescriptionTextValue());
point.setAddress(getAddressTextValue());
point.setColor(color); point.setColor(color);
point.setBackgroundType(backgroundType); point.setBackgroundType(backgroundType);
point.setIconId(iconId); point.setIconId(iconId);
@ -259,6 +260,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(), final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(),
getNameTextValue(), getCategoryTextValue()); getNameTextValue(), getCategoryTextValue());
point.setDescription(getDescriptionTextValue()); point.setDescription(getDescriptionTextValue());
point.setAddress(getAddressTextValue());
point.setColor(color); point.setColor(color);
point.setBackgroundType(backgroundType); point.setBackgroundType(backgroundType);
point.setIconId(iconId); point.setIconId(iconId);
@ -276,13 +278,13 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { 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); point.getColor(), point.getBackgroundType(), point.getIconId(), needDismiss);
} }
}); });
builder.create().show(); builder.create().show();
} else { } 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); point.getColor(), point.getBackgroundType(), point.getIconId(), needDismiss);
} }
saved = true; saved = true;
@ -295,10 +297,11 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
favorite.getName().equals(point.getName()) && favorite.getName().equals(point.getName()) &&
favorite.getCategory().equals(point.getCategory()) && favorite.getCategory().equals(point.getCategory()) &&
favorite.getBackgroundType().equals(point.getBackgroundType()) && 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) { @ColorInt int color, BackgroundType backgroundType, @DrawableRes int iconId, boolean needDismiss) {
FavouritesDbHelper helper = getHelper(); FavouritesDbHelper helper = getHelper();
FavoritePointEditor editor = getFavoritePointEditor(); FavoritePointEditor editor = getFavoritePointEditor();
@ -306,7 +309,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
if (editor.isNew()) { if (editor.isNew()) {
doAddFavorite(name, category, description, color, backgroundType, iconId); doAddFavorite(name, category, description, color, backgroundType, iconId);
} else { } else {
doEditFavorite(favorite, name, category, description, color, backgroundType, iconId, helper); doEditFavorite(favorite, name, category, description, address, color, backgroundType, iconId, helper);
} }
} }
MapActivity mapActivity = getMapActivity(); 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, @ColorInt int color, BackgroundType backgroundType, @DrawableRes int iconId,
FavouritesDbHelper helper) { FavouritesDbHelper helper) {
OsmandApplication app = getMyApplication(); OsmandApplication app = getMyApplication();
@ -334,7 +337,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
favorite.setColor(color); favorite.setColor(color);
favorite.setBackgroundType(backgroundType); favorite.setBackgroundType(backgroundType);
favorite.setIconId(iconId); favorite.setIconId(iconId);
helper.editFavouriteName(favorite, name, category, description); helper.editFavouriteName(favorite, name, category, description, address);
} }
} }
@ -405,6 +408,12 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
return favorite != null ? favorite.getDescription() : ""; return favorite != null ? favorite.getDescription() : "";
} }
@Override
public String getAddressInitValue() {
FavouritePoint favourite = getFavorite();
return favourite != null ? favourite.getAddress() : "";
}
@Override @Override
public Drawable getNameIcon() { public Drawable getNameIcon() {
FavouritePoint favorite = getFavorite(); FavouritePoint favorite = getFavorite();

View file

@ -373,6 +373,12 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment {
return Algorithms.isEmpty(res) ? null : res; 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) { protected Drawable getPaintedIcon(int iconId, int color) {
return getPaintedContentIcon(iconId, color); return getPaintedContentIcon(iconId, color);
} }

View file

@ -75,6 +75,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
private View view; private View view;
private EditText nameEdit; private EditText nameEdit;
private TextView addDelDescription; private TextView addDelDescription;
private TextView addAddressBtn;
private TextView addToHiddenGroupInfo; private TextView addToHiddenGroupInfo;
private boolean cancelled; private boolean cancelled;
private boolean nightMode; private boolean nightMode;
@ -91,7 +92,9 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
private LinkedHashMap<String, JSONArray> iconCategories; private LinkedHashMap<String, JSONArray> iconCategories;
private OsmandApplication app; private OsmandApplication app;
private View descriptionCaption; private View descriptionCaption;
private View addressCaption;
private EditText descriptionEdit; private EditText descriptionEdit;
private EditText addressEdit;
private int layoutHeightPrevious = 0; private int layoutHeightPrevious = 0;
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
@ -142,11 +145,12 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
hideKeyboard(); hideKeyboard();
descriptionEdit.clearFocus(); descriptionEdit.clearFocus();
nameEdit.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); ImageView toolbarAction = (ImageView) view.findViewById(R.id.toolbar_action);
view.findViewById(R.id.background_layout).setBackgroundResource(nightMode view.findViewById(R.id.background_layout).setBackgroundResource(nightMode
? R.color.app_bar_color_dark : R.color.list_background_color_light); ? 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); 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(), descriptionEdit, nightMode);
AndroidUtils.setTextPrimaryColor(view.getContext(), addressEdit, nightMode);
AndroidUtils.setHintTextSecondaryColor(view.getContext(), descriptionEdit, nightMode); AndroidUtils.setHintTextSecondaryColor(view.getContext(), descriptionEdit, nightMode);
AndroidUtils.setHintTextSecondaryColor(view.getContext(), addressEdit, nightMode);
if (getDescriptionInitValue() != null) { if (getDescriptionInitValue() != null) {
descriptionEdit.setText(getDescriptionInitValue()); descriptionEdit.setText(getDescriptionInitValue());
} }
if (getAddressInitValue() != null){
addressEdit.setText(getAddressInitValue());
}
descriptionCaption = view.findViewById(R.id.description); descriptionCaption = view.findViewById(R.id.description);
addressCaption = view.findViewById(R.id.address);
addDelDescription = (TextView) view.findViewById(R.id.description_button); addDelDescription = (TextView) view.findViewById(R.id.description_button);
addAddressBtn = view.findViewById(R.id.address_button);
addDelDescription.setTextColor(getResources().getColor(activeColorResId)); addDelDescription.setTextColor(getResources().getColor(activeColorResId));
addAddressBtn.setTextColor(getResources().getColor(activeColorResId));
addAddressBtn.setCompoundDrawablesWithIntrinsicBounds(
app.getUIUtilities().getIcon(R.drawable.ic_action_location_16, activeColorResId),null,null,null);
addDelDescription.setCompoundDrawablesWithIntrinsicBounds(
app.getUIUtilities().getIcon(R.drawable.ic_action_description_16, activeColorResId),null,null,null);
addDelDescription.setOnClickListener(new View.OnClickListener() { addDelDescription.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (descriptionCaption.getVisibility() != View.VISIBLE) { if (descriptionCaption.getVisibility() != View.VISIBLE) {
descriptionCaption.setVisibility(View.VISIBLE); descriptionCaption.setVisibility(View.VISIBLE);
addDelDescription.setText(view.getResources().getString(R.string.delete_description)); addDelDescription.setText(view.getResources().getString(R.string.delete_description));
addDelDescription.setCompoundDrawablesWithIntrinsicBounds(
app.getUIUtilities().getIcon(R.drawable.ic_action_trash_basket_16,
activeColorResId),null,null,null);
View descriptionEdit = view.findViewById(R.id.description_edit); View descriptionEdit = view.findViewById(R.id.description_edit);
descriptionEdit.requestFocus(); descriptionEdit.requestFocus();
AndroidUtils.softKeyboardDelayed(getActivity(), descriptionEdit); AndroidUtils.softKeyboardDelayed(getActivity(), descriptionEdit);
} else { } else {
descriptionCaption.setVisibility(View.GONE); descriptionCaption.setVisibility(View.GONE);
addDelDescription.setText(view.getResources().getString(R.string.add_description)); addDelDescription.setText(view.getResources().getString(R.string.add_description));
addDelDescription.setCompoundDrawablesWithIntrinsicBounds(
app.getUIUtilities().getIcon(R.drawable.ic_action_description_16,
activeColorResId),null,null,null);
AndroidUtils.hideSoftKeyboard(requireActivity(), descriptionEdit); AndroidUtils.hideSoftKeyboard(requireActivity(), descriptionEdit);
descriptionEdit.clearFocus(); 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(requireActivity(),addressEdit);
} else {
addressCaption.setVisibility(View.GONE);
addAddressBtn.setText(view.getResources().getString(R.string.add_address));
AndroidUtils.hideSoftKeyboard(requireActivity(), addressEdit);
addressEdit.clearFocus();
}
}
});
nameIcon.setImageDrawable(getNameIcon()); nameIcon.setImageDrawable(getNameIcon());
if (app.accessibilityEnabled()) { if (app.accessibilityEnabled()) {
nameCaption.setFocusable(true); nameCaption.setFocusable(true);
nameEdit.setHint(R.string.access_hint_enter_name); 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); View deleteButton = view.findViewById(R.id.button_delete_container);
@ -348,6 +387,13 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
descriptionCaption.setVisibility(View.GONE); descriptionCaption.setVisibility(View.GONE);
addDelDescription.setText(app.getString(R.string.add_description)); 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() { private void createGroupSelector() {
@ -754,6 +800,8 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
public abstract String getDescriptionInitValue(); public abstract String getDescriptionInitValue();
public abstract String getAddressInitValue();
public abstract Drawable getNameIcon(); public abstract Drawable getNameIcon();
public abstract Drawable getCategoryIcon(); public abstract Drawable getCategoryIcon();
@ -800,6 +848,12 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
return Algorithms.isEmpty(res) ? null : res; 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) { protected Drawable getPaintedIcon(int iconId, int color) {
return getPaintedContentIcon(iconId, color); return getPaintedContentIcon(iconId, color);
} }

View file

@ -402,6 +402,9 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
return wpt != null ? wpt.desc : ""; return wpt != null ? wpt.desc : "";
} }
@Override
public String getAddressInitValue() { return ""; }
@Override @Override
public Drawable getNameIcon() { public Drawable getNameIcon() {
WptPt wptPt = getWpt(); WptPt wptPt = getWpt();

View file

@ -14,6 +14,7 @@ import androidx.core.content.ContextCompat;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.util.Algorithms;
import java.util.List; import java.util.List;
@ -82,11 +83,18 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter<MapMultiSelectionMe
// Text line 2 // Text line 2
TextView line2 = (TextView) convertView.findViewById(R.id.context_menu_line2); TextView line2 = (TextView) convertView.findViewById(R.id.context_menu_line2);
((TextView) line2).setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_subtitle_color)); ((TextView) line2).setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_subtitle_color));
line2.setText(item.getTypeStr()); StringBuilder line2Str = new StringBuilder(item.getTypeStr());
String streetStr = item.getStreetStr();
if (!Algorithms.isEmpty(streetStr) && !item.displayStreetNameInTitle()) {
if (line2Str.length() > 0) {
line2Str.append(", ");
}
line2Str.append(streetStr);
}
line2.setText(line2Str);
Drawable slIcon = item.getTypeIcon(); Drawable slIcon = item.getTypeIcon();
line2.setCompoundDrawablesWithIntrinsicBounds(slIcon, null, null, null); line2.setCompoundDrawablesWithIntrinsicBounds(slIcon, null, null, null);
line2.setCompoundDrawablePadding(AndroidUtils.dpToPx(menu.getMapActivity(), 5f)); line2.setCompoundDrawablePadding(AndroidUtils.dpToPx(menu.getMapActivity(), 5f));
// Divider // Divider
View divider = convertView.findViewById(R.id.divider); View divider = convertView.findViewById(R.id.divider);
divider.setBackgroundColor(ContextCompat.getColor(getContext(), menu.isLight() ? R.color.multi_selection_menu_divider_light : R.color.multi_selection_menu_divider_dark)); divider.setBackgroundColor(ContextCompat.getColor(getContext(), menu.isLight() ? R.color.multi_selection_menu_divider_light : R.color.multi_selection_menu_divider_dark));

View file

@ -0,0 +1,81 @@
package net.osmand.view;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull;
public class GravityDrawable extends Drawable {
// inner Drawable
private final Drawable original;
public GravityDrawable(@NonNull Drawable drawable) {
this.original = drawable;
}
@Override
public int getMinimumHeight() {
return original.getMinimumHeight();
}
@Override
public int getMinimumWidth() {
return original.getMinimumWidth();
}
@Override
public int getIntrinsicHeight() {
return original.getIntrinsicHeight();
}
@Override
public int getIntrinsicWidth() {
return original.getIntrinsicWidth();
}
@Override
public void setChangingConfigurations(int configs) {
super.setChangingConfigurations(configs);
original.setChangingConfigurations(configs);
}
@Override
public void setBounds(int left, int top, int right, int bottom) {
super.setBounds(left, top, right, bottom);
original.setBounds(left, top, right, bottom);
}
@Override
public void setAlpha(int alpha) {
original.setAlpha(alpha);
}
@Override
public void setColorFilter(ColorFilter cf) {
original.setColorFilter(cf);
}
@Override
public int getOpacity() {
return original.getOpacity();
}
@Override
public void draw(Canvas canvas) {
int halfCanvas = canvas.getHeight() / 2;
int halfDrawable = original.getIntrinsicHeight() / 2;
// align to top
canvas.save();
canvas.translate(0, -halfCanvas + halfDrawable);
original.draw(canvas);
canvas.restore();
}
public void setBoundsFrom(Drawable line2Icon) {
line2Icon.setBounds(0, 0, line2Icon.getIntrinsicWidth(), line2Icon.getIntrinsicHeight());
this.setBounds(0, 0, line2Icon.getIntrinsicWidth(), line2Icon.getIntrinsicHeight());
}
}