From: 유리나/Common Platform Lab(SR)/Staff Engineer/삼성전자 Date: Wed, 13 May 2020 02:49:04 +0000 (+0900) Subject: Fixed the issue that X.F app creates two windows (#219) X-Git-Tag: accepted/tizen/5.5/unified/20200602.155421~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d74e9b4935ed18584f610686093eeb154b70a07c;p=platform%2Fcore%2Fcsapi%2Fxsf.git Fixed the issue that X.F app creates two windows (#219) * Fixed the issue that X.F app creates two windows * Move the position of calling factory method of native object --- diff --git a/packages/tizen.net.7.0.0.15140.nupkg b/packages/tizen.net.7.0.0.15140.nupkg new file mode 100644 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 index 0000000..0297c97 Binary files /dev/null and b/packages/tizen.net.api7.7.0.0.15140.nupkg differ diff --git a/src/XSF/XSF.csproj b/src/XSF/XSF.csproj index 317f478..7128a79 100644 --- a/src/XSF/XSF.csproj +++ b/src/XSF/XSF.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/XSF/Xamarin.Forms.Platform.Tizen/Forms.cs b/src/XSF/Xamarin.Forms.Platform.Tizen/Forms.cs index 9706a34..9526161 100644 --- a/src/XSF/Xamarin.Forms.Platform.Tizen/Forms.cs +++ b/src/XSF/Xamarin.Forms.Platform.Tizen/Forms.cs @@ -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; } } diff --git a/src/XSF/Xamarin.Forms.Platform.Tizen/FormsApplication.cs b/src/XSF/Xamarin.Forms.Platform.Tizen/FormsApplication.cs index cbe2f0b..9a5b878 100644 --- a/src/XSF/Xamarin.Forms.Platform.Tizen/FormsApplication.cs +++ b/src/XSF/Xamarin.Forms.Platform.Tizen/FormsApplication.cs @@ -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; } diff --git a/src/XSF/Xamarin.Forms.Platform.Tizen/PreloadedWindow.cs b/src/XSF/Xamarin.Forms.Platform.Tizen/PreloadedWindow.cs index cd6bd5d..856ed39 100644 --- a/src/XSF/Xamarin.Forms.Platform.Tizen/PreloadedWindow.cs +++ b/src/XSF/Xamarin.Forms.Platform.Tizen/PreloadedWindow.cs @@ -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() diff --git a/src/XSF/ibc/XSF.ibc b/src/XSF/ibc/XSF.ibc index 5fb4bad..7f8a81d 100644 Binary files a/src/XSF/ibc/XSF.ibc and b/src/XSF/ibc/XSF.ibc differ