adding a sample image at thumbnail style customizatation dialog

This commit is contained in:
tibbi 2020-11-08 18:40:45 +01:00
parent 01efb1bf81
commit 5218f8f359
3 changed files with 57 additions and 2 deletions

View file

@ -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

View file

@ -13,10 +13,24 @@
android:paddingTop="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin">
<RelativeLayout
android:id="@+id/dialog_sample_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
layout="@layout/directory_item_grid"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<RadioGroup
android:id="@+id/dialog_radio_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:layout_marginBottom="@dimen/medium_margin">
<com.simplemobiletools.commons.views.MyCompatRadioButton

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/dir_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -88,14 +89,16 @@
android:shadowColor="@color/default_background_color"
android:shadowRadius="4"
android:textColor="@android:color/white"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"
tools:src="Camera" />
<TextView
android:id="@+id/photo_cnt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"
tools:text="36" />
</LinearLayout>