TizenRefApp-8629 Implement Call view 30/150430/7
authorRuslan Zakharov <r.zakharov@samsung.com>
Fri, 15 Sep 2017 13:31:59 +0000 (16:31 +0300)
committerRuslan Zakharov <r.zakharov@samsung.com>
Thu, 2 Nov 2017 08:08:55 +0000 (10:08 +0200)
Added new custom controls, resources and Dialer control

Change-Id: I6b5289eca3bc075a36a5ff0465f57dc60dcdd8c8

12 files changed:
CallApp.Tizen/Call/View/Controls/Dialer.xaml [new file with mode: 0644]
CallApp.Tizen/Call/View/Controls/Dialer.xaml.cs [new file with mode: 0644]
CallApp.Tizen/Call/View/Controls/Keypad.xaml.cs
CallApp.Tizen/CallApp.Tizen.csproj
CallApp.Tizen/Tizen.Utility/Controls/CustomContentView.xaml [new file with mode: 0644]
CallApp.Tizen/Tizen.Utility/Controls/CustomContentView.xaml.cs [new file with mode: 0644]
CallApp.Tizen/Tizen.Utility/Controls/CustomEntry.xaml [new file with mode: 0644]
CallApp.Tizen/Tizen.Utility/Controls/CustomEntry.xaml.cs [new file with mode: 0644]
CallApp.Tizen/Tizen.Utility/Controls/GesturesContainer.xaml.cs
CallApp.Tizen/Tizen.Utility/Controls/Renderers/CustomEntryRenderer.cs [new file with mode: 0644]
CallApp.Tizen/res/Call ID/348x348/call_photo_id.png [new file with mode: 0644]
CallApp.Tizen/res/keypad_predictive_arrow.png [new file with mode: 0644]

diff --git a/CallApp.Tizen/Call/View/Controls/Dialer.xaml b/CallApp.Tizen/Call/View/Controls/Dialer.xaml
new file mode 100644 (file)
index 0000000..ddabb44
--- /dev/null
@@ -0,0 +1,29 @@
+<?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.Controls.Dialer"
+             x:Name="This"
+             xmlns:CallControls="clr-namespace:CallApp.Tizen.Call.View.Controls"
+             xmlns:Extension="clr-namespace:Tizen.Xamarin.Forms.Extension;assembly=Tizen.Xamarin.Forms.Extension"
+             xmlns:TizenUtilityControls="clr-namespace:Tizen.Utility.Controls"
+             IsVisible="False">
+
+    <StackLayout>
+        <Label Margin="32,24,0,0" HorizontalOptions="Start" TextColor="{StaticResource DefaultTextColor}"
+               FontSize="27" Text="{Binding StatusText, Source={x:Reference This}}" />
+
+        <TizenUtilityControls:CustomEntry x:Name="xEntry" VerticalOptions="CenterAndExpand"
+                                          KeyboardType="None" HorizontalTextAlignment="Center"
+                                          TextColor="{StaticResource DefaultTextColor}" FontSize="56" />
+
+        <ContentView HeightRequest="80">
+            <Image HeightRequest="44" Source="keypad_predictive_arrow.png">
+                <Image.GestureRecognizers>
+                    <Extension:LongTapGestureRecognizer TapStarted="OnClose" />
+                </Image.GestureRecognizers>
+            </Image>
+        </ContentView>
+
+        <CallControls:Keypad x:Name="xKeypad" />
+    </StackLayout>
+</ContentView>
\ No newline at end of file
diff --git a/CallApp.Tizen/Call/View/Controls/Dialer.xaml.cs b/CallApp.Tizen/Call/View/Controls/Dialer.xaml.cs
new file mode 100644 (file)
index 0000000..bd0abbe
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * 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 CallApp.Tizen.Call.View.Controls
+{
+    /// <summary>
+    /// Presents handling of Keypad
+    /// </summary>
+    public partial class Dialer : ContentView
+    {
+        public Dialer()
+        {
+            InitializeComponent();
+
+            xKeypad.KeyPush = new Command(OnKeyPushed);
+        }
+
+        /// <summary>
+        /// Gets or sets a status text
+        /// </summary>
+        public static readonly BindableProperty StatusTextProperty = BindableProperty.Create(
+            "StatusText",
+            typeof(string),
+            typeof(Dialer),
+            string.Empty);
+
+        public string StatusText
+        {
+            get
+            {
+                return (string)GetValue(StatusTextProperty);
+            }
+
+            set
+            {
+                SetValue(StatusTextProperty, value);
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets a value that indicates whether the dialer is currently opened
+        /// </summary>
+        public static readonly BindableProperty IsOpenProperty = BindableProperty.Create(
+            "IsOpen",
+            typeof(bool),
+            typeof(Dialer),
+            false,
+            propertyChanged: OnIsOpenChanged);
+
+        public bool IsOpen
+        {
+            get
+            {
+                return (bool)GetValue(IsOpenProperty);
+            }
+
+            set
+            {
+                SetValue(IsOpenProperty, value);
+            }
+        }
+
+        private void OnKeyPushed(object obj)
+        {
+            xEntry.Text = xEntry.Text.Insert(xEntry.CursorPosition, obj.ToString());
+        }
+
+        private static void OnIsOpenChanged(BindableObject bindable, object oldValue, object newValue)
+        {
+            if (bindable is Dialer self)
+            {
+                self.IsVisible = (bool)newValue;
+            }
+        }
+
+        private void OnClose(object sender, EventArgs e)
+        {
+            IsOpen = false;
+        }
+    }
+}
index e2259f2..a964157 100644 (file)
@@ -27,5 +27,27 @@ namespace CallApp.Tizen.Call.View.Controls
         {
             InitializeComponent();
         }
+
+        /// <summary>
+        /// Gets or sets a command to invoke when key is pushed
+        /// </summary>
+        public static readonly BindableProperty KeyPushProperty = BindableProperty.Create(
+            "KeyPush",
+            typeof(Command),
+            typeof(Keypad),
+            null);
+
+        public Command KeyPush
+        {
+            get
+            {
+                return (Command)GetValue(KeyPushProperty);
+            }
+
+            set
+            {
+                SetValue(KeyPushProperty, value);
+            }
+        }
     }
 }
index 6bc6f1b..200fcc7 100644 (file)
@@ -81,6 +81,9 @@
     <Compile Include="Call\View\Controls\CallHandlingPanel.xaml.cs">
       <DependentUpon>CallHandlingPanel.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Call\View\Controls\Dialer.xaml.cs">
+      <DependentUpon>Dialer.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Call\View\Controls\Keypad.xaml.cs">
       <DependentUpon>Keypad.xaml</DependentUpon>
     </Compile>
     <Compile Include="Common\Themes\CommonTheme.xaml.cs">
       <DependentUpon>CommonTheme.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Tizen.Utility\Controls\CustomContentView.xaml.cs">
+      <DependentUpon>CustomContentView.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Tizen.Utility\Controls\CustomEntry.xaml.cs">
+      <DependentUpon>CustomEntry.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Tizen.Utility\Controls\CustomGrid.xaml.cs">
       <DependentUpon>CustomGrid.xaml</DependentUpon>
     </Compile>
     <Compile Include="Tizen.Utility\Controls\GesturesContainer.xaml.cs">
       <DependentUpon>GesturesContainer.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Tizen.Utility\Controls\Renderers\CustomEntryRenderer.cs" />
     <Compile Include="Tizen.Utility\Controls\Renderers\CustomImageRenderer.cs" />
     <Compile Include="Tizen.Utility\Converters\TypeToNameConverter.cs" />
     <Compile Include="Tizen.Utility\Converters\IsStringEmptyConverter.cs" />
     <Folder Include="lib\" />
   </ItemGroup>
   <ItemGroup>
+    <Content Include="res\Call ID\348x348\call_photo_id.png" />
     <Content Include="res\Call ID\348x348\call_photo_id_emergency.png" />
     <Content Include="res\call_active_ic_call.png" />
     <Content Include="res\call_btn_addcall.png" />
     <Content Include="res\keypad_number_09.png" />
     <Content Include="res\keypad_number_asterisk.png" />
     <Content Include="res\keypad_number_sharp.png" />
+    <Content Include="res\keypad_predictive_arrow.png" />
     <Content Include="shared\res\icon.png" />
   </ItemGroup>
   <ItemGroup>
       <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
     </EmbeddedResource>
   </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Tizen.Utility\Controls\CustomContentView.xaml">
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Call\View\Controls\Dialer.xaml">
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Tizen.Utility\Controls\CustomEntry.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.
diff --git a/CallApp.Tizen/Tizen.Utility/Controls/CustomContentView.xaml b/CallApp.Tizen/Tizen.Utility/Controls/CustomContentView.xaml
new file mode 100644 (file)
index 0000000..930dc52
--- /dev/null
@@ -0,0 +1,10 @@
+<?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="Tizen.Utility.Controls.CustomContentView"
+             xmlns:Extension="clr-namespace:Tizen.Xamarin.Forms.Extension;assembly=Tizen.Xamarin.Forms.Extension">
+
+    <ContentView.GestureRecognizers>
+        <Extension:LongTapGestureRecognizer TapStarted="OnTap" />
+    </ContentView.GestureRecognizers>
+</ContentView>
\ No newline at end of file
diff --git a/CallApp.Tizen/Tizen.Utility/Controls/CustomContentView.xaml.cs b/CallApp.Tizen/Tizen.Utility/Controls/CustomContentView.xaml.cs
new file mode 100644 (file)
index 0000000..e363ec0
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * 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 Tizen.Utility.Controls
+{
+    /// <summary>
+    /// Extension of Xamarin ContentView, with support:
+    /// Command pattern
+    /// </summary>
+    public partial class CustomContentView : ContentView
+    {
+        public CustomContentView()
+        {
+            InitializeComponent();
+        }
+
+        /// <summary>
+        /// Gets or sets the command to invoke when this control is tapped
+        /// </summary>
+        public static readonly BindableProperty CommandProperty = BindableProperty.Create(
+            "Command",
+            typeof(Command),
+            typeof(CustomContentView),
+            null,
+            propertyChanged: OnCommandChanged);
+
+        public Command Command
+        {
+            get
+            {
+                return (Command)GetValue(CommandProperty);
+            }
+
+            set
+            {
+                SetValue(CommandProperty, value);
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets the parameter to pass to the Command property
+        /// </summary>
+        public static readonly BindableProperty CommandParameterProperty = BindableProperty.Create(
+            "CommandParameter",
+            typeof(string),
+            typeof(CustomContentView),
+            string.Empty);
+
+        public string CommandParameter
+        {
+            get
+            {
+                return (string)GetValue(CommandParameterProperty);
+            }
+
+            set
+            {
+                SetValue(CommandParameterProperty, value);
+            }
+        }
+
+        protected virtual void OnTap(object sender, EventArgs e)
+        {
+            if (Command != null && Command.CanExecute(CommandParameter))
+            {
+                Command.Execute(CommandParameter);
+            }
+        }
+
+        private static void OnCommandChanged(BindableObject bindable, object oldValue, object newValue)
+        {
+            if (bindable is CustomContentView self)
+            {
+                if (oldValue is Command oldCommand)
+                {
+                    oldCommand.CanExecuteChanged -= OnCommandCanExecuteChanged;
+                }
+
+                if (newValue is Command newCommand)
+                {
+                    self.IsEnabled = newCommand.CanExecute(self.CommandParameter);
+
+                    newCommand.CanExecuteChanged += OnCommandCanExecuteChanged;
+                }
+            }
+        }
+
+        private static void OnCommandCanExecuteChanged(object sender, EventArgs e)
+        {
+            if (sender is CustomContentView self)
+            {
+                self.IsEnabled = self.Command.CanExecute(self.CommandParameter);
+            }
+        }
+    }
+}
diff --git a/CallApp.Tizen/Tizen.Utility/Controls/CustomEntry.xaml b/CallApp.Tizen/Tizen.Utility/Controls/CustomEntry.xaml
new file mode 100644 (file)
index 0000000..2f6f207
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<Entry xmlns="http://xamarin.com/schemas/2014/forms"
+       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+       x:Class="Tizen.Utility.Controls.CustomEntry">
+
+</Entry>
\ No newline at end of file
diff --git a/CallApp.Tizen/Tizen.Utility/Controls/CustomEntry.xaml.cs b/CallApp.Tizen/Tizen.Utility/Controls/CustomEntry.xaml.cs
new file mode 100644 (file)
index 0000000..6496f97
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * 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;
+using Native = Xamarin.Forms.Platform.Tizen.Native;
+
+namespace Tizen.Utility.Controls
+{
+    /// <summary>
+    /// Extension of Xamarin Entry, with support:
+    /// Keyboard type
+    /// Cursor position
+    /// </summary>
+    public partial class CustomEntry : Entry
+    {
+        public CustomEntry()
+        {
+            InitializeComponent();
+        }
+
+        /// <summary>
+        /// Gets or sets the keyboard type
+        /// </summary>
+        public static readonly BindableProperty KeyboardTypeProperty = BindableProperty.Create(
+            "KeyboardType",
+            typeof(Native.Keyboard),
+            typeof(CustomEntry),
+            Native.Keyboard.Normal);
+
+        public Native.Keyboard KeyboardType
+        {
+            get
+            {
+                return (Native.Keyboard)GetValue(KeyboardTypeProperty);
+            }
+
+            set
+            {
+                SetValue(KeyboardTypeProperty, value);
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets the cursor position
+        /// </summary>
+        public static readonly BindableProperty CursorPositionProperty = BindableProperty.Create(
+            "CursorPosition",
+            typeof(int),
+            typeof(CustomEntry),
+            0);
+
+        public int CursorPosition
+        {
+            get
+            {
+                return (int)GetValue(CursorPositionProperty);
+            }
+
+            set
+            {
+                SetValue(CursorPositionProperty, value);
+            }
+        }
+    }
+}
index 63a6038..5d5f46d 100644 (file)
@@ -36,9 +36,15 @@ namespace Tizen.Utility.Controls
         {
             InitializeComponent();
 
+            _pan.PanUpdated += OnPanUpdated;
+
             // Need to use last event during loading control. At this case it's a SizeChanged event
             SizeChanged += OnSizeChanged;
-            _pan.PanUpdated += OnPanUpdated;
+        }
+
+        private void OnPanUpdated(object sender, PanUpdatedEventArgs e)
+        {
+            PanUpdated(sender, e);
         }
 
         private void OnSizeChanged(object sender, EventArgs e)
@@ -49,10 +55,5 @@ namespace Tizen.Utility.Controls
                 GestureRecognizers.Add(_pan);
             }
         }
-
-        private void OnPanUpdated(object sender, PanUpdatedEventArgs e)
-        {
-            PanUpdated(sender, e);
-        }
     }
 }
diff --git a/CallApp.Tizen/Tizen.Utility/Controls/Renderers/CustomEntryRenderer.cs b/CallApp.Tizen/Tizen.Utility/Controls/Renderers/CustomEntryRenderer.cs
new file mode 100644 (file)
index 0000000..8f5695e
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * 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.ComponentModel;
+using Tizen.Utility.Controls;
+using Tizen.Utility.Controls.Renderers;
+using Xamarin.Forms;
+using Xamarin.Forms.Platform.Tizen;
+using Native = Xamarin.Forms.Platform.Tizen.Native;
+
+[assembly: ExportRenderer(typeof(CustomEntry), typeof(CustomEntryRenderer))]
+namespace Tizen.Utility.Controls.Renderers
+{
+    /// <summary>
+    /// A renderer for CustomEntry
+    /// </summary>
+    public class CustomEntryRenderer : EntryRenderer
+    {
+        private CustomEntry xamarinEntry = null;
+        private Native.Entry nativeEntry = null;
+
+        protected override void Dispose(bool disposing)
+        {
+            if (nativeEntry != null)
+            {
+                nativeEntry.CursorChanged -= OnCursorChanged;
+                nativeEntry = null;
+            }
+
+            base.Dispose(disposing);
+        }
+
+        /// <summary cref="EntryRenderer.OnElementChanged(ElementChangedEventArgs{Entry})" />
+        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
+        {
+            base.OnElementChanged(e);
+
+            if (xamarinEntry == null)
+            {
+                xamarinEntry = (CustomEntry)Element;
+            }
+
+            if (nativeEntry == null)
+            {
+                nativeEntry = Control;
+                nativeEntry.Keyboard = xamarinEntry.KeyboardType;
+                nativeEntry.CursorChanged += OnCursorChanged;
+            }
+        }
+
+        /// <summary cref="EntryRenderer.OnElementPropertyChanged(object, PropertyChangedEventArgs)" />
+        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+        {
+            base.OnElementPropertyChanged(sender, e);
+
+            // TODO: This is not working, seems a bug - http://suprem.sec.samsung.net/jira/browse/TCAPI-2528
+            /*
+            if (e.PropertyName == CustomEntry.KeyboardTypeProperty.PropertyName)
+            {
+                nativeEntry.Keyboard = xamarinEntry.KeyboardType;
+            }
+            */
+
+            nativeEntry.Keyboard = xamarinEntry.KeyboardType;
+        }
+
+        private void OnCursorChanged(object sender, EventArgs e)
+        {
+            xamarinEntry.CursorPosition = nativeEntry.CursorPosition;
+        }
+    }
+}
diff --git a/CallApp.Tizen/res/Call ID/348x348/call_photo_id.png b/CallApp.Tizen/res/Call ID/348x348/call_photo_id.png
new file mode 100644 (file)
index 0000000..ebdee4a
Binary files /dev/null and b/CallApp.Tizen/res/Call ID/348x348/call_photo_id.png differ
diff --git a/CallApp.Tizen/res/keypad_predictive_arrow.png b/CallApp.Tizen/res/keypad_predictive_arrow.png
new file mode 100644 (file)
index 0000000..7617f4e
Binary files /dev/null and b/CallApp.Tizen/res/keypad_predictive_arrow.png differ