Fixed the issue that X.F app creates two windows (#219)
author유리나/Common Platform Lab(SR)/Staff Engineer/삼성전자 <rina6350.you@samsung.com>
Wed, 13 May 2020 02:49:04 +0000 (11:49 +0900)
committer윤정현/Common Platform Lab(SR)/Staff Engineer/삼성전자 <jh0506.yun@samsung.com>
Wed, 13 May 2020 02:49:04 +0000 (11:49 +0900)
* Fixed the issue that X.F app creates two windows

* Move the position of calling factory method of native object

packages/tizen.net.7.0.0.15140.nupkg [new file with mode: 0644]
packages/tizen.net.api7.7.0.0.15140.nupkg [new file with mode: 0644]
src/XSF/XSF.csproj
src/XSF/Xamarin.Forms.Platform.Tizen/Forms.cs
src/XSF/Xamarin.Forms.Platform.Tizen/FormsApplication.cs
src/XSF/Xamarin.Forms.Platform.Tizen/PreloadedWindow.cs
src/XSF/ibc/XSF.ibc

diff --git a/packages/tizen.net.7.0.0.15140.nupkg b/packages/tizen.net.7.0.0.15140.nupkg
new file mode 100644 (file)
index 0000000..7c54a5f
Binary files /dev/null and b/packages/tizen.net.7.0.0.15140.nupkg differ
diff --git a/packages/tizen.net.api7.7.0.0.15140.nupkg b/packages/tizen.net.api7.7.0.0.15140.nupkg
new file mode 100644 (file)
index 0000000..0297c97
Binary files /dev/null and b/packages/tizen.net.api7.7.0.0.15140.nupkg differ
index 317f478..7128a79 100644 (file)
@@ -11,7 +11,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="Tizen.NET" Version="6.0.0.14995" />
+    <PackageReference Include="Tizen.NET" Version="7.0.0.15140" />
     <PackageReference Include="System.Memory" Version="4.5.3" />
   </ItemGroup>
 
index 9706a34..9526161 100644 (file)
@@ -14,6 +14,7 @@ using EWindow = ElmSharp.Window;
 using ELayout = ElmSharp.Layout;
 using DeviceOrientation = Xamarin.Forms.Internals.DeviceOrientation;
 using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
+using PTizen = Xamarin.Forms.Platform.Tizen;
 using ElmSharp.Wearable;
 using Tizen.Wearable.CircularUI.Forms;
 
@@ -664,28 +665,6 @@ namespace Xamarin.Forms
                        Init(dummyApp, false);
                        IsPreloaded = true;
 
-                       EWindow eWindow = null;
-                       ELayout eLayout = null;
-                       CircleSurface eCircleSurface = null;
-                       var typeWin = typeof(EWindow);
-                       var methodInfo = typeWin.GetMethod("CreateWindow", BindingFlags.NonPublic | BindingFlags.Static);
-                       if (methodInfo != null)
-                       {
-                               eWindow = (EWindow)methodInfo.Invoke(null, new object[] { "FormsWindow" });
-                               eLayout = (ELayout)eWindow.GetType().GetProperty("BaseLayout")?.GetValue(eWindow);
-                               eCircleSurface = (CircleSurface)eWindow.GetType().GetProperty("BaseCircleSurface")?.GetValue(eWindow);
-                       }
-
-                       PreloadedWindow preloadedWindow = null;
-                       if (eWindow != null && eLayout != null)
-                       {
-                               preloadedWindow = new PreloadedWindow(eWindow, eLayout, eCircleSurface);
-                       }
-                       else
-                       {
-                               preloadedWindow = new PreloadedWindow();
-                       }
-
                        var locale = TSystemSetting.LocaleLanguage;
                        TSystemSetting.LocaleLanguageChanged += DummyHandler;
                        TSystemSetting.LocaleLanguageChanged -= DummyHandler;
@@ -749,9 +728,17 @@ namespace Xamarin.Forms
                        {
                                System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(type.TypeHandle);
                        }
-                       global::Xamarin.Forms.Platform.Tizen.Native.NativeFactory.PrecreateNatives(preloadedWindow.Window);
-                       global::Tizen.Wearable.CircularUI.Forms.CircularUIForms.Preload(preloadedWindow.Window);
 
+                       PTizen.PreloadedWindow preloadedWindow = new PTizen.PreloadedWindow();
+                       if (preloadedWindow.Window != null)
+                       {
+                               global::Xamarin.Forms.Platform.Tizen.Native.NativeFactory.PrecreateNatives(preloadedWindow.Window);
+                               global::Tizen.Wearable.CircularUI.Forms.CircularUIForms.Preload(preloadedWindow.Window);
+                       }
+                       else
+                       {
+                               Console.WriteLine("PreloadedWindow is null");
+                       }
                        return preloadedWindow.Window;
                }
        }
index cbe2f0b..9a5b878 100644 (file)
@@ -62,18 +62,10 @@ namespace Xamarin.Forms.Platform.Tizen
                {
                        base.OnPreCreate();
                        Application.ClearCurrent();
-                       PreloadedWindow window = PreloadedWindow.GetInstance() ?? new PreloadedWindow();
+                       PreloadedWindow window = PreloadedWindow.GetInstance() ?? new PreloadedWindow(false);
 
                        MainWindow = window.Window;
-                       MainWindow.Show();
-                       if (window.BaseConformant != null)
-                       {
-                               window.BaseConformant.Show();
-                       }
-
                        BaseLayout = window.BaseLayout;
-                       BaseLayout.Show();
-
                        BaseCircleSurface = window.BaseCircleSurface;
                        Forms.CircleSurface = BaseCircleSurface;
                }
index cd6bd5d..856ed39 100644 (file)
@@ -1,7 +1,9 @@
 using ElmSharp;
 using ElmSharp.Wearable;
+using EWindow = ElmSharp.Window;
 using ELayout = ElmSharp.Layout;
-using EConformant = ElmSharp.Conformant;
+using System.Reflection;
+using System;
 
 namespace Xamarin.Forms.Platform.Tizen
 {
@@ -9,18 +11,9 @@ namespace Xamarin.Forms.Platform.Tizen
        {
                static PreloadedWindow s_precreated;
 
-               public PreloadedWindow()
+               public PreloadedWindow(bool useReflection = true)
                {
-                       s_precreated = this;
-                       Initialize();
-               }
-
-               public PreloadedWindow(Window win, ELayout layout, CircleSurface circleSurface)
-               {
-                       s_precreated = this;
-                       Window = win;
-                       BaseLayout = layout;
-                       BaseCircleSurface = circleSurface;
+                       Initialize(useReflection);
                }
 
                public Window Window
@@ -29,12 +22,6 @@ namespace Xamarin.Forms.Platform.Tizen
                        protected set;
                }
 
-               public EConformant BaseConformant
-               {
-                       get;
-                       protected set;
-               }
-
                public ELayout BaseLayout
                {
                        get;
@@ -46,23 +33,40 @@ namespace Xamarin.Forms.Platform.Tizen
                        get; protected set;
                }
 
-               protected void Initialize()
+               protected void Initialize(bool useReflection = true)
                {
-                       Window = new Window("FormsWindow");
+                       if (useReflection)
+                       {
+                               var typeWin = typeof(ElmSharp.PreloadedWindow);
+                               var methodInfo = typeWin.GetMethod("PeekInstance", BindingFlags.Public | BindingFlags.Static);
+                               if (methodInfo != null)
+                               {
+                                       Window = (EWindow)methodInfo.Invoke(null, null);
+                                       BaseLayout = (ELayout)Window?.GetType().GetProperty("BaseLayout")?.GetValue(Window);
+                                       BaseCircleSurface = (CircleSurface)Window?.GetType().GetProperty("BaseCircleSurface")?.GetValue(Window);
+                                       s_precreated = this;
+                               }
+                       }
+                       else
+                       {
+                               Window = new Window("FormsWindow");
+                               Window.Show();
 
-                       var conformant = new Conformant(Window);
-                       BaseConformant = conformant;
+                               var conformant = new Conformant(Window);
+                               conformant.Show();
 
-                       var layout = new ELayout(conformant);
-                       layout.SetTheme("layout", "application", "default");                    
+                               var layout = new ELayout(conformant);
+                               layout.SetTheme("layout", "application", "default");
 
-                       BaseLayout = layout;
+                               BaseLayout = layout;
+                               BaseLayout.Show();
 
-                       if (Device.Idiom == TargetIdiom.Watch)
-                       {
-                               BaseCircleSurface = new CircleSurface(conformant);
+                               if (Device.Idiom == TargetIdiom.Watch)
+                               {
+                                       BaseCircleSurface = new CircleSurface(conformant);
+                               }
+                               conformant.SetContent(BaseLayout);
                        }
-                       conformant.SetContent(BaseLayout);
                }
 
                public static PreloadedWindow GetInstance()
index 5fb4bad..7f8a81d 100644 (file)
Binary files a/src/XSF/ibc/XSF.ibc and b/src/XSF/ibc/XSF.ibc differ