[GSoC] Improvement and bug Fixes (#4522)

* Improvement and bug Fixes

* fixed ellipsize
This commit is contained in:
Aditya-Srivastav 2021-07-26 16:31:45 +05:30 committed by Aditya Srivastava
parent af3936ae16
commit 9b00c9417f
5 changed files with 58 additions and 49 deletions

View file

@ -3,6 +3,7 @@ package fr.free.nrw.commons.customselector.ui.selector
import android.app.Activity import android.app.Activity
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.View
import android.widget.ImageButton import android.widget.ImageButton
import android.widget.TextView import android.widget.TextView
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
@ -96,7 +97,9 @@ class CustomSelectorActivity : BaseActivity(), FolderClickListener, ImageSelectL
*/ */
override fun onSelectedImagesChanged(selectedImages: ArrayList<Image>) { override fun onSelectedImagesChanged(selectedImages: ArrayList<Image>) {
viewModel.selectedImages.value = selectedImages viewModel.selectedImages.value = selectedImages
// todo update selected images in view model.
val done : ImageButton = findViewById(R.id.done)
done.visibility = if (selectedImages.isEmpty()) View.INVISIBLE else View.VISIBLE
} }
/** /**

View file

@ -4,16 +4,10 @@
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout <include
android:id="@+id/toolbar_layout" layout="@layout/custom_selector_toolbar"
android:layout_width="match_parent" android:id="@+id/toolbar"
android:layout_height="?attr/actionBarSize" />
app:layout_constraintTop_toTopOf="parent">
<include
layout="@layout/custom_selector_toolbar"
android:id="@+id/toolbar"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.fragment.app.FragmentContainerView <androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment_container" android:id="@+id/fragment_container"

View file

@ -2,46 +2,55 @@
<merge xmlns:android="http://schemas.android.com/apk/res/android" <merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
> >
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_constraintTop_toTopOf="parent">
<ImageButton <ImageButton
android:id="@+id/back" android:id="@+id/back"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:background="?attr/selectableItemBackgroundBorderless" android:background="?attr/selectableItemBackgroundBorderless"
android:padding="@dimen/standard_gap" android:padding="@dimen/standard_gap"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
app:srcCompat="?attr/custom_selector_back" /> app:srcCompat="?attr/custom_selector_back"
android:contentDescription="@string/back" />
<TextView
android:id="@+id/title"
android:textAlignment="center"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toEndOf="@id/back"
app:layout_constraintEnd_toStartOf="@id/done"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:singleLine="true"
android:ellipsize="end"
android:text="@string/custom_selector_title"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" />
<TextView <ImageButton
android:id="@+id/title" android:id="@+id/done"
android:layout_width="wrap_content" app:layout_constraintEnd_toEndOf="parent"
android:layout_height="wrap_content" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="@id/back" android:layout_width="wrap_content"
app:layout_constraintTop_toTopOf="parent" android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent" android:layout_centerVertical="true"
android:layout_marginHorizontal="@dimen/standard_gap" android:clickable="true"
android:ellipsize="end" android:background="?attr/selectableItemBackgroundBorderless"
android:maxLines="1" android:focusable="true"
android:text="@string/custom_selector_title" android:padding="@dimen/standard_gap"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" /> app:srcCompat="?attr/custom_selector_done"
android:visibility="invisible"
<ImageButton android:contentDescription="@string/done" />
android:id="@+id/done"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:clickable="true"
android:background="?attr/selectableItemBackgroundBorderless"
android:focusable="true"
android:padding="@dimen/standard_gap"
app:srcCompat="?attr/custom_selector_done"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</merge> </merge>

View file

@ -40,6 +40,7 @@
app:layout_constraintDimensionRatio="H,1:1" app:layout_constraintDimensionRatio="H,1:1"
android:textSize="11sp" android:textSize="11sp"
android:textStyle="bold" android:textStyle="bold"
android:textColor="@color/black"
android:layout_margin="@dimen/dimen_6" android:layout_margin="@dimen/dimen_6"
android:gravity="center|center_vertical" android:gravity="center|center_vertical"
style="@style/TextAppearance.AppCompat.Small" style="@style/TextAppearance.AppCompat.Small"

View file

@ -640,5 +640,7 @@ Upload your first media by tapping on the add button.</string>
<string name="check_whether_location_is_correct">Check whether location is correct</string> <string name="check_whether_location_is_correct">Check whether location is correct</string>
<string name="custom_selector_title">Custom Selector</string> <string name="custom_selector_title">Custom Selector</string>
<string name="custom_selector_empty_text">No Images</string> <string name="custom_selector_empty_text">No Images</string>
<string name="done">Done</string>
<string name="back">Back</string>
</resources> </resources>