Remove default pinned app.
authorcskim <charles0.kim@samsung.com>
Fri, 14 Apr 2017 11:56:32 +0000 (20:56 +0900)
committerChulSeung Kim <charles0.kim@samsung.com>
Thu, 8 Jun 2017 09:34:52 +0000 (18:34 +0900)
Add options for settings app.

Change-Id: I6f2c038f096ebb2cc6005e7705b9a6c3465d3152

LibTVRefCommonPortable/DataModels/AppControlAction.cs
LibTVRefCommonPortable/Models/AppShortcutController.cs
LibTVRefCommonPortable/Utils/AppControlUtils.cs
LibTVRefCommonPortable/Utils/AppShortcutStorage.cs
LibTVRefCommonPortable/Utils/IAppControl.cs
LibTVRefCommonTizen/Ports/AppControlPort.cs
TVHome/TVHome/ViewModels/MainPageViewModel.cs

index 7702ded..dfc9969 100644 (file)
@@ -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; }
 
         /// <summary>
+        /// A dictionary which has extra data for App Control
+        /// </summary>
+        private Dictionary<string, string> extraData;
+
+        /// <summary>
+        /// A dictionary which has extra data for App Control
+        /// </summary>
+        public Dictionary<string, string> ExtraData
+        {
+            get
+            {
+                if (extraData == null)
+                {
+                    extraData = new Dictionary<string, string>();
+                }
+
+                return extraData;
+            }
+        }
+
+        /// <summary>
         /// A method which invoke a App Control to the application of the AppID
         /// </summary>
         /// <returns>a next state after App Control invocation</returns>
         public string Execute()
         {
             string result = "default";
-            AppControlUtils.SendLaunchRequest(AppID);
+            if (ExtraData == null)
+            {
+                AppControlUtils.SendLaunchRequest(AppID);
+            }
+            else
+            {
+                AppControlUtils.SendLaunchRequest(AppID, ExtraData);
+            }
 
             return result;
         }
index b536002..6397193 100755 (executable)
@@ -34,10 +34,39 @@ namespace LibTVRefCommonPortable.Models
     public class AppShortcutController
     {
         /// <summary>
+        /// The app ID of TV reference home application
+        /// </summary>
+        // TODO : change application later
+        public static string TVHomeAppID = "org.tizen.xahome";
+
+        /// <summary>
+        /// The app ID of TV reference apps-tray application
+        /// </summary>
+        public static string TVAppsAppID = "org.tizen.xaapps";
+
+        /// <summary>
+        /// The app ID of TV reference apps-tray application
+        /// </summary>
+        public static string MediaHubAppID = "org.tizen.xamediahub";
+
+        /// <summary>
         /// A default app icon for no icon applications.
         /// </summary>
         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;
+        }
+
         /// <summary>
         /// 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<string, string> 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);
             }
 
index 5ebb287..f6188d3 100644 (file)
@@ -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
         }
 
         /// <summary>
+        /// A method makes the package ID's app to be launched.
+        /// </summary>
+        /// <param name="pkgID">A package ID of the targeted application.</param>
+        /// <param name="extraData">A extra data for App Control invoking.</param>
+        public static void SendLaunchRequest(string pkgID, IDictionary<string, string> extraData)
+        {
+            if (DependencyService.Get<IAppControl>() == null)
+            {
+                return;
+            }
+
+            DependencyService.Get<IAppControl>().SendLaunchRequest(pkgID, extraData);
+        }
+
+        /// <summary>
         /// A method sends a add pin request App Control to TVApps app.
         /// </summary>
         public static void SendAddAppRequestToApps()
index 94157ee..c5bea6c 100644 (file)
@@ -65,32 +65,6 @@ namespace LibTVRefCommonPortable.Utils
         }
 
         /// <summary>
-        /// A method provides sample App Shortcuts.
-        /// </summary>
-        /// <returns>a App Shortcut list</returns>
-        private static List<AppShortcutInfo> GetSampleList()
-        {
-            var pinnedAppsInfo = new List<AppShortcutInfo>();
-
-            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;
-        }
-
-        /// <summary>
         /// A method provides a App Shortcut list.
         /// </summary>
         /// <returns>A App Shortcut list.</returns>
@@ -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<AppShortcutInfo> result = GetSampleList();
+                List<AppShortcutInfo> result = new List<AppShortcutInfo>();
                 Write(result);
                 return result;
             }
index c549066..ea57a98 100644 (file)
@@ -15,6 +15,8 @@
  */
 
 
+using System.Collections.Generic;
+
 namespace LibTVRefCommonPortable.Utils
 {
     /// <summary>
@@ -29,6 +31,13 @@ namespace LibTVRefCommonPortable.Utils
         void SendLaunchRequest(string pkgID);
 
         /// <summary>
+        /// Sends the launch request
+        /// </summary>
+        /// <param name="AppId"> The app ID to explicitly launch</param>
+        /// <param name="extraData">The extra data for the app control</param>
+        void SendLaunchRequest(string AppId, IDictionary<string, string> extraData);
+
+        /// <summary>
         /// A method sends a add pin request App Control to TVApps app.
         /// </summary>
         void SendAddAppRequestToApps();
index 403d8eb..978d4cb 100644 (file)
@@ -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
         }
 
         /// <summary>
+        /// Sends the launch request
+        /// </summary>
+        /// <param name="AppId"> The app ID to explicitly launch</param>
+        /// <param name="extraData">The extra data for the app control</param>
+        public void SendLaunchRequest(string AppId, IDictionary<string, string> 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");
+            }
+        }
+
+        /// <summary>
         /// Sends the 'Add PIN apps' operation to TV Apps
         /// </summary>
         public void SendAddAppRequestToApps()
index f79b72c..bd94e93 100755 (executable)
@@ -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<ShortcutInfo> TempList = new List<ShortcutInfo>();
 
@@ -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()
                 {