<?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
* 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
{
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;
}
}
}