[XmlIgnore]
public bool IsRemovable { get; set; }
+
+ [XmlIgnore]
public DateTime Installed { get; set; }
+ [XmlIgnore]
public DateTime LastUsed { get; set; }
public override void UpdateState()
{
public class CommandAction : IAction
{
+ public string NextStateDescription { get; set; }
public ICommand Command { get; set; }
public string CommandParameter { get; set; }
public string Execute()
{
Command.Execute(CommandParameter);
- return null;
+ return NextStateDescription;
}
}
}
return false;
}
+ if (CurrentStateDescription != null &&
+ CurrentStateDescription == stateDescriptions[state])
+ {
+ return true;
+ }
+
+ // TODO : remove, for debugging purpose
+ foreach (var item in stateDescriptions)
+ {
+ if (item.Value.Equals(CurrentStateDescription))
+ {
+ DebuggingUtils.Dbg("[" + item.Key + "] => [" + state + "]");
+ break;
+ }
+ }
+
CurrentStateDescription = stateDescriptions[state];
OnPropertyChanged("CurrentStateDescription");
return true;
{
public class StateDescription
{
+ public StateDescription()
+ {
+ Label = "";
+ IconPath = "";
+ }
+
public string Label
{
get;
<Compile Include="Utils\DebuggingUtils.cs" />
<Compile Include="Utils\IAppControl.cs" />
<Compile Include="Utils\IApplicationManagerAPIs.cs" />
+ <Compile Include="Utils\IPlatformNotification.cs" />
<Compile Include="Utils\IBTAPIs.cs" />
<Compile Include="Utils\IDBAPIs.cs" />
<Compile Include="Utils\IDebuggingAPIs.cs" />
{
public class AppShortcutController
{
- private List<AppShortcutInfo> returnPinnedAppsInfo = new List<AppShortcutInfo>();
-
public AppShortcutController()
{
public async Task<IEnumerable<AppShortcutInfo>> GetInstalledApps()
{
+ DebuggingUtils.Dbg(">AppShortcutController, GetInstalledApps - start");
IApplicationManagerAPIs applicationManagerPort = DependencyService.Get<IApplicationManagerAPIs>();
List<AppShortcutInfo> appShortcutInfoList = new List<AppShortcutInfo>();
appShortcutInfoList.Add(appShortcutInfo);
}
+ DebuggingUtils.Dbg("<AppShortcutController, GetInstalledApps - end");
return appShortcutInfoList;
}
- private void AddAllAppsAndMediaHubShortcut()
+ private void AddAllAppsAndMediaHubShortcut(ref List<AppShortcutInfo> returnPinnedAppsInfo)
{
var allAppsStateDescription = new StateDescription()
{
allAppsShortcutInfo.StateDescriptions.Add("default", allAppsStateDescription);
allAppsShortcutInfo.CurrentStateDescription = allAppsStateDescription;
- returnPinnedAppsInfo.Add(allAppsShortcutInfo);
+ returnPinnedAppsInfo.Insert(0, allAppsShortcutInfo);
var mediaHubStateDescription = new StateDescription()
{
mediaHubShortcutInfo.StateDescriptions.Add("default", mediaHubStateDescription);
mediaHubShortcutInfo.CurrentStateDescription = mediaHubStateDescription;
- returnPinnedAppsInfo.Add(mediaHubShortcutInfo);
+ returnPinnedAppsInfo.Insert(1, mediaHubShortcutInfo);
}
- private void AppendAddPinShortcut()
+ private void AppendAddPinShortcut(ref List<AppShortcutInfo> returnPinnedAppsInfo)
{
var addPinStateDescription = new StateDescription()
{
returnPinnedAppsInfo.Add(addPinShortcutInfo);
}
- public IEnumerable<AppShortcutInfo> GetPinnedApps()
+ private List<AppShortcutInfo> GetPinnedApps()
{
IApplicationManagerAPIs applicationManagerPort = DependencyService.Get<IApplicationManagerAPIs>();
IEnumerable<AppShortcutInfo> pinned_apps_info = AppShortcutStorage.Read();
string[] icons = { "ic_black.png", "ic_blue.png", "ic_green.png", "ic_red.png", "ic_yellow.png", "AppIcon.png" };
- AddAllAppsAndMediaHubShortcut();
+ List<AppShortcutInfo> returnPinnedAppsInfo = new List<AppShortcutInfo>();
foreach (AppShortcutInfo appShortcutInfo in pinned_apps_info)
{
Dictionary<string, string> appInfo = applicationManagerPort.GetInstalledApplication(appShortcutInfo.AppID);
- if (appInfo != null)
+ if (appInfo == null)
{
- string appLabel;
- string appIconPath;
+ continue;
+ }
- appInfo.TryGetValue("Label", out appLabel);
- appInfo.TryGetValue("IconPath", out appIconPath);
+ string appLabel;
+ string appIconPath;
- DebuggingUtils.Dbg("AppID: " + appShortcutInfo.AppID + ", Label : " + appLabel + " IconPath : " + appIconPath);
- Random random = new Random();
- var defaultStateDescription = new StateDescription()
- {
- Label = appLabel,
- IconPath = appIconPath ?? icons[random.Next(0, 6)],
- Action = new AppControlAction
- {
- AppID = appShortcutInfo.AppID,
- }
- };
-
- appShortcutInfo.StateDescriptions.Add("default", defaultStateDescription);
- appShortcutInfo.CurrentStateDescription = defaultStateDescription;
- appShortcutInfo.IsPinned = true;
- returnPinnedAppsInfo.Add(appShortcutInfo);
- }
- else
+ appInfo.TryGetValue("Label", out appLabel);
+ appInfo.TryGetValue("IconPath", out appIconPath);
+
+ DebuggingUtils.Dbg("AppID: " + appShortcutInfo.AppID + ", Label : " + appLabel + " IconPath : " + appIconPath);
+ Random random = new Random();
+ var defaultStateDescription = new StateDescription()
{
- // TODO : Remove the broken appInfo from pinned_apps_info
- }
+ Label = appLabel,
+ IconPath = appIconPath ?? icons[random.Next(0, 6)],
+ Action = new AppControlAction
+ {
+ AppID = appShortcutInfo.AppID,
+ }
+ };
+
+ appShortcutInfo.StateDescriptions.Add("default", defaultStateDescription);
+ appShortcutInfo.CurrentStateDescription = defaultStateDescription;
+ appShortcutInfo.IsPinned = true;
+ returnPinnedAppsInfo.Add(appShortcutInfo);
}
- AppendAddPinShortcut();
+ return returnPinnedAppsInfo;
+ }
+
+ public IEnumerable<AppShortcutInfo> GetPinnedAppsWithDefaultShortcuts()
+ {
+ List<AppShortcutInfo> returnPinnedAppsInfo = GetPinnedApps();
+
+ AddAllAppsAndMediaHubShortcut(ref returnPinnedAppsInfo);
+ AppendAddPinShortcut(ref returnPinnedAppsInfo);
return returnPinnedAppsInfo;
}
+ public Dictionary<string, string> GetPinnedAppsAppIDs()
+ {
+ IApplicationManagerAPIs applicationManagerPort = DependencyService.Get<IApplicationManagerAPIs>();
+ IEnumerable<AppShortcutInfo> pinned_apps_info = AppShortcutStorage.Read();
+ string[] icons = { "ic_black.png", "ic_blue.png", "ic_green.png", "ic_red.png", "ic_yellow.png", "AppIcon.png" };
+
+ Dictionary<string, string> pinnedAppsDictionary = new Dictionary<string, string>();
+
+ foreach (AppShortcutInfo appShortcutInfo in pinned_apps_info)
+ {
+ pinnedAppsDictionary.Add(appShortcutInfo.AppID, appShortcutInfo.AppID);
+ }
+
+ return pinnedAppsDictionary;
+ }
+
public void UpdatePinnedApps(IEnumerable<AppShortcutInfo> pinnedAppsInfo)
{
AppShortcutStorage.Write(pinnedAppsInfo);
{
public sealed class AppControlUtils
{
- private static IAppControl iam;
- private static readonly AppControlUtils instance = new AppControlUtils();
-
- public static AppControlUtils Instance
- {
- get { return instance; }
- }
-
- private class DefaultAM : IAppControl
- {
- public void SendLaunchRequest(string PkgID)
- {
- }
- }
-
- private AppControlUtils()
+ public static void SendLaunchRequest(string PkgID)
{
- if (DependencyService.Get<IAppControl>() != null)
- {
- iam = DependencyService.Get<IAppControl>();
- }
- else
+ if (DependencyService.Get<IAppControl>() == null)
{
- iam = new DefaultAM();
+ return;
}
- }
- public static void SendLaunchRequest(string PkgID)
- {
- iam.SendLaunchRequest(PkgID);
+ DependencyService.Get<IAppControl>().SendLaunchRequest(PkgID);
}
}
}
{
IFileSystemAPIs fileSystem = DependencyService.Get<IFileSystemAPIs>();
XmlSerializer serializer = new XmlSerializer(typeof(List<AppShortcutInfo>));
- Stream fileStream = fileSystem.OpenFile(storagePath, UtilFileMode.Open);
- if (fileStream == null)
+ Stream fileStream = null;
+
+ try
+ {
+ fileStream = fileSystem.OpenFile(storagePath, UtilFileMode.Open);
+ if (fileStream == null)
+ {
+ DebuggingUtils.Dbg("OpenFile failed : " + storagePath);
+ // TODO : Remove later, below lines are sample apps for demonstration.
+ List<AppShortcutInfo> result = GetSampleList();
+ Write(result);
+ return result;
+ }
+
+ StreamReader streamReader = new StreamReader(fileStream);
+ List<AppShortcutInfo> list = (List<AppShortcutInfo>)serializer.Deserialize(streamReader);
+
+ return list;
+ }
+ catch (Exception e)
{
- DebuggingUtils.Dbg("OpenFile failed : " + storagePath);
- // TODO : Remove later, below lines are sample apps for demonstration.
+ // TODO : recover xml file here!
+ DebuggingUtils.Err("XML Desearialize is failed, " + storagePath + ", " + e.Message);
List<AppShortcutInfo> result = GetSampleList();
Write(result);
return result;
}
-
- StreamReader streamReader = new StreamReader(fileStream);
- List<AppShortcutInfo> list = (List<AppShortcutInfo>)serializer.Deserialize(streamReader);
- fileSystem.CloseFile(fileStream);
- return list;
+ finally
+ {
+ if (fileStream != null)
+ {
+ fileSystem.CloseFile(fileStream);
+ }
+ }
}
public static bool Write(IEnumerable<AppShortcutInfo> pinnedAppInfo)
{
IFileSystemAPIs fileSystem = DependencyService.Get<IFileSystemAPIs>();
XmlSerializer serializer = new XmlSerializer(typeof(List<AppShortcutInfo>));
- Stream fileStream = fileSystem.OpenFile(storagePath, UtilFileMode.OpenOrCreate);
- if (fileStream == null)
+ Stream fileStream = null;
+
+ try
+ {
+ fileStream = fileSystem.OpenFile(storagePath, UtilFileMode.Create);
+ if (fileStream == null)
+ {
+ return false;
+ }
+
+ StreamWriter streamWriter = new StreamWriter(fileStream);
+ serializer.Serialize(streamWriter, pinnedAppInfo);
+ streamWriter.Flush();
+ }
+ catch (Exception e)
{
+ DebuggingUtils.Err("XML Searialize is failed, " + storagePath + ", " + e.Message);
return false;
}
+ finally
+ {
+ if (fileStream != null)
+ {
+ fileSystem.CloseFile(fileStream);
+ }
+
+ }
- StreamWriter streamWriter = new StreamWriter(fileStream);
- serializer.Serialize(streamWriter, pinnedAppInfo);
- streamWriter.Flush();
- fileSystem.CloseFile(fileStream);
return true;
}
Dictionary<string, string[]> GetPackageList();
string GetPackage(string PkgID);
+
+ bool UninstallPackage(string pkgID);
+
+ bool UninstallPackageByAppID(string appID);
}
}
--- /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.
+ */
+
+
+namespace LibTVRefCommonPortable.Utils
+{
+ public interface IPlatformNotification
+ {
+ void OnBackKeyPressed();
+
+ void OnAppInstalled(string pkgID);
+
+ void OnAppUninstalled(string pkgID);
+ }
+}
{
public sealed class PackageManagerUtils
{
- private static IPackageManager ipm;
- private static readonly PackageManagerUtils instance = new PackageManagerUtils();
-
- public static PackageManagerUtils Instance
+ public static Dictionary<string, string[]> GetPackageList()
{
- get { return instance; }
+ if (DependencyService.Get<IPackageManager>() == null)
+ {
+ return new Dictionary<string, string[]>();
+ }
+
+ return DependencyService.Get<IPackageManager>().GetPackageList();
}
- private class DefaultPM : IPackageManager
+ public static string GetPackage(string PkgID)
{
- public Dictionary<string, string[]> GetPackageList()
+ if (DependencyService.Get<IPackageManager>() == null)
{
- return null;
+ return "";
}
- public string GetPackage(string PkgID)
- {
- return null;
- }
+ return DependencyService.Get<IPackageManager>().GetPackage(PkgID);
}
- private PackageManagerUtils()
+ public static bool UninstallPackage(string pkgID)
{
- if (DependencyService.Get<IPackageManager>() != null)
+ if (DependencyService.Get<IPackageManager>() == null)
{
- ipm = DependencyService.Get<IPackageManager>();
+ return false;
}
- else
- {
- ipm = new DefaultPM();
- }
- }
- public Dictionary<string, string[]> GetPackageList()
- {
- return ipm.GetPackageList();
+ return DependencyService.Get<IPackageManager>().UninstallPackage(pkgID);
}
- public string GetPackage(string PkgID)
+ public static bool UninstallPackageByAppID(string appID)
{
- return ipm.GetPackage(PkgID);
+ if (DependencyService.Get<IPackageManager>() == null)
+ {
+ return false;
+ }
+
+ return DependencyService.Get<IPackageManager>().UninstallPackageByAppID(appID);
}
}
}
+++ /dev/null
-using System;
-
-namespace LibTVRefCommonTizen
-{
- public class MyLibrary
- {
- public string MyMethod()
- {
- return "Hello Tizen Library!!!";
- }
- }
-}
<None Include="LibTVRefCommonTizen.project.json" />
</ItemGroup>
<ItemGroup>
- <Compile Include="LibTVRefCommonTizen.cs" />
<Compile Include="Ports\AppControlPort.cs" />
<Compile Include="Ports\ApplicationManagerPort.cs" />
<Compile Include="Ports\BTModulePort.cs" />
foreach (var appInfo in installedList)
{
- DebuggingPort.D("-------------------------------------");
- DebuggingPort.D("TRY" + appInfo.ToString());
if (appInfo.IsNoDisplay)
{
continue;
continue;
}
- DebuggingPort.D("TRY" + pkgInfo.ToString());
-
if (pkgInfo.IsSystemPackage)
{
continue;
}
- DebuggingPort.D("ADD" + appInfo.ToString());
-
-
result = new string[3];
result[0] = (appInfo.Label != null) ? appInfo.Label : null;
using Tizen.Applications;
using LibTVRefCommmonPortable.Utils;
+using LibTVRefCommonPortable.Utils;
namespace LibTVRefCommonTizen.Ports
{
public class PackageManagerPort : IPackageManager
{
+ private static IPlatformNotification Notification
+ {
+ get;
+ set;
+ }
+
public PackageManagerPort()
{
+
+ }
+
+ public static void RegisterCallbacks(IPlatformNotification app)
+ {
+ Notification = app;
PackageManager.InstallProgressChanged += PackageManager_InstallProgressChanged;
PackageManager.UninstallProgressChanged += PackageManager_UninstallProgressChanged;
}
- private void PackageManager_UninstallProgressChanged(object sender, PackageManagerEventArgs e)
+ public static void DeregisterCallbacks()
+ {
+ Notification = null;
+ PackageManager.InstallProgressChanged -= PackageManager_InstallProgressChanged;
+ PackageManager.UninstallProgressChanged -= PackageManager_UninstallProgressChanged;
+ }
+
+ private static void PackageManager_UninstallProgressChanged(object sender, PackageManagerEventArgs e)
{
if (e.State == PackageEventState.Completed)
{
- DebuggingUtils.Dbg("uninstall completed");
+ if (Notification != null)
+ {
+ Notification.OnAppUninstalled(e.PackageId);
+ }
}
}
- private void PackageManager_InstallProgressChanged(object sender, PackageManagerEventArgs e)
+ private static void PackageManager_InstallProgressChanged(object sender, PackageManagerEventArgs e)
{
if (e.State == PackageEventState.Completed)
{
- DebuggingUtils.Dbg("install completed");
+ if (Notification != null)
+ {
+ Notification.OnAppInstalled(e.PackageId);
+ }
}
}
return (tempItem != null) ? tempItem.Label : null;
}
+
+ public bool UninstallPackage(string pkgID)
+ {
+ Package tempItem = PackageManager.GetPackage(pkgID);
+ if (tempItem == null)
+ {
+ return false;
+ }
+
+ return PackageManager.Uninstall(tempItem.Id, tempItem.PackageType);
+ }
+
+ public bool UninstallPackageByAppID(string appID)
+ {
+ string pkgID = PackageManager.GetPackageIdByApplicationId(appID);
+ if (pkgID == null ||
+ pkgID.Length == 0)
+ {
+ return false;
+ }
+
+ return UninstallPackage(pkgID);
+ }
}
}
\ No newline at end of file
+/*
+ * 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 LibTVRefCommonPortable.Utils;
using LibTVRefCommonTizen.Ports;
+using LibTVRefCommonTizen;
namespace TVApps.TizenTV
{
- class Program : Xamarin.Forms.Platform.Tizen.FormsApplication
+ public class Program : Xamarin.Forms.Platform.Tizen.FormsApplication
{
+ IPlatformNotification notification;
+
protected override void OnCreate()
{
base.OnCreate();
- LoadApplication(new App());
+ var app = new App();
+ notification = app;
+ LoadApplication(app);
+
+ PackageManagerPort.RegisterCallbacks(notification);
+ MainWindow.KeyGrab(ElmSharp.EvasKeyEventArgs.PlatformBackButtonName, true);
+ MainWindow.KeyUp += BackkeyListener;
+ }
+
+ private void BackkeyListener(object sender, ElmSharp.EvasKeyEventArgs e)
+ {
+ if (e.KeyName.CompareTo(ElmSharp.EvasKeyEventArgs.PlatformBackButtonName) == 0)
+ {
+ if (notification != null)
+ {
+ notification.OnBackKeyPressed();
+ }
+ }
+ }
+
+ protected override void OnTerminate()
+ {
+ base.OnTerminate();
+
+ notification = null;
+ PackageManagerPort.DeregisterCallbacks();
+ MainWindow.KeyUngrab(ElmSharp.EvasKeyEventArgs.PlatformBackButtonName);
+ MainWindow.KeyUp -= BackkeyListener;
}
static void Main(string[] args)
{
var app = new Program();
- global::Xamarin.Forms.DependencyService.Register<DebuggingPort>();
- global::Xamarin.Forms.DependencyService.Register<DBPort>();
- global::Xamarin.Forms.DependencyService.Register<AppControlPort>();
- global::Xamarin.Forms.DependencyService.Register<PackageManagerPort>();
- global::Xamarin.Forms.DependencyService.Register<WifiModulePort>();
- global::Xamarin.Forms.DependencyService.Register<BTModulePort>();
- global::Xamarin.Forms.DependencyService.Register<FileSystemWatcherPort>();
- global::Xamarin.Forms.DependencyService.Register<ApplicationManagerPort>();
- global::Xamarin.Forms.DependencyService.Register<FileSystemPort>();
+
+ Xamarin.Forms.DependencyService.Register<DebuggingPort>();
+ Xamarin.Forms.DependencyService.Register<DBPort>();
+ Xamarin.Forms.DependencyService.Register<AppControlPort>();
+ Xamarin.Forms.DependencyService.Register<PackageManagerPort>();
+ Xamarin.Forms.DependencyService.Register<WifiModulePort>();
+ Xamarin.Forms.DependencyService.Register<BTModulePort>();
+ Xamarin.Forms.DependencyService.Register<FileSystemWatcherPort>();
+ Xamarin.Forms.DependencyService.Register<ApplicationManagerPort>();
+ Xamarin.Forms.DependencyService.Register<FileSystemPort>();
Xamarin.Forms.Platform.Tizen.Forms.Init(app);
+
app.Run(args);
+
}
+
}
}
<Name>TVApps</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <Reference Include="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
using Xamarin.Forms;
using TVApps.Views;
+using LibTVRefCommonPortable.Utils;
+using System;
+using LibTVRefCommmonPortable.Utils;
namespace TVApps
{
- public class App : Application
+ public class TVAppsEventArgs : EventArgs
{
+ public string arg;
+ }
+
+ public class App : Application, IPlatformNotification
+ {
+ private static EventHandler<TVAppsEventArgs> BackKeyListener;
+ private static EventHandler<TVAppsEventArgs> AppInstalledListener;
+ private static EventHandler<TVAppsEventArgs> AppUninstalledListener;
+
public App()
{
MainPage = new MainPage();
{
}
+
+ public static void SetBackKeyListener(EventHandler<TVAppsEventArgs> listener)
+ {
+ BackKeyListener += listener;
+ }
+ public static void SetAppInstalledListener(EventHandler<TVAppsEventArgs> listener)
+ {
+ AppInstalledListener += listener;
+ }
+
+ public static void SetAppUninstalledListener(EventHandler<TVAppsEventArgs> listener)
+ {
+ AppUninstalledListener += listener;
+ }
+
+ public void OnBackKeyPressed()
+ {
+ DebuggingUtils.Dbg("[[[ Back Key ]]] ");
+ BackKeyListener.Invoke(this, new TVAppsEventArgs()
+ {
+ arg = "",
+ });
+ }
+
+ public void OnAppInstalled(string pkgID)
+ {
+ DebuggingUtils.Dbg("[[[ App Installed ]]] " + pkgID);
+ AppInstalledListener.Invoke(this, new TVAppsEventArgs()
+ {
+ arg = pkgID,
+ });
+ }
+
+ public void OnAppUninstalled(string pkgID)
+ {
+ DebuggingUtils.Dbg("[[[ App Uninstalled ]]] " + pkgID);
+ AppUninstalledListener.Invoke(this, new TVAppsEventArgs()
+ {
+ arg = pkgID,
+ });
+ }
}
}
</Compile>
<Compile Include="TVApps.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="ViewModels\AppsHolder.cs" />
<Compile Include="ViewModels\AppsListSorter.cs" />
+ <Compile Include="ViewModels\IAppsViewModel.cs" />
<Compile Include="ViewModels\MainPageViewModel.cs" />
<Compile Include="Views\FooterDeleteStatus.xaml.cs">
<DependentUpon>FooterDeleteStatus.xaml</DependentUpon>
--- /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 LibTVRefCommmonPortable.DataModels;
+using LibTVRefCommmonPortable.Utils;
+using LibTVRefCommonPortable.DataModels;
+using System.Collections.Generic;
+using System.Linq;
+using Xamarin.Forms;
+
+namespace TVApps.ViewModels
+{
+ internal class AppsHolder
+ {
+ IAppsViewModel ViewModel;
+
+ public SortingOptions SortingOption;
+
+ public List<AppShortcutInfo> InstalledApps;
+
+ public Dictionary<string, string> PinnedApps;
+
+
+ public AppsHolder(IAppsViewModel ViewModel)
+ {
+ this.ViewModel = ViewModel;
+
+ InstalledApps = new List<AppShortcutInfo>();
+ PinnedApps = new Dictionary<string, string>();
+
+ App.SetAppInstalledListener((s, e) =>
+ {
+ SetApps();
+ });
+
+ App.SetAppUninstalledListener((s, e) =>
+ {
+ // TODO : find apps by package id
+ // TODO : remove all apps from pinned app list
+
+ SetApps();
+ });
+
+ SetApps();
+ }
+
+ private async void SetApps()
+ {
+ DebuggingUtils.Dbg(">GetInstalledApps - Start");
+ PinnedApps = TVHomeImpl.GetInstance.AppShortcutControllerInstance.GetPinnedAppsAppIDs();
+ var installedApps = await TVHomeImpl.GetInstance.AppShortcutControllerInstance.GetInstalledApps();
+
+ foreach (AppShortcutInfo item in installedApps)
+ {
+ if (item.CurrentStateDescription == null)
+ {
+ DebuggingUtils.Err("Invalid AppshortcutInfo, " + item.AppID);
+ continue;
+ }
+
+ item.SetPinned(PinnedApps.ContainsKey(item.AppID));
+
+ var pinStateDescription = new StateDescription()
+ {
+ Label = item.CurrentStateDescription.Label,
+ IconPath = item.CurrentStateDescription.IconPath,
+ Action = new CommandAction()
+ {
+ NextStateDescription = AppsStatus.Pin.ToString().ToLower(),
+ Command = new Command<string>((key) =>
+ {
+ PinToggle(key);
+ }),
+ CommandParameter = item.AppID
+ }
+ };
+
+ item.StateDescriptions.Add(AppsStatus.Pin.ToString().ToLower(), pinStateDescription);
+
+ var deleteStateDescription = new StateDescription()
+ {
+ Label = item.CurrentStateDescription.Label,
+ IconPath = item.CurrentStateDescription.IconPath,
+ Action = new CommandAction()
+ {
+ NextStateDescription = AppsStatus.Delete.ToString().ToLower(),
+ Command = new Command<string>((key) =>
+ {
+ DeleteApp(key);
+ }),
+ CommandParameter = item.AppID
+ }
+ };
+
+ item.StateDescriptions.Add(AppsStatus.Delete.ToString().ToLower(), deleteStateDescription);
+ }
+
+ InstalledApps = installedApps.ToList();
+ SortApps(SortingOption);
+
+ DebuggingUtils.Dbg("<GetInstalledApps - End");
+ }
+
+ private void PinToggle(string key)
+ {
+ if (PinnedApps.ContainsKey(key))
+ {
+ DebuggingUtils.Dbg("UnPin!");
+ InstalledApps.FirstOrDefault(a => a.AppID == key).SetChecked(false);
+ PinnedApps.Remove(key);
+ }
+ else
+ {
+ DebuggingUtils.Dbg("Pin!");
+ InstalledApps.FirstOrDefault(a => a.AppID == key).SetChecked(true);
+ PinnedApps.Add(key, key);
+ }
+ }
+
+ private void DeleteApp(string AppID)
+ {
+ DebuggingUtils.Dbg("Delete, " + AppID);
+ // 1. Check the property of the app
+ // 1-1. If the app is pinned, call UnsetPinnedApp(AppId)
+ // 2. Show Popup(Delete message)
+ // 2-1. OK : Call the AppFW API to remove the app
+ // 2-2. Cancel : Change AppsStatus to Normal
+
+ // TODO : popup
+
+ RemovePinnedApp(AppID);
+
+ ViewModel.ChangeCurrentStatus(AppsStatus.Default);
+
+ if (PackageManagerUtils.UninstallPackageByAppID(AppID) == false)
+ {
+ DebuggingUtils.Err("App uninstall is failed!!!, " + AppID);
+ }
+ else
+ {
+ var removed = from app in InstalledApps
+ where app.AppID == AppID
+ select app;
+ InstalledApps.Remove(removed.First());
+ foreach (var item in InstalledApps)
+ {
+ DebuggingUtils.Dbg("- " + item.AppID);
+ }
+
+ RefreshApps();
+ }
+ }
+
+ public void UpdateStateDescription(AppsStatus status)
+ {
+ string tag = status.ToString().ToLower();
+
+ DebuggingUtils.Dbg("AppsListStateUpdate, status = " + status.ToString() + ", tag = " + tag);
+ foreach (AppShortcutInfo item in InstalledApps)
+ {
+ item.CurrentStateDescription = item.StateDescriptions[tag];
+ switch (status)
+ {
+ case AppsStatus.Pin:
+ item.SetChecked(item.IsPinned);
+ break;
+
+ default:
+ item.SetChecked(false);
+ break;
+ }
+
+ item.SetPinned(PinnedApps.ContainsKey(item.AppID));
+ }
+
+ ViewModel.OnPropertyChanged("InstalledAppList");
+ }
+
+ // Just use to update list view which is binding
+ private void RefreshApps()
+ {
+ InstalledApps = new List<AppShortcutInfo>(InstalledApps);
+ ViewModel.OnPropertyChanged("InstalledAppList");
+ }
+
+ public void SortApps(SortingOptions sortOption)
+ {
+ AppsListSorter.GetSortedAppsList(sortOption, ref InstalledApps);
+ RefreshApps();
+ }
+
+ public void ResetPinnedApps()
+ {
+ PinnedApps = TVHomeImpl.GetInstance.AppShortcutControllerInstance.GetPinnedAppsAppIDs();
+ }
+
+ public void UpdatePinnedApps()
+ {
+ List<AppShortcutInfo> pinnedAppList = new List<AppShortcutInfo>();
+ foreach (var item in PinnedApps)
+ {
+ DebuggingUtils.Dbg("Pinned App : " + item.Key);
+ pinnedAppList.Add(new AppShortcutInfo()
+ {
+ AppID = item.Key,
+ });
+ }
+
+ TVHomeImpl.GetInstance.AppShortcutControllerInstance.UpdatePinnedApps(pinnedAppList);
+ }
+
+ public void RemovePinnedApp(string AppID)
+ {
+ if (PinnedApps.ContainsKey(AppID))
+ {
+ PinnedApps.Remove(AppID);
+ UpdatePinnedApps();
+ }
+ }
+ }
+}
*/
using LibTVRefCommmonPortable.DataModels;
+using LibTVRefCommmonPortable.Utils;
using System.Collections.Generic;
namespace TVApps.ViewModels
{
- public class AppsListSorter
+ internal class AppsListSorter
{
private static int SortByLabelAscending(AppShortcutInfo left, AppShortcutInfo right)
public static void GetSortedAppsList(SortingOptions sortOption, ref List<AppShortcutInfo> list)
{
+ DebuggingUtils.Dbg("GetSortedAppsList, option = " + sortOption.ToString());
switch (sortOption)
{
case SortingOptions.RecentlyInstalled:
case SortingOptions.RecentlyUsed:
list.Sort(SortByRecentlyUsed);
break;
- case SortingOptions.Ascending:
- list.Sort(SortByLabelAscending);
- break;
case SortingOptions.Descending:
list.Sort(SortByLabelDescending);
break;
+ case SortingOptions.Ascending:
+ default:
+ list.Sort(SortByLabelAscending);
+ break;
}
}
}
--- /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.
+ */
+
+namespace TVApps.ViewModels
+{
+ interface IAppsViewModel
+ {
+ void OnPropertyChanged(string name);
+ void ChangeCurrentStatus(AppsStatus newStatus);
+ }
+}
using LibTVRefCommmonPortable.DataModels;
using LibTVRefCommmonPortable.Utils;
-using LibTVRefCommonPortable.DataModels;
using System.Collections.Generic;
using System.ComponentModel;
-using System.Linq;
using Xamarin.Forms;
using System;
{
public enum AppsStatus
{
- Launch,
+ Default = 0,
Pin,
Delete,
};
- public enum BackKeyInfo
- {
- Back,
- Front,
- Quit,
- };
-
public enum SortingOptions
{
RecentlyInstalled = 0,
Descending,
};
- class MainPageViewModel : INotifyPropertyChanged
+ class MainPageViewModel : INotifyPropertyChanged, IAppsViewModel
{
- private List<AppShortcutInfo> installedAppList;
+ AppsHolder appsHolder;
+
public List<AppShortcutInfo> InstalledAppList
{
get
{
- return installedAppList;
+ return appsHolder.InstalledApps;
}
}
- public List<AppShortcutInfo> PinnedAppList { get; private set; }
-
public Command OptionCommand { get; set; }
- public Command ButtonDelCommand { get; set; }
- public Command ButtonPinCommand { get; set; }
+ public Command ButtonDeleteCancelCommand { get; set; }
+ public Command ButtonPinAppCommand { get; set; }
+ public Command ButtonDeleteAppCommand { get; set; }
+ public Command ButtonPinOkCommand { get; set; }
+ public Command ButtonPinCancelCommand { get; set; }
public AppsStatus CurrentStatus { get; private set; }
- private SortingOptions SortingOption { get; set; }
+ private SortingOptions SortingOption
+ {
+ get
+ {
+ return appsHolder.SortingOption;
+ }
+
+ set
+ {
+ appsHolder.SortingOption = value;
+ }
+ }
public int SortOptionIndex
{
set
{
- SortingOption = (SortingOptions)Enum.ToObject(typeof(SortingOptions), value);
- if (installedAppList != null)
+ SortingOptions newSortingOption = (SortingOptions)Enum.ToObject(typeof(SortingOptions), value);
+ if (newSortingOption != SortingOption)
{
- AppsListSorter.GetSortedAppsList(SortingOption, ref installedAppList);
- OnPropertyChanged("AppList");
+ SortingOption = newSortingOption;
+ if (InstalledAppList != null)
+ {
+ appsHolder.SortApps(SortingOption);
+ }
}
}
}
- public BackKeyInfo BackKeyStatus { get; private set; }
-
public ShortcutInfo FocusedItem { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
public MainPageViewModel()
{
+ DebuggingUtils.Dbg(">MainPageViewModel - Start");
+
Init();
- GetInstalledApps();
+ ButtonDeleteCancelCommand = new Command(() =>
+ {
+ ChangeCurrentStatus(AppsStatus.Default);
+ });
- OptionCommand = new Command((optionType) =>
+ ButtonPinAppCommand = new Command(() =>
{
- // 1. Change current status by optionType
- CurrentStatus = AppsStatus.Pin;
- foreach (AppShortcutInfo item in installedAppList)
- {
- item.CurrentStateDescription = item.StateDescriptions["pin"];
- item.SetChecked(item.IsPinned);
- item.SetPinned(false);
- }
+ ChangeCurrentStatus(AppsStatus.Pin);
+ });
- OnPropertyChanged("CurrentStatus");
+ ButtonDeleteAppCommand = new Command(() =>
+ {
+ ChangeCurrentStatus(AppsStatus.Delete);
});
- ButtonDelCommand = new Command(() =>
+ ButtonPinOkCommand = new Command(() =>
{
- CurrentStatus = AppsStatus.Launch;
- foreach (AppShortcutInfo item in installedAppList)
- {
- item.CurrentStateDescription = item.StateDescriptions["default"];
- item.SetPinned(item.IsChecked);
- item.SetChecked(false);
- }
+ appsHolder.UpdatePinnedApps();
+
+ ChangeCurrentStatus(AppsStatus.Default);
+ });
- OnPropertyChanged("CurrentStatus");
+ ButtonPinCancelCommand = new Command(() =>
+ {
+ appsHolder.ResetPinnedApps();
+ ChangeCurrentStatus(AppsStatus.Default);
});
- ButtonPinCommand = new Command(() =>
+ App.SetBackKeyListener((s, e) =>
{
- CurrentStatus = AppsStatus.Delete;
- OnPropertyChanged("CurrentStatus");
+ // TODO : check concurrency
+ ChangeCurrentStatus(AppsStatus.Default);
});
+
+ DebuggingUtils.Dbg("<MainPageViewModel - End");
}
private void Init()
{
- BackKeyStatus = BackKeyInfo.Back;
+ appsHolder = new AppsHolder(this);
+
// TODO : set default value as RecentlyInstalled
SortingOption = SortingOptions.Ascending;
- SortOptionIndex = (int)SortingOption;
- CurrentStatus = AppsStatus.Launch;
+ ChangeCurrentStatus(AppsStatus.Default);
+ }
- installedAppList = new List<AppShortcutInfo>();
- PinnedAppList = new List<AppShortcutInfo>();
+ public void ChangeCurrentStatus(AppsStatus newStatus)
+ {
+ CurrentStatus = newStatus;
+ appsHolder.UpdateStateDescription(CurrentStatus);
+ OnPropertyChanged("CurrentStatus");
}
- protected void OnPropertyChanged(string name)
+ public void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
}
}
- private async void GetInstalledApps()
- {
- var pinnedApps = TVHomeImpl.GetInstance.AppShortcutControllerInstance.GetInstalledApps();
- var installedApps = await TVHomeImpl.GetInstance.AppShortcutControllerInstance.GetInstalledApps();
-
- foreach (AppShortcutInfo item in installedApps)
- {
- var pinStateDescription = new StateDescription()
- {
- Label = item.CurrentStateDescription.Label,
- IconPath = item.CurrentStateDescription.IconPath,
- Action = new CommandAction()
- {
- Command = new Command<string>((key) =>
- {
- PinToggle(key);
- }),
- CommandParameter = item.AppID
- }
- };
-
- item.StateDescriptions.Add("pin", pinStateDescription);
-
- var deleteStateDescription = new StateDescription()
- {
- Label = item.CurrentStateDescription.Label,
- IconPath = item.CurrentStateDescription.IconPath,
- Action = new CommandAction()
- {
- Command = new Command<string>((key) =>
- {
- DeleteApp(key);
- }),
- CommandParameter = item.AppID
- }
- };
-
- item.StateDescriptions.Add("delete", deleteStateDescription);
- }
-
- foreach (AppShortcutInfo item in pinnedApps.Result)
- {
- var app = installedApps.First(a => a.AppID == item.AppID);
- if (app != null)
- {
- installedApps.First(a => a.AppID == item.AppID).SetPinned(true);
- }
- }
-
- installedAppList = installedApps.ToList();
- PinnedAppList = pinnedApps.Result.ToList();
-
- if (installedAppList != null)
- {
- OnPropertyChanged("InstalledAppList");
- }
- }
-
- private void PinToggle(string key)
- {
- if (PinnedAppList.Exists(a => a.AppID == key))
- {
- DebuggingUtils.Dbg("UnPin!");
- installedAppList.FirstOrDefault(a => a.AppID == key).SetChecked(false);
- PinnedAppList.Remove(PinnedAppList.FirstOrDefault(a => a.AppID == key));
- }
- else
- {
- DebuggingUtils.Dbg("Pin!");
- installedAppList.FirstOrDefault(a => a.AppID == key).SetChecked(true);
- PinnedAppList.Add(installedAppList.FirstOrDefault(a => a.AppID == key));
- }
- }
-
- public void DeleteApp(string AppId)
- {
- // 1. Check the property of the app
- // 1-1. If the app is pinned, call UnsetPinnedApp(AppId)
- // 2. Show Popup(Delete message)
- // 2-1. OK : Call the AppFW API to remove the app
- // 2-2. Cancel : Change AppsStatus to Normal
- }
}
}
</ContentView.Resources>
<ContentView.Content>
- <Button x:Name="ButtonDel"
- Text="Del"
+ <Button Text="CANCEL"
Style="{StaticResource button}"
- Command="{Binding ButtonDelCommand}"/>
+ Command="{Binding ButtonDeleteCancelCommand}"/>
</ContentView.Content>
</ContentView>
</Picker.Items>
</Picker>
- <Button x:Name="ButtonOption"
- Style="{StaticResource button}"
- Text="OPTION"
- Command="{Binding OptionCommand}"/>
+ <Button Text="PIN"
+ Style="{StaticResource button}"
+ Command="{Binding ButtonPinAppCommand}"/>
+ <Button Text="DELETE"
+ Style="{StaticResource button}"
+ Command="{Binding ButtonDeleteAppCommand}"/>
</StackLayout>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
-<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
+<StackLayout xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
- x:Class="TVApps.Views.FooterPinStatus">
+ x:Class="TVApps.Views.FooterPinStatus"
+ Orientation="Horizontal">
- <ContentView.Resources>
+ <StackLayout.Resources>
<ResourceDictionary>
<Style x:Key="button" TargetType="Button">
<Setter Property="BorderColor" Value="#FFFFFF"/>
<Setter Property="BackgroundColor" Value="Transparent"/>
</Style>
</ResourceDictionary>
- </ContentView.Resources>
+ </StackLayout.Resources>
- <ContentView.Content>
- <Button x:Name="ButtonPin"
- Text="PIN"
- Style="{StaticResource button}"
- Command="{Binding ButtonPinCommand}"/>
- </ContentView.Content>
-</ContentView>
+ <Button x:Name="ButtonPinOk"
+ Text="OK"
+ Style="{StaticResource button}"
+ Command="{Binding ButtonPinOkCommand}"/>
+
+ <Button x:Name="ButtonPinCancel"
+ Text="CANCEL"
+ Style="{StaticResource button}"
+ Command="{Binding ButtonPinCancelCommand}"/>
+</StackLayout>
/// <summary>
/// hahaha
/// </summary>
- public partial class FooterPinStatus : ContentView
+ public partial class FooterPinStatus : StackLayout
{
public FooterPinStatus()
{
x:Class="TVApps.Views.MainPage"
BackgroundColor="#000000"
CurrentStatus="{Binding CurrentStatus}">
- <ContentPage.BindingContext>
- <ViewModels:MainPageViewModel />
- </ContentPage.BindingContext>
-
- <ContentPage.Resources>
- <ResourceDictionary>
- <Style x:Key="titleText" TargetType="Label" >
- <Setter Property="FontSize" Value="187" />
- <Setter Property="TextColor" Value="#FFFFFF" />
- <Setter Property="FontFamily" Value="Samsung sans" />
- </Style>
- <Style x:Key="buttonTextNormal" TargetType="Label" >
- <Setter Property="FontSize" Value="62" />
- <Setter Property="TextColor" Value="#F7F7F7" />
- <Setter Property="FontFamily" Value="Breeze Sans Regular" />
- </Style>
- <Style x:Key="buttonTextPressed" TargetType="Label" >
- <Setter Property="FontSize" Value="62" />
- <Setter Property="TextColor" Value="#F7F7F708" />
- <Setter Property="FontFamily" Value="Breeze Sans Regular" />
- </Style>
- <Style x:Key="pinnedText" TargetType="Label" >
- <Setter Property="FontSize" Value="50" />
- <Setter Property="TextColor" Value="#F7F7F7" />
- <Setter Property="FontFamily" Value="Breeze Sans Regular" />
- </Style>
-
- <Style x:Key="button" TargetType="Button">
- <Setter Property="BorderColor" Value="#FFFFFF"/>
- <Setter Property="HeightRequest" Value="40"/>
- <Setter Property="BorderWidth" Value="2" />
- <Setter Property="HorizontalOptions" Value="Center"/>
- <Setter Property="BackgroundColor" Value="Transparent"/>
- </Style>
- </ResourceDictionary>
- </ContentPage.Resources>
-
- <Grid>
+ <ContentPage.BindingContext>
+ <ViewModels:MainPageViewModel />
+ </ContentPage.BindingContext>
+
+ <ContentPage.Resources>
+ <ResourceDictionary>
+ <Style x:Key="titleText" TargetType="Label" >
+ <Setter Property="FontSize" Value="187" />
+ <Setter Property="TextColor" Value="#FFFFFF" />
+ <Setter Property="FontFamily" Value="Samsung sans" />
+ </Style>
+ <Style x:Key="backKeyInfoText" TargetType="Label" >
+ <Setter Property="FontSize" Value="62" />
+ <Setter Property="TextColor" Value="#99FFFFFF" />
+ <Setter Property="FontFamily" Value="Samsung sans" />
+ </Style>
+ <Style x:Key="buttonTextNormal" TargetType="Label" >
+ <Setter Property="FontSize" Value="62" />
+ <Setter Property="TextColor" Value="#F7F7F7" />
+ <Setter Property="FontFamily" Value="Breeze Sans Regular" />
+ </Style>
+ <Style x:Key="buttonTextPressed" TargetType="Label" >
+ <Setter Property="FontSize" Value="62" />
+ <Setter Property="TextColor" Value="#F7F7F708" />
+ <Setter Property="FontFamily" Value="Breeze Sans Regular" />
+ </Style>
+ <Style x:Key="pinnedText" TargetType="Label" >
+ <Setter Property="FontSize" Value="50" />
+ <Setter Property="TextColor" Value="#F7F7F7" />
+ <Setter Property="FontFamily" Value="Breeze Sans Regular" />
+ </Style>
+
+ <Style x:Key="button" TargetType="Button">
+ <Setter Property="BorderColor" Value="#FFFFFF"/>
+ <Setter Property="HeightRequest" Value="40"/>
+ <Setter Property="BorderWidth" Value="2" />
+ <Setter Property="HorizontalOptions" Value="Center"/>
+ <Setter Property="BackgroundColor" Value="Transparent"/>
+ </Style>
+ </ResourceDictionary>
+ </ContentPage.Resources>
+
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="2685*" />
+ <RowDefinition Height="83*" />
+ <RowDefinition Height="5074*" />
+ <RowDefinition Height="0981*" />
+ <RowDefinition Height="1185*" />
+ </Grid.RowDefinitions>
+ <Grid.RowSpacing>0</Grid.RowSpacing>
+ <Grid.ColumnSpacing>0</Grid.ColumnSpacing>
+
+ <Grid Grid.Row="0">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="2083*" />
+ <ColumnDefinition Width="5833*" />
+ <ColumnDefinition Width="2083*" />
+ </Grid.ColumnDefinitions>
+
+ <Label Grid.Column="1"
+ Style="{StaticResource titleText}"
+ HorizontalTextAlignment="Center"
+ VerticalOptions="CenterAndExpand"
+ HorizontalOptions="CenterAndExpand"
+ Text="APPS" />
+
+ <Grid Grid.Column="2">
<Grid.RowDefinitions>
- <RowDefinition Height="2685*" />
- <RowDefinition Height="83*" />
- <RowDefinition Height="5074*" />
- <RowDefinition Height="0981*" />
- <RowDefinition Height="1185*" />
+ <RowDefinition Height="4482*" />
+ <RowDefinition Height="1379*" />
+ <RowDefinition Height="4137*" />
</Grid.RowDefinitions>
+
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="4800*" />
+ <ColumnDefinition Width="5200*" />
+ </Grid.ColumnDefinitions>
+
<Grid.RowSpacing>0</Grid.RowSpacing>
<Grid.ColumnSpacing>0</Grid.ColumnSpacing>
- <Grid Grid.Row="0">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="2083*" />
- <ColumnDefinition Width="5833*" />
- <ColumnDefinition Width="2083*" />
- </Grid.ColumnDefinitions>
-
- <Label Grid.Column="1"
- Style="{StaticResource titleText}"
- HorizontalTextAlignment="Center"
- VerticalOptions="CenterAndExpand"
- HorizontalOptions="CenterAndExpand"
- Text="APPS" />
-
- <Label Grid.Column="2"
- x:Name="BackKeyInfo"
- Style="{StaticResource buttonTextNormal}"
- HorizontalTextAlignment="Center"
- VerticalOptions="CenterAndExpand"
- HorizontalOptions="CenterAndExpand"
- Text="Back" />
- </Grid>
-
- <Controls:AppListView x:Name="AppListView"
- Grid.Row="2"
- ItemsSource="{Binding InstalledAppList}">
- <Controls:AppListView.ItemTemplate>
- <DataTemplate>
- <Controls:AppItemCell/>
- </DataTemplate>
- </Controls:AppListView.ItemTemplate>
- </Controls:AppListView>
-
- <Grid Grid.Row="4">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="5*" />
- <ColumnDefinition Width="90*" />
- <ColumnDefinition Width="5*" />
- </Grid.ColumnDefinitions>
-
- <Views:FooterNormalStatus x:Name="FooterNormal"
- Grid.Column="1"
- IsVisible="true" />
-
- <Views:FooterPinStatus x:Name="FooterPin"
- Grid.Column="1"
- IsVisible="false" />
-
- <Views:FooterDeleteStatus x:Name="FooterDelete"
- Grid.Column="1"
- IsVisible="false" />
- </Grid>
+ <StackLayout Grid.Row="1" Grid.Column="1"
+ Orientation="Horizontal">
+ <Image Source="ic_tizen_apps_additional_back.png"
+ WidthRequest="80"
+ HeightRequest="80"
+ VerticalOptions="CenterAndExpand"
+ HorizontalOptions="CenterAndExpand"/>
+
+ <Label x:Name="BackKeyInfo"
+ Style="{StaticResource backKeyInfoText}"
+ HorizontalTextAlignment="Start"/>
+ </StackLayout>
+
+ </Grid>
+ </Grid>
+
+ <Controls:AppListView Grid.Row="2"
+ ItemsSource="{Binding InstalledAppList}">
+ <Controls:AppListView.ItemTemplate>
+ <DataTemplate>
+ <Controls:AppItemCell/>
+ </DataTemplate>
+ </Controls:AppListView.ItemTemplate>
+ </Controls:AppListView>
+
+ <Grid Grid.Row="4">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="625*" />
+ <RowDefinition Height="375*" />
+ </Grid.RowDefinitions>
+
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="6385*" />
+ <ColumnDefinition Width="3615*" />
+ </Grid.ColumnDefinitions>
+
+ <Views:FooterNormalStatus Grid.Row="0" Grid.Column="1"
+ x:Name="FooterNormal"
+ HorizontalOptions="CenterAndExpand"
+ VerticalOptions="CenterAndExpand"
+ IsVisible="true" />
+
+ <Views:FooterPinStatus Grid.Row="0" Grid.Column="1"
+ x:Name="FooterPin"
+ HorizontalOptions="CenterAndExpand"
+ VerticalOptions="CenterAndExpand"
+ IsVisible="false" />
+
+ <Views:FooterDeleteStatus Grid.Row="0" Grid.Column="1"
+ x:Name="FooterDelete"
+ HorizontalOptions="End"
+ VerticalOptions="CenterAndExpand"
+ IsVisible="false" />
</Grid>
+ </Grid>
</ContentPage>
\ No newline at end of file
{
InitializeComponent();
PropertyChanged += MainPage_PropertyChanged;
+ SetCurrntStatus(AppsStatus.Default);
+ }
+
+ private void SetCurrntStatus(AppsStatus status)
+ {
+ switch (status)
+ {
+ case AppsStatus.Default:
+ FooterNormal.IsVisible = true;
+ FooterPin.IsVisible = false;
+ FooterDelete.IsVisible = false;
+ BackKeyInfo.Text = "Quit";
+ break;
+ case AppsStatus.Pin:
+ FooterNormal.IsVisible = false;
+ FooterPin.IsVisible = true;
+ FooterDelete.IsVisible = false;
+ BackKeyInfo.Text = "Back";
+ break;
+ case AppsStatus.Delete:
+ FooterNormal.IsVisible = false;
+ FooterPin.IsVisible = false;
+ FooterDelete.IsVisible = true;
+ BackKeyInfo.Text = "Back";
+ break;
+ }
}
private void MainPage_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName.CompareTo("CurrentStatus") == 0)
{
- switch (CurrentStatus)
- {
- case AppsStatus.Launch:
- FooterNormal.IsVisible = true;
- FooterPin.IsVisible = false;
- FooterDelete.IsVisible = false;
- BackKeyInfo.Text = "Back";
- break;
- case AppsStatus.Pin:
- FooterNormal.IsVisible = false;
- FooterPin.IsVisible = true;
- FooterDelete.IsVisible = false;
- BackKeyInfo.Text = "Front";
- break;
- case AppsStatus.Delete:
- FooterNormal.IsVisible = false;
- FooterPin.IsVisible = false;
- FooterDelete.IsVisible = true;
- BackKeyInfo.Text = "Quit";
- break;
- }
+ SetCurrntStatus(CurrentStatus);
}
}
}
<privilege>http://tizen.org/privilege/network.get</privilege>\r
<privilege>http://tizen.org/privilege/network.set</privilege>\r
<privilege>http://tizen.org/privilege/packagemanager.info</privilege>\r
+ <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>\r
<privilege>http://tizen.org/privilege/appmanager.launch</privilege>\r
<privilege>http://tizen.org/privilege/externalstorage</privilege>\r
</privileges>\r
MakeRecentButtons();
DebuggingUtils.Dbg("Reading Apps list");
- AppList = TVHomeImpl.GetInstance.AppShortcutControllerInstance.GetPinnedApps();
+ AppList = TVHomeImpl.GetInstance.AppShortcutControllerInstance.GetPinnedAppsWithDefaultShortcuts();
OnPropertyChanged("AppList");
//SettingsList = TVHomeImpl.GetInstance.AppShortcutControllerInstnace.ReadFromFile();
private void TestFunction(object sender, EventArgs e)
{
- AppList = TVHomeImpl.GetInstance.AppShortcutControllerInstance.GetPinnedApps();
+ AppList = TVHomeImpl.GetInstance.AppShortcutControllerInstance.GetPinnedAppsWithDefaultShortcuts();
OnPropertyChanged("AppList");
}