From 22f61195b2f88431b940e9f72658c3df184fcc14 Mon Sep 17 00:00:00 2001 From: Pratham Pahariya <54663429+Pratham2305@users.noreply.github.com> Date: Thu, 17 Jun 2021 18:19:09 +0530 Subject: [PATCH] fix edit categories ui (#4414) Co-authored-by: Pratham2305 --- .../commons/media/MediaDetailFragment.java | 15 +- .../res/layout/layout_edit_categories.xml | 207 +++++++++--------- 2 files changed, 118 insertions(+), 104 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.java b/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.java index 8e6518c44..d9e11076d 100644 --- a/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.java +++ b/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.java @@ -626,6 +626,7 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements categoryEditSearchRecyclerViewAdapter.addToCategories(media.getCategories()); updateSelectedCategoriesTextView(categoryEditSearchRecyclerViewAdapter.getCategories()); + categoryRecyclerView.setVisibility(GONE); updateCategoryList(); if (media.getAuthor() == null || media.getAuthor().equals("")) { @@ -661,20 +662,28 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements public void updateSelectedCategoriesTextView(List selectedCategories) { if (selectedCategories == null || selectedCategories.size() == 0) { updateCategoriesButton.setClickable(false); - } - if (selectedCategories != null) { + updateCategoriesButton.setAlpha(.5f); + } else { existingCategories.setText(StringUtils.join(selectedCategories,", ")); - updateCategoriesButton.setClickable(true); + if (selectedCategories.equals(media.getCategories())) { + updateCategoriesButton.setClickable(false); + updateCategoriesButton.setAlpha(.5f); + } else { + updateCategoriesButton.setClickable(true); + updateCategoriesButton.setAlpha(1f); + } } } @Override public void noResultsFound() { + categoryRecyclerView.setVisibility(GONE); noResultsFound.setVisibility(VISIBLE); } @Override public void someResultsFound() { + categoryRecyclerView.setVisibility(VISIBLE); noResultsFound.setVisibility(GONE); } diff --git a/app/src/main/res/layout/layout_edit_categories.xml b/app/src/main/res/layout/layout_edit_categories.xml index ccbfe822d..5b1cc28ce 100644 --- a/app/src/main/res/layout/layout_edit_categories.xml +++ b/app/src/main/res/layout/layout_edit_categories.xml @@ -1,114 +1,119 @@ - + - - - - - - - - - - - - - - + android:background="?attr/mainBackground" + android:elevation="30dp"> - + + + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/standard_gap" + > + + + + + + + + + + -