mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
use smaller rounded corners at list views
This commit is contained in:
parent
e8dd9144c1
commit
46002b4358
6 changed files with 30 additions and 18 deletions
|
@ -15,6 +15,7 @@ import com.simplemobiletools.gallery.pro.R
|
|||
import com.simplemobiletools.gallery.pro.dialogs.PickDirectoryDialog
|
||||
import com.simplemobiletools.gallery.pro.extensions.*
|
||||
import com.simplemobiletools.gallery.pro.helpers.MyWidgetProvider
|
||||
import com.simplemobiletools.gallery.pro.helpers.ROUNDED_CORNERS_NONE
|
||||
import com.simplemobiletools.gallery.pro.models.Directory
|
||||
import com.simplemobiletools.gallery.pro.models.Widget
|
||||
import kotlinx.android.synthetic.main.activity_widget_config.*
|
||||
|
@ -166,7 +167,7 @@ class WidgetConfigureActivity : SimpleActivity() {
|
|||
val path = directoryDao.getDirectoryThumbnail(folderPath)
|
||||
if (path != null) {
|
||||
runOnUiThread {
|
||||
loadJpg(path, config_image, config.cropThumbnails, true)
|
||||
loadJpg(path, config_image, config.cropThumbnails, ROUNDED_CORNERS_NONE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -686,7 +686,8 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
|||
dir_lock.applyColorFilter(config.backgroundColor.getContrastColor())
|
||||
} else {
|
||||
dir_lock.beGone()
|
||||
activity.loadImage(thumbnailType, directory.tmb, dir_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, true)
|
||||
val roundedCorners = if (isListViewType) ROUNDED_CORNERS_SMALL else ROUNDED_CORNERS_BIG
|
||||
activity.loadImage(thumbnailType, directory.tmb, dir_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, roundedCorners)
|
||||
}
|
||||
|
||||
dir_pin.beVisibleIf(pinnedFolders.contains(directory.path))
|
||||
|
|
|
@ -542,15 +542,16 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
|||
path = path.getOTGPublicPath(context)
|
||||
}
|
||||
|
||||
val roundedCorners = if (isListViewType) ROUNDED_CORNERS_SMALL else ROUNDED_CORNERS_NONE
|
||||
if (loadImageInstantly) {
|
||||
activity.loadImage(medium.type, path, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, false, rotatedImagePaths)
|
||||
activity.loadImage(medium.type, path, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, roundedCorners, rotatedImagePaths)
|
||||
} else {
|
||||
medium_thumbnail.setImageDrawable(null)
|
||||
medium_thumbnail.isHorizontalScrolling = scrollHorizontally
|
||||
delayHandler.postDelayed({
|
||||
val isVisible = visibleItemPaths.contains(medium.path)
|
||||
if (isVisible) {
|
||||
activity.loadImage(medium.type, path, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, false, rotatedImagePaths)
|
||||
activity.loadImage(medium.type, path, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, roundedCorners, rotatedImagePaths)
|
||||
}
|
||||
}, IMAGE_LOAD_DELAY)
|
||||
}
|
||||
|
|
|
@ -398,7 +398,7 @@ fun Context.getFolderNameFromPath(path: String): String {
|
|||
}
|
||||
|
||||
fun Context.loadImage(type: Int, path: String, target: MySquareImageView, horizontalScroll: Boolean, animateGifs: Boolean, cropThumbnails: Boolean,
|
||||
roundCorners: Boolean, skipMemoryCacheAtPaths: ArrayList<String>? = null) {
|
||||
roundCorners: Int, skipMemoryCacheAtPaths: ArrayList<String>? = null) {
|
||||
target.isHorizontalScrolling = horizontalScroll
|
||||
if (type == TYPE_IMAGES || type == TYPE_VIDEOS || type == TYPE_RAWS || type == TYPE_PORTRAITS) {
|
||||
if (type == TYPE_IMAGES && path.isPng()) {
|
||||
|
@ -449,7 +449,7 @@ fun Context.getPathLocation(path: String): Int {
|
|||
}
|
||||
}
|
||||
|
||||
fun Context.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Boolean, skipMemoryCacheAtPaths: ArrayList<String>? = null) {
|
||||
fun Context.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, skipMemoryCacheAtPaths: ArrayList<String>? = null) {
|
||||
val options = RequestOptions()
|
||||
.signature(path.getFileSignature())
|
||||
.skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true)
|
||||
|
@ -463,15 +463,16 @@ fun Context.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boo
|
|||
.load(path)
|
||||
.apply(options)
|
||||
|
||||
if (roundCorners) {
|
||||
val cornerRadius = resources.getDimension(R.dimen.rounded_corner_radius).toInt()
|
||||
if (roundCorners != ROUNDED_CORNERS_NONE) {
|
||||
val cornerSize = if (roundCorners == ROUNDED_CORNERS_SMALL) R.dimen.rounded_corner_radius_small else R.dimen.rounded_corner_radius_big
|
||||
val cornerRadius = resources.getDimension(cornerSize).toInt()
|
||||
builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius))
|
||||
}
|
||||
|
||||
builder.into(target)
|
||||
}
|
||||
|
||||
fun Context.loadJpg(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Boolean, skipMemoryCacheAtPaths: ArrayList<String>? = null) {
|
||||
fun Context.loadJpg(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, skipMemoryCacheAtPaths: ArrayList<String>? = null) {
|
||||
val options = RequestOptions()
|
||||
.signature(path.getFileSignature())
|
||||
.skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true)
|
||||
|
@ -484,15 +485,16 @@ fun Context.loadJpg(path: String, target: MySquareImageView, cropThumbnails: Boo
|
|||
.apply(options)
|
||||
.transition(DrawableTransitionOptions.withCrossFade())
|
||||
|
||||
if (roundCorners) {
|
||||
val cornerRadius = resources.getDimension(R.dimen.rounded_corner_radius).toInt()
|
||||
if (roundCorners != ROUNDED_CORNERS_NONE) {
|
||||
val cornerSize = if (roundCorners == ROUNDED_CORNERS_SMALL) R.dimen.rounded_corner_radius_small else R.dimen.rounded_corner_radius_big
|
||||
val cornerRadius = resources.getDimension(cornerSize).toInt()
|
||||
builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius))
|
||||
}
|
||||
|
||||
builder.into(target)
|
||||
}
|
||||
|
||||
fun Context.loadStaticGIF(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Boolean, skipMemoryCacheAtPaths: ArrayList<String>? = null) {
|
||||
fun Context.loadStaticGIF(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, skipMemoryCacheAtPaths: ArrayList<String>? = null) {
|
||||
val options = RequestOptions()
|
||||
.signature(path.getFileSignature())
|
||||
.skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true)
|
||||
|
@ -505,15 +507,16 @@ fun Context.loadStaticGIF(path: String, target: MySquareImageView, cropThumbnail
|
|||
.load(path)
|
||||
.apply(options)
|
||||
|
||||
if (roundCorners) {
|
||||
val cornerRadius = resources.getDimension(R.dimen.rounded_corner_radius).toInt()
|
||||
if (roundCorners != ROUNDED_CORNERS_NONE) {
|
||||
val cornerSize = if (roundCorners == ROUNDED_CORNERS_SMALL) R.dimen.rounded_corner_radius_small else R.dimen.rounded_corner_radius_big
|
||||
val cornerRadius = resources.getDimension(cornerSize).toInt()
|
||||
builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius))
|
||||
}
|
||||
|
||||
builder.into(target)
|
||||
}
|
||||
|
||||
fun Context.loadSVG(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Boolean) {
|
||||
fun Context.loadSVG(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int) {
|
||||
target.scaleType = if (cropThumbnails) ImageView.ScaleType.CENTER_CROP else ImageView.ScaleType.FIT_CENTER
|
||||
|
||||
val options = RequestOptions().signature(path.getFileSignature())
|
||||
|
@ -524,8 +527,9 @@ fun Context.loadSVG(path: String, target: MySquareImageView, cropThumbnails: Boo
|
|||
.apply(options)
|
||||
.transition(DrawableTransitionOptions.withCrossFade())
|
||||
|
||||
if (roundCorners) {
|
||||
val cornerRadius = resources.getDimension(R.dimen.rounded_corner_radius).toInt()
|
||||
if (roundCorners != ROUNDED_CORNERS_NONE) {
|
||||
val cornerSize = if (roundCorners == ROUNDED_CORNERS_SMALL) R.dimen.rounded_corner_radius_small else R.dimen.rounded_corner_radius_big
|
||||
val cornerRadius = resources.getDimension(cornerSize).toInt()
|
||||
builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius))
|
||||
}
|
||||
|
||||
|
|
|
@ -220,3 +220,7 @@ const val LOW_TILE_DPI = 160
|
|||
const val NORMAL_TILE_DPI = 220
|
||||
const val WEIRD_TILE_DPI = 240
|
||||
const val HIGH_TILE_DPI = 280
|
||||
|
||||
const val ROUNDED_CORNERS_NONE = 1
|
||||
const val ROUNDED_CORNERS_SMALL = 2
|
||||
const val ROUNDED_CORNERS_BIG = 3
|
||||
|
|
|
@ -23,5 +23,6 @@
|
|||
<dimen name="widget_initial_size">110dp</dimen>
|
||||
<dimen name="full_brush_size">40dp</dimen>
|
||||
<dimen name="lock_padding">40dp</dimen>
|
||||
<dimen name="rounded_corner_radius">10dp</dimen>
|
||||
<dimen name="rounded_corner_radius_small">4dp</dimen>
|
||||
<dimen name="rounded_corner_radius_big">10dp</dimen>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue