mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-27 08:55:54 +03:00
add filesize and date to listview for shared items
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
925d839ccd
commit
fd08ad965a
4 changed files with 52 additions and 9 deletions
|
@ -1,6 +1,7 @@
|
|||
package com.nextcloud.talk.adapters
|
||||
|
||||
import android.net.Uri
|
||||
import android.text.format.Formatter
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -12,12 +13,14 @@ import com.facebook.imagepipeline.request.ImageRequestBuilder
|
|||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.databinding.AttachmentListItemBinding
|
||||
import com.nextcloud.talk.repositories.SharedItem
|
||||
import com.nextcloud.talk.utils.DateUtils
|
||||
import com.nextcloud.talk.utils.FileViewerUtils
|
||||
|
||||
class SharedItemsListAdapter : RecyclerView.Adapter<SharedItemsListAdapter.ViewHolder>() {
|
||||
|
||||
companion object {
|
||||
private val TAG = SharedItemsListAdapter::class.simpleName
|
||||
private const val ONE_SECOND_IN_MILLIS = 1000
|
||||
}
|
||||
|
||||
class ViewHolder(val binding: AttachmentListItemBinding, itemView: View) : RecyclerView.ViewHolder(itemView)
|
||||
|
@ -35,6 +38,13 @@ class SharedItemsListAdapter : RecyclerView.Adapter<SharedItemsListAdapter.ViewH
|
|||
val currentItem = items[position]
|
||||
|
||||
holder.binding.fileName.text = currentItem.name
|
||||
holder.binding.fileSize.text = Formatter.formatShortFileSize(
|
||||
holder.binding.fileSize.context,
|
||||
currentItem.fileSize.toLong()
|
||||
)
|
||||
holder.binding.fileDate.text = DateUtils.getLocalDateTimeStringFromTimestamp(
|
||||
currentItem.date * ONE_SECOND_IN_MILLIS
|
||||
)
|
||||
|
||||
if (currentItem.previewAvailable) {
|
||||
val imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(currentItem.previewLink))
|
||||
|
|
|
@ -6,6 +6,7 @@ data class SharedItem(
|
|||
val id: String,
|
||||
val name: String,
|
||||
val fileSize: Int,
|
||||
val date: Long,
|
||||
val path: String,
|
||||
val link: String,
|
||||
val mimeType: String,
|
||||
|
|
|
@ -71,6 +71,7 @@ class SharedItemsViewModel(private val repository: SharedItemsRepository, privat
|
|||
fileParameters["id"]!!,
|
||||
fileParameters["name"]!!,
|
||||
fileParameters["size"]!!.toInt(),
|
||||
it.value.timestamp,
|
||||
fileParameters["path"]!!,
|
||||
fileParameters["link"]!!,
|
||||
fileParameters["mimetype"]!!,
|
||||
|
|
|
@ -63,18 +63,49 @@
|
|||
android:visibility="gone" />
|
||||
</FrameLayout>
|
||||
|
||||
<androidx.emoji.widget.EmojiTextView
|
||||
android:id="@+id/file_name"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@id/preview_container"
|
||||
android:ellipsize="end"
|
||||
android:lines="1"
|
||||
android:textAlignment="viewStart"
|
||||
android:textAppearance="@style/ListItem"
|
||||
tools:text="Filename" />
|
||||
android:orientation="vertical"
|
||||
android:layout_toEndOf="@id/preview_container">
|
||||
|
||||
<androidx.emoji.widget.EmojiTextView
|
||||
android:id="@+id/file_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:lines="1"
|
||||
android:textAlignment="viewStart"
|
||||
android:textAppearance="@style/ListItem"
|
||||
tools:text="Filename" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/file_size"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="filesize"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/margin_between_elements"
|
||||
android:text="|"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/file_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/margin_between_elements"
|
||||
tools:text="date"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue