3 using System.Collections.Generic;
4 using System.Threading.Tasks;
7 namespace LibTVRefCommonPortable.Utils
10 /// A class provides application controlling functions
12 public sealed class ApplicationManagerUtils
15 /// A instance of platform specific application manager port.
17 private static IApplicationManagerAPIs applicationManagerAPIs;
20 /// A instance of ApplicationManagerUtils
22 private static readonly ApplicationManagerUtils instance = new ApplicationManagerUtils();
25 /// A getter of ApplicationManagerUtils instance
27 public static ApplicationManagerUtils Instance
36 /// A unit testing stub of IApplicationManagerAPIs.
38 private class TestingStub : IApplicationManagerAPIs
40 public void DeleteAllRecentApplication()
42 throw new NotImplementedException();
45 public void DeleteRecentApplication(string appId)
47 throw new NotImplementedException();
50 public Task<Dictionary<string, string[]>> GetAllInstalledApplication()
52 throw new NotImplementedException();
55 public Task<string> GetAppIDbyAppLabel(string appLabel)
57 throw new NotImplementedException();
60 public bool GetAppInfoRemovable(string appID)
62 throw new NotImplementedException();
65 public Dictionary<string, string> GetInstalledApplication(string applicationId)
67 throw new NotImplementedException();
70 public IEnumerable<RecentApp> GetRecentApplications()
72 IList<RecentApp> testData = new List<RecentApp>();
74 testData.Add(new RecentApp
76 InstanceID = "recentapp1",
77 InstanceLabel = "recentapp1",
78 AppID = "org.tizen.recentapp1",
79 Applabel = "recentapp1",
80 IconPath = "/test/recentapp1",
81 LaunchedTime = new DateTime(2014, 11, 12),
82 Uri = "uri/recentapp1",
83 ScreenShot = "screenshot/recentapp1",
85 testData.Add(new RecentApp
87 InstanceID = "recentapp2.noscreenshot",
88 InstanceLabel = "recentapp2.noscreenshot",
89 AppID = "org.tizen.recentapp2.noscreenshot",
90 Applabel = "recentapp2.noscreenshot",
91 IconPath = "/test/recentapp2",
92 LaunchedTime = new DateTime(2014, 11, 12),
93 Uri = "uri/recentapp2",
95 testData.Add(new RecentApp
97 InstanceID = "invalid.recentapp3.nolabel",
98 AppID = "invalid.org.tizen.recentapp3.nolabel",
99 IconPath = "/test/recentapp3",
100 LaunchedTime = new DateTime(2014, 11, 12),
101 Uri = "uri/recentapp3",
102 ScreenShot = "screenshot/recentapp3",
104 testData.Add(new RecentApp
106 InstanceID = "invalid.recentapp4.notime",
107 AppID = "invalid.org.tizen.recentapp4.notime",
108 Applabel = "recentapp4.notime",
109 IconPath = "/test/recentapp4",
110 Uri = "uri/recentapp4",
111 ScreenShot = "screenshot/recentapp4",
113 testData.Add(new RecentApp
115 InstanceID = "recentapp5",
116 InstanceLabel = "recentapp5",
117 AppID = "org.tizen.recentapp5",
118 Applabel = "recentapp5",
119 IconPath = "/test/recentapp5",
120 LaunchedTime = new DateTime(2017, 05, 02),
121 Uri = "uri/recentapp5",
122 ScreenShot = "screenshot/recentapp5",
124 testData.Add(new RecentApp
126 InstanceID = "recentapp6",
127 InstanceLabel = "recentapp6",
128 AppID = "org.tizen.recentapp6",
129 Applabel = "recentapp6",
130 IconPath = "/test/recentapp6",
131 LaunchedTime = new DateTime(2017, 02, 26),
132 Uri = "uri/recentapp6",
133 ScreenShot = "screenshot/recentapp6",
135 testData.Add(new RecentApp
137 InstanceID = "recentapp7",
138 InstanceLabel = "recentapp7",
139 AppID = "org.tizen.recentapp7",
140 Applabel = "recentapp7",
141 IconPath = "/test/recentapp7",
142 LaunchedTime = new DateTime(2016, 04, 25),
143 Uri = "uri/recentapp7",
144 ScreenShot = "screenshot/recentapp7",
154 private ApplicationManagerUtils()
156 applicationManagerAPIs = new TestingStub();
160 if (DependencyService.Get<IApplicationManagerAPIs>() != null)
162 applicationManagerAPIs = DependencyService.Get<IApplicationManagerAPIs>();
165 catch (InvalidOperationException e)
167 DebuggingUtils.Err(e.Message);
172 /// A method for removing all recent applications
174 public void DeleteAllRecentApplication()
176 applicationManagerAPIs.DeleteAllRecentApplication();
180 /// A method for removing the specified recent application
182 /// <param name="appId">An application ID</param>
183 public void DeleteRecentApplication(string appId)
185 applicationManagerAPIs.DeleteRecentApplication(appId);
190 /// Gets the information of the recent applications
192 /// <returns>The list of the recent applications</returns>
193 public IEnumerable<RecentApp> GetRecentApplications()
195 return applicationManagerAPIs.GetRecentApplications();
199 /// Gets the information of the specified application with the app ID
201 /// <param name="appID">The app Id to get</param>
202 /// <returns>The information of the installed application</returns>
203 public Dictionary<string, string> GetInstalledApplication(string appID)
205 return applicationManagerAPIs.GetInstalledApplication(appID);
209 /// Gets the information of the installed applications asynchronously
211 /// <returns>The list of the installed applications</returns>
212 public Task<Dictionary<string, string[]>> GetAllInstalledApplication()
214 return applicationManagerAPIs.GetAllInstalledApplication();
218 /// Checks whether application is removable
220 /// <param name="appID">The app ID to get</param>
221 /// <returns>If the application is removable, true; otherwise, false</returns>
222 public bool GetAppInfoRemovable(string appID)
224 return applicationManagerAPIs.GetAppInfoRemovable(appID);
228 /// Gets the app ID by the app label
230 /// <param name="appLabel">the app label to get</param>
231 /// <returns>the app ID of the app label</returns>
232 public Task<string> GetAppIDbyAppLabel(string appLabel)
234 return applicationManagerAPIs.GetAppIDbyAppLabel(appLabel);