Skip to content

Commit

Permalink
Merge pull request #39 from webex/3.4.0-GA
Browse files Browse the repository at this point in the history
3.4.0 release
  • Loading branch information
knamoach authored Apr 19, 2022
2 parents b643bfa + 3a52d21 commit eb691a4
Show file tree
Hide file tree
Showing 23 changed files with 229 additions and 77 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ This demo support Android device with **Android 7.0** or later
```
dependencies {
implementation 'com.ciscowebex:androidsdk:3.2.1@aar'
implementation 'com.ciscowebex:androidsdk:3.4.0@aar'
}
```
Expand All @@ -84,4 +84,4 @@ For example see [README](https://github.com/webex/webex-android-sdk/blob/master/
CLIENT_SECRET=""
SCOPE=""
REDIRECT_URI=""
```
```
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ android {
applicationId "com.cisco.sdk_android"
minSdkVersion Versions.minSdk
targetSdkVersion Versions.targetSdk
versionCode 33000
versionName "3.3.0"
versionCode 34000
versionName "3.4.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField "String", "CLIENT_ID", "${CLIENT_ID}"
Expand Down Expand Up @@ -62,7 +62,7 @@ android {
}

dependencies {
implementation 'com.ciscowebex:androidsdk:3.3.0@aar'
implementation 'com.ciscowebex:androidsdk:3.4.0@aar'

implementation fileTree(dir: "libs", include: ["*.jar"])
implementation Dependencies.kotlinStdLib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ class WebexViewModel(val webex: Webex, val repository: WebexRepository) : BaseVi
override fun onPhotoCaptured(imageData: ByteArray?) {
callObserverInterface?.onPhotoCaptured(imageData)
}

override fun onMediaQualityInfoChanged(mediaQualityInfo: Call.MediaQualityInfo) {
callObserverInterface?.onMediaQualityInfoChanged(mediaQualityInfo)
}
})
}

Expand Down Expand Up @@ -718,10 +722,14 @@ class WebexViewModel(val webex: Webex, val repository: WebexRepository) : BaseVi
return getCall(callId)?.getVideoRenderViews() ?: Pair(null, null)
}

fun setVideoRenderViews(callId: String, localVideoView: View, remoteVideoView: View) {
fun setVideoRenderViews(callId: String, localVideoView: View?, remoteVideoView: View?) {
getCall(callId)?.setVideoRenderViews(Pair(localVideoView, remoteVideoView))
}

fun setVideoRenderViews(callId: String) {
getCall(callId)?.setVideoRenderViews(null)
}

fun forceSendingVideoLandscape(callId: String, forceLandscape: Boolean) {
getCall(callId)?.forceSendingVideoLandscape(forceLandscape, CompletionHandler { result ->
if (result.isSuccessful) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ class CallControlsFragment : Fragment(), OnClickListener, CallObserverInterface
private var callerId: String = ""
var bottomSheetFragment: BackgroundOptionsBottomSheetFragment? = null

enum class NetworkStatus {
PoorUplink,
PoorDownlink,
Good,
NoNetwork
}

var currentNetworkStatus = NetworkStatus.Good

enum class ShareButtonState {
OFF,
ON,
Expand Down Expand Up @@ -268,7 +277,14 @@ class CallControlsFragment : Fragment(), OnClickListener, CallObserverInterface
*/
onCallTerminated(call?.getCallId().orEmpty())
} else {
onCallDisconnected(call)
/*
* Below line takes care of ending the call if it is scheduled call and local leaves or ends the meeting
* This fixes white screen issue when call is started from calendar meeting fragment
*/
if (!isIncomingActivity) {
onCallTerminated(call?.getCallId().orEmpty())
} else
onCallDisconnected(call)
}
}
}
Expand Down Expand Up @@ -420,6 +436,11 @@ class CallControlsFragment : Fragment(), OnClickListener, CallObserverInterface
}
}

override fun onMediaQualityInfoChanged(mediaQualityInfo: Call.MediaQualityInfo) {
Log.d(TAG, "CallObserver mediaQualityInfo changed : ${mediaQualityInfo.name}")
updateNetworkStatusChange(mediaQualityInfo)
}

@SuppressLint("NotifyDataSetChanged")
private fun observerCallLiveData() {

Expand Down Expand Up @@ -882,7 +903,8 @@ class CallControlsFragment : Fragment(), OnClickListener, CallObserverInterface
binding.ibMoreOption.setOnClickListener(this)

initAddedCallControls()

binding.ivNetworkSignal.setOnClickListener(this)
binding.ivNetworkSignal.visibility = View.GONE
}

override fun onClick(v: View?) {
Expand Down Expand Up @@ -944,6 +966,10 @@ class CallControlsFragment : Fragment(), OnClickListener, CallObserverInterface
showBottomSheet(webexViewModel.getCall(it))
}
}
binding.ivNetworkSignal -> {
val text = "Network Status : ${currentNetworkStatus.name}"
Toast.makeText(requireContext(), text, Toast.LENGTH_SHORT).show()
}
else -> {
}
}
Expand Down Expand Up @@ -1213,6 +1239,7 @@ class CallControlsFragment : Fragment(), OnClickListener, CallObserverInterface

val layout = webexViewModel.getCompositedLayout()
Log.d(TAG, "onCallConnected getCompositedLayout: $layout")
binding.ivNetworkSignal.visibility = View.VISIBLE
webexViewModel.setCompositedLayout(layout)
webexViewModel.setRemoteVideoRenderMode(callId, webexViewModel.scalingMode)

Expand Down Expand Up @@ -1943,6 +1970,29 @@ class CallControlsFragment : Fragment(), OnClickListener, CallObserverInterface
activity?.supportFragmentManager?.let { cameraOptionsBottomSheetFragment.show(it, CameraOptionsBottomSheetFragment.TAG) }
}

private fun updateNetworkStatusChange(mediaQualityInfo: Call.MediaQualityInfo) {
when (mediaQualityInfo) {
Call.MediaQualityInfo.NetworkLost -> {
binding.ivNetworkSignal.setImageResource(R.drawable.ic_no_network)
currentNetworkStatus = NetworkStatus.NoNetwork
}
Call.MediaQualityInfo.Good -> {
binding.ivNetworkSignal.setImageResource(R.drawable.ic_good_network)
currentNetworkStatus = NetworkStatus.Good
}
Call.MediaQualityInfo.PoorUplink -> {
binding.ivNetworkSignal.setImageResource(R.drawable.ic_poor_network)
currentNetworkStatus = NetworkStatus.PoorUplink
}
Call.MediaQualityInfo.PoorDownlink -> {
binding.ivNetworkSignal.setImageResource(R.drawable.ic_poor_network)
currentNetworkStatus = NetworkStatus.PoorDownlink
}
Call.MediaQualityInfo.HighCpuUsage -> showDialogWithMessage(requireContext(), R.string.warning, getString(R.string.high_cpu_usage))
Call.MediaQualityInfo.DeviceLimitation -> showDialogWithMessage(requireContext(), R.string.warning, getString(R.string.device_limitation))
}
}

class IncomingInfoAdapter(private val incomingCallEvent: (Call?) -> Unit, private val IncomingCallPickEvent: (Call?) -> Unit, private val incomingCallCancelEvent: (Call?) -> Unit) : RecyclerView.Adapter<IncomingInfoViewHolder>() {
var info: MutableList<IncomingCallInfoModel> = mutableListOf()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ interface CallObserverInterface {
fun onScheduleChanged(call: Call?) {}
fun onCpuHitThreshold() {}
fun onPhotoCaptured(imageData: ByteArray?) {}
fun onMediaQualityInfoChanged(mediaQualityInfo: Call.MediaQualityInfo)
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class KitchenSinkFCMService : FirebaseMessagingService() {
val size = it.data?.size ?: 0
if (size > 0) {
val message = it.data?.get(size - 1)
Log.d(TAG, "last message: ${message?.getTextAsObject()?.getMarkdown()}")
Log.d(TAG, "last message: ${message?.getText()}")

Log.d(TAG, "Fetching person details")
repository.getPerson(Base64Utils.decodeString(notificationData?.data?.personId), CompletionHandler { personResult ->
Expand Down Expand Up @@ -217,7 +217,7 @@ class KitchenSinkFCMService : FirebaseMessagingService() {
.setContentIntent(pendingIntent)
.setStyle(
NotificationCompat.BigTextStyle()
.bigText(Html.fromHtml(message?.getTextAsObject()?.getMarkdown().orEmpty(), Html.FROM_HTML_MODE_LEGACY))
.bigText(Html.fromHtml(message?.getText().orEmpty(), Html.FROM_HTML_MODE_LEGACY))
)
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class MessageComposerActivity : AppCompatActivity() {

enum class StyleType {
PLAIN_TEXT,
MARKDOWN_TEXT
MARKDOWN_TEXT,
HTML_TEXT
}

fun getIntent(context: Context, type: ComposerType, id: String, replyParentMessage: ReplyMessageModel?, messageId: String? = null): Intent {
Expand Down Expand Up @@ -118,6 +119,9 @@ class MessageComposerActivity : AppCompatActivity() {
R.id.markdownRadioButton -> {
styleType = StyleType.MARKDOWN_TEXT
}
R.id.htmlRadioButton -> {
styleType = StyleType.HTML_TEXT
}
}
}

Expand Down Expand Up @@ -261,14 +265,20 @@ class MessageComposerActivity : AppCompatActivity() {
}
}

private fun buildMessageText(message: String) : Message.Text{
return when(styleType){
StyleType.HTML_TEXT -> Message.Text.html(message)
StyleType.MARKDOWN_TEXT -> Message.Text.markdown(message)
else -> {
Message.Text.plain(message)
}
}
}

private fun editMessage(messageId: String) {
val str = binding.message.text.toString()
val messageContent = binding.message.getMessageContent()
val text: Message.Text = if (styleType == StyleType.PLAIN_TEXT) {
Message.Text.plain(str)
} else {
Message.Text.markdown(str, null, null)
}
val text: Message.Text = buildMessageText(str);

messageComposerViewModel.editMessage(messageId, text, messageContent.messageInputMentions)
}
Expand All @@ -283,11 +293,11 @@ class MessageComposerActivity : AppCompatActivity() {
messageData = message
val msg = message.getTextAsObject()

msg.getMarkdown()?.let {
messageBodyTextView.text = Html.fromHtml(msg.getMarkdown(), Html.FROM_HTML_MODE_LEGACY)
msg.getHtml()?.let {
messageBodyTextView.text = Html.fromHtml(msg.getHtml(), Html.FROM_HTML_MODE_LEGACY)
} ?: run {
msg.getPlain()?.let {
messageBodyTextView.text = Html.fromHtml(msg.getPlain(), Html.FROM_HTML_MODE_LEGACY)
messageBodyTextView.text = msg.getPlain()
}
}
builder.setView(this.root)
Expand All @@ -302,33 +312,27 @@ class MessageComposerActivity : AppCompatActivity() {
private fun postPersonByEmail(email: String, files: ArrayList<LocalFile>?) {
val emailAddress = EmailAddress.fromString(email)
emailAddress?.let {
messageComposerViewModel.postToPerson(emailAddress, binding.message.text.toString(), styleType == StyleType.PLAIN_TEXT, files)
val text: Message.Text = buildMessageText(binding.message.text.toString());
messageComposerViewModel.postToPerson(emailAddress, text, files)
showProgress()
} ?: run {
showDialogWithMessage(this@MessageComposerActivity, R.string.post_message_error, getString(R.string.post_message_email_empty))
}
}

private fun postPersonById(personId: String, files: ArrayList<LocalFile>?) {
messageComposerViewModel.postToPerson(personId, binding.message.text.toString(), styleType == StyleType.PLAIN_TEXT, files)
val text: Message.Text = buildMessageText(binding.message.text.toString());
messageComposerViewModel.postToPerson(personId, text, files)
showProgress()
}

private fun postToSpace(spaceId: String, files: ArrayList<LocalFile>?) {
val messageContent = binding.message.getMessageContent()

var progress = true

val text: Message.Text = buildMessageText(binding.message.text.toString());
replyParentMessage?.let { replyMessage ->
val str = binding.message.text.toString()

val text: Message.Text? = if (styleType == StyleType.PLAIN_TEXT) {
Message.Text.plain(str)
} else {
Message.Text.markdown(str, null, null)
}

text?.let { msgTxt ->
text.let { msgTxt ->
val draft = Message.draft(msgTxt)

messageContent.messageInputMentions?.let { mentionsArray ->
Expand All @@ -346,12 +350,9 @@ class MessageComposerActivity : AppCompatActivity() {
draft.setParent(replyMessage.getMessage())

messageComposerViewModel.postMessageDraft(spaceId, draft)
} ?: run {
progress = false
showDialogWithMessage(this@MessageComposerActivity, R.string.post_message_error, getString(R.string.post_message_invalid_message))
}
} ?: run {
messageComposerViewModel.postToSpace(spaceId, binding.message.text.toString(), styleType == StyleType.PLAIN_TEXT, messageContent.messageInputMentions, files)
messageComposerViewModel.postToSpace(spaceId, text, messageContent.messageInputMentions, files)
}

if (progress) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@ import io.reactivex.Single

open class MessageComposerRepository(private val webex: Webex) {

fun postToSpace(spaceId: String, message: String, plainText: Boolean, mentions: ArrayList<Mention>?, files: ArrayList<LocalFile>?): Observable<Message> {
fun postToSpace(spaceId: String, message: Message.Text, mentions: ArrayList<Mention>?, files: ArrayList<LocalFile>?): Observable<Message> {
return Single.create<Message> { emitter ->
val text: Message.Text? = if (plainText) {
Message.Text.plain(message)
} else {
Message.Text.markdown(message, null, null)
}
webex.messages.postToSpace(spaceId, text, mentions, files, CompletionHandler { result ->
webex.messages.postToSpace(spaceId, message, mentions, files, CompletionHandler { result ->
if (result.isSuccessful) {
emitter.onSuccess(result.data!!)
} else {
Expand All @@ -29,14 +24,9 @@ open class MessageComposerRepository(private val webex: Webex) {
}.toObservable()
}

fun postToPerson(email: EmailAddress, message: String, plainText: Boolean, files: ArrayList<LocalFile>?): Observable<Message> {
fun postToPerson(email: EmailAddress, message: Message.Text, files: ArrayList<LocalFile>?): Observable<Message> {
return Single.create<Message> { emitter ->
val text: Message.Text? = if (plainText) {
Message.Text.plain(message)
} else {
Message.Text.markdown(message, null, null)
}
webex.messages.postToPerson(email, text, files, CompletionHandler { result ->
webex.messages.postToPerson(email, message, files, CompletionHandler { result ->
if (result.isSuccessful) {
emitter.onSuccess(result.data!!)
} else {
Expand All @@ -46,14 +36,9 @@ open class MessageComposerRepository(private val webex: Webex) {
}.toObservable()
}

fun postToPerson(id: String, message: String, plainText: Boolean, files: ArrayList<LocalFile>?): Observable<Message> {
fun postToPerson(id: String, message: Message.Text, files: ArrayList<LocalFile>?): Observable<Message> {
return Single.create<Message> { emitter ->
val text: Message.Text? = if (plainText) {
Message.Text.plain(message)
} else {
Message.Text.markdown(message, null, null)
}
webex.messages.postToPerson(id, text, files, CompletionHandler { result ->
webex.messages.postToPerson(id, message, files, CompletionHandler { result ->
if (result.isSuccessful) {
emitter.onSuccess(result.data!!)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ class MessageComposerViewModel(private val composerRepo: MessageComposerReposito

val labelAll = "All"

fun postToSpace(spaceId: String, message: String, plainText: Boolean, mentions: ArrayList<Mention>?, files: ArrayList<LocalFile>? = null) {
composerRepo.postToSpace(spaceId, message, plainText, mentions, files).observeOn(AndroidSchedulers.mainThread()).subscribe({ result ->
fun postToSpace(spaceId: String, message: Message.Text, mentions: ArrayList<Mention>?, files: ArrayList<LocalFile>? = null) {
composerRepo.postToSpace(spaceId, message, mentions, files).observeOn(AndroidSchedulers.mainThread()).subscribe({ result ->
_postMessages.postValue(result)
}, { error -> _postMessageError.postValue(error.message) }).autoDispose()
}

fun postToPerson(email: EmailAddress, message: String, plainText: Boolean, files: ArrayList<LocalFile>? = null) {
composerRepo.postToPerson(email, message, plainText, files).observeOn(AndroidSchedulers.mainThread()).subscribe({ result ->
fun postToPerson(email: EmailAddress, message: Message.Text, files: ArrayList<LocalFile>? = null) {
composerRepo.postToPerson(email, message, files).observeOn(AndroidSchedulers.mainThread()).subscribe({ result ->
_postMessages.postValue(result)
}, { error -> _postMessageError.postValue(error.message) }).autoDispose()
}

fun postToPerson(id: String, message: String, plainText: Boolean, files: ArrayList<LocalFile>? = null) {
composerRepo.postToPerson(id, message, plainText, files).observeOn(AndroidSchedulers.mainThread()).subscribe({ result ->
fun postToPerson(id: String, message: Message.Text, files: ArrayList<LocalFile>? = null) {
composerRepo.postToPerson(id, message, files).observeOn(AndroidSchedulers.mainThread()).subscribe({ result ->
Log.d(tag, "postToPersonID result: $result")
_postMessages.postValue(result)
}, { error -> _postMessageError.postValue(error.message) }).autoDispose()
Expand Down
Loading

0 comments on commit eb691a4

Please sign in to comment.