From 8c732e8ebba3c6805b6dfe7f5f853f121dd68adf Mon Sep 17 00:00:00 2001 From: cskim Date: Fri, 14 Apr 2017 20:56:32 +0900 Subject: [PATCH] Remove default pinned app. Add options for settings app. Change-Id: I6f2c038f096ebb2cc6005e7705b9a6c3465d3152 --- .../DataModels/AppControlAction.cs | 31 +++++++++++++++- .../Models/AppShortcutController.cs | 43 +++++++++++++++++++++- LibTVRefCommonPortable/Utils/AppControlUtils.cs | 16 ++++++++ LibTVRefCommonPortable/Utils/AppShortcutStorage.cs | 29 +-------------- LibTVRefCommonPortable/Utils/IAppControl.cs | 9 +++++ LibTVRefCommonTizen/Ports/AppControlPort.cs | 37 +++++++++++++++++++ TVHome/TVHome/ViewModels/MainPageViewModel.cs | 4 +- 7 files changed, 136 insertions(+), 33 deletions(-) diff --git a/LibTVRefCommonPortable/DataModels/AppControlAction.cs b/LibTVRefCommonPortable/DataModels/AppControlAction.cs index 7702ded..dfc9969 100644 --- a/LibTVRefCommonPortable/DataModels/AppControlAction.cs +++ b/LibTVRefCommonPortable/DataModels/AppControlAction.cs @@ -16,6 +16,7 @@ using System; using LibTVRefCommonPortable.Utils; +using System.Collections.Generic; namespace LibTVRefCommonPortable.DataModels { @@ -30,13 +31,41 @@ namespace LibTVRefCommonPortable.DataModels public string AppID { get; set; } /// + /// A dictionary which has extra data for App Control + /// + private Dictionary extraData; + + /// + /// A dictionary which has extra data for App Control + /// + public Dictionary ExtraData + { + get + { + if (extraData == null) + { + extraData = new Dictionary(); + } + + return extraData; + } + } + + /// /// A method which invoke a App Control to the application of the AppID /// /// a next state after App Control invocation public string Execute() { string result = "default"; - AppControlUtils.SendLaunchRequest(AppID); + if (ExtraData == null) + { + AppControlUtils.SendLaunchRequest(AppID); + } + else + { + AppControlUtils.SendLaunchRequest(AppID, ExtraData); + } return result; } diff --git a/LibTVRefCommonPortable/Models/AppShortcutController.cs b/LibTVRefCommonPortable/Models/AppShortcutController.cs index b536002..6397193 100755 --- a/LibTVRefCommonPortable/Models/AppShortcutController.cs +++ b/LibTVRefCommonPortable/Models/AppShortcutController.cs @@ -34,10 +34,39 @@ 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. @@ -93,7 +122,7 @@ namespace LibTVRefCommonPortable.Models IconPath = "ic_tizen_home_list_allapps_normal.png", Action = new AppControlAction { - AppID = "org.tizen.xaapps", + AppID = TVAppsAppID, } }; @@ -110,7 +139,7 @@ namespace LibTVRefCommonPortable.Models IconPath = "ic_tizen_home_list_mediahub_normal.png", Action = new AppControlAction { - AppID = "org.tizen.xamediahub", + AppID = MediaHubAppID, } }; @@ -166,6 +195,11 @@ namespace LibTVRefCommonPortable.Models foreach (AppShortcutInfo appShortcutInfo in pinned_apps_info) { + if (IsNonPinnableApps(appShortcutInfo.AppID)) + { + continue; + } + Dictionary appInfo = ApplicationManagerUtils.GetInstalledApplication(appShortcutInfo.AppID); if (appInfo == null) @@ -245,6 +279,11 @@ namespace LibTVRefCommonPortable.Models foreach (AppShortcutInfo appShortcutInfo in pinned_apps_info) { + if (IsNonPinnableApps(appShortcutInfo.AppID)) + { + continue; + } + pinnedAppsDictionary.Add(appShortcutInfo.AppID, appShortcutInfo.AppID); } diff --git a/LibTVRefCommonPortable/Utils/AppControlUtils.cs b/LibTVRefCommonPortable/Utils/AppControlUtils.cs index 5ebb287..f6188d3 100644 --- a/LibTVRefCommonPortable/Utils/AppControlUtils.cs +++ b/LibTVRefCommonPortable/Utils/AppControlUtils.cs @@ -14,6 +14,7 @@ * limitations under the License. */ +using System.Collections.Generic; using Xamarin.Forms; namespace LibTVRefCommonPortable.Utils @@ -38,6 +39,21 @@ namespace LibTVRefCommonPortable.Utils } /// + /// A method makes the package ID's app to be launched. + /// + /// A package ID of the targeted application. + /// A extra data for App Control invoking. + public static void SendLaunchRequest(string pkgID, IDictionary extraData) + { + if (DependencyService.Get() == null) + { + return; + } + + DependencyService.Get().SendLaunchRequest(pkgID, extraData); + } + + /// /// A method sends a add pin request App Control to TVApps app. /// public static void SendAddAppRequestToApps() diff --git a/LibTVRefCommonPortable/Utils/AppShortcutStorage.cs b/LibTVRefCommonPortable/Utils/AppShortcutStorage.cs index 94157ee..c5bea6c 100644 --- a/LibTVRefCommonPortable/Utils/AppShortcutStorage.cs +++ b/LibTVRefCommonPortable/Utils/AppShortcutStorage.cs @@ -65,32 +65,6 @@ namespace LibTVRefCommonPortable.Utils } /// - /// A method provides sample App Shortcuts. - /// - /// a App Shortcut list - private static List GetSampleList() - { - var pinnedAppsInfo = new List(); - - pinnedAppsInfo.Add(new AppShortcutInfo() - { - AppID = "org.tizen.settings", - }); - - pinnedAppsInfo.Add(new AppShortcutInfo() - { - AppID = "org.tizen.apps", - }); - - pinnedAppsInfo.Add(new AppShortcutInfo() - { - AppID = "org.tizen.home", - }); - - return pinnedAppsInfo; - } - - /// /// A method provides a App Shortcut list. /// /// A App Shortcut list. @@ -100,9 +74,8 @@ namespace LibTVRefCommonPortable.Utils if (fileSystem.IsFileExist(storagePath) == false) { - // TODO : Modify default pinned Apps DebuggingUtils.Err("Set Default Pinned Apps" + storagePath); - List result = GetSampleList(); + List result = new List(); Write(result); return result; } diff --git a/LibTVRefCommonPortable/Utils/IAppControl.cs b/LibTVRefCommonPortable/Utils/IAppControl.cs index c549066..ea57a98 100644 --- a/LibTVRefCommonPortable/Utils/IAppControl.cs +++ b/LibTVRefCommonPortable/Utils/IAppControl.cs @@ -15,6 +15,8 @@ */ +using System.Collections.Generic; + namespace LibTVRefCommonPortable.Utils { /// @@ -29,6 +31,13 @@ namespace LibTVRefCommonPortable.Utils void SendLaunchRequest(string pkgID); /// + /// Sends the launch request + /// + /// The app ID to explicitly launch + /// The extra data for the app control + void SendLaunchRequest(string AppId, IDictionary extraData); + + /// /// A method sends a add pin request App Control to TVApps app. /// void SendAddAppRequestToApps(); diff --git a/LibTVRefCommonTizen/Ports/AppControlPort.cs b/LibTVRefCommonTizen/Ports/AppControlPort.cs index 403d8eb..978d4cb 100644 --- a/LibTVRefCommonTizen/Ports/AppControlPort.cs +++ b/LibTVRefCommonTizen/Ports/AppControlPort.cs @@ -18,6 +18,7 @@ using System; using LibTVRefCommonPortable.Utils; using Tizen.Applications; +using System.Collections.Generic; namespace LibTVRefCommonTizen.Ports { @@ -78,6 +79,42 @@ namespace LibTVRefCommonTizen.Ports } /// + /// Sends the launch request + /// + /// The app ID to explicitly launch + /// The extra data for the app control + public void SendLaunchRequest(string AppId, IDictionary extraData) + { + try + { + AppControl appControl = new AppControl(); + + if (AppId == null || AppId.Length <= 0) + { + DebuggingUtils.Err("The AppID is null or blank"); + return; + } + + string value; + + appControl.ApplicationId = AppId; + foreach (var key in extraData.Keys) + { + if (extraData.TryGetValue(key, out value)) + { + appControl.ExtraData.Add(key, value); + } + } + + AppControl.SendLaunchRequest(appControl); + } + catch (InvalidOperationException) + { + DebuggingUtils.Err("Failed to create AppControl"); + } + } + + /// /// Sends the 'Add PIN apps' operation to TV Apps /// public void SendAddAppRequestToApps() diff --git a/TVHome/TVHome/ViewModels/MainPageViewModel.cs b/TVHome/TVHome/ViewModels/MainPageViewModel.cs index f79b72c..bd94e93 100755 --- a/TVHome/TVHome/ViewModels/MainPageViewModel.cs +++ b/TVHome/TVHome/ViewModels/MainPageViewModel.cs @@ -371,7 +371,6 @@ namespace TVHome.ViewModels private void MakeSettingsButtons() { string[] ShortCutLabel = { "Brightness", "Contrast", "Color", "Tint" }; - string[] shortCutActionID = { "org.tizen.settings", "org.tizen.settings", "org.tizen.settings", "org.tizen.settings" }; List TempList = new List(); @@ -412,8 +411,9 @@ namespace TVHome.ViewModels { AppControlAction appControlAction = new AppControlAction() { - AppID = shortCutActionID[i] + AppID = "org.tizen.settings", }; + appControlAction.ExtraData.Add("subview", ShortCutLabel[i].ToLower()); ShortcutInfo shortcutInfo = new SettingShortcutInfo() { -- 2.7.4