Add name and description

This commit is contained in:
Dima-1 2020-03-04 19:08:42 +02:00
parent fe14dcee91
commit 97f2f749e2
3 changed files with 396 additions and 55 deletions

View file

@ -0,0 +1,325 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/point_edit_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:fitsSystemWindows="true">
<LinearLayout
android:id="@+id/background_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/card_and_list_background_basic"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="fill_parent"
android:layout_height="@dimen/dashboard_map_toolbar"
android:background="?attr/card_and_list_background_basic"
android:minHeight="@dimen/dashboard_map_toolbar"
app:contentInsetLeft="72dp"
app:contentInsetStart="72dp"
osmand:subtitleTextColor="?android:textColorPrimary"
osmand:theme="@style/ThemeOverlay.AppCompat.ActionBar"
osmand:titleTextColor="?android:textColorPrimary">
<ImageView
android:id="@+id/toolbar_action"
android:layout_width="@dimen/list_item_height"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="?attr/card_and_list_background_basic"
android:contentDescription="@string/replace_all"
android:scaleType="center"
android:src="@drawable/ic_action_replace" />
</android.support.v7.widget.Toolbar>
<ScrollView
android:id="@+id/editor_scroll_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/main_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/title_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<net.osmand.plus.widgets.OsmandTextFieldBoxes
android:id="@+id/name_caption"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:errorColor="@color/color_invalid"
app:labelText="@string/shared_string_name"
app:primaryColor="@color/active_color_primary_dark"
app:secondaryColor="?android:textColorSecondary">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:id="@+id/name_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:layout_marginRight="48dp"
android:inputType="textMultiLine"
android:maxLines="4"
android:scrollHorizontally="false"
android:textSize="16sp"
tools:text="@string/lorem_ipsum" />
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
</LinearLayout>
<ImageView
android:id="@+id/toolbar_action_1"
android:layout_width="@dimen/favorites_icon_size"
android:layout_height="@dimen/favorites_icon_size"
android:layout_gravity="end"
android:layout_margin="10dp"
android:contentDescription="@string/replace_all"
android:scaleType="center"
android:src="@drawable/ic_action_home_dark" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/card_padding"
android:gravity="center_vertical"
android:orientation="horizontal">
<net.osmand.plus.widgets.OsmandTextFieldBoxes
android:id="@+id/description_caption"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:layout_weight="1"
app:errorColor="@color/color_invalid"
app:labelText="@string/shared_string_description"
app:primaryColor="@color/active_color_primary_dark"
app:secondaryColor="?android:textColorSecondary">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:id="@+id/description_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:maxLines="4"
android:scrollHorizontally="false"
android:textSize="16sp"
tools:text="@string/lorem_ipsum" />
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
</LinearLayout>
<Button
android:id="@+id/description_button"
style="@android:style/Widget.Button.Toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:background="?attr/selectableItemBackground"
android:minHeight="48dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:text="@string/add_description"
android:textColor="?attr/contextMenuButtonColor" />
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="?attr/dashboard_divider" />
<net.osmand.plus.widgets.TextViewEx
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="16dp"
android:paddingTop="14dp"
android:paddingRight="16dp"
android:paddingBottom="14dp"
android:text="@string/select_group"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular" />
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="?attr/dashboard_divider" />
<net.osmand.plus.widgets.TextViewEx
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="16dp"
android:paddingTop="14dp"
android:paddingRight="16dp"
android:paddingBottom="14dp"
android:text="@string/select_icon_profile_dialog_title"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular" />
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="?attr/dashboard_divider" />
<net.osmand.plus.widgets.TextViewEx
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="16dp"
android:paddingTop="14dp"
android:paddingRight="16dp"
android:paddingBottom="14dp"
android:text="@string/select_color"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular" />
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="?attr/dashboard_divider" />
<net.osmand.plus.widgets.TextViewEx
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="16dp"
android:paddingTop="14dp"
android:paddingRight="16dp"
android:paddingBottom="14dp"
android:text="@string/select_shape"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular" />
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="?attr/dashboard_divider" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/buttons_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:id="@+id/buttons_top_border"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/divider_color" />
<LinearLayout
android:id="@+id/buttons_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/activity_background_color"
android:orientation="horizontal">
<Button
android:id="@+id/delete_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:paddingStart="10dp"
android:paddingLeft="10dp"
android:paddingEnd="10dp"
android:paddingRight="10dp"
android:text="@string/shared_string_delete"
android:textColor="?attr/contextMenuButtonColor" />
<Button
android:id="@+id/replace_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:paddingStart="10dp"
android:paddingLeft="10dp"
android:paddingEnd="10dp"
android:paddingRight="10dp"
android:text="@string/update_existing"
android:textColor="?attr/contextMenuButtonColor"
android:visibility="gone" />
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1" />
<Button
android:id="@+id/cancel_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:paddingStart="10dp"
android:paddingLeft="10dp"
android:paddingEnd="10dp"
android:paddingRight="10dp"
android:text="@string/shared_string_cancel"
android:textColor="?attr/contextMenuButtonColor" />
<Button
android:id="@+id/save_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:paddingStart="10dp"
android:paddingLeft="10dp"
android:paddingEnd="10dp"
android:paddingRight="10dp"
android:text="@string/shared_string_save"
android:textColor="?attr/contextMenuButtonColor" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>

View file

@ -11,6 +11,10 @@
Thx - Hardy
-->
<string name="select_shape">Select shape</string>
<string name="select_group">Select group</string>
<string name="add_description">Add description</string>
<string name="delete_description">Delete description</string>
<string name="import_rendering_file">Import rendering file</string>
<string name="profile_type_custom_string">Custom profile</string>
<string name="shared_string_angle_param">Angle: %s°</string>

View file

@ -31,6 +31,7 @@ import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.widgets.AutoCompleteTextViewEx;
import net.osmand.plus.widgets.OsmandTextFieldBoxes;
import net.osmand.util.Algorithms;
import static net.osmand.plus.FavouritesDbHelper.FavoriteGroup.PERSONAL_CATEGORY;
@ -48,7 +49,7 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment {
Bundle savedInstanceState) {
boolean nightMode = !getMyApplication().getSettings().isLightContent();
view = UiUtilities.getInflater(getContext(), nightMode).inflate(R.layout.point_editor_fragment, container, false);
view = UiUtilities.getInflater(getContext(), nightMode).inflate(R.layout.new_point_editor_fragment, container, false);
PointEditor editor = getEditor();
if (editor == null) {
@ -59,14 +60,12 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment {
editor.updateNightMode();
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setBackgroundColor(ContextCompat.getColor(getContext(), !editor.isLight() ? R.color.app_bar_color_dark : R.color.app_bar_color_light));
toolbar.setTitle(getToolbarTitle());
OsmandApplication app = requireMyApplication();
Drawable icBack = app.getUIUtilities().getIcon(R.drawable.ic_arrow_back, !editor.isLight() ? R.color.active_buttons_and_links_text_dark : R.color.active_buttons_and_links_text_light);
Drawable icBack = app.getUIUtilities().getIcon(R.drawable.ic_arrow_back, 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);
toolbar.setTitleTextColor(getResources().getColor(getResIdFromAttribute(getMapActivity(), R.attr.pstsTextColor)));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -75,6 +74,8 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment {
});
int activeColorResId = !editor.isLight() ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
ImageView toolbarAction = (ImageView) view.findViewById(R.id.toolbar_action);
toolbarAction.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_replace,activeColorResId));
Button saveButton = (Button) view.findViewById(R.id.save_button);
saveButton.setTextColor(getResources().getColor(activeColorResId));
@ -110,61 +111,59 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment {
deleteButton.setVisibility(View.VISIBLE);
}
view.findViewById(R.id.background_layout).setBackgroundResource(!editor.isLight() ? R.color.activity_background_color_dark : R.color.activity_background_color_light);
view.findViewById(R.id.buttons_layout).setBackgroundResource(!editor.isLight() ? R.color.activity_background_color_dark : R.color.activity_background_color_light);
view.findViewById(R.id.title_view).setBackgroundResource(!editor.isLight() ? R.color.list_background_color_dark : R.color.list_background_color_light);
view.findViewById(R.id.description_info_view).setBackgroundResource(!editor.isLight() ? R.color.activity_background_color_dark : R.color.activity_background_color_light);
// view.findViewById(R.id.background_layout).setBackgroundResource(!editor.isLight() ? R.color.activity_background_color_dark : R.color.activity_background_color_light);
// view.findViewById(R.id.buttons_layout).setBackgroundResource(!editor.isLight() ? R.color.activity_background_color_dark : R.color.activity_background_color_light);
// view.findViewById(R.id.title_view).setBackgroundResource(!editor.isLight() ? R.color.list_background_color_dark : R.color.list_background_color_light);
// view.findViewById(R.id.description_caption).setBackgroundResource(!editor.isLight() ? R.color.activity_background_color_dark : R.color.activity_background_color_light);
TextView nameCaption = (TextView) view.findViewById(R.id.name_caption);
AndroidUtils.setTextSecondaryColor(view.getContext(), nameCaption, !editor.isLight());
nameCaption.setText(getNameCaption());
TextView categoryCaption = (TextView) view.findViewById(R.id.category_caption);
AndroidUtils.setTextSecondaryColor(view.getContext(), categoryCaption, !editor.isLight());
categoryCaption.setText(getCategoryCaption());
OsmandTextFieldBoxes nameCaption = (OsmandTextFieldBoxes) view.findViewById(R.id.name_caption);
AndroidUtils.setTextSecondaryColor(view.getContext(), nameCaption.getEditText(), !editor.isLight());
nameCaption.getEditText().setText(getNameCaption());
// TextView categoryCaption = (TextView) view.findViewById(R.id.category_caption);
// AndroidUtils.setTextSecondaryColor(view.getContext(), categoryCaption, !editor.isLight());
// categoryCaption.setText(getCategoryCaption());
nameEdit = (EditText) view.findViewById(R.id.name_edit);
AndroidUtils.setTextPrimaryColor(view.getContext(), nameEdit, !editor.isLight());
AndroidUtils.setHintTextSecondaryColor(view.getContext(), nameEdit, !editor.isLight());
nameEdit.setText(getNameInitValue());
AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) view.findViewById(R.id.category_edit);
AndroidUtils.setTextPrimaryColor(view.getContext(), categoryEdit, !editor.isLight());
categoryEdit.setText(getCategoryInitValue());
categoryEdit.setFocusable(false);
categoryEdit.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(final View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
DialogFragment dialogFragment = createSelectCategoryDialog();
if (dialogFragment != null) {
dialogFragment.show(getChildFragmentManager(), SelectCategoryDialogFragment.TAG);
}
return true;
}
return false;
}
});
// AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) view.findViewById(R.id.category_edit);
// AndroidUtils.setTextPrimaryColor(view.getContext(), categoryEdit, !editor.isLight());
// categoryEdit.setText(getCategoryInitValue());
// categoryEdit.setFocusable(false);
// categoryEdit.setOnTouchListener(new View.OnTouchListener() {
// @Override
// public boolean onTouch(final View v, MotionEvent event) {
// if (event.getAction() == MotionEvent.ACTION_UP) {
// DialogFragment dialogFragment = createSelectCategoryDialog();
// if (dialogFragment != null) {
// dialogFragment.show(getChildFragmentManager(), SelectCategoryDialogFragment.TAG);
// }
// return true;
// }
// return false;
// }
// });
final EditText descriptionEdit = (EditText) view.findViewById(R.id.description_edit);
AndroidUtils.setTextPrimaryColor(view.getContext(), descriptionEdit, !editor.isLight());
AndroidUtils.setHintTextSecondaryColor(view.getContext(), descriptionEdit, !editor.isLight());
if (getDescriptionInitValue() != null) {
descriptionEdit.setText(getDescriptionInitValue());
}
// final EditText descriptionEdit = (EditText) view.findViewById(R.id.description_edit);
// AndroidUtils.setTextPrimaryColor(view.getContext(), descriptionEdit, !editor.isLight());
// AndroidUtils.setHintTextSecondaryColor(view.getContext(), descriptionEdit, !editor.isLight());
// if (getDescriptionInitValue() != null) {
// descriptionEdit.setText(getDescriptionInitValue());
// }
ImageView nameImage = (ImageView) view.findViewById(R.id.name_image);
nameImage.setImageDrawable(getNameIcon());
ImageView categoryImage = (ImageView) view.findViewById(R.id.category_image);
categoryImage.setImageDrawable(getCategoryIcon());
// ImageView nameImage = (ImageView) view.findViewById(R.id.name_image);
// nameImage.setImageDrawable(getNameIcon());
// ImageView categoryImage = (ImageView) view.findViewById(R.id.category_image);
// categoryImage.setImageDrawable(getCategoryIcon());
ImageView descriptionImage = (ImageView) view.findViewById(R.id.description_image);
descriptionImage.setImageDrawable(getRowIcon(R.drawable.ic_action_note_dark));
if (app.accessibilityEnabled()) {
nameCaption.setFocusable(true);
categoryCaption.setFocusable(true);
nameEdit.setHint(R.string.access_hint_enter_name);
categoryEdit.setHint(R.string.access_hint_enter_category);
descriptionEdit.setHint(R.string.access_hint_enter_description);
// categoryCaption.setFocusable(true);
// nameEdit.setHint(R.string.access_hint_enter_name);
// categoryEdit.setHint(R.string.access_hint_enter_category);
// descriptionEdit.setHint(R.string.access_hint_enter_description);
}
return view;
}
@ -207,6 +206,19 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment {
nameEdit.requestFocus();
AndroidUtils.softKeyboardDelayed(nameEdit);
}
if (Build.VERSION.SDK_INT >= 21) {
Activity activity = getActivity();
if (activity != null) {
int colorId = getStatusBarColorId();
if (colorId != -1) {
if (activity instanceof MapActivity) {
((MapActivity) activity).updateStatusBarColor();
} else {
activity.getWindow().setStatusBarColor(ContextCompat.getColor(activity, colorId));
}
}
}
}
}
@Override
@ -354,15 +366,15 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment {
}
public String getCategoryTextValue() {
AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) view.findViewById(R.id.category_edit);
String name = categoryEdit.getText().toString().trim();
if (isPersonalCategoryDisplayName(requireContext(), name)) {
return PERSONAL_CATEGORY;
}
if(name.equals(getDefaultCategoryName())) {
// AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) view.findViewById(R.id.category_edit);
// String name = categoryEdit.getText().toString().trim();
// if (isPersonalCategoryDisplayName(requireContext(), name)) {
// return PERSONAL_CATEGORY;
// }
// if(name.equals(getDefaultCategoryName())) {
return "";
}
return name;
// }
// return name;
}
public String getDescriptionTextValue() {