Skip to content

Commit a956bc2

Browse files
authored
[GSoC] Improvement and bug Fixes (#4522)
* Improvement and bug Fixes * fixed ellipsize
1 parent 2a9f5ed commit a956bc2

File tree

5 files changed

+58
-49
lines changed

5 files changed

+58
-49
lines changed

app/src/main/java/fr/free/nrw/commons/customselector/ui/selector/CustomSelectorActivity.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package fr.free.nrw.commons.customselector.ui.selector
33
import android.app.Activity
44
import android.content.Intent
55
import android.os.Bundle
6+
import android.view.View
67
import android.widget.ImageButton
78
import android.widget.TextView
89
import androidx.lifecycle.ViewModelProvider
@@ -96,7 +97,9 @@ class CustomSelectorActivity : BaseActivity(), FolderClickListener, ImageSelectL
9697
*/
9798
override fun onSelectedImagesChanged(selectedImages: ArrayList<Image>) {
9899
viewModel.selectedImages.value = selectedImages
99-
// todo update selected images in view model.
100+
101+
val done : ImageButton = findViewById(R.id.done)
102+
done.visibility = if (selectedImages.isEmpty()) View.INVISIBLE else View.VISIBLE
100103
}
101104

102105
/**

app/src/main/res/layout/activity_custom_selector.xml

+4-10
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@
44
android:layout_height="match_parent"
55
xmlns:app="http://schemas.android.com/apk/res-auto">
66

7-
<androidx.constraintlayout.widget.ConstraintLayout
8-
android:id="@+id/toolbar_layout"
9-
android:layout_width="match_parent"
10-
android:layout_height="?attr/actionBarSize"
11-
app:layout_constraintTop_toTopOf="parent">
12-
<include
13-
layout="@layout/custom_selector_toolbar"
14-
android:id="@+id/toolbar"
15-
app:layout_constraintTop_toTopOf="parent"/>
16-
</androidx.constraintlayout.widget.ConstraintLayout>
7+
<include
8+
layout="@layout/custom_selector_toolbar"
9+
android:id="@+id/toolbar"
10+
/>
1711

1812
<androidx.fragment.app.FragmentContainerView
1913
android:id="@+id/fragment_container"

app/src/main/res/layout/custom_selector_toolbar.xml

+47-38
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,55 @@
22
<merge xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
>
5+
<androidx.constraintlayout.widget.ConstraintLayout
6+
android:id="@+id/toolbar_layout"
7+
android:layout_width="match_parent"
8+
android:layout_height="?attr/actionBarSize"
9+
app:layout_constraintTop_toTopOf="parent">
510

6-
<ImageButton
7-
android:id="@+id/back"
8-
android:layout_width="wrap_content"
9-
android:layout_height="match_parent"
10-
app:layout_constraintBottom_toBottomOf="parent"
11-
app:layout_constraintStart_toStartOf="parent"
12-
app:layout_constraintTop_toTopOf="parent"
13-
android:layout_centerVertical="true"
14-
android:background="?attr/selectableItemBackgroundBorderless"
15-
android:padding="@dimen/standard_gap"
16-
android:clickable="true"
17-
android:focusable="true"
18-
app:srcCompat="?attr/custom_selector_back" />
11+
<ImageButton
12+
android:id="@+id/back"
13+
android:layout_width="wrap_content"
14+
android:layout_height="match_parent"
15+
app:layout_constraintBottom_toBottomOf="parent"
16+
app:layout_constraintStart_toStartOf="parent"
17+
app:layout_constraintTop_toTopOf="parent"
18+
android:layout_centerVertical="true"
19+
android:background="?attr/selectableItemBackgroundBorderless"
20+
android:padding="@dimen/standard_gap"
21+
android:clickable="true"
22+
android:focusable="true"
23+
app:srcCompat="?attr/custom_selector_back"
24+
android:contentDescription="@string/back" />
1925

26+
<TextView
27+
android:id="@+id/title"
28+
android:textAlignment="center"
29+
android:layout_width="0dp"
30+
android:layout_height="wrap_content"
31+
app:layout_constraintStart_toEndOf="@id/back"
32+
app:layout_constraintEnd_toStartOf="@id/done"
33+
app:layout_constraintTop_toTopOf="parent"
34+
app:layout_constraintBottom_toBottomOf="parent"
35+
android:singleLine="true"
36+
android:ellipsize="end"
37+
android:text="@string/custom_selector_title"
38+
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" />
2039

21-
<TextView
22-
android:id="@+id/title"
23-
android:layout_width="wrap_content"
24-
android:layout_height="wrap_content"
25-
app:layout_constraintStart_toEndOf="@id/back"
26-
app:layout_constraintTop_toTopOf="parent"
27-
app:layout_constraintBottom_toBottomOf="parent"
28-
android:layout_marginHorizontal="@dimen/standard_gap"
29-
android:ellipsize="end"
30-
android:maxLines="1"
31-
android:text="@string/custom_selector_title"
32-
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" />
33-
34-
<ImageButton
35-
android:id="@+id/done"
36-
app:layout_constraintEnd_toEndOf="parent"
37-
app:layout_constraintTop_toTopOf="parent"
38-
android:layout_width="wrap_content"
39-
android:layout_height="match_parent"
40-
android:layout_centerVertical="true"
41-
android:clickable="true"
42-
android:background="?attr/selectableItemBackgroundBorderless"
43-
android:focusable="true"
44-
android:padding="@dimen/standard_gap"
45-
app:srcCompat="?attr/custom_selector_done"/>
40+
<ImageButton
41+
android:id="@+id/done"
42+
app:layout_constraintEnd_toEndOf="parent"
43+
app:layout_constraintTop_toTopOf="parent"
44+
android:layout_width="wrap_content"
45+
android:layout_height="match_parent"
46+
android:layout_centerVertical="true"
47+
android:clickable="true"
48+
android:background="?attr/selectableItemBackgroundBorderless"
49+
android:focusable="true"
50+
android:padding="@dimen/standard_gap"
51+
app:srcCompat="?attr/custom_selector_done"
52+
android:visibility="invisible"
53+
android:contentDescription="@string/done" />
4654

55+
</androidx.constraintlayout.widget.ConstraintLayout>
4756
</merge>

app/src/main/res/layout/item_custom_selector_image.xml

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
app:layout_constraintDimensionRatio="H,1:1"
4141
android:textSize="11sp"
4242
android:textStyle="bold"
43+
android:textColor="@color/black"
4344
android:layout_margin="@dimen/dimen_6"
4445
android:gravity="center|center_vertical"
4546
style="@style/TextAppearance.AppCompat.Small"

app/src/main/res/values/strings.xml

+2
Original file line numberDiff line numberDiff line change
@@ -636,5 +636,7 @@ Upload your first media by tapping on the add button.</string>
636636
The shadow of the image view of the location picker</string>
637637
<string name="image_location">Image Location</string>
638638
<string name="check_whether_location_is_correct">Check whether location is correct</string>
639+
<string name="done">Done</string>
640+
<string name="back">Back</string>
639641

640642
</resources>

0 commit comments

Comments
 (0)