Skip to content

[GSoC] Image preview #4559

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

Merged
Show file tree
Hide file tree
Changes from all commits
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
@@ -1,5 +1,6 @@
package fr.free.nrw.commons.customselector.listeners

import android.net.Uri
import fr.free.nrw.commons.customselector.model.Image

/**
Expand All @@ -12,4 +13,10 @@ interface ImageSelectListener {
* @param selectedImages : new selected images.
*/
fun onSelectedImagesChanged(selectedImages: ArrayList<Image>)

/**
* onLongPress
* @param imageUri : uri of image
*/
fun onLongPress(imageUri: Uri)
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ class ImageAdapter(
holder.itemView.setOnClickListener {
selectOrRemoveImage(holder, position)
}

// launch media preview on long click.
holder.itemView.setOnLongClickListener {
imageSelectListener.onLongPress(image.uri)
true
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.Activity
import android.app.Dialog
import android.content.Intent
import android.content.SharedPreferences
import android.net.Uri
import android.os.Bundle
import android.view.View
import android.view.Window
Expand All @@ -15,6 +16,7 @@ import fr.free.nrw.commons.R
import fr.free.nrw.commons.customselector.listeners.FolderClickListener
import fr.free.nrw.commons.customselector.listeners.ImageSelectListener
import fr.free.nrw.commons.customselector.model.Image
import fr.free.nrw.commons.media.ZoomableActivity
import fr.free.nrw.commons.theme.BaseActivity
import java.io.File
import javax.inject.Inject
Expand Down Expand Up @@ -156,6 +158,15 @@ class CustomSelectorActivity: BaseActivity(), FolderClickListener, ImageSelectLi
done.visibility = if (selectedImages.isEmpty()) View.INVISIBLE else View.VISIBLE
}

/**
* onLongPress
* @param imageUri : uri of image
*/
override fun onLongPress(imageUri: Uri) {
val intent = Intent(this, ZoomableActivity::class.java).setData(imageUri);
startActivity(intent)
}

/**
* OnDone clicked.
* Get the selected images. Remove any non existent file, forward the data to finish selector.
Expand Down