Fix element's alignment: icons and colors
https://github.com/osmandapp/OsmAnd-Issues/issues/472
This commit is contained in:
parent
0125820d76
commit
7a738dd55c
8 changed files with 120 additions and 101 deletions
|
@ -1,16 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.internal.FlowLayout
|
||||
<net.osmand.plus.widgets.FlowLayout
|
||||
android:id="@+id/select_color"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/content_padding_small"
|
||||
android:layout_marginLeft="@dimen/content_padding_small"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:layout_marginTop="@dimen/context_menu_padding_margin_tiny"
|
||||
android:layout_marginBottom="@dimen/content_padding_half" />
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@
|
|||
android:drawableEnd="@drawable/btn_circle_transparent_full"
|
||||
android:drawableRight="@drawable/btn_circle_transparent_full"
|
||||
android:drawablePadding="@dimen/favorites_list_item_height"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="textMultiLine"
|
||||
android:maxLines="4"
|
||||
android:minHeight="@dimen/favorites_list_item_height"
|
||||
|
@ -93,7 +94,6 @@
|
|||
android:paddingRight="@dimen/content_padding_small"
|
||||
android:scrollHorizontally="false"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
android:imeOptions="actionDone"
|
||||
tools:text="@string/lorem_ipsum" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
@ -137,6 +137,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="start"
|
||||
android:imeOptions="actionDone"
|
||||
android:maxLines="4"
|
||||
android:minHeight="@dimen/favorites_list_item_height"
|
||||
android:paddingStart="@dimen/content_padding_small"
|
||||
|
@ -144,7 +145,6 @@
|
|||
android:paddingEnd="@dimen/content_padding_small"
|
||||
android:paddingRight="@dimen/content_padding_small"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
android:imeOptions="actionDone"
|
||||
tools:text="@string/lorem_ipsum" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
@ -248,6 +248,7 @@
|
|||
android:drawablePadding="8dp"
|
||||
android:duplicateParentState="true"
|
||||
android:gravity="center"
|
||||
android:imeOptions="actionDone"
|
||||
android:paddingStart="@dimen/content_padding_half"
|
||||
android:paddingLeft="@dimen/content_padding_half"
|
||||
android:paddingEnd="@dimen/content_padding_half"
|
||||
|
@ -255,7 +256,6 @@
|
|||
android:text="@string/add_description"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:imeOptions="actionDone"
|
||||
tools:text="@string/add_description" />
|
||||
|
||||
<View
|
||||
|
@ -402,9 +402,11 @@
|
|||
android:id="@+id/select_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/content_padding_small"
|
||||
android:layout_marginLeft="@dimen/content_padding_small"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginTop="@dimen/context_menu_padding_margin_tiny"
|
||||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:layout_marginBottom="@dimen/content_padding_half" />
|
||||
|
||||
<View
|
||||
|
@ -447,12 +449,10 @@
|
|||
osmand:typeface="@string/font_roboto_medium" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
<net.osmand.plus.widgets.FlowLayout
|
||||
android:id="@+id/select_color"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/content_padding_small"
|
||||
android:layout_marginLeft="@dimen/content_padding_small"
|
||||
android:layout_marginTop="@dimen/context_menu_padding_margin_tiny"
|
||||
android:layout_marginBottom="@dimen/content_padding_half" />
|
||||
|
||||
|
@ -500,9 +500,11 @@
|
|||
android:id="@+id/select_shape"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/content_padding_small"
|
||||
android:layout_marginLeft="@dimen/content_padding_small"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginTop="@dimen/context_menu_padding_margin_tiny"
|
||||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:layout_marginBottom="@dimen/content_padding_half"
|
||||
android:gravity="start" />
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="@dimen/context_menu_padding_margin_tiny"
|
||||
android:visibility="gone"
|
||||
android:paddingBottom="@dimen/content_padding">
|
||||
android:paddingBottom="@dimen/content_padding"
|
||||
android:visibility="gone">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
|
@ -41,13 +41,15 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.internal.FlowLayout
|
||||
<net.osmand.plus.widgets.FlowLayout
|
||||
android:id="@+id/select_color"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/content_padding_small"
|
||||
android:layout_marginLeft="@dimen/content_padding_small"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginTop="@dimen/context_menu_padding_margin_tiny"
|
||||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:layout_marginBottom="@dimen/content_padding_half" />
|
||||
|
||||
</LinearLayout>
|
|
@ -22,7 +22,6 @@ import android.view.inputmethod.InputMethodManager;
|
|||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -66,6 +65,7 @@ import org.json.JSONObject;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
@ -124,7 +124,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
|||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
app = requireMyApplication();
|
||||
nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
||||
|
@ -144,7 +144,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
|||
selectedShape = getBackgroundType();
|
||||
selectedIcon = getIconId();
|
||||
|
||||
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
|
||||
Toolbar toolbar = view.findViewById(R.id.toolbar);
|
||||
toolbar.setBackgroundColor(ContextCompat.getColor(requireContext(),
|
||||
nightMode ? R.color.app_bar_color_dark : R.color.list_background_color_light));
|
||||
toolbar.setTitle(getToolbarTitle());
|
||||
|
@ -159,7 +159,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
|||
}
|
||||
});
|
||||
|
||||
final ScrollView scrollView = (ScrollView) view.findViewById(R.id.editor_scroll_view);
|
||||
final ScrollView scrollView = view.findViewById(R.id.editor_scroll_view);
|
||||
scrollViewY = scrollView.getScrollY();
|
||||
scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
|
||||
@Override
|
||||
|
@ -175,14 +175,14 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
|||
});
|
||||
|
||||
final int activeColorResId = getActiveColorRes();
|
||||
ImageView toolbarAction = (ImageView) view.findViewById(R.id.toolbar_action);
|
||||
ImageView toolbarAction = view.findViewById(R.id.toolbar_action);
|
||||
view.findViewById(R.id.background_layout).setBackgroundResource(nightMode
|
||||
? R.color.app_bar_color_dark : R.color.list_background_color_light);
|
||||
ImageView replaceIcon = (ImageView) view.findViewById(R.id.replace_action_icon);
|
||||
ImageView replaceIcon = view.findViewById(R.id.replace_action_icon);
|
||||
replaceIcon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_replace, activeColorResId));
|
||||
ImageView deleteIcon = (ImageView) view.findViewById(R.id.delete_action_icon);
|
||||
ImageView deleteIcon = view.findViewById(R.id.delete_action_icon);
|
||||
deleteIcon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_delete_dark, activeColorResId));
|
||||
ImageView groupListIcon = (ImageView) view.findViewById(R.id.group_list_button_icon);
|
||||
ImageView groupListIcon = view.findViewById(R.id.group_list_button_icon);
|
||||
groupListIcon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_group_select_all, activeColorResId));
|
||||
addToHiddenGroupInfo = view.findViewById(R.id.add_hidden_group_info);
|
||||
addToHiddenGroupInfo.setText(getString(R.string.add_hidden_group_info, getString(R.string.shared_string_my_places)));
|
||||
|
@ -217,10 +217,10 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
|||
UiUtilities.setupDialogButton(nightMode, cancelButton, UiUtilities.DialogButtonType.SECONDARY, R.string.shared_string_cancel);
|
||||
UiUtilities.setupDialogButton(nightMode, saveButton, UiUtilities.DialogButtonType.PRIMARY, R.string.shared_string_save);
|
||||
|
||||
final TextInputLayout nameCaption = (TextInputLayout) view.findViewById(R.id.name_caption);
|
||||
final TextInputLayout nameCaption = view.findViewById(R.id.name_caption);
|
||||
nameCaption.setHint(getString(R.string.shared_string_name));
|
||||
|
||||
nameEdit = (EditText) view.findViewById(R.id.name_edit);
|
||||
nameEdit = view.findViewById(R.id.name_edit);
|
||||
nameEdit.setText(getNameInitValue());
|
||||
nameEdit.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
|
@ -238,15 +238,15 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
|||
});
|
||||
|
||||
checkEmptyName(nameEdit.getText(), nameCaption, saveButton);
|
||||
nameIcon = (ImageView) view.findViewById(R.id.name_icon);
|
||||
nameIcon = view.findViewById(R.id.name_icon);
|
||||
TextView categoryEdit = view.findViewById(R.id.groupName);
|
||||
if (categoryEdit != null) {
|
||||
AndroidUtils.setTextPrimaryColor(view.getContext(), categoryEdit, nightMode);
|
||||
categoryEdit.setText(getCategoryInitValue());
|
||||
}
|
||||
|
||||
descriptionEdit = (EditText) view.findViewById(R.id.description_edit);
|
||||
addressEdit = (EditText) view.findViewById(R.id.address_edit);
|
||||
descriptionEdit = view.findViewById(R.id.description_edit);
|
||||
addressEdit = view.findViewById(R.id.address_edit);
|
||||
AndroidUtils.setTextPrimaryColor(view.getContext(), descriptionEdit, nightMode);
|
||||
AndroidUtils.setTextPrimaryColor(view.getContext(), addressEdit, nightMode);
|
||||
AndroidUtils.setHintTextSecondaryColor(view.getContext(), descriptionEdit, nightMode);
|
||||
|
@ -257,7 +257,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
|||
|
||||
descriptionCaption = view.findViewById(R.id.description);
|
||||
addressCaption = view.findViewById(R.id.address);
|
||||
addDelDescription = (TextView) view.findViewById(R.id.description_button);
|
||||
addDelDescription = view.findViewById(R.id.description_button);
|
||||
addAddressBtn = view.findViewById(R.id.address_button);
|
||||
deleteAddressIcon = view.findViewById(R.id.delete_address_icon);
|
||||
deleteAddressIcon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_trash_basket_16, activeColorResId));
|
||||
|
@ -476,8 +476,9 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
|||
}
|
||||
colorsCard = new ColorsCard(mapActivity, selectedColor, this, colors);
|
||||
colorsCard.setListener(this);
|
||||
LinearLayout selectColor = view.findViewById(R.id.select_color);
|
||||
selectColor.addView(colorsCard.build(view.getContext()));
|
||||
FlowLayout selectColor = view.findViewById(R.id.select_color);
|
||||
selectColor.addView(colorsCard.build(view.getContext()),
|
||||
new FlowLayout.LayoutParams(0, 0, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -520,7 +521,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
|||
for (BackgroundType backgroundType : BackgroundType.values()) {
|
||||
if (backgroundType.isSelected()) {
|
||||
selectShape.addView(createShapeItemView(backgroundType, selectShape),
|
||||
new FlowLayout.LayoutParams(0, 0));
|
||||
new FlowLayout.LayoutParams(0, 0, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -561,7 +562,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
|||
((TextView) rootView.findViewById(R.id.shape_name)).setText(backgroundType.getNameId());
|
||||
ImageView background = newShape.findViewById(R.id.background);
|
||||
background.setImageDrawable(UiUtilities.tintDrawable(AppCompatResources.getDrawable(app, backgroundType.getIconId()),
|
||||
selectedColor));
|
||||
selectedColor));
|
||||
selectedShape = backgroundType;
|
||||
setBackgroundType(backgroundType);
|
||||
updateNameIcon();
|
||||
|
@ -569,9 +570,9 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
|||
|
||||
private void setShapeSelectorBackground(BackgroundType backgroundType, ImageView background) {
|
||||
background.setImageDrawable(UiUtilities.tintDrawable(AppCompatResources.getDrawable(app, backgroundType.getIconId()),
|
||||
ContextCompat.getColor(app,
|
||||
nightMode ? R.color.inactive_buttons_and_links_bg_dark
|
||||
: R.color.inactive_buttons_and_links_bg_light)));
|
||||
ContextCompat.getColor(app,
|
||||
nightMode ? R.color.inactive_buttons_and_links_bg_dark
|
||||
: R.color.inactive_buttons_and_links_bg_light)));
|
||||
}
|
||||
|
||||
private String getInitCategory() {
|
||||
|
@ -643,7 +644,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
|||
horizontalSelectionAdapter.notifyDataSetChanged();
|
||||
iconCategoriesRecyclerView.smoothScrollToPosition(horizontalSelectionAdapter.getItemPositionByTitle(selectedIconCategory));
|
||||
for (String name : iconNameList) {
|
||||
selectIcon.addView(createIconItemView(name, selectIcon), new FlowLayout.LayoutParams(0, 0));
|
||||
selectIcon.addView(createIconItemView(name, selectIcon), new FlowLayout.LayoutParams(0, 0, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -701,9 +702,9 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
|||
|
||||
private void setIconSelectorBackground(ImageView backgroundCircle) {
|
||||
backgroundCircle.setImageDrawable(UiUtilities.tintDrawable(AppCompatResources.getDrawable(app, R.drawable.bg_point_circle),
|
||||
ContextCompat.getColor(app, nightMode
|
||||
? R.color.inactive_buttons_and_links_bg_dark
|
||||
: R.color.inactive_buttons_and_links_bg_light)));
|
||||
ContextCompat.getColor(app, nightMode
|
||||
? R.color.inactive_buttons_and_links_bg_dark
|
||||
: R.color.inactive_buttons_and_links_bg_light)));
|
||||
}
|
||||
|
||||
private void updateNameIcon() {
|
||||
|
@ -720,7 +721,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
|||
byte[] buffer = new byte[size];
|
||||
is.read(buffer);
|
||||
is.close();
|
||||
json = new String(buffer, "UTF-8");
|
||||
json = new String(buffer, StandardCharsets.UTF_8);
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
|
@ -887,8 +888,6 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
|||
return true;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
String getNameTextValue() {
|
||||
EditText nameEdit = view.findViewById(R.id.name_edit);
|
||||
return nameEdit.getText().toString().trim();
|
||||
|
|
|
@ -294,8 +294,8 @@ public class PublicTransportCard extends BaseCard {
|
|||
if (walkingSegment != null) {
|
||||
double walkTime = walkingSegment.getRoutingTime();
|
||||
if (walkTime > MIN_WALK_TIME) {
|
||||
routesBadges.addView(createWalkRouteBadge(walkingSegment, badgesRowClickable), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
|
||||
routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
|
||||
routesBadges.addView(createWalkRouteBadge(walkingSegment, badgesRowClickable), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing, false));
|
||||
routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing, false));
|
||||
}
|
||||
} else if (s.walkDist > 0) {
|
||||
double walkTime = getWalkTime(s.walkDist, routeResult.getWalkSpeed());
|
||||
|
@ -307,20 +307,20 @@ public class PublicTransportCard extends BaseCard {
|
|||
} else {
|
||||
start = this.startLocation;
|
||||
}
|
||||
routesBadges.addView(createWalkRouteBadge(walkTime, start, end, badgesRowClickable), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
|
||||
routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
|
||||
routesBadges.addView(createWalkRouteBadge(walkTime, start, end, badgesRowClickable), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing, false));
|
||||
routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing, false));
|
||||
}
|
||||
}
|
||||
routesBadges.addView(createRouteBadge(s, badgesRowClickable), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
|
||||
routesBadges.addView(createRouteBadge(s, badgesRowClickable), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing, false));
|
||||
if (iterator.hasNext()) {
|
||||
routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
|
||||
routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing, false));
|
||||
} else {
|
||||
walkingSegment = transportRoutingHelper.getWalkingRouteSegment(s, null);
|
||||
if (walkingSegment != null) {
|
||||
double walkTime = walkingSegment.getRoutingTime();
|
||||
if (walkTime > MIN_WALK_TIME) {
|
||||
routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
|
||||
routesBadges.addView(createWalkRouteBadge(walkingSegment, badgesRowClickable), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
|
||||
routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing, false));
|
||||
routesBadges.addView(createWalkRouteBadge(walkingSegment, badgesRowClickable), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing, false));
|
||||
}
|
||||
} else {
|
||||
double finishWalkDist = routeResult.getFinishWalkDist();
|
||||
|
@ -329,7 +329,7 @@ public class PublicTransportCard extends BaseCard {
|
|||
if (walkTime > MIN_WALK_TIME) {
|
||||
LatLon start = s.getEnd().getLocation();
|
||||
LatLon end = this.endLocation;
|
||||
routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
|
||||
routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing, false));
|
||||
routesBadges.addView(createWalkRouteBadge(walkTime, start, end, badgesRowClickable));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -413,7 +413,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
|
|||
colorItems.removeAllViews();
|
||||
for (ProfileIconColors color : ProfileIconColors.values()) {
|
||||
View colorItem = createColorItemView(color, colorItems);
|
||||
colorItems.addView(colorItem, new FlowLayout.LayoutParams(0, 0));
|
||||
colorItems.addView(colorItem, new FlowLayout.LayoutParams(0, 0, true));
|
||||
}
|
||||
updateColorSelector(changedProfile.color);
|
||||
} else if (ICON_ITEMS.equals(preference.getKey())) {
|
||||
|
@ -422,7 +422,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
|
|||
ArrayList<Integer> icons = ProfileIcons.getIcons();
|
||||
for (int iconRes : icons) {
|
||||
View iconItem = createIconItemView(iconRes, iconItems);
|
||||
iconItems.addView(iconItem, new FlowLayout.LayoutParams(0, 0));
|
||||
iconItems.addView(iconItem, new FlowLayout.LayoutParams(0, 0,true));
|
||||
}
|
||||
setIconColor(changedProfile.iconRes);
|
||||
} else if (LOCATION_ICON_ITEMS.equals(preference.getKey())) {
|
||||
|
@ -430,7 +430,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
|
|||
locationIconItems.removeAllViews();
|
||||
for (LocationIcon locationIcon : LocationIcon.values()) {
|
||||
View iconItemView = createLocationIconView(locationIcon, locationIconItems);
|
||||
locationIconItems.addView(iconItemView, new FlowLayout.LayoutParams(0, 0));
|
||||
locationIconItems.addView(iconItemView, new FlowLayout.LayoutParams(0, 0, false));
|
||||
}
|
||||
updateLocationIconSelector(changedProfile.locationIcon);
|
||||
} else if (NAV_ICON_ITEMS.equals(preference.getKey())) {
|
||||
|
@ -438,7 +438,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
|
|||
navIconItems.removeAllViews();
|
||||
for (NavigationIcon navigationIcon : NavigationIcon.values()) {
|
||||
View iconItemView = createNavigationIconView(navigationIcon, navIconItems);
|
||||
navIconItems.addView(iconItemView, new FlowLayout.LayoutParams(0, 0));
|
||||
navIconItems.addView(iconItemView, new FlowLayout.LayoutParams(0, 0, false));
|
||||
}
|
||||
updateNavigationIconSelector(changedProfile.navigationIcon);
|
||||
}
|
||||
|
|
|
@ -13,8 +13,6 @@ import androidx.core.content.ContextCompat;
|
|||
import androidx.core.graphics.ColorUtils;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.google.android.material.internal.FlowLayout;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -23,6 +21,7 @@ import net.osmand.plus.UiUtilities;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||
import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener;
|
||||
import net.osmand.plus.widgets.FlowLayout;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -96,15 +95,15 @@ public class ColorsCard extends BaseCard implements ColorPickerListener {
|
|||
selectColor.removeAllViews();
|
||||
|
||||
for (int color : customColors) {
|
||||
selectColor.addView(createColorItemView(color, selectColor, true));
|
||||
selectColor.addView(createColorItemView(color, selectColor, true), new FlowLayout.LayoutParams(0, 0, true));
|
||||
}
|
||||
if (customColors.size() < 6) {
|
||||
selectColor.addView(createAddCustomColorItemView(selectColor));
|
||||
selectColor.addView(createAddCustomColorItemView(selectColor), new FlowLayout.LayoutParams(0, 0, true));
|
||||
}
|
||||
selectColor.addView(createDividerView(selectColor));
|
||||
selectColor.addView(createDividerView(selectColor), new FlowLayout.LayoutParams(0, 0, false));
|
||||
|
||||
for (int color : colors) {
|
||||
selectColor.addView(createColorItemView(color, selectColor, false));
|
||||
selectColor.addView(createColorItemView(color, selectColor, false), new FlowLayout.LayoutParams(0, 0, true));
|
||||
}
|
||||
updateColorSelector(selectedColor, selectColor);
|
||||
}
|
||||
|
@ -195,7 +194,6 @@ public class ColorsCard extends BaseCard implements ColorPickerListener {
|
|||
LinearLayout dividerContainer = new LinearLayout(view.getContext());
|
||||
dividerContainer.addView(divider);
|
||||
dividerContainer.setPadding(0, AndroidUtils.dpToPx(app, 1), 0, AndroidUtils.dpToPx(app, 5));
|
||||
|
||||
return dividerContainer;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package net.osmand.plus.widgets;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -16,15 +15,17 @@ public class FlowLayout extends ViewGroup {
|
|||
|
||||
final int horizontal_spacing;
|
||||
final int vertical_spacing;
|
||||
final boolean horizontalAutoSpacing;
|
||||
|
||||
/**
|
||||
* @param horizontal_spacing Pixels between items, horizontally
|
||||
* @param vertical_spacing Pixels between items, vertically
|
||||
*/
|
||||
public LayoutParams(int horizontal_spacing, int vertical_spacing) {
|
||||
public LayoutParams(int horizontal_spacing, int vertical_spacing, boolean horizontalAutoSpacing) {
|
||||
super(0, 0);
|
||||
this.horizontal_spacing = horizontal_spacing;
|
||||
this.vertical_spacing = vertical_spacing;
|
||||
this.horizontalAutoSpacing = horizontalAutoSpacing;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,43 +39,44 @@ public class FlowLayout extends ViewGroup {
|
|||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
if ((MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.UNSPECIFIED)) throw new AssertionError();
|
||||
if ((MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.UNSPECIFIED))
|
||||
throw new AssertionError();
|
||||
|
||||
final int width = MeasureSpec.getSize(widthMeasureSpec) - getPaddingLeft() - getPaddingRight();
|
||||
int height = MeasureSpec.getSize(heightMeasureSpec) - getPaddingTop() - getPaddingBottom();
|
||||
final int count = getChildCount();
|
||||
int line_height = 0;
|
||||
int xpos = getPaddingLeft();
|
||||
int ypos = getPaddingTop();
|
||||
int childHeightMeasureSpec;
|
||||
int horizontalPosition = getPaddingLeft();
|
||||
int verticalPosition = getPaddingTop();
|
||||
int childHeighteightMeasureSpec;
|
||||
|
||||
if (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.AT_MOST) {
|
||||
childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST);
|
||||
childHeighteightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST);
|
||||
} else {
|
||||
childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
|
||||
childHeighteightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
final View child = getChildAt(i);
|
||||
if (child.getVisibility() != GONE) {
|
||||
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||
child.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), childHeightMeasureSpec);
|
||||
final int childw = child.getMeasuredWidth();
|
||||
child.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), childHeighteightMeasureSpec);
|
||||
final int childWidth = child.getMeasuredWidth();
|
||||
line_height = Math.max(line_height, child.getMeasuredHeight() + lp.vertical_spacing);
|
||||
if (xpos + childw > width) {
|
||||
xpos = getPaddingLeft();
|
||||
ypos += line_height;
|
||||
if (horizontalPosition + childWidth > width) {
|
||||
horizontalPosition = getPaddingLeft();
|
||||
verticalPosition += line_height;
|
||||
}
|
||||
xpos += childw + lp.horizontal_spacing;
|
||||
horizontalPosition += childWidth + lp.horizontal_spacing;
|
||||
}
|
||||
}
|
||||
|
||||
this.line_height = line_height;
|
||||
if (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.UNSPECIFIED) {
|
||||
height = ypos + line_height;
|
||||
height = verticalPosition + line_height;
|
||||
} else if (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.AT_MOST) {
|
||||
if (ypos + line_height < height) {
|
||||
height = ypos + line_height;
|
||||
if (verticalPosition + line_height < height) {
|
||||
height = verticalPosition + line_height;
|
||||
}
|
||||
}
|
||||
setMeasuredDimension(width, height);
|
||||
|
@ -82,7 +84,7 @@ public class FlowLayout extends ViewGroup {
|
|||
|
||||
@Override
|
||||
protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
|
||||
return new LayoutParams(1, 1); // default of 1px spacing
|
||||
return new LayoutParams(1, 1, false); // default of 1px spacing
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -94,29 +96,44 @@ public class FlowLayout extends ViewGroup {
|
|||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
final int count = getChildCount();
|
||||
final int width = r - l;
|
||||
int freeSizeSpacing;
|
||||
boolean isLayoutRtl = AndroidUtils.isLayoutRtl(getContext());
|
||||
int xpos = isLayoutRtl ? width - getPaddingRight() : getPaddingLeft();
|
||||
int ypos = getPaddingTop();
|
||||
int horizontalPosition = isLayoutRtl ? width - getPaddingRight() : getPaddingLeft();
|
||||
int verticalPosition = getPaddingTop();
|
||||
for (int i = 0; i < count; i++) {
|
||||
final View child = getChildAt(i);
|
||||
if (child.getVisibility() != GONE) {
|
||||
final int childw = child.getMeasuredWidth();
|
||||
final int childh = child.getMeasuredHeight();
|
||||
final int childWidth = child.getMeasuredWidth();
|
||||
final int childHeight = child.getMeasuredHeight();
|
||||
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||
if (isLayoutRtl) {
|
||||
if (xpos - childw < l) {
|
||||
xpos = width - getPaddingRight();
|
||||
ypos += line_height;
|
||||
}
|
||||
child.layout(xpos - childw, ypos, xpos, ypos + childh);
|
||||
xpos -= childw + lp.horizontal_spacing;
|
||||
int itemsCount = width / childWidth;
|
||||
if (itemsCount > 1) {
|
||||
freeSizeSpacing = width % childWidth / (itemsCount - 1);
|
||||
} else {
|
||||
if (xpos + childw > width) {
|
||||
xpos = getPaddingLeft();
|
||||
ypos += line_height;
|
||||
freeSizeSpacing = width % childWidth / itemsCount;
|
||||
}
|
||||
if (isLayoutRtl) {
|
||||
if (horizontalPosition - childWidth < l) {
|
||||
horizontalPosition = width - getPaddingRight();
|
||||
verticalPosition += line_height;
|
||||
}
|
||||
child.layout(horizontalPosition - childWidth, verticalPosition, horizontalPosition, verticalPosition + childHeight);
|
||||
if (lp.horizontalAutoSpacing) {
|
||||
horizontalPosition -= childWidth + lp.horizontal_spacing + freeSizeSpacing;
|
||||
} else {
|
||||
horizontalPosition -= childWidth + lp.horizontal_spacing;
|
||||
}
|
||||
} else {
|
||||
if (horizontalPosition + childWidth > width) {
|
||||
horizontalPosition = getPaddingLeft();
|
||||
verticalPosition += line_height;
|
||||
}
|
||||
child.layout(horizontalPosition, verticalPosition, horizontalPosition + childWidth, verticalPosition + childHeight);
|
||||
if (lp.horizontalAutoSpacing) {
|
||||
horizontalPosition += childWidth + lp.horizontal_spacing + freeSizeSpacing;
|
||||
} else {
|
||||
horizontalPosition += childWidth + lp.horizontal_spacing;
|
||||
}
|
||||
child.layout(xpos, ypos, xpos + childw, ypos + childh);
|
||||
xpos += childw + lp.horizontal_spacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue