瀏覽代碼

create narrow(er) interface for file selection

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 2 年之前
父節點
當前提交
80eccf3176

+ 1 - 0
app/src/main/java/com/nextcloud/talk/interfaces/SelectionInterface.kt

@@ -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)
 

+ 27 - 0
app/src/main/java/com/nextcloud/talk/remotefilebrowser/SelectionInterface.kt

@@ -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
+}

+ 4 - 10
app/src/main/java/com/nextcloud/talk/remotefilebrowser/activities/RemoteFileBrowserActivity.kt

@@ -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
-    }
 }

+ 1 - 1
app/src/main/java/com/nextcloud/talk/remotefilebrowser/adapters/RemoteFileBrowserItemsAdapter.kt

@@ -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(

+ 1 - 1
app/src/main/java/com/nextcloud/talk/remotefilebrowser/adapters/RemoteFileBrowserItemsListViewHolder.kt

@@ -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

+ 1 - 1
app/src/main/java/com/nextcloud/talk/remotefilebrowser/adapters/RemoteFileBrowserItemsViewHolder.kt

@@ -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
 

+ 3 - 1
app/src/main/java/com/nextcloud/talk/remotefilebrowser/viewmodels/RemoteFileBrowserItemsViewModel.kt

@@ -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