From: Kyuho Jo Date: Thu, 16 Mar 2017 10:47:21 +0000 (+0900) Subject: Activate Home app by pressing Home Key X-Git-Tag: submit/tizen/20170808.015446~189 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a3bb5903ee3a0dbf4be6efbfef83a9ce555e09b8;p=profile%2Ftv%2Fapps%2Fdotnet%2Fhome.git Activate Home app by pressing Home Key 1. Grab Home key event. 2. Remove background image. 3. Set Transparent background of MainWindow. Signed-off-by: Kyuho Jo Change-Id: I9196826042c8baab8a78e83e061dbfa9c5534c60 --- diff --git a/LibTVRefCommonPortable/Utils/IPlatformNotification.cs b/LibTVRefCommonPortable/Utils/IPlatformNotification.cs index c78426d..296a3b3 100644 --- a/LibTVRefCommonPortable/Utils/IPlatformNotification.cs +++ b/LibTVRefCommonPortable/Utils/IPlatformNotification.cs @@ -19,7 +19,9 @@ namespace LibTVRefCommonPortable.Utils { public interface IPlatformNotification { - void OnAppInstalled(string pkgID); + void OnHomeKeyPressed(); + + void OnAppInstalled(string pkgID); void OnAppUninstalled(string pkgID); diff --git a/LibTVRefCommonTizen/LibTVRefCommonTizen.project.json b/LibTVRefCommonTizen/LibTVRefCommonTizen.project.json index 8032092..dc60bbf 100644 --- a/LibTVRefCommonTizen/LibTVRefCommonTizen.project.json +++ b/LibTVRefCommonTizen/LibTVRefCommonTizen.project.json @@ -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" diff --git a/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs b/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs index 33b3db3..9c38356 100644 --- a/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs +++ b/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs @@ -14,15 +14,19 @@ * 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() diff --git a/TVHome/TVHome.TizenTV/TVHome.TizenTV.project.json b/TVHome/TVHome.TizenTV/TVHome.TizenTV.project.json index daa395f..c8db355 100644 --- a/TVHome/TVHome.TizenTV/TVHome.TizenTV.project.json +++ b/TVHome/TVHome.TizenTV/TVHome.TizenTV.project.json @@ -6,7 +6,7 @@ "preserveCompilationContext": true }, "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", diff --git a/TVHome/TVHome.TizenTV/bin/Debug/TVHome.TizenTV.tpk b/TVHome/TVHome.TizenTV/bin/Debug/TVHome.TizenTV.tpk index 8dedb0d..2fe103d 100644 Binary files a/TVHome/TVHome.TizenTV/bin/Debug/TVHome.TizenTV.tpk and b/TVHome/TVHome.TizenTV/bin/Debug/TVHome.TizenTV.tpk differ diff --git a/TVHome/TVHome.TizenTV/tizen-manifest.xml b/TVHome/TVHome.TizenTV/tizen-manifest.xml index fa1e02a..4612f28 100644 --- a/TVHome/TVHome.TizenTV/tizen-manifest.xml +++ b/TVHome/TVHome.TizenTV/tizen-manifest.xml @@ -8,6 +8,7 @@ http://tizen.org/privilege/packagemanager.admin http://tizen.org/privilege/appmanager.launch http://tizen.org/privilege/externalstorage + http://tizen.org/privilege/keygrab HomeKeyListener; private static EventHandler AppInstalledListener; private static EventHandler AppUninstalledListener; private static EventHandler AppPinnedNotificationListener; @@ -52,7 +53,12 @@ namespace TVHome } - public static void SetAppInstalledListener(EventHandler listener) + public static void SetHomeKeyListener(EventHandler listener) + { + HomeKeyListener += listener; + } + + public static void SetAppInstalledListener(EventHandler listener) { AppInstalledListener += listener; } @@ -61,11 +67,21 @@ namespace TVHome { AppUninstalledListener += listener; } - public static void SetAppPinnedNotificationListener(EventHandler listener) + + public static void SetAppPinnedNotificationListener(EventHandler 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); diff --git a/TVHome/TVHome/Views/MainPage.xaml b/TVHome/TVHome/Views/MainPage.xaml index 2ccca47..3ee0147 100755 --- a/TVHome/TVHome/Views/MainPage.xaml +++ b/TVHome/TVHome/Views/MainPage.xaml @@ -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"> - - White - + Appearing="OnAppearing"> @@ -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"/> { + DebuggingUtils.Dbg("FIRED!!"); + if (IsVisible) + { + PlayHideAnimation(); + IsVisible = !IsVisible; + } + else + { + IsVisible = !IsVisible; + PageMainPanel.InitialFocusing(); + PlayShowAnimation(); + } + }); + PageMainPanel.OnFocusedCommand = new Command((key) => { DebuggingUtils.Dbg("MainPage : " + key); - if (currentSubPanel != null) + foreach (KeyValuePair 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 +} diff --git a/TVHome/TVHome/Views/SubThumbnailPanel.xaml.cs b/TVHome/TVHome/Views/SubThumbnailPanel.xaml.cs index 449f728..4b880cb 100644 --- a/TVHome/TVHome/Views/SubThumbnailPanel.xaml.cs +++ b/TVHome/TVHome/Views/SubThumbnailPanel.xaml.cs @@ -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) {