get a list of parents at exclude folder dialog
This commit is contained in:
parent
4e97c9bfa4
commit
f480ae6e14
4 changed files with 24 additions and 11 deletions
|
@ -194,10 +194,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryExcludeFolder() {
|
private fun tryExcludeFolder() {
|
||||||
val pathSet = HashSet<String>(1)
|
ExcludeFolderDialog(this, arrayListOf(mPath)) {
|
||||||
pathSet.add(mPath)
|
|
||||||
|
|
||||||
ExcludeFolderDialog(this, pathSet) {
|
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,7 +197,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryExcludeFolder() {
|
private fun tryExcludeFolder() {
|
||||||
ExcludeFolderDialog(activity, getSelectedPaths()) {
|
ExcludeFolderDialog(activity, getSelectedPaths().toList()) {
|
||||||
listener?.refreshItems()
|
listener?.refreshItems()
|
||||||
actMode?.finish()
|
actMode?.finish()
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,13 @@ package com.simplemobiletools.gallery.dialogs
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
|
import com.simplemobiletools.commons.extensions.getBasePath
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||||
import kotlinx.android.synthetic.main.dialog_exclude_folder.view.*
|
import kotlinx.android.synthetic.main.dialog_exclude_folder.view.*
|
||||||
|
|
||||||
class ExcludeFolderDialog(val activity: SimpleActivity, val selectedPaths: HashSet<String>, val callback: () -> Unit) {
|
class ExcludeFolderDialog(val activity: SimpleActivity, val selectedPaths: List<String>, val callback: () -> Unit) {
|
||||||
var dialog: AlertDialog? = null
|
var dialog: AlertDialog? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -30,11 +31,24 @@ class ExcludeFolderDialog(val activity: SimpleActivity, val selectedPaths: HashS
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAlternativePaths(): ArrayList<String> {
|
private fun getAlternativePaths(): List<String> {
|
||||||
val parentsList = ArrayList<String>()
|
val pathsList = ArrayList<String>()
|
||||||
if (selectedPaths.size > 1)
|
if (selectedPaths.size > 1)
|
||||||
return parentsList
|
return pathsList
|
||||||
|
|
||||||
return parentsList
|
val path = selectedPaths[0]
|
||||||
|
var basePath = path.getBasePath(activity)
|
||||||
|
val relativePath = path.substring(basePath.length)
|
||||||
|
val parts = relativePath.split("/").filter(String::isNotEmpty)
|
||||||
|
if (parts.isEmpty())
|
||||||
|
return pathsList
|
||||||
|
|
||||||
|
pathsList.add(basePath)
|
||||||
|
for (part in parts) {
|
||||||
|
basePath += "/$part"
|
||||||
|
pathsList.add(basePath)
|
||||||
|
}
|
||||||
|
|
||||||
|
return pathsList.reversed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,9 @@
|
||||||
android:id="@+id/exclude_folder_parent"
|
android:id="@+id/exclude_folder_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/exclude_folder_parent"/>
|
android:layout_marginTop="@dimen/activity_margin"
|
||||||
|
android:text="@string/exclude_folder_parent"
|
||||||
|
android:textSize="@dimen/normal_text_size"/>
|
||||||
|
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
android:id="@+id/exclude_folder_radio_group"
|
android:id="@+id/exclude_folder_radio_group"
|
||||||
|
|
Loading…
Reference in a new issue