From 7227478dfb13d27d445e1ef1693a82730c871b9a Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Wed, 10 Mar 2021 00:30:43 +0200 Subject: [PATCH 1/3] Review "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. --- .../res/layout/add_new_favorite_category.xml | 5 ++- .../plus/helpers/SearchHistoryHelper.java | 4 +- .../AddNewFavoriteCategoryBottomSheet.java | 3 -- .../editors/PointEditorFragment.java | 7 ++-- .../editors/PointEditorFragmentNew.java | 9 ++++- .../editors/RtePtEditorFragment.java | 2 +- .../SelectFavoriteCategoryBottomSheet.java | 37 +++++++++++++------ .../editors/WptPtEditorFragment.java | 2 +- .../editors/WptPtEditorFragmentNew.java | 2 +- .../quickaction/actions/FavoriteAction.java | 2 +- .../plus/quickaction/actions/GPXAction.java | 2 +- 11 files changed, 48 insertions(+), 27 deletions(-) diff --git a/OsmAnd/res/layout/add_new_favorite_category.xml b/OsmAnd/res/layout/add_new_favorite_category.xml index 74510f0842..c54020040a 100644 --- a/OsmAnd/res/layout/add_new_favorite_category.xml +++ b/OsmAnd/res/layout/add_new_favorite_category.xml @@ -21,7 +21,10 @@ android:paddingLeft="@dimen/content_padding" android:paddingEnd="@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"> getHistoryEntries(boolean onlyPoints) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/AddNewFavoriteCategoryBottomSheet.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/AddNewFavoriteCategoryBottomSheet.java index d90c06b609..5485c3a79a 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/AddNewFavoriteCategoryBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/AddNewFavoriteCategoryBottomSheet.java @@ -169,7 +169,6 @@ public class AddNewFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag view = UiUtilities.getInflater(app, nightMode).inflate(R.layout.add_new_favorite_category, null); 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)); ColorStateList colorStateList = ColorStateList.valueOf(ContextCompat .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(); AndroidUtils.softKeyboardDelayed(getActivity(), editText); nameTextBox.setStartIconTintList(ColorStateList.valueOf(selectedColor)); - nameTextBox.setBoxStrokeColorStateList(ColorStateList.valueOf(selectedColor)); BaseBottomSheetItem editFolderName = new BaseBottomSheetItem.Builder() .setCustomView(view) @@ -200,7 +198,6 @@ public class AddNewFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag ((TextView) view.findViewById(R.id.color_name)).setText(ColorDialogs.getColorName(color)); selectedColor = color; nameTextBox.setStartIconTintList(ColorStateList.valueOf(selectedColor)); - nameTextBox.setBoxStrokeColorStateList(ColorStateList.valueOf(selectedColor)); } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java index 8b8fc64f5b..9d5c86d111 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java @@ -32,7 +32,6 @@ import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.BaseOsmAndFragment; -import net.osmand.plus.base.BottomSheetDialogFragment; import net.osmand.plus.widgets.AutoCompleteTextViewEx; import net.osmand.util.Algorithms; @@ -77,7 +76,7 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment { dismiss(); } }); - + 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); @@ -182,7 +181,7 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment { protected DialogFragment createSelectCategoryDialog() { PointEditor editor = getEditor(); if (editor != null) { - return SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag()); + return SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag(), "getSelectedCategory()"); } else { return null; } @@ -364,7 +363,7 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment { if (isPersonalCategoryDisplayName(requireContext(), name)) { return PERSONAL_CATEGORY; } - if(name.equals(getDefaultCategoryName())) { + if (name.equals(getDefaultCategoryName())) { return ""; } return name; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java index 946351baa0..b8fb261f09 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java @@ -739,12 +739,19 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen protected DialogFragment createSelectCategoryDialog() { PointEditor editor = getEditor(); if (editor != null) { - return SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag()); + return SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag(), getSelectedCategory()); } else { return null; } } + public String getSelectedCategory() { + if (groupListAdapter != null && groupListAdapter.getSelectedItem() != null) { + return groupListAdapter.getSelectedItem(); + } + return getCategoryInitValue(); + } + @Nullable protected AddNewFavoriteCategoryBottomSheet createAddCategoryDialog() { PointEditor editor = getEditor(); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/RtePtEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/RtePtEditorFragment.java index 9bbbb0ec34..e2e8a8490e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/RtePtEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/RtePtEditorFragment.java @@ -23,7 +23,7 @@ public class RtePtEditorFragment extends WptPtEditorFragment { @Override protected DialogFragment createSelectCategoryDialog() { 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) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/SelectFavoriteCategoryBottomSheet.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/SelectFavoriteCategoryBottomSheet.java index c3ee4169dc..fd1102cdd8 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/SelectFavoriteCategoryBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/SelectFavoriteCategoryBottomSheet.java @@ -43,7 +43,9 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag 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_CURRENT_CATEGORY = "key_ctx_sel_current_category"; private static String editorTag; + private static String selectedCategory; private OsmandApplication app; private GPXUtilities.GPXFile gpxFile; private Map gpxCategories; @@ -60,10 +62,11 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag return drawable; } - public static SelectFavoriteCategoryBottomSheet createInstance(String editorTag) { + public static SelectFavoriteCategoryBottomSheet createInstance(String editorTag, String selectedCategory) { SelectFavoriteCategoryBottomSheet fragment = new SelectFavoriteCategoryBottomSheet(); Bundle bundle = new Bundle(); bundle.putString(KEY_CTX_SEL_CAT_EDITOR_TAG, editorTag); + bundle.putString(KEY_CTX_SEL_CURRENT_CATEGORY, selectedCategory); fragment.setArguments(bundle); fragment.setRetainInstance(true); return fragment; @@ -94,6 +97,12 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag restoreState(getArguments()); } + if (selectedCategory == null) { + restoreState(savedInstanceState); + } else if (getArguments() != null) { + restoreState(getArguments()); + } + BaseBottomSheetItem titleItem = new BottomSheetItemWithDescription.Builder() .setDescription(getString(R.string.select_category_descr)) .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); ScrollView scrollContainer = favoriteCategoryList.findViewById(R.id.scroll_container); 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); final FavouritesDbHelper favoritesHelper = app.getFavorites(); if (gpxFile != null) { if (gpxCategories != null) { for (Map.Entry e : gpxCategories.entrySet()) { - String categoryName = e.getKey(); - String favoriteCategoryCount = String.valueOf(e.getKey().length()); - favoriteCategoryContainer.addView(createCategoryItem(activity, nightMode, categoryName, e.getValue(), favoriteCategoryCount, false)); + String favoriteCategoryCount; + if (Algorithms.isEmpty(gpxFile.getPointsByCategories().get(e.getKey()))) { + 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 { @@ -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); final AppCompatImageView button = (AppCompatImageView) itemView.findViewById(R.id.icon); 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); descriptionContainer.setPadding(0, 0, 0, 0); View divider = itemView.findViewById(R.id.divider_bottom); divider.setVisibility(View.GONE); itemView.setPadding(0, 0, 0, 0); - final RadioButton compoundButton = itemView.findViewById(R.id.compound_button); int activeColorId = nightMode ? 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) { 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))); } } + 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; TextView text = itemView.findViewById(R.id.title); TextView description = itemView.findViewById(R.id.description); @@ -204,7 +217,6 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag @Override public void onClick(View v) { FragmentActivity a = getActivity(); - compoundButton.setSelected(true); if (a instanceof MapActivity) { PointEditor pointEditor = ((MapActivity) a).getContextMenu().getPointEditor(editorTag); if (pointEditor != null) { @@ -222,6 +234,7 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag public void restoreState(Bundle bundle) { editorTag = bundle.getString(KEY_CTX_SEL_CAT_EDITOR_TAG); + selectedCategory = bundle.getString(KEY_CTX_SEL_CURRENT_CATEGORY); } public interface CategorySelectionListener { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java index a3efbca5ad..2d0654301b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java @@ -67,7 +67,7 @@ public class WptPtEditorFragment extends PointEditorFragment { protected DialogFragment createSelectCategoryDialog() { WptPtEditor editor = getWptPtEditor(); if (editor != null) { - SelectFavoriteCategoryBottomSheet selectCategoryDialogFragment = SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag()); + SelectFavoriteCategoryBottomSheet selectCategoryDialogFragment = SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag(), ""); GPXFile gpx = editor.getGpxFile(); if (gpx != null) { selectCategoryDialogFragment.setGpxFile(gpx); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java index 456049403e..ae30904896 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java @@ -81,7 +81,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew { protected DialogFragment createSelectCategoryDialog() { WptPtEditor editor = getWptPtEditor(); if (editor != null) { - SelectFavoriteCategoryBottomSheet selectCategoryDialogFragment = SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag()); + SelectFavoriteCategoryBottomSheet selectCategoryDialogFragment = SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag(), getSelectedCategory()); GPXFile gpx = editor.getGpxFile(); if (gpx != null) { selectCategoryDialogFragment.setGpxFile(gpx); diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/FavoriteAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/FavoriteAction.java index ecd277b092..5331045af4 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/FavoriteAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/FavoriteAction.java @@ -176,7 +176,7 @@ public class FavoriteAction extends QuickAction { @Override public void onClick(final View view) { - SelectFavoriteCategoryBottomSheet dialogFragment = SelectFavoriteCategoryBottomSheet.createInstance(""); + SelectFavoriteCategoryBottomSheet dialogFragment = SelectFavoriteCategoryBottomSheet.createInstance("", ""); dialogFragment.show( activity.getSupportFragmentManager(), diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/GPXAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/GPXAction.java index d0bfd98cbf..ca45f06413 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/GPXAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/GPXAction.java @@ -120,7 +120,7 @@ public class GPXAction extends QuickAction { @Override public void onClick(final View view) { - SelectFavoriteCategoryBottomSheet dialogFragment = SelectFavoriteCategoryBottomSheet.createInstance(""); + SelectFavoriteCategoryBottomSheet dialogFragment = SelectFavoriteCategoryBottomSheet.createInstance("", ""); dialogFragment.show( activity.getSupportFragmentManager(), From 71ae5345b166388a836a595bb3a204532a9de1b5 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Thu, 11 Mar 2021 15:10:51 +0200 Subject: [PATCH 2/3] Review2 --- ...om_sheet_item_with_descr_and_radio_btn.xml | 8 ++--- .../res/layout/favorite_categories_dialog.xml | 28 +++++++-------- .../editors/PointEditorFragment.java | 2 +- .../SelectFavoriteCategoryBottomSheet.java | 34 ++++++++----------- 4 files changed, 33 insertions(+), 39 deletions(-) diff --git a/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_radio_btn.xml b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_radio_btn.xml index d4d052c868..00d901de57 100644 --- a/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_radio_btn.xml +++ b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_radio_btn.xml @@ -1,6 +1,5 @@ - diff --git a/OsmAnd/res/layout/favorite_categories_dialog.xml b/OsmAnd/res/layout/favorite_categories_dialog.xml index 5dc2e799c4..6e81f248b7 100644 --- a/OsmAnd/res/layout/favorite_categories_dialog.xml +++ b/OsmAnd/res/layout/favorite_categories_dialog.xml @@ -1,21 +1,21 @@ + android:paddingLeft="@dimen/dialog_content_margin" + android:paddingTop="@dimen/dialog_content_bottom_margin" + android:paddingEnd="@dimen/dialog_content_margin" + android:paddingRight="@dimen/dialog_content_margin" + android:paddingBottom="@dimen/dialog_content_bottom_margin"> - + - + diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java index 9d5c86d111..5f03754847 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java @@ -181,7 +181,7 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment { protected DialogFragment createSelectCategoryDialog() { PointEditor editor = getEditor(); if (editor != null) { - return SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag(), "getSelectedCategory()"); + return SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag(), ""); } else { return null; } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/SelectFavoriteCategoryBottomSheet.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/SelectFavoriteCategoryBottomSheet.java index fd1102cdd8..2a868fc40d 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/SelectFavoriteCategoryBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/SelectFavoriteCategoryBottomSheet.java @@ -42,8 +42,8 @@ import java.util.Set; public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFragment { 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_CURRENT_CATEGORY = "key_ctx_sel_current_category"; + private static final String SELECT_CATEGORY_EDITOR_TAG = "select_category_editor_tag"; + private static final String SELECT_CURRENT_CATEGORY_EDITOR_TAG = "select_current_category_editor_tag"; private static String editorTag; private static String selectedCategory; private OsmandApplication app; @@ -65,8 +65,8 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag public static SelectFavoriteCategoryBottomSheet createInstance(String editorTag, String selectedCategory) { SelectFavoriteCategoryBottomSheet fragment = new SelectFavoriteCategoryBottomSheet(); Bundle bundle = new Bundle(); - bundle.putString(KEY_CTX_SEL_CAT_EDITOR_TAG, editorTag); - bundle.putString(KEY_CTX_SEL_CURRENT_CATEGORY, selectedCategory); + bundle.putString(SELECT_CATEGORY_EDITOR_TAG, editorTag); + bundle.putString(SELECT_CURRENT_CATEGORY_EDITOR_TAG, selectedCategory); fragment.setArguments(bundle); fragment.setRetainInstance(true); return fragment; @@ -91,13 +91,7 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag @Override public void createMenuItems(Bundle savedInstanceState) { app = requiredMyApplication(); - if (savedInstanceState != null) { - restoreState(savedInstanceState); - } else if (getArguments() != null) { - restoreState(getArguments()); - } - - if (selectedCategory == null) { + if (savedInstanceState != null && selectedCategory == null) { restoreState(savedInstanceState); } else if (getArguments() != null) { restoreState(getArguments()); @@ -145,16 +139,16 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag View favoriteCategoryList = UiUtilities.getInflater(app, nightMode).inflate(R.layout.favorite_categories_dialog, null); ScrollView scrollContainer = favoriteCategoryList.findViewById(R.id.scroll_container); - final int dp16 = AndroidUtils.dpToPx(app, 16f); - scrollContainer.setPadding(dp16, 0, dp16, 0); + scrollContainer.setPadding(0, 0, 0, 0); LinearLayout favoriteCategoryContainer = favoriteCategoryList.findViewById(R.id.list_container); final FavouritesDbHelper favoritesHelper = app.getFavorites(); if (gpxFile != null) { if (gpxCategories != null) { + Map> pointsCategories = gpxFile.getPointsByCategories(); for (Map.Entry e : gpxCategories.entrySet()) { String favoriteCategoryCount; - if (Algorithms.isEmpty(gpxFile.getPointsByCategories().get(e.getKey()))) { + if (Algorithms.isEmpty(pointsCategories.get(e.getKey()))) { favoriteCategoryCount = app.getString(R.string.shared_string_empty); } else { favoriteCategoryCount = String.valueOf(gpxFile.getPointsByCategories().get(e.getKey()).size()); @@ -184,9 +178,10 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag 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 int dp8 = AndroidUtils.dpToPx(app, 8f); + final int dp16 = AndroidUtils.dpToPx(app, 16f); button.setPadding(0, 0, dp8, 0); LinearLayout descriptionContainer = itemView.findViewById(R.id.descriptionContainer); - descriptionContainer.setPadding(0, 0, 0, 0); + descriptionContainer.setPadding(dp16, 0, dp16, 0); View divider = itemView.findViewById(R.id.divider_bottom); divider.setVisibility(View.GONE); itemView.setPadding(0, 0, 0, 0); @@ -203,9 +198,8 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag 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); + RadioButton compoundButton = itemView.findViewById(R.id.compound_button); + compoundButton.setChecked(Algorithms.stringsEqual(selectedCategory, categoryName)); UiUtilities.setupCompoundButton(nightMode, ContextCompat.getColor(app, activeColorId), compoundButton); String name = categoryName.length() == 0 ? getString(R.string.shared_string_favorites) : categoryName; @@ -233,8 +227,8 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag } public void restoreState(Bundle bundle) { - editorTag = bundle.getString(KEY_CTX_SEL_CAT_EDITOR_TAG); - selectedCategory = bundle.getString(KEY_CTX_SEL_CURRENT_CATEGORY); + editorTag = bundle.getString(SELECT_CATEGORY_EDITOR_TAG); + selectedCategory = bundle.getString(SELECT_CURRENT_CATEGORY_EDITOR_TAG); } public interface CategorySelectionListener { From fa8140b74c15007acada98d6d54ebe806daed364 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Thu, 11 Mar 2021 17:23:48 +0200 Subject: [PATCH 3/3] Small fixes --- .../layout/bottom_sheet_item_with_descr_and_radio_btn.xml | 3 +-- OsmAnd/res/layout/favorite_categories_dialog.xml | 2 +- .../editors/SelectFavoriteCategoryBottomSheet.java | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_radio_btn.xml b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_radio_btn.xml index 00d901de57..0f2318da57 100644 --- a/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_radio_btn.xml +++ b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_radio_btn.xml @@ -10,7 +10,6 @@ android:id="@+id/descriptionContainer" android:layout_width="match_parent" android:layout_height="@dimen/bottom_sheet_large_list_item_height" - android:background="?attr/selectableItemBackground" android:gravity="center_vertical" android:orientation="horizontal" android:paddingStart="@dimen/list_content_padding" @@ -61,7 +60,7 @@ android:id="@+id/compound_button" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="?attr/selectableItemBackground" + android:background="@null" android:clickable="false" android:focusable="false" android:saveEnabled="false" /> diff --git a/OsmAnd/res/layout/favorite_categories_dialog.xml b/OsmAnd/res/layout/favorite_categories_dialog.xml index 6e81f248b7..50901b0a7b 100644 --- a/OsmAnd/res/layout/favorite_categories_dialog.xml +++ b/OsmAnd/res/layout/favorite_categories_dialog.xml @@ -1,7 +1,7 @@