Review2
This commit is contained in:
parent
7227478dfb
commit
71ae5345b1
4 changed files with 33 additions and 39 deletions
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_large_list_item_height"
|
||||
|
@ -8,9 +7,10 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
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 +61,7 @@
|
|||
android:id="@+id/compound_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:saveEnabled="false" />
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
android:id="@+id/scroll_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/dialog_content_bottom_margin"
|
||||
android:paddingLeft="@dimen/dialog_content_margin"
|
||||
android:paddingRight="@dimen/dialog_content_margin"
|
||||
android:paddingTop="@dimen/dialog_content_bottom_margin"
|
||||
android:paddingStart="@dimen/dialog_content_margin"
|
||||
android:paddingEnd="@dimen/dialog_content_margin">
|
||||
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">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/list_container"
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<String, List<GPXUtilities.WptPt>> pointsCategories = gpxFile.getPointsByCategories();
|
||||
for (Map.Entry<String, Integer> 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 {
|
||||
|
|
Loading…
Reference in a new issue