From: huiyu.eun Date: Tue, 16 Feb 2021 04:10:25 +0000 (+0900) Subject: [NUI] Clean code releated to application X-Git-Tag: citest_t1~274 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d1d63ca32a64b3b84f7d2efa20cbe371b41ce95f;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Clean code releated to application - Delete Application.WindowMode - Delete state of NewApplication without args in Run(). - Delete unused code & variable - Change to follow NUI coding rule - Resolve build warnings Signed-off-by: huiyu.eun --- diff --git a/src/Tizen.NUI/src/internal/Application/Application.cs b/src/Tizen.NUI/src/internal/Application/Application.cs index 8fa349c..c6312d1 100755 --- a/src/Tizen.NUI/src/internal/Application/Application.cs +++ b/src/Tizen.NUI/src/internal/Application/Application.cs @@ -1078,15 +1078,15 @@ namespace Tizen.NUI public static Application NewApplication() { - return NewApplication("", Application.WindowMode.Opaque); + return NewApplication("", NUIApplication.WindowMode.Opaque); } public static Application NewApplication(string stylesheet) { - return NewApplication(stylesheet, Application.WindowMode.Opaque); + return NewApplication(stylesheet, NUIApplication.WindowMode.Opaque); } - public static Application NewApplication(string stylesheet, Application.WindowMode windowMode) + public static Application NewApplication(string stylesheet, NUIApplication.WindowMode windowMode) { // register all Views with the type registry, so that can be created / styled via JSON //ViewRegistryHelper.Initialize(); //moved to Application side. @@ -1103,7 +1103,7 @@ namespace Tizen.NUI return ret; } - public static Application NewApplication(string stylesheet, Application.WindowMode windowMode, Rectangle positionSize) + public static Application NewApplication(string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize) { if (_instance) { @@ -1117,13 +1117,13 @@ namespace Tizen.NUI return ret; } - public static Application NewApplication(string[] args, string stylesheet, Application.WindowMode windowMode) + public static Application NewApplication(string[] args, string stylesheet, NUIApplication.WindowMode windowMode) { if (_instance) { return _instance; } - Application ret = New(args, stylesheet, (Application.WindowMode)windowMode); + Application ret = New(args, stylesheet, windowMode); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); // set the singleton @@ -1131,13 +1131,13 @@ namespace Tizen.NUI return _instance; } - public static Application NewApplication(string[] args, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize) + public static Application NewApplication(string[] args, string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize) { if (_instance) { return _instance; } - Application ret = New(args, stylesheet, (Application.WindowMode)windowMode, positionSize); + Application ret = New(args, stylesheet, windowMode, positionSize); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); // set the singleton @@ -1185,7 +1185,7 @@ namespace Tizen.NUI return ret; } - public static Application New(int argc, string stylesheet, Application.WindowMode windowMode) + public static Application New(int argc, string stylesheet, NUIApplication.WindowMode windowMode) { Application ret = new Application(Interop.Application.New(argc, stylesheet, (int)windowMode), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); @@ -1193,7 +1193,7 @@ namespace Tizen.NUI return ret; } - public static Application New(string[] args, string stylesheet, Application.WindowMode windowMode) + public static Application New(string[] args, string stylesheet, NUIApplication.WindowMode windowMode) { Application ret = null; int argc = 0; @@ -1217,14 +1217,14 @@ namespace Tizen.NUI return ret; } - public static Application New(int argc, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize) + public static Application New(int argc, string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize) { Application ret = new Application(Interop.Application.New(argc, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } - public static Application New(string[] args, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize) + public static Application New(string[] args, string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize) { Application ret = null; int argc = 0; @@ -1411,11 +1411,5 @@ namespace Tizen.NUI if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } - - public enum WindowMode - { - Opaque = 0, - Transparent = 1 - } } } diff --git a/src/Tizen.NUI/src/internal/Application/NUICoreBackend.cs b/src/Tizen.NUI/src/internal/Application/NUICoreBackend.cs index 615cc1c..0cc935c 100755 --- a/src/Tizen.NUI/src/internal/Application/NUICoreBackend.cs +++ b/src/Tizen.NUI/src/internal/Application/NUICoreBackend.cs @@ -27,11 +27,10 @@ namespace Tizen.NUI /// /// The Application instance to connect event. /// - protected Application _application; - private string _stylesheet = ""; - private NUIApplication.WindowMode _windowMode = NUIApplication.WindowMode.Opaque; - private Size2D _windowSize = null; - private Position2D _windowPosition = null; + protected Application application; + private string stylesheet = ""; + private NUIApplication.WindowMode windowMode = NUIApplication.WindowMode.Opaque; + private Rectangle windowRectangle = null; /// /// The Dictionary to contain each type of event callback. @@ -50,7 +49,7 @@ namespace Tizen.NUI /// public NUICoreBackend(string stylesheet) { - _stylesheet = stylesheet; + this.stylesheet = stylesheet; } /// @@ -58,8 +57,8 @@ namespace Tizen.NUI /// public NUICoreBackend(string stylesheet, NUIApplication.WindowMode windowMode) { - _stylesheet = stylesheet; - _windowMode = windowMode; + this.stylesheet = stylesheet; + this.windowMode = windowMode; } /// @@ -67,10 +66,12 @@ namespace Tizen.NUI /// public NUICoreBackend(string stylesheet, NUIApplication.WindowMode windowMode, Size2D windowSize, Position2D windowPosition) { - _stylesheet = stylesheet; - _windowMode = windowMode; - _windowSize = windowSize; - _windowPosition = windowPosition; + this.stylesheet = stylesheet; + this.windowMode = windowMode; + if (windowSize != null && windowPosition != null) + { + this.windowRectangle = new Rectangle(windowPosition.X, windowPosition.Y, windowSize.Width, windowSize.Height); + } } /// @@ -101,17 +102,13 @@ namespace Tizen.NUI /// public void Dispose() { - if (_application != null) - { - _application.Dispose(); - } - if (_windowSize != null) + if (application != null) { - _windowSize.Dispose(); + application.Dispose(); } - if (_windowPosition != null) + if (windowRectangle != null) { - _windowPosition.Dispose(); + windowRectangle.Dispose(); } } @@ -120,9 +117,9 @@ namespace Tizen.NUI /// public void Exit() { - if (_application != null) + if (application != null) { - _application.Quit(); + application.Quit(); } } @@ -133,7 +130,7 @@ namespace Tizen.NUI /// true if added successfully, false otherwise public bool AddIdle(System.Delegate func) { - return _application.AddIdle(func); + return application.AddIdle(func); } /// @@ -150,42 +147,28 @@ namespace Tizen.NUI args[0] = this.GetType().Assembly.FullName; } - if (args.Length == 1) + if (windowRectangle != null) { - if (_windowSize != null) - { - _application = Application.NewApplication(_stylesheet, (Application.WindowMode)_windowMode, new Rectangle(_windowPosition.X, _windowPosition.Y, _windowSize.Width, _windowSize.Height)); - } - else - { - _application = Application.NewApplication(_stylesheet, (Application.WindowMode)_windowMode); - } + application = Application.NewApplication(args, stylesheet, windowMode, windowRectangle); } - else if (args.Length > 1) + else { - if (_windowSize != null) - { - _application = Application.NewApplication(args, _stylesheet, (Application.WindowMode)_windowMode, new Rectangle(_windowPosition.X, _windowPosition.Y, _windowSize.Width, _windowSize.Height)); - } - else - { - _application = Application.NewApplication(args, _stylesheet, (Application.WindowMode)_windowMode); - } + application = Application.NewApplication(args, stylesheet, windowMode); } - _application.BatteryLow += OnBatteryLow; - _application.LanguageChanged += OnLanguageChanged; - _application.MemoryLow += OnMemoryLow; - _application.RegionChanged += OnRegionChanged; + application.BatteryLow += OnBatteryLow; + application.LanguageChanged += OnLanguageChanged; + application.MemoryLow += OnMemoryLow; + application.RegionChanged += OnRegionChanged; - _application.Initialized += OnInitialized; - _application.Resumed += OnResumed; - _application.Terminating += OnTerminated; - _application.Paused += OnPaused; - _application.AppControl += OnAppControl; + application.Initialized += OnInitialized; + application.Resumed += OnResumed; + application.Terminating += OnTerminated; + application.Paused += OnPaused; + application.AppControl += OnAppControl; - _application.MainLoop(); - _application.Dispose(); + application.MainLoop(); + application.Dispose(); } /// @@ -340,7 +323,7 @@ namespace Tizen.NUI { get { - return _application; + return application; } } } diff --git a/src/Tizen.NUI/src/public/Application/NUIApplication.cs b/src/Tizen.NUI/src/public/Application/NUIApplication.cs index 90e3aab..56c553f 100755 --- a/src/Tizen.NUI/src/public/Application/NUIApplication.cs +++ b/src/Tizen.NUI/src/public/Application/NUIApplication.cs @@ -39,28 +39,24 @@ namespace Tizen.NUI /// The instance of ResourceManager. /// private static System.Resources.ResourceManager resourceManager = null; - private Size2D _windowSize2D = null; - private Position2D _windowPosition2D = null; - private TransitionOptions transitionOptions; - private string appId = null; - internal static NUIApplication me; - - private static bool isPreload = false; // TODO Enable this after tizen-theme-manager is released. // private readonly ThemeLoader themeLoader = new ThemeLoader(); + static NUIApplication() + { + Registry.Instance.SavedApplicationThread = Thread.CurrentThread; + // TODO Enable this after tizen-theme-manager is released. + // themeLoader.ThemeChanged += TizenThemeChanged; + } + /// /// The default constructor. /// /// 3 + [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")] public NUIApplication() : base(new NUICoreBackend()) { - Registry.Instance.SavedApplicationThread = Thread.CurrentThread; - me = this; - - // TODO Enable this after tizen-theme-manager is released. - // themeLoader.ThemeChanged += TizenThemeChanged; } /// @@ -70,15 +66,10 @@ namespace Tizen.NUI /// The window position. /// 5 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. + [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")] [EditorBrowsable(EditorBrowsableState.Never)] - public NUIApplication(Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend("", WindowMode.Opaque, windowSize, windowPosition)) + public NUIApplication(Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend("", NUIApplication.WindowMode.Opaque, windowSize, windowPosition)) { - Registry.Instance.SavedApplicationThread = Thread.CurrentThread; - // TODO Enable this after tizen-theme-manager is released. - // themeLoader.ThemeChanged += TizenThemeChanged; - _windowSize2D = windowSize; - _windowPosition2D = windowPosition; - me = this; } /// @@ -86,12 +77,9 @@ namespace Tizen.NUI /// /// The styleSheet url. /// 3 + [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")] public NUIApplication(string styleSheet) : base(new NUICoreBackend(styleSheet)) { - Registry.Instance.SavedApplicationThread = Thread.CurrentThread; - me = this; - // TODO Enable this after tizen-theme-manager is released. - // themeLoader.ThemeChanged += TizenThemeChanged; } /// @@ -102,15 +90,10 @@ namespace Tizen.NUI /// The window position. /// 5 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. + [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")] [EditorBrowsable(EditorBrowsableState.Never)] public NUIApplication(string styleSheet, Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend(styleSheet, WindowMode.Opaque, windowSize, windowPosition)) { - Registry.Instance.SavedApplicationThread = Thread.CurrentThread; - // TODO Enable this after tizen-theme-manager is released. - // themeLoader.ThemeChanged += TizenThemeChanged; - _windowSize2D = windowSize; - _windowPosition2D = windowPosition; - me = this; } /// @@ -119,12 +102,9 @@ namespace Tizen.NUI /// The styleSheet url. /// The windowMode. /// 3 + [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")] public NUIApplication(string styleSheet, WindowMode windowMode) : base(new NUICoreBackend(styleSheet, windowMode)) { - Registry.Instance.SavedApplicationThread = Thread.CurrentThread; - me = this; - // TODO Enable this after tizen-theme-manager is released. - // themeLoader.ThemeChanged += TizenThemeChanged; } /// @@ -136,15 +116,10 @@ namespace Tizen.NUI /// The window position. /// 5 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. + [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")] [EditorBrowsable(EditorBrowsableState.Never)] public NUIApplication(string styleSheet, WindowMode windowMode, Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition)) { - Registry.Instance.SavedApplicationThread = Thread.CurrentThread; - // TODO Enable this after tizen-theme-manager is released. - // themeLoader.ThemeChanged += TizenThemeChanged; - _windowSize2D = windowSize; - _windowPosition2D = windowPosition; - me = this; } /// @@ -163,13 +138,6 @@ namespace Tizen.NUI //windowMode and styleSheet will be added later. currenlty it's not working as expected. Graphics.Backend = backend; Tizen.Log.Error("NUI", "Plaese DO NOT set graphical backend type with this constructor! This will give no effect!"); - - if (windowSize != null) { _windowSize2D = windowSize; } - if (windowPosition != null) { _windowPosition2D = windowPosition; } - Registry.Instance.SavedApplicationThread = Thread.CurrentThread; - me = this; - // TODO Enable this after tizen-theme-manager is released. - // themeLoader.ThemeChanged += TizenThemeChanged; } /// @@ -241,7 +209,7 @@ namespace Tizen.NUI { get { - return appId; + return Tizen.Applications.Application.Current.ApplicationInfo.ApplicationId; } } @@ -418,7 +386,6 @@ namespace Tizen.NUI protected override void OnCreate() { base.OnCreate(); - appId = Tizen.Applications.Application.Current.ApplicationInfo.ApplicationId; } /// @@ -428,7 +395,7 @@ namespace Tizen.NUI static public void Preload() { Interop.Application.PreInitialize(); - isPreload = true; + IsPreload = true; } /// @@ -437,24 +404,14 @@ namespace Tizen.NUI [EditorBrowsable(EditorBrowsableState.Never)] public void SendLaunchRequest(AppControl appControl) { - transitionOptions.SendLaunchRequest(appControl); + TransitionOptions?.SendLaunchRequest(appControl); } /// /// This is used to improve application launch performance. /// [EditorBrowsable(EditorBrowsableState.Never)] - public TransitionOptions TransitionOptions - { - get - { - return transitionOptions; - } - set - { - transitionOptions = value; - } - } + public TransitionOptions TransitionOptions { get; set; } // TODO Enable this after tizen-theme-manager is released. // private void TizenThemeChanged(object sender, ThemeEventArgs e) @@ -482,13 +439,7 @@ namespace Tizen.NUI /// /// Check if it is loaded as dotnet-loader-nui. /// - static internal bool IsPreload - { - get - { - return isPreload; - } - } + static internal bool IsPreload { get; set; } } /// diff --git a/src/Tizen.NUI/src/public/Widget/WidgetViewManager.cs b/src/Tizen.NUI/src/public/Widget/WidgetViewManager.cs index 885956a..f86cdd4 100755 --- a/src/Tizen.NUI/src/public/Widget/WidgetViewManager.cs +++ b/src/Tizen.NUI/src/public/Widget/WidgetViewManager.cs @@ -40,7 +40,7 @@ namespace Tizen.NUI /// Creates a new widgetView manager object. /// /// 6 - internal WidgetViewManager() : this(Interop.WidgetViewManager.New(Application.getCPtr(NUIApplication.me?.ApplicationHandle), NUIApplication.me?.AppId), true) + internal WidgetViewManager() : this(Interop.WidgetViewManager.New(Application.Instance.SwigCPtr, Applications.Application.Current.ApplicationInfo.ApplicationId), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -57,9 +57,9 @@ namespace Tizen.NUI { get { - if(!instance) + if (!instance) { - instance = new WidgetViewManager(); + instance = new WidgetViewManager(); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } return instance; diff --git a/src/Tizen.NUI/src/public/XamlBinding/IRegisterable.cs b/src/Tizen.NUI/src/public/XamlBinding/IRegisterable.cs deleted file mode 100755 index ab41c61..0000000 --- a/src/Tizen.NUI/src/public/XamlBinding/IRegisterable.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.ComponentModel; - -namespace Tizen.NUI.Binding -{ - /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IRegisterable - { - } -} diff --git a/src/Tizen.NUI/src/public/XamlBinding/Registrar.cs b/src/Tizen.NUI/src/public/XamlBinding/Registrar.cs index 42b912c..bf3ce79 100755 --- a/src/Tizen.NUI/src/public/XamlBinding/Registrar.cs +++ b/src/Tizen.NUI/src/public/XamlBinding/Registrar.cs @@ -212,7 +212,6 @@ namespace Tizen.NUI.Binding.Internals { static Registrar() { - Registered = new Registrar(); } internal static Dictionary Effects { get; } = new Dictionary(); @@ -220,9 +219,5 @@ namespace Tizen.NUI.Binding.Internals /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable ExtraAssemblies { get; set; } - - /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public static Registrar Registered { get; internal set; } } }