Fix last used category, black color, GPX icon shape
This commit is contained in:
parent
9d5209d666
commit
22c0b9b04d
4 changed files with 48 additions and 25 deletions
|
@ -178,7 +178,7 @@
|
|||
<color name="row_selection_color">#CC33BBE0</color>
|
||||
|
||||
<!-- GPX analysis colors -->
|
||||
<color name="gpx_color_point">#d00d0d</color>
|
||||
<color name="gpx_color_point">#b4d00d0d</color>
|
||||
<color name="gpx_speed">#c79c00</color>
|
||||
<color name="gpx_altitude_desc">#32CD32</color>
|
||||
<color name="gpx_altitude_asc">#EE3232</color>
|
||||
|
|
|
@ -171,6 +171,16 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLastUsedGroup() {
|
||||
OsmandApplication app = requireMyApplication();
|
||||
String lastCategory = app.getSettings().LAST_FAV_CATEGORY_ENTERED.get();
|
||||
if (!Algorithms.isEmpty(lastCategory) && !app.getFavorites().groupExists(lastCategory)) {
|
||||
lastCategory = "";
|
||||
}
|
||||
return lastCategory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
|
@ -290,10 +300,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
if (editor.isNew()) {
|
||||
doAddFavorite(name, category, description, color, backgroundType, iconId);
|
||||
} else {
|
||||
favorite.setColor(color);
|
||||
favorite.setBackgroundType(backgroundType);
|
||||
favorite.setIconId(iconId);
|
||||
helper.editFavouriteName(favorite, name, category, description);
|
||||
doEditFavorite(favorite, name, category, description, color, backgroundType, iconId, helper);
|
||||
}
|
||||
}
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
|
@ -312,6 +319,16 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
}
|
||||
}
|
||||
|
||||
private void doEditFavorite(FavouritePoint favorite, String name, String category, String description,
|
||||
@ColorInt int color, BackgroundType backgroundType, @DrawableRes int iconId,
|
||||
FavouritesDbHelper helper) {
|
||||
requireMyApplication().getSettings().LAST_FAV_CATEGORY_ENTERED.set(category);
|
||||
favorite.setColor(color);
|
||||
favorite.setBackgroundType(backgroundType);
|
||||
favorite.setIconId(iconId);
|
||||
helper.editFavouriteName(favorite, name, category, description);
|
||||
}
|
||||
|
||||
private void doAddFavorite(String name, String category, String description, @ColorInt int color,
|
||||
BackgroundType backgroundType, @DrawableRes int iconId) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
|
@ -433,9 +450,22 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
public Set<String> getCategories() {
|
||||
Set<String> categories = new LinkedHashSet<>();
|
||||
FavouritesDbHelper helper = getHelper();
|
||||
if (helper != null) {
|
||||
for (FavouritesDbHelper.FavoriteGroup fg : getHelper().getFavoriteGroups()) {
|
||||
categories.add(fg.getDisplayName(getMyApplication()));
|
||||
if (helper != null && editor != null) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (editor.isNew()) {
|
||||
FavoriteGroup lastUsedGroup = helper.getGroup(getLastUsedGroup());
|
||||
if (lastUsedGroup != null) {
|
||||
categories.add(lastUsedGroup.getDisplayName(app));
|
||||
}
|
||||
for (FavouritesDbHelper.FavoriteGroup fg : getHelper().getFavoriteGroups()) {
|
||||
if (lastUsedGroup != null && !fg.equals(lastUsedGroup)) {
|
||||
categories.add(fg.getDisplayName(app));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (FavoriteGroup fg : helper.getFavoriteGroups()) {
|
||||
categories.add(fg.getDisplayName(app));
|
||||
}
|
||||
}
|
||||
}
|
||||
return categories;
|
||||
|
|
|
@ -102,7 +102,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
editor.updateLandscapePortrait(requireActivity());
|
||||
editor.updateNightMode();
|
||||
|
||||
selectedColor = 0xb4FFFFFF & getPointColor();
|
||||
selectedColor = getPointColor();
|
||||
selectedShape = getBackgroundType();
|
||||
selectedIcon = getIconId();
|
||||
|
||||
|
@ -619,12 +619,10 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
groupListAdapter.setSelectedItemName(name);
|
||||
groupListAdapter.notifyDataSetChanged();
|
||||
int position;
|
||||
if (getEditor().isNew()) {
|
||||
String lastCategory = app.getSettings().LAST_FAV_CATEGORY_ENTERED.get();
|
||||
if (!Algorithms.isEmpty(lastCategory) && !app.getFavorites().groupExists(lastCategory)) {
|
||||
lastCategory = "";
|
||||
}
|
||||
position = groupListAdapter.getItemPosition(lastCategory);
|
||||
PointEditor editor = getEditor();
|
||||
if (editor != null && editor.isNew()) {
|
||||
String lastUsedGroup = getLastUsedGroup();
|
||||
position = groupListAdapter.getItemPosition(lastUsedGroup);
|
||||
} else {
|
||||
position = groupListAdapter.items.size() == groupListAdapter.getItemPosition(name) + 1
|
||||
? groupListAdapter.getItemPosition(name) + 1
|
||||
|
@ -633,6 +631,10 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
groupRecyclerView.scrollToPosition(position);
|
||||
}
|
||||
|
||||
protected String getLastUsedGroup() {
|
||||
return "";
|
||||
}
|
||||
|
||||
protected String getDefaultCategoryName() {
|
||||
return getString(R.string.shared_string_none);
|
||||
}
|
||||
|
@ -642,15 +644,6 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
return (MapActivity) getActivity();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected OsmandApplication getMyApplication() {
|
||||
if (getActivity() == null) {
|
||||
return null;
|
||||
}
|
||||
return (OsmandApplication) getActivity().getApplication();
|
||||
}
|
||||
|
||||
public void dismiss() {
|
||||
dismiss(false);
|
||||
}
|
||||
|
|
|
@ -359,7 +359,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
|
|||
|
||||
@Override
|
||||
public void setBackgroundType(BackgroundType backgroundType) {
|
||||
this.backgroundTypeName = backgroundType.name();
|
||||
this.backgroundTypeName = backgroundType.getTypeName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue