Merge pull request #9771 from osmandapp/favorites_allow_to_edit_address

context_menu
This commit is contained in:
vshcherb 2020-09-11 13:40:56 +02:00 committed by GitHub
commit 2ffabd7e9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 52 additions and 45 deletions

View file

@ -174,6 +174,38 @@
android:paddingEnd="@dimen/context_menu_padding_margin_default" android:paddingEnd="@dimen/context_menu_padding_margin_default"
android:paddingTop="3dp"> android:paddingTop="3dp">
<LinearLayout
android:id="@+id/compass_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/direction"
android:layout_width="@dimen/directionIconSize"
android:layout_height="@dimen/directionIconSize"
android:layout_gravity="center_vertical"
android:layout_marginTop="1sp"
tools:src="@drawable/ic_direction_arrow"/>
<TextView
android:id="@+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="2dp"
android:layout_marginStart="2dp"
android:textSize="@dimen/default_desc_text_size"
tools:text="100500 km"
tools:textColor="?android:textColorSecondary"/>
<View
android:id="@+id/favourite_right_point_space"
android:layout_width="@dimen/text_margin_small"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/additional_info_row" android:id="@+id/additional_info_row"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -222,32 +254,6 @@
android:visibility="gone" android:visibility="gone"
tools:visibility="visible"/> tools:visibility="visible"/>
<LinearLayout
android:id="@+id/compass_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/direction"
android:layout_width="@dimen/directionIconSize"
android:layout_height="@dimen/directionIconSize"
android:layout_gravity="center_vertical"
android:layout_marginTop="1sp"
tools:src="@drawable/ic_direction_arrow"/>
<TextView
android:id="@+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="2dp"
android:layout_marginStart="2dp"
android:textSize="@dimen/default_desc_text_size"
tools:text="100500 km"
tools:textColor="?android:textColorSecondary"/>
</LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -1473,7 +1473,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
return menuController != null && menuController.displayDistanceDirection(); return menuController != null && menuController.displayDistanceDirection();
} }
public String getSubtypeStr() { public CharSequence getSubtypeStr() {
MenuController menuController = getMenuController(); MenuController menuController = getMenuController();
if (menuController != null) { if (menuController != null) {
return menuController.getSubtypeStr(); return menuController.getSubtypeStr();

View file

@ -1835,7 +1835,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
} }
TextView line3 = (TextView) view.findViewById(R.id.context_menu_line3); TextView line3 = (TextView) view.findViewById(R.id.context_menu_line3);
String subtypeStr = menu.getSubtypeStr(); CharSequence subtypeStr = menu.getSubtypeStr();
if (TextUtils.isEmpty(subtypeStr)) { if (TextUtils.isEmpty(subtypeStr)) {
line3.setVisibility(View.GONE); line3.setVisibility(View.GONE);
} else { } else {

View file

@ -534,7 +534,7 @@ public abstract class MenuController extends BaseMenuController implements Colla
} }
@NonNull @NonNull
public String getSubtypeStr() { public CharSequence getSubtypeStr() {
return ""; return "";
} }

View file

@ -148,7 +148,7 @@ public class AMapPointMenuController extends MenuController {
@NonNull @NonNull
@Override @Override
public String getSubtypeStr() { public CharSequence getSubtypeStr() {
MapActivity activity = getMapActivity(); MapActivity activity = getMapActivity();
if (activity != null) { if (activity != null) {
float bearing = getPointBearing(); float bearing = getPointBearing();

View file

@ -1,6 +1,8 @@
package net.osmand.plus.mapcontextmenu.controllers; package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.text.SpannableString;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
@ -18,14 +20,15 @@ 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;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.mapcontextmenu.builders.FavouritePointMenuBuilder; import net.osmand.plus.mapcontextmenu.builders.FavouritePointMenuBuilder;
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor; import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor;
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragment; 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.plus.widgets.style.CustomTypefaceSpan;
import net.osmand.util.OpeningHoursParser; import net.osmand.util.OpeningHoursParser;
import net.osmand.view.GravityDrawable;
import java.util.List; import java.util.List;
@ -155,8 +158,12 @@ public class FavouritePointMenuController extends MenuController {
@NonNull @NonNull
@Override @Override
public String getSubtypeStr() { public CharSequence getSubtypeStr() {
return fav.getAddress(); Typeface typeface = FontCache.getRobotoRegular(getMapActivity());
SpannableString addressSpannable = new SpannableString(fav.getAddress());
addressSpannable.setSpan(new CustomTypefaceSpan(typeface), 0, addressSpannable.length(), 0);
return addressSpannable;
} }
@Override @Override
@ -167,10 +174,8 @@ public class FavouritePointMenuController extends MenuController {
FavouritesDbHelper helper = app.getFavorites(); FavouritesDbHelper helper = app.getFavorites();
String group = fav.getCategory(); String group = fav.getCategory();
if (helper.getGroup(group) != null) { if (helper.getGroup(group) != null) {
Drawable line2icon = helper.getColoredIconForGroup(group); int colorId = R.color.color_favorite;
GravityDrawable gravityIcon = new GravityDrawable(line2icon); return getIcon(R.drawable.ic_action_group_name_16, colorId);
gravityIcon.setBoundsFrom(line2icon);
return gravityIcon;
} else { } else {
int colorId = isLight() ? R.color.icon_color_default_light : R.color.ctx_menu_bottom_view_icon_dark; int colorId = isLight() ? R.color.icon_color_default_light : R.color.ctx_menu_bottom_view_icon_dark;
return getIcon(R.drawable.ic_action_group_name_16, colorId); return getIcon(R.drawable.ic_action_group_name_16, colorId);

View file

@ -268,6 +268,8 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
} }
} }
}); });
AndroidUiHelper.updateVisibility(addressCaption, false);
addAddressBtn.setText(getAddressInitValue());
addAddressBtn.setOnClickListener(new View.OnClickListener() { addAddressBtn.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -279,7 +281,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
AndroidUtils.softKeyboardDelayed(requireActivity(),addressEdit); AndroidUtils.softKeyboardDelayed(requireActivity(),addressEdit);
} else { } else {
addressCaption.setVisibility(View.GONE); addressCaption.setVisibility(View.GONE);
addAddressBtn.setText(view.getResources().getString(R.string.add_address)); addAddressBtn.setText(getAddressTextValue());
AndroidUtils.hideSoftKeyboard(requireActivity(), addressEdit); AndroidUtils.hideSoftKeyboard(requireActivity(), addressEdit);
addressEdit.clearFocus(); addressEdit.clearFocus();
} }
@ -388,13 +390,7 @@ 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() {