--- /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.Threading.Tasks;
+using Xamarin.Forms.Platform.Tizen.Native;
+using Tizen;
+using Tizen.Applications;
+using TVApps.Utils;
+using TVApps.Models;
+
+namespace TVApps.TizenTV.Ports
+{
+ class ApplicationManagerPort : IApplicationManagerAPIs
+ {
+ public async Task<IEnumerable<AppItem>> GetAllInstalledApplication()
+ {
+ try
+ {
+ List<AppItem> appItemList = new List<AppItem>();
+ Task<IEnumerable<ApplicationInfo>> task = ApplicationManager.GetInstalledApplicationsAsync();
+ if (task == null)
+ {
+ DebuggingPort.D("GetInstalledApplication failed");
+ return null;
+ }
+
+ IEnumerable<ApplicationInfo> installedList = await task;
+
+ foreach (var appInfo in installedList)
+ {
+ DebuggingPort.D("-------------------------------------");
+ DebuggingPort.D("TRY" + appInfo.ToString());
+ if (appInfo.IsNoDisplay)
+ {
+ continue;
+ }
+
+ Package pkgInfo = PackageManager.GetPackage(appInfo.PackageId);
+ if (pkgInfo == null)
+ {
+ continue;
+ }
+
+ DebuggingPort.D("TRY" + pkgInfo.ToString());
+
+ if (pkgInfo.IsSystemPackage)
+ {
+ continue;
+ }
+
+ DebuggingPort.D("ADD" + appInfo.ToString());
+ AppItem item = new AppItem();
+ item.Title = appInfo.Label;
+ item.IconUrl = appInfo.IconPath;
+ item.IconColor = "#00000000";
+ appItemList.Add(item);
+ }
+
+ return appItemList;
+ }
+ catch (Exception exception)
+ {
+ DebuggingPort.E(exception.Message);
+ return null;
+ }
+ }
+
+ }
+}
\ No newline at end of file
--- /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 Xamarin.Forms.Platform.Tizen.Native;
+using Tizen;
+using TVApps.Utils;
+
+namespace TVApps.TizenTV
+{
+ /// <summary>
+ /// Platform dependent implementation for the Logging and the Popup displaying.
+ /// DebuggingPort is implementing IDebuggingAPIs which is defined in Calculator shared project.
+ /// </summary>
+ /// <remarks>
+ /// Please refer to Xamarin Dependency Service
+ /// https://developer.xamarin.com/guides/xamarin-forms/dependency-service/introduction/
+ /// </remarks>
+ class DebuggingPort : IDebuggingAPIs
+ {
+ /// <summary>
+ /// A TV Home Windows reference. This is used to display a Dialog</summary>
+ public static Xamarin.Forms.Platform.Tizen.Native.Window MainWindow
+ {
+ set;
+ get;
+ }
+
+ /// <summary>
+ /// A Logging Tag. </summary>
+ public static string TAG = "apps";
+
+ /// <summary>
+ /// A method displays a debugging log. </summary>
+ /// <param name="message"> A debugging message.</param>
+ public void Dbg(string message)
+ {
+ Log.Debug(TAG, message);
+ }
+
+ /// <summary>
+ /// A method displays a error log. </summary>
+ /// <param name="message"> A error message.</param>
+ public void Err(string message)
+ {
+ Log.Error(TAG, message);
+ }
+
+ /// <summary>
+ /// A method displays a dialog with a given message. </summary>
+ /// <param name="message"> A debugging message.</param>
+ public void Popup(string message)
+ {
+ if (MainWindow == null)
+ {
+ return;
+ }
+ //bool result = await Xamarin.Forms.Page.DisplayAlert("Calculator", message, "OK");
+
+ Dialog toast = new Dialog(MainWindow);
+ toast.Title = message;
+ toast.Timeout = 2.3;
+ toast.BackButtonPressed += (s, e) =>
+ {
+ toast.Dismiss();
+ };
+ toast.Show();
+ }
+
+ public static void D(string message)
+ {
+ Log.Debug(TAG, message);
+ }
+
+ public static void E(string message)
+ {
+ Log.Error(TAG, message);
+ }
+
+ }
+}
\ No newline at end of file
+++ /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 Tizen;
-using TVApps.Impl;
-
-namespace TVApps.TizenTV
-{
- public class SystemMessagingPort : ISystemMessaging
- {
- public static string TAG = "tvapps";
- public void Dbg(string message)
- {
- Log.Debug(TAG, message);
- }
-
- public void Err(string message)
- {
- Log.Error(TAG, message);
- }
-
- public void Toast(string message)
- {
- //Android.Widget.Toast.MakeText(Application.Context, message, ToastLength.Long).Show();
- }
- }
-}
using System;
using TVApps;
+using TVApps.TizenTV.Ports;
namespace TVApps.TizenTV
{
protected override void OnCreate()
{
base.OnCreate();
- Xamarin.Forms.DependencyService.Register<SystemMessagingPort>();
LoadApplication(new App());
}
static void Main(string[] args)
{
var app = new Program();
+ Xamarin.Forms.DependencyService.Register<DebuggingPort>();
+ Xamarin.Forms.DependencyService.Register<ApplicationManagerPort>();
Xamarin.Forms.Platform.Tizen.Forms.Init(app);
app.Run(args);
}
<None Include="shared\res\TVApps.TizenTV.png" />
</ItemGroup>
<ItemGroup>
- <Compile Include="SystemMessagingPort.cs" />
+ <Compile Include="ApplicationManagerPort.cs" />
+ <Compile Include="DebuggingPort.cs" />
<Compile Include="TVApps.TizenTV.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
x:Class="TVApps.Controls.AppItemCell">
<AbsoluteLayout Margin="13,13,13,13">
<Button x:Name="ItemBackgroundButton"
+ Opacity="0"
AbsoluteLayout.LayoutBounds="0,0,210,290"/>
<BoxView x:Name="ItemBackgroundBox"
AbsoluteLayout.LayoutBounds="0,0,210,290"
Source="{Binding IconUrl}"/>
<Label Grid.Row="1"
Grid.Column="0"
+ TextColor="#FFFFFF"
HorizontalTextAlignment="Center"
Text="{Binding Title}"
FontSize="40"/>
namespace TVApps.Controls
{
/// <summary>
+ /// hahaha
/// </summary>
public partial class AppItemCell : ViewCell
{
private void ItemButton_Focused(object sender, FocusEventArgs e)
{
- ItemBackgroundBox.Color = Color.Red;
+ ItemBackgroundBox.Color = Color.Blue;
}
private void ItemButton_Unfocused(object sender, FocusEventArgs e)
namespace TVApps.Controls
{
/// <summary>
+ /// hahaha
/// </summary>
public partial class AppListView : ScrollView
{
+++ /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.Impl
-{
- public interface ISystemMessaging
- {
- void Toast(string message);
- void Dbg(string message);
- void Err(string message);
- }
-}
+++ /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 Xamarin.Forms;
-
-namespace TVApps.Impl
-{
- public sealed class SystemMessaging
- {
- private static ISystemMessaging ism;
- private static readonly SystemMessaging instance = new SystemMessaging();
- public static SystemMessaging Instance
- {
- get { return instance; }
- }
-
- private class DefaultSM : ISystemMessaging
- {
- public void Dbg(string message)
- {
- }
-
- public void Err(string message)
- {
- }
-
- public void Toast(string message)
- {
- }
- }
-
- private SystemMessaging()
- {
- ism = DependencyService.Get<ISystemMessaging>();
- }
-
- public static void Dbg(string message)
- {
- ism.Dbg(message);
- }
-
- public static void Err(string message)
- {
- ism.Err(message);
- }
-
- public static void Toast(string message)
- {
- ism.Toast(message);
- }
- }
-}
<Compile Include="Controls\AppListView.xaml.cs">
<DependentUpon>AppListView.xaml</DependentUpon>
</Compile>
- <Compile Include="Impl\ISystemMessaging.cs" />
- <Compile Include="Impl\SystemMessaging.cs" />
<Compile Include="Models\AppItem.cs" />
<Compile Include="TVApps.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Utils\DebuggingUtils.cs" />
+ <Compile Include="Utils\IApplicationManagerAPIs.cs" />
+ <Compile Include="Utils\IDebuggingAPIs.cs" />
<Compile Include="ViewModels\AppsListViewModel.cs" />
<Compile Include="Views\MainPage.xaml.cs">
<DependentUpon>MainPage.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 Xamarin.Forms;
+
+namespace TVApps.Utils
+{
+ /// <summary>
+ /// A debugging utility class.
+ /// </summary>
+ public sealed class DebuggingUtils
+ {
+ private static IDebuggingAPIs ism;
+ private static readonly DebuggingUtils instance = new DebuggingUtils();
+
+ /// <summary>
+ /// A method provides instance of DebuggingUtils. </summary>
+ public static DebuggingUtils Instance
+ {
+ get { return instance; }
+ }
+
+ /// <summary>
+ /// Default implementation of IDebuggingAPIs interface .
+ /// This is required for the unit testing of the Calculator application. </summary>
+ private class DefaultSM : IDebuggingAPIs
+ {
+ public void Dbg(string message)
+ {
+ }
+
+ public void Err(string message)
+ {
+ }
+
+ public void Popup(string message)
+ {
+ }
+ }
+
+ /// <summary>
+ /// DebuggingUtils constructor which set interface instance. </summary>
+ private DebuggingUtils()
+ {
+ if (DependencyService.Get<IDebuggingAPIs>() != null)
+ {
+ ism = DependencyService.Get<IDebuggingAPIs>();
+ }
+ else
+ {
+ ism = new DefaultSM();
+ }
+ }
+
+ /// <summary>
+ /// A method displays a debugging message </summary>
+ /// <param name="message"> A list of command line arguments.</param>
+ public static void Dbg(string message)
+ {
+ ism.Dbg(message);
+ }
+
+ /// <summary>
+ /// A method displays a error message </summary>
+ /// <param name="message"> A list of command line arguments.</param>
+ public static void Err(string message)
+ {
+ ism.Err(message);
+ }
+
+ /// <summary>
+ /// A method displays a pop up message </summary>
+ /// <param name="message"> A list of command line arguments.</param>
+ public static void Popup(string message)
+ {
+ ism.Popup(message);
+ }
+ }
+}
--- /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.Collections.Generic;
+using System.Threading.Tasks;
+using TVApps.Models;
+
+namespace TVApps.Utils
+{
+ public interface IApplicationManagerAPIs
+ {
+ Task<IEnumerable<AppItem>> GetAllInstalledApplication();
+ }
+}
--- /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.Utils
+{
+ /// <summary>
+ /// A interface contains debugging methods which are using platform subsystems.
+ /// </summary>
+ /// <remarks>
+ /// Implementing this class should be occurred in platform project.
+ /// Also the implementation should be registered to the DependencyService in a app initialization.
+ /// Please refer to Xamarin Dependency Service
+ /// https://developer.xamarin.com/guides/xamarin-forms/dependency-service/introduction/
+ /// </remarks>
+ public interface IDebuggingAPIs
+ {
+ /// <summary>
+ /// A method displays a debugging log. </summary>
+ /// <param name="message"> A debugging message.</param>
+ void Popup(string message);
+
+ /// <summary>
+ /// A method displays a error log. </summary>
+ /// <param name="message"> A error message.</param>
+ void Dbg(string message);
+
+ /// <summary>
+ /// A method displays a dialog with a given message. </summary>
+ /// <param name="message"> A debugging message.</param>
+ void Err(string message);
+ }
+}
* limitations under the License.
*/
+using System.Collections;
+using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
-
+using System.Threading.Tasks;
using TVApps.Models;
+using TVApps.Utils;
+using Xamarin.Forms;
namespace TVApps.ViewModels
{
public AppsListViewModel()
{
AppItems = new ObservableCollection<AppItem>();
+
+ GetInstalledApps();
+ }
+
+ private async void GetInstalledApps()
+ {
+ IApplicationManagerAPIs applicationManagerPort = DependencyService.Get<IApplicationManagerAPIs>();
+
+ IEnumerable<AppItem> appList = await applicationManagerPort.GetAllInstalledApplication();
+ foreach (var item in appList)
+ {
+ AppItems.Add(item);
+ DebuggingUtils.Dbg("ADD " + item.Title + ", " + item.IconUrl);
+ }
}
public void AddItem()
namespace TVApps.Views
{
+ /// <summary>
+ /// hahaha
+ /// </summary>
public partial class MainPage : ContentPage
{
- /// <summary>
- /// </summary>
public MainPage()
{
InitializeComponent();
<Project>{7e341bf5-b7bd-4532-9d4a-aa89537b525e}</Project>\r
<Name>TVApps.TizenTV</Name>\r
</ProjectReference>\r
+ <ProjectReference Include="..\..\TVApps\TVApps\TVApps.csproj">\r
+ <Project>{fd8c0ef4-6cea-4421-85b7-7ac8592738c6}</Project>\r
+ <Name>TVApps</Name>\r
+ </ProjectReference>\r
<ProjectReference Include="..\TVHome\TVHome.csproj">\r
<Project>{54dd6673-7e64-48e6-a008-4d455e19e017}</Project>\r
<Name>TVHome</Name>\r
exec="TVApps.TizenTV.exe"\r
type="dotnet"\r
multiple="false"\r
- taskmanage="true"\r
- nodisplay="false"\r
+ taskmanage="false"\r
+ nodisplay="true"\r
launch_mode="single">\r
<icon>TVApps.TizenTV.png</icon>\r
<label>Apps</label>\r
/// </summary>
public partial class MainPanelButton : PanelButton
{
- public BindableProperty OnFocusedCommandProperty = BindableProperty.Create("OnFocusedCommand", typeof(ICommand), typeof(MainPanelButton));
-
- public ICommand OnFocusedCommand
- {
- get { return (ICommand)GetValue(OnFocusedCommandProperty); }
- set { SetValue(OnFocusedCommandProperty, value); }
- }
-
- public BindableProperty OnClickedCommandProperty = BindableProperty.Create("OnClickedCommand", typeof(ICommand), typeof(MainPanelButton));
-
- public ICommand OnClickedCommand
- {
- get { return (ICommand)GetValue(OnClickedCommandProperty); }
- set { SetValue(OnClickedCommandProperty, value); }
- }
-
public MainPanelButton()
{
InitializeComponent();
ButtonImage.Source = "ic_tizen_home_menu_settings_focused.png";
}
+#pragma warning disable CS4014
ButtonTitle.FadeTo(0.8, 300);
ButtonBgImage.FadeTo(0.99, 300);
ButtonBgImage.ScaleTo(1.0, 300);
+#pragma warning restore CS4014
await View.FadeTo(0.6, 300);
}
ButtonImage.Source = "ic_tizen_home_menu_settings_normal.png";
}
+#pragma warning disable CS4014
ButtonTitle.FadeTo(0, 300);
ButtonBgImage.FadeTo(0, 300);
ButtonBgImage.ScaleTo(0.01, 300);
+#pragma warning restore CS4014
await View.FadeTo(0.3, 300);
}
OnFocusedCommand.Execute("");\r
}\r
\r
+#pragma warning disable CS4014\r
ButtonTitle.FadeTo(0.8, 300);\r
+ ButtonTitle.FadeTo(0.99, 300);\r
+#pragma warning restore CS4014\r
await View.FadeTo(0.6, 300);\r
}\r
\r
public override async void OnUnfocused(object sender, FocusEventArgs e)\r
{\r
+#pragma warning disable CS4014\r
ButtonTitle.FadeTo(0, 300);\r
+#pragma warning restore CS4014\r
await View.FadeTo(0.3, 300);\r
}\r
}\r
//Animation.Add(0, 1, titleAnimation);
//Animation.Commit(ThumbnailTitle, "FocusedAnimation", 16, 300);
+#pragma warning disable CS4014
ThumbnailTitle.FadeTo(0.99, 300);
+#pragma warning restore CS4014
await View.FadeTo(0.6, 300);
}
//Animation.Add(0, 1, titleAnimation);
//Animation.Commit(ThumbnailTitle, "UnfocusedAnimation", 16, 300);
+#pragma warning disable CS4014
ThumbnailTitle.FadeTo(0, 300);
+#pragma warning restore CS4014
await View.FadeTo(0.3, 300);
}
}
item.IsEnabled = false;\r
}\r
\r
+#pragma warning disable CS4014\r
PanelScrollView.ScrollToAsync(0, 0, true);\r
this.TranslateTo(0, 1, 0);\r
+#pragma warning restore CS4014\r
await this.FadeTo(0, 0);\r
}\r
\r
item.IsEnabled = true;\r
}\r
\r
+#pragma warning disable CS4014\r
this.TranslateTo(0, 0, 0);\r
+#pragma warning restore CS4014\r
await this.FadeTo(0.3, 0);\r
}\r
\r
var button = PanelButtonStack.Children[1] as RelativeLayout;\r
button.FindByName<Button>("ButtonFocusArea").Focus();\r
\r
+#pragma warning disable CS4014\r
this.TranslateTo(0, -140, 300);\r
+#pragma warning restore CS4014\r
await this.FadeTo(0.99, 300);\r
}\r
}\r