create a new confirmation dialog for excluding folders
This commit is contained in:
parent
7844bf5f9b
commit
77d203214a
|
@ -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,15 +194,13 @@ 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() {
|
||||||
val file = File(mPath)
|
val file = File(mPath)
|
||||||
|
|
|
@ -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,16 +197,11 @@ 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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun excludeFolder() {
|
|
||||||
activity.config.addExcludedFolders(getSelectedPaths())
|
|
||||||
listener?.refreshItems()
|
listener?.refreshItems()
|
||||||
actMode?.finish()
|
actMode?.finish()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun noMediaHandled() {
|
private fun noMediaHandled() {
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
|
@ -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>
|
Loading…
Reference in New Issue