public class RecentShortcutInfo : ShortcutInfo
{
/// <summary>
- /// A application ID
+ /// An application ID
/// </summary>
public string AppID { get; set; }
/// <summary>
<Compile Include="Models\RecentShortcutController.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils\AppControlUtils.cs" />
+ <Compile Include="Utils\ApplicationManagerUtils.cs" />
<Compile Include="Utils\AppShortcutStorage.cs" />
<Compile Include="Utils\DateUtils.cs" />
<Compile Include="Utils\DebuggingUtils.cs" />
/// <returns>A installed app list.</returns>
public async Task<IEnumerable<AppShortcutInfo>> GetInstalledApps()
{
- IApplicationManagerAPIs applicationManagerPort = DependencyService.Get<IApplicationManagerAPIs>();
List<AppShortcutInfo> appShortcutInfoList = new List<AppShortcutInfo>();
- var installedAppList = await applicationManagerPort.GetAllInstalledApplication();
+ var installedAppList = await ApplicationManagerUtils.GetAllInstalledApplication();
foreach (KeyValuePair<string, string[]> item in installedAppList)
{
var appShortcutInfo = new AppShortcutInfo()
{
+ IsRemovable = ApplicationManagerUtils.GetAppInfoRemovable(item.Key),
// TODO : Fill these correctly by using Tizen Device APIs
Installed = DateUtils.GetRandomDate(),
LastUsed = DateUtils.GetRandomDate(),
/// <returns>A Pinned App Shortcut list.</returns>
private async Task<List<ShortcutInfo>> GetPinnedApps()
{
- IApplicationManagerAPIs applicationManagerPort = DependencyService.Get<IApplicationManagerAPIs>();
IEnumerable<AppShortcutInfo> pinned_apps_info = await AppShortcutStorage.Read();
List<ShortcutInfo> returnPinnedAppsInfo = new List<ShortcutInfo>();
foreach (AppShortcutInfo appShortcutInfo in pinned_apps_info)
{
- Dictionary<string, string> appInfo = applicationManagerPort.GetInstalledApplication(appShortcutInfo.AppID);
+ Dictionary<string, string> appInfo = ApplicationManagerUtils.GetInstalledApplication(appShortcutInfo.AppID);
if (appInfo == null)
{
/// <returns>A Recent Shortcut list.</returns>
public IEnumerable<RecentShortcutInfo> GetList()
{
- IApplicationManagerAPIs applicationManagerPort = DependencyService.Get<IApplicationManagerAPIs>();
List<RecentShortcutInfo> recentShortcutInfoList = new List<RecentShortcutInfo>();
- var recentApps = applicationManagerPort.GetRecentApplications();
+ var recentApps = ApplicationManagerUtils.GetRecentApplications();
foreach (var item in recentApps)
{
var defaultStateDescription = new StateDescription()
--- /dev/null
+
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Xamarin.Forms;
+
+namespace LibTVRefCommonPortable.Utils
+{
+ public sealed class ApplicationManagerUtils
+ {
+ /// <summary>
+ /// A constructor
+ /// </summary>
+ public ApplicationManagerUtils()
+ {
+ }
+
+ /// <summary>
+ /// Gets the information of the recent applications
+ /// </summary>
+ /// <returns>The list of the recent applications</returns>
+ public static IEnumerable<RecentApp> GetRecentApplications()
+ {
+ if (DependencyService.Get<IApplicationManagerAPIs>() == null)
+ {
+ return null;
+ }
+
+ return DependencyService.Get<IApplicationManagerAPIs>().GetRecentApplications();
+ }
+
+ /// <summary>
+ /// Gets the information of the specified application with the app ID
+ /// </summary>
+ /// <param name="appID">The app Id to get</param>
+ /// <returns>The information of the installed application</returns>
+ public static Dictionary<string, string> GetInstalledApplication(string appID)
+ {
+ if (DependencyService.Get<IApplicationManagerAPIs>() == null)
+ {
+ return null;
+ }
+
+ return DependencyService.Get<IApplicationManagerAPIs>().GetInstalledApplication(appID);
+ }
+
+ /// <summary>
+ /// Gets the information of the installed applications asynchronously
+ /// </summary>
+ /// <returns>The list of the installed applications</returns>
+ public static Task<Dictionary<string, string[]>> GetAllInstalledApplication()
+ {
+ if (DependencyService.Get<IApplicationManagerAPIs>() == null)
+ {
+ return null;
+ }
+
+ return DependencyService.Get<IApplicationManagerAPIs>().GetAllInstalledApplication();
+ }
+
+ /// <summary>
+ /// Checks whether application is removable
+ /// </summary>
+ /// <param name="appID">The app ID to get</param>
+ /// <returns>If the application is removable, true; otherwise, false</returns>
+ public static bool GetAppInfoRemovable(string appID)
+ {
+ if (DependencyService.Get<IApplicationManagerAPIs>() == null)
+ {
+ return false;
+ }
+
+ return DependencyService.Get<IApplicationManagerAPIs>().GetAppInfoRemovable(appID);
+ }
+ }
+}
/// <returns>A installed application information</returns>
Dictionary<string, string> GetInstalledApplication(string applicationId);
- /// <summary>
- /// A method for removing all recent applications
- /// </summary>
+ /// <summary>
+ /// A method for removing all recent applications
+ /// </summary>
void DeleteAllRecentApplication();
- /// <summary>
- /// A method for removing the specified recent application
- /// </summary>
+ /// <summary>
+ /// A method for removing the specified recent application
+ /// </summary>
void DeleteRecentApplication(string appId);
+
+ /// <summary>
+ /// Checks whether application is removable
+ /// </summary>
+ /// <param name="appID">The app ID to get</param>
+ /// <returns>If the application is removable, true; otherwise, false</returns>
+ bool GetAppInfoRemovable(string appID);
}
}
}
catch (Exception exception)
{
- DbgPort.E("Exception " + appID + " :" + exception.Message);
+ DbgPort.E("Failed to get the installed application(" + appID + ") :" + exception.Message);
return null;
}
}
catch (Exception exception)
{
- DbgPort.E(exception.Message);
+ DbgPort.E("Failed to get the all installed applications : " + exception.Message);
return null;
}
}
+
+ /// <summary>
+ /// Checks whether application is removable
+ /// </summary>
+ /// <param name="appID">The app ID to get</param>
+ /// <returns>If the application is removable, true; otherwise, false</returns>
+ public bool GetAppInfoRemovable(string appID)
+ {
+ ApplicationInfo appInfo = null;
+
+ try
+ {
+ appInfo = ApplicationManager.GetInstalledApplication(appID);
+ if (appInfo == null)
+ {
+ DbgPort.D("Failed to get the installed application(" + appID +")");
+ return false;
+ }
+
+ return !appInfo.IsPreload;
+ }
+ catch (Exception exception)
+ {
+ DbgPort.E("Failed to get the installed application(" + appID + ") :" + exception.Message);
+ return false;
+ }
+ }
}
}
\ No newline at end of file
{
DebuggingUtils.Dbg("Delete, " + appID);
+ if (!ApplicationManagerUtils.GetAppInfoRemovable(appID))
+ {
+ DebuggingUtils.Dbg("This app is not removable : " + appID);
+ return;
+ }
+
// TODO : popup
// if the app to be deleted is pinned, remove the app in the pinned apps list
return;
}
- List<string> removableAppsList = PackageManagerUtils.GetApplicationsByPkgID(pkgID);
- if (removableAppsList == null || removableAppsList.Count == 0)
+ List<string> appsList = PackageManagerUtils.GetApplicationsByPkgID(pkgID);
+ if (appsList == null || appsList.Count == 0)
{
DebuggingUtils.Err("Failed to get the apps list by package ID(" + pkgID + ")");
DebuggingUtils.Dbg("- " + item.AppID);
}
- RemovePinnedApp(removableAppsList);
+ RemovePinnedApp(appsList);
RefreshApps();
}
}
break;
case AppsStatus.Delete:
+ if (!item.IsRemovable)
+ {
+ item.IsDim = true;
+ }
+
item.IsChecked = false;
break;
}