using System;
using System.Collections.Generic;
+
using LibTVRefCommonPortable.DataModels;
using LibTVRefCommonPortable.Utils;
using System.Threading.Tasks;
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);
}
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,
appShortcutInfo.CurrentStateDescription = defaultStateDescription;
appShortcutInfo.IsPinned = true;
returnPinnedAppsInfo.Add(appShortcutInfo);
-
- numberOfPinnedApp += 1;
}
return returnPinnedAppsInfo;
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;