Add edit category
This commit is contained in:
parent
ef2cff6843
commit
9954b345f8
3 changed files with 188 additions and 43 deletions
|
@ -33,6 +33,7 @@
|
|||
android:layout_width="@dimen/list_item_height"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginRight="8dp"
|
||||
android:background="?attr/card_and_list_background_basic"
|
||||
android:contentDescription="@string/replace_all"
|
||||
android:scaleType="center"
|
||||
|
@ -70,6 +71,15 @@
|
|||
android:layout_marginLeft="@dimen/list_content_padding"
|
||||
android:layout_marginRight="@dimen/list_content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/name_icon"
|
||||
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/icon"
|
||||
android:src="@drawable/ic_action_home_dark" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -102,18 +112,10 @@
|
|||
|
||||
</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:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/card_padding"
|
||||
|
@ -164,18 +166,61 @@
|
|||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
<LinearLayout
|
||||
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" />
|
||||
android:orientation="horizontal">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
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" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/group_list_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="end"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/group_list_button_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="end"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_list"
|
||||
android:textColor="?attr/active_color_basic"
|
||||
android:textSize="@dimen/text_button_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:ignore="UnusedAttribute" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/group_list_button_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingStart="@dimen/content_padding_small"
|
||||
android:paddingLeft="@dimen/content_padding_small"
|
||||
android:paddingEnd="@dimen/route_info_buttons_padding_top_bottom"
|
||||
android:paddingRight="@dimen/route_info_buttons_padding_top_bottom"
|
||||
android:src="@drawable/ic_action_folder"
|
||||
tools:src="@drawable/ic_action_group_select_all" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -236,6 +281,44 @@
|
|||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/button_replace_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/replace_action_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:contentDescription="@string/replace_all"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingTop="21dp"
|
||||
android:paddingBottom="21dp"
|
||||
android:src="@drawable/ic_action_replace" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/button_delete_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/delete_action_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/delete_point"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:src="@drawable/ic_action_delete_dark" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -89,9 +89,21 @@ public abstract class PointEditor {
|
|||
if (mapActivity != null) {
|
||||
Fragment fragment = mapActivity.getSupportFragmentManager().findFragmentByTag(getFragmentTag());
|
||||
if (fragment != null) {
|
||||
PointEditorFragment editorFragment = (PointEditorFragment) fragment;
|
||||
editorFragment.setCategory(name, color);
|
||||
if (!checkNewUiFragment(fragment, name, color)) { //todo remove "if" after switch to new UI
|
||||
PointEditorFragment editorFragment = (PointEditorFragment) fragment;
|
||||
editorFragment.setCategory(name, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//todo remove after switch to new UI
|
||||
private boolean checkNewUiFragment(Fragment fragment, String name, int color) {
|
||||
if (fragment instanceof PointEditorFragmentNew) {
|
||||
PointEditorFragmentNew editorFragment = (PointEditorFragmentNew) fragment;
|
||||
editorFragment.setCategory(name, color);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.support.annotation.NonNull;
|
|||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -35,6 +36,8 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
|
||||
private View view;
|
||||
private EditText nameEdit;
|
||||
private ImageView nameIcon;
|
||||
private Button addDelDescription;
|
||||
private boolean cancelled;
|
||||
private boolean nightMode;
|
||||
|
||||
|
@ -46,7 +49,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
nightMode = !getMyApplication().getSettings().isLightContent();
|
||||
view = UiUtilities.getInflater(getContext(), nightMode).inflate(R.layout.point_editor_fragment_new, container, false);
|
||||
|
||||
PointEditor editor = getEditor();
|
||||
final PointEditor editor = getEditor();
|
||||
if (editor == null) {
|
||||
return view;
|
||||
}
|
||||
|
@ -57,7 +60,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
|
||||
toolbar.setTitle(getToolbarTitle());
|
||||
|
||||
OsmandApplication app = requireMyApplication();
|
||||
final OsmandApplication app = requireMyApplication();
|
||||
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);
|
||||
|
@ -70,7 +73,28 @@ public abstract class PointEditorFragmentNew 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));
|
||||
|
||||
|
||||
ImageView groupListIcon = (ImageView) view.findViewById(R.id.group_list_button_icon);
|
||||
groupListIcon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_group_select_all, activeColorResId));
|
||||
|
||||
ImageView replaceIcon = (ImageView) 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);
|
||||
deleteIcon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_delete_dark, activeColorResId));
|
||||
|
||||
View groupList = view.findViewById(R.id.group_list_button);
|
||||
groupList.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
DialogFragment dialogFragment = createSelectCategoryDialog();
|
||||
if (dialogFragment != null) {
|
||||
dialogFragment.show(getChildFragmentManager(), SelectCategoryDialogFragment.TAG);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Button saveButton = (Button) view.findViewById(R.id.save_button);
|
||||
saveButton.setTextColor(getResources().getColor(activeColorResId));
|
||||
|
@ -100,17 +124,6 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
}
|
||||
});
|
||||
|
||||
if (editor.isNew()) {
|
||||
deleteButton.setVisibility(View.GONE);
|
||||
} else {
|
||||
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_caption).setBackgroundResource(!editor.isLight() ? R.color.activity_background_color_dark : R.color.activity_background_color_light);
|
||||
|
||||
OsmandTextFieldBoxes nameCaption = (OsmandTextFieldBoxes) view.findViewById(R.id.name_caption);
|
||||
AndroidUtils.setTextSecondaryColor(view.getContext(), nameCaption.getEditText(), !editor.isLight());
|
||||
nameCaption.getEditText().setText(getNameCaption());
|
||||
|
@ -122,6 +135,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
AndroidUtils.setTextPrimaryColor(view.getContext(), nameEdit, !editor.isLight());
|
||||
AndroidUtils.setHintTextSecondaryColor(view.getContext(), nameEdit, !editor.isLight());
|
||||
nameEdit.setText(getNameInitValue());
|
||||
nameIcon = (ImageView) view.findViewById(R.id.name_icon);
|
||||
// AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) view.findViewById(R.id.category_edit);
|
||||
// AndroidUtils.setTextPrimaryColor(view.getContext(), categoryEdit, !editor.isLight());
|
||||
// categoryEdit.setText(getCategoryInitValue());
|
||||
|
@ -140,15 +154,30 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
// }
|
||||
// });
|
||||
|
||||
// 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());
|
||||
final OsmandTextFieldBoxes descriptionCaption = (OsmandTextFieldBoxes) view.findViewById(R.id.description_caption);
|
||||
addDelDescription = (Button) view.findViewById(R.id.description_button);
|
||||
addDelDescription.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!descriptionCaption.isActivated()) {
|
||||
descriptionCaption.activate(true);
|
||||
descriptionCaption.setVisibility(View.VISIBLE);
|
||||
addDelDescription.setText(view.getResources().getString(R.string.delete_description));
|
||||
} else {
|
||||
descriptionCaption.deactivate();
|
||||
descriptionCaption.setVisibility(View.GONE);
|
||||
addDelDescription.setText(view.getResources().getString(R.string.add_description));
|
||||
}
|
||||
}
|
||||
});
|
||||
nameIcon.setImageDrawable(getNameIcon());
|
||||
// ImageView categoryImage = (ImageView) view.findViewById(R.id.category_image);
|
||||
// categoryImage.setImageDrawable(getCategoryIcon());
|
||||
|
||||
|
@ -160,6 +189,26 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
// categoryEdit.setHint(R.string.access_hint_enter_category);
|
||||
// descriptionEdit.setHint(R.string.access_hint_enter_description);
|
||||
}
|
||||
|
||||
if (editor.isNew()) {
|
||||
toolbarAction.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_replace, activeColorResId));
|
||||
deleteButton.setVisibility(View.GONE);
|
||||
descriptionCaption.setVisibility(View.GONE);
|
||||
deleteIcon.setVisibility(View.GONE);
|
||||
} else {
|
||||
toolbarAction.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_delete_dark, activeColorResId));
|
||||
deleteButton.setVisibility(View.VISIBLE);
|
||||
deleteIcon.setVisibility(View.VISIBLE);
|
||||
if (!descriptionEdit.getText().toString().isEmpty()) {
|
||||
descriptionCaption.activate(true);
|
||||
descriptionCaption.setVisibility(View.VISIBLE);
|
||||
addDelDescription.setText(app.getString(R.string.delete_description));
|
||||
} else {
|
||||
descriptionCaption.deactivate();
|
||||
descriptionCaption.setVisibility(View.GONE);
|
||||
addDelDescription.setText(app.getString(R.string.add_description));
|
||||
}
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -281,6 +330,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
public abstract String getToolbarTitle();
|
||||
|
||||
public void setCategory(String name, int color) {
|
||||
//todo renew category list
|
||||
AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) view.findViewById(R.id.category_edit);
|
||||
String n = name.length() == 0 ? getDefaultCategoryName() : name;
|
||||
categoryEdit.setText(n);
|
||||
|
|
Loading…
Reference in a new issue