use smaller rounded corners at list views

This commit is contained in:
tibbi 2020-11-02 13:22:30 +01:00
parent e8dd9144c1
commit 46002b4358
6 changed files with 30 additions and 18 deletions

View file

@ -15,6 +15,7 @@ import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.dialogs.PickDirectoryDialog import com.simplemobiletools.gallery.pro.dialogs.PickDirectoryDialog
import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.extensions.*
import com.simplemobiletools.gallery.pro.helpers.MyWidgetProvider 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.Directory
import com.simplemobiletools.gallery.pro.models.Widget import com.simplemobiletools.gallery.pro.models.Widget
import kotlinx.android.synthetic.main.activity_widget_config.* import kotlinx.android.synthetic.main.activity_widget_config.*
@ -166,7 +167,7 @@ class WidgetConfigureActivity : SimpleActivity() {
val path = directoryDao.getDirectoryThumbnail(folderPath) val path = directoryDao.getDirectoryThumbnail(folderPath)
if (path != null) { if (path != null) {
runOnUiThread { runOnUiThread {
loadJpg(path, config_image, config.cropThumbnails, true) loadJpg(path, config_image, config.cropThumbnails, ROUNDED_CORNERS_NONE)
} }
} }
} }

View file

@ -686,7 +686,8 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
dir_lock.applyColorFilter(config.backgroundColor.getContrastColor()) dir_lock.applyColorFilter(config.backgroundColor.getContrastColor())
} else { } else {
dir_lock.beGone() 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)) dir_pin.beVisibleIf(pinnedFolders.contains(directory.path))

View file

@ -542,15 +542,16 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
path = path.getOTGPublicPath(context) path = path.getOTGPublicPath(context)
} }
val roundedCorners = if (isListViewType) ROUNDED_CORNERS_SMALL else ROUNDED_CORNERS_NONE
if (loadImageInstantly) { 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 { } else {
medium_thumbnail.setImageDrawable(null) medium_thumbnail.setImageDrawable(null)
medium_thumbnail.isHorizontalScrolling = scrollHorizontally medium_thumbnail.isHorizontalScrolling = scrollHorizontally
delayHandler.postDelayed({ delayHandler.postDelayed({
val isVisible = visibleItemPaths.contains(medium.path) val isVisible = visibleItemPaths.contains(medium.path)
if (isVisible) { 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) }, IMAGE_LOAD_DELAY)
} }

View file

@ -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, 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 target.isHorizontalScrolling = horizontalScroll
if (type == TYPE_IMAGES || type == TYPE_VIDEOS || type == TYPE_RAWS || type == TYPE_PORTRAITS) { if (type == TYPE_IMAGES || type == TYPE_VIDEOS || type == TYPE_RAWS || type == TYPE_PORTRAITS) {
if (type == TYPE_IMAGES && path.isPng()) { 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() val options = RequestOptions()
.signature(path.getFileSignature()) .signature(path.getFileSignature())
.skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true) .skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true)
@ -463,15 +463,16 @@ fun Context.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boo
.load(path) .load(path)
.apply(options) .apply(options)
if (roundCorners) { if (roundCorners != ROUNDED_CORNERS_NONE) {
val cornerRadius = resources.getDimension(R.dimen.rounded_corner_radius).toInt() 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 = builder.transform(CenterCrop(), RoundedCorners(cornerRadius))
} }
builder.into(target) 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() val options = RequestOptions()
.signature(path.getFileSignature()) .signature(path.getFileSignature())
.skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true) .skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true)
@ -484,15 +485,16 @@ fun Context.loadJpg(path: String, target: MySquareImageView, cropThumbnails: Boo
.apply(options) .apply(options)
.transition(DrawableTransitionOptions.withCrossFade()) .transition(DrawableTransitionOptions.withCrossFade())
if (roundCorners) { if (roundCorners != ROUNDED_CORNERS_NONE) {
val cornerRadius = resources.getDimension(R.dimen.rounded_corner_radius).toInt() 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 = builder.transform(CenterCrop(), RoundedCorners(cornerRadius))
} }
builder.into(target) 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() val options = RequestOptions()
.signature(path.getFileSignature()) .signature(path.getFileSignature())
.skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true) .skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true)
@ -505,15 +507,16 @@ fun Context.loadStaticGIF(path: String, target: MySquareImageView, cropThumbnail
.load(path) .load(path)
.apply(options) .apply(options)
if (roundCorners) { if (roundCorners != ROUNDED_CORNERS_NONE) {
val cornerRadius = resources.getDimension(R.dimen.rounded_corner_radius).toInt() 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 = builder.transform(CenterCrop(), RoundedCorners(cornerRadius))
} }
builder.into(target) 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 target.scaleType = if (cropThumbnails) ImageView.ScaleType.CENTER_CROP else ImageView.ScaleType.FIT_CENTER
val options = RequestOptions().signature(path.getFileSignature()) val options = RequestOptions().signature(path.getFileSignature())
@ -524,8 +527,9 @@ fun Context.loadSVG(path: String, target: MySquareImageView, cropThumbnails: Boo
.apply(options) .apply(options)
.transition(DrawableTransitionOptions.withCrossFade()) .transition(DrawableTransitionOptions.withCrossFade())
if (roundCorners) { if (roundCorners != ROUNDED_CORNERS_NONE) {
val cornerRadius = resources.getDimension(R.dimen.rounded_corner_radius).toInt() 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 = builder.transform(CenterCrop(), RoundedCorners(cornerRadius))
} }

View file

@ -220,3 +220,7 @@ const val LOW_TILE_DPI = 160
const val NORMAL_TILE_DPI = 220 const val NORMAL_TILE_DPI = 220
const val WEIRD_TILE_DPI = 240 const val WEIRD_TILE_DPI = 240
const val HIGH_TILE_DPI = 280 const val HIGH_TILE_DPI = 280
const val ROUNDED_CORNERS_NONE = 1
const val ROUNDED_CORNERS_SMALL = 2
const val ROUNDED_CORNERS_BIG = 3

View file

@ -23,5 +23,6 @@
<dimen name="widget_initial_size">110dp</dimen> <dimen name="widget_initial_size">110dp</dimen>
<dimen name="full_brush_size">40dp</dimen> <dimen name="full_brush_size">40dp</dimen>
<dimen name="lock_padding">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> </resources>