Minor fixes

This commit is contained in:
Vitaliy 2020-11-02 03:36:07 +02:00
parent c606260def
commit 48f81f2ccc
3 changed files with 25 additions and 32 deletions

View file

@ -444,9 +444,9 @@
osmand:typeface="@string/font_roboto_medium" />
</LinearLayout>
<net.osmand.plus.widgets.FlowLayout
<LinearLayout
android:id="@+id/select_color"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/content_padding_small"
android:layout_marginLeft="@dimen/content_padding_small"
@ -458,12 +458,6 @@
android:layout_height="1dp"
android:background="?attr/dashboard_divider" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/container"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -106,6 +106,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
private EditText descriptionEdit;
private EditText addressEdit;
private int layoutHeightPrevious = 0;
private ColorsCard colorsCard;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
@ -463,22 +464,30 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
}
private void createColorSelector() {
trackColoringCard = new ColorsCard(getMapActivity(), 0, this, ColorDialogs.pallette);
trackColoringCard.setListener(this);
LinearLayout container = view.findViewById(R.id.container);
container.addView(trackColoringCard.build(getMapActivity()));
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
List<Integer> colors = new ArrayList<>();
for (int color : ColorDialogs.pallette) {
colors.add(color);
}
int customColor = getPointColor();
if (!ColorDialogs.isPaletteColor(customColor)) {
colors.add(customColor);
}
colorsCard = new ColorsCard(mapActivity, selectedColor, this, colors);
colorsCard.setListener(this);
LinearLayout selectColor = view.findViewById(R.id.select_color);
selectColor.addView(colorsCard.build(view.getContext()));
}
}
@Override
public void onColorSelected(Integer prevColor, int newColor) {
trackColoringCard.onColorSelected(prevColor, newColor);
selectedColor = trackColoringCard.getSelectedColor();
updateColorSelector(selectedColor, view);
colorsCard.onColorSelected(prevColor, newColor);
int color = colorsCard.getSelectedColor();
updateColorSelector(color, view);
}
ColorsCard trackColoringCard;
@Override
public void onCardLayoutNeeded(@NonNull BaseCard card) {
@ -487,8 +496,8 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
@Override
public void onCardPressed(@NonNull BaseCard card) {
if (card instanceof ColorsCard) {
selectedColor = ((ColorsCard) card).getSelectedColor();
updateColorSelector(selectedColor, view);
int color = ((ColorsCard) card).getSelectedColor();
updateColorSelector(color, view);
}
}
@ -498,16 +507,6 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
}
private void updateColorSelector(int color, View rootView) {
View oldColor = rootView.findViewWithTag(selectedColor);
if (oldColor != null) {
oldColor.findViewById(R.id.outline).setVisibility(View.INVISIBLE);
ImageView icon = oldColor.findViewById(R.id.icon);
icon.setImageDrawable(UiUtilities.tintDrawable(icon.getDrawable(), R.color.icon_color_default_light));
}
View newColor = rootView.findViewWithTag(color);
if (newColor != null) {
newColor.findViewById(R.id.outline).setVisibility(View.VISIBLE);
}
((TextView) view.findViewById(R.id.color_name)).setText(ColorDialogs.getColorName(color));
selectedColor = color;
setColor(color);

View file

@ -40,7 +40,7 @@ public class ColorsCard extends BaseCard implements ColorPickerListener {
private Fragment targetFragment;
private int[] colors;
private List<Integer> colors;
private List<Integer> customColors;
private int selectedColor;
@ -50,7 +50,7 @@ public class ColorsCard extends BaseCard implements ColorPickerListener {
return R.layout.colors_card;
}
public ColorsCard(MapActivity mapActivity, int selectedColor, Fragment targetFragment, int[] colors) {
public ColorsCard(MapActivity mapActivity, int selectedColor, Fragment targetFragment, List<Integer> colors) {
super(mapActivity);
this.targetFragment = targetFragment;
this.selectedColor = selectedColor;