Updated on 2026-08-14
This commit is contained in:
commit
38fab82d81
8 changed files with 49 additions and 45 deletions
|
|
@ -144,7 +144,7 @@ dependencies {
|
|||
implementation("com.squareup.okhttp3:logging-interceptor")
|
||||
|
||||
// Support
|
||||
implementation("com.zendesk:support:5.0.9")
|
||||
implementation("com.zendesk:chat:3.3.5")
|
||||
implementation("com.zendesk:messaging:5.2.4")
|
||||
|
||||
//Crypto
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
<activity
|
||||
android:exported="true"
|
||||
android:name="com.tangem.tap.MainActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<intent-filter>
|
||||
|
|
|
|||
|
|
@ -141,4 +141,5 @@ class TapApplication : Application(), ImageLoaderFactory {
|
|||
data class LogConfig(
|
||||
val coil: Boolean = BuildConfig.DEBUG,
|
||||
val storeAction: Boolean = BuildConfig.DEBUG,
|
||||
val zendesk: Boolean = BuildConfig.DEBUG,
|
||||
)
|
||||
|
|
@ -6,18 +6,19 @@ import com.tangem.tap.common.extensions.sendEmail
|
|||
import com.tangem.tap.common.log.TangemLogCollector
|
||||
import com.tangem.tap.common.zendesk.ZendeskConfig
|
||||
import com.tangem.tap.foregroundActivityObserver
|
||||
import com.tangem.tap.logConfig
|
||||
import com.tangem.tap.withForegroundActivity
|
||||
import com.tangem.wallet.R
|
||||
import com.zendesk.logger.Logger
|
||||
import timber.log.Timber
|
||||
import zendesk.chat.Chat
|
||||
import zendesk.chat.ChatConfiguration
|
||||
import zendesk.chat.ChatEngine
|
||||
import zendesk.configurations.Configuration
|
||||
import zendesk.messaging.MessagingActivity
|
||||
import java.io.File
|
||||
import java.io.FileWriter
|
||||
import java.io.StringWriter
|
||||
import timber.log.Timber
|
||||
import zendesk.configurations.Configuration
|
||||
import zendesk.core.AnonymousIdentity
|
||||
import zendesk.core.Zendesk
|
||||
import zendesk.support.Support
|
||||
import zendesk.support.request.RequestConfiguration
|
||||
import zendesk.support.requestlist.RequestListActivity
|
||||
import zendesk.support.requestlist.RequestListConfiguration
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
|
|
@ -30,14 +31,14 @@ class FeedbackManager(
|
|||
context: Context,
|
||||
zendeskConfig: ZendeskConfig,
|
||||
) {
|
||||
Zendesk.INSTANCE.init(
|
||||
/* context = */ context,
|
||||
/* zendeskUrl = */ zendeskConfig.url,
|
||||
/* applicationId = */ zendeskConfig.appId,
|
||||
/* oauthClientId = */ zendeskConfig.clientId,
|
||||
Chat.INSTANCE.init(
|
||||
context,
|
||||
zendeskConfig.accountKey,
|
||||
zendeskConfig.appId
|
||||
)
|
||||
Support.INSTANCE.init(Zendesk.INSTANCE)
|
||||
Zendesk.INSTANCE.setIdentity(AnonymousIdentity())
|
||||
|
||||
// Zendesk logs
|
||||
Logger.setLoggable(logConfig.zendesk)
|
||||
}
|
||||
|
||||
fun sendEmail(feedbackData: FeedbackData, onFail: ((Exception) -> Unit)? = null) {
|
||||
|
|
@ -57,11 +58,8 @@ class FeedbackManager(
|
|||
fun openChat(feedbackData: FeedbackData) {
|
||||
feedbackData.prepare(infoHolder)
|
||||
foregroundActivityObserver.withForegroundActivity { activity ->
|
||||
RequestListActivity.builder()
|
||||
.show(
|
||||
/* context = */ activity,
|
||||
/* configurations = */ buildConfigs(activity, feedbackData)
|
||||
)
|
||||
setChatVisitorNote(activity, feedbackData)
|
||||
showMessagingActivity(activity)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -84,20 +82,30 @@ class FeedbackManager(
|
|||
}
|
||||
}
|
||||
|
||||
private fun buildConfigs(
|
||||
private fun setChatVisitorNote(
|
||||
context: Context,
|
||||
feedbackData: FeedbackData,
|
||||
): List<Configuration> {
|
||||
return listOf(
|
||||
// Request configuration
|
||||
RequestConfiguration.Builder()
|
||||
.withRequestSubject(context.getString(feedbackData.subjectResId))
|
||||
.config(),
|
||||
// Request list configuration
|
||||
RequestListConfiguration.Builder()
|
||||
.withContactUsButtonVisible(true)
|
||||
.config(),
|
||||
)
|
||||
) {
|
||||
Chat.INSTANCE.providers()
|
||||
?.profileProvider()
|
||||
?.setVisitorNote(feedbackData.joinTogether(context, infoHolder))
|
||||
}
|
||||
|
||||
private fun showMessagingActivity(context: Context) {
|
||||
MessagingActivity.builder()
|
||||
.withMultilineResponseOptionsEnabled(false)
|
||||
.withBotLabelStringRes(R.string.chat_bot_name)
|
||||
.withBotAvatarDrawable(R.mipmap.ic_launcher)
|
||||
.withEngines(ChatEngine.engine())
|
||||
.show(context, buildChatConfig())
|
||||
}
|
||||
|
||||
private fun buildChatConfig(): Configuration {
|
||||
return ChatConfiguration.builder()
|
||||
.withOfflineFormEnabled(true)
|
||||
.withAgentAvailabilityEnabled(true)
|
||||
.withPreChatFormEnabled(false)
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun getSupportEmail(): String {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ data class ZendeskConfig(
|
|||
val appId: String,
|
||||
@Json(name = "zendeskClientId")
|
||||
val clientId: String,
|
||||
@Json(name = "zendeskAccountKey")
|
||||
val accountKey: String,
|
||||
@Json(name = "zendeskUrl")
|
||||
val url: String,
|
||||
)
|
||||
|
|
@ -77,4 +77,6 @@
|
|||
<string name="common_yes">Да</string>
|
||||
|
||||
<string name="details_ask_a_question">Задать вопрос</string>
|
||||
|
||||
<string name="chat_bot_name">Tangem Bot</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -78,4 +78,6 @@
|
|||
<string name="common_no">No</string>
|
||||
|
||||
<string name="details_ask_a_question">Ask a question</string>
|
||||
|
||||
<string name="chat_bot_name">Tangem Bot</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -4,15 +4,4 @@
|
|||
<item name="colorPrimary">@color/darkGray6</item>
|
||||
<item name="colorPrimaryDark">@color/darkGray6</item>
|
||||
</style>
|
||||
|
||||
// Contact us FAB style
|
||||
<style name="zs_contact_us_fab">
|
||||
<item name="android:gravity">bottom|end</item>
|
||||
<item name="android:layout_margin">@dimen/zs_fab_margin</item>
|
||||
<item name="android:contentDescription">@string/zs_general_contact_us_button_label_accessibility</item>
|
||||
<item name="android:visibility">gone</item>
|
||||
<item name="backgroundTint">@color/selector_btn_green</item>
|
||||
<item name="srcCompat">@drawable/zs_create_ticket_fab</item>
|
||||
<item name="tint">@color/white</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue