Implement Apps Option menu behavior
authorGeunsun, Lee <gs86.lee@samsung.com>
Thu, 16 Mar 2017 08:28:57 +0000 (17:28 +0900)
committerChulSeung Kim <charles0.kim@samsung.com>
Thu, 8 Jun 2017 09:34:47 +0000 (18:34 +0900)
Change-Id: I3ac6b529d81655c76d3e5d79828b8d480cbe8fb4

LibTVRefCommonPortable/DataModels/AppShortcutInfo.cs
TVApps/TVApps/Controls/AppItemCell.xaml
TVApps/TVApps/Controls/AppItemCell.xaml.cs
TVApps/TVApps/Controls/AppListView.xaml
TVApps/TVApps/Controls/AppListView.xaml.cs
TVApps/TVApps/ViewModels/AppsHolder.cs
TVApps/TVApps/ViewModels/MainPageViewModel.cs
TVApps/TVApps/Views/MainPage.xaml
TVApps/TVApps/Views/MainPage.xaml.cs

index e6f24ee..7248692 100644 (file)
@@ -35,6 +35,15 @@ namespace LibTVRefCommonPortable.DataModels
         public bool IsRemovable { get; set; }
 
         [XmlIgnore]
+        public bool IsVisible { get; set; } = true;
+
+        [XmlIgnore]
+        public bool IsDim { get; set; }
+
+        [XmlIgnore]
+        public bool IsShowOptions { get; set; }
+
+        [XmlIgnore]
         public DateTime Installed { get; set; }
 
         [XmlIgnore]
@@ -56,5 +65,29 @@ namespace LibTVRefCommonPortable.DataModels
             IsPinned = value;
             OnPropertyChanged("IsPinned");
         }
+
+        public void SetVisible(bool value)
+        {
+            IsVisible = value;
+            OnPropertyChanged("IsVisible");
+        }
+
+        public void SetDim(bool value)
+        {
+            IsDim = value;
+            OnPropertyChanged("IsDim");
+        }
+
+        public void  ShowOptions()
+        {
+            IsShowOptions = true;
+            OnPropertyChanged("IsShowOptions");
+        }
+
+        public void HideOptions()
+        {
+            IsShowOptions = false;
+            OnPropertyChanged("IsShowOptions");
+        }
     }
 }
index 4e7f764..b2b1036 100755 (executable)
@@ -3,33 +3,34 @@
           xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
           x:Class="TVApps.Controls.AppItemCell">
   <RelativeLayout BackgroundColor="#000000"
-             HeightRequest="266"
+             HeightRequest="342"
              WidthRequest="240">
     <Image x:Name="ButtonImage"
-           RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.6833}"
+           RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.4795}"
            RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.6833}"
-           RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.1}"
+           RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.2923}"
            RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.1583}"
+                IsVisible="{Binding IsVisible}"
            Source="{Binding CurrentStateDescription.IconPath}" />
     <Image x:Name="DimImage"
-           RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.6833}"
-           RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.6833}"
-           RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.1}"
+           RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonImage, Property=Height, Factor=1}"
+           RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonImage, Property=Width, Factor=1}"
+           RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.2923}"
            RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.1583}"
            Source="img_tizen_apps_list_dimmed_check.png"
            Opacity="0"
            Scale="0" />
     <Image x:Name="CheckImage"
-           RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.4}"
-           RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.4}"
-           RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.2417}"
+           RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonImage, Property=Height, Factor=0.5853}"
+           RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonImage, Property=Width, Factor=0.5853}"
+           RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.3918}"
            RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.3}"
            Source="ic_tizen_apps_launcher_pinmark.png"
            Opacity="0" />
     <Grid x:Name="TextArea"
           RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.1333}"
           RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
-          RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.7744}">
+          RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.8245}">
       <Grid.RowDefinitions>
         <RowDefinition Height="6*" />
         <RowDefinition Height="18*" />
                Grid.Column="3"
                Opacity="0" />
     </Grid>
+
+    <!-- This BoxView is temporary code for Long Press test -->
+    <BoxView x:Name="ItemDim"
+             Color="Black"
+             Opacity="0.5"
+             IsVisible="{Binding IsDim}"
+             RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
+             RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}" />
+
     <Button x:Name = "ButtonFocusArea"
             RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
             RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
index 0749c64..8539b35 100755 (executable)
@@ -46,6 +46,13 @@ namespace TVApps.Controls
             set { SetValue(IsCheckedProperty, value); }
         }
 
+        public static readonly BindableProperty IsShowOptionsProperty = BindableProperty.Create("IsShowOptions", typeof(bool), typeof(AppItemCell), default(bool));
+        public bool IsShowOptions
+        {
+            get { return (bool)GetValue(IsShowOptionsProperty); }
+            set { SetValue(IsShowOptionsProperty, value); }
+        }
+
         public AppItemCell()
         {
             InitializeComponent();
@@ -88,6 +95,21 @@ namespace TVApps.Controls
 
                 return;
             }
+            else if (e.PropertyName.CompareTo("IsShowOptions") == 0)
+            {
+                if (IsShowOptions)
+                {
+                    ButtonImage.TranslateTo(0, -50, 100);
+                    TextArea.TranslateTo(0, -50, 100);
+                    TextArea.FadeTo(0.0, 100);
+                }
+                else
+                {
+                    ButtonImage.TranslateTo(0, 0, 100);
+                    TextArea.TranslateTo(0, 0, 100);
+                    TextArea.FadeTo(0.99, 100);
+                }
+            }
         }
 
         private void ButtonTitle_PropertyChanged(object sender, PropertyChangedEventArgs e)
index e44fc05..c07475b 100755 (executable)
@@ -6,27 +6,32 @@
             x:Class="TVApps.Controls.AppListView"
             HorizontalOptions="Fill"
             Orientation="Horizontal">
-  <Grid x:Name="AppListGrid"
-        HorizontalOptions="Start"
-        Padding="58,0,58,0">
-    <Grid.RowDefinitions>
-      <RowDefinition Height="133*" />
-      <RowDefinition Height="8*" />
-      <RowDefinition Height="133*" />
-    </Grid.RowDefinitions>
-    <Grid.RowSpacing>0</Grid.RowSpacing>
-    <Grid.ColumnSpacing>0</Grid.ColumnSpacing>
+
+  <RelativeLayout x:Name="AppListGrid"
+                  HorizontalOptions="Start"
+                  RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
+                  RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
+                  RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0}"
+                  RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0}"
+                  Padding="58, 0, 58, 0">
 
     <StackLayout x:Name="AppUpperList"
-                 Grid.Row="0"
+                 RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.4772}"
+                 RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
+                 RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0}"
+                 RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0}"
                  Orientation="Horizontal"
                  HorizontalOptions="Start"
                  Spacing="16"/>
 
     <StackLayout x:Name="AppLowerList"
-                 Grid.Row="2"
+                 RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.4772}"
+                 RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
+                 RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=AppUpperList, Property=Height, Factor=1, Constant=20}"
+                 RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0}"
                  Orientation="Horizontal"
                  HorizontalOptions="Start"
                  Spacing="16"/>
-  </Grid>
+
+  </RelativeLayout>
 </ScrollView>
index 6fedbef..e2dcb40 100644 (file)
@@ -97,6 +97,7 @@ namespace TVApps.Controls
                 viewCell.View.BindingContext = item;
                 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.OnClickedCommand = new Command(() =>
                 {
                     item.DoAction();
index d6ca14c..29056bf 100644 (file)
@@ -104,6 +104,22 @@ namespace TVApps.ViewModels
                 };
 
                 item.StateDescriptions.Add(AppsStatus.Delete.ToString().ToLower(), deleteStateDescription);
+
+                var longPressStateDescription = new StateDescription()
+                {
+                    Label = item.CurrentStateDescription.Label,
+                    IconPath = item.CurrentStateDescription.IconPath,
+                    Action = new CommandAction()
+                    {
+                        NextStateDescription = AppsStatus.LongPress.ToString().ToLower(),
+                        Command = new Command<string>((key) =>
+                        {
+                            LongPressApp(key);
+                        }),
+                        CommandParameter = item.AppID
+                    }
+                };
+                item.StateDescriptions.Add(AppsStatus.LongPress.ToString().ToLower(), longPressStateDescription);
             }
 
             InstalledApps = installedApps.ToList();
@@ -158,6 +174,12 @@ namespace TVApps.ViewModels
             }
         }
 
+        private void LongPressApp(string AppID)
+        {
+            // TODO:
+            DebuggingUtils.Dbg(" +++++ long press app : " + AppID);
+        }
+
         public void UpdateStateDescription(AppsStatus status)
         {
             string tag = status.ToString().ToLower();
@@ -224,5 +246,71 @@ namespace TVApps.ViewModels
                 UpdatePinnedApps();
             }
         }
+
+        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.ShowOptions();
+            }
+        }
+
+    public void HideLongPressOption(string appId)
+        {
+            InstalledApps = new List<AppShortcutInfo>(InstalledApps);
+            AppShortcutInfo longPressedApp = InstalledApps.Find(app => app.AppID.Equals(appId));
+            if (longPressedApp != null)
+            {
+                longPressedApp.HideOptions();
+            }
+        }
     }
 }
index 15519da..cf79e29 100644 (file)
@@ -28,6 +28,7 @@ namespace TVApps.ViewModels
         Default = 0,
         Pin,
         Delete,
+        LongPress,
     };
 
     public enum SortingOptions
@@ -57,6 +58,11 @@ namespace TVApps.ViewModels
         public Command ButtonPinOkCommand { get; set; }
         public Command ButtonPinCancelCommand { get; set; }
 
+        //This command is temporary for option menu test
+        public Command SetLongPressCommand { get; set; }
+        //This command is temporary for option menu test
+        public Command UnSetLongPressCommand { get; set; }
+
         public AppsStatus CurrentStatus { get; private set; }
 
         private SortingOptions SortingOption
@@ -131,6 +137,31 @@ namespace TVApps.ViewModels
                 ChangeCurrentStatus(AppsStatus.Default);
             });
 
+            SetLongPressCommand = new Command((appId) =>
+            {
+                DebuggingUtils.Dbg(" === Set LongPress AppID : " + appId);
+
+                // 1. ItemCell will be dimmed
+                appsHolder.SetAppItemDim((string) appId);
+
+                // 2. The selected icon on apps list will be moved
+                appsHolder.ShowLongPressOption((string)appId);
+                // 3. The option menu will be shown
+
+            });
+
+            UnSetLongPressCommand = new Command((appId) =>
+            {
+                DebuggingUtils.Dbg(" === Unset LongPress AppID : " + appId);
+
+                // 1. The option menu will be hidden
+                // 2. The selected icon will be moved
+                appsHolder.HideLongPressOption((string)appId);
+
+                // 3. ItemCell will be changed to normal
+                appsHolder.UnsetAppItemDim((string) appId);
+            });
+
             App.SetBackKeyListener((s, e) =>
             {
                 // TODO : check concurrency
index dd30318..c4aaf8b 100755 (executable)
@@ -51,9 +51,8 @@
 
   <Grid>
     <Grid.RowDefinitions>
-      <RowDefinition Height="145*" />
-      <RowDefinition Height="5*" />
-      <RowDefinition Height="274*" />
+      <RowDefinition Height="95*" />
+      <RowDefinition Height="329*" />
       <RowDefinition Height="52*" />
       <RowDefinition Height="64*" />
     </Grid.RowDefinitions>
@@ -68,7 +67,6 @@
              Text="APPS" />
 
     <Grid Grid.Row="0">
-
       <Grid.RowDefinitions>
         <RowDefinition Height="37*" />
         <RowDefinition Height="34*" />
         <ColumnDefinition Width="50*" />
       </Grid.ColumnDefinitions>
 
+      <!-- This StackLayout is temporary code for Long Press test -->
+      <Button Grid.Row="0" Grid.Column="1"
+              Text="Set LongPress"
+              FontSize="30"
+              Style="{StaticResource button}"
+              Command="{Binding SetLongPressCommand}"
+              CommandParameter="org.tizen.example.TVHome.TizenTV"
+              VerticalOptions="FillAndExpand"
+              HorizontalOptions="FillAndExpand"/>
+      <Button Grid.Row="2" Grid.Column="1"
+              Text="UnSet LongPress"
+              FontSize="30"
+              Style="{StaticResource button}"
+              Command="{Binding UnSetLongPressCommand}"
+              CommandParameter="org.tizen.example.TVHome.TizenTV"
+              VerticalOptions="FillAndExpand"
+              HorizontalOptions="FillAndExpand"/>
+
       <StackLayout Grid.Row="1" Grid.Column="1"
                    VerticalOptions="FillAndExpand"
                    HorizontalOptions="StartAndExpand"
                    Orientation="Horizontal">
-
         <Image Source="ic_tizen_apps_additional_back.png"
                WidthRequest="40"
                HeightRequest="40"
                VerticalOptions="Center"/>
-
         <Label x:Name="BackKeyInfo"
                Style="{StaticResource backKeyInfoText}"
                Margin="6, 0, 0, 0"
                HorizontalOptions="End"
                HorizontalTextAlignment="Start"/>
       </StackLayout>
-
     </Grid>
 
     <Controls:AppListView x:Name="AppList"
-                          Grid.Row="2"
+                          Grid.Row="1"
                           ItemsSource="{Binding InstalledAppList}">
       <Controls:AppListView.ItemTemplate>
         <DataTemplate>
       </Controls:AppListView.ItemTemplate>
     </Controls:AppListView>
 
-    <Views:FooterNormalStatus Grid.Row="4"
+    <Views:FooterNormalStatus Grid.Row="3"
                                 x:Name="FooterNormal"
                                 IsVisible="true" />
 
-    <Views:FooterPinStatus Grid.Row="4"
+    <Views:FooterPinStatus Grid.Row="3"
                              x:Name="FooterPin"
                              IsVisible="false" />
 
-    <Views:FooterDeleteStatus Grid.Row="4"
+    <Views:FooterDeleteStatus Grid.Row="3"
                                x:Name="FooterDelete"
                                IsVisible="false" />
   </Grid>
index b6c96ec..8c26a32 100644 (file)
@@ -66,6 +66,12 @@ namespace TVApps.Views
                     FooterDelete.IsVisible = true;
                     BackKeyInfo.Text = "Back";
                     break;
+                case AppsStatus.LongPress:
+                    FooterNormal.IsVisible = true;
+                    FooterPin.IsVisible = false;
+                    FooterDelete.IsVisible = false;
+                    BackKeyInfo.Text = "Back";
+                    break;
             }
 
             AppList.InitializeFocus();