diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt index c608bf8f0..34d427655 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt @@ -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) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt index e757a71aa..59ffad8ba 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt @@ -686,7 +686,8 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList? = null) { + roundCorners: Int, skipMemoryCacheAtPaths: ArrayList? = 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? = null) { +fun Context.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, skipMemoryCacheAtPaths: ArrayList? = 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? = null) { +fun Context.loadJpg(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, skipMemoryCacheAtPaths: ArrayList? = 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? = null) { +fun Context.loadStaticGIF(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, skipMemoryCacheAtPaths: ArrayList? = 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)) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt index 630896ff6..956df3884 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt @@ -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 diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 35346cf7e..bc9c3ad9f 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -23,5 +23,6 @@ 110dp 40dp 40dp - 10dp + 4dp + 10dp