Activate Home app by pressing Home Key
authorKyuho Jo <kyuho.jo@samsung.com>
Thu, 16 Mar 2017 10:47:21 +0000 (19:47 +0900)
committerChulSeung Kim <charles0.kim@samsung.com>
Thu, 8 Jun 2017 09:34:47 +0000 (18:34 +0900)
1. Grab Home key event.
2. Remove background image.
3. Set Transparent background of MainWindow.

Signed-off-by: Kyuho Jo <kyuho.jo@samsung.com>
Change-Id: I9196826042c8baab8a78e83e061dbfa9c5534c60

LibTVRefCommonPortable/Utils/IPlatformNotification.cs
LibTVRefCommonTizen/LibTVRefCommonTizen.project.json
TVHome/TVHome.TizenTV/TVHome.TizenTV.cs
TVHome/TVHome.TizenTV/TVHome.TizenTV.project.json
TVHome/TVHome.TizenTV/bin/Debug/TVHome.TizenTV.tpk
TVHome/TVHome.TizenTV/tizen-manifest.xml
TVHome/TVHome/TVHome.cs
TVHome/TVHome/Views/MainPage.xaml
TVHome/TVHome/Views/MainPage.xaml.cs
TVHome/TVHome/Views/SubThumbnailPanel.xaml.cs

index c78426d..296a3b3 100644 (file)
@@ -19,7 +19,9 @@ namespace LibTVRefCommonPortable.Utils
 {
     public interface IPlatformNotification
     {
-        void OnAppInstalled(string pkgID);
+        void OnHomeKeyPressed();
+
+       void OnAppInstalled(string pkgID);
 
         void OnAppUninstalled(string pkgID);
 
index 8032092..dc60bbf 100644 (file)
@@ -1,13 +1,13 @@
 {
   "dependencies": {
-       "ElmSharp": "1.1.0-beta-010",
+    "ElmSharp": "1.1.0-beta-013",
     "Microsoft.NETCore.App": "1.1.0",
     "Tizen.Library": "1.0.0-pre2",
     "Xamarin.Forms": "2.3.3.193",
     "Xamarin.Forms.Platform.Tizen": "2.3.3.175-beta-007"
   },
   "frameworks": {
-   "netcoreapp1.0": {
+    "netcoreapp1.0": {
       "imports": [
         "portable-net45+wp80+win81+wpa81",
         "netstandard1.6"
index 33b3db3..9c38356 100644 (file)
  * limitations under the License.
  */
 
+using System;
+using System.Threading;
 using LibTVRefCommonPortable.Utils;
 using LibTVRefCommonTizen.Ports;
 using Tizen.Applications;
 
+
 namespace TVHome.TizenTV
 {
     class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication
     {
         IPlatformNotification notification;
+        private Timer timerForKeyGrab;
 
         public static string AppResourcePath
         {
@@ -36,6 +40,14 @@ namespace TVHome.TizenTV
             private set;
         }
 
+        private void CallbackForKeyGrab(Object state)
+        {
+            MainWindow.KeyGrab(ElmSharp.EvasKeyEventArgs.PlatformHomeButtonName, true);
+            timerForKeyGrab.Dispose();
+            timerForKeyGrab = null;
+            DebuggingPort.D("KeyGrab finished");
+        }
+
         protected override void OnCreate()
         {
             base.OnCreate();
@@ -49,7 +61,26 @@ namespace TVHome.TizenTV
             LoadApplication(app);
 
             PackageManagerPort.RegisterCallbacks(notification);
-            MainWindow.KeyGrab(ElmSharp.EvasKeyEventArgs.PlatformHomeButtonName, true);
+
+           MainWindow.KeyUp += KeyUpListener;
+            MainWindow.Alpha = true;
+
+            TimerCallback timerDelegate = new TimerCallback(CallbackForKeyGrab);
+            timerForKeyGrab = new Timer(timerDelegate, MainWindow, 3000, 0);
+
+        }
+
+        private void KeyUpListener(object sender, ElmSharp.EvasKeyEventArgs e)
+        {
+            DebuggingPort.D("Key Pressed :" + e.KeyName);
+            if (e.KeyName.CompareTo(ElmSharp.EvasKeyEventArgs.PlatformHomeButtonName) == 0)
+            {
+                MainWindow.Active();
+                if (notification != null)
+                {
+                    notification.OnHomeKeyPressed();
+                }
+            }
         }
 
         protected override void OnTerminate()
index daa395f..c8db355 100644 (file)
@@ -6,7 +6,7 @@
     "preserveCompilationContext": true\r
   },\r
   "dependencies": {\r
-    "ElmSharp": "1.1.0-beta-010",\r
+    "ElmSharp": "1.1.0-beta-013",\r
     "Microsoft.NETCore.App": "1.1.0",\r
     "Tizen.Library": "1.0.0-pre2",\r
     "Xamarin.Forms": "2.3.3.193",\r
index 8dedb0d..2fe103d 100644 (file)
Binary files a/TVHome/TVHome.TizenTV/bin/Debug/TVHome.TizenTV.tpk and b/TVHome/TVHome.TizenTV/bin/Debug/TVHome.TizenTV.tpk differ
index fa1e02a..4612f28 100644 (file)
@@ -8,6 +8,7 @@
        <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>\r
     <privilege>http://tizen.org/privilege/appmanager.launch</privilege>\r
     <privilege>http://tizen.org/privilege/externalstorage</privilege>\r
+       <privilege>http://tizen.org/privilege/keygrab</privilege>\r
   </privileges>\r
   <profile name="common" />\r
   <ui-application appid="org.tizen.example.TVHome.TizenTV" \r
index 0b70745..57a8a9c 100644 (file)
@@ -28,6 +28,7 @@ namespace TVHome
 
     public class App : Application, IPlatformNotification
     {
+        private static EventHandler<TVHomeEventArgs> HomeKeyListener;
         private static EventHandler<TVHomeEventArgs> AppInstalledListener;
         private static EventHandler<TVHomeEventArgs> AppUninstalledListener;
         private static EventHandler<TVHomeEventArgs> AppPinnedNotificationListener;
@@ -52,7 +53,12 @@ namespace TVHome
 
         }
 
-        public static void SetAppInstalledListener(EventHandler<TVHomeEventArgs> listener)
+        public static void SetHomeKeyListener(EventHandler<TVHomeEventArgs> listener)
+        {
+            HomeKeyListener += listener;
+        }
+
+       public static void SetAppInstalledListener(EventHandler<TVHomeEventArgs> listener)
         {
             AppInstalledListener += listener;
         }
@@ -61,11 +67,21 @@ namespace TVHome
         {
             AppUninstalledListener += listener;
         }
-        public static void SetAppPinnedNotificationListener(EventHandler<TVHomeEventArgs> listener)
+        
+       public static void SetAppPinnedNotificationListener(EventHandler<TVHomeEventArgs> listener)
         {
             AppPinnedNotificationListener += listener;
         }
 
+        public void OnHomeKeyPressed()
+        {
+            DebuggingUtils.Dbg("[[[ Home Key ]]] ");
+            HomeKeyListener.Invoke(this, new TVHomeEventArgs()
+            {
+                arg = "",
+            });
+        }
+
         public void OnAppInstalled(string pkgID)
         {
             DebuggingUtils.Dbg("[[[ App Installed ]]] " + pkgID);
index 2ccca47..3ee0147 100755 (executable)
@@ -5,11 +5,7 @@
              xmlns:Views="clr-namespace:TVHome.Views"
              xmlns:ViewModels="clr-namespace:TVHome.ViewModels"
              xmlns:Controls="clr-namespace:TVHome.Controls"
-             Appearing="OnAppearing"
-             BackgroundImage="background.jpg">
-    <ContentPage.BackgroundColor>
-        <Color>White</Color>
-    </ContentPage.BackgroundColor>
+             Appearing="OnAppearing">
     <ContentPage.BindingContext>
         <ViewModels:MainPageViewModel />
     </ContentPage.BindingContext>
@@ -21,7 +17,7 @@
                   RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0}"
                   RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0}"
                   Source="bg_dimmed.png"
-                  Opacity="0.95"/>
+                  Opacity="0.5"/>
 
             <Views:MainPanel x:Name="PageMainPanel"
                              RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.22}"
index 99416b6..47771e0 100755 (executable)
@@ -1,4 +1,4 @@
-/*
+/*
  * Copyright (c) 2017 Samsung Electronics Co., Ltd
  *
  * Licensed under the Flora License, Version 1.1 (the "License");
@@ -35,6 +35,18 @@ namespace TVHome.Views
         private Panel currentSubPanel;
         public ICommand ChangeSubPanelCommand;
 
+        private async void PlayHideAnimation()
+        {
+            currentSubPanel?.TranslateTo(0.0, 100, 150);
+            await PageMainPanel.ScaleTo(0.0, 150);
+        }
+
+        private async void PlayShowAnimation()
+        {
+            currentSubPanel?.TranslateTo(0.0, 0.0, 150);
+            await PageMainPanel.ScaleTo(1.0, 150);
+        }
+
         public MainPage()
         {
             InitializeComponent();
@@ -43,16 +55,34 @@ namespace TVHome.Views
             SubPanelDictionary.Add("Apps", AppsSubPanel);
             SubPanelDictionary.Add("Settings", SettingsSubPanel);
 
+            App.SetHomeKeyListener((e, arg) => {
+                DebuggingUtils.Dbg("FIRED!!");
+                if (IsVisible)
+                {
+                    PlayHideAnimation();
+                    IsVisible = !IsVisible;
+                }
+                else
+                {
+                    IsVisible = !IsVisible;
+                    PageMainPanel.InitialFocusing();
+                    PlayShowAnimation();
+                }
+            });
+
             PageMainPanel.OnFocusedCommand = new Command<string>((key) =>
             {
                 DebuggingUtils.Dbg("MainPage : " + key);
-                if (currentSubPanel != null)
+                foreach (KeyValuePair<string, Panel> aPair in SubPanelDictionary)
                 {
-                    currentSubPanel.HidePanel();
+                    if (aPair.Key != key)
+                        aPair.Value.HidePanel();
+                    else
+                    {
+                        currentSubPanel = aPair.Value;
+                        currentSubPanel.ShowPanel();
+                    }
                 }
-
-                currentSubPanel = SubPanelDictionary[key];
-                currentSubPanel.ShowPanel();
             });
 
             RecentSubPanel.OnFocusedCommand = new Command(() =>
@@ -110,4 +140,4 @@ namespace TVHome.Views
             }
         }
     }
-}
\ No newline at end of file
+}
index 449f728..4b880cb 100644 (file)
@@ -77,10 +77,12 @@ namespace TVHome.Views
             this.TranslateTo(0, 1, 0);
 #pragma warning restore CS4014
             await this.FadeTo(0, 0);
+            IsVisible = false;
         }
 
         public override async void ShowPanel()
         {
+            IsVisible = true;
             isFocused = false;
             foreach (var item in PanelButtonStack.Children)
             {