From: cskim Date: Sat, 15 Apr 2017 06:22:15 +0000 (+0900) Subject: Remove TVHome, TVApps, MediaHub from the Recent list. X-Git-Tag: submit/tizen/20170808.015446~112 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2ccd5a406b83aa6902436f673930e3634750f04f;p=profile%2Ftv%2Fapps%2Fdotnet%2Fhome.git Remove TVHome, TVApps, MediaHub from the Recent list. Change-Id: I8c4f4ebb93722175ae1d21668411b53fa2029a3b --- diff --git a/LibTVRefCommonPortable/LibTVRefCommonPortable.csproj b/LibTVRefCommonPortable/LibTVRefCommonPortable.csproj index ff74f8d..ce6975d 100755 --- a/LibTVRefCommonPortable/LibTVRefCommonPortable.csproj +++ b/LibTVRefCommonPortable/LibTVRefCommonPortable.csproj @@ -48,6 +48,7 @@ + diff --git a/LibTVRefCommonPortable/Models/AppShortcutController.cs b/LibTVRefCommonPortable/Models/AppShortcutController.cs index 6397193..24f88c2 100755 --- a/LibTVRefCommonPortable/Models/AppShortcutController.cs +++ b/LibTVRefCommonPortable/Models/AppShortcutController.cs @@ -33,40 +33,11 @@ namespace LibTVRefCommonPortable.Models /// public class AppShortcutController { - /// - /// The app ID of TV reference home application - /// - // TODO : change application later - public static string TVHomeAppID = "org.tizen.xahome"; - - /// - /// The app ID of TV reference apps-tray application - /// - public static string TVAppsAppID = "org.tizen.xaapps"; - - /// - /// The app ID of TV reference apps-tray application - /// - public static string MediaHubAppID = "org.tizen.xamediahub"; - /// /// A default app icon for no icon applications. /// private static String DefaultAppIcon = "AppIcon.png"; - - private bool IsNonPinnableApps(string appID) - { - if (appID.CompareTo(TVHomeAppID) == 0 || - appID.CompareTo(TVAppsAppID) == 0 || - appID.CompareTo(MediaHubAppID) == 0) - { - return true; - } - - return false; - } - /// /// A method provides installed app list. /// The returned app list has only Tizen UI apps not the system app or no display apps. @@ -80,6 +51,11 @@ namespace LibTVRefCommonPortable.Models foreach (KeyValuePair item in installedAppList) { + if (ManagedApps.IsNonPinnableApps(item.Key)) + { + continue; + } + var defaultStateDescription = new StateDescription() { Label = item.Value[0], @@ -122,7 +98,7 @@ namespace LibTVRefCommonPortable.Models IconPath = "ic_tizen_home_list_allapps_normal.png", Action = new AppControlAction { - AppID = TVAppsAppID, + AppID = ManagedApps.TVAppsAppID, } }; @@ -139,7 +115,7 @@ namespace LibTVRefCommonPortable.Models IconPath = "ic_tizen_home_list_mediahub_normal.png", Action = new AppControlAction { - AppID = MediaHubAppID, + AppID = ManagedApps.MediaHubAppID, } }; @@ -195,7 +171,7 @@ namespace LibTVRefCommonPortable.Models foreach (AppShortcutInfo appShortcutInfo in pinned_apps_info) { - if (IsNonPinnableApps(appShortcutInfo.AppID)) + if (ManagedApps.IsNonPinnableApps(appShortcutInfo.AppID)) { continue; } @@ -279,7 +255,7 @@ namespace LibTVRefCommonPortable.Models foreach (AppShortcutInfo appShortcutInfo in pinned_apps_info) { - if (IsNonPinnableApps(appShortcutInfo.AppID)) + if (ManagedApps.IsNonPinnableApps(appShortcutInfo.AppID)) { continue; } diff --git a/LibTVRefCommonPortable/Models/ManagedApps.cs b/LibTVRefCommonPortable/Models/ManagedApps.cs new file mode 100644 index 0000000..ac1892e --- /dev/null +++ b/LibTVRefCommonPortable/Models/ManagedApps.cs @@ -0,0 +1,99 @@ +/* + * 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.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LibTVRefCommonPortable.Models +{ + /// + /// A class has some apps have to managed in the TVHome, TVApps by platform policy reason. + /// + public class ManagedApps + { + /// + /// The app ID of TV reference home application + /// + // TODO : change application later + public static string TVHomeAppID + { + get + { + return "org.tizen.xahome"; + } + } + + /// + /// The app ID of TV reference apps-tray application + /// + public static string TVAppsAppID + { + get + { + return "org.tizen.xaapps"; + } + } + + /// + /// The app ID of TV reference apps-tray application + /// + public static string MediaHubAppID + { + get + { + return "org.tizen.xamediahub"; + } + } + + /// + /// The Settings App ID + /// + public static string SettingsAppID + { + get + { + return "org.tizen.settings"; + } + } + + public static bool IsNonPinnableApps(string appID) + { + if (appID.CompareTo(TVHomeAppID) == 0 || + appID.CompareTo(TVAppsAppID) == 0 || + appID.CompareTo(MediaHubAppID) == 0) + { + return true; + } + + return false; + } + + public static bool IsHiddenRecentApp(string appID) + { + if (appID.CompareTo(TVHomeAppID) == 0 || + appID.CompareTo(TVAppsAppID) == 0 || + appID.CompareTo(MediaHubAppID) == 0) + { + return true; + } + + return false; + } + } +} diff --git a/LibTVRefCommonPortable/Models/RecentShortcutController.cs b/LibTVRefCommonPortable/Models/RecentShortcutController.cs index a3a7ca0..bf546cf 100755 --- a/LibTVRefCommonPortable/Models/RecentShortcutController.cs +++ b/LibTVRefCommonPortable/Models/RecentShortcutController.cs @@ -75,22 +75,44 @@ namespace LibTVRefCommonPortable.Models var recentApps = ApplicationManagerUtils.GetRecentApplications(); foreach (var item in recentApps) { + if (ManagedApps.IsHiddenRecentApp(item.AppID)) + { + continue; + } + var defaultStateDescription = new StateDescription() { - Label = item.applabel, - IconPath = item.iconPath, + Label = item.Applabel, + IconPath = item.IconPath, Action = new AppControlAction() { - AppID = item.appID, + AppID = item.AppID, } }; var recentShortcutInfo = new RecentShortcutInfo(); - // TODO : Revert this after getting a API from app framework team. - //recentShortcutInfo.ScreenshotPath = "screenshot_" + item.Value[0] + ".png"; - recentShortcutInfo.ScreenshotPath = "screenshot.png"; + + if (item.ScreenShot == null) + { + recentShortcutInfo.ScreenshotPath = "screenshot.png"; + + IFileSystemAPIs fsApi = DependencyService.Get(); + if (fsApi != null) + { + string testScreenShot = fsApi.PlatformShareStorage + item.AppID + ".png"; + if (fsApi.IsFileExist(testScreenShot)) + { + recentShortcutInfo.ScreenshotPath = testScreenShot; + } + } + } + else + { + recentShortcutInfo.ScreenshotPath = item.ScreenShot; + } + recentShortcutInfo.StateDescriptions.Add("default", defaultStateDescription); recentShortcutInfo.CurrentStateDescription = defaultStateDescription; - recentShortcutInfo.AppID = item.appID; + recentShortcutInfo.AppID = item.AppID; recentShortcutInfoList.Add(recentShortcutInfo); } diff --git a/LibTVRefCommonPortable/Utils/AppShortcutStorage.cs b/LibTVRefCommonPortable/Utils/AppShortcutStorage.cs index c5bea6c..83817d7 100644 --- a/LibTVRefCommonPortable/Utils/AppShortcutStorage.cs +++ b/LibTVRefCommonPortable/Utils/AppShortcutStorage.cs @@ -34,9 +34,7 @@ namespace LibTVRefCommonPortable.Utils /// /// A storage path. /// - // TODO : Make this working properly, a accessing below directory is not permitted. - // private String storagePath = "/home/owner/apps_rw/xahome/res/pinned_apps_info.xml"; - private static String storagePath = "/opt/usr/home/owner/share/pinned_apps_info.xml"; + private static String StoragePath; /// /// A file system watcher which checks if the targeted storage is changed. @@ -61,6 +59,10 @@ namespace LibTVRefCommonPortable.Utils /// private AppShortcutStorage() { + // TODO : Make this working properly, a accessing below directory is not permitted. + //return DependencyService.Get()?.AppDataStorage + "pinned_apps_info.xml"; + StoragePath = DependencyService.Get()?.PlatformShareStorage + "pinned_apps_info.xml"; + fileSystemWatcher.Run(); } @@ -72,9 +74,9 @@ namespace LibTVRefCommonPortable.Utils { IFileSystemAPIs fileSystem = DependencyService.Get(); - if (fileSystem.IsFileExist(storagePath) == false) + if (fileSystem.IsFileExist(StoragePath) == false) { - DebuggingUtils.Err("Set Default Pinned Apps" + storagePath); + DebuggingUtils.Err("Set Default Pinned Apps" + StoragePath); List result = new List(); Write(result); return result; @@ -82,21 +84,21 @@ namespace LibTVRefCommonPortable.Utils for (int i = 0; i < 5; i++) { - if (fileSystem.IsFileReady(storagePath)) + if (fileSystem.IsFileReady(StoragePath)) { break; } else if (i >= 4) { - DebuggingUtils.Err("Can't open storage" + storagePath); + DebuggingUtils.Err("Can't open storage" + StoragePath); return new List(); } await Task.Delay(100); - DebuggingUtils.Dbg("[" + i + "/5] Waiting for Writing" + storagePath); + DebuggingUtils.Dbg("[" + i + "/5] Waiting for Writing" + StoragePath); } - using (Stream fileStream = fileSystem.OpenFile(storagePath, UtilFileMode.Open)) + using (Stream fileStream = fileSystem.OpenFile(StoragePath, UtilFileMode.Open)) { Debug.Assert(fileStream != null); @@ -117,7 +119,7 @@ namespace LibTVRefCommonPortable.Utils { IFileSystemAPIs fileSystem = DependencyService.Get(); - using (Stream fileStream = fileSystem.OpenFile(storagePath, UtilFileMode.Create)) + using (Stream fileStream = fileSystem.OpenFile(StoragePath, UtilFileMode.Create)) { Debug.Assert(fileStream != null); diff --git a/LibTVRefCommonPortable/Utils/IApplicationManagerAPIs.cs b/LibTVRefCommonPortable/Utils/IApplicationManagerAPIs.cs index 97bb8a1..b5a7693 100755 --- a/LibTVRefCommonPortable/Utils/IApplicationManagerAPIs.cs +++ b/LibTVRefCommonPortable/Utils/IApplicationManagerAPIs.cs @@ -28,37 +28,42 @@ namespace LibTVRefCommonPortable.Utils /// /// A Recent instance ID /// - public String instanceID; + public String InstanceID; /// /// A Recent instance label /// - public String instanceLabel; + public String InstanceLabel; /// /// A app ID /// - public String appID; + public String AppID; /// /// A app label /// - public String applabel; + public String Applabel; /// /// A app icon path /// - public String iconPath; + public String IconPath; /// /// A last launched data /// - public DateTime launchedTime; + public DateTime LaunchedTime; /// /// A URI of accessible content if the Recent is a content. /// - public String uri; + public String Uri; + + /// + /// A File Path of screenshot of the recent app or recent content. + /// + public String ScreenShot; } /// diff --git a/LibTVRefCommonPortable/Utils/IFileSystemAPIs.cs b/LibTVRefCommonPortable/Utils/IFileSystemAPIs.cs index 745f6a7..d142b86 100644 --- a/LibTVRefCommonPortable/Utils/IFileSystemAPIs.cs +++ b/LibTVRefCommonPortable/Utils/IFileSystemAPIs.cs @@ -41,6 +41,16 @@ namespace LibTVRefCommonPortable.Utils /// public interface IFileSystemAPIs { + string AppDataStorage + { + get; + } + + string PlatformShareStorage + { + get; + } + /// /// A method opens a file on the given mode. /// diff --git a/LibTVRefCommonTizen/Ports/ApplicationManagerPort.cs b/LibTVRefCommonTizen/Ports/ApplicationManagerPort.cs index 1b79e72..9d99edf 100755 --- a/LibTVRefCommonTizen/Ports/ApplicationManagerPort.cs +++ b/LibTVRefCommonTizen/Ports/ApplicationManagerPort.cs @@ -105,13 +105,13 @@ namespace LibTVRefCommonTizen.Ports resultList.Add(new RecentApp() { - instanceID = app.InstanceId, - instanceLabel = app.InstanceName, - appID = app.ApplicationId, - applabel = (app.Label == null || app.Label.Length < 1) ? "No Name" : app.Label, - iconPath = app.IconPath, - launchedTime = app.LaunchTime, - uri = app.Uri, + InstanceID = app.InstanceId, + InstanceLabel = app.InstanceName, + AppID = app.ApplicationId, + Applabel = (app.Label == null || app.Label.Length < 1) ? "No Name" : app.Label, + IconPath = app.IconPath, + LaunchedTime = app.LaunchTime, + Uri = app.Uri, }); } } diff --git a/LibTVRefCommonTizen/Ports/FileSystemPort.cs b/LibTVRefCommonTizen/Ports/FileSystemPort.cs index 5d41d14..a5ede17 100644 --- a/LibTVRefCommonTizen/Ports/FileSystemPort.cs +++ b/LibTVRefCommonTizen/Ports/FileSystemPort.cs @@ -25,6 +25,38 @@ namespace LibTVRefCommonTizen.Ports /// public class FileSystemPort : IFileSystemAPIs { + /// + /// A directory path which should be used for app data storing. + /// + public static string AppDataStroagePath { private get; set; } + + /// + /// A property of AppDataStroagePath to be exported to PCL. + /// + public string AppDataStorage + { + get + { + return AppDataStroagePath ?? ""; + } + } + + /// + /// A directory path which should be used for sharing between apps. + /// + public static string PlatformShareStroagePath { private get; set; } + + /// + /// A property of PlatformShareStroagePath to be exported to PCL. + /// + public string PlatformShareStorage + { + get + { + return PlatformShareStroagePath ?? ""; + } + } + /// /// Opens the given file /// diff --git a/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs b/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs index ad11034..6c4c662 100755 --- a/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs +++ b/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs @@ -36,37 +36,25 @@ namespace TVApps.TizenTV /// private IPlatformNotification notification; - /// - /// Gets and Sets application resource path - /// - public static string AppResourcePath - { - get; - private set; - } - - /// - /// Gets and Sets application data path - /// - public static string AppDataPath - { - get; - private set; - } - /// /// A method will be called when application is created /// protected override void OnCreate() { base.OnCreate(); - var app = new App(MainWindow.ScreenSize.Width, MainWindow.ScreenSize.Height, MainWindow.ScreenDpi.X, ElmSharp.Elementary.GetScale()); - notification = app; - AppResourcePath = DirectoryInfo.Resource; - AppDataPath = DirectoryInfo.Data; + FileSystemPort.AppDataStroagePath = DirectoryInfo.Data; + FileSystemPort.PlatformShareStroagePath = "/opt/usr/home/owner/share/"; + + var app = new App(MainWindow.ScreenSize.Width, + MainWindow.ScreenSize.Height, + MainWindow.ScreenDpi.X, + ElmSharp.Elementary.GetScale()); + notification = app; + DbgPort.D("-----------------------------------"); DbgPort.D("Apps application is being loaded..."); + DbgPort.D("-----------------------------------"); LoadApplication(app); PackageManagerPort.RegisterCallbacks(notification); diff --git a/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs b/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs index ac184ee..5f42d57 100755 --- a/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs +++ b/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs @@ -35,35 +35,22 @@ namespace TVHome.TizenTV /// WindowPort windowPort; - /// - /// Gets or set the application resource path - /// - public static string AppResourcePath - { - get; - private set; - } - - /// - /// Gets or set the application data path - /// - public static string AppDataPath - { - get; - private set; - } - /// /// A method will be called when application is created /// protected override void OnCreate() { base.OnCreate(); - var app = new App(MainWindow.ScreenSize.Width, MainWindow.ScreenSize.Height, MainWindow.ScreenDpi.X, ElmSharp.Elementary.GetScale()); - notification = app; - AppResourcePath = DirectoryInfo.Resource; - AppDataPath = DirectoryInfo.Data; + FileSystemPort.AppDataStroagePath = DirectoryInfo.Data; + FileSystemPort.PlatformShareStroagePath = "/opt/usr/home/owner/share/"; + + var app = new App(MainWindow.ScreenSize.Width, + MainWindow.ScreenSize.Height, + MainWindow.ScreenDpi.X, + ElmSharp.Elementary.GetScale()); + + notification = app; DbgPort.D("-----------------------------------"); DbgPort.D("Home application is being loaded..."); diff --git a/TVHome/TVHome/ViewModels/MainPageViewModel.cs b/TVHome/TVHome/ViewModels/MainPageViewModel.cs index bd94e93..b7ee6e3 100755 --- a/TVHome/TVHome/ViewModels/MainPageViewModel.cs +++ b/TVHome/TVHome/ViewModels/MainPageViewModel.cs @@ -21,6 +21,7 @@ using System.Linq; using LibTVRefCommonPortable.DataModels; using LibTVRefCommonPortable.Utils; using Xamarin.Forms; +using LibTVRefCommonPortable.Models; namespace TVHome.ViewModels { @@ -276,9 +277,7 @@ namespace TVHome.ViewModels private void MakeMainMenuItems() { string[] AppName = { "Recent", "Apps", "Settings" }; - // TODO : Revert this before release - //string[] AppControlID = { "org.tizen.settings", "org.tizen.apps", "org.tizen.settings" }; - string[] AppControlID = { "org.tizen.xaapps", "org.tizen.xaapps", "org.tizen.settings" }; + string[] AppControlID = { ManagedApps.TVAppsAppID, ManagedApps.TVAppsAppID, ManagedApps.SettingsAppID }; string[] AppIconPath = { "ic_tizen_home_menu_{0}_normal.png",