rewriting the Included Folders to recyclerview too
This commit is contained in:
parent
d596829fd6
commit
69bc80fa4e
5 changed files with 36 additions and 61 deletions
|
@ -7,26 +7,27 @@ import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.adapters.ExcludedFoldersAdapter
|
import com.simplemobiletools.gallery.adapters.ManageFoldersAdapter
|
||||||
import com.simplemobiletools.gallery.extensions.config
|
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 {
|
class ExcludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_excluded_folders)
|
setContentView(R.layout.activity_manage_folders)
|
||||||
updateExcludedFolders()
|
updateExcludedFolders()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateExcludedFolders() {
|
private fun updateExcludedFolders() {
|
||||||
val folders = ArrayList<String>()
|
val folders = ArrayList<String>()
|
||||||
config.excludedFolders.mapTo(folders, { it })
|
config.excludedFolders.mapTo(folders, { it })
|
||||||
manage_excluded_folders_placeholder.beVisibleIf(folders.isEmpty())
|
manage_folders_placeholder.text = getString(R.string.excluded_activity_placeholder)
|
||||||
manage_excluded_folders_placeholder.setTextColor(config.textColor)
|
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)
|
adapter.setupDragListener(true)
|
||||||
manage_exclude_folders_list.adapter = adapter
|
manage_folders_list.adapter = adapter
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||||
|
|
|
@ -6,32 +6,29 @@ import android.view.MenuItem
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.extensions.scanPath
|
import com.simplemobiletools.commons.extensions.scanPath
|
||||||
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
|
import com.simplemobiletools.gallery.adapters.ManageFoldersAdapter
|
||||||
import com.simplemobiletools.gallery.extensions.config
|
import com.simplemobiletools.gallery.extensions.config
|
||||||
import kotlinx.android.synthetic.main.activity_included_folders.*
|
import kotlinx.android.synthetic.main.activity_manage_folders.*
|
||||||
import kotlinx.android.synthetic.main.item_manage_folder.view.*
|
|
||||||
|
|
||||||
class IncludedFoldersActivity : SimpleActivity() {
|
class IncludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_included_folders)
|
setContentView(R.layout.activity_manage_folders)
|
||||||
updateIncludedFolders()
|
updateIncludedFolders()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateIncludedFolders() {
|
private fun updateIncludedFolders() {
|
||||||
included_folders_holder.removeAllViews()
|
val folders = ArrayList<String>()
|
||||||
val folders = config.includedFolders
|
config.includedFolders.mapTo(folders, { it })
|
||||||
included_folders_placeholder.beVisibleIf(folders.isEmpty())
|
manage_folders_placeholder.text = getString(R.string.included_activity_placeholder)
|
||||||
included_folders_placeholder.setTextColor(config.textColor)
|
manage_folders_placeholder.beVisibleIf(folders.isEmpty())
|
||||||
|
manage_folders_placeholder.setTextColor(config.textColor)
|
||||||
|
|
||||||
for (folder in folders) {
|
val adapter = ManageFoldersAdapter(this, folders, false, this, manage_folders_list) {}
|
||||||
layoutInflater.inflate(R.layout.item_manage_folder, null, false).apply {
|
adapter.setupDragListener(true)
|
||||||
manage_folder_title.apply {
|
manage_folders_list.adapter = adapter
|
||||||
text = folder
|
|
||||||
setTextColor(config.textColor)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||||
|
@ -47,6 +44,10 @@ class IncludedFoldersActivity : SimpleActivity() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun refreshItems() {
|
||||||
|
updateIncludedFolders()
|
||||||
|
}
|
||||||
|
|
||||||
private fun addIncludedFolder() {
|
private fun addIncludedFolder() {
|
||||||
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden) {
|
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden) {
|
||||||
config.addIncludedFolder(it)
|
config.addIncludedFolder(it)
|
||||||
|
|
|
@ -14,8 +14,8 @@ import com.simplemobiletools.gallery.extensions.config
|
||||||
import kotlinx.android.synthetic.main.item_manage_folder.view.*
|
import kotlinx.android.synthetic.main.item_manage_folder.view.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class ExcludedFoldersAdapter(activity: BaseSimpleActivity, var folders: ArrayList<String>, val listener: RefreshRecyclerViewListener?, recyclerView: MyRecyclerView,
|
class ManageFoldersAdapter(activity: BaseSimpleActivity, var folders: ArrayList<String>, val isShowingExcludedFolders: Boolean, val listener: RefreshRecyclerViewListener?,
|
||||||
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
||||||
|
|
||||||
private val config = activity.config
|
private val config = activity.config
|
||||||
|
|
||||||
|
@ -74,7 +74,11 @@ class ExcludedFoldersAdapter(activity: BaseSimpleActivity, var folders: ArrayLis
|
||||||
removeFolders.add(folder)
|
removeFolders.add(folder)
|
||||||
notifyItemRemoved(it)
|
notifyItemRemoved(it)
|
||||||
itemViews.put(it, null)
|
itemViews.put(it, null)
|
||||||
config.removeExcludedFolder(folder)
|
if (isShowingExcludedFolders) {
|
||||||
|
config.removeExcludedFolder(folder)
|
||||||
|
} else {
|
||||||
|
config.removeIncludedFolder(folder)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
folders.removeAll(removeFolders)
|
folders.removeAll(removeFolders)
|
|
@ -1,30 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<ScrollView
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/included_folders_scrollview"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/include_folders_wrapper"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/included_folders_holder"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"/>
|
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
|
||||||
android:id="@+id/included_folders_placeholder"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:paddingLeft="@dimen/big_margin"
|
|
||||||
android:paddingRight="@dimen/big_margin"
|
|
||||||
android:paddingTop="@dimen/activity_margin"
|
|
||||||
android:text="@string/included_activity_placeholder"
|
|
||||||
android:visibility="gone"/>
|
|
||||||
</RelativeLayout>
|
|
||||||
</ScrollView>
|
|
|
@ -1,21 +1,20 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/manage_exclude_folders_wrapper"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/manage_folders_wrapper"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
android:id="@+id/manage_folders_list"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/manage_exclude_folders_list"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
app:layoutManager="android.support.v7.widget.LinearLayoutManager"/>
|
app:layoutManager="android.support.v7.widget.LinearLayoutManager"/>
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
android:id="@+id/manage_excluded_folders_placeholder"
|
android:id="@+id/manage_folders_placeholder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
Loading…
Reference in a new issue