Updated on 2026-08-14
This commit is contained in:
parent
3f089ec4c1
commit
8a6e1e6fc9
3 changed files with 18 additions and 15 deletions
|
|
@ -19,4 +19,8 @@ fun StringBuilder.appendIfNotNull(value: String?, prefix: String? = null, postfi
|
|||
|
||||
fun String.appendIfNotNull(value: String?, prefix: String? = null, postfix: String? = null): String {
|
||||
return StringBuilder(this).apply { appendIfNotNull(value, prefix, postfix) }.toString()
|
||||
}
|
||||
|
||||
fun StringBuilder.breakLine(count: Int = 1): StringBuilder {
|
||||
return append(List(count) { "\n" }.joinToString(separator = ""))
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.tangem.tap.common.feedback
|
|||
|
||||
import android.content.Context
|
||||
import com.tangem.domain.common.TapWorkarounds
|
||||
import com.tangem.tap.common.extensions.breakLine
|
||||
import com.tangem.wallet.R
|
||||
|
||||
interface FeedbackData {
|
||||
|
|
@ -17,9 +18,9 @@ interface FeedbackData {
|
|||
fun joinTogether(context: Context, infoHolder: AdditionalFeedbackInfo): String {
|
||||
return StringBuilder().apply {
|
||||
append(context.getString(mainMessageResId))
|
||||
appendLine(3)
|
||||
breakLine(3)
|
||||
append(context.getString(getDataCollectionMessageResId()))
|
||||
appendLine()
|
||||
breakLine()
|
||||
append(createOptionalMessage(infoHolder))
|
||||
}.toString()
|
||||
}
|
||||
|
|
@ -31,7 +32,7 @@ class RateCanBeBetterEmail : FeedbackData {
|
|||
|
||||
override fun createOptionalMessage(infoHolder: AdditionalFeedbackInfo): String = FeedbackDataBuilder(infoHolder)
|
||||
.appendCardInfo()
|
||||
.appendLine()
|
||||
.breakLine()
|
||||
.appendPhoneInfo()
|
||||
.build()
|
||||
}
|
||||
|
|
@ -43,7 +44,7 @@ class ScanFailsEmail : FeedbackData {
|
|||
|
||||
override fun joinTogether(context: Context, infoHolder: AdditionalFeedbackInfo): String = StringBuilder().apply {
|
||||
append(context.getString(mainMessageResId))
|
||||
appendLine(4)
|
||||
breakLine(4)
|
||||
append(createOptionalMessage(infoHolder))
|
||||
}.toString()
|
||||
|
||||
|
|
@ -53,7 +54,7 @@ class ScanFailsEmail : FeedbackData {
|
|||
}
|
||||
|
||||
class SendTransactionFailedEmail(
|
||||
val error: String
|
||||
val error: String,
|
||||
) : FeedbackData {
|
||||
|
||||
override val subjectResId: Int = R.string.feedback_subject_tx_failed
|
||||
|
|
@ -63,7 +64,7 @@ class SendTransactionFailedEmail(
|
|||
.appendCardInfo()
|
||||
.appendDelimiter()
|
||||
.appendTxFailedBlockchainInfo(error)
|
||||
.appendLine()
|
||||
.breakLine()
|
||||
.appendPhoneInfo()
|
||||
.build()
|
||||
}
|
||||
|
|
@ -89,7 +90,7 @@ class FeedbackEmail : FeedbackData {
|
|||
override fun createOptionalMessage(infoHolder: AdditionalFeedbackInfo): String = FeedbackDataBuilder(infoHolder)
|
||||
.appendCardInfo()
|
||||
.appendWalletsInfo()
|
||||
.appendLine()
|
||||
.breakLine()
|
||||
.appendPhoneInfo()
|
||||
.build()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tangem.tap.common.feedback
|
||||
|
||||
import com.tangem.tap.common.extensions.breakLine
|
||||
|
||||
class FeedbackDataBuilder(
|
||||
private val infoHolder: AdditionalFeedbackInfo
|
||||
) {
|
||||
|
|
@ -10,8 +12,8 @@ class FeedbackDataBuilder(
|
|||
return this
|
||||
}
|
||||
|
||||
fun appendLine(count: Int = 1): FeedbackDataBuilder {
|
||||
builder.appendLine(count)
|
||||
fun breakLine(count: Int = 1): FeedbackDataBuilder {
|
||||
builder.breakLine(count)
|
||||
return this
|
||||
}
|
||||
|
||||
|
|
@ -34,7 +36,7 @@ class FeedbackDataBuilder(
|
|||
|
||||
infoHolder.tokens[it.blockchain]?.let { tokens ->
|
||||
builder.append("Tokens:")
|
||||
appendLine()
|
||||
breakLine()
|
||||
tokens.forEach { token ->
|
||||
builder.appendKeyValue("Name", token.name)
|
||||
builder.appendKeyValue("ID", token.id ?: "[custom token]")
|
||||
|
|
@ -74,8 +76,4 @@ private fun StringBuilder.appendKeyValue(key: String, value: String): StringBuil
|
|||
return if (value.isNotBlank()) this.append("$key: $value\n") else this
|
||||
}
|
||||
|
||||
private fun StringBuilder.appendDelimiter(): StringBuilder = append("----------\n")
|
||||
|
||||
private fun StringBuilder.appendLine(count: Int = 1): StringBuilder {
|
||||
return append(List(count) { "\n" }.joinToString(separator = ""))
|
||||
}
|
||||
private fun StringBuilder.appendDelimiter(): StringBuilder = append("----------\n")
|
||||
Loading…
Add table
Add a link
Reference in a new issue