From: Heonjae Jang Date: Thu, 9 Mar 2017 00:25:06 +0000 (+0900) Subject: Remove Utils, Ports in Apps and Change Apps List X-Git-Tag: submit/tizen/20170808.015446~218 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cff57d0bb2d1f3064810cf6a010df7aef6792713;p=profile%2Ftv%2Fapps%2Fdotnet%2Fhome.git Remove Utils, Ports in Apps and Change Apps List 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 --- diff --git a/LibTVRefCommonPortable/DataModels/AppShortcutInfo.cs b/LibTVRefCommonPortable/DataModels/AppShortcutInfo.cs index 3abdc6f..80b6037 100644 --- a/LibTVRefCommonPortable/DataModels/AppShortcutInfo.cs +++ b/LibTVRefCommonPortable/DataModels/AppShortcutInfo.cs @@ -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"); diff --git a/LibTVRefCommonPortable/Models/AppShortcutController.cs b/LibTVRefCommonPortable/Models/AppShortcutController.cs index ba144bf..325a5d5 100644 --- a/LibTVRefCommonPortable/Models/AppShortcutController.cs +++ b/LibTVRefCommonPortable/Models/AppShortcutController.cs @@ -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> GetList() + { + // TODO : This is a clone of AppShorcutController.ReadFromFile(). Write new code by using RUA + IApplicationManagerAPIs applicationManagerPort = DependencyService.Get(); + List appShortcutInfoList = new List(); + + var installedAppList = await applicationManagerPort.GetAllInstalledApplication(); + + foreach (KeyValuePair 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 ReadFromFile() { IApplicationManagerAPIs applicationManagerPort = DependencyService.Get(); diff --git a/LibTVRefCommonPortable/Utils/IApplicationManagerAPIs.cs b/LibTVRefCommonPortable/Utils/IApplicationManagerAPIs.cs index cd33c16..6fe6aca 100644 --- a/LibTVRefCommonPortable/Utils/IApplicationManagerAPIs.cs +++ b/LibTVRefCommonPortable/Utils/IApplicationManagerAPIs.cs @@ -24,6 +24,7 @@ namespace LibTVRefCommmonPortable.Utils { public interface IApplicationManagerAPIs { + Task> GetAllInstalledApplication(); Task> GetRecentApplications(); Dictionary GetInstalledApplication(string applicationId); } diff --git a/LibTVRefCommonTizen/Ports/ApplicationManagerPort.cs b/LibTVRefCommonTizen/Ports/ApplicationManagerPort.cs index dc3b1a2..c2e8b42 100644 --- a/LibTVRefCommonTizen/Ports/ApplicationManagerPort.cs +++ b/LibTVRefCommonTizen/Ports/ApplicationManagerPort.cs @@ -87,13 +87,15 @@ namespace LibTVRefCommonTizen.Ports return result; } - /* - public async Task> GetAllInstalledApplication() + + public async Task> GetAllInstalledApplication() { try { - List appItemList = new List(); + Dictionary resultList = new Dictionary(); Task> 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 index baffdb5..0000000 --- a/TVApps/TVApps.TizenTV/ApplicationManagerPort.cs +++ /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> GetAllInstalledApplication() - { - try - { - List appItemList = new List(); - Task> task = ApplicationManager.GetInstalledApplicationsAsync(); - if (task == null) - { - DebuggingPort.D("GetInstalledApplication failed"); - return null; - } - - IEnumerable 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 diff --git a/TVApps/TVApps.TizenTV/TVApps.TizenTV.csproj b/TVApps/TVApps.TizenTV/TVApps.TizenTV.csproj index 30d1772..283d6ef 100644 --- a/TVApps/TVApps.TizenTV/TVApps.TizenTV.csproj +++ b/TVApps/TVApps.TizenTV/TVApps.TizenTV.csproj @@ -47,7 +47,6 @@ - diff --git a/TVApps/TVApps/Controls/AppItemCell.xaml b/TVApps/TVApps/Controls/AppItemCell.xaml index 622b938..7af0b02 100755 --- a/TVApps/TVApps/Controls/AppItemCell.xaml +++ b/TVApps/TVApps/Controls/AppItemCell.xaml @@ -2,40 +2,40 @@ - - - -