Remove default gpx color and width

This commit is contained in:
Vitaliy 2020-09-15 16:13:08 +03:00
parent 86774adf54
commit 3bc6ec76ed
4 changed files with 24 additions and 21 deletions

View file

@ -21,6 +21,7 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="@dimen/context_menu_padding_margin_tiny"
android:visibility="gone"
android:paddingBottom="@dimen/content_padding">
<androidx.recyclerview.widget.RecyclerView

View file

@ -113,30 +113,27 @@ public class GpxAppearanceAdapter extends ArrayAdapter<GpxAppearanceAdapter.Appe
}
if (trackWidthProp != null) {
AppearanceListItem item = new AppearanceListItem(ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR, "",
SettingsActivity.getStringPropertyValue(app, trackWidthProp.getDefaultValueDescription()));
items.add(item);
for (int j = 0; j < trackWidthProp.getPossibleValues().length; j++) {
item = new AppearanceListItem(ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR,
AppearanceListItem item = new AppearanceListItem(ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR,
trackWidthProp.getPossibleValues()[j],
SettingsActivity.getStringPropertyValue(app, trackWidthProp.getPossibleValues()[j]));
items.add(item);
if (j == trackWidthProp.getPossibleValues().length - 1) {
item.setLastItem(true);
}
}
item.setLastItem(true);
}
if (trackColorProp != null) {
AppearanceListItem item = new AppearanceListItem(ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR, "",
SettingsActivity.getStringPropertyValue(app, trackColorProp.getDefaultValueDescription()),
parseTrackColor(renderer, ""));
items.add(item);
for (int j = 0; j < trackColorProp.getPossibleValues().length; j++) {
item = new AppearanceListItem(ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR,
AppearanceListItem item = new AppearanceListItem(ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR,
trackColorProp.getPossibleValues()[j],
SettingsActivity.getStringPropertyValue(app, trackColorProp.getPossibleValues()[j]),
parseTrackColor(renderer, trackColorProp.getPossibleValues()[j]));
items.add(item);
if (j == trackColorProp.getPossibleValues().length - 1) {
item.setLastItem(true);
}
}
item.setLastItem(true);
}
return items;
}

View file

@ -17,7 +17,6 @@ import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.ColorUtils;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.internal.FlowLayout;
@ -81,10 +80,10 @@ public class TrackColoringCard extends BaseCard implements ColorPickerListener {
createColorSelector();
updateColorSelector();
coloringAdapter = new TrackColoringAdapter(appearanceItems);
RecyclerView groupRecyclerView = view.findViewById(R.id.recycler_view);
groupRecyclerView.setAdapter(coloringAdapter);
groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
// coloringAdapter = new TrackColoringAdapter(appearanceItems);
// RecyclerView groupRecyclerView = view.findViewById(R.id.recycler_view);
// groupRecyclerView.setAdapter(coloringAdapter);
// groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
AndroidUiHelper.updateVisibility(view.findViewById(R.id.top_divider), isShowDivider());
}
@ -156,7 +155,7 @@ public class TrackColoringCard extends BaseCard implements ColorPickerListener {
@Override
public void onClick(View v) {
updateColorSelector(color, rootView);
coloringAdapter.notifyDataSetChanged();
// coloringAdapter.notifyDataSetChanged();
trackDrawInfo.setColor(color);
CardListener listener = getListener();

View file

@ -8,6 +8,7 @@ import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
@ -71,13 +72,14 @@ public class TrackWidthCard extends BaseCard {
}
}
@Nullable
private AppearanceListItem getSelectedItem() {
if (selectedItem == null) {
String selectedWidth = trackDrawInfo.getWidth();
for (AppearanceListItem item : appearanceItems) {
if (Algorithms.objectEquals(item.getValue(), selectedWidth)
if (selectedWidth != null && (Algorithms.objectEquals(item.getValue(), selectedWidth)
|| Algorithms.isEmpty(selectedWidth) && Algorithms.isEmpty(item.getValue())
|| Algorithms.isInt(selectedWidth) && CUSTOM_WIDTH.equals(item.getAttrName())) {
|| Algorithms.isInt(selectedWidth) && CUSTOM_WIDTH.equals(item.getAttrName()))) {
selectedItem = item;
break;
}
@ -106,11 +108,15 @@ public class TrackWidthCard extends BaseCard {
titleView.setText(R.string.select_track_width);
TextView descriptionView = view.findViewById(R.id.description);
descriptionView.setText(getSelectedItem().getLocalizedValue());
AppearanceListItem item = getSelectedItem();
if (item != null) {
descriptionView.setText(item.getLocalizedValue());
}
}
private void updateCustomWidthSlider() {
if (CUSTOM_WIDTH.equals(getSelectedItem().getAttrName())) {
AppearanceListItem item = getSelectedItem();
if (item != null && CUSTOM_WIDTH.equals(item.getAttrName())) {
Slider widthSlider = view.findViewById(R.id.width_slider);
widthSlider.setValueTo(CUSTOM_WIDTH_MAX);