Modify Unpin action in Home apps list
authorHyerim Kim <rimi.kim@samsung.com>
Mon, 20 Mar 2017 08:16:19 +0000 (17:16 +0900)
committerChulSeung Kim <charles0.kim@samsung.com>
Thu, 8 Jun 2017 09:34:48 +0000 (18:34 +0900)
 - Triggered by Menu key
Remove BackgroundImage

Change-Id: Ie1c7242c9743d42d73f0835d6a4766522e368ae7
Signed-off-by: Hyerim Kim <rimi.kim@samsung.com>
LibTVRefCommonPortable/Utils/IPlatformNotification.cs [changed mode: 0644->0755]
TVApps/TVApps/TVApps.cs [changed mode: 0644->0755]
TVHome/TVHome.TizenTV/TVHome.TizenTV.cs [changed mode: 0644->0755]
TVHome/TVHome/TVHome.cs [changed mode: 0644->0755]
TVHome/TVHome/Views/MainPage.xaml
TVHome/TVHome/Views/MainPage.xaml.cs
TVHome/TVHome/Views/SubPanel.xaml.cs

old mode 100644 (file)
new mode 100755 (executable)
index 296a3b3..ee2669c
@@ -21,7 +21,9 @@ namespace LibTVRefCommonPortable.Utils
     {
         void OnHomeKeyPressed();
 
-       void OnAppInstalled(string pkgID);
+        void OnMenuKeyPressed();
+
+        void OnAppInstalled(string pkgID);
 
         void OnAppUninstalled(string pkgID);
 
old mode 100644 (file)
new mode 100755 (executable)
index 6425c4e..33d3d16
@@ -98,5 +98,9 @@ namespace TVApps
         public void OnHomeKeyPressed()
         {
         }
+
+        public void OnMenuKeyPressed()
+        {
+        }
     }
 }
old mode 100644 (file)
new mode 100755 (executable)
index 9c38356..a2c9b6a
@@ -43,6 +43,7 @@ namespace TVHome.TizenTV
         private void CallbackForKeyGrab(Object state)
         {
             MainWindow.KeyGrab(ElmSharp.EvasKeyEventArgs.PlatformHomeButtonName, true);
+            MainWindow.KeyGrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName, true);
             timerForKeyGrab.Dispose();
             timerForKeyGrab = null;
             DebuggingPort.D("KeyGrab finished");
@@ -81,6 +82,13 @@ namespace TVHome.TizenTV
                     notification.OnHomeKeyPressed();
                 }
             }
+            else if (e.KeyName.CompareTo(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName) == 0)
+            {
+                if (notification != null)
+                {
+                    notification.OnMenuKeyPressed();
+                }
+            }
         }
 
         protected override void OnTerminate()
@@ -90,6 +98,7 @@ namespace TVHome.TizenTV
             notification = null;
             PackageManagerPort.DeregisterCallbacks();
             MainWindow.KeyUngrab(ElmSharp.EvasKeyEventArgs.PlatformHomeButtonName);
+            MainWindow.KeyUngrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName);
         }
 
         protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
old mode 100644 (file)
new mode 100755 (executable)
index 57a8a9c..59102ce
@@ -29,6 +29,7 @@ namespace TVHome
     public class App : Application, IPlatformNotification
     {
         private static EventHandler<TVHomeEventArgs> HomeKeyListener;
+        private static EventHandler<TVHomeEventArgs> MenuKeyListener;
         private static EventHandler<TVHomeEventArgs> AppInstalledListener;
         private static EventHandler<TVHomeEventArgs> AppUninstalledListener;
         private static EventHandler<TVHomeEventArgs> AppPinnedNotificationListener;
@@ -58,7 +59,12 @@ namespace TVHome
             HomeKeyListener += listener;
         }
 
-       public static void SetAppInstalledListener(EventHandler<TVHomeEventArgs> listener)
+        public static void SetMenuKeyListener(EventHandler<TVHomeEventArgs> listener)
+        {
+            MenuKeyListener += listener;
+        }
+
+        public static void SetAppInstalledListener(EventHandler<TVHomeEventArgs> listener)
         {
             AppInstalledListener += listener;
         }
@@ -68,7 +74,7 @@ namespace TVHome
             AppUninstalledListener += listener;
         }
         
-       public static void SetAppPinnedNotificationListener(EventHandler<TVHomeEventArgs> listener)
+        public static void SetAppPinnedNotificationListener(EventHandler<TVHomeEventArgs> listener)
         {
             AppPinnedNotificationListener += listener;
         }
@@ -82,6 +88,15 @@ namespace TVHome
             });
         }
 
+        public void OnMenuKeyPressed()
+        {
+            DebuggingUtils.Dbg("\" Menu Key \" ");
+            MenuKeyListener.Invoke(this, new TVHomeEventArgs()
+            {
+                arg = "",
+            });
+        }
+
         public void OnAppInstalled(string pkgID)
         {
             DebuggingUtils.Dbg("[[[ App Installed ]]] " + pkgID);
index 56ea793..065116e 100755 (executable)
@@ -6,7 +6,6 @@
              xmlns:ViewModels="clr-namespace:TVHome.ViewModels"
              xmlns:Controls="clr-namespace:TVHome.Controls"
              Appearing="OnAppearing"
-             BackgroundImage="background.jpg"
              CurrentStatus="{Binding CurrentStatus}"
              SelectedMenuName="{Binding SelectedMenuName}">
     <ContentPage.BindingContext>
index 6ceac09..0f75161 100755 (executable)
@@ -85,9 +85,22 @@ namespace TVHome.Views
                 }
             });
 
+            // TODO : this is for the unpin test.
+            App.SetMenuKeyListener((e, arg) =>
+            {
+                AppShortcutInfo item = null;
+                item = AppsSubPanel.GetFocusedItem() as AppShortcutInfo;
+
+                DebuggingUtils.Dbg("Menu key is pressed : " + item.AppID);
+                if (item != null && item.AppID != null)
+                {
+                    UnpinAppShortcutInfo(item.AppID);
+                }
+            });
+
             AppsSubPanel.OnUnpinCommand = new Command<string>((appId) =>
             {
-                UnpinAppShortcutInfo(appId);
+                //UnpinAppShortcutInfo(appId);
             });
         }
 
@@ -167,7 +180,7 @@ namespace TVHome.Views
             TVHomeImpl.GetInstance.AppShortcutControllerInstance.UpdatePinnedApps(pinnedAppList);
         }
 
-        public async void RemovePinnedApp(string AppID)
+        private async void RemovePinnedApp(string AppID)
         {
             Dictionary<string, string> PinnedApps = await TVHomeImpl.GetInstance.AppShortcutControllerInstance.GetPinnedAppsAppIDs();
             if (PinnedApps.ContainsKey(AppID))
index 5be4bde..7da3f09 100755 (executable)
@@ -32,6 +32,7 @@ namespace TVHome.Views
     /// </summary>
     public partial class SubPanel : Panel
     {
+        private ShortcutInfo focusedItem;
         public SubPanel()
         {
             InitializeComponent();
@@ -39,6 +40,11 @@ namespace TVHome.Views
             PropertyChanged += OnItemsSourcePropertyChanged;
         }
 
+        public ShortcutInfo GetFocusedItem()
+        {
+            return focusedItem;
+        }
+
         private void OnItemsSourcePropertyChanged(object sender, PropertyChangedEventArgs e)
         {
             if (e.PropertyName != "ItemsSource")
@@ -68,25 +74,12 @@ namespace TVHome.Views
                 button.View.BindingContext = item;
                 button.OnFocusedCommand = new Command(() =>
                 {
+                    focusedItem = item;
                     FocusPanel();
                 });
                 button.OnClickedCommand = new Command(() =>
                 {
-                    if (item is AppShortcutInfo)
-                    {
-                        if (button is SubPanelAllAppsButton || button is SubPanelReservedButton)
-                        {
-                            item.DoAction();
-                        }
-                        else
-                        {
-                            OnUnpinCommand.Execute((item as AppShortcutInfo).AppID);
-                        }
-                    }
-                    else
-                    {
-                        item.DoAction();
-                    }
+                    item.DoAction();
                 });
                 PanelButtonStack.Children.Add(button.View);
             }