create narrow(er) interface for file selection

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-06-07 18:38:41 +02:00
parent ed09934c7a
commit 80eccf3176
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
7 changed files with 38 additions and 14 deletions

View file

@ -20,6 +20,7 @@
package com.nextcloud.talk.interfaces
@Deprecated("To be replaced with com.nextcloud.talk.remotefilebrowser.SelectionInterface")
interface SelectionInterface {
fun toggleBrowserItemSelection(path: String)

View file

@ -0,0 +1,27 @@
/*
* Nextcloud Talk application
*
* @author Mario Danic
* @author Andy Scherzinger
* Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.nextcloud.talk.remotefilebrowser
interface SelectionInterface {
fun isPathSelected(path: String): Boolean
}

View file

@ -2,7 +2,9 @@
* Nextcloud Talk application
*
* @author Andy Scherzinger
* @author Álvaro Brey
* Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
* Copyright (C) 2022 Álvaro Brey <alvaro.brey@nextcloud.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -38,7 +40,7 @@ import autodagger.AutoInjector
import com.nextcloud.talk.R
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.databinding.ActivityRemoteFileBrowserBinding
import com.nextcloud.talk.interfaces.SelectionInterface
import com.nextcloud.talk.remotefilebrowser.SelectionInterface
import com.nextcloud.talk.remotefilebrowser.adapters.RemoteFileBrowserItemsAdapter
import com.nextcloud.talk.remotefilebrowser.viewmodels.RemoteFileBrowserItemsViewModel
import com.nextcloud.talk.ui.dialog.SortingOrderDialogFragment
@ -121,7 +123,7 @@ class RemoteFileBrowserActivity : AppCompatActivity(), SelectionInterface, Swipe
// TODO make mimeTypeSelectionFilter a bundled arg for the activity
val mimeTypeSelectionFilter = "image/"
// TODO do not needlesly recreate adapter if it can be reused
// TODO do not needlessly recreate adapter if it can be reused
val adapter = RemoteFileBrowserItemsAdapter(
showGrid = showGrid,
mimeTypeSelectionFilter = mimeTypeSelectionFilter,
@ -240,16 +242,8 @@ class RemoteFileBrowserActivity : AppCompatActivity(), SelectionInterface, Swipe
const val REQUEST_CODE_SELECT_AVATAR = 22
}
override fun toggleBrowserItemSelection(path: String) {
// unused, viewmodel gets called directly
}
override fun isPathSelected(path: String): Boolean {
// TODO figure out a better way to do this. Narrower interface?
return viewModel.isPathSelected(path)
}
override fun shouldOnlySelectOneImageFile(): Boolean {
return true // unused
}
}

View file

@ -25,8 +25,8 @@ import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.nextcloud.talk.databinding.RvItemBrowserFileBinding
import com.nextcloud.talk.interfaces.SelectionInterface
import com.nextcloud.talk.models.database.UserEntity
import com.nextcloud.talk.remotefilebrowser.SelectionInterface
import com.nextcloud.talk.remotefilebrowser.model.RemoteFileBrowserItem
class RemoteFileBrowserItemsAdapter(

View file

@ -30,8 +30,8 @@ import com.facebook.drawee.view.SimpleDraweeView
import com.nextcloud.talk.R
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.databinding.RvItemBrowserFileBinding
import com.nextcloud.talk.interfaces.SelectionInterface
import com.nextcloud.talk.models.database.UserEntity
import com.nextcloud.talk.remotefilebrowser.SelectionInterface
import com.nextcloud.talk.remotefilebrowser.model.RemoteFileBrowserItem
import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.DateUtils.getLocalDateTimeStringFromTimestamp

View file

@ -25,8 +25,8 @@ import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import androidx.viewbinding.ViewBinding
import com.facebook.drawee.view.SimpleDraweeView
import com.nextcloud.talk.interfaces.SelectionInterface
import com.nextcloud.talk.models.database.UserEntity
import com.nextcloud.talk.remotefilebrowser.SelectionInterface
import com.nextcloud.talk.remotefilebrowser.model.RemoteFileBrowserItem
import com.nextcloud.talk.utils.DrawableUtils

View file

@ -2,7 +2,9 @@
* Nextcloud Talk application
*
* @author Andy Scherzinger
* Copyright (C) 202 Andy Scherzinger <info@andy-scherzinger.de>
* @author Álvaro Brey
* Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
* Copyright (C) 2022 Álvaro Brey <alvaro.brey@nextcloud.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by