Skip to content

Commit

Permalink
Merge pull request #37 from webex/patch/3.2.1
Browse files Browse the repository at this point in the history
Patch/3.2.1
  • Loading branch information
ankibatr authored Nov 30, 2021
2 parents 5af47a2 + 7ab699e commit 6056183
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 64 deletions.
2 changes: 1 addition & 1 deletion 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.0@aar'
implementation 'com.ciscowebex:androidsdk:3.2.1@aar'
}
```
Expand Down
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 32000
versionName "3.2.0"
versionCode 32100
versionName "3.2.1"

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.2.0@aar'
implementation 'com.ciscowebex:androidsdk:3.2.1@aar'

implementation fileTree(dir: "libs", include: ["*.jar"])
implementation Dependencies.kotlinStdLib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.ciscowebex.androidsdk.auth.PhoneServiceRegistrationFailureReason
import com.ciscowebex.androidsdk.auth.UCLoginServerConnectionStatus
import com.ciscowebex.androidsdk.kitchensink.utils.CallObjectStorage
import com.ciscowebex.androidsdk.calendarMeeting.CalendarMeetingObserver
import com.ciscowebex.androidsdk.kitchensink.messaging.spaces.listeners.SpaceEventListener
import com.ciscowebex.androidsdk.membership.Membership
import com.ciscowebex.androidsdk.membership.MembershipObserver
import com.ciscowebex.androidsdk.message.LocalFile
Expand Down Expand Up @@ -132,6 +133,7 @@ class WebexRepository(val webex: Webex) : WebexUCLoginDelegate {
var _stopShareLiveData: MutableLiveData<Boolean>? = null

var _spaceEventLiveData: MutableLiveData<Pair<SpaceEvent, Any?>>? = null
var spaceEventListener : SpaceEventListener? = null
var _membershipEventLiveData: MutableLiveData<Pair<MembershipEvent, Membership?>>? = null
var _messageEventLiveData: MutableLiveData<Pair<MessageEvent, Any?>>? = null
var _calendarMeetingEventLiveData: MutableLiveData<Pair<CalendarMeetingEvent, Any>>? = null
Expand Down Expand Up @@ -160,7 +162,7 @@ class WebexRepository(val webex: Webex) : WebexUCLoginDelegate {
}

fun clearSpaceData(){
_spaceEventLiveData = null
spaceEventListener = null
}

fun setSpaceObserver() {
Expand All @@ -169,20 +171,20 @@ class WebexRepository(val webex: Webex) : WebexUCLoginDelegate {
Log.d(tag, "onEvent: $event with actorID : ${event.getActorId().orEmpty()}")
when (event) {
is SpaceObserver.SpaceCallStarted -> {
_spaceEventLiveData?.postValue(Pair(SpaceEvent.CallStarted, event.getSpaceId()))
spaceEventListener?.onCallStarted(event.getSpaceId() ?: "")
isSpaceCallStarted = true
spaceCallId = event.getSpaceId()
}
is SpaceObserver.SpaceCallEnded -> {
_spaceEventLiveData?.postValue(Pair(SpaceEvent.CallEnded, event.getSpaceId()))
spaceEventListener?.onCallEnded(event.getSpaceId() ?: "")
isSpaceCallStarted = false
spaceCallId = null
}
is SpaceObserver.SpaceCreated -> {
_spaceEventLiveData?.postValue(Pair(SpaceEvent.Created, event.getSpace()))
event.getSpace()?.let { spaceEventListener?.onCreate(it) }
}
is SpaceObserver.SpaceUpdated -> {
_spaceEventLiveData?.postValue(Pair(SpaceEvent.Updated, event.getSpace()))
event.getSpace()?.let { spaceEventListener?.onUpdate(it) }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class WebexViewModel(val webex: Webex, val repository: WebexRepository) : BaseVi
val _stopShareLiveData = MutableLiveData<Boolean>()
val _setCompositeLayoutLiveData = MutableLiveData<Pair<Boolean, String>>()
val _setRemoteVideoRenderModeLiveData = MutableLiveData<Pair<Boolean, String>>()
val _forceSendingVideoLandscapeLiveData = MutableLiveData<Boolean>()

var callMembershipsLiveData: LiveData<List<CallMembership>> = _callMembershipsLiveData
val muteAllLiveData: LiveData<Boolean> = _muteAllLiveData
Expand All @@ -55,6 +56,7 @@ class WebexViewModel(val webex: Webex, val repository: WebexRepository) : BaseVi
val stopShareLiveData: LiveData<Boolean> = _stopShareLiveData
val setCompositeLayoutLiveData: LiveData<Pair<Boolean, String>> = _setCompositeLayoutLiveData
val setRemoteVideoRenderModeLiveData: LiveData<Pair<Boolean, String>> = _setRemoteVideoRenderModeLiveData
val forceSendingVideoLandscapeLiveData: LiveData<Boolean> = _forceSendingVideoLandscapeLiveData

private val _incomingListenerLiveData = MutableLiveData<Call?>()
val incomingListenerLiveData: LiveData<Call?> = _incomingListenerLiveData
Expand All @@ -78,6 +80,8 @@ class WebexViewModel(val webex: Webex, val repository: WebexRepository) : BaseVi

var isVideoViewsSwapped: Boolean = true

var isSendingVideoForceLandscape: Boolean = false

var callCapability: WebexRepository.CallCap
get() = repository.callCapability
set(value) {
Expand Down Expand Up @@ -705,6 +709,18 @@ class WebexViewModel(val webex: Webex, val repository: WebexRepository) : BaseVi
getCall(callId)?.setVideoRenderViews(Pair(localVideoView, remoteVideoView))
}

fun forceSendingVideoLandscape(callId: String, forceLandscape: Boolean) {
getCall(callId)?.forceSendingVideoLandscape(forceLandscape, CompletionHandler { result ->
if (result.isSuccessful) {
Log.d(tag, "forceSendingVideoLandscape Lambda isSuccessful")
_forceSendingVideoLandscapeLiveData.postValue(true)
} else {
Log.d(tag, "forceSendingVideoLandscape Lambda error: ${result.error?.errorMessage}")
_forceSendingVideoLandscapeLiveData.postValue(false)
}
})
}

fun getSharingRenderView(callId: String): View? {
return getCall(callId)?.getSharingRenderView()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class CallBottomSheetFragment(val receivingVideoClickListener: (Call?) -> Unit,
val scalingModeClickListener: (Call?) -> Unit,
val virtualBackgroundOptionsClickListener: (Call?) -> Unit,
val compositeStreamLayoutClickListener: (Call?) -> Unit,
val swapVideoClickListener: (Call?) -> Unit): BottomSheetDialogFragment() {
val swapVideoClickListener: (Call?) -> Unit,
val forceLandscapeClickListener: (Call?) -> Unit): BottomSheetDialogFragment() {
companion object {
val TAG = "MessageActionBottomSheetFragment"
}
Expand All @@ -27,6 +28,7 @@ class CallBottomSheetFragment(val receivingVideoClickListener: (Call?) -> Unit,
lateinit var scalingModeValue: Call.VideoRenderMode
lateinit var compositeLayoutValue: MediaOption.CompositedVideoLayout
lateinit var streamMode: Phone.VideoStreamMode
var isSendingVideoForceLandscape: Boolean = false

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return BottomSheetCallOptionsBinding.inflate(inflater, container, false).also { binding = it }.apply {
Expand Down Expand Up @@ -138,6 +140,18 @@ class CallBottomSheetFragment(val receivingVideoClickListener: (Call?) -> Unit,
swapVideoClickListener(call)
}

var sendingVideoforceLandscapeText = getString(R.string.sending_video_force_landscape)
sendingVideoforceLandscapeText += if (isSendingVideoForceLandscape) {
" - " + getString(R.string.receiving_on)
} else {
" - " + getString(R.string.receiving_off)
}
sendingVideoforceLandscape.text = sendingVideoforceLandscapeText
sendingVideoforceLandscape.setOnClickListener {
dismiss()
forceLandscapeClickListener(call)
}

bgOptionsBtn.setOnClickListener {
dismiss()
virtualBackgroundOptionsClickListener(call)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,12 @@ class CallControlsFragment : Fragment(), OnClickListener, CallObserverInterface
}
})

webexViewModel.forceSendingVideoLandscapeLiveData.observe(viewLifecycleOwner, Observer { result ->
if (result) {
webexViewModel.isSendingVideoForceLandscape = !webexViewModel.isSendingVideoForceLandscape
}
})

webexViewModel.virtualBgError.observe(viewLifecycleOwner, Observer { error ->
Log.d(tag, error)
requireContext().toast(error)
Expand Down Expand Up @@ -782,7 +788,8 @@ class CallControlsFragment : Fragment(), OnClickListener, CallObserverInterface
{ call -> scalingModeClickListener(call) },
{ call -> virtualBackgroundOptionsClickListener(call) },
{ call -> compositeStreamLayoutClickListener(call) },
{ call -> swapVideoClickListener(call) })
{ call -> swapVideoClickListener(call) },
{ call -> forceLandscapeClickListener(call) })

callingActivity = activity?.intent?.getIntExtra(Constants.Intent.CALLING_ACTIVITY_ID, 0)!!
if (callingActivity == 1) {
Expand Down Expand Up @@ -1690,6 +1697,12 @@ class CallControlsFragment : Fragment(), OnClickListener, CallObserverInterface
}
}

private fun forceLandscapeClickListener(call: Call?) {
Log.d(TAG, "forceLandscapeClickListener isSendingVideoForceLandscape: ${webexViewModel.isSendingVideoForceLandscape}")
val value = !webexViewModel.isSendingVideoForceLandscape
webexViewModel.forceSendingVideoLandscape(webexViewModel.currentCallId.orEmpty(), value)
}

private fun compositeStreamLayoutClickListener(call: Call?) {
Log.d(TAG, "compositeStreamLayoutClickListener getCompositedLayout: ${webexViewModel.getCompositedLayout()}")

Expand Down Expand Up @@ -1743,6 +1756,7 @@ class CallControlsFragment : Fragment(), OnClickListener, CallObserverInterface
callOptionsBottomSheetFragment.scalingModeValue = webexViewModel.scalingMode
callOptionsBottomSheetFragment.compositeLayoutValue = webexViewModel.compositedVideoLayout
callOptionsBottomSheetFragment.streamMode = webexViewModel.streamMode
callOptionsBottomSheetFragment.isSendingVideoForceLandscape = webexViewModel.isSendingVideoForceLandscape
activity?.supportFragmentManager?.let { callOptionsBottomSheetFragment.show(it, CallBottomSheetFragment.TAG) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.ciscowebex.androidsdk.kitchensink.databinding.FragmentSpacesBinding
import com.ciscowebex.androidsdk.kitchensink.messaging.search.MessagingSearchActivity
import com.ciscowebex.androidsdk.kitchensink.messaging.spaces.adapters.SpaceReadStatusClientAdapter
import com.ciscowebex.androidsdk.kitchensink.messaging.spaces.adapters.SpacesClientAdapter
import com.ciscowebex.androidsdk.kitchensink.messaging.spaces.listeners.SpaceEventListener
import com.ciscowebex.androidsdk.kitchensink.messaging.spaces.members.MembershipActivity
import com.ciscowebex.androidsdk.kitchensink.messaging.spaces.members.membersReadStatus.MembershipReadStatusActivity
import com.ciscowebex.androidsdk.kitchensink.person.PersonModel
Expand Down Expand Up @@ -60,55 +61,51 @@ class SpacesFragment : Fragment() {
showAddSpaceDialog()
}

spacesViewModel.getSpaceEvent()?.observe(viewLifecycleOwner, Observer {
when (it.first) {
WebexRepository.SpaceEvent.Updated -> {
if (it.second is Space) {
Log.d(TAG, "Space event ${(it.second as Space).title} is updated")
val space = SpaceModel.convertToSpaceModel(it.second as Space?)
val index = spacesClientAdapter.getPositionById(space.id)
if (!spacesClientAdapter.spaces.isNullOrEmpty() && index != -1) {
spacesClientAdapter.spaces[index] = space
spacesClientAdapter.notifyDataSetChanged()
}
spacesViewModel.setSpaceEventListener(object : SpaceEventListener {
override fun onUpdate(space: Space) {
Log.d(TAG, "SpaceClientImpl(Fragment) Space event ${space.title} is updated")
val spaceModel = SpaceModel.convertToSpaceModel(space)
val index = spacesClientAdapter.getPositionById(spaceModel.id)
if (!spacesClientAdapter.spaces.isNullOrEmpty() && index != -1) {
Log.d(TAG, "SpaceClientImpl(Fragment) Updating space object in list")
spacesClientAdapter.spaces[index] = spaceModel
activity?.runOnUiThread {
spacesClientAdapter.notifyItemChanged(index)
}
}
WebexRepository.SpaceEvent.Created -> {
if (it.second is Space) {
val space = SpaceModel.convertToSpaceModel(it.second as Space?)
spacesClientAdapter.spaces.add(0, space)
spacesClientAdapter.notifyItemInserted(0)
Log.d(TAG, "Space event ${(it.second as Space).title} is created")
}
}

override fun onCreate(space: Space) {
val spaceModel = SpaceModel.convertToSpaceModel(space)
spacesClientAdapter.spaces.add(0, spaceModel)
Log.d(TAG, "Space event ${space.title} is created")
activity?.runOnUiThread {
spacesClientAdapter.notifyItemInserted(0)
}
WebexRepository.SpaceEvent.CallStarted -> {
if (it.second is String?) {
val spaceId = it.second as String?
spaceId?.let {
val index = spacesClientAdapter.getPositionById(it)
if (!spacesClientAdapter.spaces.isNullOrEmpty() && index != -1) {
val space = spacesClientAdapter.spaces[index]
Log.d(TAG, "Space event ${space} is CallStarted")
val inCallSpace = SpaceModel(spaceId, space.title + " " + addOnCallSuffix, space.spaceType, space.isLocked, space.lastActivity, space.created, space.teamId, space.sipAddress)
spacesClientAdapter.spaces[index] = inCallSpace
spacesClientAdapter.notifyItemChanged(index)
}
}
}

override fun onCallStarted(spaceId: String) {
val index = spacesClientAdapter.getPositionById(spaceId)
if (!spacesClientAdapter.spaces.isNullOrEmpty() && index != -1) {
val space = spacesClientAdapter.spaces[index]
Log.d(TAG, "Space event ${space} is CallStarted")
val inCallSpace = SpaceModel(spaceId, space.title + " " + addOnCallSuffix, space.spaceType, space.isLocked, space.lastActivity, space.created, space.teamId, space.sipAddress)
spacesClientAdapter.spaces[index] = inCallSpace
activity?.runOnUiThread {
spacesClientAdapter.notifyItemChanged(index)
}
}
WebexRepository.SpaceEvent.CallEnded -> {
if (it.second is String?) {
val spaceId = it.second as String?
spaceId?.let {
val index = spacesClientAdapter.getPositionById(it)
if (!spacesClientAdapter.spaces.isNullOrEmpty() && index != -1) {
val space = spacesClientAdapter.spaces[index]
Log.d(TAG, "Space event ${space.title} is CallEnded")
val inCallSpace = SpaceModel(spaceId, space.title.removeSuffix(addOnCallSuffix), space.spaceType, space.isLocked, space.lastActivity, space.created, space.teamId, space.sipAddress)
spacesClientAdapter.spaces[index] = inCallSpace
spacesClientAdapter.notifyItemChanged(index)
}
}
}

override fun onCallEnded(spaceId: String) {
val index = spacesClientAdapter.getPositionById(spaceId)
if (!spacesClientAdapter.spaces.isNullOrEmpty() && index != -1) {
val space = spacesClientAdapter.spaces[index]
Log.d(TAG, "Space event ${space.title} is CallEnded")
val inCallSpace = SpaceModel(spaceId, space.title.removeSuffix(addOnCallSuffix), space.spaceType, space.isLocked, space.lastActivity, space.created, space.teamId, space.sipAddress)
spacesClientAdapter.spaces[index] = inCallSpace
activity?.runOnUiThread {
spacesClientAdapter.notifyItemChanged(index)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.ciscowebex.androidsdk.kitchensink.BaseViewModel
import com.ciscowebex.androidsdk.kitchensink.WebexRepository
import com.ciscowebex.androidsdk.kitchensink.messaging.spaces.listeners.SpaceEventListener
import com.ciscowebex.androidsdk.kitchensink.messaging.spaces.members.MembershipModel
import com.ciscowebex.androidsdk.kitchensink.messaging.spaces.members.MembershipRepository
import com.ciscowebex.androidsdk.kitchensink.messaging.teams.TeamsRepository
Expand Down Expand Up @@ -38,14 +39,8 @@ class SpacesViewModel(private val spacesRepo: SpacesRepository,
private val _deleteSpace = MutableLiveData<String>()
val deleteSpace: LiveData<String> = _deleteSpace

private val _spaceEventLiveData = MutableLiveData<Pair<WebexRepository.SpaceEvent, Any?>>()

private val addOnCallSuffix = " (On Call)"

init {
webexRepository._spaceEventLiveData = _spaceEventLiveData
}

override fun onCleared() {
webexRepository.clearSpaceData()
}
Expand All @@ -65,7 +60,9 @@ class SpacesViewModel(private val spacesRepo: SpacesRepository,
}) { _spaces.postValue(spaces.value)}.autoDispose()
}

fun getSpaceEvent() = webexRepository._spaceEventLiveData
fun setSpaceEventListener(listener : SpaceEventListener) {
webexRepository.spaceEventListener = listener
}

fun getSpacesList(maxSpaces: Int) {
spacesRepo.fetchSpacesList(null, maxSpaces).observeOn(AndroidSchedulers.mainThread()).subscribe({ spacesList ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.ciscowebex.androidsdk.kitchensink.messaging.spaces.listeners

import com.ciscowebex.androidsdk.space.Space

interface SpaceEventListener {
fun onUpdate(space: Space)
fun onCreate(space: Space)
fun onCallStarted(spaceId: String)
fun onCallEnded(spaceId: String)
}
Loading

0 comments on commit 6056183

Please sign in to comment.