/// <summary>
/// A method provides a detail information (TBD)
/// </summary>
- /// <param name="PkgID">A package ID</param>
+ /// <param name="pkgID">A package ID</param>
/// <returns>A package label</returns>
- string GetPackage(string PkgID);
+ string GetPackageID(string pkgID);
+
+ /// <summary>
+ /// Gets the pacakge ID by the app ID
+ /// </summary>
+ /// <param name="appID">The app ID to get</param>
+ /// <returns>The pacakge ID that contains given app ID</returns>
+ string GetPackageIDByAppID(string appID);
/// <summary>
/// A method removes the package.
/// <param name="appID">A app ID</param>
/// <returns>A status of uninstall</returns>
bool UninstallPackageByAppID(string appID);
+
+ /// <summary>
+ /// Gets applications list by the package ID
+ /// </summary>
+ /// <param name="pkgID">The package ID to get applications</param>
+ /// <returns>The list of applications</returns>
+ List<string> GetApplicationsByPkgID(string pkgID);
}
}
/// <summary>
/// A method provides a detail information (TBD)
/// </summary>
- /// <param name="PkgID">A package ID</param>
+ /// <param name="pkgID">A package ID</param>
/// <returns>A package label</returns>
- public static string GetPackage(string PkgID)
+ public static string GetPackageID(string pkgID)
{
if (DependencyService.Get<IPackageManager>() == null)
{
return "";
}
- return DependencyService.Get<IPackageManager>().GetPackage(PkgID);
+ return DependencyService.Get<IPackageManager>().GetPackageID(pkgID);
+ }
+
+ /// <summary>
+ /// Gets the pacakge ID by the app ID
+ /// </summary>
+ /// <param name="appID">The app ID to get</param>
+ /// <returns>The pacakge ID that contains given app ID</returns>
+ public static string GetPackageIDByAppID(string appID)
+ {
+ if (DependencyService.Get<IPackageManager>() == null)
+ {
+ return null;
+ }
+
+ return DependencyService.Get<IPackageManager>().GetPackageIDByAppID(appID);
}
/// <summary>
return DependencyService.Get<IPackageManager>().UninstallPackageByAppID(appID);
}
+
+ /// <summary>
+ /// Gets applications list by the package ID
+ /// </summary>
+ /// <param name="pkgID">The package ID to get applications</param>
+ /// <returns>The list of applications</returns>
+ public static List<string> GetApplicationsByPkgID(string pkgID)
+ {
+ if (DependencyService.Get<IPackageManager>() == null)
+ {
+ return null;
+ }
+
+ return DependencyService.Get<IPackageManager>().GetApplicationsByPkgID(pkgID);
+ }
}
}
/// </summary>
public class PackageManagerPort : IPackageManager
{
+ /// <summary>
+ /// A interface for platform notification
+ /// </summary>
private static IPlatformNotification Notification
{
get;
/// <summary>
/// Retrieves package information of all installed packages
/// </summary>
- /// <returns>The list of packages.</returns>
+ /// <returns>The list of packages</returns>
public Dictionary<string, string[]> GetPackageList()
{
Dictionary<string, string[]> pkgList = new Dictionary<string, string[]>();
/// </summary>
/// <param name="pkgID">The ID of the package</param>
/// <returns>The package name for the given package ID</returns>
- public string GetPackage(string pkgID)
+ public string GetPackageID(string pkgID)
{
try
{
}
}
+ /// <summary>
+ /// Gets the pacakge ID by the app ID
+ /// </summary>
+ /// <param name="appID">The app ID to get</param>
+ /// <returns>The pacakge ID that contains given app ID</returns>
+ public string GetPackageIDByAppID(string appID)
+ {
+ try
+ {
+ return PackageManager.GetPackageIdByApplicationId(appID);
+ }
+ catch (Exception e)
+ {
+ DebuggingUtils.Err("Failed to get the package ID by app ID(" + appID + ") : " + e.Message);
+
+ return null;
+ }
+ }
+
/// <summary>
/// Uninstalls package with the given package
/// </summary>
return false;
}
}
+
+ /// <summary>
+ /// Gets applications list by the package ID
+ /// </summary>
+ /// <param name="pkgID">The package ID to get applications</param>
+ /// <returns>The list of applications</returns>
+ public List<string> GetApplicationsByPkgID(string pkgID)
+ {
+ try
+ {
+ int index = 0;
+ List<string> apps = new List<string>();
+ Package pkg = PackageManager.GetPackage(pkgID);
+ IEnumerable<ApplicationInfo> appsList = pkg.GetApplications();
+ if (appsList == null)
+ {
+ DebuggingUtils.Err("Failed to get apps list(" + pkgID + ")");
+
+ return null;
+ }
+
+ foreach (var app in appsList)
+ {
+ apps.Add(app.ApplicationId);
+ DebuggingUtils.Dbg("[" + index + "] " + app.ApplicationId);
+ index++;
+ }
+
+ return apps;
+ }
+ catch (Exception e)
+ {
+ DebuggingUtils.Err("Failed to get the package information(" + pkgID + ") : " + e.Message);
+
+ return new List<string>();
+ }
+
+ }
}
}
\ No newline at end of file
App.SetAppUninstalledListener((s, e) =>
{
- // TODO : find apps by package id
- // TODO : remove all apps from pinned app list
-
SetApps();
});
ViewModel.ChangeCurrentStatus(AppsStatus.Default);
}
+ /// <summary>
+ /// Removes the pinned app by app ID
+ /// </summary>
+ /// <param name="removableAppsList">The apps list to remove at the pinned app list</param>
+ public void RemovePinnedApp(List<string> removableAppsList)
+ {
+ foreach (string app in removableAppsList)
+ {
+ if (PinnedApps.ContainsKey(app))
+ {
+ DebuggingUtils.Dbg("UnPin! : " + app);
+
+ PinnedApps.Remove(app);
+ }
+ }
+
+ UpdatePinnedApps();
+ }
+
/// <summary>
/// A method sends application delete request
/// If application is pinned, removes in PinnedApps
/// </summary>
- /// <param name="AppID">The ID of application for deleting</param>
- public void DeleteApp(string AppID)
+ /// <param name="appID">The ID of application for deleting</param>
+ public void DeleteApp(string appID)
{
- DebuggingUtils.Dbg("Delete, " + AppID);
+ DebuggingUtils.Dbg("Delete, " + appID);
// TODO : popup
- // TODO : remove all app of removed package!!!
- RemovePinnedApp(AppID);
+ // if the app to be deleted is pinned, remove the app in the pinned apps list
+ string pkgID = PackageManagerUtils.GetPackageIDByAppID(appID);
+ if (pkgID == null)
+ {
+ DebuggingUtils.Err("Failed to get the package ID by app ID(" + appID + ")");
+
+ return;
+ }
+
+ List<string> removableAppsList = PackageManagerUtils.GetApplicationsByPkgID(pkgID);
+ if (removableAppsList == null || removableAppsList.Count == 0)
+ {
+ DebuggingUtils.Err("Failed to get the apps list by package ID(" + pkgID + ")");
+
+ return;
+ }
ViewModel.ChangeCurrentStatus(AppsStatus.Default);
- if (PackageManagerUtils.UninstallPackageByAppID(AppID) == false)
+ if (PackageManagerUtils.UninstallPackageByAppID(appID) == false)
{
- DebuggingUtils.Err("App uninstall is failed!!!, " + AppID);
+ DebuggingUtils.Err("App uninstall is failed!!!, " + appID);
}
else
{
var removed = from app in InstalledApps
- where app.AppID == AppID
+ where app.AppID == appID
select app;
InstalledApps.Remove(removed.First());
foreach (var item in InstalledApps)
DebuggingUtils.Dbg("- " + item.AppID);
}
+ RemovePinnedApp(removableAppsList);
RefreshApps();
}
}
TVHomeImpl.GetInstance.AppShortcutControllerInstance.UpdatePinnedApps(pinnedAppList);
}
- /// <summary>
- /// A method removes a application in pinned list
- /// </summary>
- /// <param name="AppID">The ID of application for changing pin state to false</param>
- public void RemovePinnedApp(string AppID)
- {
- if (PinnedApps.ContainsKey(AppID))
- {
- PinnedApps.Remove(AppID);
- UpdatePinnedApps();
- }
- }
-
/// <summary>
/// A method changes visible state of option menu to true
/// </summary>