Change Apps status in longpress mode
authorGeunsun, Lee <gs86.lee@samsung.com>
Fri, 17 Mar 2017 03:59:23 +0000 (12:59 +0900)
committerChulSeung Kim <charles0.kim@samsung.com>
Thu, 8 Jun 2017 09:34:48 +0000 (18:34 +0900)
Change-Id: I2b6caa0f60d2bd0cfa01781707b6c469e2ec174d

TVApps/TVApps/Controls/AppItemCell.xaml
TVApps/TVApps/Controls/AppItemCell.xaml.cs
TVApps/TVApps/Controls/AppListView.xaml.cs
TVApps/TVApps/ViewModels/AppsHolder.cs
TVApps/TVApps/ViewModels/MainPageViewModel.cs

index b2b1036..b62d966 100755 (executable)
@@ -68,8 +68,7 @@
     <!-- This BoxView is temporary code for Long Press test -->
     <BoxView x:Name="ItemDim"
              Color="Black"
-             Opacity="0.5"
-             IsVisible="{Binding IsDim}"
+             Opacity="0.0"
              RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
              RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}" />
 
index 8539b35..d222404 100755 (executable)
@@ -18,6 +18,7 @@ using LibTVRefCommonPortable.DataModels;
 using LibTVRefCommonPortable.Utils;
 using System;
 using System.ComponentModel;
+using System.Threading.Tasks;
 using System.Windows.Input;
 using Xamarin.Forms;
 
@@ -53,6 +54,13 @@ namespace TVApps.Controls
             set { SetValue(IsShowOptionsProperty, value); }
         }
 
+        public static readonly BindableProperty IsDimProperty = BindableProperty.Create("IsDim", typeof(bool), typeof(AppItemCell), default(bool));
+        public bool IsDim
+        {
+            get { return (bool)GetValue(IsDimProperty); }
+            set { SetValue(IsDimProperty, value); }
+        }
+
         public AppItemCell()
         {
             InitializeComponent();
@@ -97,6 +105,12 @@ namespace TVApps.Controls
             }
             else if (e.PropertyName.CompareTo("IsShowOptions") == 0)
             {
+
+                // Set the icon status to default
+                ButtonImage.ScaleTo(1.0, 50);
+                ButtonImage.TranslateTo(0.0, 0.0, 50);
+                TextArea.TranslateTo(0.0, 0.0, 50);
+
                 if (IsShowOptions)
                 {
                     ButtonImage.TranslateTo(0, -50, 100);
@@ -110,6 +124,17 @@ namespace TVApps.Controls
                     TextArea.FadeTo(0.99, 100);
                 }
             }
+            else if (e.PropertyName.CompareTo("IsDim") == 0)
+            {
+                if (IsDim)
+                {
+                    ItemDim.FadeTo(0.5, 100);
+                }
+                else
+                {
+                    ItemDim.FadeTo(0.0, 100);
+                }
+            }
         }
 
         private void ButtonTitle_PropertyChanged(object sender, PropertyChangedEventArgs e)
index e2dcb40..1862584 100644 (file)
@@ -98,7 +98,9 @@ namespace TVApps.Controls
                 viewCell.SetBinding(AppItemCell.IsPinnedProperty, new Binding("BindingContext.IsPinned", source: viewCell.View));
                 viewCell.SetBinding(AppItemCell.IsCheckedProperty, new Binding("BindingContext.IsChecked", source: viewCell.View));
                 viewCell.SetBinding(AppItemCell.IsShowOptionsProperty, new Binding("BindingContext.IsShowOptions", source: viewCell.View));
+                viewCell.SetBinding(AppItemCell.IsDimProperty, new Binding("BindingContext.IsDim", source: viewCell.View));
                 viewCell.OnClickedCommand = new Command(() =>
+
                 {
                     item.DoAction();
                 });
index cc06d74..464d4fd 100644 (file)
@@ -197,11 +197,17 @@ namespace TVApps.ViewModels
                 item.CurrentStateDescription = item.StateDescriptions[tag];
                 switch (status)
                 {
+                    case AppsStatus.Default:
+                        item.SetChecked(false);
+                        item.SetDim(false);
+                        break;
                     case AppsStatus.Pin:
                         item.SetChecked(item.IsPinned);
                         break;
-
-                    default:
+                    case AppsStatus.LongPress:
+                        item.SetDim(true);
+                        break;
+                    case AppsStatus.Delete:
                         item.SetChecked(false);
                         break;
                 }
@@ -254,65 +260,18 @@ namespace TVApps.ViewModels
             }
         }
 
-        public void HideLongPressedApp(string appId)
-        {
-            InstalledApps = new List<AppShortcutInfo>(InstalledApps);
-            AppShortcutInfo longPressedApp = InstalledApps.Find(app => app.AppID.Equals(appId));
-            if (longPressedApp != null)
-            {
-                DebuggingUtils.Dbg("Hide the app icon : " + longPressedApp.AppID);
-                longPressedApp.SetVisible(false);
-            }
-        }
-
-        public void ShowLongPressedApp(string appId)
-        {
-            InstalledApps = new List<AppShortcutInfo>(InstalledApps);
-            AppShortcutInfo longPressedApp = InstalledApps.Find(app => app.AppID.Equals(appId));
-            if (longPressedApp != null)
-            {
-                DebuggingUtils.Dbg("Show the app icon : " + longPressedApp.AppID);
-                longPressedApp.SetVisible(true);
-            }
-        }
-
-        public void SetAppItemDim(string appId)
-        {
-            InstalledApps = new List<AppShortcutInfo>(InstalledApps);
-            foreach (AppShortcutInfo app in InstalledApps)
-            {
-                if (!app.AppID.Equals(appId))
-                {
-                    app.SetDim(true);
-                }
-            }
-        }
-
-        public void UnsetAppItemDim(string appId)
-        {
-            InstalledApps = new List<AppShortcutInfo>(InstalledApps);
-            foreach (AppShortcutInfo app in InstalledApps)
-            {
-                if (!app.AppID.Equals(appId))
-                {
-                    app.SetDim(false);
-                }
-            }
-        }
-
         public void ShowLongPressOption(string appId)
         {
-            InstalledApps = new List<AppShortcutInfo>(InstalledApps);
             AppShortcutInfo longPressedApp = InstalledApps.Find(app => app.AppID.Equals(appId));
             if (longPressedApp != null)
             {
+                longPressedApp.SetDim(false);
                 longPressedApp.ShowOptions();
             }
         }
 
         public void HideLongPressOption(string appId)
         {
-            InstalledApps = new List<AppShortcutInfo>(InstalledApps);
             AppShortcutInfo longPressedApp = InstalledApps.Find(app => app.AppID.Equals(appId));
             if (longPressedApp != null)
             {
index 6c1944d..f2831b9 100644 (file)
@@ -154,11 +154,13 @@ namespace TVApps.ViewModels
             {
                 DebuggingUtils.Dbg(" === Set LongPress AppID : " + appId);
 
-                // 1. ItemCell will be dimmed
-                appsHolder.SetAppItemDim((string)appId);
+                // 1. Change Apps status to LongPress
+                // LongPress of AppsStatus will change ItemCell to be dimmed
+                ChangeCurrentStatus(AppsStatus.LongPress);
 
                 // 2. The selected icon on apps list will be moved
                 appsHolder.ShowLongPressOption((string)appId);
+
                 // 3. The option menu will be shown
 
             });
@@ -167,12 +169,15 @@ namespace TVApps.ViewModels
             {
                 DebuggingUtils.Dbg(" === Unset LongPress AppID : " + appId);
 
-                // 1. The option menu will be hidden
-                // 2. The selected icon will be moved
+                // 1. change Apps status to Default
+                // Default of AppsStatus will change ItemCell to be normal
+                ChangeCurrentStatus(AppsStatus.Default);
+
+                // 2. The option menu will be hidden
+
+                // 3. The selected icon will be moved
                 appsHolder.HideLongPressOption((string)appId);
 
-                // 3. ItemCell will be changed to normal
-                appsHolder.UnsetAppItemDim((string)appId);
             });