diff --git a/src/Tizen.Wearable.CircularUI.Forms.Renderer/CirclePageRenderer.cs b/src/Tizen.Wearable.CircularUI.Forms.Renderer/CirclePageRenderer.cs index 89a55af2..d3e46c0f 100644 --- a/src/Tizen.Wearable.CircularUI.Forms.Renderer/CirclePageRenderer.cs +++ b/src/Tizen.Wearable.CircularUI.Forms.Renderer/CirclePageRenderer.cs @@ -26,6 +26,7 @@ using Xamarin.Forms.Platform.Tizen; using Xamarin.Forms.Platform.Tizen.Native; using XForms = Xamarin.Forms.Forms; +using ERotaryEventManager = ElmSharp.Wearable.RotaryEventManager; using XToolbarItem = Xamarin.Forms.ToolbarItem; @@ -428,7 +429,7 @@ void ActivateRotaryWidget() { if (_currentRotaryFocusObject is IRotaryEventReceiver) { - RotaryEventManager.Rotated += OnRotaryEventChanged; + ERotaryEventManager.Rotated += OnRotaryEventChanged; } else if (_currentRotaryFocusObject is IRotaryFocusable) { @@ -439,7 +440,7 @@ void DeactivateRotaryWidget() { if (_currentRotaryFocusObject is IRotaryEventReceiver) { - RotaryEventManager.Rotated -= OnRotaryEventChanged; + ERotaryEventManager.Rotated -= OnRotaryEventChanged; } else if (_currentRotaryFocusObject is IRotaryFocusable) { diff --git a/src/Tizen.Wearable.CircularUI.Forms.Renderer/CircularUI.cs b/src/Tizen.Wearable.CircularUI.Forms.Renderer/CircularUI.cs index 0ec91036..72f3a526 100644 --- a/src/Tizen.Wearable.CircularUI.Forms.Renderer/CircularUI.cs +++ b/src/Tizen.Wearable.CircularUI.Forms.Renderer/CircularUI.cs @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -using ElmSharp; using System.Diagnostics; using Tizen.Applications; @@ -51,7 +50,6 @@ public static void Init() public static void Init(string apiKey) { - if (!string.IsNullOrEmpty(apiKey)) { GoogleMaps.Init(apiKey); @@ -60,7 +58,6 @@ public static void Init(string apiKey) { Debug.Assert(!string.IsNullOrEmpty(apiKey), "apiKey is null or empty!"); } - Init(); } diff --git a/src/Tizen.Wearable.CircularUI.Forms.Renderer/FlatViewCellRenderer.cs b/src/Tizen.Wearable.CircularUI.Forms.Renderer/FlatViewCellRenderer.cs new file mode 100644 index 00000000..6d64c6ee --- /dev/null +++ b/src/Tizen.Wearable.CircularUI.Forms.Renderer/FlatViewCellRenderer.cs @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 Tizen.Wearable.CircularUI.Forms; +using Tizen.Wearable.CircularUI.Forms.Renderer; +using Xamarin.Forms; +using Xamarin.Forms.Platform.Tizen; + +[assembly: ExportRenderer(typeof(FlatViewCell), typeof(FlatViewCellRenderer))] +namespace Tizen.Wearable.CircularUI.Forms.Renderer +{ + public class FlatViewCellRenderer : ViewCellRenderer + { + public FlatViewCellRenderer() + { + Style = "full_effect_off"; + } + } +} diff --git a/src/Tizen.Wearable.CircularUI.Forms.Renderer/RotaryService.cs b/src/Tizen.Wearable.CircularUI.Forms.Renderer/RotaryService.cs new file mode 100644 index 00000000..530361e6 --- /dev/null +++ b/src/Tizen.Wearable.CircularUI.Forms.Renderer/RotaryService.cs @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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; +using ERotaryEventManager = ElmSharp.Wearable.RotaryEventManager; +using ERotaryEventArgs = ElmSharp.Wearable.RotaryEventArgs; + +[assembly: Dependency(typeof(Tizen.Wearable.CircularUI.Forms.Renderer.RotaryService))] +namespace Tizen.Wearable.CircularUI.Forms.Renderer +{ + public class RotaryService : IRotaryService + { + EventHandler _rotated; + + public event EventHandler Rotated + { + add + { + if (_rotated == null) + { + ERotaryEventManager.Rotated += OnRotaryChanged; + } + _rotated += value; + } + remove + { + _rotated -= value; + if (_rotated == null) + { + ERotaryEventManager.Rotated -= OnRotaryChanged; + } + } + } + + void OnRotaryChanged(ERotaryEventArgs args) + { + _rotated?.Invoke(this, new RotaryEventArgs() { IsClockwise = args.IsClockwise }); + } + } +} diff --git a/src/Tizen.Wearable.CircularUI.Forms.Renderer/Shell/NavigationDrawer.cs b/src/Tizen.Wearable.CircularUI.Forms.Renderer/Shell/NavigationDrawer.cs index 3e0cb463..937aa4af 100644 --- a/src/Tizen.Wearable.CircularUI.Forms.Renderer/Shell/NavigationDrawer.cs +++ b/src/Tizen.Wearable.CircularUI.Forms.Renderer/Shell/NavigationDrawer.cs @@ -10,6 +10,7 @@ using ELayout = ElmSharp.Layout; using EWidget = ElmSharp.Widget; using EButton = ElmSharp.Button; +using ERotaryEventManager = ElmSharp.Wearable.RotaryEventManager; namespace Tizen.Wearable.CircularUI.Forms.Renderer { @@ -262,7 +263,7 @@ void InitializeDrawerBox() _gestureOnDrawer.SetMomentumCallback(GestureLayer.GestureState.Abort, OnDrawerDragEnded); _gestureOnDrawer.Attach(_drawerIconBox); - RotaryEventManager.Rotated += OnRotateEventReceived; + ERotaryEventManager.Rotated += OnRotateEventReceived; } void SetDrawerIcon(ImageSource source) diff --git a/src/Tizen.Wearable.CircularUI.Forms.Renderer/TizenCircleSurfaceEffect.cs b/src/Tizen.Wearable.CircularUI.Forms.Renderer/TizenCircleSurfaceEffect.cs index 4ca61bae..d1198817 100644 --- a/src/Tizen.Wearable.CircularUI.Forms.Renderer/TizenCircleSurfaceEffect.cs +++ b/src/Tizen.Wearable.CircularUI.Forms.Renderer/TizenCircleSurfaceEffect.cs @@ -23,6 +23,7 @@ using Xamarin.Forms; using Xamarin.Forms.Platform.Tizen; using XForms = Xamarin.Forms.Forms; +using ERotaryEventManager = ElmSharp.Wearable.RotaryEventManager; [assembly: ExportEffect(typeof(Tizen.Wearable.CircularUI.Forms.Renderer.TizenCircleSurfaceEffect), "CircleSurfaceEffect")] namespace Tizen.Wearable.CircularUI.Forms.Renderer @@ -151,7 +152,7 @@ void ActivateRotaryFocusable(IRotaryFocusable focusable) if (focusable is IRotaryEventReceiver) { _rotaryReceiver = focusable as IRotaryEventReceiver; - RotaryEventManager.Rotated += OnRotaryEventChanged; + ERotaryEventManager.Rotated += OnRotaryEventChanged; } else if (focusable is IRotaryFocusable) { @@ -169,7 +170,7 @@ void DeativateRotaryFocusable(IRotaryFocusable focusable) if (focusable is IRotaryEventReceiver) { _rotaryReceiver = null; - RotaryEventManager.Rotated -= OnRotaryEventChanged; + ERotaryEventManager.Rotated -= OnRotaryEventChanged; } else if (focusable is IRotaryFocusable) { diff --git a/src/Tizen.Wearable.CircularUI.Forms/FlatViewCell.cs b/src/Tizen.Wearable.CircularUI.Forms/FlatViewCell.cs new file mode 100644 index 00000000..43b2d24a --- /dev/null +++ b/src/Tizen.Wearable.CircularUI.Forms/FlatViewCell.cs @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 Tizen.Wearable.CircularUI.Forms +{ + /// + /// FlatViewCell contains a developer-defined Xamarin.Forms.View. + /// It has no fish-eye effect while ViewCell has fish-eye effect. + /// + /// 6 + public class FlatViewCell : ViewCell + { + } +} diff --git a/src/Tizen.Wearable.CircularUI.Forms/IRotaryService.cs b/src/Tizen.Wearable.CircularUI.Forms/IRotaryService.cs new file mode 100644 index 00000000..3b2566d9 --- /dev/null +++ b/src/Tizen.Wearable.CircularUI.Forms/IRotaryService.cs @@ -0,0 +1,9 @@ +using System; + +namespace Tizen.Wearable.CircularUI.Forms +{ + interface IRotaryService + { + event EventHandler Rotated; + } +} diff --git a/src/Tizen.Wearable.CircularUI.Forms/RotaryEventHandler.cs b/src/Tizen.Wearable.CircularUI.Forms/RotaryEventHandler.cs old mode 100755 new mode 100644 diff --git a/src/Tizen.Wearable.CircularUI.Forms/RotaryEventManager.cs b/src/Tizen.Wearable.CircularUI.Forms/RotaryEventManager.cs new file mode 100644 index 00000000..d044b998 --- /dev/null +++ b/src/Tizen.Wearable.CircularUI.Forms/RotaryEventManager.cs @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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.Wearable.CircularUI.Forms +{ + /// + /// The RotaryEventManager provides an event for the global rotary event for wearable devices. + /// + /// 4 + /// + /// + /// RotaryEventManager.Rotated += (s, e) => + /// { + /// Console.WriteLine($"Rotated! Rotated direction: ${e.IsClockwise}"); + /// }; + /// + /// + public static class RotaryEventManager + { + static IRotaryService ProxyService { get; } = DependencyService.Get(); + + /// + /// Rotated will be triggered when the rotatable device's Bezel is rotated. + /// + public static event EventHandler Rotated + { + add + { + ProxyService.Rotated += value; + } + remove + { + ProxyService.Rotated -= value; + } + } + } +} diff --git a/test/WearableUIGallery/WearableUIGallery/TC/TCCircleListViewNoItemEffect.xaml b/test/WearableUIGallery/WearableUIGallery/TC/TCCircleListViewNoItemEffect.xaml new file mode 100644 index 00000000..6d7fac9c --- /dev/null +++ b/test/WearableUIGallery/WearableUIGallery/TC/TCCircleListViewNoItemEffect.xaml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + Item 1 + Item 2 + Item 3 + Item 4 + Item 5 + + + + Header + + + Footer + + + + + + + + + + + + \ No newline at end of file diff --git a/test/WearableUIGallery/WearableUIGallery/TC/TCCircleListViewNoItemEffect.xaml.cs b/test/WearableUIGallery/WearableUIGallery/TC/TCCircleListViewNoItemEffect.xaml.cs new file mode 100644 index 00000000..913ccfef --- /dev/null +++ b/test/WearableUIGallery/WearableUIGallery/TC/TCCircleListViewNoItemEffect.xaml.cs @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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; +using Tizen.Wearable.CircularUI.Forms; +using Xamarin.Forms.Xaml; + +namespace WearableUIGallery.TC +{ + + public class MyItemSelector : DataTemplateSelector + { + public DataTemplate FlatItemTemplate { get; set; } + + public DataTemplate NormalItemTemplate { get; set; } + + protected override DataTemplate OnSelectTemplate(object item, BindableObject container) + { + if (item.ToString().Contains("Item 1")) + { + return FlatItemTemplate; + } + else + { + return NormalItemTemplate; + } + } + } + + [XamlCompilation(XamlCompilationOptions.Compile)] + public partial class TCCircleListViewNoItemEffect : CirclePage + { + public TCCircleListViewNoItemEffect() + { + InitializeComponent (); + Console.WriteLine($"location = {Shell.Current.CurrentState.Location.ToString()}"); + } + + public void OnItemTapped(object sender, ItemTappedEventArgs args) + { + Console.WriteLine($"OnItemTapped Item:{args.Item.ToString()}"); + } + } +} \ No newline at end of file diff --git a/test/WearableUIGallery/WearableUIGallery/TCData.cs b/test/WearableUIGallery/WearableUIGallery/TCData.cs index 23b76c1d..65ed4a37 100644 --- a/test/WearableUIGallery/WearableUIGallery/TCData.cs +++ b/test/WearableUIGallery/WearableUIGallery/TCData.cs @@ -44,6 +44,7 @@ static TCData() Class = new TCTypes { new TCDescribe { Title = "NoFishEyeHeaderList", Class = typeof(TCCircleListViewNoEffect) }, + new TCDescribe { Title = "NoFishEyeItemList", Class = typeof(TCCircleListViewNoItemEffect) }, new TCDescribe { Title = "CircleListBehavior", Class = typeof(TCListAppender) }, new TCDescribe { Title = "GroupList", Class = typeof(TCGroupList) }, new TCDescribe { Title = "CircleListView", Class = typeof(TCCircleListView) },