From: Heonjae Jang Date: Wed, 29 Mar 2017 10:45:44 +0000 (+0900) Subject: Add comments for TVApps.Views, Renderers and Main X-Git-Tag: submit/tizen/20170808.015446~134 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2b12ce802b9b30a0db7eb2b442e6238a81f3450b;p=profile%2Ftv%2Fapps%2Fdotnet%2Fhome.git Add comments for TVApps.Views, Renderers and Main Change-Id: Id415c82490af563fa088d6e9cafd63671487f600 --- diff --git a/TVApps/TVApps.TizenTV/Renderer/CustomButtonRenderer.cs b/TVApps/TVApps.TizenTV/Renderer/CustomButtonRenderer.cs index ab6f1af..bcf0504 100644 --- a/TVApps/TVApps.TizenTV/Renderer/CustomButtonRenderer.cs +++ b/TVApps/TVApps.TizenTV/Renderer/CustomButtonRenderer.cs @@ -24,8 +24,16 @@ using Xamarin.Forms.Platform.Tizen; [assembly: ExportRenderer(typeof(CustomButton), typeof(CustomButtonRenderer))] namespace TVApps.TizenTV.Renderer { + /// + /// A custom renderer for CustomButton + /// + /// class CustomButtonRenderer : ButtonRenderer//ViewRenderer { + /// + /// Register touch event callback for the Tap. + /// + /// A button element changed event's argument protected override void OnElementChanged(ElementChangedEventArgs args) { base.OnElementChanged(args); @@ -45,6 +53,11 @@ namespace TVApps.TizenTV.Renderer Control.Released += KeyUp; } + /// + /// A action delegate invokes OnButtonUp event + /// + /// The source of the event + /// The event that is occurred when Control(Native Button) is pressed private void KeyUp(object sender, EventArgs e) { DbgPort.D("KeyUp"); @@ -52,6 +65,11 @@ namespace TVApps.TizenTV.Renderer BtnElement.OnButtonUp.Invoke(sender, e); } + /// + /// A action delegate invokes OnButtonDown event + /// + /// The source of the event + /// The event that is occurred when Control(Native Button) is released private void KeyDown(object sender, EventArgs e) { DbgPort.D("KeyDown"); diff --git a/TVApps/TVApps.TizenTV/Renderer/NinePatchImageRenderer.cs b/TVApps/TVApps.TizenTV/Renderer/NinePatchImageRenderer.cs index a83f448..9b791b5 100644 --- a/TVApps/TVApps.TizenTV/Renderer/NinePatchImageRenderer.cs +++ b/TVApps/TVApps.TizenTV/Renderer/NinePatchImageRenderer.cs @@ -14,8 +14,6 @@ * limitations under the License. */ -using LibTVRefCommonTizen.Ports; -using System; using System.ComponentModel; using TVApps.Controls; @@ -25,33 +23,52 @@ using Xamarin.Forms.Platform.Tizen; [assembly: ExportRenderer(typeof(NinePatchImage), typeof(NinePatchImageRenderer))] namespace TVApps.TizenTV.Renderer { + /// + /// A custom renderer for NinePatchImage + /// + /// class NinePatchImageRenderer : ImageRenderer { - protected override void OnElementChanged(ElementChangedEventArgs e) + /// + /// Updates border when Element is changed + /// + /// A image element changed event's argument + protected override void OnElementChanged(ElementChangedEventArgs args) { - base.OnElementChanged(e); + base.OnElementChanged(args); UpdateBorder(); } - protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) + /// + /// Updates border when ElementProperty is changed + /// + /// The source of the event + /// A image element property changed event's argument + protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs args) { - if ((e.PropertyName == NinePatchImage.BorderBottomProperty.PropertyName) - || (e.PropertyName == NinePatchImage.BorderLeftProperty.PropertyName) - || (e.PropertyName == NinePatchImage.BorderRightProperty.PropertyName) - || (e.PropertyName == NinePatchImage.BorderTopProperty.PropertyName)) + if ((args.PropertyName == NinePatchImage.BorderBottomProperty.PropertyName) + || (args.PropertyName == NinePatchImage.BorderLeftProperty.PropertyName) + || (args.PropertyName == NinePatchImage.BorderRightProperty.PropertyName) + || (args.PropertyName == NinePatchImage.BorderTopProperty.PropertyName)) { UpdateBorder(); } - base.OnElementPropertyChanged(sender, e); + base.OnElementPropertyChanged(sender, args); } + /// + /// A method updates border of Control(Native Image) + /// void UpdateBorder() { var img = Element as NinePatchImage; Control.SetBorder(img.BorderLeft, img.BorderRight, img.BorderTop, img.BorderBottom); } + /// + /// A method updates border of Control(Native Image) after loading + /// protected override void UpdateAfterLoading() { base.UpdateAfterLoading(); diff --git a/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs b/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs index 6d9a57e..b753b13 100644 --- a/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs +++ b/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs @@ -22,32 +22,42 @@ using System.Threading; namespace TVApps.TizenTV { + /// + /// TV Apps application main entry point + /// public class Program : Xamarin.Forms.Platform.Tizen.FormsApplication, IAppLifeControl { + /// + /// The application instance + /// private static Program instance; + + /// + /// A interface for the platform notification + /// private IPlatformNotification notification; - private Timer timerForKeyGrab; + /// + /// Gets and Sets application resource path + /// public static string AppResourcePath { get; private set; } + /// + /// Gets and Sets application data path + /// public static string AppDataPath { get; private set; } - private void CallbackForKeyGrab(Object state) - { - MainWindow.KeyGrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName, true); - timerForKeyGrab.Dispose(); - timerForKeyGrab = null; - DebuggingUtils.Dbg("KeyGrab finished"); - } - + /// + /// A method will be called when application is created + /// protected override void OnCreate() { base.OnCreate(); @@ -64,14 +74,19 @@ namespace TVApps.TizenTV MainWindow.KeyUp += KeyUpListener; - TimerCallback timerDelegate = new TimerCallback(CallbackForKeyGrab); - timerForKeyGrab = new Timer(timerDelegate, MainWindow, 3000, 0); + MainWindow.KeyGrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName, true); } - private void KeyUpListener(object sender, ElmSharp.EvasKeyEventArgs e) + /// + /// A method will be called when application receives KeyUp event + /// + + /// The source of the event + /// A EvasKey event's argument + private void KeyUpListener(object sender, ElmSharp.EvasKeyEventArgs args) { - DebuggingUtils.Dbg("[TVApps.TizenTV.cs] Key Pressed :" + e.KeyName); - if (e.KeyName.CompareTo(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName) == 0) + DebuggingUtils.Dbg("[TVApps.TizenTV.cs] Key Pressed :" + args.KeyName); + if (args.KeyName.CompareTo(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName) == 0) { if (notification != null) { @@ -80,17 +95,22 @@ namespace TVApps.TizenTV } } + /// + /// A method will be called when application is terminated + /// protected override void OnTerminate() { base.OnTerminate(); notification = null; PackageManagerPort.UnregisterCallbacks(); - MainWindow.KeyUngrab(ElmSharp.EvasKeyEventArgs.PlatformBackButtonName); MainWindow.KeyUngrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName); - } + /// + /// A method will be called when application receives AppControl + /// + /// AppControl event argument protected override void OnAppControlReceived(AppControlReceivedEventArgs e) { DbgPort.D("OnAppControlReceived, " + e.ReceivedAppControl.Operation); @@ -102,6 +122,10 @@ namespace TVApps.TizenTV } } + /// + /// The entry point for the application + /// + /// A list of command line arguments static void Main(string[] args) { instance = new Program(); @@ -121,9 +145,11 @@ namespace TVApps.TizenTV Xamarin.Forms.Platform.Tizen.Forms.Init(instance, true); instance.Run(args); - } + /// + /// A method terminates application + /// public void SelfTerminate() { instance.Exit(); diff --git a/TVApps/TVApps/TVApps.cs b/TVApps/TVApps/TVApps.cs index d5948b4..2c8a4f6 100755 --- a/TVApps/TVApps/TVApps.cs +++ b/TVApps/TVApps/TVApps.cs @@ -21,58 +21,114 @@ using System; namespace TVApps { + /// + /// A custom EventArgs with string field + /// public class TVAppsEventArgs : EventArgs { public string arg; } + /// + /// A class that represents TV Apps application. + /// public class App : Application, IPlatformNotification { + /// + /// A event handler for handling MenuKey event + /// private static EventHandler MenuKeyListener; + + /// + /// A event handler for handling AppInstalled event + /// private static EventHandler AppInstalledListener; + + /// + /// A event handler for handling AppUninstalled event + /// private static EventHandler AppUninstalledListener; + + /// + /// A event handler for handling PinApp request for TV Home + /// private static EventHandler PinAppRequestListener; + + /// + /// A constructor + /// Sets main page to MainPage instance + /// + /// public App() { MainPage = new MainPage(); } + /// + /// This method is called when the application starts + /// protected override void OnStart() { } + /// + /// This method is called when the application enters the sleeping state + /// protected override void OnSleep() { } + /// + /// This method is called when the application resumes from a sleeping state + /// protected override void OnResume() { } + /// + /// A method adds EventHandler to MenuKeyListener + /// + /// The EventHandler for adding public static void SetMenuKeyListener(EventHandler listener) { MenuKeyListener += listener; } + /// + /// A method adds EventHandler to AppInstalledListener + /// + /// The EventHandler for adding public static void SetAppInstalledListener(EventHandler listener) { AppInstalledListener += listener; } + /// + /// A method adds EventHandler to AppUninstalledListener + /// + /// The EventHandler for adding public static void SetAppUninstalledListener(EventHandler listener) { AppUninstalledListener += listener; } + /// + /// A method adds EventHandler to PinAppRequestListener + /// + /// The EventHandler for adding public static void SetPinAppRequestListener(EventHandler listener) { PinAppRequestListener += listener; } + /// + /// A method will be called if a app is installed. + /// + /// A package ID of newly installed. public void OnAppInstalled(string pkgID) { DebuggingUtils.Dbg("[[[ App Installed ]]] " + pkgID); @@ -82,6 +138,10 @@ namespace TVApps }); } + /// + /// A method will be called if a app is uninstalled. + /// + /// A package ID of uninstalled. public void OnAppUninstalled(string pkgID) { DebuggingUtils.Dbg("[[[ App Uninstalled ]]] " + pkgID); @@ -91,20 +151,33 @@ namespace TVApps }); } + /// + /// A method will be called if the app gets a pin app App Control request. + /// public void OnPinAppRequestReceived() { DebuggingUtils.Dbg("[[[ Pin Add Request ]]] "); PinAppRequestListener.Invoke(this, new TVAppsEventArgs()); } + /// + /// A method will be called if the app gets a app pinned notification App Control request. + /// + /// A pinned app ID/// public void OnAppPinnedNotificationReceived(string appID) { } + /// + /// A method will be called when the Home remote control key is pressed. + /// public void OnHomeKeyPressed() { } + /// + /// A method will be called when the Menu remote control key is pressed. + /// public void OnMenuKeyPressed() { DebuggingUtils.Dbg("[APPS] Menu Key is pressed"); diff --git a/TVApps/TVApps/Views/FooterDeleteStatus.xaml.cs b/TVApps/TVApps/Views/FooterDeleteStatus.xaml.cs index 8670618..8631d95 100644 --- a/TVApps/TVApps/Views/FooterDeleteStatus.xaml.cs +++ b/TVApps/TVApps/Views/FooterDeleteStatus.xaml.cs @@ -15,15 +15,17 @@ */ using Xamarin.Forms; -using TVApps.Controls; namespace TVApps.Views { /// - /// hahaha + /// A custom view for displaying footer when CurrentStatus of MainPage is AppsStatus.Delete /// public partial class FooterDeleteStatus : Grid { + /// + /// A constructor + /// public FooterDeleteStatus() { InitializeComponent(); diff --git a/TVApps/TVApps/Views/FooterNormalStatus.xaml.cs b/TVApps/TVApps/Views/FooterNormalStatus.xaml.cs index 1f777c3..744a4f4 100644 --- a/TVApps/TVApps/Views/FooterNormalStatus.xaml.cs +++ b/TVApps/TVApps/Views/FooterNormalStatus.xaml.cs @@ -19,10 +19,13 @@ using Xamarin.Forms; namespace TVApps.Views { /// - /// hahaha + /// A custom view for displaying footer when CurrentStatus of MainPage is AppsStatus.Default /// public partial class FooterNormalStatus : Grid { + /// + /// A constructor + /// public FooterNormalStatus() { InitializeComponent(); diff --git a/TVApps/TVApps/Views/FooterPinStatus.xaml.cs b/TVApps/TVApps/Views/FooterPinStatus.xaml.cs index d535e4a..e22237d 100644 --- a/TVApps/TVApps/Views/FooterPinStatus.xaml.cs +++ b/TVApps/TVApps/Views/FooterPinStatus.xaml.cs @@ -19,17 +19,27 @@ using Xamarin.Forms; namespace TVApps.Views { /// - /// hahaha + /// A custom view for displaying footer when CurrentStatus of MainPage is AppsStatus.Pin /// public partial class FooterPinStatus : Grid { + /// + /// Identifies the SumOfCheckedApp bindable property + /// public static readonly BindableProperty SumOfCheckedAppProperty = BindableProperty.Create("SumOfCheckedApp", typeof(int), typeof(FooterPinStatus), default(int)); + + /// + /// Gets or sets count of checked AppItemCell + /// public int SumOfCheckedApp { get { return (int)GetValue(SumOfCheckedAppProperty); } set { SetValue(SumOfCheckedAppProperty, value); } } + /// + /// A constructor + /// public FooterPinStatus() { InitializeComponent(); diff --git a/TVApps/TVApps/Views/MainPage.xaml.cs b/TVApps/TVApps/Views/MainPage.xaml.cs index 83b5481..84d7a86 100644 --- a/TVApps/TVApps/Views/MainPage.xaml.cs +++ b/TVApps/TVApps/Views/MainPage.xaml.cs @@ -25,11 +25,18 @@ using System.Threading.Tasks; namespace TVApps.Views { /// - /// Root Page of TV Apps Application + /// A custom view for displaying main page of TV Apps /// public partial class MainPage : ContentPage { + /// + /// Identifies the CurrentStatus bindable property + /// public static readonly BindableProperty CurrentStatusProperty = BindableProperty.Create("CurrentStatus", typeof(AppsStatus), typeof(MainPage), default(AppsStatus)); + + /// + /// Gets or sets current status of MainPage + /// public AppsStatus CurrentStatus { get { return (AppsStatus)GetValue(CurrentStatusProperty); } @@ -43,6 +50,9 @@ namespace TVApps.Views } */ + /// + /// A method runs animation when TV Apps is started + /// private async void PlayShowAnimation() { await AppList.TranslateTo(0, 12, 0); @@ -55,11 +65,15 @@ namespace TVApps.Views AppList.InitializeFocus(); } + /// + /// A constructor + /// Adds PropertyChanged event handler and MenuKey event listener + /// public MainPage() { InitializeComponent(); - PropertyChanged += MainPage_PropertyChanged; - SetCurrntStatus(AppsStatus.Default); + PropertyChanged += MainPagePropertyChanged; + SetCurrentStatus(AppsStatus.Default); PlayShowAnimation(); // TODO: This code is temporary for menu option test @@ -74,7 +88,12 @@ namespace TVApps.Views }); } - private void SetCurrntStatus(AppsStatus status) + /// + /// A method sets current status of MainPage + /// Changes visibility of footers + /// + /// The next status name + private void SetCurrentStatus(AppsStatus status) { switch (status) { @@ -106,14 +125,24 @@ namespace TVApps.Views } } - private void MainPage_PropertyChanged(object sender, PropertyChangedEventArgs e) + /// + /// This method is called when the properties of MainPage is changed + /// If CurrentStatus is changed, call SetCurrentStatus method + /// + /// The source of the event + /// The event that is occurred when property of MainPage is changed + private void MainPagePropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName.CompareTo("CurrentStatus") == 0) { - SetCurrntStatus(CurrentStatus); + SetCurrentStatus(CurrentStatus); } } + /// + /// A task for handling BackKey event + /// + /// Always returns true private async Task OnBackKeyPressedAtMain() { if (CurrentStatus != AppsStatus.Default) @@ -138,6 +167,11 @@ namespace TVApps.Views return true; } + /// + /// This method is called when Back button is pressed + /// + /// Always returns true + /// protected override bool OnBackButtonPressed() { SynchronizationContext.Current.Post(async (o) =>