From cc5992f7b07b4962445e3bcb9a2ad062fbf55a7a Mon Sep 17 00:00:00 2001 From: Andrei Misiukevich Date: Mon, 31 Aug 2020 18:54:45 +0300 Subject: [PATCH] https://github.com/AndreiMisiukevich/OpenTok-Xamarin.Forms/issues/34 --- .../Service/PlatformOpenTokService.cs | 3 ++- .../Service/PlatformOpenTokService.cs | 3 ++- .../Service/BaseOpenTokService.cs | 10 ++++++++-- Lib/Xamarin.Forms.OpenTok/Service/IOpenTokService.cs | 7 +++++-- OpenTok.nuspec | 2 +- .../Resources/Resource.designer.cs | 3 +++ 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Lib/Xamarin.Forms.OpenTok.Android/Service/PlatformOpenTokService.cs b/Lib/Xamarin.Forms.OpenTok.Android/Service/PlatformOpenTokService.cs index be6d986..23a687e 100644 --- a/Lib/Xamarin.Forms.OpenTok.Android/Service/PlatformOpenTokService.cs +++ b/Lib/Xamarin.Forms.OpenTok.Android/Service/PlatformOpenTokService.cs @@ -33,7 +33,8 @@ public sealed class PlatformOpenTokService : BaseOpenTokService private readonly Collection _subscribers = new Collection(); private PlatformOpenTokService() - { + { + _subscriberStreamIds.CollectionChanged += OnSubscriberStreamIdsCollectionChanged; PropertyChanged += OnPropertyChanged; StreamIdCollection = new ReadOnlyObservableCollection(_subscriberStreamIds); Subscribers = new ReadOnlyCollection(_subscribers); diff --git a/Lib/Xamarin.Forms.OpenTok.iOS/Service/PlatformOpenTokService.cs b/Lib/Xamarin.Forms.OpenTok.iOS/Service/PlatformOpenTokService.cs index 8220d7d..fef976b 100644 --- a/Lib/Xamarin.Forms.OpenTok.iOS/Service/PlatformOpenTokService.cs +++ b/Lib/Xamarin.Forms.OpenTok.iOS/Service/PlatformOpenTokService.cs @@ -22,7 +22,8 @@ public sealed class PlatformOpenTokService : BaseOpenTokService private readonly Collection _subscribers = new Collection(); private PlatformOpenTokService() - { + { + _subscriberStreamIds.CollectionChanged += OnSubscriberStreamIdsCollectionChanged; PropertyChanged += OnPropertyChanged; StreamIdCollection = new ReadOnlyObservableCollection(_subscriberStreamIds); Subscribers = new ReadOnlyCollection(_subscribers); diff --git a/Lib/Xamarin.Forms.OpenTok/Service/BaseOpenTokService.cs b/Lib/Xamarin.Forms.OpenTok/Service/BaseOpenTokService.cs index 0e7c06d..c02c006 100644 --- a/Lib/Xamarin.Forms.OpenTok/Service/BaseOpenTokService.cs +++ b/Lib/Xamarin.Forms.OpenTok/Service/BaseOpenTokService.cs @@ -4,6 +4,7 @@ using System; using System.Threading.Tasks; using System.Collections.ObjectModel; +using System.Collections.Specialized; namespace Xamarin.Forms.OpenTok.Service { @@ -12,12 +13,14 @@ public abstract class BaseOpenTokService : IOpenTokService { public event PropertyChangedEventHandler PropertyChanged; - public abstract ReadOnlyObservableCollection StreamIdCollection { get; } - public event Action Error; public event Action MessageReceived; + public event NotifyCollectionChangedEventHandler StreamIdCollectionChanged; + + public abstract ReadOnlyObservableCollection StreamIdCollection { get; } + private readonly object _propertiesLocker = new object(); private readonly Dictionary _properties = new Dictionary(); @@ -91,6 +94,9 @@ public bool IsPublishingStarted protected void RaiseMessageReceived(string message) => MessageReceived?.Invoke(message); + protected void OnSubscriberStreamIdsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + => StreamIdCollectionChanged(sender, e); + private T GetValue(T defaultValue, [CallerMemberName] string name = null) { lock (_propertiesLocker) diff --git a/Lib/Xamarin.Forms.OpenTok/Service/IOpenTokService.cs b/Lib/Xamarin.Forms.OpenTok/Service/IOpenTokService.cs index fe89bec..9a63b57 100644 --- a/Lib/Xamarin.Forms.OpenTok/Service/IOpenTokService.cs +++ b/Lib/Xamarin.Forms.OpenTok/Service/IOpenTokService.cs @@ -2,17 +2,20 @@ using System.Collections.ObjectModel; using System.ComponentModel; using System.Threading.Tasks; +using System.Collections.Specialized; namespace Xamarin.Forms.OpenTok.Service { public interface IOpenTokService : INotifyPropertyChanged { - ReadOnlyObservableCollection StreamIdCollection { get; } - event Action Error; event Action MessageReceived; + event NotifyCollectionChangedEventHandler StreamIdCollectionChanged; + + ReadOnlyObservableCollection StreamIdCollection { get; } + bool IsVideoPublishingEnabled { get; set; } bool IsAudioPublishingEnabled { get; set; } diff --git a/OpenTok.nuspec b/OpenTok.nuspec index c0dd99a..790cc96 100644 --- a/OpenTok.nuspec +++ b/OpenTok.nuspec @@ -2,7 +2,7 @@ Xamarin.Forms.OpenTok - 1.2.5 + 1.2.6 Xamarin.Forms.OpenTok Andrei Misiukevich Andrei Misiukevich diff --git a/Xamarin.Forms.OpenTok.Sample.Android/Resources/Resource.designer.cs b/Xamarin.Forms.OpenTok.Sample.Android/Resources/Resource.designer.cs index de378e4..10318f5 100644 --- a/Xamarin.Forms.OpenTok.Sample.Android/Resources/Resource.designer.cs +++ b/Xamarin.Forms.OpenTok.Sample.Android/Resources/Resource.designer.cs @@ -1663,6 +1663,7 @@ public static void UpdateIdValues() global::Xamarin.Forms.OpenTok.Android.Resource.Style.Animation_AppCompat_DropDownUp = global::Xamarin.Forms.OpenTok.Sample.Droid.Resource.Style.Animation_AppCompat_DropDownUp; global::Xamarin.Forms.OpenTok.Android.Resource.Style.Animation_AppCompat_Tooltip = global::Xamarin.Forms.OpenTok.Sample.Droid.Resource.Style.Animation_AppCompat_Tooltip; global::Xamarin.Forms.OpenTok.Android.Resource.Style.Animation_Design_BottomSheetDialog = global::Xamarin.Forms.OpenTok.Sample.Droid.Resource.Style.Animation_Design_BottomSheetDialog; + global::Xamarin.Forms.OpenTok.Android.Resource.Style.AppCompatDialogStyle = global::Xamarin.Forms.OpenTok.Sample.Droid.Resource.Style.AppCompatDialogStyle; global::Xamarin.Forms.OpenTok.Android.Resource.Style.Base_AlertDialog_AppCompat = global::Xamarin.Forms.OpenTok.Sample.Droid.Resource.Style.Base_AlertDialog_AppCompat; global::Xamarin.Forms.OpenTok.Android.Resource.Style.Base_AlertDialog_AppCompat_Light = global::Xamarin.Forms.OpenTok.Sample.Droid.Resource.Style.Base_AlertDialog_AppCompat_Light; global::Xamarin.Forms.OpenTok.Android.Resource.Style.Base_Animation_AppCompat_Dialog = global::Xamarin.Forms.OpenTok.Sample.Droid.Resource.Style.Base_Animation_AppCompat_Dialog; @@ -1855,6 +1856,8 @@ public static void UpdateIdValues() global::Xamarin.Forms.OpenTok.Android.Resource.Style.CardView_Dark = global::Xamarin.Forms.OpenTok.Sample.Droid.Resource.Style.CardView_Dark; global::Xamarin.Forms.OpenTok.Android.Resource.Style.CardView_Light = global::Xamarin.Forms.OpenTok.Sample.Droid.Resource.Style.CardView_Light; global::Xamarin.Forms.OpenTok.Android.Resource.Style.collectionViewStyle = global::Xamarin.Forms.OpenTok.Sample.Droid.Resource.Style.collectionViewStyle; + global::Xamarin.Forms.OpenTok.Android.Resource.Style.MainTheme = global::Xamarin.Forms.OpenTok.Sample.Droid.Resource.Style.MainTheme; + global::Xamarin.Forms.OpenTok.Android.Resource.Style.MainTheme_Base = global::Xamarin.Forms.OpenTok.Sample.Droid.Resource.Style.MainTheme_Base; global::Xamarin.Forms.OpenTok.Android.Resource.Style.Platform_AppCompat = global::Xamarin.Forms.OpenTok.Sample.Droid.Resource.Style.Platform_AppCompat; global::Xamarin.Forms.OpenTok.Android.Resource.Style.Platform_AppCompat_Light = global::Xamarin.Forms.OpenTok.Sample.Droid.Resource.Style.Platform_AppCompat_Light; global::Xamarin.Forms.OpenTok.Android.Resource.Style.Platform_MaterialComponents = global::Xamarin.Forms.OpenTok.Sample.Droid.Resource.Style.Platform_MaterialComponents;