diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ExcludedFoldersActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ExcludedFoldersActivity.kt index b05f8fbcd..0b1c722cf 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ExcludedFoldersActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ExcludedFoldersActivity.kt @@ -7,26 +7,27 @@ import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener import com.simplemobiletools.gallery.R -import com.simplemobiletools.gallery.adapters.ExcludedFoldersAdapter +import com.simplemobiletools.gallery.adapters.ManageFoldersAdapter import com.simplemobiletools.gallery.extensions.config -import kotlinx.android.synthetic.main.activity_excluded_folders.* +import kotlinx.android.synthetic.main.activity_manage_folders.* class ExcludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_excluded_folders) + setContentView(R.layout.activity_manage_folders) updateExcludedFolders() } private fun updateExcludedFolders() { val folders = ArrayList() config.excludedFolders.mapTo(folders, { it }) - manage_excluded_folders_placeholder.beVisibleIf(folders.isEmpty()) - manage_excluded_folders_placeholder.setTextColor(config.textColor) + manage_folders_placeholder.text = getString(R.string.excluded_activity_placeholder) + manage_folders_placeholder.beVisibleIf(folders.isEmpty()) + manage_folders_placeholder.setTextColor(config.textColor) - val adapter = ExcludedFoldersAdapter(this, folders, this, manage_exclude_folders_list) {} + val adapter = ManageFoldersAdapter(this, folders, true, this, manage_folders_list) {} adapter.setupDragListener(true) - manage_exclude_folders_list.adapter = adapter + manage_folders_list.adapter = adapter } override fun onCreateOptionsMenu(menu: Menu?): Boolean { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/IncludedFoldersActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/IncludedFoldersActivity.kt index 2ddc9aaa7..3f4067312 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/IncludedFoldersActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/IncludedFoldersActivity.kt @@ -6,32 +6,29 @@ import android.view.MenuItem import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.commons.extensions.scanPath +import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener import com.simplemobiletools.gallery.R +import com.simplemobiletools.gallery.adapters.ManageFoldersAdapter import com.simplemobiletools.gallery.extensions.config -import kotlinx.android.synthetic.main.activity_included_folders.* -import kotlinx.android.synthetic.main.item_manage_folder.view.* +import kotlinx.android.synthetic.main.activity_manage_folders.* -class IncludedFoldersActivity : SimpleActivity() { +class IncludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_included_folders) + setContentView(R.layout.activity_manage_folders) updateIncludedFolders() } private fun updateIncludedFolders() { - included_folders_holder.removeAllViews() - val folders = config.includedFolders - included_folders_placeholder.beVisibleIf(folders.isEmpty()) - included_folders_placeholder.setTextColor(config.textColor) + val folders = ArrayList() + config.includedFolders.mapTo(folders, { it }) + manage_folders_placeholder.text = getString(R.string.included_activity_placeholder) + manage_folders_placeholder.beVisibleIf(folders.isEmpty()) + manage_folders_placeholder.setTextColor(config.textColor) - for (folder in folders) { - layoutInflater.inflate(R.layout.item_manage_folder, null, false).apply { - manage_folder_title.apply { - text = folder - setTextColor(config.textColor) - } - } - } + val adapter = ManageFoldersAdapter(this, folders, false, this, manage_folders_list) {} + adapter.setupDragListener(true) + manage_folders_list.adapter = adapter } override fun onCreateOptionsMenu(menu: Menu?): Boolean { @@ -47,6 +44,10 @@ class IncludedFoldersActivity : SimpleActivity() { return true } + override fun refreshItems() { + updateIncludedFolders() + } + private fun addIncludedFolder() { FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden) { config.addIncludedFolder(it) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/ExcludedFoldersAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/ManageFoldersAdapter.kt similarity index 84% rename from app/src/main/kotlin/com/simplemobiletools/gallery/adapters/ExcludedFoldersAdapter.kt rename to app/src/main/kotlin/com/simplemobiletools/gallery/adapters/ManageFoldersAdapter.kt index 99b4ea001..675490a0c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/ExcludedFoldersAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/ManageFoldersAdapter.kt @@ -14,8 +14,8 @@ import com.simplemobiletools.gallery.extensions.config import kotlinx.android.synthetic.main.item_manage_folder.view.* import java.util.* -class ExcludedFoldersAdapter(activity: BaseSimpleActivity, var folders: ArrayList, val listener: RefreshRecyclerViewListener?, recyclerView: MyRecyclerView, - itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, itemClick) { +class ManageFoldersAdapter(activity: BaseSimpleActivity, var folders: ArrayList, val isShowingExcludedFolders: Boolean, val listener: RefreshRecyclerViewListener?, + recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, itemClick) { private val config = activity.config @@ -74,7 +74,11 @@ class ExcludedFoldersAdapter(activity: BaseSimpleActivity, var folders: ArrayLis removeFolders.add(folder) notifyItemRemoved(it) itemViews.put(it, null) - config.removeExcludedFolder(folder) + if (isShowingExcludedFolders) { + config.removeExcludedFolder(folder) + } else { + config.removeIncludedFolder(folder) + } } folders.removeAll(removeFolders) diff --git a/app/src/main/res/layout/activity_included_folders.xml b/app/src/main/res/layout/activity_included_folders.xml deleted file mode 100644 index 527cdd94a..000000000 --- a/app/src/main/res/layout/activity_included_folders.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - diff --git a/app/src/main/res/layout/activity_excluded_folders.xml b/app/src/main/res/layout/activity_manage_folders.xml similarity index 75% rename from app/src/main/res/layout/activity_excluded_folders.xml rename to app/src/main/res/layout/activity_manage_folders.xml index 62e36ecb6..aaac86a7f 100644 --- a/app/src/main/res/layout/activity_excluded_folders.xml +++ b/app/src/main/res/layout/activity_manage_folders.xml @@ -1,21 +1,20 @@