Merge pull request #8729 from osmandapp/Fix_1_edit_fav_icons
Fix UI, fix rtl, fix icon size
This commit is contained in:
commit
6e33e20bc4
8 changed files with 81 additions and 66 deletions
|
@ -1,25 +0,0 @@
|
|||
{
|
||||
"categories": {
|
||||
"special": {
|
||||
"icons": [
|
||||
"special_star",
|
||||
"special_star_stroked",
|
||||
"special_marker",
|
||||
"special_flag_stroke",
|
||||
"special_house",
|
||||
"special_building"
|
||||
]
|
||||
},
|
||||
"amenity": {
|
||||
"icons": [
|
||||
"amenity_bar",
|
||||
"amenity_cafe",
|
||||
"amenity_atm",
|
||||
"amenity_biergarten",
|
||||
"amenity_cinema",
|
||||
"amenity_fire_station",
|
||||
"amenity_parking"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -49,11 +49,12 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/favourite_icon"
|
||||
android:layout_width="@dimen/favorites_icon_size"
|
||||
android:layout_height="@dimen/favorites_icon_size"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="@dimen/list_header_padding"
|
||||
android:layout_marginEnd="@dimen/list_header_padding" />
|
||||
android:scaleType="center"
|
||||
android:layout_marginRight="@dimen/list_header_settings_top_margin"
|
||||
android:layout_marginEnd="@dimen/list_header_settings_top_margin" />
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
@ -65,7 +66,7 @@
|
|||
android:paddingTop="6dp"
|
||||
android:paddingRight="@dimen/list_content_padding"
|
||||
android:paddingBottom="6dp"
|
||||
android:paddingEnd="@dimen/list_content_padding">
|
||||
android:paddingEnd="@dimen/list_content_padding">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/favourite_label"
|
||||
|
@ -96,7 +97,7 @@
|
|||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
tools:text="100500 km"
|
||||
android:layout_marginStart="2dp" />
|
||||
android:layout_marginStart="2dp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/group_image"
|
||||
|
@ -105,7 +106,7 @@
|
|||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:src="@drawable/ic_small_group"
|
||||
android:layout_marginStart="4dp" />
|
||||
android:layout_marginStart="4dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/group_name"
|
||||
|
@ -115,7 +116,7 @@
|
|||
android:layout_marginLeft="2dp"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
android:layout_marginStart="2dp" />
|
||||
android:layout_marginStart="2dp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -129,7 +130,7 @@
|
|||
android:background="?attr/dashboard_button"
|
||||
android:src="@drawable/ic_action_test_light"
|
||||
android:visibility="gone"
|
||||
android:layout_marginStart="@dimen/dashFavIconMargin" />
|
||||
android:layout_marginStart="@dimen/dashFavIconMargin" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/options"
|
||||
|
|
|
@ -83,10 +83,10 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:drawableEnd="@drawable/btn_circle_transparent_full"
|
||||
android:drawableRight="@drawable/btn_circle_transparent_full"
|
||||
android:drawablePadding="50dp"
|
||||
android:drawablePadding="60dp"
|
||||
android:inputType="textMultiLine"
|
||||
android:maxLines="4"
|
||||
android:minHeight="50dp"
|
||||
android:minHeight="60dp"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingLeft="12dp"
|
||||
android:paddingRight="12dp"
|
||||
|
@ -103,7 +103,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_margin="12dp"
|
||||
android:scaleType="center"
|
||||
android:contentDescription="@string/icon"
|
||||
android:src="@drawable/ic_action_home_dark" />
|
||||
|
||||
|
@ -134,7 +135,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:inputType="textMultiLine"
|
||||
android:maxLines="4"
|
||||
android:minHeight="50dp"
|
||||
android:minHeight="60dp"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingLeft="12dp"
|
||||
android:paddingRight="12dp"
|
||||
|
|
|
@ -101,11 +101,13 @@
|
|||
</style>
|
||||
|
||||
<style name="OsmandMaterialLightTheme" parent="Theme.MaterialComponents.Light">
|
||||
<item name="colorPrimary">@color/active_color_primary_light</item>
|
||||
<item name="dashboard_divider">@color/divider_color_light</item>
|
||||
<item name="divider_color">@color/divider_color</item>
|
||||
</style>
|
||||
|
||||
<style name="OsmandMaterialDarkTheme" parent="Theme.MaterialComponents">
|
||||
<item name="colorPrimary">@color/active_color_primary_dark</item>
|
||||
<item name="dashboard_divider">@color/divider_color_dark</item>
|
||||
<item name="divider_color">@color/divider_color_dark</item>
|
||||
</style>
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.graphics.Canvas;
|
|||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Rect;
|
||||
|
@ -98,9 +97,11 @@ public class FavoriteImageDrawable extends Drawable {
|
|||
super.onBoundsChange(bounds);
|
||||
Rect bs = new Rect(bounds);
|
||||
if (!withShadow && !synced) {
|
||||
uiBackgroundIcon.setBounds(bounds);
|
||||
bs.inset(bs.width() / 5, bs.height() / 5);
|
||||
uiListIcon.setBounds(bs);
|
||||
uiBackgroundIcon.setBounds(0, 0, uiBackgroundIcon.getIntrinsicWidth(), uiBackgroundIcon.getIntrinsicHeight());
|
||||
int offsetX = bounds.centerX() - uiListIcon.getIntrinsicWidth() / 2;
|
||||
int offsetY = bounds.centerY() - uiListIcon.getIntrinsicHeight() / 2;
|
||||
uiListIcon.setBounds(offsetX, offsetY, uiListIcon.getIntrinsicWidth() + offsetX,
|
||||
uiListIcon.getIntrinsicHeight() + offsetY);
|
||||
} else if (withShadow) {
|
||||
bs.inset(bs.width() / 3, bs.height() / 3);
|
||||
favIcon.setBounds(bs);
|
||||
|
@ -109,12 +110,22 @@ public class FavoriteImageDrawable extends Drawable {
|
|||
|
||||
@Override
|
||||
public int getIntrinsicHeight() {
|
||||
return synced ? syncedShadow.getHeight() : favBackgroundCenter.getHeight();
|
||||
if (synced) {
|
||||
return syncedShadow.getHeight();
|
||||
} else if (withShadow) {
|
||||
return favBackgroundCenter.getHeight();
|
||||
}
|
||||
return uiBackgroundIcon.getIntrinsicHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
return synced ? syncedShadow.getWidth() : favBackgroundCenter.getWidth();
|
||||
if (synced) {
|
||||
return syncedShadow.getWidth();
|
||||
} else if (withShadow) {
|
||||
return favBackgroundCenter.getWidth();
|
||||
}
|
||||
return uiBackgroundIcon.getIntrinsicWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -105,7 +105,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
toolbar.setBackgroundColor(ContextCompat.getColor(requireContext(),
|
||||
nightMode ? R.color.app_bar_color_dark : R.color.list_background_color_light));
|
||||
toolbar.setTitle(getToolbarTitle());
|
||||
Drawable icBack = app.getUIUtilities().getIcon(R.drawable.ic_arrow_back,
|
||||
Drawable icBack = app.getUIUtilities().getIcon(AndroidUtils.getNavigationIconResId(app),
|
||||
nightMode ? R.color.active_buttons_and_links_text_dark : R.color.description_font_and_bottom_sheet_icons);
|
||||
toolbar.setNavigationIcon(icBack);
|
||||
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
|
||||
|
@ -471,9 +471,15 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
oldIcon.findViewById(R.id.outline).setVisibility(View.INVISIBLE);
|
||||
ImageView background = oldIcon.findViewById(R.id.background);
|
||||
setIconSelectorBackground(background);
|
||||
ImageView iconView = oldIcon.findViewById(R.id.icon);
|
||||
iconView.setImageDrawable(UiUtilities.tintDrawable(ContextCompat.getDrawable(app, selectedIcon),
|
||||
ContextCompat.getColor(app, R.color.icon_color_default_light)));
|
||||
}
|
||||
View icon = rootView.findViewWithTag(iconRes);
|
||||
if (icon != null) {
|
||||
ImageView iconView = icon.findViewById(R.id.icon);
|
||||
iconView.setImageDrawable(UiUtilities.tintDrawable(ContextCompat.getDrawable(app, iconRes),
|
||||
ContextCompat.getColor(app, R.color.color_white)));
|
||||
icon.findViewById(R.id.outline).setVisibility(View.VISIBLE);
|
||||
ImageView backgroundCircle = icon.findViewById(R.id.background);
|
||||
AndroidUtils.setBackground(backgroundCircle,
|
||||
|
@ -760,6 +766,14 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
Drawable iconAdd = app.getUIUtilities().getIcon(R.drawable.ic_action_add, activeColorResId);
|
||||
((ImageView) view.findViewById(R.id.groupIcon)).setImageDrawable(iconAdd);
|
||||
((TextView) view.findViewById(R.id.groupName)).setText(requireMyApplication().getString(R.string.add_group));
|
||||
GradientDrawable rectContourDrawable = (GradientDrawable) ContextCompat.getDrawable(app,
|
||||
R.drawable.bg_select_group_button_outline);
|
||||
if (rectContourDrawable != null) {
|
||||
int strokeColor = ContextCompat.getColor(app, nightMode ? R.color.stroked_buttons_and_links_outline_dark
|
||||
: R.color.stroked_buttons_and_links_outline_light);
|
||||
rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, 1), strokeColor);
|
||||
((ImageView) view.findViewById(R.id.outlineRect)).setImageDrawable(rectContourDrawable);
|
||||
}
|
||||
}
|
||||
((TextView) view.findViewById(R.id.groupName)).setTextColor(getResources().getColor(activeColorResId));
|
||||
return new GroupsViewHolder(view);
|
||||
|
|
|
@ -347,7 +347,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
|
|||
if (categoriesMap != null) {
|
||||
categoriesMap.put(name, color);
|
||||
}
|
||||
this.color = color;
|
||||
this.color = this.color == 0 ? color : this.color;
|
||||
super.setCategory(name, color);
|
||||
}
|
||||
|
||||
|
@ -411,12 +411,16 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
|
|||
|
||||
@Override
|
||||
public int getDefaultColor() {
|
||||
return 0;
|
||||
return defaultColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPointColor() {
|
||||
return color == 0 ? defaultColor : color;
|
||||
if (color != 0) {
|
||||
return color;
|
||||
} else {
|
||||
return getCategoryColor(getCategoryTextValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
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;
|
||||
|
||||
|
||||
public class FlowLayout extends ViewGroup {
|
||||
|
||||
private int line_height;
|
||||
private boolean rtl = false;
|
||||
|
||||
public static class LayoutParams extends ViewGroup.LayoutParams {
|
||||
|
||||
public final int horizontal_spacing;
|
||||
public final int vertical_spacing;
|
||||
final int horizontal_spacing;
|
||||
final int vertical_spacing;
|
||||
|
||||
/**
|
||||
* @param horizontal_spacing Pixels between items, horizontally
|
||||
|
@ -36,24 +37,22 @@ public class FlowLayout extends ViewGroup {
|
|||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
assert (MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.UNSPECIFIED);
|
||||
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;
|
||||
|
||||
if (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.AT_MOST) {
|
||||
childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST);
|
||||
} else {
|
||||
childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
final View child = getChildAt(i);
|
||||
if (child.getVisibility() != GONE) {
|
||||
|
@ -61,20 +60,17 @@ public class FlowLayout extends ViewGroup {
|
|||
child.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), childHeightMeasureSpec);
|
||||
final int childw = child.getMeasuredWidth();
|
||||
line_height = Math.max(line_height, child.getMeasuredHeight() + lp.vertical_spacing);
|
||||
|
||||
if (xpos + childw > width) {
|
||||
xpos = getPaddingLeft();
|
||||
ypos += line_height;
|
||||
}
|
||||
|
||||
xpos += childw + lp.horizontal_spacing;
|
||||
}
|
||||
}
|
||||
this.line_height = line_height;
|
||||
|
||||
this.line_height = line_height;
|
||||
if (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.UNSPECIFIED) {
|
||||
height = ypos + line_height;
|
||||
|
||||
} else if (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.AT_MOST) {
|
||||
if (ypos + line_height < height) {
|
||||
height = ypos + line_height;
|
||||
|
@ -95,23 +91,34 @@ public class FlowLayout extends ViewGroup {
|
|||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
rtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
|
||||
}
|
||||
final int count = getChildCount();
|
||||
final int width = r - l;
|
||||
int xpos = getPaddingLeft();
|
||||
int xpos = rtl ? width - getPaddingRight() : getPaddingLeft();
|
||||
int ypos = 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 LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||
if (xpos + childw > width) {
|
||||
xpos = getPaddingLeft();
|
||||
ypos += line_height;
|
||||
if (rtl) {
|
||||
if (xpos - childw < l) {
|
||||
xpos = width - getPaddingRight();
|
||||
ypos += line_height;
|
||||
}
|
||||
child.layout(xpos - childw, ypos, xpos, ypos + childh);
|
||||
xpos -= childw - lp.horizontal_spacing;
|
||||
} else {
|
||||
if (xpos + childw > width) {
|
||||
xpos = getPaddingLeft();
|
||||
ypos += line_height;
|
||||
}
|
||||
child.layout(xpos, ypos, xpos + childw, ypos + childh);
|
||||
xpos += childw + lp.horizontal_spacing;
|
||||
}
|
||||
child.layout(xpos, ypos, xpos + childw, ypos + childh);
|
||||
xpos += childw + lp.horizontal_spacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue