"Choose category" indicate selected group (radion button) right next to group
"Choose category" ripple background on tap is missing
"Add new category" text field underline should be OsmAnd active color, not the selected.
"Add new category" text field background is barely visible, check its background color.
This commit is contained in:
androiddevkotlin 2021-03-10 00:30:43 +02:00
parent fe1fda65ff
commit 7227478dfb
11 changed files with 48 additions and 27 deletions

View file

@ -21,7 +21,10 @@
android:paddingLeft="@dimen/content_padding" android:paddingLeft="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding" android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding" android:paddingRight="@dimen/content_padding"
app:startIconDrawable="@drawable/ic_action_folder"> app:startIconDrawable="@drawable/ic_action_folder"
app:boxBackgroundColor="?attr/text_input_background"
app:boxStrokeColor="@color/osmand_orange"
app:hintTextColor="@color/text_color_secondary_light">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:id="@+id/name_edit_text" android:id="@+id/name_edit_text"

View file

@ -57,7 +57,9 @@ public class SearchHistoryHelper {
} }
public void addNewItemToHistory(GPXInfo gpxInfo) { public void addNewItemToHistory(GPXInfo gpxInfo) {
addNewItemToHistory(new HistoryEntry(0, 0, createPointDescription(gpxInfo))); if(gpxInfo != null) {
addNewItemToHistory(new HistoryEntry(0, 0, createPointDescription(gpxInfo)));
}
} }
public List<HistoryEntry> getHistoryEntries(boolean onlyPoints) { public List<HistoryEntry> getHistoryEntries(boolean onlyPoints) {

View file

@ -169,7 +169,6 @@ public class AddNewFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag
view = UiUtilities.getInflater(app, nightMode).inflate(R.layout.add_new_favorite_category, null); view = UiUtilities.getInflater(app, nightMode).inflate(R.layout.add_new_favorite_category, null);
nameTextBox = view.findViewById(R.id.name_text_box); nameTextBox = view.findViewById(R.id.name_text_box);
nameTextBox.setBoxBackgroundColorResource(nightMode ? R.color.list_background_color_dark : R.color.activity_background_color_light);
nameTextBox.setHint(app.getResources().getString(R.string.favorite_category_name)); nameTextBox.setHint(app.getResources().getString(R.string.favorite_category_name));
ColorStateList colorStateList = ColorStateList.valueOf(ContextCompat ColorStateList colorStateList = ColorStateList.valueOf(ContextCompat
.getColor(app, nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light)); .getColor(app, nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light));
@ -179,7 +178,6 @@ public class AddNewFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag
editText.requestFocus(); editText.requestFocus();
AndroidUtils.softKeyboardDelayed(getActivity(), editText); AndroidUtils.softKeyboardDelayed(getActivity(), editText);
nameTextBox.setStartIconTintList(ColorStateList.valueOf(selectedColor)); nameTextBox.setStartIconTintList(ColorStateList.valueOf(selectedColor));
nameTextBox.setBoxStrokeColorStateList(ColorStateList.valueOf(selectedColor));
BaseBottomSheetItem editFolderName = new BaseBottomSheetItem.Builder() BaseBottomSheetItem editFolderName = new BaseBottomSheetItem.Builder()
.setCustomView(view) .setCustomView(view)
@ -200,7 +198,6 @@ public class AddNewFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag
((TextView) view.findViewById(R.id.color_name)).setText(ColorDialogs.getColorName(color)); ((TextView) view.findViewById(R.id.color_name)).setText(ColorDialogs.getColorName(color));
selectedColor = color; selectedColor = color;
nameTextBox.setStartIconTintList(ColorStateList.valueOf(selectedColor)); nameTextBox.setStartIconTintList(ColorStateList.valueOf(selectedColor));
nameTextBox.setBoxStrokeColorStateList(ColorStateList.valueOf(selectedColor));
} }
@Override @Override

View file

@ -32,7 +32,6 @@ import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.base.BottomSheetDialogFragment;
import net.osmand.plus.widgets.AutoCompleteTextViewEx; import net.osmand.plus.widgets.AutoCompleteTextViewEx;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -77,7 +76,7 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment {
dismiss(); dismiss();
} }
}); });
int activeColorResId = !editor.isLight() ? R.color.active_color_primary_dark : R.color.active_color_primary_light; int activeColorResId = !editor.isLight() ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
Button saveButton = (Button) view.findViewById(R.id.save_button); Button saveButton = (Button) view.findViewById(R.id.save_button);
@ -182,7 +181,7 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment {
protected DialogFragment createSelectCategoryDialog() { protected DialogFragment createSelectCategoryDialog() {
PointEditor editor = getEditor(); PointEditor editor = getEditor();
if (editor != null) { if (editor != null) {
return SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag()); return SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag(), "getSelectedCategory()");
} else { } else {
return null; return null;
} }
@ -364,7 +363,7 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment {
if (isPersonalCategoryDisplayName(requireContext(), name)) { if (isPersonalCategoryDisplayName(requireContext(), name)) {
return PERSONAL_CATEGORY; return PERSONAL_CATEGORY;
} }
if(name.equals(getDefaultCategoryName())) { if (name.equals(getDefaultCategoryName())) {
return ""; return "";
} }
return name; return name;

View file

@ -739,12 +739,19 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
protected DialogFragment createSelectCategoryDialog() { protected DialogFragment createSelectCategoryDialog() {
PointEditor editor = getEditor(); PointEditor editor = getEditor();
if (editor != null) { if (editor != null) {
return SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag()); return SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag(), getSelectedCategory());
} else { } else {
return null; return null;
} }
} }
public String getSelectedCategory() {
if (groupListAdapter != null && groupListAdapter.getSelectedItem() != null) {
return groupListAdapter.getSelectedItem();
}
return getCategoryInitValue();
}
@Nullable @Nullable
protected AddNewFavoriteCategoryBottomSheet createAddCategoryDialog() { protected AddNewFavoriteCategoryBottomSheet createAddCategoryDialog() {
PointEditor editor = getEditor(); PointEditor editor = getEditor();

View file

@ -23,7 +23,7 @@ public class RtePtEditorFragment extends WptPtEditorFragment {
@Override @Override
protected DialogFragment createSelectCategoryDialog() { protected DialogFragment createSelectCategoryDialog() {
PointEditor editor = getEditor(); PointEditor editor = getEditor();
return editor != null ? SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag()) : null; return editor != null ? SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag(), "") : null;
} }
public static void showInstance(final MapActivity mapActivity) { public static void showInstance(final MapActivity mapActivity) {

View file

@ -43,7 +43,9 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag
public static final String TAG = SelectFavoriteCategoryBottomSheet.class.getSimpleName(); public static final String TAG = SelectFavoriteCategoryBottomSheet.class.getSimpleName();
private static final String KEY_CTX_SEL_CAT_EDITOR_TAG = "key_ctx_sel_cat_editor_tag"; private static final String KEY_CTX_SEL_CAT_EDITOR_TAG = "key_ctx_sel_cat_editor_tag";
private static final String KEY_CTX_SEL_CURRENT_CATEGORY = "key_ctx_sel_current_category";
private static String editorTag; private static String editorTag;
private static String selectedCategory;
private OsmandApplication app; private OsmandApplication app;
private GPXUtilities.GPXFile gpxFile; private GPXUtilities.GPXFile gpxFile;
private Map<String, Integer> gpxCategories; private Map<String, Integer> gpxCategories;
@ -60,10 +62,11 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag
return drawable; return drawable;
} }
public static SelectFavoriteCategoryBottomSheet createInstance(String editorTag) { public static SelectFavoriteCategoryBottomSheet createInstance(String editorTag, String selectedCategory) {
SelectFavoriteCategoryBottomSheet fragment = new SelectFavoriteCategoryBottomSheet(); SelectFavoriteCategoryBottomSheet fragment = new SelectFavoriteCategoryBottomSheet();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(KEY_CTX_SEL_CAT_EDITOR_TAG, editorTag); bundle.putString(KEY_CTX_SEL_CAT_EDITOR_TAG, editorTag);
bundle.putString(KEY_CTX_SEL_CURRENT_CATEGORY, selectedCategory);
fragment.setArguments(bundle); fragment.setArguments(bundle);
fragment.setRetainInstance(true); fragment.setRetainInstance(true);
return fragment; return fragment;
@ -94,6 +97,12 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag
restoreState(getArguments()); restoreState(getArguments());
} }
if (selectedCategory == null) {
restoreState(savedInstanceState);
} else if (getArguments() != null) {
restoreState(getArguments());
}
BaseBottomSheetItem titleItem = new BottomSheetItemWithDescription.Builder() BaseBottomSheetItem titleItem = new BottomSheetItemWithDescription.Builder()
.setDescription(getString(R.string.select_category_descr)) .setDescription(getString(R.string.select_category_descr))
.setTitle(getString(R.string.favorite_category_select)) .setTitle(getString(R.string.favorite_category_select))
@ -137,16 +146,20 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag
View favoriteCategoryList = UiUtilities.getInflater(app, nightMode).inflate(R.layout.favorite_categories_dialog, null); View favoriteCategoryList = UiUtilities.getInflater(app, nightMode).inflate(R.layout.favorite_categories_dialog, null);
ScrollView scrollContainer = favoriteCategoryList.findViewById(R.id.scroll_container); ScrollView scrollContainer = favoriteCategoryList.findViewById(R.id.scroll_container);
final int dp16 = AndroidUtils.dpToPx(app, 16f); final int dp16 = AndroidUtils.dpToPx(app, 16f);
scrollContainer.setPadding(dp16,0, dp16,0); scrollContainer.setPadding(dp16, 0, dp16, 0);
LinearLayout favoriteCategoryContainer = favoriteCategoryList.findViewById(R.id.list_container); LinearLayout favoriteCategoryContainer = favoriteCategoryList.findViewById(R.id.list_container);
final FavouritesDbHelper favoritesHelper = app.getFavorites(); final FavouritesDbHelper favoritesHelper = app.getFavorites();
if (gpxFile != null) { if (gpxFile != null) {
if (gpxCategories != null) { if (gpxCategories != null) {
for (Map.Entry<String, Integer> e : gpxCategories.entrySet()) { for (Map.Entry<String, Integer> e : gpxCategories.entrySet()) {
String categoryName = e.getKey(); String favoriteCategoryCount;
String favoriteCategoryCount = String.valueOf(e.getKey().length()); if (Algorithms.isEmpty(gpxFile.getPointsByCategories().get(e.getKey()))) {
favoriteCategoryContainer.addView(createCategoryItem(activity, nightMode, categoryName, e.getValue(), favoriteCategoryCount, false)); favoriteCategoryCount = app.getString(R.string.shared_string_empty);
} else {
favoriteCategoryCount = String.valueOf(gpxFile.getPointsByCategories().get(e.getKey()).size());
}
favoriteCategoryContainer.addView(createCategoryItem(activity, nightMode, e.getKey(), e.getValue(), favoriteCategoryCount, false));
} }
} }
} else { } else {
@ -171,19 +184,14 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag
View itemView = UiUtilities.getInflater(activity, nightMode).inflate(R.layout.bottom_sheet_item_with_descr_and_radio_btn, null); View itemView = UiUtilities.getInflater(activity, nightMode).inflate(R.layout.bottom_sheet_item_with_descr_and_radio_btn, null);
final AppCompatImageView button = (AppCompatImageView) itemView.findViewById(R.id.icon); final AppCompatImageView button = (AppCompatImageView) itemView.findViewById(R.id.icon);
final int dp8 = AndroidUtils.dpToPx(app, 8f); final int dp8 = AndroidUtils.dpToPx(app, 8f);
button.setPadding(0,0, dp8,0); button.setPadding(0, 0, dp8, 0);
LinearLayout descriptionContainer = itemView.findViewById(R.id.descriptionContainer); LinearLayout descriptionContainer = itemView.findViewById(R.id.descriptionContainer);
descriptionContainer.setPadding(0, 0, 0, 0); descriptionContainer.setPadding(0, 0, 0, 0);
View divider = itemView.findViewById(R.id.divider_bottom); View divider = itemView.findViewById(R.id.divider_bottom);
divider.setVisibility(View.GONE); divider.setVisibility(View.GONE);
itemView.setPadding(0, 0, 0, 0); itemView.setPadding(0, 0, 0, 0);
final RadioButton compoundButton = itemView.findViewById(R.id.compound_button);
int activeColorId = nightMode ? int activeColorId = nightMode ?
R.color.active_color_primary_dark : R.color.active_color_primary_light; R.color.active_color_primary_dark : R.color.active_color_primary_light;
int disableColorId = nightMode ?
R.color.icon_color_default_dark : R.color.icon_color_default_light;
UiUtilities.setupCompoundButton(nightMode, ContextCompat.getColor(app,
nightMode ? activeColorId : disableColorId), compoundButton);
if (isHidden) { if (isHidden) {
button.setImageResource(R.drawable.ic_action_hide); button.setImageResource(R.drawable.ic_action_hide);
@ -195,6 +203,11 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag
gpxFile != null ? R.color.gpx_color_point : R.color.color_favorite))); gpxFile != null ? R.color.gpx_color_point : R.color.color_favorite)));
} }
} }
final RadioButton compoundButton = itemView.findViewById(R.id.compound_button);
final boolean isSelectedCategory = selectedCategory.equals(categoryName);
compoundButton.setChecked(isSelectedCategory);
UiUtilities.setupCompoundButton(nightMode, ContextCompat.getColor(app,
activeColorId), compoundButton);
String name = categoryName.length() == 0 ? getString(R.string.shared_string_favorites) : categoryName; String name = categoryName.length() == 0 ? getString(R.string.shared_string_favorites) : categoryName;
TextView text = itemView.findViewById(R.id.title); TextView text = itemView.findViewById(R.id.title);
TextView description = itemView.findViewById(R.id.description); TextView description = itemView.findViewById(R.id.description);
@ -204,7 +217,6 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag
@Override @Override
public void onClick(View v) { public void onClick(View v) {
FragmentActivity a = getActivity(); FragmentActivity a = getActivity();
compoundButton.setSelected(true);
if (a instanceof MapActivity) { if (a instanceof MapActivity) {
PointEditor pointEditor = ((MapActivity) a).getContextMenu().getPointEditor(editorTag); PointEditor pointEditor = ((MapActivity) a).getContextMenu().getPointEditor(editorTag);
if (pointEditor != null) { if (pointEditor != null) {
@ -222,6 +234,7 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag
public void restoreState(Bundle bundle) { public void restoreState(Bundle bundle) {
editorTag = bundle.getString(KEY_CTX_SEL_CAT_EDITOR_TAG); editorTag = bundle.getString(KEY_CTX_SEL_CAT_EDITOR_TAG);
selectedCategory = bundle.getString(KEY_CTX_SEL_CURRENT_CATEGORY);
} }
public interface CategorySelectionListener { public interface CategorySelectionListener {

View file

@ -67,7 +67,7 @@ public class WptPtEditorFragment extends PointEditorFragment {
protected DialogFragment createSelectCategoryDialog() { protected DialogFragment createSelectCategoryDialog() {
WptPtEditor editor = getWptPtEditor(); WptPtEditor editor = getWptPtEditor();
if (editor != null) { if (editor != null) {
SelectFavoriteCategoryBottomSheet selectCategoryDialogFragment = SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag()); SelectFavoriteCategoryBottomSheet selectCategoryDialogFragment = SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag(), "");
GPXFile gpx = editor.getGpxFile(); GPXFile gpx = editor.getGpxFile();
if (gpx != null) { if (gpx != null) {
selectCategoryDialogFragment.setGpxFile(gpx); selectCategoryDialogFragment.setGpxFile(gpx);

View file

@ -81,7 +81,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
protected DialogFragment createSelectCategoryDialog() { protected DialogFragment createSelectCategoryDialog() {
WptPtEditor editor = getWptPtEditor(); WptPtEditor editor = getWptPtEditor();
if (editor != null) { if (editor != null) {
SelectFavoriteCategoryBottomSheet selectCategoryDialogFragment = SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag()); SelectFavoriteCategoryBottomSheet selectCategoryDialogFragment = SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag(), getSelectedCategory());
GPXFile gpx = editor.getGpxFile(); GPXFile gpx = editor.getGpxFile();
if (gpx != null) { if (gpx != null) {
selectCategoryDialogFragment.setGpxFile(gpx); selectCategoryDialogFragment.setGpxFile(gpx);

View file

@ -176,7 +176,7 @@ public class FavoriteAction extends QuickAction {
@Override @Override
public void onClick(final View view) { public void onClick(final View view) {
SelectFavoriteCategoryBottomSheet dialogFragment = SelectFavoriteCategoryBottomSheet.createInstance(""); SelectFavoriteCategoryBottomSheet dialogFragment = SelectFavoriteCategoryBottomSheet.createInstance("", "");
dialogFragment.show( dialogFragment.show(
activity.getSupportFragmentManager(), activity.getSupportFragmentManager(),

View file

@ -120,7 +120,7 @@ public class GPXAction extends QuickAction {
@Override @Override
public void onClick(final View view) { public void onClick(final View view) {
SelectFavoriteCategoryBottomSheet dialogFragment = SelectFavoriteCategoryBottomSheet.createInstance(""); SelectFavoriteCategoryBottomSheet dialogFragment = SelectFavoriteCategoryBottomSheet.createInstance("", "");
dialogFragment.show( dialogFragment.show(
activity.getSupportFragmentManager(), activity.getSupportFragmentManager(),