From 5218f8f359e9577f9f94aad894b16f6f3366957c Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 8 Nov 2020 18:40:45 +0100 Subject: [PATCH] adding a sample image at thumbnail style customizatation dialog --- .../pro/dialogs/ChangeThumbnailStyleDialog.kt | 38 +++++++++++++++++++ .../layout/dialog_change_thumbnail_style.xml | 14 +++++++ .../main/res/layout/directory_item_grid.xml | 7 +++- 3 files changed, 57 insertions(+), 2 deletions(-) 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 0d66e44e3..cb5560687 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 @@ -3,12 +3,17 @@ package com.simplemobiletools.gallery.pro.dialogs import android.content.DialogInterface import android.view.View import androidx.appcompat.app.AlertDialog +import com.bumptech.glide.Glide +import com.bumptech.glide.request.RequestOptions import com.simplemobiletools.commons.activities.BaseSimpleActivity +import com.simplemobiletools.commons.extensions.beGone +import com.simplemobiletools.commons.extensions.beVisible import com.simplemobiletools.commons.extensions.setupDialogStuff 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.* class ChangeThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) : DialogInterface.OnClickListener { private var config = activity.config @@ -28,6 +33,7 @@ class ChangeThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback: setupStyle() setupMediaCount() + updateSample() } private fun setupStyle() { @@ -42,6 +48,10 @@ class ChangeThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback: private fun setupMediaCount() { val countRadio = view.dialog_radio_count_holder + countRadio.setOnCheckedChangeListener { group, checkedId -> + updateSample() + } + val countBtn = when (config.showFolderMediaCount) { FOLDER_MEDIA_CNT_LINE -> countRadio.dialog_radio_count_line FOLDER_MEDIA_CNT_BRACKETS -> countRadio.dialog_radio_count_brackets @@ -51,6 +61,34 @@ class ChangeThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback: countBtn.isChecked = true } + private fun updateSample() { + val photoCount = 36 + val folderName = "Camera" + view.apply { + when (dialog_radio_count_holder.checkedRadioButtonId) { + R.id.dialog_radio_count_line -> { + dir_name.text = folderName + photo_cnt.text = photoCount.toString() + photo_cnt.beVisible() + } + R.id.dialog_radio_count_brackets -> { + photo_cnt.beGone() + dir_name.text = "${dir_name.text} ($photoCount)" + } + else -> { + dir_name.text = folderName + photo_cnt.beGone() + } + } + + val options = RequestOptions().centerCrop() + Glide.with(activity) + .load(R.drawable.sample_logo) + .apply(options) + .into(dir_thumbnail) + } + } + override fun onClick(dialog: DialogInterface, which: Int) { val style = when (view.dialog_radio_style.checkedRadioButtonId) { R.id.dialog_radio_square -> FOLDER_STYLE_SQUARE 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 b09888c63..b675a42d6 100644 --- a/app/src/main/res/layout/dialog_change_thumbnail_style.xml +++ b/app/src/main/res/layout/dialog_change_thumbnail_style.xml @@ -13,10 +13,24 @@ android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/activity_margin"> + + + + + + + android:textSize="@dimen/normal_text_size" + tools:src="Camera" /> + android:textSize="@dimen/normal_text_size" + tools:text="36" />