mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-23 21:45:42 +03:00
Merge pull request #2283 from nextcloud/feature/2029/more-tabs-in-shared-items-view-2
Add tab for deck cards
This commit is contained in:
commit
768cb06999
15 changed files with 201 additions and 48 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,12 +32,12 @@ 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
|
||||
import com.nextcloud.talk.shareditems.model.SharedOtherItem
|
||||
import com.nextcloud.talk.shareditems.model.SharedPollItem
|
||||
import com.nextcloud.talk.utils.DateUtils
|
||||
|
||||
class SharedItemsListViewHolder(
|
||||
override val binding: SharedItemListBinding,
|
||||
|
@ -62,16 +62,18 @@ class SharedItemsListViewHolder(
|
|||
it
|
||||
)
|
||||
}
|
||||
binding.fileDate.text = DateUtils.getLocalDateTimeStringFromTimestamp(
|
||||
item.date * ONE_SECOND_IN_MILLIS
|
||||
)
|
||||
binding.fileDate.text = item.dateTime
|
||||
binding.actor.text = item.actorName
|
||||
}
|
||||
|
||||
override fun onBind(item: SharedPollItem, showPoll: (item: SharedItem, context: Context) -> Unit) {
|
||||
super.onBind(item, showPoll)
|
||||
|
||||
binding.fileName.text = item.name
|
||||
binding.fileMetadata.visibility = View.GONE
|
||||
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_bar_chart_24)
|
||||
image.setColorFilter(
|
||||
ContextCompat.getColor(image.context, R.color.high_emphasis_menu_icon),
|
||||
|
@ -86,7 +88,10 @@ class SharedItemsListViewHolder(
|
|||
super.onBind(item)
|
||||
|
||||
binding.fileName.text = item.name
|
||||
binding.fileMetadata.visibility = View.GONE
|
||||
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),
|
||||
|
@ -94,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)
|
||||
|
@ -105,7 +109,10 @@ class SharedItemsListViewHolder(
|
|||
super.onBind(item)
|
||||
|
||||
binding.fileName.text = item.name
|
||||
binding.fileMetadata.visibility = View.GONE
|
||||
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_mimetype_file)
|
||||
image.setColorFilter(
|
||||
ContextCompat.getColor(image.context, R.color.high_emphasis_menu_icon),
|
||||
|
@ -113,7 +120,24 @@ class SharedItemsListViewHolder(
|
|||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val ONE_SECOND_IN_MILLIS = 1000
|
||||
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_deck_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
|
|
@ -27,8 +27,8 @@ data class SharedFileItem(
|
|||
override val name: String,
|
||||
override val actorId: String,
|
||||
override val actorName: String,
|
||||
override val dateTime: String,
|
||||
val fileSize: Long,
|
||||
val date: Long,
|
||||
val path: String,
|
||||
val link: String,
|
||||
val mimeType: String,
|
||||
|
|
|
@ -5,4 +5,5 @@ interface SharedItem {
|
|||
val name: String
|
||||
val actorId: String
|
||||
val actorName: String
|
||||
val dateTime: String
|
||||
}
|
||||
|
|
|
@ -26,5 +26,6 @@ data class SharedLocationItem(
|
|||
override val name: String,
|
||||
override val actorId: String,
|
||||
override val actorName: String,
|
||||
override val dateTime: String,
|
||||
val geoUri: Uri
|
||||
) : SharedItem
|
||||
|
|
|
@ -24,4 +24,5 @@ data class SharedOtherItem(
|
|||
override val name: String,
|
||||
override val actorId: String,
|
||||
override val actorName: String,
|
||||
override val dateTime: String
|
||||
) : SharedItem
|
||||
|
|
|
@ -24,4 +24,5 @@ data class SharedPollItem(
|
|||
override val name: String,
|
||||
override val actorId: String,
|
||||
override val actorName: String,
|
||||
override val dateTime: String
|
||||
) : 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
|
||||
|
@ -36,8 +37,10 @@ import com.nextcloud.talk.shareditems.model.SharedLocationItem
|
|||
import com.nextcloud.talk.shareditems.model.SharedOtherItem
|
||||
import com.nextcloud.talk.shareditems.model.SharedPollItem
|
||||
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
|
||||
|
||||
|
@ -83,6 +86,10 @@ class SharedItemsRepositoryImpl @Inject constructor(private val ncApi: NcApi) :
|
|||
if (mediaItems != null) {
|
||||
for (it in mediaItems) {
|
||||
val actorParameters = it.value.messageParameters!!["actor"]!!
|
||||
val dateTime = DateUtils.getLocalDateTimeStringFromTimestamp(
|
||||
it.value.timestamp * ONE_SECOND_IN_MILLIS
|
||||
)
|
||||
|
||||
if (it.value.messageParameters?.containsKey("file") == true) {
|
||||
val fileParameters = it.value.messageParameters!!["file"]!!
|
||||
|
||||
|
@ -94,8 +101,8 @@ class SharedItemsRepositoryImpl @Inject constructor(private val ncApi: NcApi) :
|
|||
fileParameters["name"]!!,
|
||||
actorParameters["id"]!!,
|
||||
actorParameters["name"]!!,
|
||||
dateTime,
|
||||
fileParameters["size"]!!.toLong(),
|
||||
it.value.timestamp,
|
||||
fileParameters["path"]!!,
|
||||
fileParameters["link"]!!,
|
||||
fileParameters["mimetype"]!!,
|
||||
|
@ -104,33 +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"]!!
|
||||
)
|
||||
}
|
||||
"geo-location" -> {
|
||||
items[it.value.id] = SharedLocationItem(
|
||||
objectParameters["id"]!!,
|
||||
objectParameters["name"]!!,
|
||||
actorParameters["id"]!!,
|
||||
actorParameters["name"]!!,
|
||||
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"]!!
|
||||
)
|
||||
}
|
||||
}
|
||||
items[it.value.id] = itemFromObject(objectParameters, actorParameters, dateTime)
|
||||
} else {
|
||||
Log.w(TAG, "Item contains neither 'file' or 'object'.")
|
||||
}
|
||||
|
@ -148,6 +129,55 @@ class SharedItemsRepositoryImpl @Inject constructor(private val ncApi: NcApi) :
|
|||
)
|
||||
}
|
||||
|
||||
private fun itemFromObject(
|
||||
objectParameters: HashMap<String?, String?>,
|
||||
actorParameters: HashMap<String?, String?>,
|
||||
dateTime: String
|
||||
): SharedItem {
|
||||
val returnValue: SharedItem
|
||||
when (objectParameters["type"]) {
|
||||
"talk-poll" -> {
|
||||
returnValue = SharedPollItem(
|
||||
objectParameters["id"]!!,
|
||||
objectParameters["name"]!!,
|
||||
actorParameters["id"]!!,
|
||||
actorParameters["name"]!!,
|
||||
dateTime
|
||||
)
|
||||
}
|
||||
"geo-location" -> {
|
||||
returnValue = SharedLocationItem(
|
||||
objectParameters["id"]!!,
|
||||
objectParameters["name"]!!,
|
||||
actorParameters["id"]!!,
|
||||
actorParameters["name"]!!,
|
||||
dateTime,
|
||||
Uri.parse(objectParameters["id"]!!.replace("geo:", "geo:0,0?z=11&q="))
|
||||
)
|
||||
}
|
||||
"deck-card" -> {
|
||||
returnValue = SharedDeckCardItem(
|
||||
objectParameters["id"]!!,
|
||||
objectParameters["name"]!!,
|
||||
actorParameters["id"]!!,
|
||||
actorParameters["name"]!!,
|
||||
dateTime,
|
||||
Uri.parse(objectParameters["link"]!!)
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
returnValue = SharedOtherItem(
|
||||
objectParameters["id"]!!,
|
||||
objectParameters["name"]!!,
|
||||
actorParameters["id"]!!,
|
||||
actorParameters["name"]!!,
|
||||
dateTime
|
||||
)
|
||||
}
|
||||
}
|
||||
return returnValue
|
||||
}
|
||||
|
||||
override fun availableTypes(parameters: SharedItemsRepository.Parameters): Observable<Set<SharedItemType>> {
|
||||
val credentials = ApiUtils.getCredentials(parameters.userName, parameters.userToken)
|
||||
|
||||
|
@ -182,6 +212,7 @@ class SharedItemsRepositoryImpl @Inject constructor(private val ncApi: NcApi) :
|
|||
|
||||
companion object {
|
||||
const val BATCH_SIZE: Int = 28
|
||||
private const val ONE_SECOND_IN_MILLIS = 1000
|
||||
private val TAG = SharedItemsRepositoryImpl::class.simpleName
|
||||
}
|
||||
}
|
||||
|
|
39
app/src/main/res/drawable/ic_baseline_deck_24.xml
Normal file
39
app/src/main/res/drawable/ic_baseline_deck_24.xml
Normal file
|
@ -0,0 +1,39 @@
|
|||
<!--
|
||||
~ Nextcloud Talk application
|
||||
~
|
||||
~ Copyright (C) 2022 Nextcloud GmbH
|
||||
~
|
||||
~ 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/>.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="?attr/colorControlNormal"
|
||||
android:viewportWidth="16"
|
||||
android:viewportHeight="16">
|
||||
<group>
|
||||
<path
|
||||
android:fillColor="#fff"
|
||||
android:pathData="M2,7L14,7A1,1 0,0 1,15 8L15,14A1,1 0,0 1,14 15L2,15A1,1 0,0 1,1 14L1,8A1,1 0,0 1,2 7z" />
|
||||
<path
|
||||
android:fillColor="#fff"
|
||||
android:pathData="M2.5,5L13.5,5A0.5,0.5 0,0 1,14 5.5L14,5.5A0.5,0.5 0,0 1,13.5 6L2.5,6A0.5,0.5 0,0 1,2 5.5L2,5.5A0.5,0.5 0,0 1,2.5 5z" />
|
||||
<path
|
||||
android:fillColor="#fff"
|
||||
android:pathData="M3.5,3L12.5,3A0.5,0.5 0,0 1,13 3.5L13,3.5A0.5,0.5 0,0 1,12.5 4L3.5,4A0.5,0.5 0,0 1,3 3.5L3,3.5A0.5,0.5 0,0 1,3.5 3z" />
|
||||
<path
|
||||
android:fillColor="#fff"
|
||||
android:pathData="M4.5,1L11.5,1A0.5,0.5 0,0 1,12 1.5L12,1.5A0.5,0.5 0,0 1,11.5 2L4.5,2A0.5,0.5 0,0 1,4 1.5L4,1.5A0.5,0.5 0,0 1,4.5 1z" />
|
||||
</group>
|
||||
</vector>
|
|
@ -115,7 +115,7 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:id="@+id/separator"
|
||||
android:id="@+id/separator_1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/controller_chat_separator" />
|
||||
|
|
|
@ -92,7 +92,7 @@
|
|||
tools:text="11 KB" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/separator"
|
||||
android:id="@+id/separator_1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/standard_quarter_margin"
|
||||
|
@ -110,6 +110,25 @@
|
|||
android:textSize="14sp"
|
||||
tools:text="04-05-2022 21:16" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/separator_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/standard_quarter_margin"
|
||||
android:text="|"
|
||||
android:textColor="@color/textColorMaxContrast"
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/actor"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/standard_quarter_margin"
|
||||
android:textColor="@color/textColorMaxContrast"
|
||||
android:textSize="14sp"
|
||||
tools:text="Actor" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -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