public string AppID { get; set; }
/// <summary>
+ /// A file URI to be open
+ /// </summary>
+ public string FileUri { get; set; }
+
+ /// <summary>
+ /// A media id of MediaContent
+ /// </summary>
+ public string MediaId { get; set; }
+
+ /// <summary>
/// A dictionary which has extra data for App Control
/// </summary>
private Dictionary<string, string> extraData;
/// <returns>a next state after App Control invocation</returns>
public string Execute()
{
- string result = "default";
- if (ExtraData == null)
- {
- AppControlUtils.SendLaunchRequest(AppID);
- }
- else
- {
- AppControlUtils.SendLaunchRequest(AppID, ExtraData);
- }
-
- return result;
+ // Warn : Do NOT pass 'E'xtraData, it will create a new Dictionary and it might cause unexpected situation.
+ AppControlUtils.SendLaunchRequest(AppID, extraData, FileUri);
+ return "default";
}
}
}
*/
using System;
+using System.Collections;
namespace LibTVRefCommonPortable.DataModels
{
/// <summary>
+ /// Types for recent shortcut
+ /// </summary>
+ public enum RecentShortcutType
+ {
+ Application = 0,
+ Media = 1,
+ }
+
+ /// <summary>
/// A Recent Shortcut information
/// </summary>
- public class RecentShortcutInfo : ShortcutInfo
+ public class RecentShortcutInfo : ShortcutInfo, IComparable
{
/// <summary>
- /// An application ID
+ /// A type for the content of the shortcut
/// </summary>
- public string AppID { get; set; }
+ public RecentShortcutType Type { get; set; }
+
+ /// <summary>
+ /// An Id for the content of the shortcut
+ /// </summary>
+ public string Id { get; set; }
/// <summary>
/// A Last used Time
/// </summary>
{
SetCurrentState("default");
}
+
+ int IComparable.CompareTo(object target)
+ {
+ var rightShortcutInfo = target as RecentShortcutInfo;
+ return Date.CompareTo(rightShortcutInfo.Date);
+ }
}
}
<Compile Include="Utils\AppControlUtils.cs" />
<Compile Include="Utils\ApplicationManagerUtils.cs" />
<Compile Include="Utils\AppShortcutStorage.cs" />
+ <Compile Include="Utils\IMediaContentAPIs.cs" />
<Compile Include="Utils\ISystemSettings.cs" />
<Compile Include="Utils\SizeUtils.cs" />
<Compile Include="Utils\DateUtils.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Tizen.Xamarin.Forms.Extension, Version=0.0.1.0, Culture=neutral, processorArchitecture=MSIL">
- <HintPath>..\packages\Tizen.Xamarin.Forms.Extension.2.3.4-r214-001\lib\portable-win+net45+wp80+win81+wpa81\Tizen.Xamarin.Forms.Extension.dll</HintPath>
+ <HintPath>..\packages\Tizen.Xamarin.Forms.Extension.2.3.5-r233-002\lib\portable-win+net45+wp80+win81+wpa81\Tizen.Xamarin.Forms.Extension.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
* limitations under the License.
*/
+using System;
using System.Collections.Generic;
using LibTVRefCommonPortable.DataModels;
using LibTVRefCommonPortable.Utils;
public IEnumerable<RecentShortcutInfo> GetList()
{
List<RecentShortcutInfo> recentShortcutInfoList = new List<RecentShortcutInfo>();
+ IEnumerable<RecentApp> recentApps = null;
- var defaultStateDescription = new StateDescription()
+ try
{
- Label = "Youtube",
- IconPath = "ic_home_settings_all_138.png",
- Action = new AppControlAction()
- {
- AppID = "org.tizen.example.Youtube.TizenTV",
- }
- };
- var recentShortcutInfo = new RecentShortcutInfo();
- string testScreenShot = "org.tizen.example.Youtube.Tizen.png";
-
- recentShortcutInfo.ScreenshotPath = testScreenShot;
-
- recentShortcutInfo.StateDescriptions.Add("default", defaultStateDescription);
- recentShortcutInfo.CurrentStateDescription = defaultStateDescription;
- recentShortcutInfo.AppID = "org.tizen.example.Youtube.TizenTV";
- recentShortcutInfoList.Add(recentShortcutInfo);
-
- /*var recentApps = ApplicationManagerUtils.GetRecentApplications();
- foreach (var item in recentApps)
+ recentApps = ApplicationManagerUtils.GetRecentApplications();
+ }
+ catch (Exception e)
{
- if (ManagedApps.IsHiddenRecentApp(item.AppID))
- {
- continue;
- }
+ DebuggingUtils.Err("GetRecentApplications failed. " + e.Message);
+ }
- var defaultStateDescription = new StateDescription()
+ if (recentApps != null)
+ {
+ foreach (var item in recentApps)
{
- Label = item.Applabel,
- IconPath = item.IconPath,
- Action = new AppControlAction()
+ if (ManagedApps.IsHiddenRecentApp(item.AppID))
{
- AppID = item.AppID,
+ continue;
}
- };
- var recentShortcutInfo = new RecentShortcutInfo();
- if (item.ScreenShot == null)
- {
- recentShortcutInfo.ScreenshotPath = "screenshot.png";
-
- IFileSystemAPIs fsApi = DependencyService.Get<IFileSystemAPIs>();
- if (fsApi != null)
+ var defaultStateDescription = new StateDescription()
{
- // Temporary, use preinstalled screenshot
- string capturedAppScreen = @"/tmp/" + item.AppID + ".jpg";
- if (fsApi.IsFileExist(capturedAppScreen))
+ Label = item.Applabel,
+ IconPath = item.IconPath,
+ Action = new AppControlAction()
{
- recentShortcutInfo.ScreenshotPath = capturedAppScreen;
+ AppID = item.AppID,
}
- else
+ };
+ var recentShortcutInfo = new RecentShortcutInfo();
+
+ if (item.ScreenShot == null)
+ {
+ recentShortcutInfo.ScreenshotPath = "screenshot.png";
+
+ IFileSystemAPIs fsApi = DependencyService.Get<IFileSystemAPIs>();
+ if (fsApi != null)
{
- //string testScreenShot = fsApi.PlatformShareStorage + item.AppID + ".png";
- string testScreenShot = fsApi.AppResourceStorage + item.AppID + ".png";
- if (fsApi.IsFileExist(testScreenShot))
+ // Temporary, use preinstalled screenshot
+ string capturedAppScreen = @"/tmp/" + item.AppID + ".jpg";
+ if (fsApi.IsFileExist(capturedAppScreen))
+ {
+ recentShortcutInfo.ScreenshotPath = capturedAppScreen;
+ }
+ else
{
- recentShortcutInfo.ScreenshotPath = testScreenShot;
+ //string testScreenShot = fsApi.PlatformShareStorage + item.AppID + ".png";
+ string testScreenShot = fsApi.AppResourceStorage + item.AppID + ".png";
+ if (fsApi.IsFileExist(testScreenShot))
+ {
+ recentShortcutInfo.ScreenshotPath = testScreenShot;
+ }
}
}
}
+ else
+ {
+ recentShortcutInfo.ScreenshotPath = item.ScreenShot;
+ }
+
+ recentShortcutInfo.StateDescriptions.Add("default", defaultStateDescription);
+ recentShortcutInfo.CurrentStateDescription = defaultStateDescription;
+ recentShortcutInfo.Id = item.AppID;
+ recentShortcutInfoList.Add(recentShortcutInfo);
}
- else
+ }
+ else
+ {
+ DebuggingUtils.Dbg("No recent apps");
+ var defaultStateDescription = new StateDescription()
{
- recentShortcutInfo.ScreenshotPath = item.ScreenShot;
- }
+ Label = "Youtube",
+ IconPath = "ic_home_settings_all_138.png",
+ Action = new AppControlAction()
+ {
+ AppID = "org.tizen.example.Youtube.TizenTV",
+ }
+ };
+ var recentShortcutInfo = new RecentShortcutInfo();
+ string testScreenShot = "org.tizen.example.Youtube.Tizen.png";
+
+ recentShortcutInfo.ScreenshotPath = testScreenShot;
recentShortcutInfo.StateDescriptions.Add("default", defaultStateDescription);
recentShortcutInfo.CurrentStateDescription = defaultStateDescription;
- recentShortcutInfo.AppID = item.AppID;
+ recentShortcutInfo.Id = "org.tizen.example.Youtube.TizenTV";
recentShortcutInfoList.Add(recentShortcutInfo);
- }*/
+ }
- return recentShortcutInfoList;
+ IMediaContentAPIs apiSet = DependencyService.Get<IMediaContentAPIs>();
+ var recentPlayedMedia = DependencyService.Get<IMediaContentAPIs>().GetRecentlyPladyedMedia(10);
+
+
+ foreach (var item in recentPlayedMedia)
+ {
+ // DebuggingUtils.Dbg("media :" + item.DisplayName + ", PlayedAt : " + item.PlayedAt.ToString());
+ var defaultStateDescription = new StateDescription()
+ {
+ Label = item.DisplayName,
+ IconPath = "ic_launcher_mediahub_138.png",
+ Action = new AppControlAction()
+ {
+ AppID = "org.tizen.xamediahub",
+ MediaId = item.MediaId,
+ FileUri = "file://" + item.FilePath,
+ }
+ };
+ var recentShortcutInfo = new RecentShortcutInfo();
+ recentShortcutInfo.ScreenshotPath = item.ThumbnailPath;
+ recentShortcutInfo.StateDescriptions.Add("default", defaultStateDescription);
+ recentShortcutInfo.CurrentStateDescription = defaultStateDescription;
+ recentShortcutInfo.Id = "org.tizen.xamediahub";
+ recentShortcutInfoList.Add(recentShortcutInfo);
+ }
+
+ recentShortcutInfoList.Sort();
+
+ return recentShortcutInfoList;
}
}
}
public sealed class AppControlUtils
{
/// <summary>
- /// A method makes the package ID's app to be launched.
+ /// A method makes the app to be launched.
/// </summary>
- /// <param name="pkgID">A package ID of the targeted application.</param>
- public static void SendLaunchRequest(string pkgID)
- {
- if (DependencyService.Get<IAppControl>() == null)
- {
- return;
- }
-
- DependencyService.Get<IAppControl>().SendLaunchRequest(pkgID);
- }
-
- /// <summary>
- /// A method makes the package ID's app to be launched.
- /// </summary>
- /// <param name="pkgID">A package ID of the targeted application.</param>
+ /// <param name="appID">A application ID of the targeted application.</param>
/// <param name="extraData">A extra data for App Control invoking.</param>
- public static void SendLaunchRequest(string pkgID, IDictionary<string, string> extraData)
+ /// <param name="fileUri">A file Uri to be opened.</param>
+ public static void SendLaunchRequest(string appID, IDictionary<string, string> extraData = null, string fileUri = null)
{
if (DependencyService.Get<IAppControl>() == null)
{
return;
}
- DependencyService.Get<IAppControl>().SendLaunchRequest(pkgID, extraData);
+ DependencyService.Get<IAppControl>().SendLaunchRequest(appID, extraData, fileUri);
}
/// <summary>
public interface IAppControl
{
/// <summary>
- /// A method makes the package ID's app to be launched.
- /// </summary>
- /// <param name="pkgID">A package ID of the targeted application.</param>
- void SendLaunchRequest(string pkgID);
-
- /// <summary>
/// Sends the launch request
/// </summary>
- /// <param name="AppId"> The app ID to explicitly launch</param>
+ /// <param name="appId"> The app ID to explicitly launch</param>
/// <param name="extraData">The extra data for the app control</param>
- void SendLaunchRequest(string AppId, IDictionary<string, string> extraData);
+ /// <param name="fileUri">The file uri to be opened</param>
+ void SendLaunchRequest(string appId, IDictionary<string, string> extraData, string fileUri);
/// <summary>
/// A method sends a add pin request App Control to TVApps app.
--- /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;
+
+namespace LibTVRefCommonPortable.Utils
+{
+ public struct RecentlyPlayedMedia
+ {
+ public string MediaId;
+ public string ThumbnailPath;
+ public string FilePath;
+ public string DisplayName;
+ public DateTime PlayedAt;
+ }
+
+ public interface IMediaContentAPIs
+ {
+ IEnumerable<RecentlyPlayedMedia> GetRecentlyPladyedMedia(int limitation);
+ }
+}
<?xml version="1.0" encoding="utf-8"?>
<packages>
+ <package id="Tizen.Xamarin.Forms.Extension" version="2.3.5-r233-002" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Xamarin.Forms" version="2.3.5-r233-003" targetFramework="portable45-net45+win8+wp8+wpa81" />
</packages>
\ No newline at end of file
<Compile Include="Ports\AppControlPort.cs" />
<Compile Include="Ports\ApplicationManagerPort.cs" />
<Compile Include="Ports\DbgPort.cs" />
+ <Compile Include="Ports\MediaContentPort.cs" />
<Compile Include="Ports\SystemSettingsPort.cs" />
<Compile Include="Ports\WindowPort.cs" />
<Compile Include="Ports\FileSystemPort.cs" />
"Microsoft.NETCore.App": "1.1.0",
"Tizen": "1.0.3",
"Tizen.Applications": "1.5.1",
+ "Tizen.Content.MediaContent": "1.0.19",
"Xamarin.Forms": "2.3.5-r233-003",
"Xamarin.Forms.Platform.Tizen": "2.3.5-r233-003"
},
/// Sends the launch request
/// </summary>
/// <param name="AppId"> The app ID to explicitly launch</param>
- public void SendLaunchRequest(string AppId)
- {
- try
- {
- AppControl appControl = new AppControl();
-
- if (AppId == null || AppId.Length <= 0)
- {
- DebuggingUtils.Err("The AppID is null or blank");
- return;
- }
-
- appControl.ApplicationId = AppId;
-
- AppControl.SendLaunchRequest(appControl);
- }
- catch (InvalidOperationException)
- {
- DebuggingUtils.Err("Failed to create AppControl");
- }
- }
-
- /// <summary>
- /// Sends the launch request
- /// </summary>
- /// <param name="AppId"> The app ID to explicitly launch</param>
/// <param name="extraData">The extra data for the app control</param>
- public void SendLaunchRequest(string AppId, IDictionary<string, string> extraData)
+ /// <param name="fileUri">The file URI to be opened</param>
+ public void SendLaunchRequest(string appId, IDictionary<string, string> extraData = null, string fileUri = null)
{
try
{
AppControl appControl = new AppControl();
- if (AppId == null || AppId.Length <= 0)
+ if (appId == null || appId.Length <= 0)
{
DebuggingUtils.Err("The AppID is null or blank");
return;
string value;
- appControl.ApplicationId = AppId;
- foreach (var key in extraData.Keys)
+ appControl.ApplicationId = appId;
+
+ if (extraData != null)
{
- if (extraData.TryGetValue(key, out value))
+ foreach (var key in extraData.Keys)
{
- appControl.ExtraData.Add(key, value);
+ if (extraData.TryGetValue(key, out value))
+ {
+ appControl.ExtraData.Add(key, value);
+ }
}
}
+ if (fileUri != null && fileUri.Length != 0)
+ {
+ appControl.Uri = fileUri;
+ appControl.LaunchMode = AppControlLaunchMode.Group;
+ appControl.Mime = "video/*";
+ appControl.Operation = AppControlOperations.View;
+ }
+
AppControl.SendLaunchRequest(appControl);
}
catch (InvalidOperationException)
--- /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 Tizen;
+using Tizen.Content.MediaContent;
+using LibTVRefCommonPortable.Utils;
+
+namespace LibTVRefCommonTizen.Ports
+{
+ public class MediaContentPort : IMediaContentAPIs
+ {
+ public MediaContentPort()
+ {
+ DbgPort.D("MediaContentPort");
+ ContentDatabase.Connect();
+ }
+
+ public IEnumerable<RecentlyPlayedMedia> GetRecentlyPladyedMedia(int limitation)
+ {
+ var recentlyPlayedVideos = new List<RecentlyPlayedMedia>();
+ var contentFilter = new ContentFilter();
+
+ contentFilter.OrderKey = "MEDIA_LAST_PLAYED_TIME";
+ contentFilter.Order = ContentOrder.Desc;
+ contentFilter.Condition = "MEDIA_TYPE=1 AND MEDIA_LAST_PLAYED_TIME!=0";
+ contentFilter.Offset = 0;
+ contentFilter.Count = limitation;
+
+ IEnumerable<MediaInformation> mediaInformations = null;
+
+ try
+ {
+ mediaInformations = ContentManager.Database.SelectAll<MediaInformation>(contentFilter);
+ }
+ catch (Exception exception)
+ {
+ DbgPort.E(exception.Message);
+ }
+
+ foreach (var mediaInformation in mediaInformations)
+ {
+ recentlyPlayedVideos.Add(new RecentlyPlayedMedia()
+ {
+ MediaId = mediaInformation.MediaId,
+ ThumbnailPath = mediaInformation.ThumbnailPath,
+ DisplayName = mediaInformation.DisplayName,
+ PlayedAt = mediaInformation.PlayedAt,
+ FilePath = mediaInformation.FilePath,
+ }
+ );
+ }
+
+ return recentlyPlayedVideos;
+ }
+ }
+}
global::Xamarin.Forms.DependencyService.Register<FileSystemPort>();
global::Xamarin.Forms.DependencyService.Register<WindowPort>();
global::Xamarin.Forms.DependencyService.Register<SystemSettingsPort>();
+ global::Xamarin.Forms.DependencyService.Register<MediaContentPort>();
TizenFormsExtension.Init();
global::Xamarin.Forms.Platform.Tizen.Forms.Init(app);
app.Run(args);
});
button.OnClearCommand = new Command(() =>
{
- OnClearVMCommand.Execute(item.AppID);
+ OnClearVMCommand.Execute(item.Id);
});
button.OnClearAllCommand = new Command(() =>
{