mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
adding a sample image at thumbnail style customizatation dialog
This commit is contained in:
parent
01efb1bf81
commit
5218f8f359
3 changed files with 57 additions and 2 deletions
|
@ -3,12 +3,17 @@ package com.simplemobiletools.gallery.pro.dialogs
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.appcompat.app.AlertDialog
|
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.activities.BaseSimpleActivity
|
||||||
|
import com.simplemobiletools.commons.extensions.beGone
|
||||||
|
import com.simplemobiletools.commons.extensions.beVisible
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.extensions.config
|
import com.simplemobiletools.gallery.pro.extensions.config
|
||||||
import com.simplemobiletools.gallery.pro.helpers.*
|
import com.simplemobiletools.gallery.pro.helpers.*
|
||||||
import kotlinx.android.synthetic.main.dialog_change_thumbnail_style.view.*
|
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 {
|
class ChangeThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) : DialogInterface.OnClickListener {
|
||||||
private var config = activity.config
|
private var config = activity.config
|
||||||
|
@ -28,6 +33,7 @@ class ChangeThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback:
|
||||||
|
|
||||||
setupStyle()
|
setupStyle()
|
||||||
setupMediaCount()
|
setupMediaCount()
|
||||||
|
updateSample()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupStyle() {
|
private fun setupStyle() {
|
||||||
|
@ -42,6 +48,10 @@ class ChangeThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback:
|
||||||
|
|
||||||
private fun setupMediaCount() {
|
private fun setupMediaCount() {
|
||||||
val countRadio = view.dialog_radio_count_holder
|
val countRadio = view.dialog_radio_count_holder
|
||||||
|
countRadio.setOnCheckedChangeListener { group, checkedId ->
|
||||||
|
updateSample()
|
||||||
|
}
|
||||||
|
|
||||||
val countBtn = when (config.showFolderMediaCount) {
|
val countBtn = when (config.showFolderMediaCount) {
|
||||||
FOLDER_MEDIA_CNT_LINE -> countRadio.dialog_radio_count_line
|
FOLDER_MEDIA_CNT_LINE -> countRadio.dialog_radio_count_line
|
||||||
FOLDER_MEDIA_CNT_BRACKETS -> countRadio.dialog_radio_count_brackets
|
FOLDER_MEDIA_CNT_BRACKETS -> countRadio.dialog_radio_count_brackets
|
||||||
|
@ -51,6 +61,34 @@ class ChangeThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback:
|
||||||
countBtn.isChecked = true
|
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) {
|
override fun onClick(dialog: DialogInterface, which: Int) {
|
||||||
val style = when (view.dialog_radio_style.checkedRadioButtonId) {
|
val style = when (view.dialog_radio_style.checkedRadioButtonId) {
|
||||||
R.id.dialog_radio_square -> FOLDER_STYLE_SQUARE
|
R.id.dialog_radio_square -> FOLDER_STYLE_SQUARE
|
||||||
|
|
|
@ -13,10 +13,24 @@
|
||||||
android:paddingTop="@dimen/activity_margin"
|
android:paddingTop="@dimen/activity_margin"
|
||||||
android:paddingRight="@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
|
<RadioGroup
|
||||||
android:id="@+id/dialog_radio_style"
|
android:id="@+id/dialog_radio_style"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/medium_margin"
|
||||||
android:layout_marginBottom="@dimen/medium_margin">
|
android:layout_marginBottom="@dimen/medium_margin">
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/dir_holder"
|
android:id="@+id/dir_holder"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -88,14 +89,16 @@
|
||||||
android:shadowColor="@color/default_background_color"
|
android:shadowColor="@color/default_background_color"
|
||||||
android:shadowRadius="4"
|
android:shadowRadius="4"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="@dimen/normal_text_size" />
|
android:textSize="@dimen/normal_text_size"
|
||||||
|
tools:src="Camera" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/photo_cnt"
|
android:id="@+id/photo_cnt"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="@dimen/normal_text_size" />
|
android:textSize="@dimen/normal_text_size"
|
||||||
|
tools:text="36" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue