Updated on 2026-08-14

This commit is contained in:
Tangem 2021-03-22 09:01:46 +00:00
commit 8e4e318e0c
3 changed files with 23 additions and 16 deletions

View file

@ -1,10 +1,7 @@
package com.tangem.tap.common.extensions
import android.app.Activity
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.content.*
import android.content.res.Resources
import android.graphics.drawable.Drawable
import android.os.Build
@ -77,6 +74,9 @@ fun Context.dpToPixels(dp: Int): Int =
TypedValue.COMPLEX_UNIT_DIP, dp.toFloat(), this.resources.displayMetrics
).toInt()
tailrec fun Context?.getActivity(): Activity? = this as? Activity ?:
(this as? ContextWrapper)?.baseContext?.getActivity()
fun MaterialCardView.setMargins(
marginLeftDp: Int = 16,
marginTopDp: Int = 8,

View file

@ -33,10 +33,8 @@ class FeedbackManager(
}
private fun sendTo(email: String, subject: String, message: String, fileLog: File? = null) {
val intent = Intent(Intent.ACTION_SEND).apply {
data = Uri.parse("mailto:")
type = "text/plain"
putExtra(Intent.EXTRA_EMAIL, arrayOf(email))
val intent = Intent(Intent.ACTION_SENDTO).apply {
data = Uri.parse("mailto:$email")
putExtra(Intent.EXTRA_SUBJECT, subject)
putExtra(Intent.EXTRA_TEXT, message)
fileLog?.let {

View file

@ -11,6 +11,7 @@ import androidx.recyclerview.widget.RecyclerView.ItemDecoration
import com.google.android.play.core.review.ReviewManagerFactory
import com.tangem.tap.common.analytics.AnalyticsEvent
import com.tangem.tap.common.analytics.FirebaseAnalyticsHandler
import com.tangem.tap.common.extensions.getActivity
import com.tangem.tap.common.extensions.getString
import com.tangem.tap.common.extensions.hide
import com.tangem.tap.common.extensions.show
@ -21,6 +22,7 @@ import com.tangem.tap.features.wallet.redux.WalletAction
import com.tangem.tap.store
import com.tangem.wallet.R
import kotlinx.android.synthetic.main.layout_warning.view.*
import timber.log.Timber
class WarningMessagesAdapter : ListAdapter<WarningMessage, WarningMessageVH>(DiffUtilCallback) {
@ -91,20 +93,27 @@ class WarningMessageVH(val view: View) : RecyclerView.ViewHolder(view) {
store.dispatch(GlobalAction.SendFeedback(RateCanBeBetterEmail()))
}
view.btn_really_cool.setOnClickListener {
val activity = view.context.getActivity() ?: return@setOnClickListener
FirebaseAnalyticsHandler.triggerEvent(AnalyticsEvent.APP_RATING_POSITIVE)
store.dispatch(WalletAction.Warnings.AppRating.SetNeverToShow)
val context = view.context
val reviewManager = ReviewManagerFactory.create(context)
val flow = reviewManager.requestReviewFlow()
flow.addOnCompleteListener {
val reviewManager = ReviewManagerFactory.create(activity)
val task = reviewManager.requestReviewFlow()
task.addOnCompleteListener {
if (it.isSuccessful) {
// val info = it.result
// Toast.makeText(context, "success", Toast.LENGTH_SHORT).show()
val reviewFlow = reviewManager.launchReviewFlow(activity, it.result)
reviewFlow.addOnCompleteListener {
if (it.isSuccessful) {
// send review was succeed
} else {
// send fails
}
}
} else {
// Toast.makeText(context, "fail", Toast.LENGTH_SHORT).show()
Timber.e(task.exception)
}
}.addOnFailureListener {
// Toast.makeText(context, "failure", Toast.LENGTH_SHORT).show()
Timber.e(it)
}
store.dispatch(GlobalAction.HideWarningMessage(warning))
}