Fix #8764 import shape, fix UI

This commit is contained in:
Dima-1 2020-04-14 15:01:18 +03:00
parent efdc0aabec
commit 0f869b81be
4 changed files with 56 additions and 21 deletions

View file

@ -29,6 +29,8 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="horizontal"
android:paddingRight="@dimen/list_header_padding"
android:paddingEnd="@dimen/list_header_padding"
android:paddingLeft="@dimen/list_header_padding"
android:paddingStart="@dimen/list_header_padding">
@ -41,10 +43,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/list_content_padding"
android:focusable="false"
android:visibility="gone"
tools:visibility="visible"
android:layout_marginLeft="@dimen/list_header_padding"
android:layout_marginStart="@dimen/list_header_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:layout_marginEnd="@dimen/list_content_padding" />
<ImageView
@ -53,8 +57,9 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:scaleType="center"
android:layout_marginRight="@dimen/list_header_settings_top_margin"
android:layout_marginEnd="@dimen/list_header_settings_top_margin" />
android:layout_marginRight="@dimen/list_header_text_left_margin"
android:layout_marginEnd="@dimen/list_header_text_left_margin"
android:contentDescription="@string/favorite" />
</FrameLayout>
<LinearLayout
@ -63,10 +68,8 @@
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical"
android:paddingTop="6dp"
android:paddingRight="@dimen/list_content_padding"
android:paddingBottom="6dp"
android:paddingEnd="@dimen/list_content_padding">
android:paddingTop="@dimen/context_menu_padding_margin_tiny"
android:paddingBottom="@dimen/context_menu_padding_margin_tiny">
<TextView
android:id="@+id/favourite_label"
@ -86,37 +89,39 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginTop="2dp"
android:src="@drawable/ic_direction_arrow" />
android:layout_marginTop="@dimen/subHeaderPadding"
android:src="@drawable/ic_direction_arrow"
android:contentDescription="@string/show_view_angle" />
<TextView
android:id="@+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginLeft="@dimen/subHeaderPadding"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
tools:text="100500 km"
android:layout_marginStart="2dp" />
android:layout_marginStart="@dimen/subHeaderPadding" />
<ImageView
android:id="@+id/group_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp"
android:layout_marginLeft="@dimen/list_item_button_padding"
android:src="@drawable/ic_small_group"
android:layout_marginStart="4dp" />
android:layout_marginStart="@dimen/list_item_button_padding"
android:contentDescription="@string/favorite_category_name" />
<TextView
android:id="@+id/group_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="2dp"
android:layout_marginLeft="@dimen/subHeaderPadding"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
android:layout_marginStart="2dp" />
android:layout_marginStart="@dimen/subHeaderPadding" />
</LinearLayout>
</LinearLayout>

View file

@ -139,7 +139,7 @@
android:paddingStart="12dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:scrollHorizontally="false"
android:scrollbars="vertical"
android:textSize="16sp"
tools:text="@string/lorem_ipsum" />

View file

@ -31,6 +31,7 @@ import net.osmand.IProgress;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
import net.osmand.data.FavouritePoint;
import net.osmand.data.FavouritePoint.BackgroundType;
import net.osmand.plus.AppInitializer;
import net.osmand.plus.AppInitializer.AppInitializeListener;
import net.osmand.plus.AppInitializer.InitEvents;
@ -1181,6 +1182,7 @@ public class ImportHelper {
}
fp.setColor(p.getColor(0));
fp.setIconIdFromName(app, p.getIconName());
fp.setBackgroundType(BackgroundType.getByTypeName(p.getBackgroundType(), BackgroundType.CIRCLE));
favourites.add(fp);
}
}

View file

@ -1,5 +1,6 @@
package net.osmand.plus.mapcontextmenu.editors;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
@ -10,6 +11,7 @@ import android.os.Bundle;
import android.os.IBinder;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
@ -65,7 +67,7 @@ import static net.osmand.util.Algorithms.capitalizeFirstLetter;
public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
public static final String TAG = "PointEditorFragmentNew";
public static final String TAG = PointEditorFragmentNew.class.getSimpleName();
private View view;
private EditText nameEdit;
@ -87,6 +89,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
private View descriptionCaption;
private EditText descriptionEdit;
@SuppressLint("ClickableViewAccessibility")
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
@ -95,6 +98,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
nightMode = app.getDaynightHelper().isNightModeForMapControls();
view = UiUtilities.getMaterialInflater(getContext(), nightMode)
.inflate(R.layout.point_editor_fragment_new, container, false);
AndroidUtils.addStatusBarPadding21v(getActivity(), view);
final PointEditor editor = getEditor();
if (editor == null) {
@ -131,6 +135,8 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
if (scrollViewY != scrollView.getScrollY()) {
scrollViewY = scrollView.getScrollY();
hideKeyboard();
descriptionEdit.clearFocus();
nameEdit.clearFocus();
}
}
});
@ -259,6 +265,23 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
createShapeSelector();
updateColorSelector(selectedColor, view);
updateShapeSelector(selectedShape, view);
scrollView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
descriptionEdit.getParent().requestDisallowInterceptTouchEvent(false);
return false;
}
});
descriptionEdit.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
descriptionEdit.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
return view;
}
@ -442,10 +465,11 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
}
IconCategoriesAdapter iconCategoriesAdapter = new IconCategoriesAdapter();
iconCategoriesAdapter.setItems(new ArrayList<>(iconCategories.keySet()));
RecyclerView groupNameRecyclerView = view.findViewById(R.id.group_name_recycler_view);
groupNameRecyclerView.setAdapter(iconCategoriesAdapter);
groupNameRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
RecyclerView iconCategoriesRecyclerView = view.findViewById(R.id.group_name_recycler_view);
iconCategoriesRecyclerView.setAdapter(iconCategoriesAdapter);
iconCategoriesRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
iconCategoriesAdapter.notifyDataSetChanged();
iconCategoriesRecyclerView.scrollToPosition(iconCategoriesAdapter.getItemPosition(selectedIconCategory));
for (String name : iconNameList) {
selectIcon.addView(createIconItemView(name, selectIcon), new FlowLayout.LayoutParams(0, 0));
}
@ -562,7 +586,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
@Override
protected boolean isFullScreenAllowed() {
return false;
return true;
}
private void hideKeyboard() {
@ -920,6 +944,10 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
public int getItemCount() {
return items.size();
}
int getItemPosition(String name) {
return items.indexOf(name);
}
}
static class NameViewHolder extends RecyclerView.ViewHolder {