From ca2576db39586e69fc8d3a3a7ee875b2fb24a635 Mon Sep 17 00:00:00 2001 From: cskim Date: Fri, 3 Mar 2017 14:01:20 +0900 Subject: [PATCH] Make TVApps displays app list temporarily Change-Id: Idc0a35363f734746040619b751313f50bcb5538a --- TVApps/TVApps.TizenTV/ApplicationManagerPort.cs | 84 +++++++++++++++++++ TVApps/TVApps.TizenTV/DebuggingPort.cs | 93 ++++++++++++++++++++++ TVApps/TVApps.TizenTV/SystemMessagingPort.cs | 40 ---------- TVApps/TVApps.TizenTV/TVApps.TizenTV.cs | 4 +- TVApps/TVApps.TizenTV/TVApps.TizenTV.csproj | 3 +- TVApps/TVApps/Controls/AppItemCell.xaml | 2 + TVApps/TVApps/Controls/AppItemCell.xaml.cs | 3 +- TVApps/TVApps/Controls/AppListView.xaml.cs | 1 + TVApps/TVApps/Impl/SystemMessaging.cs | 65 --------------- TVApps/TVApps/TVApps.csproj | 5 +- TVApps/TVApps/Utils/DebuggingUtils.cs | 92 +++++++++++++++++++++ .../IApplicationManagerAPIs.cs} | 12 +-- TVApps/TVApps/Utils/IDebuggingAPIs.cs | 45 +++++++++++ TVApps/TVApps/ViewModels/AppsListViewModel.cs | 20 ++++- TVApps/TVApps/Views/MainPage.xaml.cs | 5 +- TVHome/TVHome.TizenTV/TVHome.TizenTV.csproj | 4 + TVHome/TVHome.TizenTV/tizen-manifest.xml | 4 +- TVHome/TVHome/Controls/MainPanelButton.xaml.cs | 20 +---- TVHome/TVHome/Controls/SubPanelButton.xaml.cs | 5 ++ .../Controls/SubPanelThumbnailButton.xaml.cs | 4 + TVHome/TVHome/Views/SubPanel.xaml.cs | 6 ++ 21 files changed, 381 insertions(+), 136 deletions(-) create mode 100644 TVApps/TVApps.TizenTV/ApplicationManagerPort.cs create mode 100644 TVApps/TVApps.TizenTV/DebuggingPort.cs delete mode 100644 TVApps/TVApps.TizenTV/SystemMessagingPort.cs delete mode 100644 TVApps/TVApps/Impl/SystemMessaging.cs create mode 100644 TVApps/TVApps/Utils/DebuggingUtils.cs rename TVApps/TVApps/{Impl/ISystemMessaging.cs => Utils/IApplicationManagerAPIs.cs} (74%) create mode 100644 TVApps/TVApps/Utils/IDebuggingAPIs.cs diff --git a/TVApps/TVApps.TizenTV/ApplicationManagerPort.cs b/TVApps/TVApps.TizenTV/ApplicationManagerPort.cs new file mode 100644 index 0000000..421380b --- /dev/null +++ b/TVApps/TVApps.TizenTV/ApplicationManagerPort.cs @@ -0,0 +1,84 @@ +/* + * 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; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xamarin.Forms.Platform.Tizen.Native; +using Tizen; +using Tizen.Applications; +using TVApps.Utils; +using TVApps.Models; + +namespace TVApps.TizenTV.Ports +{ + 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/DebuggingPort.cs b/TVApps/TVApps.TizenTV/DebuggingPort.cs new file mode 100644 index 0000000..892ace1 --- /dev/null +++ b/TVApps/TVApps.TizenTV/DebuggingPort.cs @@ -0,0 +1,93 @@ +/* + * 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.Platform.Tizen.Native; +using Tizen; +using TVApps.Utils; + +namespace TVApps.TizenTV +{ + /// + /// Platform dependent implementation for the Logging and the Popup displaying. + /// DebuggingPort is implementing IDebuggingAPIs which is defined in Calculator shared project. + /// + /// + /// Please refer to Xamarin Dependency Service + /// https://developer.xamarin.com/guides/xamarin-forms/dependency-service/introduction/ + /// + class DebuggingPort : IDebuggingAPIs + { + /// + /// A TV Home Windows reference. This is used to display a Dialog + public static Xamarin.Forms.Platform.Tizen.Native.Window MainWindow + { + set; + get; + } + + /// + /// A Logging Tag. + public static string TAG = "apps"; + + /// + /// A method displays a debugging log. + /// A debugging message. + public void Dbg(string message) + { + Log.Debug(TAG, message); + } + + /// + /// A method displays a error log. + /// A error message. + public void Err(string message) + { + Log.Error(TAG, message); + } + + /// + /// A method displays a dialog with a given message. + /// A debugging message. + public void Popup(string message) + { + if (MainWindow == null) + { + return; + } + //bool result = await Xamarin.Forms.Page.DisplayAlert("Calculator", message, "OK"); + + Dialog toast = new Dialog(MainWindow); + toast.Title = message; + toast.Timeout = 2.3; + toast.BackButtonPressed += (s, e) => + { + toast.Dismiss(); + }; + toast.Show(); + } + + public static void D(string message) + { + Log.Debug(TAG, message); + } + + public static void E(string message) + { + Log.Error(TAG, message); + } + + } +} \ No newline at end of file diff --git a/TVApps/TVApps.TizenTV/SystemMessagingPort.cs b/TVApps/TVApps.TizenTV/SystemMessagingPort.cs deleted file mode 100644 index 061e3e9..0000000 --- a/TVApps/TVApps.TizenTV/SystemMessagingPort.cs +++ /dev/null @@ -1,40 +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 Tizen; -using TVApps.Impl; - -namespace TVApps.TizenTV -{ - public class SystemMessagingPort : ISystemMessaging - { - public static string TAG = "tvapps"; - public void Dbg(string message) - { - Log.Debug(TAG, message); - } - - public void Err(string message) - { - Log.Error(TAG, message); - } - - public void Toast(string message) - { - //Android.Widget.Toast.MakeText(Application.Context, message, ToastLength.Long).Show(); - } - } -} diff --git a/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs b/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs index 4c05099..358e24c 100644 --- a/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs +++ b/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs @@ -1,5 +1,6 @@ using System; using TVApps; +using TVApps.TizenTV.Ports; namespace TVApps.TizenTV { @@ -8,13 +9,14 @@ namespace TVApps.TizenTV protected override void OnCreate() { base.OnCreate(); - Xamarin.Forms.DependencyService.Register(); LoadApplication(new App()); } static void Main(string[] args) { var app = new Program(); + Xamarin.Forms.DependencyService.Register(); + Xamarin.Forms.DependencyService.Register(); Xamarin.Forms.Platform.Tizen.Forms.Init(app); app.Run(args); } diff --git a/TVApps/TVApps.TizenTV/TVApps.TizenTV.csproj b/TVApps/TVApps.TizenTV/TVApps.TizenTV.csproj index ea35eda..b117ab4 100644 --- a/TVApps/TVApps.TizenTV/TVApps.TizenTV.csproj +++ b/TVApps/TVApps.TizenTV/TVApps.TizenTV.csproj @@ -47,7 +47,8 @@ - + + diff --git a/TVApps/TVApps/Controls/AppItemCell.xaml b/TVApps/TVApps/Controls/AppItemCell.xaml index 2ab4892..c72977f 100644 --- a/TVApps/TVApps/Controls/AppItemCell.xaml +++ b/TVApps/TVApps/Controls/AppItemCell.xaml @@ -4,6 +4,7 @@ x:Class="TVApps.Controls.AppItemCell">