Updated on 2026-08-14
This commit is contained in:
parent
9cb70782cf
commit
a10342f948
10 changed files with 3 additions and 174 deletions
|
|
@ -27,20 +27,12 @@ configurations.all {
|
|||
|
||||
resolutionStrategy {
|
||||
dependencySubstitution {
|
||||
substitute(module("com.facebook.react:react-native"))
|
||||
.using(module("com.facebook.react:react-android:0.72.4"))
|
||||
|
||||
substitute(module("com.facebook.react:hermes-engine"))
|
||||
.using(module("com.facebook.react:hermes-android:0.72.4"))
|
||||
|
||||
substitute(module("org.bouncycastle:bcprov-jdk15on"))
|
||||
.using(module("org.bouncycastle:bcprov-jdk18on:1.73"))
|
||||
}
|
||||
|
||||
force(
|
||||
"org.bouncycastle:bcpkix-jdk15on:1.70",
|
||||
"com.facebook.react:react-android:0.72.4",
|
||||
"com.facebook.react:hermes-android:0.72.4",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -224,10 +216,6 @@ dependencies {
|
|||
implementation(deps.walletConnectCore)
|
||||
implementation(deps.walletConnectWeb3)
|
||||
implementation(deps.prettyLogger)
|
||||
implementation("com.facebook.react:react-android:0.72.4")
|
||||
implementation(deps.sprClient) {
|
||||
exclude(group = "com.github.stephenc.jcip")
|
||||
}
|
||||
|
||||
/** Testing libraries */
|
||||
testImplementation(deps.test.coroutine)
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ import com.tangem.tap.common.analytics.AnalyticsFactory
|
|||
import com.tangem.tap.common.analytics.api.AnalyticsHandlerBuilder
|
||||
import com.tangem.tap.common.analytics.handlers.amplitude.AmplitudeAnalyticsHandler
|
||||
import com.tangem.tap.common.analytics.handlers.firebase.FirebaseAnalyticsHandler
|
||||
import com.tangem.tap.common.chat.ChatManager
|
||||
import com.tangem.tap.common.feedback.AdditionalFeedbackInfo
|
||||
import com.tangem.tap.common.feedback.LegacyFeedbackManager
|
||||
import com.tangem.tap.common.images.createCoilImageLoader
|
||||
|
|
@ -316,7 +315,7 @@ abstract class TangemApplication : Application(), ImageLoaderFactory {
|
|||
|
||||
private fun initWithConfigDependency(config: Config) {
|
||||
initAnalytics(this, config)
|
||||
initFeedbackManager(this, foregroundActivityObserver, store)
|
||||
initFeedbackManager(this, store)
|
||||
}
|
||||
|
||||
private fun initAnalytics(application: Application, config: Config) {
|
||||
|
|
@ -337,11 +336,7 @@ abstract class TangemApplication : Application(), ImageLoaderFactory {
|
|||
// ExceptionHandler.append(blockchainExceptionHandler) TODO: [REDACTED_JIRA]
|
||||
}
|
||||
|
||||
private fun initFeedbackManager(
|
||||
context: Context,
|
||||
foregroundActivityObserver: ForegroundActivityObserver,
|
||||
store: Store<AppState>,
|
||||
) {
|
||||
private fun initFeedbackManager(context: Context, store: Store<AppState>) {
|
||||
fun initAdditionalFeedbackInfo(context: Context): AdditionalFeedbackInfo {
|
||||
return AdditionalFeedbackInfo().apply {
|
||||
appVersion = try {
|
||||
|
|
@ -382,7 +377,6 @@ abstract class TangemApplication : Application(), ImageLoaderFactory {
|
|||
val feedbackManager = LegacyFeedbackManager(
|
||||
infoHolder = additionalFeedbackInfo,
|
||||
logCollector = tangemLogCollector,
|
||||
chatManager = ChatManager(foregroundActivityObserver),
|
||||
feedbackManagerFeatureToggles = feedbackManagerFeatureToggles,
|
||||
getFeedbackEmailUseCase = getFeedbackEmailUseCase,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
package com.tangem.tap.common.chat
|
||||
|
||||
import android.content.Context
|
||||
import com.tangem.datasource.config.models.ChatConfig
|
||||
import com.tangem.datasource.config.models.SprinklrConfig
|
||||
import com.tangem.tap.ForegroundActivityObserver
|
||||
import com.tangem.tap.common.chat.opener.ChatOpener
|
||||
import com.tangem.tap.common.chat.opener.implementation.SprinklrChatOpener
|
||||
import java.io.File
|
||||
|
||||
class ChatManager(private val foregroundActivityObserver: ForegroundActivityObserver) {
|
||||
private val openers = mutableMapOf<ChatConfig, ChatOpener>()
|
||||
|
||||
fun open(config: ChatConfig, createLogsFile: (Context) -> File?, createFeedbackFile: (Context) -> File?) {
|
||||
val opener = openers.getOrPut(config) {
|
||||
when (config) {
|
||||
is SprinklrConfig -> SprinklrChatOpener(config, foregroundActivityObserver)
|
||||
}
|
||||
}
|
||||
|
||||
opener.open(createFeedbackFile, createLogsFile)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
package com.tangem.tap.common.chat.opener
|
||||
|
||||
import android.content.Context
|
||||
import java.io.File
|
||||
|
||||
internal interface ChatOpener {
|
||||
fun open(createFeedbackFile: (Context) -> File?, createLogsFile: (Context) -> File?)
|
||||
}
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
package com.tangem.tap.common.chat.opener.implementation
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.provider.Settings
|
||||
import com.spr.messengerclient.config.SPRMessenger
|
||||
import com.spr.messengerclient.config.bean.SPRMessengerConfig
|
||||
import com.tangem.common.extensions.guard
|
||||
import com.tangem.datasource.config.models.SprinklrConfig
|
||||
import com.tangem.tap.ForegroundActivityObserver
|
||||
import com.tangem.tap.common.chat.opener.ChatOpener
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
import java.util.Locale
|
||||
|
||||
internal class SprinklrChatOpener(
|
||||
private val config: SprinklrConfig,
|
||||
private val foregroundActivityObserver: ForegroundActivityObserver,
|
||||
) : ChatOpener {
|
||||
|
||||
override fun open(createFeedbackFile: (Context) -> File?, createLogsFile: (Context) -> File?) {
|
||||
val messenger = SPRMessenger.shared()
|
||||
|
||||
if (messenger.config == null) {
|
||||
initSprConfig(messenger)
|
||||
}
|
||||
|
||||
messenger.startApplication()
|
||||
}
|
||||
|
||||
private fun initSprConfig(messenger: SPRMessenger) {
|
||||
val application = foregroundActivityObserver.foregroundActivity?.application.guard {
|
||||
Timber.e("The SPR chat cannot be opened because there are no activities in foreground")
|
||||
return
|
||||
}
|
||||
|
||||
messenger.takeOff(application, createSprConfig(application, config))
|
||||
}
|
||||
|
||||
@SuppressLint("HardwareIds")
|
||||
private fun createSprConfig(application: Application, config: SprinklrConfig): SPRMessengerConfig {
|
||||
return SPRMessengerConfig().apply {
|
||||
appId = config.appId
|
||||
appKey = CHAT_APP_KEY
|
||||
deviceId = Settings.Secure.getString(application.contentResolver, Settings.Secure.ANDROID_ID)
|
||||
environment = config.environment
|
||||
skin = CHAT_SKIN
|
||||
locale = Locale.getDefault().language
|
||||
}
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val CHAT_APP_KEY = "com.sprinklr.messenger.release"
|
||||
const val CHAT_SKIN = "MODERN"
|
||||
}
|
||||
}
|
||||
|
|
@ -2,13 +2,11 @@ package com.tangem.tap.common.feedback
|
|||
|
||||
import android.content.Context
|
||||
import com.tangem.core.navigation.email.EmailSender
|
||||
import com.tangem.datasource.config.models.ChatConfig
|
||||
import com.tangem.domain.common.TapWorkarounds
|
||||
import com.tangem.domain.feedback.FeedbackManagerFeatureToggles
|
||||
import com.tangem.domain.feedback.GetFeedbackEmailUseCase
|
||||
import com.tangem.domain.feedback.models.FeedbackEmailType
|
||||
import com.tangem.domain.models.scan.ScanResponse
|
||||
import com.tangem.tap.common.chat.ChatManager
|
||||
import com.tangem.tap.common.extensions.inject
|
||||
import com.tangem.tap.common.extensions.sendEmail
|
||||
import com.tangem.tap.common.log.TangemLogCollector
|
||||
|
|
@ -29,12 +27,10 @@ import java.io.StringWriter
|
|||
class LegacyFeedbackManager(
|
||||
val infoHolder: AdditionalFeedbackInfo,
|
||||
private val logCollector: TangemLogCollector,
|
||||
private val chatManager: ChatManager,
|
||||
private val feedbackManagerFeatureToggles: FeedbackManagerFeatureToggles,
|
||||
private val getFeedbackEmailUseCase: GetFeedbackEmailUseCase,
|
||||
) {
|
||||
|
||||
private var sessionFeedbackFile: File? = null
|
||||
private var sessionLogsFile: File? = null
|
||||
|
||||
fun sendEmail(feedbackData: FeedbackData, scanResponse: ScanResponse?) {
|
||||
|
|
@ -97,43 +93,6 @@ class LegacyFeedbackManager(
|
|||
}
|
||||
}
|
||||
|
||||
fun openChat(config: ChatConfig, feedbackData: FeedbackData) {
|
||||
chatManager.open(
|
||||
config = config,
|
||||
createLogsFile = ::getLogFile,
|
||||
createFeedbackFile = { context -> getFeedbackFile(context, feedbackData) },
|
||||
)
|
||||
}
|
||||
|
||||
private fun getFeedbackFile(context: Context, feedbackData: FeedbackData): File? {
|
||||
return try {
|
||||
if (sessionFeedbackFile != null) {
|
||||
return sessionFeedbackFile
|
||||
}
|
||||
val file = File(context.filesDir, FEEDBACK_FILE)
|
||||
file.delete()
|
||||
file.createNewFile()
|
||||
|
||||
val feedback = feedbackData.run {
|
||||
prepare(infoHolder)
|
||||
joinTogether(context, infoHolder)
|
||||
}
|
||||
val fileWriter = FileWriter(file)
|
||||
fileWriter.write(feedback)
|
||||
fileWriter.close()
|
||||
|
||||
if (file.exists()) {
|
||||
sessionFeedbackFile = file
|
||||
sessionFeedbackFile
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
Timber.e(ex, "Can't create the logs file")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun getLogFile(context: Context): File? {
|
||||
return try {
|
||||
if (sessionLogsFile != null) {
|
||||
|
|
@ -172,7 +131,6 @@ class LegacyFeedbackManager(
|
|||
private companion object {
|
||||
const val DEFAULT_SUPPORT_EMAIL = "support@tangem.com"
|
||||
const val S2C_SUPPORT_EMAIL = "cardsupport@start2coin.com"
|
||||
const val FEEDBACK_FILE = "feedback.txt"
|
||||
const val LOGS_FILE = "logs.txt"
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@ package com.tangem.tap.common.redux.global
|
|||
import com.tangem.common.CompletionResult
|
||||
import com.tangem.core.analytics.models.AnalyticsParam
|
||||
import com.tangem.datasource.config.ConfigManager
|
||||
import com.tangem.datasource.config.models.ChatConfig
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.apptheme.model.AppThemeMode
|
||||
import com.tangem.domain.models.scan.ScanResponse
|
||||
|
|
@ -80,7 +79,6 @@ sealed class GlobalAction : Action {
|
|||
data class SetFeedbackManager(val feedbackManager: LegacyFeedbackManager) : GlobalAction()
|
||||
|
||||
data class SendEmail(val feedbackData: FeedbackData, val scanResponse: ScanResponse?) : GlobalAction()
|
||||
data class OpenChat(val feedbackData: FeedbackData, val chatConfig: ChatConfig? = null) : GlobalAction()
|
||||
|
||||
object ExchangeManager : GlobalAction() {
|
||||
object Init : GlobalAction() {
|
||||
|
|
|
|||
|
|
@ -74,26 +74,6 @@ private fun handleAction(action: Action, appState: () -> AppState?) {
|
|||
scanResponse = action.scanResponse,
|
||||
)
|
||||
}
|
||||
is GlobalAction.OpenChat -> {
|
||||
val globalState = store.state.globalState
|
||||
val feedbackManager = globalState.feedbackManager.guard {
|
||||
store.dispatchDebugErrorNotification("FeedbackManager not initialized")
|
||||
return
|
||||
}
|
||||
val config = globalState.configManager?.config.guard {
|
||||
store.dispatchDebugErrorNotification("Config not initialized")
|
||||
return
|
||||
}
|
||||
|
||||
// if config not set -> try to get it based on a scanResponse.productType
|
||||
val unsafeChatConfig = action.chatConfig ?: config.sprinklr
|
||||
|
||||
val chatConfig = unsafeChatConfig.guard {
|
||||
store.dispatchDebugErrorNotification("The chat config is not initialized")
|
||||
return
|
||||
}
|
||||
feedbackManager.openChat(chatConfig, action.feedbackData)
|
||||
}
|
||||
is GlobalAction.ExchangeManager.Init -> {
|
||||
val appStateSafe = appState() ?: return
|
||||
val config = appStateSafe.globalState.configManager?.config ?: return
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ internal object AttestationFailedDialog {
|
|||
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
|
||||
setTitle(R.string.common_error)
|
||||
setMessage(R.string.issuer_signature_loading_failed)
|
||||
setPositiveButton(R.string.ok) { dialog, _ ->
|
||||
setPositiveButton(R.string.common_ok) { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
setOnDismissListener {
|
||||
|
|
|
|||
|
|
@ -254,7 +254,6 @@ reactive-network = { module = "com.github.pwittchen:reactivenetwork-rx2", versio
|
|||
walletConnectCore = { module = "com.walletconnect:android-core", version.ref = "walletConnectCore" }
|
||||
walletConnectWeb3 = { module = "com.walletconnect:web3wallet", version.ref = "walletConnectWeb3" }
|
||||
prettyLogger = { module = "com.orhanobut:logger", version.ref = "prettyLogger" }
|
||||
sprClient = { module = "com.spr:messengerclient", version.ref = "spr-client" }
|
||||
chucker = { module = "com.github.chuckerteam.chucker:library", version.ref = "chucker" }
|
||||
chuckerStub = { module = "com.github.chuckerteam.chucker:library-no-op", version.ref = "chucker" }
|
||||
mlKit-barcodeScanning = { module = "com.google.mlkit:barcode-scanning", version.ref = "mlKit-barcodeScanning" }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue