-/*
+/*
* Copyright (c) 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
namespace LibTVRefCommonTizen.Ports
{
/// <summary>
- /// This class is for AppControl API
+ /// Handles the Appcontrol APIs
/// </summary>
public class AppControlPort : IAppControl
{
public static string TVAppsAppID = "org.tizen.example.TVApps.TizenTV";
/// <summary>
+ /// Represents the operation to be performed between TVHome and TVApps
/// This operation is sended from TVHomes to TVApps
/// </summary>
public static string AddAppOperation = "http://xahome.tizen.org/appcontrol/operation/add_app";
/// <summary>
+ /// Represents the operation to be performed between TVHome and TVApps
/// This operation is sended from TVApps to TVHome
/// </summary>
public static string AppAddedNotifyOperation = "http://xahome.tizen.org/appcontrol/operation/app_added";
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
-using Xamarin.Forms.Platform.Tizen.Native;
-using Tizen;
using Tizen.Applications;
using LibTVRefCommonPortable.Utils;
namespace LibTVRefCommonTizen.Ports
{
+ /// <summary>
+ /// Handles the ApplicationsManager APIs
+ /// </summary>
public class ApplicationManagerPort : IApplicationManagerAPIs
{
+ /// <summary>
+ /// Defines the default app icon
+ /// If the app icon is not exist, shows the default app icon
+ /// </summary>
private static String DefaultAppIcon = "AppIcon.png";
+ /// <summary>
+ /// The constructor of this class
+ /// Adds the EventHandler for ApplicationLaunched
+ /// </summary>
public ApplicationManagerPort()
{
ApplicationManager.ApplicationLaunched += new EventHandler<ApplicationLaunchedEventArgs>(OnApplicationLaunched);
}
+ /// <summary>
+ /// Arguments for the event that is raised when the application is launched
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="args">An object that contains no event data</param>
+ /// <remarks>
+ /// https://msdn.microsoft.com/en-us/library/system.eventhandler(v=vs.110).aspx
+ /// </remarks>
void OnApplicationLaunched(object sender, EventArgs args)
{
ApplicationLaunchedEventArgs launchedEventArgs = args as ApplicationLaunchedEventArgs;
DebuggingUtils.Dbg(launchedEventArgs.ApplicationRunningContext.ApplicationId + " launched");
}
+ /// <summary>
+ /// Gets the information of the recent applications
+ /// </summary>
+ /// <returns>The list of the recent applications</returns>
public IEnumerable<RecentApp> GetRecentApplications()
{
List<RecentApp> resultList = new List<RecentApp>();
- IEnumerable<RecentApplicationInfo> recentApps = ApplicationManager.GetRecentApplications();
-
- foreach (var app in recentApps)
+ try
{
- if (app.IsNoDisplay ||
- app.ApplicationId == null ||
- app.ApplicationId.Length < 1)
- {
- continue;
- }
+ IEnumerable<RecentApplicationInfo> recentApps = ApplicationManager.GetRecentApplications();
- resultList.Add(new RecentApp()
+ foreach (var app in recentApps)
{
- 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,
- });
+ if (app.IsNoDisplay ||
+ app.ApplicationId == null ||
+ app.ApplicationId.Length < 1)
+ {
+ continue;
+ }
+
+ 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,
+ });
+ }
+ }
+ catch (InvalidOperationException)
+ {
+ DebuggingUtils.Err("Failed to get the information of the recent applications");
+ return null;
}
return resultList;
}
- public Dictionary<string, string> GetInstalledApplication(string applicationId)
+ /// <summary>
+ /// Gets the information of the specified application with the app ID
+ /// </summary>
+ /// <param name="appID">The app Id you want to get</param>
+ /// <returns>The information of the installed applications</returns>
+ public Dictionary<string, string> GetInstalledApplication(string appID)
{
Dictionary<string, string> result = null;
ApplicationInfo appInfo = null;
try
{
- appInfo = ApplicationManager.GetInstalledApplication(applicationId);
+ appInfo = ApplicationManager.GetInstalledApplication(appID);
if (appInfo == null)
{
DbgPort.D("GetInstalledApplication failed");
}
catch (Exception exception)
{
- DbgPort.E("Exception " + applicationId + " :" + exception.Message);
+ DbgPort.E("Exception " + appID + " :" + exception.Message);
return null;
}
return result;
}
+ /// <summary>
+ /// Gets the information of the installed applications asynchronously
+ /// </summary>
+ /// <returns>The list of the installed applications</returns>
public async Task<Dictionary<string, string[]>> GetAllInstalledApplication()
{
try