mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-27 17:08:34 +03:00
Shared items: Add tab for deck cards
Deck cards will be opened in the web browser because no specific view exists. Resolves: #2029 Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
parent
4c8c8ac98a
commit
43f2d1badf
7 changed files with 115 additions and 38 deletions
|
@ -206,12 +206,12 @@ class SharedItemsActivity : AppCompatActivity() {
|
|||
binding.sharedItemsTabs.addTab(tabLocation)
|
||||
}
|
||||
|
||||
// if(sharedItemTypes.contains(SharedItemType.DECKCARD)) {
|
||||
// val tabDeckCard: TabLayout.Tab = binding.sharedItemsTabs.newTab()
|
||||
// tabDeckCard.tag = SharedItemType.DECKCARD
|
||||
// tabDeckCard.text = "deckcard"
|
||||
// binding.sharedItemsTabs.addTab(tabDeckCard)
|
||||
// }
|
||||
if (sharedItemTypes.contains(SharedItemType.DECKCARD)) {
|
||||
val tabDeckCard: TabLayout.Tab = binding.sharedItemsTabs.newTab()
|
||||
tabDeckCard.tag = SharedItemType.DECKCARD
|
||||
tabDeckCard.setText(R.string.nc_shared_items_deck_card)
|
||||
binding.sharedItemsTabs.addTab(tabDeckCard)
|
||||
}
|
||||
|
||||
if (sharedItemTypes.contains(SharedItemType.OTHER)) {
|
||||
val tabOther: TabLayout.Tab = binding.sharedItemsTabs.newTab()
|
||||
|
|
|
@ -31,6 +31,7 @@ import com.nextcloud.talk.databinding.SharedItemGridBinding
|
|||
import com.nextcloud.talk.databinding.SharedItemListBinding
|
||||
import com.nextcloud.talk.polls.ui.PollMainDialogFragment
|
||||
import com.nextcloud.talk.shareditems.activities.SharedItemsActivity
|
||||
import com.nextcloud.talk.shareditems.model.SharedDeckCardItem
|
||||
import com.nextcloud.talk.shareditems.model.SharedFileItem
|
||||
import com.nextcloud.talk.shareditems.model.SharedItem
|
||||
import com.nextcloud.talk.shareditems.model.SharedLocationItem
|
||||
|
@ -75,6 +76,7 @@ class SharedItemsAdapter(
|
|||
is SharedFileItem -> holder.onBind(item)
|
||||
is SharedLocationItem -> holder.onBind(item)
|
||||
is SharedOtherItem -> holder.onBind(item)
|
||||
is SharedDeckCardItem -> holder.onBind(item)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import com.facebook.drawee.view.SimpleDraweeView
|
|||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.data.user.model.User
|
||||
import com.nextcloud.talk.databinding.SharedItemListBinding
|
||||
import com.nextcloud.talk.shareditems.model.SharedDeckCardItem
|
||||
import com.nextcloud.talk.shareditems.model.SharedFileItem
|
||||
import com.nextcloud.talk.shareditems.model.SharedItem
|
||||
import com.nextcloud.talk.shareditems.model.SharedLocationItem
|
||||
|
@ -98,7 +99,6 @@ class SharedItemsListViewHolder(
|
|||
)
|
||||
|
||||
clickTarget.setOnClickListener {
|
||||
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, item.geoUri)
|
||||
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
it.context.startActivity(browserIntent)
|
||||
|
@ -119,4 +119,25 @@ class SharedItemsListViewHolder(
|
|||
android.graphics.PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBind(item: SharedDeckCardItem) {
|
||||
super.onBind(item)
|
||||
|
||||
binding.fileName.text = item.name
|
||||
binding.fileSize.visibility = View.GONE
|
||||
binding.separator1.visibility = View.GONE
|
||||
binding.fileDate.text = item.dateTime
|
||||
binding.actor.text = item.actorName
|
||||
image.hierarchy.setPlaceholderImage(R.drawable.ic_baseline_location_on_24)
|
||||
image.setColorFilter(
|
||||
ContextCompat.getColor(image.context, R.color.high_emphasis_menu_icon),
|
||||
android.graphics.PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
|
||||
clickTarget.setOnClickListener {
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, item.link)
|
||||
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
it.context.startActivity(browserIntent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import com.facebook.imagepipeline.common.RotationOptions
|
|||
import com.facebook.imagepipeline.image.ImageInfo
|
||||
import com.facebook.imagepipeline.request.ImageRequestBuilder
|
||||
import com.nextcloud.talk.data.user.model.User
|
||||
import com.nextcloud.talk.shareditems.model.SharedDeckCardItem
|
||||
import com.nextcloud.talk.shareditems.model.SharedFileItem
|
||||
import com.nextcloud.talk.shareditems.model.SharedItem
|
||||
import com.nextcloud.talk.shareditems.model.SharedLocationItem
|
||||
|
@ -134,6 +135,8 @@ abstract class SharedItemsViewHolder(
|
|||
|
||||
open fun onBind(item: SharedOtherItem) {}
|
||||
|
||||
open fun onBind(item: SharedDeckCardItem) {}
|
||||
|
||||
private fun staticImage(
|
||||
mimeType: String?,
|
||||
image: SimpleDraweeView
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Tim Krüger
|
||||
* Copyright (C) 2022 Tim Krüger <t@timkrueger.me>
|
||||
*
|
||||
* 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.shareditems.model
|
||||
|
||||
import android.net.Uri
|
||||
|
||||
data class SharedDeckCardItem(
|
||||
override val id: String,
|
||||
override val name: String,
|
||||
override val actorId: String,
|
||||
override val actorName: String,
|
||||
override val dateTime: String,
|
||||
val link: Uri
|
||||
) : SharedItem
|
|
@ -28,6 +28,7 @@ import com.nextcloud.talk.R
|
|||
import com.nextcloud.talk.api.NcApi
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
|
||||
import com.nextcloud.talk.models.json.chat.ChatShareOverall
|
||||
import com.nextcloud.talk.shareditems.model.SharedDeckCardItem
|
||||
import com.nextcloud.talk.shareditems.model.SharedFileItem
|
||||
import com.nextcloud.talk.shareditems.model.SharedItem
|
||||
import com.nextcloud.talk.shareditems.model.SharedItemType
|
||||
|
@ -39,6 +40,7 @@ import com.nextcloud.talk.utils.ApiUtils
|
|||
import com.nextcloud.talk.utils.DateUtils
|
||||
import io.reactivex.Observable
|
||||
import retrofit2.Response
|
||||
import java.util.HashMap
|
||||
import java.util.Locale
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -109,36 +111,7 @@ class SharedItemsRepositoryImpl @Inject constructor(private val ncApi: NcApi) :
|
|||
)
|
||||
} else if (it.value.messageParameters?.containsKey("object") == true) {
|
||||
val objectParameters = it.value.messageParameters!!["object"]!!
|
||||
when (objectParameters["type"]) {
|
||||
"talk-poll" -> {
|
||||
items[it.value.id] = SharedPollItem(
|
||||
objectParameters["id"]!!,
|
||||
objectParameters["name"]!!,
|
||||
actorParameters["id"]!!,
|
||||
actorParameters["name"]!!,
|
||||
dateTime
|
||||
)
|
||||
}
|
||||
"geo-location" -> {
|
||||
items[it.value.id] = SharedLocationItem(
|
||||
objectParameters["id"]!!,
|
||||
objectParameters["name"]!!,
|
||||
actorParameters["id"]!!,
|
||||
actorParameters["name"]!!,
|
||||
dateTime,
|
||||
Uri.parse(objectParameters["id"]!!.replace("geo:", "geo:0,0?z=11&q="))
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
items[it.value.id] = SharedOtherItem(
|
||||
objectParameters["id"]!!,
|
||||
objectParameters["name"]!!,
|
||||
actorParameters["id"]!!,
|
||||
actorParameters["name"]!!,
|
||||
dateTime
|
||||
)
|
||||
}
|
||||
}
|
||||
items[it.value.id] = itemFromObject(objectParameters, actorParameters, dateTime)
|
||||
} else {
|
||||
Log.w(TAG, "Item contains neither 'file' or 'object'.")
|
||||
}
|
||||
|
@ -156,6 +129,53 @@ class SharedItemsRepositoryImpl @Inject constructor(private val ncApi: NcApi) :
|
|||
)
|
||||
}
|
||||
|
||||
private fun itemFromObject(
|
||||
objectParameters: HashMap<String?, String?>,
|
||||
actorParameters: HashMap<String?, String?>,
|
||||
dateTime: String
|
||||
): SharedItem {
|
||||
when (objectParameters["type"]) {
|
||||
"talk-poll" -> {
|
||||
return SharedPollItem(
|
||||
objectParameters["id"]!!,
|
||||
objectParameters["name"]!!,
|
||||
actorParameters["id"]!!,
|
||||
actorParameters["name"]!!,
|
||||
dateTime
|
||||
)
|
||||
}
|
||||
"geo-location" -> {
|
||||
return SharedLocationItem(
|
||||
objectParameters["id"]!!,
|
||||
objectParameters["name"]!!,
|
||||
actorParameters["id"]!!,
|
||||
actorParameters["name"]!!,
|
||||
dateTime,
|
||||
Uri.parse(objectParameters["id"]!!.replace("geo:", "geo:0,0?z=11&q="))
|
||||
)
|
||||
}
|
||||
"deck-card" -> {
|
||||
return SharedDeckCardItem(
|
||||
objectParameters["id"]!!,
|
||||
objectParameters["name"]!!,
|
||||
actorParameters["id"]!!,
|
||||
actorParameters["name"]!!,
|
||||
dateTime,
|
||||
Uri.parse(objectParameters["link"]!!)
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
return SharedOtherItem(
|
||||
objectParameters["id"]!!,
|
||||
objectParameters["name"]!!,
|
||||
actorParameters["id"]!!,
|
||||
actorParameters["name"]!!,
|
||||
dateTime
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun availableTypes(parameters: SharedItemsRepository.Parameters): Observable<Set<SharedItemType>> {
|
||||
val credentials = ApiUtils.getCredentials(parameters.userName, parameters.userToken)
|
||||
|
||||
|
|
|
@ -431,6 +431,7 @@
|
|||
<string name="nc_shared_items_description">Images, files, voice messages …</string>
|
||||
<string name="nc_shared_items_empty">No shared items</string>
|
||||
<string name="nc_shared_items_location">Location</string>
|
||||
<string name="nc_shared_items_deck_card">Deck card</string>
|
||||
|
||||
<!-- voice messages -->
|
||||
<string name="nc_voice_message_filename">Talk recording from %1$s (%2$s)</string>
|
||||
|
@ -563,5 +564,4 @@
|
|||
<string name="call_without_notification">Call without notification</string>
|
||||
<string name="set_avatar_from_camera">Set avatar from camera</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue