in azure-communication-ui/demo-app/src/call-with-chat/java/com/azure/android/communication/ui/callwithchatdemoapp/CallWithChatLauncherActivity.kt [31:154]
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (shouldFinish()) {
finish()
return
}
if (!AppCenter.isConfigured() && !BuildConfig.DEBUG) {
AppCenter.start(
application,
BuildConfig.APP_SECRET,
Analytics::class.java,
Crashes::class.java,
Distribute::class.java
)
}
// Register Memory Viewer with FeatureFlags
conditionallyRegisterDiagnostics(this)
binding = ActivityCallwithchatLauncherBinding.inflate(layoutInflater)
setContentView(binding.root)
val data: Uri? = intent?.data
val deeplinkAcsToken = data?.getQueryParameter("acstoken")
val deeplinkName = data?.getQueryParameter("name")
val deeplinkGroupId = data?.getQueryParameter("groupid")
val deeplinkTeamsUrl = data?.getQueryParameter("teamsurl")
if (savedInstanceState != null) {
if (savedInstanceState.getBoolean(isTokenFunctionOptionSelected)) {
callLauncherViewModel.useTokenFunction()
} else {
callLauncherViewModel.useAcsToken()
}
if (savedInstanceState.getBoolean(isKotlinLauncherOptionSelected)) {
callLauncherViewModel.setKotlinLauncher()
} else {
callLauncherViewModel.setJavaLauncher()
}
}
binding.run {
if (!deeplinkAcsToken.isNullOrEmpty()) {
acsTokenText.setText(deeplinkAcsToken)
} else {
acsTokenText.setText(BuildConfig.ACS_TOKEN)
}
if (!deeplinkName.isNullOrEmpty()) {
userNameText.setText(deeplinkName)
} else {
userNameText.setText(BuildConfig.USER_NAME)
}
if (!deeplinkGroupId.isNullOrEmpty()) {
groupIdOrTeamsMeetingLinkText.setText(deeplinkGroupId)
groupCallRadioButton.isChecked = true
teamsMeetingRadioButton.isChecked = false
} else if (!deeplinkTeamsUrl.isNullOrEmpty()) {
groupIdOrTeamsMeetingLinkText.setText(deeplinkTeamsUrl)
groupCallRadioButton.isChecked = false
teamsMeetingRadioButton.isChecked = true
} else {
groupIdOrTeamsMeetingLinkText.setText(BuildConfig.GROUP_CALL_ID)
}
launchButton.setOnClickListener {
launchButton.isEnabled = false
launch()
}
tokenFunctionRadioButton.setOnClickListener {
if (tokenFunctionRadioButton.isChecked) {
tokenFunctionUrlText.requestFocus()
tokenFunctionUrlText.isEnabled = true
acsTokenText.isEnabled = false
acsCommunicationUserIdText.isEnabled = false
acsTokenRadioButton.isChecked = false
callLauncherViewModel.useTokenFunction()
}
}
acsTokenRadioButton.setOnClickListener {
if (acsTokenRadioButton.isChecked) {
acsTokenText.requestFocus()
acsTokenText.isEnabled = true
acsCommunicationUserIdText.isEnabled = true
tokenFunctionUrlText.isEnabled = false
tokenFunctionRadioButton.isChecked = false
callLauncherViewModel.useAcsToken()
}
}
groupCallRadioButton.setOnClickListener {
if (groupCallRadioButton.isChecked) {
groupIdOrTeamsMeetingLinkText.setText(BuildConfig.GROUP_CALL_ID)
teamsMeetingRadioButton.isChecked = false
chatThreadIdText.isEnabled = true
}
}
teamsMeetingRadioButton.setOnClickListener {
if (teamsMeetingRadioButton.isChecked) {
groupIdOrTeamsMeetingLinkText.setText(BuildConfig.TEAMS_MEETING_LINK)
groupCallRadioButton.isChecked = false
chatThreadIdText.isEnabled = false
}
}
javaButton.setOnClickListener {
callLauncherViewModel.setJavaLauncher()
}
kotlinButton.setOnClickListener {
callLauncherViewModel.setKotlinLauncher()
}
if (!BuildConfig.DEBUG) {
versionText.text = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})"
}
}
callLauncherViewModel.fetchResult.observe(this) {
processResult(it)
}
}