diff --git a/app/build.gradle b/app/build.gradle index 723179bf8..03addfef4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -77,7 +77,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.31.17' + implementation 'com.simplemobiletools:commons:5.31.18' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19' 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 3f0c66912..c608bf8f0 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 @@ -166,7 +166,7 @@ class WidgetConfigureActivity : SimpleActivity() { val path = directoryDao.getDirectoryThumbnail(folderPath) if (path != null) { runOnUiThread { - loadJpg(path, config_image, config.cropThumbnails) + loadJpg(path, config_image, config.cropThumbnails, true) } } } 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 0042ca286..460ba1921 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 @@ -35,7 +35,6 @@ import kotlinx.android.synthetic.main.directory_item_grid.view.dir_lock import kotlinx.android.synthetic.main.directory_item_grid.view.dir_name import kotlinx.android.synthetic.main.directory_item_grid.view.dir_pin import kotlinx.android.synthetic.main.directory_item_grid.view.dir_thumbnail -import kotlinx.android.synthetic.main.directory_item_grid.view.photo_cnt import kotlinx.android.synthetic.main.directory_item_list.view.* import java.io.File @@ -662,9 +661,6 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList 1) "${directory.name} (${directory.subfoldersCount})" else directory.name - dir_path?.text = "${directory.path.substringBeforeLast("/")}/" - photo_cnt.text = directory.subfoldersMediaCount.toString() val thumbnailType = when { directory.tmb.isVideoFast() -> TYPE_VIDEOS directory.tmb.isGif() -> TYPE_GIFS @@ -684,7 +680,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList 1) "${directory.name} [${directory.subfoldersCount}]" else directory.name + dir_path.text = "${directory.path.substringBeforeLast("/")}/" photo_cnt.setTextColor(textColor) + photo_cnt.text = directory.subfoldersMediaCount.toString() + photo_cnt.beVisibleIf(showMediaCount) + dir_path.setTextColor(textColor) dir_pin.applyColorFilter(textColor) dir_location.applyColorFilter(textColor) + } else { + dir_name.text = if (groupDirectSubfolders && directory.subfoldersCount > 1) "${directory.name} [${directory.subfoldersCount}]" else "${directory.name} (${directory.subfoldersMediaCount})" } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt index b4de42ac8..b048eca9a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt @@ -371,10 +371,10 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList? = null) { + roundCorners: Boolean, 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()) { - loadPng(path, target, cropThumbnails, skipMemoryCacheAtPaths) + loadPng(path, target, cropThumbnails, roundCorners, skipMemoryCacheAtPaths) } else { - loadJpg(path, target, cropThumbnails, skipMemoryCacheAtPaths) + loadJpg(path, target, cropThumbnails, roundCorners, skipMemoryCacheAtPaths) } } else if (type == TYPE_GIFS) { if (!animateGifs) { - loadStaticGIF(path, target, cropThumbnails, skipMemoryCacheAtPaths) + loadStaticGIF(path, target, cropThumbnails, roundCorners, skipMemoryCacheAtPaths) return } @@ -417,12 +419,12 @@ fun Context.loadImage(type: Int, path: String, target: MySquareImageView, horizo target.scaleType = if (cropThumbnails) ImageView.ScaleType.CENTER_CROP else ImageView.ScaleType.FIT_CENTER } catch (e: Exception) { - loadStaticGIF(path, target, cropThumbnails, skipMemoryCacheAtPaths) + loadStaticGIF(path, target, cropThumbnails, roundCorners, skipMemoryCacheAtPaths) } catch (e: OutOfMemoryError) { - loadStaticGIF(path, target, cropThumbnails, skipMemoryCacheAtPaths) + loadStaticGIF(path, target, cropThumbnails, roundCorners, skipMemoryCacheAtPaths) } } else if (type == TYPE_SVGS) { - loadSVG(path, target, cropThumbnails) + loadSVG(path, target, cropThumbnails, roundCorners) } } @@ -447,7 +449,7 @@ fun Context.getPathLocation(path: String): Int { } } -fun Context.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boolean, skipMemoryCacheAtPaths: ArrayList? = null) { +fun Context.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Boolean, skipMemoryCacheAtPaths: ArrayList? = null) { val options = RequestOptions() .signature(path.getFileSignature()) .skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true) @@ -455,57 +457,79 @@ fun Context.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boo .priority(Priority.LOW) .format(DecodeFormat.PREFER_ARGB_8888) - val builder = Glide.with(applicationContext) + if (cropThumbnails) options.centerCrop() else options.fitCenter() + var builder = Glide.with(applicationContext) .asBitmap() .load(path) + .apply(options) - if (cropThumbnails) options.centerCrop() else options.fitCenter() - builder.apply(options).into(target) + if (roundCorners) { + val cornerRadius = resources.getDimension(R.dimen.rounded_corner_radius).toInt() + builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius)) + } + + builder.into(target) } -fun Context.loadJpg(path: String, target: MySquareImageView, cropThumbnails: Boolean, skipMemoryCacheAtPaths: ArrayList? = null) { +fun Context.loadJpg(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Boolean, skipMemoryCacheAtPaths: ArrayList? = null) { val options = RequestOptions() .signature(path.getFileSignature()) .skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true) .priority(Priority.LOW) .diskCacheStrategy(DiskCacheStrategy.RESOURCE) - val builder = Glide.with(applicationContext) + if (cropThumbnails) options.centerCrop() else options.fitCenter() + var builder = Glide.with(applicationContext) .load(path) - - if (cropThumbnails) options.centerCrop() else options.fitCenter() - builder.apply(options) + .apply(options) .transition(DrawableTransitionOptions.withCrossFade()) - .into(target) + + if (roundCorners) { + val cornerRadius = resources.getDimension(R.dimen.rounded_corner_radius).toInt() + builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius)) + } + + builder.into(target) } -fun Context.loadStaticGIF(path: String, target: MySquareImageView, cropThumbnails: Boolean, skipMemoryCacheAtPaths: ArrayList? = null) { +fun Context.loadStaticGIF(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Boolean, skipMemoryCacheAtPaths: ArrayList? = null) { val options = RequestOptions() .signature(path.getFileSignature()) .skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true) .priority(Priority.LOW) .diskCacheStrategy(DiskCacheStrategy.RESOURCE) - val builder = Glide.with(applicationContext) + if (cropThumbnails) options.centerCrop() else options.fitCenter() + var builder = Glide.with(applicationContext) .asBitmap() // make sure the GIF wont animate .load(path) + .apply(options) - if (cropThumbnails) options.centerCrop() else options.fitCenter() - builder.apply(options) - .into(target) + if (roundCorners) { + val cornerRadius = resources.getDimension(R.dimen.rounded_corner_radius).toInt() + builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius)) + } + + builder.into(target) } -fun Context.loadSVG(path: String, target: MySquareImageView, cropThumbnails: Boolean) { +fun Context.loadSVG(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Boolean) { target.scaleType = if (cropThumbnails) ImageView.ScaleType.CENTER_CROP else ImageView.ScaleType.FIT_CENTER val options = RequestOptions().signature(path.getFileSignature()) - Glide.with(applicationContext) + var builder = Glide.with(applicationContext) .`as`(PictureDrawable::class.java) .listener(SvgSoftwareLayerSetter()) .load(path) .apply(options) .transition(DrawableTransitionOptions.withCrossFade()) - .into(target) + + if (roundCorners) { + val cornerRadius = resources.getDimension(R.dimen.rounded_corner_radius).toInt() + builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius)) + } + + builder.into(target) } fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly: Boolean = false, forceShowHidden: Boolean = false, callback: (ArrayList) -> Unit) { diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 6e2f06d16..3756cbb82 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,6 +1,5 @@ - + android:visibility="gone" /> + android:textStyle="italic" + android:visibility="gone" /> + android:visibility="gone" /> + app:spanCount="@integer/directory_columns_vertical_scroll" /> - + @@ -79,7 +78,7 @@ android:paddingTop="@dimen/normal_margin" android:visibility="gone"> - + diff --git a/app/src/main/res/layout/directory_item_grid.xml b/app/src/main/res/layout/directory_item_grid.xml index 591a2dfe1..5f5d03e5c 100644 --- a/app/src/main/res/layout/directory_item_grid.xml +++ b/app/src/main/res/layout/directory_item_grid.xml @@ -1,17 +1,17 @@ - + android:paddingTop="@dimen/medium_margin"> + android:layout_height="match_parent" /> + android:visibility="gone" /> + android:visibility="gone" /> + android:visibility="gone" /> - - - - - - - - - + android:layout_toStartOf="@+id/dir_location" + android:ellipsize="end" + android:maxLines="2" + android:paddingTop="@dimen/medium_margin" + android:textColor="@android:color/white" + android:textSize="@dimen/normal_text_size" /> + android:visibility="gone" /> diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index eb0f6cdf6..35346cf7e 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -23,4 +23,5 @@ 110dp 40dp 40dp + 10dp