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 06d5e574b..67998cebc 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 @@ -29,12 +29,12 @@ import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.interfaces.DirectoryOperationsListener import com.simplemobiletools.gallery.pro.models.AlbumCover import com.simplemobiletools.gallery.pro.models.Directory -import kotlinx.android.synthetic.main.directory_item_grid.view.dir_check -import kotlinx.android.synthetic.main.directory_item_grid.view.dir_location -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_square.view.dir_check +import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_location +import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_lock +import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_name +import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_pin +import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_thumbnail import kotlinx.android.synthetic.main.directory_item_list.view.* import java.io.File diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeThumbnailStyleDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeThumbnailStyleDialog.kt index f1ebe0fa3..cf6f7b5e5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeThumbnailStyleDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeThumbnailStyleDialog.kt @@ -2,8 +2,11 @@ package com.simplemobiletools.gallery.pro.dialogs import android.content.DialogInterface import android.view.View +import android.widget.RelativeLayout import androidx.appcompat.app.AlertDialog import com.bumptech.glide.Glide +import com.bumptech.glide.load.resource.bitmap.CenterCrop +import com.bumptech.glide.load.resource.bitmap.RoundedCorners import com.bumptech.glide.request.RequestOptions import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.beGone @@ -13,7 +16,7 @@ import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.helpers.* import kotlinx.android.synthetic.main.dialog_change_thumbnail_style.view.* -import kotlinx.android.synthetic.main.directory_item_grid.view.* +import kotlinx.android.synthetic.main.directory_item_grid_square.view.* class ChangeThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) : DialogInterface.OnClickListener { private var config = activity.config @@ -28,16 +31,20 @@ class ChangeThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback: .setPositiveButton(R.string.ok, this) .setNegativeButton(R.string.cancel, null) .create().apply { - activity.setupDialogStuff(view, this) + activity.setupDialogStuff(view, this) { + setupStyle() + setupMediaCount() + updateSample() + } } - - setupStyle() - setupMediaCount() - updateSample() } private fun setupStyle() { val styleRadio = view.dialog_radio_style + styleRadio.setOnCheckedChangeListener { group, checkedId -> + updateSample() + } + val styleBtn = when (config.folderStyle) { FOLDER_STYLE_SQUARE -> styleRadio.dialog_radio_square else -> styleRadio.dialog_radio_rounded_corners @@ -65,6 +72,16 @@ class ChangeThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback: val photoCount = 36 val folderName = "Camera" view.apply { + val useRoundedCornersLayout = dialog_radio_style.checkedRadioButtonId == R.id.dialog_radio_rounded_corners + dialog_sample_holder.removeAllViews() + + val layout = if (useRoundedCornersLayout) R.layout.directory_item_grid_rounded_corners else R.layout.directory_item_grid_square + val sampleView = activity.layoutInflater.inflate(layout, null) + dialog_sample_holder.addView(sampleView) + + sampleView.layoutParams.width = activity.resources.getDimension(R.dimen.sample_thumbnail_size).toInt() + (sampleView.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.CENTER_HORIZONTAL) + when (dialog_radio_count_holder.checkedRadioButtonId) { R.id.dialog_radio_count_line -> { dir_name.text = folderName @@ -77,15 +94,21 @@ class ChangeThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback: } else -> { dir_name.text = folderName - photo_cnt.beGone() + photo_cnt?.beGone() } } val options = RequestOptions().centerCrop() - Glide.with(activity) + var builder = Glide.with(activity) .load(R.drawable.sample_logo) .apply(options) - .into(dir_thumbnail) + + if (useRoundedCornersLayout) { + val cornerRadius = resources.getDimension(R.dimen.rounded_corner_radius_big).toInt() + builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius)) + } + + builder.into(dir_thumbnail) } } diff --git a/app/src/main/res/drawable-hdpi/sample_logo.png b/app/src/main/res/drawable-hdpi/sample_logo.png new file mode 100644 index 000000000..6ef81904c Binary files /dev/null and b/app/src/main/res/drawable-hdpi/sample_logo.png differ diff --git a/app/src/main/res/drawable-xhdpi/sample_logo.png b/app/src/main/res/drawable-xhdpi/sample_logo.png new file mode 100644 index 000000000..69c3e3684 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/sample_logo.png differ diff --git a/app/src/main/res/drawable-xxhdpi/sample_logo.png b/app/src/main/res/drawable-xxhdpi/sample_logo.png new file mode 100644 index 000000000..aeebc03d5 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/sample_logo.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/sample_logo.png b/app/src/main/res/drawable-xxxhdpi/sample_logo.png new file mode 100644 index 000000000..589331642 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/sample_logo.png differ diff --git a/app/src/main/res/layout/dialog_change_thumbnail_style.xml b/app/src/main/res/layout/dialog_change_thumbnail_style.xml index 3221e5bb1..34d935527 100644 --- a/app/src/main/res/layout/dialog_change_thumbnail_style.xml +++ b/app/src/main/res/layout/dialog_change_thumbnail_style.xml @@ -16,21 +16,13 @@ - - - - + android:layout_height="wrap_content" /> + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 78b30b24b..48dd76ef1 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -23,4 +23,5 @@ 110dp 40dp 30dp + 180dp