mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
store the selected customization related values
This commit is contained in:
parent
20ef1924a7
commit
01efb1bf81
2 changed files with 49 additions and 5 deletions
|
@ -418,7 +418,9 @@ class SettingsActivity : SimpleActivity() {
|
|||
private fun setupFolderThumbnailStyle() {
|
||||
settings_folder_thumbnail_style.text = getFolderStyleText()
|
||||
settings_folder_thumbnail_style_holder.setOnClickListener {
|
||||
ChangeThumbnailStyleDialog(this)
|
||||
ChangeThumbnailStyleDialog(this) {
|
||||
settings_folder_thumbnail_style.text = getFolderStyleText()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,23 +7,65 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
|||
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.*
|
||||
|
||||
class ChangeThumbnailStyleDialog(val activity: BaseSimpleActivity) : DialogInterface.OnClickListener {
|
||||
class ChangeThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) : DialogInterface.OnClickListener {
|
||||
private var config = activity.config
|
||||
private var view: View = activity.layoutInflater.inflate(R.layout.dialog_change_thumbnail_style, null).apply {
|
||||
|
||||
}
|
||||
private var view: View
|
||||
|
||||
init {
|
||||
view = activity.layoutInflater.inflate(R.layout.dialog_change_thumbnail_style, null).apply {
|
||||
dialog_limit_title.isChecked = config.limitFolderTitle
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok, this)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
}
|
||||
|
||||
setupStyle()
|
||||
setupMediaCount()
|
||||
}
|
||||
|
||||
private fun setupStyle() {
|
||||
val styleRadio = view.dialog_radio_style
|
||||
val styleBtn = when (config.folderStyle) {
|
||||
FOLDER_STYLE_SQUARE -> styleRadio.dialog_radio_square
|
||||
else -> styleRadio.dialog_radio_rounded_corners
|
||||
}
|
||||
|
||||
styleBtn.isChecked = true
|
||||
}
|
||||
|
||||
private fun setupMediaCount() {
|
||||
val countRadio = view.dialog_radio_count_holder
|
||||
val countBtn = when (config.showFolderMediaCount) {
|
||||
FOLDER_MEDIA_CNT_LINE -> countRadio.dialog_radio_count_line
|
||||
FOLDER_MEDIA_CNT_BRACKETS -> countRadio.dialog_radio_count_brackets
|
||||
else -> countRadio.dialog_radio_count_none
|
||||
}
|
||||
|
||||
countBtn.isChecked = true
|
||||
}
|
||||
|
||||
override fun onClick(dialog: DialogInterface, which: Int) {
|
||||
val style = when (view.dialog_radio_style.checkedRadioButtonId) {
|
||||
R.id.dialog_radio_square -> FOLDER_STYLE_SQUARE
|
||||
else -> FOLDER_STYLE_ROUNDED_CORNERS
|
||||
}
|
||||
|
||||
val count = when (view.dialog_radio_count_holder.checkedRadioButtonId) {
|
||||
R.id.dialog_radio_count_line -> FOLDER_MEDIA_CNT_LINE
|
||||
R.id.dialog_radio_count_brackets -> FOLDER_MEDIA_CNT_BRACKETS
|
||||
else -> FOLDER_MEDIA_CNT_NONE
|
||||
}
|
||||
|
||||
config.folderStyle = style
|
||||
config.showFolderMediaCount = count
|
||||
config.limitFolderTitle = view.dialog_limit_title.isChecked
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue