TizenRefApp-8536 Provide basic class structure for S-Voice app 88/132888/5 tizen
authorRuslan Zakharov <r.zakharov@samsung.com>
Thu, 8 Jun 2017 07:10:18 +0000 (10:10 +0300)
committerRuslan Zakharov <r.zakharov@samsung.com>
Mon, 12 Jun 2017 07:00:02 +0000 (10:00 +0300)
Added base classes structure

Change-Id: Ia6fa4079dc634254619f3a5e75fbf16aadf20237

25 files changed:
VoiceApp.Tizen/Common/Controls/CustomImage.xaml [new file with mode: 0644]
VoiceApp.Tizen/Common/Controls/CustomImage.xaml.cs [new file with mode: 0644]
VoiceApp.Tizen/Common/Controls/Renderers/CustomImageRenderer.cs [new file with mode: 0644]
VoiceApp.Tizen/Common/Helpers/BaseViewModel.cs [new file with mode: 0644]
VoiceApp.Tizen/Common/Helpers/PageNavigator.cs [new file with mode: 0644]
VoiceApp.Tizen/Common/Input/AttachedTapCommand.cs [new file with mode: 0644]
VoiceApp.Tizen/Settings/SettingsPage.xaml.cs
VoiceApp.Tizen/Settings/SettingsViewModel.cs
VoiceApp.Tizen/Voice/Client/Client.cs [new file with mode: 0644]
VoiceApp.Tizen/Voice/Client/CommandData.cs [new file with mode: 0644]
VoiceApp.Tizen/Voice/Client/CommandExecutors.cs [new file with mode: 0644]
VoiceApp.Tizen/Voice/Controls/ListeningPanel.xaml [new file with mode: 0644]
VoiceApp.Tizen/Voice/Controls/ListeningPanel.xaml.cs [new file with mode: 0644]
VoiceApp.Tizen/Voice/Controls/ViewModel/ListeningViewModel.cs [new file with mode: 0644]
VoiceApp.Tizen/Voice/Themes/VoiceTheme.xaml [new file with mode: 0644]
VoiceApp.Tizen/Voice/Themes/VoiceTheme.xaml.cs [new file with mode: 0644]
VoiceApp.Tizen/Voice/VoicePage.xaml
VoiceApp.Tizen/VoiceApp.Tizen.csproj
VoiceApp.Tizen/VoiceApp.Tizen.project.json
VoiceApp.Tizen/loc/loc.Designer.cs
VoiceApp.Tizen/loc/loc.resx
VoiceApp.Tizen/res/icon_arrow.png [new file with mode: 0644]
VoiceApp.Tizen/res/icon_close.png [new file with mode: 0644]
VoiceApp.Tizen/res/icon_settings.png [new file with mode: 0644]
VoiceApp.Tizen/res/icon_voice.png

diff --git a/VoiceApp.Tizen/Common/Controls/CustomImage.xaml b/VoiceApp.Tizen/Common/Controls/CustomImage.xaml
new file mode 100644 (file)
index 0000000..6c03914
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<Image xmlns="http://xamarin.com/schemas/2014/forms"
+       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+       x:Class="VoiceApp.Tizen.Common.Controls.CustomImage">
+
+</Image>
\ No newline at end of file
diff --git a/VoiceApp.Tizen/Common/Controls/CustomImage.xaml.cs b/VoiceApp.Tizen/Common/Controls/CustomImage.xaml.cs
new file mode 100644 (file)
index 0000000..4c45b31
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using Xamarin.Forms;
+
+namespace VoiceApp.Tizen.Common.Controls
+{
+    /// <summary>
+    /// Extension of Xamarin Image, with supports:
+    /// Color blending
+    /// </summary>
+    public partial class CustomImage : Image
+    {
+        public CustomImage()
+        {
+            InitializeComponent();
+        }
+
+        /// <summary>
+        /// Color for blending
+        /// </summary>
+        public static readonly BindableProperty BlendingColorProperty = BindableProperty.Create(
+            "BlendingColor",
+            typeof(Color),
+            typeof(CustomImage),
+            Color.White);
+
+        public Color BlendingColor
+        {
+            get
+            {
+                return (Color)GetValue(BlendingColorProperty);
+            }
+            set
+            {
+                SetValue(BlendingColorProperty, value);
+            }
+        }
+    }
+}
diff --git a/VoiceApp.Tizen/Common/Controls/Renderers/CustomImageRenderer.cs b/VoiceApp.Tizen/Common/Controls/Renderers/CustomImageRenderer.cs
new file mode 100644 (file)
index 0000000..857316e
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System.ComponentModel;
+using VoiceApp.Tizen.Common.Controls;
+using VoiceApp.Tizen.Common.Controls.Renderers;
+using Xamarin.Forms;
+using Xamarin.Forms.Platform.Tizen;
+
+[assembly: ExportRenderer(typeof(CustomImage), typeof(CustomImageRenderer))]
+namespace VoiceApp.Tizen.Common.Controls.Renderers
+{
+    /// <summary>
+    /// Custom renderer for blending color, needed for CustomImage control
+    /// </summary>
+    class CustomImageRenderer : ImageRenderer
+    {
+        /// <summary>
+        /// <see cref="ImageRenderer.OnElementChanged(ElementChangedEventArgs{Image})" />
+        /// </summary>
+        protected override void OnElementChanged(ElementChangedEventArgs<Image> e)
+        {
+            base.OnElementChanged(e);
+
+            if (Control == null || Element == null)
+            {
+                return;
+            }
+
+            applyBlendingColor();
+        }
+
+        /// <summary>
+        /// <see cref="ImageRenderer.OnElementPropertyChanged(object, PropertyChangedEventArgs)" />
+        /// </summary>
+        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+        {
+            base.OnElementPropertyChanged(sender, e);
+
+            // TODO this is not working, seems a bug
+            /*
+            if (e.PropertyName == CustomImage.BlendingColorProperty.PropertyName)
+            {
+                applyBlendingColor();
+            }
+            */
+
+            applyBlendingColor();
+        }
+
+        private void applyBlendingColor()
+        {
+            Control.Color = ((CustomImage)Element).BlendingColor.ToNative();
+        }
+    }
+}
diff --git a/VoiceApp.Tizen/Common/Helpers/BaseViewModel.cs b/VoiceApp.Tizen/Common/Helpers/BaseViewModel.cs
new file mode 100644 (file)
index 0000000..9b51ebc
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+
+namespace VoiceApp.Tizen.Common.Helpers
+{
+    /// <summary>
+    /// Base class for ViewModels, implements INotifyPropertyChanged interface
+    /// </summary>
+    public class BaseViewModel : INotifyPropertyChanged
+    {
+        /// <summary>
+        /// Property changed event
+        /// </summary>
+        public event PropertyChangedEventHandler PropertyChanged;
+
+        /// <summary>
+        /// Raise PropertyChanged event
+        /// </summary>
+        /// <param name="propertyName">Changed property name</param>
+        protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
+        {
+            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+        }
+    }
+}
diff --git a/VoiceApp.Tizen/Common/Helpers/PageNavigator.cs b/VoiceApp.Tizen/Common/Helpers/PageNavigator.cs
new file mode 100644 (file)
index 0000000..d615813
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Xamarin.Forms;
+
+namespace VoiceApp.Tizen.Common.Helpers
+{
+    /// <summary>
+    /// Helper with navigation logics through pages
+    /// </summary>
+    class PageNavigator
+    {
+        /// <summary>
+        /// Navigate to new page in modal state
+        /// </summary>
+        /// <param name="page">Page to navigate</param>
+        public static void NavigateModal(Page page)
+        {
+            if (Application.Current.MainPage != null)
+            {
+                Application.Current.MainPage.Navigation.PushModalAsync(page);
+            }
+            else
+            {
+                Console.WriteLine("PageNavigator, NavigateModal(Page), Application.Current.MainPage is null");
+            }
+        }
+    }
+}
diff --git a/VoiceApp.Tizen/Common/Input/AttachedTapCommand.cs b/VoiceApp.Tizen/Common/Input/AttachedTapCommand.cs
new file mode 100644 (file)
index 0000000..66346d4
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System.Windows.Input;
+using Xamarin.Forms;
+
+namespace VoiceApp.Tizen.Common.Input
+{
+    /// <summary>
+    /// Implementation of tap event through command. Can be attached to UI control
+    /// </summary>
+    class AttachedTapCommand
+    {
+        /// <summary>
+        /// Property for attaching ICommand
+        /// </summary>
+        public static readonly BindableProperty CommandProperty = BindableProperty.CreateAttached(
+            "Command",
+            typeof(ICommand),
+            typeof(View),
+            null,
+            BindingMode.OneWay,
+            defaultValueCreator: InitializeCommand);
+
+        /// <summary>
+        /// Property for attaching CommandParameter
+        /// </summary>
+        public static readonly BindableProperty CommandParameterProperty = BindableProperty.CreateAttached(
+            "CommandParameter",
+            typeof(string),
+            typeof(View),
+            string.Empty);
+
+        public static ICommand GetCommand(BindableObject obj)
+        {
+            return (ICommand)obj.GetValue(CommandProperty);
+        }
+
+        public static void SetCommand(BindableObject obj, ICommand value)
+        {
+            obj.SetValue(CommandProperty, value);
+        }
+
+        public static string GetCommandParameter(BindableObject obj)
+        {
+            return (string)obj.GetValue(CommandParameterProperty);
+        }
+
+        public static void SetCommandParameter(BindableObject obj, ICommand value)
+        {
+            obj.SetValue(CommandParameterProperty, value);
+        }
+
+        private static object InitializeCommand(BindableObject obj)
+        {
+            if (obj is View view)
+            {
+                var tapGestureRecognizer = new TapGestureRecognizer();
+                tapGestureRecognizer.Tapped += OnTapped;
+
+                view.GestureRecognizers.Add(tapGestureRecognizer);
+            }
+
+            return null;
+        }
+
+        private static void OnTapped(object sender, System.EventArgs e)
+        {
+            if (sender is BindableObject obj)
+            {
+                var command = GetCommand(obj);
+                var commandParameter = GetCommandParameter(obj);
+
+                if (command != null && command.CanExecute(commandParameter))
+                {
+                    command.Execute(commandParameter);
+                }
+            }
+        }
+    }
+}
index 44386c7..98a2e51 100644 (file)
  * limitations under the License.
  */
 
+using VoiceApp.Tizen.Common.Helpers;
 using Xamarin.Forms;
 
 namespace VoiceApp.Tizen.Settings
 {
     public partial class SettingsPage : ContentPage
     {
-        public SettingsPage()
+        public SettingsPage(BaseViewModel vm)
         {
             InitializeComponent();
+
+            BindingContext = vm;
         }
     }
 }
index 12000db..321cb8c 100644 (file)
  * limitations under the License.
  */
 
+using VoiceApp.Tizen.Common.Helpers;
+
 namespace VoiceApp.Tizen.Settings
 {
-    class SettingsViewModel
+    class SettingsViewModel : BaseViewModel
     {
     }
 }
diff --git a/VoiceApp.Tizen/Voice/Client/Client.cs b/VoiceApp.Tizen/Voice/Client/Client.cs
new file mode 100644 (file)
index 0000000..0dc0a0d
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System.Collections.Generic;
+
+namespace VoiceApp.Tizen.Voice.Client
+{
+    // TODO:
+    // Implement API https://developer.tizen.org/dev-guide/csapi/namespaceTizen_1_1Uix_1_1VoiceControl.html
+    class Client
+    {
+        private List<CommandData> _commandsContainer = new List<CommandData>();
+
+        public Client()
+        {
+            Initialize();
+        }
+
+        /// <summary>
+        /// Start the record
+        /// </summary>
+        public void StartRecord()
+        {
+        }
+
+        /// <summary>
+        /// Stop the record
+        /// </summary>
+        public void StopRecord()
+        {
+        }
+
+        private void Initialize()
+        {
+            _commandsContainer.Add(new CommandData { Name = "Mute", Execute = CommandExecutors.Mute });
+        }
+    }
+}
diff --git a/VoiceApp.Tizen/Voice/Client/CommandData.cs b/VoiceApp.Tizen/Voice/Client/CommandData.cs
new file mode 100644 (file)
index 0000000..47064de
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace VoiceApp.Tizen.Voice.Client
+{
+    class CommandData
+    {
+        /// <summary>
+        /// Name of command
+        /// </summary>
+        public string Name
+        {
+            get;
+            set;
+        }
+
+        /// <summary>
+        /// Delegate to execute command
+        /// </summary>
+        public Action<object> Execute
+        {
+            get;
+            set;
+        }
+    }
+}
diff --git a/VoiceApp.Tizen/Voice/Client/CommandExecutors.cs b/VoiceApp.Tizen/Voice/Client/CommandExecutors.cs
new file mode 100644 (file)
index 0000000..824504c
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace VoiceApp.Tizen.Voice.Client
+{
+    class CommandExecutors
+    {
+        /// <summary>
+        /// Mute the sound
+        /// </summary>
+        /// <param name="parameter">Some additional parameter</param>
+        public static void Mute(object parameter)
+        {
+        }
+    }
+}
diff --git a/VoiceApp.Tizen/Voice/Controls/ListeningPanel.xaml b/VoiceApp.Tizen/Voice/Controls/ListeningPanel.xaml
new file mode 100644 (file)
index 0000000..de04979
--- /dev/null
@@ -0,0 +1,46 @@
+<?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="VoiceApp.Tizen.Voice.Controls.ListeningPanel"
+             xmlns:loc="clr-namespace:VoiceApp.Tizen.loc"
+             xmlns:vm="clr-namespace:VoiceApp.Tizen.Voice.Controls.ViewModel"
+             xmlns:commonControls="clr-namespace:VoiceApp.Tizen.Common.Controls"
+             xmlns:commonInput="clr-namespace:VoiceApp.Tizen.Common.Input"
+             xmlns:voiceThemes="clr-namespace:VoiceApp.Tizen.Voice.Themes">
+
+    <ContentPage.BindingContext>
+        <vm:ListeningViewModel />
+    </ContentPage.BindingContext>
+
+    <ContentPage.Resources>
+        <ResourceDictionary MergedWith="voiceThemes:VoiceTheme" />
+    </ContentPage.Resources>
+
+    <Grid BackgroundColor="{StaticResource ListeningPanelColor}">
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="50" />
+            <ColumnDefinition Width="50" />
+            <ColumnDefinition Width="*" />
+            <ColumnDefinition Width="50" />
+            <ColumnDefinition Width="50" />
+        </Grid.ColumnDefinitions>
+
+        <Grid.RowDefinitions>
+            <RowDefinition Height="100" />
+        </Grid.RowDefinitions>
+
+        <Image Grid.Column="0" Source="icon_voice.png" />
+        <Image Grid.Column="1" Source="icon_arrow.png" />
+
+        <Label Grid.Column="2" TextColor="White" VerticalOptions="Center" Text="{x:Static loc:loc.Waiting}" commonInput:AttachedTapCommand.Command="{Binding StartListeningCommand}">
+            <Label.Triggers>
+                <DataTrigger TargetType="Label" Binding="{Binding CurrentVoiceState}" Value="Listening">
+                    <Setter Property="Text" Value="{x:Static loc:loc.Listening}" />
+                </DataTrigger>
+            </Label.Triggers>
+        </Label>
+
+        <Image Grid.Column="3" Source="icon_settings.png" commonInput:AttachedTapCommand.Command="{Binding OpenSettingsCommand}" />
+        <Image Grid.Column="4" Source="icon_close.png" />
+    </Grid>
+</ContentView>
\ No newline at end of file
diff --git a/VoiceApp.Tizen/Voice/Controls/ListeningPanel.xaml.cs b/VoiceApp.Tizen/Voice/Controls/ListeningPanel.xaml.cs
new file mode 100644 (file)
index 0000000..8476d3d
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using Xamarin.Forms;
+
+namespace VoiceApp.Tizen.Voice.Controls
+{
+    public partial class ListeningPanel : ContentView
+    {
+        public ListeningPanel()
+        {
+            InitializeComponent();
+        }
+    }
+}
diff --git a/VoiceApp.Tizen/Voice/Controls/ViewModel/ListeningViewModel.cs b/VoiceApp.Tizen/Voice/Controls/ViewModel/ListeningViewModel.cs
new file mode 100644 (file)
index 0000000..356a397
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Windows.Input;
+using VoiceApp.Tizen.Common.Helpers;
+using VoiceApp.Tizen.Settings;
+using Xamarin.Forms;
+
+namespace VoiceApp.Tizen.Voice.Controls.ViewModel
+{
+    class ListeningViewModel : BaseViewModel
+    {
+        /// <summary>
+        /// States of voice
+        /// </summary>
+        public enum VoiceState
+        {
+            Listening,
+            Waiting
+        }
+
+        private Client.Client _voiceClient = new Client.Client();
+        private VoiceState _currentVoiceState = VoiceState.Waiting;
+
+        public ListeningViewModel()
+        {
+            StartListeningCommand = new Command(OnStartListening, OnStartListeningCanExecute);
+            OpenSettingsCommand = new Command(OnOpenSettings);
+        }
+
+        /// <summary>
+        /// Command for start listening
+        /// </summary>
+        public ICommand StartListeningCommand
+        {
+            get;
+            private set;
+        }
+
+        /// <summary>
+        /// Command for open settings
+        /// </summary>
+        public ICommand OpenSettingsCommand
+        {
+            get;
+            private set;
+        }
+
+        /// <summary>
+        /// Current voice state
+        /// </summary>
+        public VoiceState CurrentVoiceState
+        {
+            get
+            {
+                return _currentVoiceState;
+            }
+            private set
+            {
+                _currentVoiceState = value;
+                OnPropertyChanged();
+            }
+        }
+
+        private void OnStartListening(object obj)
+        {
+            CurrentVoiceState = VoiceState.Listening;
+            _voiceClient.StartRecord();
+
+            Device.StartTimer(new TimeSpan(0, 0, 5), OnListeningElapsed);
+
+            if (StartListeningCommand is Command command)
+            {
+                command.ChangeCanExecute();
+            }
+        }
+
+        private bool OnStartListeningCanExecute(object obj)
+        {
+            return CurrentVoiceState == VoiceState.Waiting;
+        }
+
+        private void OnOpenSettings(object obj)
+        {
+            PageNavigator.NavigateModal(new SettingsPage(new SettingsViewModel()));
+        }
+
+        private bool OnListeningElapsed()
+        {
+            _voiceClient.StopRecord();
+            CurrentVoiceState = VoiceState.Waiting;
+
+            return false;
+        }
+    }
+}
diff --git a/VoiceApp.Tizen/Voice/Themes/VoiceTheme.xaml b/VoiceApp.Tizen/Voice/Themes/VoiceTheme.xaml
new file mode 100644 (file)
index 0000000..d4cb148
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
+                    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+                    x:Class="VoiceApp.Tizen.Voice.Themes.VoiceTheme">
+
+    <Color x:Key="ListeningPanelColor">#FF0088AA</Color>
+</ResourceDictionary>
\ No newline at end of file
diff --git a/VoiceApp.Tizen/Voice/Themes/VoiceTheme.xaml.cs b/VoiceApp.Tizen/Voice/Themes/VoiceTheme.xaml.cs
new file mode 100644 (file)
index 0000000..674e657
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using Xamarin.Forms;
+
+namespace VoiceApp.Tizen.Voice.Themes
+{
+    public partial class VoiceTheme : ResourceDictionary
+    {
+        public VoiceTheme()
+        {
+            InitializeComponent();
+        }
+    }
+}
index d1dfb93..2e2657a 100644 (file)
@@ -1,6 +1,8 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
-             x:Class="VoiceApp.Tizen.Voice.VoicePage">
+             x:Class="VoiceApp.Tizen.Voice.VoicePage"
+             xmlns:voiceControls="clr-namespace:VoiceApp.Tizen.Voice.Controls">
 
+    <voiceControls:ListeningPanel VerticalOptions="EndAndExpand" HorizontalOptions="Fill" />
 </ContentPage>
\ No newline at end of file
index e948568..7601e61 100644 (file)
     <None Include="tizen-manifest.xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="Common\Input\AttachedTapCommand.cs" />
+    <Compile Include="Common\Controls\Renderers\CustomImageRenderer.cs" />
+    <Compile Include="Common\Controls\CustomImage.xaml.cs">
+      <DependentUpon>CustomImage.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Common\Helpers\BaseViewModel.cs" />
+    <Compile Include="Common\Helpers\PageNavigator.cs" />
     <Compile Include="loc\loc.Designer.cs">
       <AutoGen>True</AutoGen>
       <DesignTime>True</DesignTime>
     </Compile>
     <Compile Include="Settings\SettingsViewModel.cs" />
     <Compile Include="App.cs" />
+    <Compile Include="Voice\Themes\VoiceTheme.xaml.cs">
+      <DependentUpon>VoiceTheme.xaml</DependentUpon>
+    </Compile>
     <Compile Include="VoiceApp.Tizen.cs" />
+    <Compile Include="Voice\Client\CommandData.cs" />
+    <Compile Include="Voice\Client\Client.cs" />
+    <Compile Include="Voice\Client\CommandExecutors.cs" />
+    <Compile Include="Voice\Controls\ListeningPanel.xaml.cs">
+      <DependentUpon>ListeningPanel.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Voice\Controls\ViewModel\ListeningViewModel.cs" />
     <Compile Include="Voice\VoicePage.xaml.cs">
       <DependentUpon>VoicePage.xaml</DependentUpon>
     </Compile>
     </EmbeddedResource>
   </ItemGroup>
   <ItemGroup>
+    <Content Include="res\icon_arrow.png" />
+    <Content Include="res\icon_close.png" />
+    <Content Include="res\icon_settings.png" />
     <Content Include="res\icon_voice.png" />
   </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Common\Controls\CustomImage.xaml">
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Voice\Themes\VoiceTheme.xaml">
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Voice\Controls\ListeningPanel.xaml">
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
                Other similar extension points exist, see Microsoft.Common.targets.
index 9976176..c15149d 100644 (file)
@@ -10,6 +10,7 @@
       "version": "1.0.0"
     },
     "Tizen.Library": "1.0.0-pre3",
+    "Tizen.Uix.VoiceControl": "1.0.5",
     "Xamarin.Forms": "2.3.4.214-pre5",
     "Xamarin.Forms.Platform.Tizen": "2.3.4-r214-002"
   },
index 9a279a0..2873746 100644 (file)
@@ -73,9 +73,9 @@ namespace VoiceApp.Tizen.loc {
         /// <summary>
         ///   Looks up a localized string similar to Touch here to restart.
         /// </summary>
-        public static string WaitingMessage {
+        public static string Waiting {
             get {
-                return ResourceManager.GetString("WaitingMessage", resourceCulture);
+                return ResourceManager.GetString("Waiting", resourceCulture);
             }
         }
     }
index 9a1af8a..9b43850 100644 (file)
   <data name="Listening" xml:space="preserve">
     <value>Listening...</value>
   </data>
-  <data name="WaitingMessage" xml:space="preserve">
+  <data name="Waiting" xml:space="preserve">
     <value>Touch here to restart</value>
   </data>
 </root>
\ No newline at end of file
diff --git a/VoiceApp.Tizen/res/icon_arrow.png b/VoiceApp.Tizen/res/icon_arrow.png
new file mode 100644 (file)
index 0000000..09e3712
Binary files /dev/null and b/VoiceApp.Tizen/res/icon_arrow.png differ
diff --git a/VoiceApp.Tizen/res/icon_close.png b/VoiceApp.Tizen/res/icon_close.png
new file mode 100644 (file)
index 0000000..b451a6d
Binary files /dev/null and b/VoiceApp.Tizen/res/icon_close.png differ
diff --git a/VoiceApp.Tizen/res/icon_settings.png b/VoiceApp.Tizen/res/icon_settings.png
new file mode 100644 (file)
index 0000000..e0360fb
Binary files /dev/null and b/VoiceApp.Tizen/res/icon_settings.png differ
index bbef369..cc470cd 100644 (file)
Binary files a/VoiceApp.Tizen/res/icon_voice.png and b/VoiceApp.Tizen/res/icon_voice.png differ