From cf546e3c60b8488da957c3032145fe4de2c10daa Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 4 Mar 2017 10:28:02 +0100 Subject: [PATCH] really exclude the selected folder --- .../gallery/dialogs/ExcludeFolderDialog.kt | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ExcludeFolderDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ExcludeFolderDialog.kt index 87f25bfc7..1cfeed52d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ExcludeFolderDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ExcludeFolderDialog.kt @@ -2,23 +2,39 @@ package com.simplemobiletools.gallery.dialogs import android.support.v7.app.AlertDialog import android.view.LayoutInflater +import android.view.ViewGroup +import android.widget.RadioButton +import android.widget.RadioGroup import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.commons.extensions.getBasePath import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.activities.SimpleActivity +import com.simplemobiletools.gallery.extensions.config import kotlinx.android.synthetic.main.dialog_exclude_folder.view.* class ExcludeFolderDialog(val activity: SimpleActivity, val selectedPaths: List, val callback: () -> Unit) { var dialog: AlertDialog? = null + val alternativePaths = getAlternativePathsList() + var radioGroup: RadioGroup? = null init { - val alternativePaths = getAlternativePaths() val view = LayoutInflater.from(activity).inflate(R.layout.dialog_exclude_folder, null).apply { exclude_folder_parent.beVisibleIf(alternativePaths.size > 1) + + radioGroup = exclude_folder_radio_group exclude_folder_radio_group.beVisibleIf(alternativePaths.size > 1) } + alternativePaths.forEachIndexed { index, value -> + val radioButton = (activity.layoutInflater.inflate(R.layout.radio_button, null) as RadioButton).apply { + text = alternativePaths[index] + isChecked = index == 0 + id = index + } + radioGroup!!.addView(radioButton, RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)) + } + AlertDialog.Builder(activity) .setPositiveButton(R.string.ok, { dialog, which -> dialogConfirmed() }) .setNegativeButton(R.string.cancel, null) @@ -28,10 +44,12 @@ class ExcludeFolderDialog(val activity: SimpleActivity, val selectedPaths: List< } private fun dialogConfirmed() { - + val path = alternativePaths[radioGroup!!.checkedRadioButtonId] + activity.config.addExcludedFolder(path) + callback.invoke() } - private fun getAlternativePaths(): List { + private fun getAlternativePathsList(): List { val pathsList = ArrayList() if (selectedPaths.size > 1) return pathsList