<Compile Include="DataModels\StateDescription.cs" />
<Compile Include="DataModels\WatcherType.cs" />
<Compile Include="Models\AppShortcutController.cs" />
+ <Compile Include="Models\ManagedApps.cs" />
<Compile Include="Models\RecentShortcutController.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils\AppControlUtils.cs" />
/// </summary>
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.
foreach (KeyValuePair<string, string[]> item in installedAppList)
{
+ if (ManagedApps.IsNonPinnableApps(item.Key))
+ {
+ continue;
+ }
+
var defaultStateDescription = new StateDescription()
{
Label = item.Value[0],
IconPath = "ic_tizen_home_list_allapps_normal.png",
Action = new AppControlAction
{
- AppID = TVAppsAppID,
+ AppID = ManagedApps.TVAppsAppID,
}
};
IconPath = "ic_tizen_home_list_mediahub_normal.png",
Action = new AppControlAction
{
- AppID = MediaHubAppID,
+ AppID = ManagedApps.MediaHubAppID,
}
};
foreach (AppShortcutInfo appShortcutInfo in pinned_apps_info)
{
- if (IsNonPinnableApps(appShortcutInfo.AppID))
+ if (ManagedApps.IsNonPinnableApps(appShortcutInfo.AppID))
{
continue;
}
foreach (AppShortcutInfo appShortcutInfo in pinned_apps_info)
{
- if (IsNonPinnableApps(appShortcutInfo.AppID))
+ if (ManagedApps.IsNonPinnableApps(appShortcutInfo.AppID))
{
continue;
}
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace LibTVRefCommonPortable.Models
+{
+ /// <summary>
+ /// A class has some apps have to managed in the TVHome, TVApps by platform policy reason.
+ /// </summary>
+ public class ManagedApps
+ {
+ /// <summary>
+ /// The app ID of TV reference home application
+ /// </summary>
+ // TODO : change application later
+ public static string TVHomeAppID
+ {
+ get
+ {
+ return "org.tizen.xahome";
+ }
+ }
+
+ /// <summary>
+ /// The app ID of TV reference apps-tray application
+ /// </summary>
+ public static string TVAppsAppID
+ {
+ get
+ {
+ return "org.tizen.xaapps";
+ }
+ }
+
+ /// <summary>
+ /// The app ID of TV reference apps-tray application
+ /// </summary>
+ public static string MediaHubAppID
+ {
+ get
+ {
+ return "org.tizen.xamediahub";
+ }
+ }
+
+ /// <summary>
+ /// The Settings App ID
+ /// </summary>
+ public static string SettingsAppID
+ {
+ get
+ {
+ return "org.tizen.settings";
+ }
+ }
+
+ public static bool IsNonPinnableApps(string appID)
+ {
+ if (appID.CompareTo(TVHomeAppID) == 0 ||
+ appID.CompareTo(TVAppsAppID) == 0 ||
+ appID.CompareTo(MediaHubAppID) == 0)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ public static bool IsHiddenRecentApp(string appID)
+ {
+ if (appID.CompareTo(TVHomeAppID) == 0 ||
+ appID.CompareTo(TVAppsAppID) == 0 ||
+ appID.CompareTo(MediaHubAppID) == 0)
+ {
+ return true;
+ }
+
+ return false;
+ }
+ }
+}
var recentApps = ApplicationManagerUtils.GetRecentApplications();
foreach (var item in recentApps)
{
+ if (ManagedApps.IsHiddenRecentApp(item.AppID))
+ {
+ continue;
+ }
+
var defaultStateDescription = new StateDescription()
{
- Label = item.applabel,
- IconPath = item.iconPath,
+ Label = item.Applabel,
+ IconPath = item.IconPath,
Action = new AppControlAction()
{
- AppID = item.appID,
+ AppID = item.AppID,
}
};
var recentShortcutInfo = new RecentShortcutInfo();
- // TODO : Revert this after getting a API from app framework team.
- //recentShortcutInfo.ScreenshotPath = "screenshot_" + item.Value[0] + ".png";
- recentShortcutInfo.ScreenshotPath = "screenshot.png";
+
+ if (item.ScreenShot == null)
+ {
+ recentShortcutInfo.ScreenshotPath = "screenshot.png";
+
+ IFileSystemAPIs fsApi = DependencyService.Get<IFileSystemAPIs>();
+ if (fsApi != null)
+ {
+ string testScreenShot = fsApi.PlatformShareStorage + item.AppID + ".png";
+ if (fsApi.IsFileExist(testScreenShot))
+ {
+ recentShortcutInfo.ScreenshotPath = testScreenShot;
+ }
+ }
+ }
+ else
+ {
+ recentShortcutInfo.ScreenshotPath = item.ScreenShot;
+ }
+
recentShortcutInfo.StateDescriptions.Add("default", defaultStateDescription);
recentShortcutInfo.CurrentStateDescription = defaultStateDescription;
- recentShortcutInfo.AppID = item.appID;
+ recentShortcutInfo.AppID = item.AppID;
recentShortcutInfoList.Add(recentShortcutInfo);
}
/// <summary>
/// A storage path.
/// </summary>
- // TODO : Make this working properly, a accessing below directory is not permitted.
- // private String storagePath = "/home/owner/apps_rw/xahome/res/pinned_apps_info.xml";
- private static String storagePath = "/opt/usr/home/owner/share/pinned_apps_info.xml";
+ private static String StoragePath;
/// <summary>
/// A file system watcher which checks if the targeted storage is changed.
/// </summary>
private AppShortcutStorage()
{
+ // TODO : Make this working properly, a accessing below directory is not permitted.
+ //return DependencyService.Get<IFileSystemAPIs>()?.AppDataStorage + "pinned_apps_info.xml";
+ StoragePath = DependencyService.Get<IFileSystemAPIs>()?.PlatformShareStorage + "pinned_apps_info.xml";
+
fileSystemWatcher.Run();
}
{
IFileSystemAPIs fileSystem = DependencyService.Get<IFileSystemAPIs>();
- if (fileSystem.IsFileExist(storagePath) == false)
+ if (fileSystem.IsFileExist(StoragePath) == false)
{
- DebuggingUtils.Err("Set Default Pinned Apps" + storagePath);
+ DebuggingUtils.Err("Set Default Pinned Apps" + StoragePath);
List<AppShortcutInfo> result = new List<AppShortcutInfo>();
Write(result);
return result;
for (int i = 0; i < 5; i++)
{
- if (fileSystem.IsFileReady(storagePath))
+ if (fileSystem.IsFileReady(StoragePath))
{
break;
}
else if (i >= 4)
{
- DebuggingUtils.Err("Can't open storage" + storagePath);
+ DebuggingUtils.Err("Can't open storage" + StoragePath);
return new List<AppShortcutInfo>();
}
await Task.Delay(100);
- DebuggingUtils.Dbg("[" + i + "/5] Waiting for Writing" + storagePath);
+ DebuggingUtils.Dbg("[" + i + "/5] Waiting for Writing" + StoragePath);
}
- using (Stream fileStream = fileSystem.OpenFile(storagePath, UtilFileMode.Open))
+ using (Stream fileStream = fileSystem.OpenFile(StoragePath, UtilFileMode.Open))
{
Debug.Assert(fileStream != null);
{
IFileSystemAPIs fileSystem = DependencyService.Get<IFileSystemAPIs>();
- using (Stream fileStream = fileSystem.OpenFile(storagePath, UtilFileMode.Create))
+ using (Stream fileStream = fileSystem.OpenFile(StoragePath, UtilFileMode.Create))
{
Debug.Assert(fileStream != null);
/// <summary>
/// A Recent instance ID
/// </summary>
- public String instanceID;
+ public String InstanceID;
/// <summary>
/// A Recent instance label
/// </summary>
- public String instanceLabel;
+ public String InstanceLabel;
/// <summary>
/// A app ID
/// </summary>
- public String appID;
+ public String AppID;
/// <summary>
/// A app label
/// </summary>
- public String applabel;
+ public String Applabel;
/// <summary>
/// A app icon path
/// </summary>
- public String iconPath;
+ public String IconPath;
/// <summary>
/// A last launched data
/// </summary>
- public DateTime launchedTime;
+ public DateTime LaunchedTime;
/// <summary>
/// A URI of accessible content if the Recent is a content.
/// </summary>
- public String uri;
+ public String Uri;
+
+ /// <summary>
+ /// A File Path of screenshot of the recent app or recent content.
+ /// </summary>
+ public String ScreenShot;
}
/// <summary>
/// </summary>
public interface IFileSystemAPIs
{
+ string AppDataStorage
+ {
+ get;
+ }
+
+ string PlatformShareStorage
+ {
+ get;
+ }
+
/// <summary>
/// A method opens a file on the given mode.
/// </summary>
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,
+ 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,
});
}
}
/// </summary>
public class FileSystemPort : IFileSystemAPIs
{
+ /// <summary>
+ /// A directory path which should be used for app data storing.
+ /// </summary>
+ public static string AppDataStroagePath { private get; set; }
+
+ /// <summary>
+ /// A property of AppDataStroagePath to be exported to PCL.
+ /// </summary>
+ public string AppDataStorage
+ {
+ get
+ {
+ return AppDataStroagePath ?? "";
+ }
+ }
+
+ /// <summary>
+ /// A directory path which should be used for sharing between apps.
+ /// </summary>
+ public static string PlatformShareStroagePath { private get; set; }
+
+ /// <summary>
+ /// A property of PlatformShareStroagePath to be exported to PCL.
+ /// </summary>
+ public string PlatformShareStorage
+ {
+ get
+ {
+ return PlatformShareStroagePath ?? "";
+ }
+ }
+
/// <summary>
/// Opens the given file
/// </summary>
/// </summary>
private IPlatformNotification notification;
- /// <summary>
- /// Gets and Sets application resource path
- /// </summary>
- public static string AppResourcePath
- {
- get;
- private set;
- }
-
- /// <summary>
- /// Gets and Sets application data path
- /// </summary>
- public static string AppDataPath
- {
- get;
- private set;
- }
-
/// <summary>
/// A method will be called when application is created
/// </summary>
protected override void OnCreate()
{
base.OnCreate();
- var app = new App(MainWindow.ScreenSize.Width, MainWindow.ScreenSize.Height, MainWindow.ScreenDpi.X, ElmSharp.Elementary.GetScale());
- notification = app;
- AppResourcePath = DirectoryInfo.Resource;
- AppDataPath = DirectoryInfo.Data;
+ FileSystemPort.AppDataStroagePath = DirectoryInfo.Data;
+ FileSystemPort.PlatformShareStroagePath = "/opt/usr/home/owner/share/";
+
+ var app = new App(MainWindow.ScreenSize.Width,
+ MainWindow.ScreenSize.Height,
+ MainWindow.ScreenDpi.X,
+ ElmSharp.Elementary.GetScale());
+ notification = app;
+ DbgPort.D("-----------------------------------");
DbgPort.D("Apps application is being loaded...");
+ DbgPort.D("-----------------------------------");
LoadApplication(app);
PackageManagerPort.RegisterCallbacks(notification);
/// </summary>
WindowPort windowPort;
- /// <summary>
- /// Gets or set the application resource path
- /// </summary>
- public static string AppResourcePath
- {
- get;
- private set;
- }
-
- /// <summary>
- /// Gets or set the application data path
- /// </summary>
- public static string AppDataPath
- {
- get;
- private set;
- }
-
/// <summary>
/// A method will be called when application is created
/// </summary>
protected override void OnCreate()
{
base.OnCreate();
- var app = new App(MainWindow.ScreenSize.Width, MainWindow.ScreenSize.Height, MainWindow.ScreenDpi.X, ElmSharp.Elementary.GetScale());
- notification = app;
- AppResourcePath = DirectoryInfo.Resource;
- AppDataPath = DirectoryInfo.Data;
+ FileSystemPort.AppDataStroagePath = DirectoryInfo.Data;
+ FileSystemPort.PlatformShareStroagePath = "/opt/usr/home/owner/share/";
+
+ var app = new App(MainWindow.ScreenSize.Width,
+ MainWindow.ScreenSize.Height,
+ MainWindow.ScreenDpi.X,
+ ElmSharp.Elementary.GetScale());
+
+ notification = app;
DbgPort.D("-----------------------------------");
DbgPort.D("Home application is being loaded...");
using LibTVRefCommonPortable.DataModels;
using LibTVRefCommonPortable.Utils;
using Xamarin.Forms;
+using LibTVRefCommonPortable.Models;
namespace TVHome.ViewModels
{
private void MakeMainMenuItems()
{
string[] AppName = { "Recent", "Apps", "Settings" };
- // TODO : Revert this before release
- //string[] AppControlID = { "org.tizen.settings", "org.tizen.apps", "org.tizen.settings" };
- string[] AppControlID = { "org.tizen.xaapps", "org.tizen.xaapps", "org.tizen.settings" };
+ string[] AppControlID = { ManagedApps.TVAppsAppID, ManagedApps.TVAppsAppID, ManagedApps.SettingsAppID };
string[] AppIconPath =
{
"ic_tizen_home_menu_{0}_normal.png",