Fix background type.
This commit is contained in:
parent
0ff96f333b
commit
889ac143d3
7 changed files with 117 additions and 56 deletions
7
OsmAnd/res/drawable/bg_point_circle_contour.xml
Normal file
7
OsmAnd/res/drawable/bg_point_circle_contour.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="@android:color/transparent" />
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="@color/divider_color_light" />
|
||||
</shape>
|
10
OsmAnd/res/drawable/bg_point_rhomb_contour.xml
Normal file
10
OsmAnd/res/drawable/bg_point_rhomb_contour.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="40dp"
|
||||
android:height="40dp"
|
||||
android:viewportWidth="40"
|
||||
android:viewportHeight="40">
|
||||
<path
|
||||
android:pathData="M21.7071,0.7071L39.2929,18.2929C39.7456,18.7456 40,19.3597 40,20C40,20.6403 39.7456,21.2544 39.2929,21.7071L21.7071,39.2929C21.2544,39.7456 20.6403,40 20,40C19.3597,40 18.7456,39.7456 18.2929,39.2929L0.7071,21.7071C0.2544,21.2544 0,20.6403 0,20C0,19.3597 0.2544,18.7456 0.7071,18.2929L18.2929,0.7071C18.7456,0.2544 19.3597,0 20,0C20.6403,0 21.2544,0.2544 21.7071,0.7071Z"
|
||||
android:strokeWidth="2"
|
||||
android:strokeColor="#e6e6e6" />
|
||||
</vector>
|
10
OsmAnd/res/drawable/bg_point_square_contour.xml
Normal file
10
OsmAnd/res/drawable/bg_point_square_contour.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="48dp"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="40"
|
||||
android:viewportHeight="40">
|
||||
<path
|
||||
android:pathData="M4,1L36,1A3,3 0,0 1,39 4L39,36A3,3 0,0 1,36 39L4,39A3,3 0,0 1,1 36L1,4A3,3 0,0 1,4 1z"
|
||||
android:strokeWidth="2"
|
||||
android:strokeColor="#e6e6e6"/>
|
||||
</vector>
|
|
@ -206,7 +206,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
|||
return backgroundType;
|
||||
}
|
||||
|
||||
private void setBackgroundType(BackgroundType backgroundType) {
|
||||
public void setBackgroundType(BackgroundType backgroundType) {
|
||||
this.backgroundType = backgroundType;
|
||||
}
|
||||
|
||||
|
|
|
@ -302,7 +302,9 @@ public class FavouritesDbHelper {
|
|||
if (FavouritePoint.SpecialPointType.PARKING.equals(p.getSpecialPointType())) {
|
||||
p.setColor(ContextCompat.getColor(context, R.color.map_widget_blue));
|
||||
} else {
|
||||
p.setColor(group.color);
|
||||
if (p.getColor() == 0) {
|
||||
p.setColor(group.color);
|
||||
}
|
||||
}
|
||||
group.points.add(p);
|
||||
cachedFavoritePoints.add(p);
|
||||
|
@ -440,7 +442,9 @@ public class FavouritesDbHelper {
|
|||
if (FavouritePoint.SpecialPointType.PARKING.equals(p.getSpecialPointType())) {
|
||||
p.setColor(ContextCompat.getColor(context, R.color.map_widget_blue));
|
||||
} else {
|
||||
p.setColor(pg.color);
|
||||
if (p.getColor() == 0) {
|
||||
p.setColor(pg.color);
|
||||
}
|
||||
}
|
||||
pg.points.add(p);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
@ -38,8 +40,10 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
private FavouritePoint favorite;
|
||||
@Nullable
|
||||
private FavoriteGroup group;
|
||||
|
||||
private int color;
|
||||
private int iconId;
|
||||
@NonNull
|
||||
private FavouritePoint.BackgroundType backgroundType = FavouritePoint.BackgroundType.CIRCLE;
|
||||
|
||||
@Nullable
|
||||
FavouritesDbHelper helper;
|
||||
|
@ -71,6 +75,8 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
this.favorite = favorite;
|
||||
this.group = helper.getGroup(favorite);
|
||||
this.color = favorite.getColor();
|
||||
this.backgroundType = favorite.getBackgroundType();
|
||||
this.iconId = favorite.getIconId();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,7 +182,16 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
@Override
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundType(@NonNull FavouritePoint.BackgroundType backgroundType) {
|
||||
this.backgroundType = backgroundType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIcon(int iconId) {
|
||||
this.iconId = iconId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -226,11 +241,12 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(),
|
||||
getNameTextValue(), getCategoryTextValue());
|
||||
point.setDescription(getDescriptionTextValue());
|
||||
point.setColor(color);
|
||||
point.setBackgroundType(backgroundType);
|
||||
point.setIconId(iconId);
|
||||
AlertDialog.Builder builder = FavouritesDbHelper.checkDuplicates(point, helper, getMapActivity());
|
||||
|
||||
if (favorite.getName().equals(point.getName()) &&
|
||||
favorite.getCategory().equals(point.getCategory()) &&
|
||||
Algorithms.stringsEqual(favorite.getDescription(), point.getDescription())) {
|
||||
if (isChanged(favorite, point)) {
|
||||
|
||||
if (needDismiss) {
|
||||
dismiss(false);
|
||||
|
@ -242,24 +258,39 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
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.getColor(), point.getBackgroundType(), point.getIconId(), needDismiss);
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
} else {
|
||||
doSave(favorite, point.getName(), point.getCategory(), point.getDescription(), needDismiss);
|
||||
doSave(favorite, point.getName(), point.getCategory(), point.getDescription(),
|
||||
point.getColor(), point.getBackgroundType(), point.getIconId(), needDismiss);
|
||||
}
|
||||
saved = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void doSave(FavouritePoint favorite, String name, String category, String description, boolean needDismiss) {
|
||||
private boolean isChanged(FavouritePoint favorite, FavouritePoint point) {
|
||||
return favorite.getColor() == point.getColor() &&
|
||||
favorite.getIconId() == point.getIconId() &&
|
||||
favorite.getName().equals(point.getName()) &&
|
||||
favorite.getCategory().equals(point.getCategory()) &&
|
||||
favorite.getBackgroundType().equals(point.getBackgroundType()) &&
|
||||
Algorithms.stringsEqual(favorite.getDescription(), point.getDescription());
|
||||
}
|
||||
|
||||
private void doSave(FavouritePoint favorite, String name, String category, String description,
|
||||
@ColorInt int color, FavouritePoint.BackgroundType backgroundType, @DrawableRes int iconId, boolean needDismiss) {
|
||||
FavouritesDbHelper helper = getHelper();
|
||||
FavoritePointEditor editor = getFavoritePointEditor();
|
||||
if (editor != null && helper != null) {
|
||||
if (editor.isNew()) {
|
||||
doAddFavorite(name, category, description);
|
||||
doAddFavorite(name, category, description, color, backgroundType, iconId);
|
||||
} else {
|
||||
favorite.setColor(color);
|
||||
favorite.setBackgroundType(backgroundType);
|
||||
favorite.setIconId(iconId);
|
||||
helper.editFavouriteName(favorite, name, category, description);
|
||||
}
|
||||
}
|
||||
|
@ -279,7 +310,8 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
}
|
||||
}
|
||||
|
||||
private void doAddFavorite(String name, String category, String description) {
|
||||
private void doAddFavorite(String name, String category, String description, @ColorInt int color,
|
||||
FavouritePoint.BackgroundType backgroundType, @DrawableRes int iconId) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
FavouritesDbHelper helper = getHelper();
|
||||
FavouritePoint favorite = getFavorite();
|
||||
|
@ -287,6 +319,9 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
favorite.setName(name);
|
||||
favorite.setCategory(category);
|
||||
favorite.setDescription(description);
|
||||
favorite.setColor(color);
|
||||
favorite.setBackgroundType(backgroundType);
|
||||
favorite.setIconId(iconId);
|
||||
app.getSettings().LAST_FAV_CATEGORY_ENTERED.set(category);
|
||||
helper.addFavourite(favorite);
|
||||
}
|
||||
|
@ -374,6 +409,12 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
return color;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public FavouritePoint.BackgroundType getBackgroundType() {
|
||||
return backgroundType;
|
||||
}
|
||||
|
||||
private int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
private Button addDelDescription;
|
||||
private boolean cancelled;
|
||||
private boolean nightMode;
|
||||
private String selectedIcon;
|
||||
private int selectedIcon;
|
||||
@ColorInt
|
||||
private int selectedColor;
|
||||
private FavouritePoint.BackgroundType selectedShape = FavouritePoint.BackgroundType.CIRCLE;
|
||||
|
@ -91,6 +91,8 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
editor.updateNightMode();
|
||||
|
||||
selectedColor = 0xb4FFFFFF & getPointColor();
|
||||
selectedShape = getBackgroundType();
|
||||
selectedIcon = R.drawable.mx_special_star;
|
||||
|
||||
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
|
||||
toolbar.setTitle(getToolbarTitle());
|
||||
|
@ -115,10 +117,6 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
replaceIcon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_replace, activeColorResId));
|
||||
ImageView deleteIcon = (ImageView) view.findViewById(R.id.delete_action_icon);
|
||||
deleteIcon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_delete_dark, activeColorResId));
|
||||
|
||||
// ((TextView)view.findViewById(R.id.replace_action_title)).setTextColor(ContextCompat.getColor(app,activeColorResId));
|
||||
// ((TextView)view.findViewById(R.id.replace_action_description)).setTextColor(ContextCompat.getColor(app,activeColorResId));
|
||||
// ((TextView)view.findViewById(R.id.delete_action_title)).setTextColor(ContextCompat.getColor(app,activeColorResId));
|
||||
View groupList = view.findViewById(R.id.group_list_button);
|
||||
groupList.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -239,16 +237,6 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
|
||||
private void createGroupSelector(OsmandApplication app) {
|
||||
GroupAdapter groupListAdapter = new GroupAdapter(app);
|
||||
groupListAdapter.setItemClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// int position = groupListAdapter.getChildAdapterPosition(v);
|
||||
// if (position == RecyclerView.NO_POSITION) {
|
||||
// return;
|
||||
// }
|
||||
// selectFavorite(favouritePoints.get(position));
|
||||
}
|
||||
});
|
||||
groupListAdapter.setSelectedItemName(getCategoryInitValue());
|
||||
RecyclerView groupRecyclerView = view.findViewById(R.id.group_recycler_view);
|
||||
groupRecyclerView.setAdapter(groupListAdapter);
|
||||
|
@ -256,6 +244,9 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
groupListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void selectIconGroup() {
|
||||
}
|
||||
|
||||
private void createColorSelector() {
|
||||
FlowLayout selectColor = view.findViewById(R.id.select_color);
|
||||
for (int color : ColorDialogs.pallette) {
|
||||
|
@ -289,19 +280,13 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
icon.setImageDrawable(UiUtilities.tintDrawable(icon.getDrawable(), R.color.icon_color_default_light));
|
||||
}
|
||||
rootView.findViewWithTag(color).findViewById(R.id.outline).setVisibility(View.VISIBLE);
|
||||
View icon = rootView.findViewWithTag(selectedIcon);
|
||||
if (icon != null) {
|
||||
ImageView iconImage = icon.findViewById(R.id.icon);
|
||||
iconImage.setImageDrawable(UiUtilities.tintDrawable(iconImage.getDrawable(), R.color.white_50_transparent));
|
||||
ImageView backgroundCircle = view.findViewById(R.id.background);
|
||||
AndroidUtils.setBackground(backgroundCircle,
|
||||
UiUtilities.tintDrawable(ContextCompat.getDrawable(view.getContext(), selectedShape.getIconId()), color));
|
||||
}
|
||||
|
||||
((TextView) view.findViewById(R.id.color_name)).setText(ColorDialogs.getColorName(color));
|
||||
selectedColor = color;
|
||||
setColor(color);
|
||||
updateNameIcon();
|
||||
updateShapeSelector();
|
||||
updateShapeSelector(selectedShape, view);
|
||||
updateIconSelector(selectedIcon, view);
|
||||
}
|
||||
|
||||
private void createShapeSelector() {
|
||||
|
@ -339,10 +324,6 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
return app.getUIUtilities().getIcon(iconRes, R.color.divider_color_light);
|
||||
}
|
||||
|
||||
private void updateShapeSelector() {
|
||||
updateShapeSelector(selectedShape, view);
|
||||
}
|
||||
|
||||
private void updateShapeSelector(FavouritePoint.BackgroundType backgroundType, View rootView) {
|
||||
View oldShape = rootView.findViewWithTag(selectedShape);
|
||||
if (oldShape != null) {
|
||||
|
@ -360,6 +341,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
UiUtilities.tintDrawable(ContextCompat.getDrawable(requireMyApplication(), backgroundType.getIconId()),
|
||||
selectedColor));
|
||||
selectedShape = backgroundType;
|
||||
setBackgroundType(backgroundType);
|
||||
}
|
||||
|
||||
private void createIconSelector() {
|
||||
|
@ -375,7 +357,6 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String selectedIconCategory = group.keySet().iterator().next();
|
||||
FlowLayout selectIcon = view.findViewById(R.id.select_icon);
|
||||
JSONArray iconJsonArray = group.get(selectedIconCategory);
|
||||
|
@ -388,14 +369,12 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
GroupNameAdapter groupNameListAdapter = new GroupNameAdapter();
|
||||
groupNameListAdapter.setItems(new ArrayList<>(group.keySet()));
|
||||
RecyclerView groupNameRecyclerView = view.findViewById(R.id.group_name_recycler_view);
|
||||
groupNameRecyclerView.setAdapter(groupNameListAdapter);
|
||||
groupNameRecyclerView.setLayoutManager(new LinearLayoutManager(requireMyApplication(), RecyclerView.HORIZONTAL, false));
|
||||
groupNameListAdapter.notifyDataSetChanged();
|
||||
|
||||
for (String name : iconNameList) {
|
||||
selectIcon.addView(createIconItemView(name, selectIcon), new FlowLayout.LayoutParams(0, 0));
|
||||
}
|
||||
|
@ -420,24 +399,32 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
updateIconSelector(iconRes, rootView);
|
||||
}
|
||||
});
|
||||
iconItemView.setTag(String.valueOf(iconRes));
|
||||
iconItemView.setTag(iconRes);
|
||||
return iconItemView;
|
||||
}
|
||||
|
||||
private void updateIconSelector(int iconRes, ViewGroup rootView) {
|
||||
// setIconNewColor(iconRes);
|
||||
private void updateIconSelector(int iconRes, View rootView) {
|
||||
View oldIcon = rootView.findViewWithTag(selectedIcon);
|
||||
if (oldIcon != null) {
|
||||
oldIcon.findViewById(R.id.outline).setVisibility(View.INVISIBLE);
|
||||
ImageView background = oldIcon.findViewById(R.id.background);
|
||||
AndroidUtils.setBackground(background,
|
||||
UiUtilities.tintDrawable(ContextCompat.getDrawable(requireMyApplication(), R.drawable.bg_point_circle),
|
||||
ContextCompat.getColor(requireMyApplication(), R.color.divider_color_light)));
|
||||
}
|
||||
rootView.findViewWithTag(String.valueOf(iconRes)).findViewById(R.id.outline).setVisibility(View.VISIBLE);
|
||||
|
||||
// checkMark.setImageDrawable(app.getUIUtilities().getIcon(changedProfile.iconRes, R.color.icon_color_default_light));
|
||||
// AndroidUtils.setBackground(oldIcon.findViewById(R.id.backgroundCircle),
|
||||
// UiUtilities.tintDrawable(ContextCompat.getDrawable(app, R.drawable.circle_background_light),
|
||||
// UiUtilities.getColorWithAlpha(ContextCompat.getColor(app, R.color.icon_color_default_light), 0.1f)));
|
||||
selectedIcon = String.valueOf(iconRes);
|
||||
View icon = rootView.findViewWithTag(iconRes);
|
||||
if (icon != null) {
|
||||
ImageView iconImage = icon.findViewById(R.id.icon);
|
||||
icon.findViewById(R.id.outline).setVisibility(View.VISIBLE);
|
||||
iconImage.setImageDrawable(UiUtilities.tintDrawable(iconImage.getDrawable(), R.color.white_50_transparent));
|
||||
ImageView backgroundCircle = icon.findViewById(R.id.background);
|
||||
AndroidUtils.setBackground(backgroundCircle,
|
||||
UiUtilities.tintDrawable(ContextCompat.getDrawable(view.getContext(), R.drawable.bg_point_circle), selectedColor));
|
||||
}
|
||||
selectedIcon = iconRes;
|
||||
updateNameIcon();
|
||||
setIcon(iconRes);
|
||||
}
|
||||
|
||||
private void updateNameIcon() {
|
||||
|
@ -586,6 +573,10 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
|
||||
public abstract void setColor(int color);
|
||||
|
||||
public abstract void setBackgroundType(FavouritePoint.BackgroundType backgroundType);
|
||||
|
||||
public abstract void setIcon(int iconId);
|
||||
|
||||
protected String getDefaultCategoryName() {
|
||||
return getString(R.string.shared_string_none);
|
||||
}
|
||||
|
@ -636,6 +627,8 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
|
||||
public abstract int getPointColor();
|
||||
|
||||
public abstract FavouritePoint.BackgroundType getBackgroundType();
|
||||
|
||||
public abstract Set<String> getCategories();
|
||||
|
||||
String getNameTextValue() {
|
||||
|
@ -759,10 +752,6 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
return items == null ? 0 : items.size() + 1;
|
||||
}
|
||||
|
||||
void setItemClickListener(View.OnClickListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
String getSelectedItem() {
|
||||
return selectedItemName;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue