mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Tick icon in place of number of images selected in custom picker (#5331)
* tick in place of number of images selected in custom picker * fixes tests, dark mode visibility, bold tick icon for better visibility
This commit is contained in:
parent
f69ecde713
commit
0d90ac3c53
6 changed files with 36 additions and 23 deletions
|
|
@ -151,7 +151,7 @@ class ImageAdapter(
|
||||||
|
|
||||||
val isSelected = selectedIndex != -1
|
val isSelected = selectedIndex != -1
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
holder.itemSelected(selectedImages.size)
|
holder.itemSelected()
|
||||||
} else {
|
} else {
|
||||||
holder.itemUnselected()
|
holder.itemUnselected()
|
||||||
}
|
}
|
||||||
|
|
@ -407,7 +407,6 @@ class ImageAdapter(
|
||||||
*/
|
*/
|
||||||
class ImageViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) {
|
class ImageViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) {
|
||||||
val image: ImageView = itemView.findViewById(R.id.image_thumbnail)
|
val image: ImageView = itemView.findViewById(R.id.image_thumbnail)
|
||||||
private val selectedNumber: TextView = itemView.findViewById(R.id.selected_count)
|
|
||||||
private val uploadedGroup: Group = itemView.findViewById(R.id.uploaded_group)
|
private val uploadedGroup: Group = itemView.findViewById(R.id.uploaded_group)
|
||||||
private val notForUploadGroup: Group = itemView.findViewById(R.id.not_for_upload_group)
|
private val notForUploadGroup: Group = itemView.findViewById(R.id.not_for_upload_group)
|
||||||
private val selectedGroup: Group = itemView.findViewById(R.id.selected_group)
|
private val selectedGroup: Group = itemView.findViewById(R.id.selected_group)
|
||||||
|
|
@ -415,9 +414,8 @@ class ImageAdapter(
|
||||||
/**
|
/**
|
||||||
* Item selected view.
|
* Item selected view.
|
||||||
*/
|
*/
|
||||||
fun itemSelected(index: Int) {
|
fun itemSelected() {
|
||||||
selectedGroup.visibility = View.VISIBLE
|
selectedGroup.visibility = View.VISIBLE
|
||||||
selectedNumber.text = index.toString()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import fr.free.nrw.commons.media.ZoomableActivity
|
||||||
import fr.free.nrw.commons.theme.BaseActivity
|
import fr.free.nrw.commons.theme.BaseActivity
|
||||||
import fr.free.nrw.commons.upload.FileUtilsWrapper
|
import fr.free.nrw.commons.upload.FileUtilsWrapper
|
||||||
import fr.free.nrw.commons.utils.CustomSelectorUtils
|
import fr.free.nrw.commons.utils.CustomSelectorUtils
|
||||||
|
import kotlinx.android.synthetic.main.activity_login.view.title
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
@ -142,7 +143,7 @@ class CustomSelectorActivity : BaseActivity(), FolderClickListener, ImageSelectL
|
||||||
data!!
|
data!!
|
||||||
.getParcelableArrayListExtra(CustomSelectorConstants.NEW_SELECTED_IMAGES)!!
|
.getParcelableArrayListExtra(CustomSelectorConstants.NEW_SELECTED_IMAGES)!!
|
||||||
val shouldRefresh = data.getBooleanExtra(SHOULD_REFRESH, false)
|
val shouldRefresh = data.getBooleanExtra(SHOULD_REFRESH, false)
|
||||||
imageFragment!!.passSelectedImages(selectedImages, shouldRefresh)
|
imageFragment?.passSelectedImages(selectedImages, shouldRefresh)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -280,6 +281,7 @@ class CustomSelectorActivity : BaseActivity(), FolderClickListener, ImageSelectL
|
||||||
val bottomLayout: ConstraintLayout = findViewById(R.id.bottom_layout)
|
val bottomLayout: ConstraintLayout = findViewById(R.id.bottom_layout)
|
||||||
bottomLayout.visibility = View.GONE
|
bottomLayout.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
changeTitle(bucketName, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -292,10 +294,17 @@ class CustomSelectorActivity : BaseActivity(), FolderClickListener, ImageSelectL
|
||||||
/**
|
/**
|
||||||
* Change the title of the toolbar.
|
* Change the title of the toolbar.
|
||||||
*/
|
*/
|
||||||
private fun changeTitle(title: String) {
|
private fun changeTitle(title: String, selectedImageCount:Int) {
|
||||||
val titleText = findViewById<TextView>(R.id.title)
|
if (title.isNotEmpty()){
|
||||||
if (titleText != null) {
|
val titleText = findViewById<TextView>(R.id.title)
|
||||||
titleText.text = title
|
var titleWithAppendedImageCount = title
|
||||||
|
if (selectedImageCount > 0) {
|
||||||
|
titleWithAppendedImageCount += " (${resources.getQuantityString(R.plurals.custom_picker_images_selected_title_appendix,
|
||||||
|
selectedImageCount, selectedImageCount)})"
|
||||||
|
}
|
||||||
|
if (titleText != null) {
|
||||||
|
titleText.text = titleWithAppendedImageCount
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -316,7 +325,7 @@ class CustomSelectorActivity : BaseActivity(), FolderClickListener, ImageSelectL
|
||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commit()
|
.commit()
|
||||||
|
|
||||||
changeTitle(folderName)
|
changeTitle(folderName, 0)
|
||||||
|
|
||||||
bucketId = folderId
|
bucketId = folderId
|
||||||
bucketName = folderName
|
bucketName = folderName
|
||||||
|
|
@ -331,6 +340,7 @@ class CustomSelectorActivity : BaseActivity(), FolderClickListener, ImageSelectL
|
||||||
selectedNotForUploadImages: Int
|
selectedNotForUploadImages: Int
|
||||||
) {
|
) {
|
||||||
viewModel.selectedImages.value = selectedImages
|
viewModel.selectedImages.value = selectedImages
|
||||||
|
changeTitle(bucketName, selectedImages.size)
|
||||||
|
|
||||||
if (selectedNotForUploadImages > 0) {
|
if (selectedNotForUploadImages > 0) {
|
||||||
bottomSheetBinding.upload.isEnabled = false
|
bottomSheetBinding.upload.isEnabled = false
|
||||||
|
|
@ -418,7 +428,7 @@ class CustomSelectorActivity : BaseActivity(), FolderClickListener, ImageSelectL
|
||||||
val fragment = supportFragmentManager.findFragmentById(R.id.fragment_container)
|
val fragment = supportFragmentManager.findFragmentById(R.id.fragment_container)
|
||||||
if (fragment != null && fragment is FolderFragment) {
|
if (fragment != null && fragment is FolderFragment) {
|
||||||
isImageFragmentOpen = false
|
isImageFragmentOpen = false
|
||||||
changeTitle(getString(R.string.custom_selector_title))
|
changeTitle(getString(R.string.custom_selector_title), 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,10 @@
|
||||||
android:width="24dp"
|
android:width="24dp"
|
||||||
android:height="24dp"
|
android:height="24dp"
|
||||||
android:viewportWidth="24"
|
android:viewportWidth="24"
|
||||||
android:viewportHeight="24"
|
android:viewportHeight="24">
|
||||||
android:tint="?attr/colorControlNormal">
|
|
||||||
<path
|
<path
|
||||||
android:fillColor="@android:color/black"
|
android:fillColor="@android:color/black"
|
||||||
|
android:strokeWidth="2"
|
||||||
|
android:strokeColor="@color/black"
|
||||||
android:pathData="M9,16.2L4.8,12l-1.4,1.4L9,19 21,7l-1.4,-1.4L9,16.2z"/>
|
android:pathData="M9,16.2L4.8,12l-1.4,1.4L9,19 21,7l-1.4,-1.4L9,16.2z"/>
|
||||||
</vector>
|
</vector>
|
||||||
|
|
|
||||||
|
|
@ -33,18 +33,14 @@
|
||||||
android:background="@color/divider_grey"
|
android:background="@color/divider_grey"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextView
|
<ImageView
|
||||||
android:id="@+id/selected_count"
|
android:id="@+id/selected_image"
|
||||||
android:layout_width="@dimen/dimen_20"
|
android:layout_width="@dimen/dimen_20"
|
||||||
android:layout_height="@dimen/dimen_20"
|
android:layout_height="@dimen/dimen_20"
|
||||||
app:layout_constraintDimensionRatio="H,1:1"
|
app:layout_constraintDimensionRatio="H,1:1"
|
||||||
android:textSize="11sp"
|
android:src="@drawable/ic_done_black"
|
||||||
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"
|
|
||||||
android:text="12"
|
|
||||||
android:background="@drawable/circle_shape"
|
android:background="@drawable/circle_shape"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"/>
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
|
|
@ -55,7 +51,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:constraint_referenced_ids="selected_overlay,selected_count"/>
|
app:constraint_referenced_ids="selected_overlay,selected_image"/>
|
||||||
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
|
|
||||||
|
|
@ -775,4 +775,8 @@ Upload your first media by tapping on the add button.</string>
|
||||||
<string name="full_screen_mode_features_info">Swipe fast and long to perform these actions: \n- Left/Right: Go to previous/next \n- Up: Select\n- Down: Mark as not for upload.</string>
|
<string name="full_screen_mode_features_info">Swipe fast and long to perform these actions: \n- Left/Right: Go to previous/next \n- Up: Select\n- Down: Mark as not for upload.</string>
|
||||||
<string name="set_up_avatar_toast_string">To set up your leaderboard avatar, tap \"Set as avatar\" in the three-dots menu of any image.</string>
|
<string name="set_up_avatar_toast_string">To set up your leaderboard avatar, tap \"Set as avatar\" in the three-dots menu of any image.</string>
|
||||||
<string name="similar_coordinate_description_auto_set">The coordinates are not the exact coordinates, but the person who uploaded this picture thinks they are close enough.</string>
|
<string name="similar_coordinate_description_auto_set">The coordinates are not the exact coordinates, but the person who uploaded this picture thinks they are close enough.</string>
|
||||||
|
<plurals name="custom_picker_images_selected_title_appendix">
|
||||||
|
<item quantity="one">%d image selected</item>
|
||||||
|
<item quantity="other">%d images selected</item>
|
||||||
|
</plurals>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -73,9 +73,10 @@ class CustomSelectorActivityTest {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testChangeTitle() {
|
fun testChangeTitle() {
|
||||||
val func = activity.javaClass.getDeclaredMethod("changeTitle", String::class.java)
|
activity.onFolderClick(1, "test", 0)
|
||||||
|
val func = activity.javaClass.getDeclaredMethod("changeTitle", String::class.java, Int::class.java)
|
||||||
func.isAccessible = true
|
func.isAccessible = true
|
||||||
func.invoke(activity, "test")
|
func.invoke(activity, "test", 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -141,6 +142,7 @@ class CustomSelectorActivityTest {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnSelectedImagesChanged() {
|
fun testOnSelectedImagesChanged() {
|
||||||
|
activity.onFolderClick(1, "test", 0)
|
||||||
activity.onSelectedImagesChanged(ArrayList(), 0)
|
activity.onSelectedImagesChanged(ArrayList(), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -151,6 +153,7 @@ class CustomSelectorActivityTest {
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnDone() {
|
fun testOnDone() {
|
||||||
activity.onDone()
|
activity.onDone()
|
||||||
|
activity.onFolderClick(1, "test", 0)
|
||||||
activity.onSelectedImagesChanged(
|
activity.onSelectedImagesChanged(
|
||||||
ArrayList(arrayListOf(Image(1, "test", Uri.parse("test"), "test", 1))),
|
ArrayList(arrayListOf(Image(1, "test", Uri.parse("test"), "test", 1))),
|
||||||
1
|
1
|
||||||
|
|
@ -164,6 +167,7 @@ class CustomSelectorActivityTest {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnClickNotForUpload() {
|
fun testOnClickNotForUpload() {
|
||||||
|
activity.onFolderClick(1, "test", 0)
|
||||||
val method: Method = CustomSelectorActivity::class.java.getDeclaredMethod(
|
val method: Method = CustomSelectorActivity::class.java.getDeclaredMethod(
|
||||||
"onClickNotForUpload"
|
"onClickNotForUpload"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue