Fix wrong category name in add/edit favorite
This commit is contained in:
parent
9a4f043a64
commit
19419d7d55
3 changed files with 9 additions and 8 deletions
|
@ -83,6 +83,8 @@ public class FavouritesDbHelper {
|
|||
public static String getDisplayName(String name, Context ctx) {
|
||||
if (isPersonal(name)) {
|
||||
return ctx.getString(R.string.personal_category_name);
|
||||
} else if (name.isEmpty()) {
|
||||
return ctx.getString(R.string.shared_string_favorites);
|
||||
} else {
|
||||
return name;
|
||||
}
|
||||
|
@ -108,7 +110,7 @@ public class FavouritesDbHelper {
|
|||
return getDisplayName(name, ctx);
|
||||
}
|
||||
|
||||
public String convertDisplayNameToGroupIdName(Context context, String name) {
|
||||
public static String convertDisplayNameToGroupIdName(Context context, String name) {
|
||||
if (name.equals(context.getString(R.string.personal_category_name))) {
|
||||
return PERSONAL_CATEGORY;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
FavoritePointEditor editor = getFavoritePointEditor();
|
||||
if (view != null && editor != null && editor.isNew()) {
|
||||
Button replaceButton = (Button) view.findViewById(R.id.replace_button);
|
||||
Button replaceButton = view.findViewById(R.id.replace_button);
|
||||
replaceButton.setTextColor(getResources().getColor(!editor.isLight() ? R.color.osmand_orange : R.color.map_widget_blue));
|
||||
replaceButton.setVisibility(View.VISIBLE);
|
||||
replaceButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -147,7 +147,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
public void setCategory(String name, int color) {
|
||||
FavouritesDbHelper helper = getHelper();
|
||||
if (helper != null) {
|
||||
FavoriteGroup group = helper.getGroup(name);
|
||||
FavoriteGroup group = helper.getGroup(FavouritesDbHelper.FavoriteGroup.convertDisplayNameToGroupIdName(requireContext(), name));
|
||||
this.group = group;
|
||||
super.setCategory(name, group.getColor());
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
@Override
|
||||
public String getCategoryInitValue() {
|
||||
FavouritePoint favorite = getFavorite();
|
||||
return favorite == null || favorite.getCategory().length() == 0 ? getDefaultCategoryName() : favorite.getCategoryDisplayName(getContext());
|
||||
return favorite == null || favorite.getCategory().length() == 0 ? getDefaultCategoryName() : favorite.getCategoryDisplayName(requireContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -132,14 +132,13 @@ public class SelectCategoryDialogFragment extends DialogFragment {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
FragmentActivity a = getActivity();
|
||||
if (a != null && a instanceof MapActivity) {
|
||||
String categoryInternalName = categoryName.equals(a.getString(R.string.personal_category_name)) ? PERSONAL_CATEGORY : categoryName;
|
||||
if (a instanceof MapActivity) {
|
||||
PointEditor pointEditor = ((MapActivity) a).getContextMenu().getPointEditor(editorTag);
|
||||
if (pointEditor != null) {
|
||||
pointEditor.setCategory(categoryInternalName, categoryColor);
|
||||
pointEditor.setCategory(categoryName, categoryColor);
|
||||
}
|
||||
if (selectionListener != null) {
|
||||
selectionListener.onCategorySelected(categoryInternalName, categoryColor);
|
||||
selectionListener.onCategorySelected(categoryName, categoryColor);
|
||||
}
|
||||
}
|
||||
dismiss();
|
||||
|
|
Loading…
Reference in a new issue