Revert "Add Test cases for app shortcut, managedapps"
[profile/tv/apps/dotnet/home.git] / LibTVRefCommonPortable / Models / AppShortcutController.cs
index e6cbdd5..21d63de 100755 (executable)
@@ -16,6 +16,7 @@
 
 using System;
 using System.Collections.Generic;
+
 using LibTVRefCommonPortable.DataModels;
 using LibTVRefCommonPortable.Utils;
 using System.Threading.Tasks;
@@ -47,32 +48,38 @@ namespace LibTVRefCommonPortable.Models
 
             var installedAppList = await ApplicationManagerUtils.Instance.GetAllInstalledApplication();
 
-            foreach (var item in installedAppList)
+            foreach (KeyValuePair<string, string[]> item in installedAppList)
             {
-                if (ManagedApps.IsNonPinnableApps(item.AppID))
+                if (ManagedApps.IsNonPinnableApps(item.Key))
                 {
                     continue;
                 }
 
                 var defaultStateDescription = new StateDescription()
                 {
-                    Label = item.Applabel,
-                    IconPath = item.IconPath,
+                    Label = item.Value[0],
+                    IconPath = item.Value[2],
                     Action = new AppControlAction()
                     {
-                        AppID = item.AppID,
+                        AppID = item.Key,
                     }
                 };
 
+                long longDate;
+                if (long.TryParse(item.Value[3], out longDate) == false)
+                {
+                    longDate = long.MinValue;
+                }
+
                 var appShortcutInfo = new AppShortcutInfo()
                 {
-                    IsRemovable = ApplicationManagerUtils.Instance.GetAppInfoRemovable(item.AppID),
-                    Installed = item.InstalledTime,
+                    IsRemovable = ApplicationManagerUtils.Instance.GetAppInfoRemovable(item.Key),
+                    Installed = new DateTime(longDate),
                 };
 
                 appShortcutInfo.StateDescriptions.Add("default", defaultStateDescription);
                 appShortcutInfo.CurrentStateDescription = defaultStateDescription;
-                appShortcutInfo.AppID = item.AppID;
+                appShortcutInfo.AppID = item.Key;
                 appShortcutInfoList.Add(appShortcutInfo);
             }
 
@@ -217,38 +224,34 @@ namespace LibTVRefCommonPortable.Models
 
             List<ShortcutInfo> returnPinnedAppsInfo = new List<ShortcutInfo>();
 
-            int numberOfPinnedApp = 0;
             foreach (AppShortcutInfo appShortcutInfo in pinned_apps_info)
             {
-                if (numberOfPinnedApp >= 10)
-                {
-                    break;
-                }
-
-                if (appShortcutInfo.AppID == null ||
-                    appShortcutInfo.AppID.Length < 1)
+                if (ManagedApps.IsNonPinnableApps(appShortcutInfo.AppID))
                 {
                     continue;
                 }
 
-                if (ManagedApps.IsNonPinnableApps(appShortcutInfo.AppID))
+                Dictionary<string, string> appInfo = ApplicationManagerUtils.Instance.GetInstalledApplication(appShortcutInfo.AppID);
+
+                if (appInfo == null)
                 {
                     continue;
                 }
 
-                InstalledApp appInfo = ApplicationManagerUtils.Instance.GetInstalledApplication(appShortcutInfo.AppID);
-                if (appInfo == null)
+                string appLabel;
+                string appIconPath;
+
+                if (appInfo.TryGetValue("Label", out appLabel) == false)
                 {
-                    continue;
+                    appLabel = "No Name";
                 }
 
-                string appLabel = appInfo.Applabel ?? "No Name";
-                string appIconPath = appInfo.IconPath ?? DefaultAppIcon;
+                appInfo.TryGetValue("IconPath", out appIconPath);
 
                 var defaultStateDescription = new StateDescription()
                 {
                     Label = appLabel,
-                    IconPath = appIconPath,
+                    IconPath = appIconPath ?? DefaultAppIcon,
                     Action = new AppControlAction
                     {
                         AppID = appShortcutInfo.AppID,
@@ -259,8 +262,6 @@ namespace LibTVRefCommonPortable.Models
                 appShortcutInfo.CurrentStateDescription = defaultStateDescription;
                 appShortcutInfo.IsPinned = true;
                 returnPinnedAppsInfo.Add(appShortcutInfo);
-
-                numberOfPinnedApp += 1;
             }
 
             return returnPinnedAppsInfo;
@@ -305,21 +306,14 @@ namespace LibTVRefCommonPortable.Models
             IEnumerable<AppShortcutInfo> pinned_apps_info = await AppShortcutStorage.Read();
             Dictionary<string, string> pinnedAppsDictionary = new Dictionary<string, string>();
 
-            int numberOfPinnedApp = 0;
             foreach (AppShortcutInfo appShortcutInfo in pinned_apps_info)
             {
-                if (numberOfPinnedApp >= 10)
-                {
-                    break;
-                }
-
                 if (ManagedApps.IsNonPinnableApps(appShortcutInfo.AppID))
                 {
                     continue;
                 }
 
                 pinnedAppsDictionary.Add(appShortcutInfo.AppID, appShortcutInfo.AppID);
-                numberOfPinnedApp += 1;
             }
 
             return pinnedAppsDictionary;