Change the appearance of the attachment view in message details to look like v4

MAILAND-1955
This commit is contained in:
stefanija 2021-06-03 18:00:53 +02:00
parent aae518331f
commit 66a61eefc7
18 changed files with 284 additions and 357 deletions

View File

@ -31,7 +31,6 @@ import android.view.ViewGroup
import android.webkit.WebSettings
import android.webkit.WebView
import android.widget.LinearLayout
import android.widget.ProgressBar
import android.widget.TextView
import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.RecyclerView
@ -46,8 +45,8 @@ import ch.protonmail.android.ui.view.LabelChipUiModel
import ch.protonmail.android.utils.redirectToChrome
import ch.protonmail.android.utils.ui.ExpandableRecyclerAdapter
import ch.protonmail.android.views.PMWebViewClient
import ch.protonmail.android.views.messageDetails.AttachmentsView
import ch.protonmail.android.views.messageDetails.LoadContentButton
import ch.protonmail.android.views.messageDetails.MessageDetailsAttachmentsView
import ch.protonmail.android.views.messageDetails.MessageDetailsExpirationInfoView
import ch.protonmail.android.views.messageDetails.MessageDetailsHeaderView
import kotlinx.android.synthetic.main.layout_message_details.view.*
@ -73,8 +72,7 @@ class MessageDetailsAdapter(
var containerDisplayImages = LoadContentButton(context)
var loadEmbeddedImagesContainer = LoadContentButton(context)
var embeddedImagesDownloadProgress = ProgressBar(context)
var attachmentsView = AttachmentsView(context)
var attachmentsView = MessageDetailsAttachmentsView(context)
var attachmentsViewDivider = View(context)
var expirationInfoView = MessageDetailsExpirationInfoView(context)
var messageDetailsView = View(context)
@ -301,10 +299,6 @@ class MessageDetailsAdapter(
containerDisplayImages.visibility = visibility
}
fun displayEmbeddedImagesDownloadProgress(visibility: Int) {
embeddedImagesDownloadProgress.visibility = visibility
}
fun displayLoadEmbeddedImagesContainer(visibility: Int) {
loadEmbeddedImagesContainer.visibility = visibility
}
@ -382,5 +376,4 @@ class MessageDetailsAdapter(
else -> throw IllegalArgumentException("Unknown spam score.")
}
}
}

View File

@ -30,20 +30,20 @@ import ch.protonmail.android.views.messageDetails.AttachmentDetailView
class MessageDetailsAttachmentListAdapter(
context: Context,
private val downloadListener: (String) -> Unit
) : ArrayAdapter<Attachment>(context, R.layout.view_attachment_detail) {
) : ArrayAdapter<Attachment>(context, R.layout.layout_message_details_attachments_details) {
private val downloadingIds = mutableSetOf<String>()
private var pgpEncrypted: Boolean = false
@DrawableRes
private fun String?.getIconRes(): Int {
return when (this) {
"image/jpeg", "image/pjpeg" -> R.drawable.mail_attachment_jpeg
"image/png" -> R.drawable.mail_attachment_png
"application/zip", "application/x-compressed", "application/x-zip-compressed", "multipart/x-zip" -> R.drawable.mail_attachment_zip
"text/plain" -> R.drawable.mail_attachment_txt
"application/pdf" -> R.drawable.mail_attachment_pdf
"application/msword" -> R.drawable.mail_attachment_doc
else -> R.drawable.mail_attachment_file
"image/jpeg", "image/pjpeg", "image/png" -> R.drawable.ic_file_image_variants
"application/zip", "application/x-compressed", "application/x-zip-compressed", "multipart/x-zip" ->
R.drawable.ic_file_rar_zip_variants
"text/plain" -> R.drawable.ic_file_attachment_variants // currently no icon for plain text files
"application/pdf" -> R.drawable.ic_file_pdf_variants
"application/msword" -> R.drawable.ic_file_word_variants
else -> R.drawable.ic_file_attachment_variants
}
}

View File

@ -27,7 +27,6 @@ import android.content.DialogInterface
import android.content.Intent
import android.graphics.Color
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.os.Looper
@ -81,8 +80,6 @@ import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.snackbar.Snackbar
import com.squareup.otto.Subscribe
import dagger.hilt.android.AndroidEntryPoint
import io.sentry.Sentry
import io.sentry.event.EventBuilder
import kotlinx.android.synthetic.main.activity_message_details.*
import kotlinx.android.synthetic.main.layout_message_details_activity_toolbar.*
import kotlinx.coroutines.flow.launchIn
@ -93,7 +90,6 @@ import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicReference
import kotlin.math.abs
private const val TITLE_ANIMATION_THRESHOLD = 0.9
private const val TITLE_ANIMATION_DURATION = 200L
private const val ONE_HUNDRED_PERCENT = 1.0
@ -263,7 +259,6 @@ internal class MessageDetailsActivity : BaseStoragePermissionActivity() {
override fun onStop() {
super.onStop()
mApp.bus.unregister(viewModel)
stopEmbeddedImagesTask()
mApp.bus.unregister(this)
}
@ -277,10 +272,6 @@ internal class MessageDetailsActivity : BaseStoragePermissionActivity() {
screenShotPreventerView.visibility = View.GONE
}
private fun stopEmbeddedImagesTask() {
messageExpandableAdapter.displayEmbeddedImagesDownloadProgress(View.GONE)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
android.R.id.home -> {
@ -416,7 +407,6 @@ internal class MessageDetailsActivity : BaseStoragePermissionActivity() {
}
override fun onBackPressed() {
stopEmbeddedImagesTask()
saveLastInteraction()
finish()
}
@ -428,10 +418,8 @@ internal class MessageDetailsActivity : BaseStoragePermissionActivity() {
when (event.status) {
Status.SUCCESS -> {
messageExpandableAdapter.displayLoadEmbeddedImagesContainer(View.GONE)
messageExpandableAdapter.displayEmbeddedImagesDownloadProgress(View.VISIBLE)
viewModel.downloadEmbeddedImagesResult.observe(this) { content ->
Timber.v("downloadEmbeddedImagesResult content size: ${content.length}")
messageExpandableAdapter.displayEmbeddedImagesDownloadProgress(View.GONE)
if (content.isNullOrEmpty()) {
return@observe
}
@ -442,17 +430,14 @@ internal class MessageDetailsActivity : BaseStoragePermissionActivity() {
}
Status.NO_NETWORK -> {
messageExpandableAdapter.displayLoadEmbeddedImagesContainer(View.VISIBLE)
messageExpandableAdapter.displayEmbeddedImagesDownloadProgress(View.GONE)
showToast(R.string.load_embedded_images_failed_no_network)
}
Status.FAILED -> {
messageExpandableAdapter.displayLoadEmbeddedImagesContainer(View.VISIBLE)
messageExpandableAdapter.displayEmbeddedImagesDownloadProgress(View.GONE)
showToast(R.string.load_embedded_images_failed)
}
Status.STARTED -> {
messageExpandableAdapter.displayLoadEmbeddedImagesContainer(View.GONE)
messageExpandableAdapter.displayEmbeddedImagesDownloadProgress(View.VISIBLE)
viewModel.hasEmbeddedImages = false
}
Status.UNAUTHORIZED -> {
@ -616,12 +601,10 @@ internal class MessageDetailsActivity : BaseStoragePermissionActivity() {
private fun displayAttachmentInfo(attachments: List<Attachment>) {
val attachmentsCount = attachments.size
val totalAttachmentSize = attachments.map { it.fileSize }.sum()
val attachmentsVisibility: Int
messageExpandableAdapter.attachmentsView.setTitle(attachmentsCount, totalAttachmentSize)
attachmentsListAdapter.setList(attachments)
messageExpandableAdapter.attachmentsView.attachmentsAdapter = attachmentsListAdapter
attachmentsVisibility = if (attachmentsCount > 0) View.VISIBLE else View.GONE
messageExpandableAdapter.attachmentsView.bind(attachmentsCount, totalAttachmentSize, attachmentsListAdapter)
val attachmentsVisibility = if (attachmentsCount > 0) View.VISIBLE else View.GONE
messageExpandableAdapter.displayAttachmentsViews(attachmentsVisibility)
}

View File

@ -19,14 +19,13 @@
package ch.protonmail.android.views.messageDetails
import android.content.Context
import android.graphics.Typeface
import android.text.format.Formatter
import android.util.AttributeSet
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import ch.protonmail.android.R
import kotlinx.android.synthetic.main.view_attachment_detail.view.*
import kotlinx.android.synthetic.main.layout_message_details_attachments_details.view.*
class AttachmentDetailView @JvmOverloads constructor(
context: Context,
@ -34,11 +33,7 @@ class AttachmentDetailView @JvmOverloads constructor(
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr) {
init {
inflate(context, R.layout.view_attachment_detail, this)
val typefacePgp = Typeface.createFromAsset(context.assets, "pgp-icons-android.ttf")
attachment_modifier.typeface = typefacePgp
attachment_modifier.setText(R.string.pgp_lock_open)
attachment_modifier.setTextColor(ContextCompat.getColor(context, R.color.icon_warning))
inflate(context, R.layout.layout_message_details_attachments_details, this)
}
fun bind(
@ -48,11 +43,12 @@ class AttachmentDetailView @JvmOverloads constructor(
showWarningIcon: Boolean,
downloading: Boolean
) {
attachment_name.text = fileName
attachment_name_text_view.text = fileName
val formattedSize = Formatter.formatShortFileSize(context, fileSize)
attachment_size.text = context.getString(R.string.attachment_size, formattedSize)
attachment_specific_icon.setImageResource(attachmentSpecificIcon)
attachment_modifier.visibility = if (showWarningIcon) View.VISIBLE else View.GONE
attachment_download_progress.visibility = if (downloading) View.VISIBLE else View.GONE
attachment_size_text_view.text = context.getString(R.string.attachment_size, formattedSize)
attachment_name_text_view.setCompoundDrawablesRelativeWithIntrinsicBounds(attachmentSpecificIcon, 0, 0, 0)
attachment_modifier_text_view.isVisible = showWarningIcon
attachment_download_progress.isVisible = downloading
attachment_download_image_view.visibility = if (downloading) View.INVISIBLE else View.VISIBLE
}
}

View File

@ -1,87 +0,0 @@
/*
* Copyright (c) 2020 Proton Technologies AG
*
* This file is part of ProtonMail.
*
* ProtonMail 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.
*
* ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
*/
package ch.protonmail.android.views.messageDetails
import android.content.Context
import android.database.DataSetObserver
import android.graphics.Typeface
import android.text.format.Formatter
import android.util.AttributeSet
import android.view.View
import android.widget.Adapter
import androidx.constraintlayout.widget.ConstraintLayout
import ch.protonmail.android.R
import kotlinx.android.synthetic.main.view_attachments_message_details.view.*
class AttachmentsView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) :
ConstraintLayout(context, attrs, defStyleAttr) {
init {
inflate(context, R.layout.view_attachments_message_details, this)
val typeface = Typeface.createFromAsset(context.assets, "protonmail-mobile-icons.ttf")
attachment_title_icon.typeface = typeface
setOnClickListener {
expanded = !expanded
}
}
var expanded = false
set(value) {
attachment_detail_list.visibility = if (value) View.VISIBLE else View.GONE
attachments_toggle.setImageResource(if (value) R.drawable.triangle_up else R.drawable.triangle_down)
field = value
}
var attachmentsAdapter: Adapter? = null
set(value) {
field?.unregisterDataSetObserver(dataSetObserver)
value?.registerDataSetObserver(dataSetObserver)
field = value
dataSetObserver.onChanged()
}
private val dataSetObserver = object : DataSetObserver() {
override fun onChanged() {
attachmentsAdapter?.apply {
attachment_detail_list.removeAllViews()
(0 until count).forEach {
attachment_detail_list.addView(getView(it, null, attachment_detail_list))
}
}
}
override fun onInvalidated() {
attachment_detail_list.removeAllViews()
}
}
fun setTitle(attachmentsCount: Int, sizeOfAttachments: Long) {
val attachmentsText = resources.getQuantityString(
R.plurals.attachments_non_descriptive,
attachmentsCount,
attachmentsCount
)
val sizeText = context.getString(
R.string.attachment_size,
Formatter.formatShortFileSize(context, sizeOfAttachments)
)
attachment_title.text = "$attachmentsText $sizeText"
}
}

View File

@ -19,11 +19,15 @@
package ch.protonmail.android.views.messageDetails
import android.content.Context
import android.database.DataSetObserver
import android.text.format.Formatter
import android.util.AttributeSet
import android.widget.Adapter
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.isVisible
import ch.protonmail.android.R
import kotlinx.android.synthetic.main.layout_message_details_attachments.view.*
import kotlinx.android.synthetic.main.layout_message_details_attachments.view.attachments_list_linear_layout
import me.proton.core.presentation.utils.inflate
/**
@ -38,11 +42,41 @@ class MessageDetailsAttachmentsView @JvmOverloads constructor(
init {
inflate(R.layout.layout_message_details_attachments, true)
setOnClickListener {
// TODO: To be implemented with MAILAND-1545
expanded = !expanded
}
}
fun bind(attachmentsCount: Int, sizeOfAttachments: Long) {
private var expanded = false
set(value) {
attachments_list_linear_layout.isVisible = value
chevron_image_view.setImageResource(if (value) R.drawable.ic_chevron_up else R.drawable.ic_chevron_down)
field = value
}
private var attachmentsAdapter: Adapter? = null
set(value) {
field?.unregisterDataSetObserver(dataSetObserver)
value?.registerDataSetObserver(dataSetObserver)
field = value
dataSetObserver.onChanged()
}
private val dataSetObserver = object : DataSetObserver() {
override fun onChanged() {
attachmentsAdapter?.apply {
attachments_list_linear_layout.removeAllViews()
(0 until count).forEach {
attachments_list_linear_layout.addView(getView(it, null, attachments_list_linear_layout))
}
}
}
override fun onInvalidated() {
attachments_list_linear_layout.removeAllViews()
}
}
fun bind(attachmentsCount: Int, sizeOfAttachments: Long, attachmentsAdapter: Adapter) {
val attachmentsText = resources.getQuantityString(
R.plurals.attachments_number,
attachmentsCount,
@ -52,6 +86,7 @@ class MessageDetailsAttachmentsView @JvmOverloads constructor(
R.string.attachment_size,
Formatter.formatShortFileSize(context, sizeOfAttachments)
)
attachmentsTextView.text = "$attachmentsText $sizeText"
attachments_text_view.text = "$attachmentsText $sizeText"
this.attachmentsAdapter = attachmentsAdapter
}
}

View File

@ -0,0 +1,32 @@
<!--
~ Copyright (c) 2020 Proton Technologies AG
~
~ This file is part of ProtonMail.
~
~ ProtonMail 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.
~
~ ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:pathData="M11.65,5.15L12.35,5.85L8,10.21L3.65,5.85L4.35,5.15L7.5,8.29V1H8.5V8.29L11.65,5.15Z"
android:fillColor="@color/icon_norm"/>
<path
android:pathData="M1,12V15H15V12H1ZM14,13V14H2V13H14Z"
android:fillColor="@color/icon_norm"
android:fillType="evenOdd"/>
</vector>

View File

@ -0,0 +1,17 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group>
<clip-path
android:pathData="M0,0h24v24h-24z"/>
<path
android:pathData="M4,0L20,0A4,4 0,0 1,24 4L24,20A4,4 0,0 1,20 24L4,24A4,4 0,0 1,0 20L0,4A4,4 0,0 1,4 0z"
android:fillColor="#EBEDF3"/>
<path
android:pathData="M16.4166,7.4471C15.0378,6.5592 13.2237,6.7698 12.0848,7.9498L6.8482,13.1865C6.3554,13.665 6.098,14.3361 6.1444,15.0214C6.1981,15.7078 6.5464,16.3374 7.0995,16.7474C7.493,17.0365 7.9686,17.1921 8.4569,17.1915C9.1431,17.1834 9.7989,16.9067 10.2834,16.4206L14.8079,11.8962C15.309,11.348 15.291,10.5027 14.7669,9.9764C14.2428,9.4501 13.3976,9.4284 12.8473,9.9272L10.1282,12.6463C9.9641,12.8104 9.9641,13.0766 10.1282,13.2407C10.2925,13.4051 10.559,13.4049 10.7231,13.2403L13.4338,10.5221C13.6534,10.337 13.9781,10.3509 14.1812,10.5539C14.3842,10.757 14.3981,11.0817 14.213,11.3013L9.6969,15.8258C9.1457,16.3937 8.2722,16.4985 7.6023,16.0771C7.2512,15.8109 7.0317,15.4065 6.9997,14.9671C6.9676,14.5277 7.1261,14.0958 7.4347,13.7814L12.6713,8.5447C13.5272,7.6524 14.8923,7.4844 15.939,8.1426C16.5597,8.5603 16.9621,9.233 17.0366,9.9775C17.0997,10.7131 16.8362,11.4392 16.316,11.9632L12.1864,16.0772C12.0236,16.2394 12.0224,16.5025 12.1837,16.6661C12.3463,16.831 12.612,16.8321 12.7759,16.6685L16.8942,12.5581C17.59,11.8535 17.9386,10.8773 17.8465,9.8913C17.7543,8.9053 17.2309,8.0106 16.4166,7.4471Z"
android:fillColor="#3A3F4A"
android:fillType="evenOdd"/>
</group>
</vector>

View File

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M4,0L20,0A4,4 0,0 1,24 4L24,20A4,4 0,0 1,20 24L4,24A4,4 0,0 1,0 20L0,4A4,4 0,0 1,4 0z"
android:fillColor="#EBEDF3"/>
<path
android:pathData="M14.0376,10.2741L10.383,14.8629C10.383,14.8799 10.3652,14.8799 10.3475,14.8629L8.325,12.3986C8.0944,12.1096 7.6509,12.1096 7.4202,12.3986L4.5107,15.9676C4.2092,16.3245 4.4753,16.8514 4.9543,16.8514H8.7863H11.9797H19.2002C19.6082,16.8514 19.8389,16.3925 19.5905,16.0866L14.9601,10.2741C14.7295,9.9852 14.2682,9.9852 14.0376,10.2741Z"
android:fillColor="#3A3F4A"/>
<path
android:pathData="M10.0991,10.6656C11.1573,10.6656 12.0151,9.8439 12.0151,8.8301C12.0151,7.8164 11.1573,6.9946 10.0991,6.9946C9.0409,6.9946 8.1831,7.8164 8.1831,8.8301C8.1831,9.8439 9.0409,10.6656 10.0991,10.6656Z"
android:fillColor="#3A3F4A"/>
</vector>

View File

@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M4,0L20,0A4,4 0,0 1,24 4L24,20A4,4 0,0 1,20 24L4,24A4,4 0,0 1,0 20L0,4A4,4 0,0 1,4 0z"
android:fillColor="#E04930"/>
<path
android:pathData="M11.9879,5.92C10.6399,5.92 9.7495,7.3489 10.4534,8.5314L11.4378,10.1861L9.2011,14.4273H6.9874C5.971,14.4273 5.12,15.229 5.12,16.2502C5.12,18.1166 7.5969,18.7475 8.574,17.2212L9.7528,15.3873H14.2472L15.4263,17.2217C16.4033,18.748 18.88,18.1166 18.88,16.2502C18.88,15.229 18.0289,14.4273 17.0126,14.4273H14.7975L12.5387,10.185L13.5216,8.5328L13.522,8.5321C14.2282,7.3531 13.3274,5.92 11.9879,5.92ZM12.0111,9.1942L12.6974,8.0406L12.6982,8.0392C12.9925,7.5483 12.6387,6.88 11.9879,6.88C11.3334,6.88 10.9812,7.5414 11.2784,8.0404L11.9627,9.1907L11.9859,9.1468L12.0111,9.1942ZM13.7099,14.4273L11.99,11.1971L10.2864,14.4273L10.3698,14.4273H13.6302L13.7099,14.4273ZM6.08,16.2502C6.08,15.7884 6.4715,15.3873 6.9874,15.3873H8.6116L7.7653,16.7039C7.2704,17.4775 6.08,17.0928 6.08,16.2502ZM15.3884,15.3873L16.2341,16.703L16.2347,16.7039C16.7296,17.4775 17.92,17.0928 17.92,16.2502C17.92,15.7884 17.5284,15.3873 17.0126,15.3873H15.3884Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
</vector>

View File

@ -0,0 +1,24 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M4,0L20,0A4,4 0,0 1,24 4L24,20A4,4 0,0 1,20 24L4,24A4,4 0,0 1,0 20L0,4A4,4 0,0 1,4 0z"
android:fillColor="#EBEDF3"/>
<path
android:pathData="M12,7.6364H9.8182C9.2157,7.6364 8.7273,8.1248 8.7273,8.7273C8.7273,9.3298 9.2157,9.8182 9.8182,9.8182H12V7.6364Z"
android:fillColor="#3A3F4A"/>
<path
android:pathData="M12,3.2727H9.8182C9.2157,3.2727 8.7273,3.7611 8.7273,4.3636C8.7273,4.9661 9.2157,5.4545 9.8182,5.4545H12V3.2727Z"
android:fillColor="#3A3F4A"/>
<path
android:pathData="M14.191,13.0909H9.8641C9.2459,13.0909 8.7308,13.6398 8.7308,14.2985V19.5198C8.7308,20.1784 9.2459,20.7273 9.8641,20.7273H14.1395C14.7576,20.7273 15.2727,20.1784 15.2727,19.5198V14.2985C15.3242,13.5849 14.8091,13.0909 14.191,13.0909ZM14.1818,18.9228C14.1818,19.3071 13.8728,19.6364 13.5122,19.6364H10.4878C10.1273,19.6364 9.8182,19.3071 9.8182,18.9228V17.6604C9.8182,17.2762 10.1273,16.9469 10.4878,16.9469H13.5122C13.8728,16.9469 14.1818,17.2762 14.1818,17.6604V18.9228Z"
android:fillColor="#3A3F4A"/>
<path
android:pathData="M12,9.8182H14.1818C14.7843,9.8182 15.2727,10.3067 15.2727,10.9091C15.2727,11.5116 14.7843,12.0001 14.1818,12.0001H12V9.8182Z"
android:fillColor="#3A3F4A"/>
<path
android:pathData="M12,5.4546H14.1818C14.7843,5.4546 15.2727,5.943 15.2727,6.5455C15.2727,7.148 14.7843,7.6364 14.1818,7.6364H12V5.4546Z"
android:fillColor="#3A3F4A"/>
</vector>

View File

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M4,0L20,0A4,4 0,0 1,24 4L24,20A4,4 0,0 1,20 24L4,24A4,4 0,0 1,0 20L0,4A4,4 0,0 1,4 0z"
android:fillColor="#6296FE"/>
<path
android:pathData="M16.4685,7.2C16.3194,7.2 16.19,7.303 16.1566,7.4484L14.4738,14.7875L12.7113,7.4453C12.6768,7.3014 12.5481,7.2 12.4002,7.2H11.6253C11.4782,7.2 11.35,7.3003 11.3147,7.4432L9.4991,14.7875L7.8428,7.4495C7.8098,7.3036 7.6802,7.2 7.5306,7.2H6.8006C6.5954,7.2 6.4432,7.3905 6.4885,7.5907L8.5183,16.5507C8.5513,16.6964 8.6809,16.8 8.8304,16.8H10.1719C10.3195,16.8 10.4479,16.6991 10.4828,16.5557L12,10.3274L13.4908,16.5545C13.5252,16.6984 13.6539,16.8 13.802,16.8H15.1432C15.2923,16.8 15.4217,16.6969 15.4551,16.5515L17.5102,7.5915C17.5562,7.3911 17.4039,7.2 17.1983,7.2H16.4685Z"
android:fillColor="#ffffff"/>
</vector>

View File

@ -43,8 +43,7 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="@id/headerView" />
<!-- TODO: Replace with MessageDetailsAttachmentsView -->
<ch.protonmail.android.views.messageDetails.AttachmentsView
<ch.protonmail.android.views.messageDetails.MessageDetailsAttachmentsView
android:id="@+id/attachmentsView"
android:layout_width="0dp"
android:layout_height="wrap_content"

View File

@ -23,17 +23,17 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/message_details_banner_height">
android:layout_height="wrap_content">
<TextView
android:id="@+id/attachmentsTextView"
android:id="@+id/attachments_text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="@dimen/message_details_banner_height"
android:layout_marginStart="@dimen/message_details_banner_margin_horizontal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/rightChevronImageView"
app:layout_constraintRight_toLeftOf="@id/chevron_image_view"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@id/attachments_list_linear_layout"
android:textAppearance="@style/Proton.Text.DefaultSmall"
app:drawableStartCompat="@drawable/ic_paper_clip"
android:drawablePadding="@dimen/message_details_banner_drawable_padding"
@ -41,14 +41,25 @@
tools:text="1 Attachment (1.2 MB)" />
<ImageView
android:id="@+id/rightChevronImageView"
android:id="@+id/chevron_image_view"
android:layout_width="@dimen/message_details_banner_small_icon_size"
android:layout_height="@dimen/message_details_banner_small_icon_size"
android:layout_marginEnd="@dimen/message_details_banner_margin_horizontal"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:src="@drawable/ic_chevron_right"
app:layout_constraintBottom_toTopOf="@id/attachments_list_linear_layout"
android:src="@drawable/ic_chevron_down"
app:tint="@color/icon_weak" />
<!-- TODO: Will be removed when the separate screen for attachments is created -->
<LinearLayout
android:id="@+id/attachments_list_linear_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:orientation="vertical"
android:visibility="gone" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2020 Proton Technologies AG
~
~ This file is part of ProtonMail.
~
~ ProtonMail 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.
~
~ ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
-->
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="@dimen/padding_l"
android:paddingVertical="@dimen/padding_m">
<TextView
android:id="@+id/attachment_name_text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/padding_m"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/attachment_size_text_view"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constrainedWidth="true"
app:drawableStartCompat="@drawable/ic_file_image_variants"
android:drawablePadding="@dimen/padding_m"
android:maxLines="1"
android:ellipsize="middle"
style="@style/Proton.Text.DefaultSmall"
tools:text="Attachment.jpg" />
<TextView
android:id="@+id/attachment_modifier_text_view"
android:layout_width="@dimen/message_details_attachment_details_attachment_modifier_width"
android:layout_height="@dimen/message_details_attachment_details_attachment_modifier_height"
app:layout_constraintBottom_toBottomOf="@+id/attachment_name_text_view"
app:layout_constraintStart_toStartOf="@+id/attachment_name_text_view"
android:orientation="horizontal"
android:textSize="18sp"
android:text="@string/pgp_lock_open"
android:textColor="@color/icon_warning" />
<TextView
android:id="@+id/attachment_size_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/padding_m"
app:layout_constraintEnd_toStartOf="@id/attachment_download_image_view"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
style="@style/Proton.Text.DefaultSmall"
tools:text="1.2MB" />
<ImageView
android:id="@+id/attachment_download_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:src="@drawable/ic_download"
android:background="?selectableItemBackgroundBorderless" />
<ProgressBar
android:id="@+id/attachment_download_progress"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="@id/attachment_download_image_view"
app:layout_constraintEnd_toEndOf="@id/attachment_download_image_view"
app:layout_constraintTop_toTopOf="@id/attachment_download_image_view"
app:layout_constraintBottom_toBottomOf="@id/attachment_download_image_view"
android:indeterminate="true"
android:visibility="gone" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,107 +0,0 @@
<!--
Copyright (c) 2020 Proton Technologies AG
This file is part of ProtonMail.
ProtonMail 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.
ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
-->
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="36dp">
<ImageView
android:id="@+id/attachment_specific_icon"
android:layout_width="25dp"
android:layout_height="30dp"
android:layout_margin="4dp"
android:background="@android:color/transparent"
android:textSize="@dimen/abc_text_size_large_material"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="@color/icon_purple"
tools:src="@drawable/mail_attachment_jpeg" />
<TextView
android:id="@+id/attachment_modifier"
android:layout_width="18dp"
android:layout_height="12dp"
android:orientation="horizontal"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="@+id/attachment_specific_icon"
app:layout_constraintEnd_toEndOf="@+id/attachment_specific_icon"
tools:text="M" />
<ProgressBar
android:id="@+id/attachment_download_progress"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:indeterminate="true"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@+id/attachment_specific_icon"
app:layout_constraintStart_toEndOf="@+id/attachment_specific_icon"
app:layout_constraintTop_toTopOf="@+id/attachment_specific_icon"
tools:visibility="visible" />
<TextView
android:id="@+id/attachment_name"
style="@style/AttachmentText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="@+id/attachment_specific_icon"
app:layout_constraintEnd_toStartOf="@+id/attachment_size"
app:layout_constraintStart_toEndOf="@+id/attachment_download_progress"
app:layout_constraintTop_toTopOf="@+id/attachment_specific_icon"
tools:text="Grandma holiday 2005.jpg" />
<TextView
android:id="@+id/attachment_size"
style="@style/AttachmentText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintBottom_toBottomOf="@+id/attachment_name"
app:layout_constraintEnd_toStartOf="@+id/download_button"
app:layout_constraintTop_toTopOf="@+id/attachment_name"
tools:text="(13 MB)" />
<ImageView
android:id="@+id/download_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_margin="8dp"
android:background="?attr/selectableItemBackground"
android:padding="2dp"
android:src="@drawable/mail_download"
app:layout_constraintBottom_toBottomOf="@+id/attachment_size"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/attachment_size" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,101 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2020 Proton Technologies AG
~
~ This file is part of ProtonMail.
~
~ ProtonMail 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.
~
~ ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
-->
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp">
<TextView
android:id="@+id/attachment_title_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:contentDescription="@null"
android:text="@string/attachment_icon"
android:textSize="@dimen/abc_text_size_large_material"
app:layout_constraintBottom_toTopOf="@+id/attachment_detail_list"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="A" />
<ProgressBar
android:id="@+id/embeddedImagesDownloadProgress"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:indeterminate="true"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@+id/attachment_detail_list"
app:layout_constraintStart_toEndOf="@+id/attachment_title_icon"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />
<TextView
android:id="@+id/attachment_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/attachment_detail_list"
app:layout_constraintEnd_toStartOf="@+id/attachments_toggle"
app:layout_constraintStart_toEndOf="@+id/embeddedImagesDownloadProgress"
app:layout_constraintTop_toTopOf="parent"
tools:text="2 Attachments (96 kB)" />
<ImageView
android:id="@+id/attachments_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingLeft="14dp"
android:paddingRight="14dp"
android:src="@drawable/triangle_down"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/attachment_title" />
<LinearLayout
android:id="@+id/attachment_detail_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:divider="@color/white"
android:dividerHeight="@dimen/divider_height"
android:orientation="vertical"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
tools:background="#00F"
tools:layout_height="4dp"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -98,6 +98,9 @@
<dimen name="message_details_banner_drawable_padding">8dp</dimen>
<dimen name="message_details_banner_small_icon_size">16dp</dimen>
<dimen name="message_details_attachment_details_attachment_modifier_width">18dp</dimen>
<dimen name="message_details_attachment_details_attachment_modifier_height">12dp</dimen>
<dimen name="message_details_actions_button_size">40dp</dimen>
<!-- Composer -->