create a new confirmation dialog for excluding folders

This commit is contained in:
tibbi 2017-03-03 22:29:08 +01:00
parent 7844bf5f9b
commit 77d203214a
4 changed files with 85 additions and 15 deletions

View File

@ -21,6 +21,7 @@ import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.adapters.MediaAdapter import com.simplemobiletools.gallery.adapters.MediaAdapter
import com.simplemobiletools.gallery.asynctasks.GetMediaAsynctask import com.simplemobiletools.gallery.asynctasks.GetMediaAsynctask
import com.simplemobiletools.gallery.dialogs.ChangeSortingDialog import com.simplemobiletools.gallery.dialogs.ChangeSortingDialog
import com.simplemobiletools.gallery.dialogs.ExcludeFolderDialog
import com.simplemobiletools.gallery.extensions.* import com.simplemobiletools.gallery.extensions.*
import com.simplemobiletools.gallery.helpers.* import com.simplemobiletools.gallery.helpers.*
import com.simplemobiletools.gallery.models.Medium import com.simplemobiletools.gallery.models.Medium
@ -193,14 +194,12 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
} }
private fun tryExcludeFolder() { private fun tryExcludeFolder() {
ConfirmationDialog(this, getString(R.string.exclude_folder_description)) { val pathSet = HashSet<String>(1)
excludeFolder() pathSet.add(mPath)
}
}
private fun excludeFolder() { ExcludeFolderDialog(this, pathSet) {
config.addExcludedFolder(mPath) finish()
finish() }
} }
private fun deleteDirectoryIfEmpty() { private fun deleteDirectoryIfEmpty() {

View File

@ -19,6 +19,7 @@ import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.activities.SimpleActivity import com.simplemobiletools.gallery.activities.SimpleActivity
import com.simplemobiletools.gallery.dialogs.CopyDialog import com.simplemobiletools.gallery.dialogs.CopyDialog
import com.simplemobiletools.gallery.dialogs.ExcludeFolderDialog
import com.simplemobiletools.gallery.dialogs.RenameDirectoryDialog import com.simplemobiletools.gallery.dialogs.RenameDirectoryDialog
import com.simplemobiletools.gallery.extensions.* import com.simplemobiletools.gallery.extensions.*
import com.simplemobiletools.gallery.models.Directory import com.simplemobiletools.gallery.models.Directory
@ -196,17 +197,12 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
} }
private fun tryExcludeFolder() { private fun tryExcludeFolder() {
ConfirmationDialog(activity, activity.getString(R.string.exclude_folder_description)) { ExcludeFolderDialog(activity, getSelectedPaths()) {
excludeFolder() listener?.refreshItems()
actMode?.finish()
} }
} }
private fun excludeFolder() {
activity.config.addExcludedFolders(getSelectedPaths())
listener?.refreshItems()
actMode?.finish()
}
private fun noMediaHandled() { private fun noMediaHandled() {
activity.runOnUiThread { activity.runOnUiThread {
listener?.refreshItems() listener?.refreshItems()

View File

@ -0,0 +1,40 @@
package com.simplemobiletools.gallery.dialogs
import android.support.v7.app.AlertDialog
import android.view.LayoutInflater
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.activities.SimpleActivity
import kotlinx.android.synthetic.main.dialog_exclude_folder.view.*
class ExcludeFolderDialog(val activity: SimpleActivity, val selectedPaths: HashSet<String>, val callback: () -> Unit) {
var dialog: AlertDialog? = 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)
exclude_folder_radio_group.beVisibleIf(alternativePaths.size > 1)
}
AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok, { dialog, which -> dialogConfirmed() })
.setNegativeButton(R.string.cancel, null)
.create().apply {
activity.setupDialogStuff(view, this)
}
}
private fun dialogConfirmed() {
}
private fun getAlternativePaths(): ArrayList<String> {
val parentsList = ArrayList<String>()
if (selectedPaths.size > 1)
return parentsList
return parentsList
}
}

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/exclude_folder_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/exclude_folder_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/exclude_folder_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/exclude_folder_description"
android:textSize="@dimen/bigger_text_size"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/exclude_folder_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/exclude_folder_parent"/>
<RadioGroup
android:id="@+id/exclude_folder_radio_group"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</RadioGroup>
</LinearLayout>
</ScrollView>