Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tick icon in place of number of images selected in custom picker #5331

Merged
merged 2 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class ImageAdapter(

val isSelected = selectedIndex != -1
if (isSelected) {
holder.itemSelected(selectedImages.size)
holder.itemSelected()
} else {
holder.itemUnselected()
}
Expand Down Expand Up @@ -407,17 +407,15 @@ class ImageAdapter(
*/
class ImageViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) {
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 notForUploadGroup: Group = itemView.findViewById(R.id.not_for_upload_group)
private val selectedGroup: Group = itemView.findViewById(R.id.selected_group)

/**
* Item selected view.
*/
fun itemSelected(index: Int) {
fun itemSelected() {
selectedGroup.visibility = View.VISIBLE
selectedNumber.text = index.toString()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import fr.free.nrw.commons.media.ZoomableActivity
import fr.free.nrw.commons.theme.BaseActivity
import fr.free.nrw.commons.upload.FileUtilsWrapper
import fr.free.nrw.commons.utils.CustomSelectorUtils
import kotlinx.android.synthetic.main.activity_login.view.title
import kotlinx.coroutines.*
import java.io.File
import javax.inject.Inject
Expand Down Expand Up @@ -142,7 +143,7 @@ class CustomSelectorActivity : BaseActivity(), FolderClickListener, ImageSelectL
data!!
.getParcelableArrayListExtra(CustomSelectorConstants.NEW_SELECTED_IMAGES)!!
val shouldRefresh = data.getBooleanExtra(SHOULD_REFRESH, false)
imageFragment!!.passSelectedImages(selectedImages, shouldRefresh)
imageFragment?.passSelectedImages(selectedImages, shouldRefresh)
}
}

Expand Down Expand Up @@ -280,6 +281,7 @@ class CustomSelectorActivity : BaseActivity(), FolderClickListener, ImageSelectL
val bottomLayout: ConstraintLayout = findViewById(R.id.bottom_layout)
bottomLayout.visibility = View.GONE
}
changeTitle(bucketName, 0)
}

/**
Expand All @@ -292,10 +294,17 @@ class CustomSelectorActivity : BaseActivity(), FolderClickListener, ImageSelectL
/**
* Change the title of the toolbar.
*/
private fun changeTitle(title: String) {
val titleText = findViewById<TextView>(R.id.title)
if (titleText != null) {
titleText.text = title
private fun changeTitle(title: String, selectedImageCount:Int) {
if (title.isNotEmpty()){
val titleText = findViewById<TextView>(R.id.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
}
}
}

Expand All @@ -316,7 +325,7 @@ class CustomSelectorActivity : BaseActivity(), FolderClickListener, ImageSelectL
.addToBackStack(null)
.commit()

changeTitle(folderName)
changeTitle(folderName, 0)

bucketId = folderId
bucketName = folderName
Expand All @@ -331,6 +340,7 @@ class CustomSelectorActivity : BaseActivity(), FolderClickListener, ImageSelectL
selectedNotForUploadImages: Int
) {
viewModel.selectedImages.value = selectedImages
changeTitle(bucketName, selectedImages.size)

if (selectedNotForUploadImages > 0) {
bottomSheetBinding.upload.isEnabled = false
Expand Down Expand Up @@ -418,7 +428,7 @@ class CustomSelectorActivity : BaseActivity(), FolderClickListener, ImageSelectL
val fragment = supportFragmentManager.findFragmentById(R.id.fragment_container)
if (fragment != null && fragment is FolderFragment) {
isImageFragmentOpen = false
changeTitle(getString(R.string.custom_selector_title))
changeTitle(getString(R.string.custom_selector_title), 0)
}
}

Expand Down
12 changes: 4 additions & 8 deletions app/src/main/res/layout/item_custom_selector_image.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,14 @@
android:background="@color/divider_grey"
/>

<TextView
android:id="@+id/selected_count"
<ImageView
android:id="@+id/selected_image"
android:layout_width="@dimen/dimen_20"
android:layout_height="@dimen/dimen_20"
app:layout_constraintDimensionRatio="H,1:1"
android:textSize="11sp"
android:textStyle="bold"
android:textColor="@color/black"
android:src="@drawable/ic_done_black"
android:layout_margin="@dimen/dimen_6"
android:gravity="center|center_vertical"
style="@style/TextAppearance.AppCompat.Small"
android:text="12"
android:background="@drawable/circle_shape"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
Expand All @@ -55,7 +51,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:constraint_referenced_ids="selected_overlay,selected_count"/>
app:constraint_referenced_ids="selected_overlay,selected_image"/>


<View
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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="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>
<plurals name="custom_picker_images_selected_title_appendix">
<item quantity="one">%d image selected</item>
<item quantity="other">%d images selected</item>
</plurals>
</resources>
Loading