Remove Utils, Ports in Apps and Change Apps List
authorHeonjae Jang <heonjae.jang@samsung.com>
Thu, 9 Mar 2017 00:25:06 +0000 (09:25 +0900)
committerChulSeung Kim <charles0.kim@samsung.com>
Thu, 8 Jun 2017 09:34:45 +0000 (18:34 +0900)
1. Remove Utils and Ports in Apps, Use PCL
2. Rename AppListViewModel to MainPageViewModel
3. Remove AppItem Class, Use ShortcutInfo
4. Add IsChecked, IsPinned, IsRemovable Property in AppShortcutInfo

Change-Id: I011ccd7b6283739b425de5e66f276ff4c8243126

18 files changed:
LibTVRefCommonPortable/DataModels/AppShortcutInfo.cs
LibTVRefCommonPortable/Models/AppShortcutController.cs
LibTVRefCommonPortable/Utils/IApplicationManagerAPIs.cs
LibTVRefCommonTizen/Ports/ApplicationManagerPort.cs
TVApps/TVApps.TizenTV/ApplicationManagerPort.cs [deleted file]
TVApps/TVApps.TizenTV/TVApps.TizenTV.csproj
TVApps/TVApps/Controls/AppItemCell.xaml
TVApps/TVApps/Controls/AppListView.xaml
TVApps/TVApps/Controls/AppListView.xaml.cs
TVApps/TVApps/Models/AppItem.cs [deleted file]
TVApps/TVApps/TVApps.csproj
TVApps/TVApps/Utils/DebuggingUtils.cs [deleted file]
TVApps/TVApps/Utils/IApplicationManagerAPIs.cs [deleted file]
TVApps/TVApps/Utils/IDebuggingAPIs.cs [deleted file]
TVApps/TVApps/ViewModels/AppsListViewModel.cs [deleted file]
TVApps/TVApps/ViewModels/MainPageViewModel.cs [new file with mode: 0644]
TVApps/TVApps/Views/MainPage.xaml
TVApps/TVApps/Views/MainPage.xaml.cs

index 3abdc6f391111a0ae9f108c520c065b7f730c879..80b6037542fc9acf3361c75f09ec91186663934b 100644 (file)
@@ -24,7 +24,10 @@ namespace LibTVRefCommmonPortable.DataModels
     public class AppShortcutInfo : ShortcutInfo
     {
         public string AppID { get; set; }
-       
+        public bool IsChecked { get; set; }
+        public bool IsPinned { get; set; }
+        public bool IsRemovable { get; set; }
+
         public override void UpdateState()
         {
             SetCurrentState("default");
index ba144bf0eaa592016dbcc427239a58ea04942613..325a5d534b0a212c189033986270c67971cc0b2d 100644 (file)
@@ -20,7 +20,7 @@ using Xamarin.Forms;
 
 using LibTVRefCommmonPortable.DataModels;
 using LibTVRefCommmonPortable.Utils;
-
+using System.Threading.Tasks;
 
 namespace LibTVRefCommmonPortable.Models
 {
@@ -32,6 +32,35 @@ namespace LibTVRefCommmonPortable.Models
 
         }
 
+        public async Task<IEnumerable<AppShortcutInfo>> GetList()
+        {
+            // TODO : This is a clone of AppShorcutController.ReadFromFile(). Write new code by using RUA
+            IApplicationManagerAPIs applicationManagerPort = DependencyService.Get<IApplicationManagerAPIs>();
+            List<AppShortcutInfo> appShortcutInfoList = new List<AppShortcutInfo>();
+
+            var installedAppList = await applicationManagerPort.GetAllInstalledApplication();
+
+            foreach (KeyValuePair<string, string[]> item in installedAppList)
+            {
+                var defaultStateDescription = new StateDescription()
+                {
+                    Label = item.Value[0],
+                    IconPath = item.Value[2],
+                    Action = new AppControlAction()
+                    {
+                        AppID = item.Key,
+                    }
+                };
+                var appShortcutInfo = new AppShortcutInfo();
+
+                appShortcutInfo.StateDescriptions.Add("default", defaultStateDescription);
+                appShortcutInfo.CurrentStateDescription = defaultStateDescription;
+                appShortcutInfoList.Add(appShortcutInfo);
+            }
+
+            return appShortcutInfoList;
+        }
+
         public IEnumerable<AppShortcutInfo> ReadFromFile()
         {
             IApplicationManagerAPIs applicationManagerPort = DependencyService.Get<IApplicationManagerAPIs>();
index cd33c163d03b7f2682856331ca24a1b75d01756d..6fe6acaafd6cdf06024bd9cfdf8d9903ab0b41a2 100644 (file)
@@ -24,6 +24,7 @@ namespace LibTVRefCommmonPortable.Utils
 {
     public interface IApplicationManagerAPIs
     {
+        Task<Dictionary<string, string[]>> GetAllInstalledApplication();
         Task<Dictionary<string, string[]>> GetRecentApplications();
         Dictionary<string, string> GetInstalledApplication(string applicationId);
     }
index dc3b1a2619489610ae8080d9e4015352572bc1ea..c2e8b42d5624caadd1b2403a25fb35a82737800e 100644 (file)
@@ -87,13 +87,15 @@ namespace LibTVRefCommonTizen.Ports
 
             return result;
         }
-        /*
-        public async Task<IEnumerable<AppItem>> GetAllInstalledApplication()
+
+        public async Task<Dictionary<string, string[]>> GetAllInstalledApplication()
         {
             try
             {
-                List<AppItem> appItemList = new List<AppItem>();
+                Dictionary<string, string[]> resultList = new Dictionary<string, string[]>();
                 Task<IEnumerable<ApplicationInfo>> task = ApplicationManager.GetInstalledApplicationsAsync();
+                string[] result;
+
                 if (task == null)
                 {
                     DebuggingPort.D("GetInstalledApplication failed");
@@ -125,20 +127,23 @@ namespace LibTVRefCommonTizen.Ports
                     }
 
                     DebuggingPort.D("ADD" + appInfo.ToString());
-                    AppItem item = new AppItem();
-                    item.Title = appInfo.Label;
-                    item.IconUrl = appInfo.IconPath;
-                    item.IconColor = "#00000000";
-                    appItemList.Add(item);
+
+
+                    result = new string[3];
+
+                    result[0] = (appInfo.Label != null) ? appInfo.Label : null;
+                    result[1] = (appInfo.ApplicationId != null) ? appInfo.ApplicationId : null;
+                    result[2] = (System.IO.File.Exists(appInfo.IconPath)) ? appInfo.IconPath : "AppIcon.png";
+                    resultList.Add(appInfo.ApplicationId, result);
                 }
 
-                return appItemList;
+                return resultList;
             }
             catch (Exception exception)
             {
                 DebuggingPort.E(exception.Message);
                 return null;
             }
-        }*/
+        }
     }
 }
\ No newline at end of file
diff --git a/TVApps/TVApps.TizenTV/ApplicationManagerPort.cs b/TVApps/TVApps.TizenTV/ApplicationManagerPort.cs
deleted file mode 100644 (file)
index baffdb5..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using LibTVRefCommonTizen.Ports;
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Tizen.Applications;
-using TVApps.Models;
-using TVApps.Utils;
-
-namespace TVApps.TizenTV
-{
-    class ApplicationManagerPort : IApplicationManagerAPIs
-    {
-        public async Task<IEnumerable<AppItem>> GetAllInstalledApplication()
-        {
-            try
-            {
-                List<AppItem> appItemList = new List<AppItem>();
-                Task<IEnumerable<ApplicationInfo>> task = ApplicationManager.GetInstalledApplicationsAsync();
-                if (task == null)
-                {
-                    DebuggingPort.D("GetInstalledApplication failed");
-                    return null;
-                }
-
-                IEnumerable<ApplicationInfo> installedList = await task;
-
-                foreach (var appInfo in installedList)
-                {
-                    DebuggingPort.D("-------------------------------------");
-                    DebuggingPort.D("TRY" + appInfo.ToString());
-                    if (appInfo.IsNoDisplay)
-                    {
-                        continue;
-                    }
-
-                    Package pkgInfo = PackageManager.GetPackage(appInfo.PackageId);
-                    if (pkgInfo == null)
-                    {
-                        continue;
-                    }
-
-                    DebuggingPort.D("TRY" + pkgInfo.ToString());
-
-                    if (pkgInfo.IsSystemPackage)
-                    {
-                        continue;
-                    }
-
-                    DebuggingPort.D("ADD" + appInfo.ToString());
-                    AppItem item = new AppItem();
-                    item.Title = appInfo.Label;
-                    item.IconUrl = appInfo.IconPath;
-                    item.IconColor = "#00000000";
-                    appItemList.Add(item);
-                }
-
-                return appItemList;
-            }
-            catch (Exception exception)
-            {
-                DebuggingPort.E(exception.Message);
-                return null;
-            }
-        }
-
-    }
-}
\ No newline at end of file
index 30d17727c77cba80bb4f36d1ce24f2edf071811b..283d6ef392d4155cc206766314df7869097d2c01 100644 (file)
@@ -47,7 +47,6 @@
     <None Include="shared\res\TVApps.TizenTV.png" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="ApplicationManagerPort.cs" />
     <Compile Include="TVApps.TizenTV.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
index 622b938fcc90900df26c3949f813b3f3cb1dbef6..7af0b025a837789d01d0287eb7a39a9a3fd5a375 100755 (executable)
@@ -2,40 +2,40 @@
 <ViewCell xmlns="http://xamarin.com/schemas/2014/forms"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
              x:Class="TVApps.Controls.AppItemCell">
-  <RelativeLayout BackgroundColor="#000000">
-    <BoxView x:Name="ButtonBox"
-             WidthRequest="240"
-             HeightRequest="266"
-             Opacity="0"/>
-    <Image x:Name="ButtonImage"
-          RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.6165}"
-          RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0.6833}"
-          RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.0977}"
-          RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0.1583}"
-          Source="{Binding IconUrl}" />
-    <Label x:Name="ButtonTitle"
-           RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.78195}"
-           RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0.1167}"
-           RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0.7667}"
-           RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.1203}"
-           Opacity="1"
-           FontSize="58"
-           TextColor="White"
-           LineBreakMode="TailTruncation"
-           HorizontalTextAlignment="Center"
-           Text="{Binding Title}" />
-      <Image x:Name="PinnedIcon"
-          RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.075}"
-          RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0.075}"
-          RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.78195}"
-          RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonTitle, Property=Width, Factor=0}"
-          Source="{Binding IconUrl}"
-          Opacity="0"/>
-      <Button x:Name = "ButtonFocusArea"
-            RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=1}"
-            RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=1}"
-            Focused="OnFocused"
-            Unfocused="OnUnFocused"
-            Opacity="0" />
-  </RelativeLayout>
+    <RelativeLayout BackgroundColor="#000000">
+        <BoxView x:Name="ButtonBox"
+                 WidthRequest="240"
+                 HeightRequest="266"
+                 Opacity="0"/>
+        <Image x:Name="ButtonImage"
+              RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.6165}"
+              RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0.6833}"
+              RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.0977}"
+              RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0.1583}"
+              Source="{Binding CurrentStateDescription.IconPath}" />
+        <Label x:Name="ButtonTitle"
+               RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.78195}"
+               RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0.1167}"
+               RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0.7667}"
+               RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.1203}"
+               Opacity="1"
+               FontSize="58"
+               TextColor="White"
+               LineBreakMode="TailTruncation"
+               HorizontalTextAlignment="Center"
+               Text="{Binding CurrentStateDescription.Label}" />
+        <Image x:Name="PinnedIcon"
+            RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.075}"
+            RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0.075}"
+            RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.78195}"
+            RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonTitle, Property=Width, Factor=0}"
+            Source="{Binding IconUrl}"
+            Opacity="0"/>
+        <Button x:Name = "ButtonFocusArea"
+              RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=1}"
+              RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=1}"
+              Focused="OnFocused"
+              Unfocused="OnUnFocused"
+              Opacity="0" />
+    </RelativeLayout>
 </ViewCell>
index 71e66b089529d6fc3c78a461816a5f28a92b1226..78d3aee55bdbad47093cf77eb70774434dca9512 100755 (executable)
@@ -5,38 +5,27 @@
             xmlns:VM="clr-namespace:TVApps.ViewModels"
             x:Class="TVApps.Controls.AppListView"
             HorizontalOptions="Fill"
-            Orientation="Horizontal"
-            ItemsSource="{Binding AppItems}">
-  <ScrollView.BindingContext>
-    <VM:AppsListViewModel />
-  </ScrollView.BindingContext>
+            Orientation="Horizontal">
+    <Grid x:Name="AppListGrid"
+          HorizontalOptions="Start">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="4863*" />
+            <RowDefinition Height="274*" />
+            <RowDefinition Height="4863*" />
+        </Grid.RowDefinitions>
+        <Grid.RowSpacing>0</Grid.RowSpacing>
+        <Grid.ColumnSpacing>0</Grid.ColumnSpacing>
 
-  <Controls:AppListView.ItemTemplate>
-    <DataTemplate>
-      <Controls:AppItemCell />
-    </DataTemplate>
-  </Controls:AppListView.ItemTemplate>
-
-  <Grid x:Name="AppListGrid"
-        HorizontalOptions="Start">
-    <Grid.RowDefinitions>
-      <RowDefinition Height="4863*" />
-      <RowDefinition Height="274*" />
-      <RowDefinition Height="4863*" />
-    </Grid.RowDefinitions>
-    <Grid.RowSpacing>0</Grid.RowSpacing>
-    <Grid.ColumnSpacing>0</Grid.ColumnSpacing>
-
-    <StackLayout x:Name="AppUpperList"
-                 Grid.Row="0"
-                 Orientation="Horizontal"
-                 HorizontalOptions="Start"
-                 Spacing="0"/>
-    <BoxView Grid.Row="1"/>
-    <StackLayout x:Name="AppLowerList"
-                 Grid.Row="2"
-                 Orientation="Horizontal"
-                 HorizontalOptions="Start"
-                 Spacing="0"/>
-  </Grid>
+        <StackLayout x:Name="AppUpperList"
+                     Grid.Row="0"
+                     Orientation="Horizontal"
+                     HorizontalOptions="Start"
+                     Spacing="0"/>
+        <BoxView Grid.Row="1"/>
+        <StackLayout x:Name="AppLowerList"
+                     Grid.Row="2"
+                     Orientation="Horizontal"
+                     HorizontalOptions="Start"
+                     Spacing="0"/>
+    </Grid>
 </ScrollView>
index 2d3a5f3b3cd33423d4211333f882fee8b6b020c1..111f64d722119b5466fc4f4658c8974ccc624d33 100644 (file)
 using System.Linq;
 
 using Xamarin.Forms;
-using TVApps.Models;
 using System.Collections.ObjectModel;
 using System.Collections.Specialized;
 using System.ComponentModel;
+using LibTVRefCommmonPortable.DataModels;
+using LibTVRefCommmonPortable.Utils;
+using System.Collections.Generic;
 
 namespace TVApps.Controls
 {
     /// <summary>
-    /// hahaha
+    /// TV Apps Custom ListView
     /// </summary>
     public partial class AppListView : ScrollView
     {
-        public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create("ItemsSource", typeof(ObservableCollection<AppItem>), typeof(AppListView), default(ObservableCollection<AppItem>));
-        public ObservableCollection<AppItem> ItemsSource
+        public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create("ItemsSource", typeof(IEnumerable<ShortcutInfo>), typeof(AppListView), default(ObservableCollection<ShortcutInfo>));
+        public IEnumerable<ShortcutInfo> ItemsSource
         {
-            get { return (ObservableCollection<AppItem>)GetValue(ItemsSourceProperty); }
+            get { return (IEnumerable<ShortcutInfo>)GetValue(ItemsSourceProperty); }
             set { SetValue(ItemsSourceProperty, value); }
         }
 
@@ -50,60 +52,6 @@ namespace TVApps.Controls
             InitializeComponent();
             AppCount = 0;
             PropertyChanged += OnPropertyChange;
-            ItemsSource.CollectionChanged += OnItemSourceCollectionChange;
-        }
-
-        private void OnItemSourceCollectionChange(object sender, NotifyCollectionChangedEventArgs e)
-        {
-            if (e.Action == NotifyCollectionChangedAction.Add)
-            {
-                foreach (var item in e.NewItems)
-                {
-                    var viewCell = ItemTemplate.CreateContent() as ViewCell;
-                    viewCell.View.BindingContext = item;
-
-                    if (AppCount % 2 == 0)
-                    {
-                        AppUpperList.Children.Add(viewCell.View);
-                    }
-                    else
-                    {
-                        AppLowerList.Children.Add(viewCell.View);
-                    }
-
-                    AppCount = AppCount + 1;
-                }
-            }
-            else if (e.Action == NotifyCollectionChangedAction.Remove)
-            {
-                var isUpper = (e.OldStartingIndex % 2) == 0;
-                var itemIndex = e.OldStartingIndex / 2;
-                var upperItemCount = AppUpperList.Children.Count;
-                var lowerItemCount = AppLowerList.Children.Count;
-
-                if (isUpper)
-                {
-                    AppUpperList.Children.RemoveAt(itemIndex);
-                    upperItemCount = upperItemCount - 1;
-                }
-                else
-                {
-                    AppLowerList.Children.RemoveAt(itemIndex);
-                    lowerItemCount = lowerItemCount - 1;
-                }
-
-                for (var i = itemIndex; i < upperItemCount; i++)
-                {
-                    AppLowerList.Children.Add(AppUpperList.Children.ElementAt(itemIndex));
-                }
-
-                for (var i = itemIndex; i < lowerItemCount; i++)
-                {
-                    AppUpperList.Children.Add(AppLowerList.Children.ElementAt(itemIndex));
-                }
-
-                AppCount = AppCount - 1;
-            }
         }
 
         void OnPropertyChange(object sender, PropertyChangedEventArgs e)
diff --git a/TVApps/TVApps/Models/AppItem.cs b/TVApps/TVApps/Models/AppItem.cs
deleted file mode 100644 (file)
index 576e4cb..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-namespace TVApps.Models
-{
-    public class AppItem
-    {
-        string[] titles = { "Hello", "Tizen", "C#" };
-        string[] images = {"t1.png", "t2.png", "t3.png"};
-        string[] colors = { "#ffc0cb", "#d3ffce", "#20b2aa", "#cbbeb5", "#66cccc", "#4169e1" };
-        public string Title { get; set; }
-        public int ID { get; set; }
-        public string IconUrl { get; set; }
-        public DateTime InstallDate { get; set; }
-        public string IconColor { get; set; }
-
-        public AppItem()
-        {
-            Random r = new Random();
-            Title = titles[r.Next(0, 3)];
-            InstallDate = DateTime.Now;
-            IconUrl = images[r.Next(0, 3)];
-            IconColor = colors[r.Next(0, 6)];
-        }
-    }
-}
index 15447a5c0ae863e1bd97c69e3a4aa079f378d5b0..8fcf1cc42d63dce283eb87f43d3cbba688c1a6cc 100644 (file)
     <Compile Include="Controls\AppListView.xaml.cs">
       <DependentUpon>AppListView.xaml</DependentUpon>
     </Compile>
-    <Compile Include="Models\AppItem.cs" />
     <Compile Include="TVApps.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="Utils\DebuggingUtils.cs" />
-    <Compile Include="Utils\IApplicationManagerAPIs.cs" />
-    <Compile Include="Utils\IDebuggingAPIs.cs" />
-    <Compile Include="ViewModels\AppsListViewModel.cs" />
+    <Compile Include="ViewModels\MainPageViewModel.cs" />
     <Compile Include="Views\MainPage.xaml.cs">
       <DependentUpon>MainPage.xaml</DependentUpon>
     </Compile>
   <ItemGroup>
     <None Include="packages.config" />
   </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\LibTVRefCommonPortable\LibTVRefCommonPortable.csproj">
+      <Project>{67F9D3A8-F71E-4428-913F-C37AE82CDB24}</Project>
+      <Name>LibTVRefCommonPortable</Name>
+    </ProjectReference>
+  </ItemGroup>
   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
   <Import Project="..\..\packages\Xamarin.Forms.2.3.3.193\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.3.3.193\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets')" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
diff --git a/TVApps/TVApps/Utils/DebuggingUtils.cs b/TVApps/TVApps/Utils/DebuggingUtils.cs
deleted file mode 100644 (file)
index 42b14bc..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using Xamarin.Forms;
-
-namespace TVApps.Utils
-{
-    /// <summary>
-    /// A debugging utility class.
-    /// </summary>
-    public sealed class DebuggingUtils
-    {
-        private static IDebuggingAPIs ism;
-        private static readonly DebuggingUtils instance = new DebuggingUtils();
-
-        /// <summary>
-        /// A method provides instance of DebuggingUtils. </summary>
-        public static DebuggingUtils Instance
-        {
-            get { return instance; }
-        }
-
-        /// <summary>
-        /// Default implementation of IDebuggingAPIs interface .
-        /// This is required for the unit testing of the Calculator application. </summary>
-        private class DefaultSM : IDebuggingAPIs
-        {
-            public void Dbg(string message)
-            {
-            }
-
-            public void Err(string message)
-            {
-            }
-
-            public void Popup(string message)
-            {
-            }
-        }
-
-        /// <summary>
-        /// DebuggingUtils constructor which set interface instance. </summary>
-        private DebuggingUtils()
-        {
-            if (DependencyService.Get<IDebuggingAPIs>() != null)
-            {
-                ism = DependencyService.Get<IDebuggingAPIs>();
-            }
-            else
-            {
-                ism = new DefaultSM();
-            }
-        }
-
-        /// <summary>
-        /// A method displays a debugging message </summary>
-        /// <param name="message"> A list of command line arguments.</param>
-        public static void Dbg(string message)
-        {
-            ism.Dbg(message);
-        }
-
-        /// <summary>
-        /// A method displays a error message </summary>
-        /// <param name="message"> A list of command line arguments.</param>
-        public static void Err(string message)
-        {
-            ism.Err(message);
-        }
-
-        /// <summary>
-        /// A method displays a pop up  message </summary>
-        /// <param name="message"> A list of command line arguments.</param>
-        public static void Popup(string message)
-        {
-            ism.Popup(message);
-        }
-    }
-}
diff --git a/TVApps/TVApps/Utils/IApplicationManagerAPIs.cs b/TVApps/TVApps/Utils/IApplicationManagerAPIs.cs
deleted file mode 100644 (file)
index 0fe68f0..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using TVApps.Models;
-
-namespace TVApps.Utils
-{
-    public interface IApplicationManagerAPIs
-    {
-        Task<IEnumerable<AppItem>> GetAllInstalledApplication();
-    }
-}
diff --git a/TVApps/TVApps/Utils/IDebuggingAPIs.cs b/TVApps/TVApps/Utils/IDebuggingAPIs.cs
deleted file mode 100644 (file)
index a138c7c..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace TVApps.Utils
-{
-    /// <summary>
-    /// A interface contains debugging methods which are using platform subsystems.
-    /// </summary>
-    /// <remarks>
-    /// Implementing this class should be occurred in platform project.
-    /// Also the implementation should be registered to the DependencyService in a app initialization.
-    /// Please refer to Xamarin Dependency Service
-    /// https://developer.xamarin.com/guides/xamarin-forms/dependency-service/introduction/
-    /// </remarks>
-    public interface IDebuggingAPIs
-    {
-        /// <summary>
-        /// A method displays a debugging log. </summary>
-        /// <param name="message"> A debugging message.</param>
-        void Popup(string message);
-
-        /// <summary>
-        /// A method displays a error log. </summary>
-        /// <param name="message"> A error message.</param>
-        void Dbg(string message);
-
-        /// <summary>
-        /// A method displays a dialog with a given message. </summary>
-        /// <param name="message"> A debugging message.</param>
-        void Err(string message);
-    }
-}
diff --git a/TVApps/TVApps/ViewModels/AppsListViewModel.cs b/TVApps/TVApps/ViewModels/AppsListViewModel.cs
deleted file mode 100644 (file)
index bbabd86..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Threading.Tasks;
-using TVApps.Models;
-using TVApps.Utils;
-using Xamarin.Forms;
-
-namespace TVApps.ViewModels
-{
-    class AppsListViewModel
-    {
-        public ObservableCollection<AppItem> AppItems { get; set; }
-
-        public AppsListViewModel()
-        {
-            AppItems = new ObservableCollection<AppItem>();
-
-            GetInstalledApps();
-        }
-
-        private async void GetInstalledApps()
-        {
-            IApplicationManagerAPIs applicationManagerPort = DependencyService.Get<IApplicationManagerAPIs>();
-
-            IEnumerable<AppItem> appList = await applicationManagerPort.GetAllInstalledApplication();
-            foreach (var item in appList)
-            {
-                AppItems.Add(item);
-                DebuggingUtils.Dbg("ADD " + item.Title + ", " + item.IconUrl);
-            }
-        }
-
-        public void AddItem()
-        {
-            AppItems.Add(new AppItem());
-        }
-
-        public void RemoveItem()
-        {
-            if (AppItems.Count > 0)
-            {
-                AppItems.RemoveAt(0);
-            }
-        }
-
-        public void SortItem()
-        {
-            AppItems = new ObservableCollection<AppItem>(AppItems.OrderByDescending(AppItem => AppItem.Title));
-        }
-    }
-}
diff --git a/TVApps/TVApps/ViewModels/MainPageViewModel.cs b/TVApps/TVApps/ViewModels/MainPageViewModel.cs
new file mode 100644 (file)
index 0000000..331a4cf
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using LibTVRefCommmonPortable.DataModels;
+using LibTVRefCommmonPortable.Utils;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Threading.Tasks;
+using Xamarin.Forms;
+
+namespace TVApps.ViewModels
+{
+    class MainPageViewModel : INotifyPropertyChanged
+    {
+        public IEnumerable<ShortcutInfo> AppList { get; set; }
+
+        public event PropertyChangedEventHandler PropertyChanged;
+        protected void OnPropertyChanged(string name)
+        {
+            PropertyChangedEventHandler handler = PropertyChanged;
+            if (handler != null)
+            {
+                handler(this, new PropertyChangedEventArgs(name));
+            }
+        }
+
+        public MainPageViewModel()
+        {
+            GetInstalledApps();
+        }
+
+        private async void GetInstalledApps()
+        {
+            AppList = await TVHomeImpl.GetInstance.AppShortcutControllerInstance.GetList();
+            if (AppList != null)
+            {
+                OnPropertyChanged("AppList");
+            }
+        }
+    }
+}
index 35c2b2055e0824a0cbea2387bba85dc55894da33..2f79f252322a8323b18bc82d4bec81787734d0df 100755 (executable)
 <?xml version="1.0" encoding="utf-8" ?>
 <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+             xmlns:ViewModels="clr-namespace:TVApps.ViewModels"
              xmlns:Controls="clr-namespace:TVApps.Controls"
              x:Class="TVApps.Views.MainPage"
              BackgroundColor="#000000">
+    <ContentPage.BindingContext>
+        <ViewModels:MainPageViewModel />
+    </ContentPage.BindingContext>
 
-  <ContentPage.Resources>
-    <ResourceDictionary>
-      <Style x:Key="titleText" TargetType="Label" >
-        <Setter Property="FontSize" Value="187" />
-        <Setter Property="TextColor" Value="#FFFFFF" />
-        <Setter Property="FontFamily" Value="Samsung sans" />
-      </Style>
-      <Style x:Key="buttonTextNormal" TargetType="Label" >
-        <Setter Property="FontSize" Value="62" />
-        <Setter Property="TextColor" Value="#F7F7F7" />
-        <Setter Property="FontFamily" Value="Breeze Sans Regular" />
-      </Style>
-      <Style x:Key="buttonTextPressed" TargetType="Label" >
-        <Setter Property="FontSize" Value="62" />
-        <Setter Property="TextColor" Value="#F7F7F708" />
-        <Setter Property="FontFamily" Value="Breeze Sans Regular" />
-      </Style>
+    <ContentPage.Resources>
+        <ResourceDictionary>
+            <Style x:Key="titleText" TargetType="Label" >
+                <Setter Property="FontSize" Value="187" />
+                <Setter Property="TextColor" Value="#FFFFFF" />
+                <Setter Property="FontFamily" Value="Samsung sans" />
+            </Style>
+            <Style x:Key="buttonTextNormal" TargetType="Label" >
+                <Setter Property="FontSize" Value="62" />
+                <Setter Property="TextColor" Value="#F7F7F7" />
+                <Setter Property="FontFamily" Value="Breeze Sans Regular" />
+            </Style>
+            <Style x:Key="buttonTextPressed" TargetType="Label" >
+                <Setter Property="FontSize" Value="62" />
+                <Setter Property="TextColor" Value="#F7F7F708" />
+                <Setter Property="FontFamily" Value="Breeze Sans Regular" />
+            </Style>
 
-      <Style x:Key="button" TargetType="Button">
-        <Setter Property="BorderColor" Value="#FFFFFF"/>
-        <Setter Property="HeightRequest" Value="40"/>
-        <Setter Property="BorderWidth" Value="2" />
-        <Setter Property="HorizontalOptions" Value="Center"/>
-        <Setter Property="BackgroundColor" Value="Transparent"/>
-      </Style>
-    </ResourceDictionary>
-  </ContentPage.Resources>
+            <Style x:Key="button" TargetType="Button">
+                <Setter Property="BorderColor" Value="#FFFFFF"/>
+                <Setter Property="HeightRequest" Value="40"/>
+                <Setter Property="BorderWidth" Value="2" />
+                <Setter Property="HorizontalOptions" Value="Center"/>
+                <Setter Property="BackgroundColor" Value="Transparent"/>
+            </Style>
+        </ResourceDictionary>
+    </ContentPage.Resources>
 
-  <Grid>
-    <Grid.RowDefinitions>
-      <RowDefinition Height="2685*" />
-      <RowDefinition Height="83*" />
-      <RowDefinition Height="5074*" />
-      <RowDefinition Height="0981*" />
-      <RowDefinition Height="1185*" />
-    </Grid.RowDefinitions>
-    <Grid.RowSpacing>0</Grid.RowSpacing>
-    <Grid.ColumnSpacing>0</Grid.ColumnSpacing>
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="2685*" />
+            <RowDefinition Height="83*" />
+            <RowDefinition Height="5074*" />
+            <RowDefinition Height="0981*" />
+            <RowDefinition Height="1185*" />
+        </Grid.RowDefinitions>
+        <Grid.RowSpacing>0</Grid.RowSpacing>
+        <Grid.ColumnSpacing>0</Grid.ColumnSpacing>
 
-    <StackLayout Grid.Row="0"
-                   HorizontalOptions="FillAndExpand"
-                   VerticalOptions="FillAndExpand">
-      <Label
-             Style="{StaticResource titleText}"
-             HorizontalTextAlignment="Center"
-             VerticalOptions="CenterAndExpand"
-             HorizontalOptions="CenterAndExpand"
-             Text="APPS" />
-    </StackLayout>
+        <StackLayout Grid.Row="0"
+                       HorizontalOptions="FillAndExpand"
+                       VerticalOptions="FillAndExpand">
+            <Label
+                   Style="{StaticResource titleText}"
+                   HorizontalTextAlignment="Center"
+                   VerticalOptions="CenterAndExpand"
+                   HorizontalOptions="CenterAndExpand"
+                   Text="APPS" />
+        </StackLayout>
 
-    <BoxView Grid.Row="1"/>
+        <BoxView Grid.Row="1"/>
 
-    <Controls:AppListView Grid.Row="2"
-                          x:Name="AppListView"/>
+        <Controls:AppListView x:Name="AppListView"
+                              Grid.Row="2"
+                              ItemsSource="{Binding AppList}">
+            <Controls:AppListView.ItemTemplate>
+                <DataTemplate>
+                    <Controls:AppItemCell/>
+                </DataTemplate>
+            </Controls:AppListView.ItemTemplate>
+        </Controls:AppListView>
 
-    <BoxView Grid.Row="3"/>
+        <BoxView Grid.Row="3"/>
 
-    <Grid Grid.Row="4">
-      <Grid.ColumnDefinitions>
-        <ColumnDefinition Width="987*" />
-        <ColumnDefinition Width="701*" />
-        <ColumnDefinition Width="88*" />
-      </Grid.ColumnDefinitions>
+        <Grid Grid.Row="4">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="987*" />
+                <ColumnDefinition Width="701*" />
+                <ColumnDefinition Width="88*" />
+            </Grid.ColumnDefinitions>
 
-      <BoxView Grid.Column="0"/>
+            <BoxView Grid.Column="0"/>
 
-      <StackLayout Grid.Column="1"
-                   HorizontalOptions="FillAndExpand"
-                   VerticalOptions="FillAndExpand"
-                   Orientation="Horizontal">
-        <Button Style="{StaticResource button}"
-                Text="ADD"
-                Clicked="OnClickButtonAdd"/>
-        <Button Style="{StaticResource button}"
-                Text="REMOVE"
-                Clicked="OnClickButtonRemove"/>
-        <Button Style="{StaticResource button}"
-                Text="SORT"
-                Clicked="OnClickButtonSort"/>
-      </StackLayout>
+            <StackLayout Grid.Column="1"
+                         HorizontalOptions="FillAndExpand"
+                         VerticalOptions="FillAndExpand"
+                         Orientation="Horizontal">
+                <Button Style="{StaticResource button}"
+                        Text="ADD"/>
+                <Button Style="{StaticResource button}"
+                        Text="REMOVE"/>
+                <Button Style="{StaticResource button}"
+                        Text="SORT"/>
+            </StackLayout>
 
-      <BoxView Grid.Column="2"/>
+            <BoxView Grid.Column="2"/>
+        </Grid>
     </Grid>
-  </Grid>
 </ContentPage>
\ No newline at end of file
index 96d93cf551e7bf67954d0be046a9df378c4a1fad..9fc268e94d6a8527b13edbceea4a372b52e734ef 100644 (file)
@@ -30,23 +30,5 @@ namespace TVApps.Views
         {
             InitializeComponent();
         }
-
-        private void OnClickButtonAdd(object sender, EventArgs e)
-        {
-            var vm = (AppsListViewModel)AppListView.BindingContext;
-            vm.AddItem();
-        }
-
-        private void OnClickButtonRemove(object sender, EventArgs e)
-        {
-            var vm = (AppsListViewModel)AppListView.BindingContext;
-            vm.RemoveItem();
-        }
-
-        private void OnClickButtonSort(object sender, EventArgs e)
-        {
-            var vm = (AppsListViewModel)AppListView.BindingContext;
-            vm.SortItem();
-        }
     }
 }