updating Commons with some recycler view selection updates
This commit is contained in:
parent
f00f0e1e60
commit
00f00514a1
|
@ -42,7 +42,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:4.9.18'
|
implementation 'com.simplemobiletools:commons:4.10.1'
|
||||||
|
|
||||||
implementation files('../libs/RootTools.jar')
|
implementation files('../libs/RootTools.jar')
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ class FavoritesActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
|
|
||||||
private fun updateFavorites() {
|
private fun updateFavorites() {
|
||||||
val favorites = ArrayList<String>()
|
val favorites = ArrayList<String>()
|
||||||
config.favorites.mapTo(favorites, { it })
|
config.favorites.mapTo(favorites) { it }
|
||||||
manage_favorites_placeholder.beVisibleIf(favorites.isEmpty())
|
manage_favorites_placeholder.beVisibleIf(favorites.isEmpty())
|
||||||
manage_favorites_placeholder.setTextColor(config.textColor)
|
manage_favorites_placeholder.setTextColor(config.textColor)
|
||||||
|
|
||||||
|
@ -37,7 +37,6 @@ class FavoritesActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
|
|
||||||
ManageFavoritesAdapter(this, favorites, this, manage_favorites_list) { }.apply {
|
ManageFavoritesAdapter(this, favorites, this, manage_favorites_list) { }.apply {
|
||||||
manage_favorites_list.adapter = this
|
manage_favorites_list.adapter = this
|
||||||
initSelectionTracker()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -247,7 +247,7 @@ class MainActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun launchAbout() {
|
private fun launchAbout() {
|
||||||
val licenses = LICENSE_MULTISELECT or LICENSE_GLIDE or LICENSE_PATTERN or LICENSE_REPRINT
|
val licenses = LICENSE_GLIDE or LICENSE_PATTERN or LICENSE_REPRINT
|
||||||
|
|
||||||
val faqItems = arrayListOf(
|
val faqItems = arrayListOf(
|
||||||
FAQItem(R.string.faq_3_title_commons, R.string.faq_3_text_commons),
|
FAQItem(R.string.faq_3_title_commons, R.string.faq_3_text_commons),
|
||||||
|
|
|
@ -17,7 +17,6 @@ import com.simplemobiletools.commons.dialogs.*
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.CONFLICT_OVERWRITE
|
import com.simplemobiletools.commons.helpers.CONFLICT_OVERWRITE
|
||||||
import com.simplemobiletools.commons.helpers.CONFLICT_SKIP
|
import com.simplemobiletools.commons.helpers.CONFLICT_SKIP
|
||||||
import com.simplemobiletools.commons.helpers.FileDirItemKeyProvider
|
|
||||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||||
import com.simplemobiletools.commons.models.FileDirItem
|
import com.simplemobiletools.commons.models.FileDirItem
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
|
@ -51,6 +50,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
||||||
var adjustedPrimaryColor = activity.getAdjustedPrimaryColor()
|
var adjustedPrimaryColor = activity.getAdjustedPrimaryColor()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
setupDragListener(true)
|
||||||
initDrawables()
|
initDrawables()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun actionItemPressed(id: Int) {
|
override fun actionItemPressed(id: Int) {
|
||||||
if (getSelectedKeys().isEmpty) {
|
if (selectedKeys.isEmpty()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
||||||
|
|
||||||
override fun getItemSelectionKey(position: Int) = fileDirItems[position].path
|
override fun getItemSelectionKey(position: Int) = fileDirItems[position].path
|
||||||
|
|
||||||
override fun getItemSelectionKeyProvider() = FileDirItemKeyProvider(fileDirItems)
|
override fun getItemKeyPosition(key: String) = fileDirItems.indexOfFirst { it.path == key }
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.list_item, parent)
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.list_item, parent)
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
||||||
fileDrawable.alpha = 180
|
fileDrawable.alpha = 180
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isOneFileSelected() = isOneItemSelected() && getItemWithKey(getSelectedKeys().first())?.isDirectory == false
|
private fun isOneFileSelected() = isOneItemSelected() && getItemWithKey(selectedKeys.first())?.isDirectory == false
|
||||||
|
|
||||||
private fun checkHideBtnVisibility(menu: Menu) {
|
private fun checkHideBtnVisibility(menu: Menu) {
|
||||||
var hiddenCnt = 0
|
var hiddenCnt = 0
|
||||||
|
@ -142,7 +142,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun confirmSelection() {
|
private fun confirmSelection() {
|
||||||
if (!getSelectedKeys().isEmpty) {
|
if (selectedKeys.isNotEmpty()) {
|
||||||
val paths = getSelectedFileDirItems().filter { !it.isDirectory }.map { it.path } as ArrayList<String>
|
val paths = getSelectedFileDirItems().filter { !it.isDirectory }.map { it.path } as ArrayList<String>
|
||||||
listener?.selectedPaths(paths)
|
listener?.selectedPaths(paths)
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showProperties() {
|
private fun showProperties() {
|
||||||
if (getSelectedKeys().size() <= 1) {
|
if (selectedKeys.size <= 1) {
|
||||||
PropertiesDialog(activity, getFirstSelectedItemPath(), activity.config.shouldShowHidden)
|
PropertiesDialog(activity, getFirstSelectedItemPath(), activity.config.shouldShowHidden)
|
||||||
} else {
|
} else {
|
||||||
val paths = getSelectedFileDirItems().map { it.path }
|
val paths = getSelectedFileDirItems().map { it.path }
|
||||||
|
@ -470,7 +470,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun askConfirmDelete() {
|
private fun askConfirmDelete() {
|
||||||
val selectionSize = getSelectedKeys().size()
|
val selectionSize = selectedKeys.size
|
||||||
val items = resources.getQuantityString(R.plurals.delete_items, selectionSize, selectionSize)
|
val items = resources.getQuantityString(R.plurals.delete_items, selectionSize, selectionSize)
|
||||||
val question = String.format(resources.getString(R.string.deletion_confirmation), items)
|
val question = String.format(resources.getString(R.string.deletion_confirmation), items)
|
||||||
ConfirmationDialog(activity, question) {
|
ConfirmationDialog(activity, question) {
|
||||||
|
@ -479,8 +479,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun deleteFiles() {
|
private fun deleteFiles() {
|
||||||
val selectedKeys = getSelectedKeys()
|
if (selectedKeys.isEmpty()) {
|
||||||
if (selectedKeys.isEmpty) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,9 +490,9 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.handleSAFDialog(SAFPath) {
|
activity.handleSAFDialog(SAFPath) {
|
||||||
val files = ArrayList<FileDirItem>(selectedKeys.size())
|
val files = ArrayList<FileDirItem>(selectedKeys.size)
|
||||||
val positions = ArrayList<Int>()
|
val positions = ArrayList<Int>()
|
||||||
getSelectedKeys().forEach {
|
selectedKeys.forEach {
|
||||||
activity.config.removeFavorite(it)
|
activity.config.removeFavorite(it)
|
||||||
val key = it
|
val key = it
|
||||||
val position = fileDirItems.indexOfFirst { it.path == key }
|
val position = fileDirItems.indexOfFirst { it.path == key }
|
||||||
|
@ -515,8 +514,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
||||||
private fun getFirstSelectedItemPath() = getSelectedFileDirItems().first().path
|
private fun getFirstSelectedItemPath() = getSelectedFileDirItems().first().path
|
||||||
|
|
||||||
private fun getSelectedFileDirItems(): ArrayList<FileDirItem> {
|
private fun getSelectedFileDirItems(): ArrayList<FileDirItem> {
|
||||||
val selectedKeys = getSelectedKeys()
|
val selectedFileDirItems = ArrayList<FileDirItem>(selectedKeys.size)
|
||||||
val selectedFileDirItems = ArrayList<FileDirItem>(selectedKeys.size())
|
|
||||||
selectedKeys.forEach {
|
selectedKeys.forEach {
|
||||||
getItemWithKey(it)?.apply {
|
getItemWithKey(it)?.apply {
|
||||||
selectedFileDirItems.add(this)
|
selectedFileDirItems.add(this)
|
||||||
|
|
|
@ -5,7 +5,6 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||||
import com.simplemobiletools.commons.helpers.StringListKeyProvider
|
|
||||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.filemanager.R
|
import com.simplemobiletools.filemanager.R
|
||||||
|
@ -18,6 +17,10 @@ class ManageFavoritesAdapter(activity: BaseSimpleActivity, var favorites: ArrayL
|
||||||
|
|
||||||
private val config = activity.config
|
private val config = activity.config
|
||||||
|
|
||||||
|
init {
|
||||||
|
setupDragListener(true)
|
||||||
|
}
|
||||||
|
|
||||||
override fun getActionMenuId() = R.menu.cab_remove_only
|
override fun getActionMenuId() = R.menu.cab_remove_only
|
||||||
|
|
||||||
override fun actionItemPressed(id: Int) {
|
override fun actionItemPressed(id: Int) {
|
||||||
|
@ -32,7 +35,7 @@ class ManageFavoritesAdapter(activity: BaseSimpleActivity, var favorites: ArrayL
|
||||||
|
|
||||||
override fun getItemSelectionKey(position: Int) = favorites[position]
|
override fun getItemSelectionKey(position: Int) = favorites[position]
|
||||||
|
|
||||||
override fun getItemSelectionKeyProvider() = StringListKeyProvider(favorites)
|
override fun getItemKeyPosition(key: String) = favorites.indexOfFirst { it == key }
|
||||||
|
|
||||||
override fun prepareActionMode(menu: Menu) {}
|
override fun prepareActionMode(menu: Menu) {}
|
||||||
|
|
||||||
|
@ -60,10 +63,9 @@ class ManageFavoritesAdapter(activity: BaseSimpleActivity, var favorites: ArrayL
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun removeSelection() {
|
private fun removeSelection() {
|
||||||
val selectedKeys = getSelectedKeys()
|
val removeFavorites = ArrayList<String>(selectedKeys.size)
|
||||||
val removeFavorites = ArrayList<String>(selectedKeys.size())
|
|
||||||
val positions = java.util.ArrayList<Int>()
|
val positions = java.util.ArrayList<Int>()
|
||||||
getSelectedKeys().forEach {
|
selectedKeys.forEach {
|
||||||
val key = it
|
val key = it
|
||||||
val position = favorites.indexOfFirst { it == key }
|
val position = favorites.indexOfFirst { it == key }
|
||||||
if (position != -1) {
|
if (position != -1) {
|
||||||
|
|
|
@ -152,7 +152,6 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
||||||
}.apply {
|
}.apply {
|
||||||
addVerticalDividers(true)
|
addVerticalDividers(true)
|
||||||
items_list.adapter = this
|
items_list.adapter = this
|
||||||
initSelectionTracker()
|
|
||||||
}
|
}
|
||||||
items_fastscroller.allowBubbleDisplay = context.config.showInfoBubble
|
items_fastscroller.allowBubbleDisplay = context.config.showInfoBubble
|
||||||
items_fastscroller.setViews(items_list, mView.items_swipe_refresh) {
|
items_fastscroller.setViews(items_list, mView.items_swipe_refresh) {
|
||||||
|
|
Loading…
Reference in New Issue