Skip to content

Commit 22f6119

Browse files
authored
fix edit categories ui (commons-app#4414)
Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com>
1 parent 3494fd0 commit 22f6119

File tree

2 files changed

+114
-100
lines changed

2 files changed

+114
-100
lines changed

app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ private void setTextFields(Media media) {
626626
categoryEditSearchRecyclerViewAdapter.addToCategories(media.getCategories());
627627
updateSelectedCategoriesTextView(categoryEditSearchRecyclerViewAdapter.getCategories());
628628

629+
categoryRecyclerView.setVisibility(GONE);
629630
updateCategoryList();
630631

631632
if (media.getAuthor() == null || media.getAuthor().equals("")) {
@@ -661,20 +662,28 @@ private void updateCategoryList() {
661662
public void updateSelectedCategoriesTextView(List<String> selectedCategories) {
662663
if (selectedCategories == null || selectedCategories.size() == 0) {
663664
updateCategoriesButton.setClickable(false);
664-
}
665-
if (selectedCategories != null) {
665+
updateCategoriesButton.setAlpha(.5f);
666+
} else {
666667
existingCategories.setText(StringUtils.join(selectedCategories,", "));
667-
updateCategoriesButton.setClickable(true);
668+
if (selectedCategories.equals(media.getCategories())) {
669+
updateCategoriesButton.setClickable(false);
670+
updateCategoriesButton.setAlpha(.5f);
671+
} else {
672+
updateCategoriesButton.setClickable(true);
673+
updateCategoriesButton.setAlpha(1f);
674+
}
668675
}
669676
}
670677

671678
@Override
672679
public void noResultsFound() {
680+
categoryRecyclerView.setVisibility(GONE);
673681
noResultsFound.setVisibility(VISIBLE);
674682
}
675683

676684
@Override
677685
public void someResultsFound() {
686+
categoryRecyclerView.setVisibility(VISIBLE);
678687
noResultsFound.setVisibility(GONE);
679688
}
680689

Lines changed: 102 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,119 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout
3-
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
4-
android:id="@+id/category_edit_layout"
5-
android:layout_height="wrap_content"
6-
android:layout_margin="15dp"
7-
android:orientation="vertical"
8-
android:background="?attr/mainBackground"
9-
android:elevation="30dp">
2+
<ScrollView
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:layout_width="match_parent"
5+
android:layout_height="wrap_content">
106

11-
<TextView
12-
android:id="@+id/tv_subtitle"
13-
android:layout_width="wrap_content"
14-
android:layout_height="@dimen/half_standard_height"
15-
android:layout_margin="@dimen/quarter_standard_height"
16-
android:gravity="center_vertical"
17-
android:text="Type categories"
18-
android:textSize="@dimen/subtitle_text"
19-
android:visibility="visible" />
20-
21-
<FrameLayout
22-
android:id="@+id/category_search_layout"
7+
<LinearLayout
238
android:layout_width="match_parent"
9+
android:id="@+id/category_edit_layout"
2410
android:layout_height="wrap_content"
25-
android:layout_marginTop="@dimen/standard_gap"
26-
>
27-
<com.google.android.material.textfield.TextInputLayout
28-
android:id="@+id/til_container_search"
29-
android:layout_width="match_parent"
30-
android:layout_height="wrap_content">
31-
32-
<SearchView
33-
android:id="@+id/et_search"
34-
android:layout_width="match_parent"
35-
android:layout_height="wrap_content"
36-
android:hint="@string/categories_search_text_hint"
37-
android:imeOptions="actionSearch"
38-
android:inputType="text"
39-
android:maxLines="1"/>
40-
</com.google.android.material.textfield.TextInputLayout>
11+
android:layout_margin="15dp"
12+
android:orientation="vertical"
13+
android:background="?attr/mainBackground"
14+
android:elevation="30dp">
4115

42-
<ProgressBar
43-
android:id="@+id/pb_categories"
44-
style="?android:progressBarStyleSmall"
16+
<TextView
17+
android:id="@+id/tv_subtitle"
4518
android:layout_width="wrap_content"
19+
android:layout_height="@dimen/half_standard_height"
20+
android:layout_margin="@dimen/quarter_standard_height"
21+
android:gravity="center_vertical"
22+
android:text="Type categories"
23+
android:textSize="@dimen/subtitle_text"
24+
android:visibility="visible" />
25+
26+
<FrameLayout
27+
android:id="@+id/category_search_layout"
28+
android:layout_width="match_parent"
4629
android:layout_height="wrap_content"
47-
android:layout_marginEnd="@dimen/tiny_gap"
48-
android:layout_marginRight="@dimen/tiny_gap"
49-
android:layout_gravity="center_vertical|end"
50-
android:indeterminate="true"
51-
android:indeterminateOnly="true"
52-
android:visibility="gone" />
53-
</FrameLayout>
30+
android:layout_marginTop="@dimen/standard_gap"
31+
>
32+
<com.google.android.material.textfield.TextInputLayout
33+
android:id="@+id/til_container_search"
34+
android:layout_width="match_parent"
35+
android:layout_height="wrap_content">
5436

55-
<TextView
56-
android:id="@+id/existing_categories"
57-
android:layout_width="match_parent"
58-
android:layout_height="wrap_content"
59-
android:layout_margin="@dimen/quarter_standard_height"
60-
android:gravity="center_vertical"
61-
android:textSize="@dimen/subtitle_text"
62-
android:visibility="visible" />
37+
<SearchView
38+
android:id="@+id/et_search"
39+
android:layout_width="match_parent"
40+
android:layout_height="wrap_content"
41+
android:queryHint="@string/categories_search_text_hint"
42+
android:iconifiedByDefault="false"
43+
android:imeOptions="actionSearch"
44+
android:inputType="text"
45+
android:maxLines="1"/>
46+
</com.google.android.material.textfield.TextInputLayout>
6347

64-
<TextView
65-
android:id="@+id/no_results_found"
66-
android:layout_width="match_parent"
67-
android:layout_height="wrap_content"
68-
android:layout_margin="@dimen/quarter_standard_height"
69-
android:gravity="center_vertical"
70-
android:text="No results found"
71-
android:textSize="@dimen/description_text_size"
72-
android:visibility="gone" />
73-
<LinearLayout
74-
android:layout_width="match_parent"
75-
android:layout_height="match_parent"
76-
android:orientation="vertical"
77-
android:weightSum="6"
78-
>
48+
<ProgressBar
49+
android:id="@+id/pb_categories"
50+
style="?android:progressBarStyleSmall"
51+
android:layout_width="wrap_content"
52+
android:layout_height="wrap_content"
53+
android:layout_marginEnd="@dimen/tiny_gap"
54+
android:layout_marginRight="@dimen/tiny_gap"
55+
android:layout_gravity="center_vertical|end"
56+
android:indeterminate="true"
57+
android:indeterminateOnly="true"
58+
android:visibility="gone" />
59+
</FrameLayout>
7960

80-
<androidx.recyclerview.widget.RecyclerView
81-
android:id="@+id/rv_categories"
61+
<TextView
62+
android:id="@+id/existing_categories"
8263
android:layout_width="match_parent"
83-
android:layout_height="0dp"
84-
android:layout_weight="4"
85-
android:background="?attr/mainBackground"/>
64+
android:layout_height="wrap_content"
65+
android:layout_margin="@dimen/quarter_standard_height"
66+
android:gravity="center_vertical"
67+
android:textSize="@dimen/subtitle_text"
68+
android:visibility="visible" />
8669

70+
<TextView
71+
android:id="@+id/no_results_found"
72+
android:layout_width="match_parent"
73+
android:layout_height="wrap_content"
74+
android:layout_margin="@dimen/quarter_standard_height"
75+
android:gravity="center_vertical"
76+
android:text="No results found"
77+
android:textSize="@dimen/description_text_size"
78+
android:visibility="gone" />
8779
<LinearLayout
8880
android:layout_width="match_parent"
89-
android:layout_height="0dp"
90-
android:layout_weight="2">
91-
<Button
92-
android:id="@+id/cancel_categories_button"
93-
android:layout_width="wrap_content"
94-
android:layout_margin="@dimen/quarter_standard_height"
95-
android:layout_height="wrap_content"
96-
android:text="@string/cancel"
97-
android:padding="@dimen/small_gap"
98-
android:textColor="@color/white"
99-
android:background="@color/opak_middle_grey"
100-
/>
101-
<Button
102-
android:id="@+id/update_categories_button"
103-
android:layout_width="wrap_content"
104-
android:layout_margin="@dimen/quarter_standard_height"
105-
android:layout_height="wrap_content"
106-
android:text="@string/category_edit_button_text"
107-
android:padding="@dimen/small_gap"
108-
android:textColor="@color/white"
109-
android:background="@color/button_blue"
110-
/>
81+
android:layout_height="match_parent"
82+
android:orientation="vertical"
83+
>
84+
85+
<androidx.recyclerview.widget.RecyclerView
86+
android:id="@+id/rv_categories"
87+
android:layout_width="match_parent"
88+
android:layout_height="@dimen/dimen_200"
89+
android:background="?attr/mainBackground"/>
90+
91+
<LinearLayout
92+
android:layout_width="match_parent"
93+
android:layout_height="wrap_content">
94+
<Button
95+
android:id="@+id/cancel_categories_button"
96+
android:layout_width="wrap_content"
97+
android:layout_margin="@dimen/quarter_standard_height"
98+
android:layout_height="wrap_content"
99+
android:text="@string/cancel"
100+
android:padding="@dimen/small_gap"
101+
android:textColor="@color/white"
102+
android:background="@color/opak_middle_grey"
103+
/>
104+
<Button
105+
android:id="@+id/update_categories_button"
106+
android:layout_width="wrap_content"
107+
android:layout_margin="@dimen/quarter_standard_height"
108+
android:layout_height="wrap_content"
109+
android:text="@string/category_edit_button_text"
110+
android:padding="@dimen/small_gap"
111+
android:textColor="@color/white"
112+
android:background="@color/button_blue"
113+
/>
114+
</LinearLayout>
111115
</LinearLayout>
116+
112117
</LinearLayout>
113118

114-
</LinearLayout>
119+
</ScrollView>

0 commit comments

Comments
 (0)