TizenRefApp-8629 Implement Call view 33/150433/9
authorRuslan Zakharov <r.zakharov@samsung.com>
Fri, 15 Sep 2017 13:41:17 +0000 (16:41 +0300)
committerRuslan Zakharov <r.zakharov@samsung.com>
Thu, 2 Nov 2017 12:24:42 +0000 (14:24 +0200)
Implemented Call view and UI logic for it

Change-Id: Ifeb650d619ba4c2be3fe8a71546d43c1f5a3f20d

CallApp.Tizen/Call/Manager/CallManager.cs
CallApp.Tizen/Call/Manager/SettingsManager.cs
CallApp.Tizen/Call/View/CallView.xaml
CallApp.Tizen/Call/View/Controls/ProximityControl.xaml
CallApp.Tizen/Call/View/Controls/ProximityControl.xaml.cs
CallApp.Tizen/Call/ViewModel/CallViewModel.cs

index 14d8cd1..b60b275 100644 (file)
@@ -28,7 +28,7 @@ namespace CallApp.Tizen.Call.Manager
         public CallManager()
         {
             Calls = new ObservableCollection<CallBase>();
-            ContactsProvider = new ContactProvider();
+            ContactProvider = new ContactProvider();
         }
 
         /// <summary>
index 65ace8f..4d52fce 100644 (file)
@@ -24,7 +24,7 @@ namespace CallApp.Tizen.Call.Manager
         /// <summary>
         /// Bluetooth state, on or off
         /// </summary>
-        public bool BluetoothState
+        public bool IsBluetoothOn
         {
             get;
             set;
@@ -33,7 +33,7 @@ namespace CallApp.Tizen.Call.Manager
         /// <summary>
         /// Sound state, on or off
         /// </summary>
-        public bool SoundState
+        public bool IsMuteOn
         {
             get;
             set;
@@ -42,7 +42,7 @@ namespace CallApp.Tizen.Call.Manager
         /// <summary>
         /// Speaker state, on or off
         /// </summary>
-        public bool SpeakerState
+        public bool IsSpeakerOn
         {
             get;
             set;
index 7cc8194..5725889 100644 (file)
@@ -1,6 +1,50 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ContentView xmlns="http://xamarin.com/schemas/2014/forms"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
-             x:Class="CallApp.Tizen.Call.View.CallView">
+             x:Class="CallApp.Tizen.Call.View.CallView"
+             x:Name="This"
+             xmlns:CallControls="clr-namespace:CallApp.Tizen.Call.View.Controls"
+             xmlns:Localization="clr-namespace:CallApp.Tizen.Localization"
+             xmlns:TizenUtilityControls="clr-namespace:Tizen.Utility.Controls">
 
+    <TizenUtilityControls:CustomGrid>
+        <StackLayout>
+            <StackLayout>
+                <CallControls:ContactInfoPanel LayoutType="Single" Image="{Binding ActiveCall.ContactModel.Image}"
+                                               PrimaryText="{Binding ActiveCall.ContactModel.Name}" SecondaryText="{Binding ActiveCall.CallerNumber}">
+                    <CallControls:ContactInfoPanel.Triggers>
+                        <DataTrigger TargetType="CallControls:ContactInfoPanel" Binding="{Binding ActiveCall.Status}" Value="Active">
+                            <Setter Property="StatusText" Value="{Binding CallDuration.Duration}" />
+                        </DataTrigger>
+
+                        <DataTrigger TargetType="CallControls:ContactInfoPanel" Binding="{Binding ActiveCall.Status}" Value="Outgoing">
+                            <Setter Property="StatusText" Value="{x:Static Localization:Localization.Dialling}" />
+                        </DataTrigger>
+                    </CallControls:ContactInfoPanel.Triggers>
+                </CallControls:ContactInfoPanel>
+
+                <CallControls:CallHandlingPanel ToggleSpeakerCommand="{Binding ToggleSpeakerCommand}"
+                                                OpenKeypadCommand="{Binding OpenKeypadCommand}"
+                                                ToggleBluetoothCommand="{Binding ToggleBluetoothCommand}"
+                                                AddCallCommand="{Binding AddCallCommand}"
+                                                ToggleMuteCommand="{Binding ToggleMuteCommand}"
+                                                AddContactCommand="{Binding AddContactCommand}" />
+                <StackLayout.Triggers>
+                    <DataTrigger TargetType="StackLayout" Binding="{Binding IsKeypadOpen}" Value="True">
+                        <Setter Property="IsVisible" Value="False" />
+                    </DataTrigger>
+                </StackLayout.Triggers>
+            </StackLayout>
+
+            <CallControls:Dialer VerticalOptions="FillAndExpand" StatusText="{Binding CallDuration.Duration}" IsOpen="{Binding IsKeypadOpen}" />
+
+            <ContentView HeightRequest="152" BackgroundColor="{StaticResource BGColor}">
+                <CallControls:AnimatedCircleButton HorizontalOptions="Center" VerticalOptions="Center" Radius="100"
+                                                   AnimationColor="{StaticResource CircleButtonRejectBGColor}" NormalColor="{StaticResource CircleButtonRejectNormalColor}"
+                                                   PressColor="{StaticResource CircleButtonRejectPressColor}" Image="call_btn_ic_reject.png" />
+            </ContentView>
+        </StackLayout>
+
+        <CallControls:ProximityControl ProximityState="{Binding ProximityState}" />
+    </TizenUtilityControls:CustomGrid>
 </ContentView>
\ No newline at end of file
index 04916ac..ff19ae8 100644 (file)
@@ -7,7 +7,7 @@
              IsVisible="False">
 
     <ContentView.Triggers>
-        <DataTrigger TargetType="ContentView" Binding="{Binding Proximity, Source={x:Reference This}}" Value="Near">
+        <DataTrigger TargetType="ContentView" Binding="{Binding ProximityState, Source={x:Reference This}}" Value="Near">
             <Setter Property="IsVisible" Value="True" />
         </DataTrigger>
     </ContentView.Triggers>
index 1f5b839..009554d 100644 (file)
@@ -30,24 +30,24 @@ namespace CallApp.Tizen.Call.View.Controls
         }
 
         /// <summary>
-        /// Proximity state
+        /// Gets or sets proximity state
         /// </summary>
-        public static readonly BindableProperty ProximityProperty = BindableProperty.Create(
-            "Proximity",
+        public static readonly BindableProperty ProximityStateProperty = BindableProperty.Create(
+            "ProximityState",
             typeof(ProximitySensorState),
             typeof(ProximityControl),
             ProximitySensorState.Unknown);
 
-        public ProximitySensorState Proximity
+        public ProximitySensorState ProximityState
         {
             get
             {
-                return (ProximitySensorState)GetValue(ProximityProperty);
+                return (ProximitySensorState)GetValue(ProximityStateProperty);
             }
 
             set
             {
-                SetValue(ProximityProperty, value);
+                SetValue(ProximityStateProperty, value);
             }
         }
     }
index 5731894..08dd514 100644 (file)
  * limitations under the License.
  */
 
+using CallApp.Tizen.Call.Helper;
 using CallApp.Tizen.Call.Manager;
 using CallApp.Tizen.Call.Model;
+using System.Windows.Input;
+using Tizen.Sensor;
 using Tizen.Utility.Helpers;
+using Xamarin.Forms;
 
 namespace CallApp.Tizen.Call.ViewModel
 {
@@ -31,106 +35,279 @@ namespace CallApp.Tizen.Call.ViewModel
         public CallViewModel(CallManager callManager)
         {
             _callManager = callManager;
+
+            ToggleSpeakerCommand = new Command(OnToggleSpeaker);
+            OpenKeypadCommand = new Command(OnOpenKeypad);
+            ToggleBluetoothCommand = new Command(OnToggleBluetooth);
+            AddCallCommand = new Command(OnAddCall, OnAddCallCanExecute);
+            ToggleMuteCommand = new Command(OnToggleMute, OnToggleMuteCanExecute);
+            AddContactCommand = new Command(OnAddContact, OnAddContactCanExecute);
+            RejectCallCommand = new Command(OnRejectCall);
+
+            ProximitySensor proximitySensor = new ProximitySensor();
+            proximitySensor.DataUpdated += OnProximitySensorDataUpdated;
+            proximitySensor.Start();
+        }
+
+        /// <summary>
+        /// Command for speaker on or off
+        /// </summary>
+        public ICommand ToggleSpeakerCommand
+        {
+            get;
+            private set;
+        }
+
+        /// <summary>
+        /// Command for keypad on or off
+        /// </summary>
+        public ICommand OpenKeypadCommand
+        {
+            get;
+            private set;
+        }
+
+        /// <summary>
+        /// Command for bluetooth on or off
+        /// </summary>
+        public ICommand ToggleBluetoothCommand
+        {
+            get;
+            private set;
+        }
+
+        /// <summary>
+        /// Command for add call
+        /// </summary>
+        public ICommand AddCallCommand
+        {
+            get;
+            private set;
+        }
+
+        /// <summary>
+        /// Command for sound on or off
+        /// </summary>
+        public ICommand ToggleMuteCommand
+        {
+            get;
+            private set;
+        }
+
+        /// <summary>
+        /// Command for add contact
+        /// </summary>
+        public ICommand AddContactCommand
+        {
+            get;
+            private set;
+        }
+
+        /// <summary>
+        /// Command for reject call
+        /// </summary>
+        public ICommand RejectCallCommand
+        {
+            get;
+            private set;
         }
 
         /// <summary>
         /// Gets or sets the active call
         /// </summary>
+        private CallModel _activeCall = null;
         public CallModel ActiveCall
         {
-            get;
+            get
+            {
+                return _activeCall;
+            }
 
             // FIXME: Make it private when Call API is completed, at this moment needed to test app
-            set;
+            set
+            {
+                _activeCall = value;
+
+                OnPropertyChanged();
+            }
         }
 
         /// <summary>
         /// Gets or sets the call on hold
         /// </summary>
+        private CallModel _holdCall = null;
         public CallModel HoldCall
         {
-            get;
+            get
+            {
+                return _holdCall;
+            }
 
             // FIXME: Make it private when Call API is completed, at this moment needed to test app
-            set;
+            set
+            {
+                _holdCall = value;
+
+                OnPropertyChanged();
+            }
+        }
+
+        /// <summary>
+        /// Call duration
+        /// </summary>
+        private TimeDuration _callDuration = new TimeDuration(0, 0);
+        public TimeDuration CallDuration
+        {
+            get
+            {
+                return _callDuration;
+            }
+            set
+            {
+                _callDuration = value;
+
+                OnPropertyChanged();
+            }
         }
 
         /// <summary>
         /// Bluetooth state, on or off
         /// </summary>
-        public bool BluetoothState
+        public bool IsBluetoothOn
         {
             get
             {
-                return _settingsManager.BluetoothState;
+                return _settingsManager.IsBluetoothOn;
             }
 
             set
             {
-                _settingsManager.BluetoothState = value;
+                _settingsManager.IsBluetoothOn = value;
+
+                OnPropertyChanged();
             }
         }
 
         /// <summary>
         /// Sound state, on or off
         /// </summary>
-        public bool SoundState
+        public bool IsMuteOn
         {
             get
             {
-                return _settingsManager.SoundState;
+                return _settingsManager.IsMuteOn;
             }
 
             set
             {
-                _settingsManager.SoundState = value;
+                _settingsManager.IsMuteOn = value;
+
+                OnPropertyChanged();
             }
         }
 
         /// <summary>
         /// Speaker state, on or off
         /// </summary>
-        public bool SpeakerState
+        public bool IsSpeakerOn
         {
             get
             {
-                return _settingsManager.SpeakerState;
+                return _settingsManager.IsSpeakerOn;
             }
 
             set
             {
-                _settingsManager.SpeakerState = value;
+                _settingsManager.IsSpeakerOn = value;
+
+                OnPropertyChanged();
             }
         }
 
         /// <summary>
-        /// Keypad state, showed or not
+        /// Is keypad open or not
         /// </summary>
-        public bool KeypadState
+        private bool _isKeypadOpen = false;
+        public bool IsKeypadOpen
         {
-            get;
-            set;
+            get
+            {
+                return _isKeypadOpen;
+            }
+            set
+            {
+                _isKeypadOpen = value;
+
+                OnPropertyChanged();
+            }
         }
 
-        /// <summary>
-        /// Adds a call
-        /// </summary>
-        public void AddCall()
+        /// <summary cref="ProximitySensorState.ProximitySensorState" />
+        private ProximitySensorState _proximityState = ProximitySensorState.Far;
+        public ProximitySensorState ProximityState
         {
+            get
+            {
+                return _proximityState;
+            }
+            set
+            {
+                _proximityState = value;
+
+                OnPropertyChanged();
+            }
         }
 
-        /// <summary>
-        /// Add a contact
-        /// </summary>
-        public void AddContact()
+        private void OnToggleSpeaker(object obj)
         {
+            IsSpeakerOn = !IsSpeakerOn;
         }
 
-        /// <summary>
-        /// Reject a call
-        /// </summary>
-        public void RejectCall()
+        private void OnOpenKeypad(object obj)
+        {
+            IsKeypadOpen = true;
+        }
+
+        private void OnToggleBluetooth(object obj)
+        {
+            IsBluetoothOn = !IsBluetoothOn;
+        }
+
+        private void OnAddCall(object obj)
+        {
+        }
+
+        private bool OnAddCallCanExecute(object arg)
+        {
+            return ActiveCall.Status == CallStatus.Active;
+        }
+
+        private void OnToggleMute(object obj)
+        {
+            IsMuteOn = !IsMuteOn;
+        }
+
+        private bool OnToggleMuteCanExecute(object arg)
+        {
+            return ActiveCall.Status == CallStatus.Active;
+        }
+
+        private void OnAddContact(object obj)
+        {
+        }
+
+        private bool OnAddContactCanExecute(object arg)
+        {
+            return ActiveCall.Status == CallStatus.Active;
+        }
+
+        private void OnRejectCall(object obj)
+        {
+        }
+
+        private void OnProximitySensorDataUpdated(object sender, ProximitySensorDataUpdatedEventArgs e)
         {
+            ProximityState = e.Proximity;
         }
     }
 }