*/
using System;
-using System.Collections.Generic;
using System.Xml.Serialization;
-
namespace LibTVRefCommonPortable.DataModels
{
public class AppShortcutInfo : ShortcutInfo
}
[XmlIgnore]
+ private bool isFocused { get; set; }
+
+ [XmlIgnore]
+ public bool IsFocused
+ {
+ get
+ {
+ return isFocused;
+ }
+
+ set
+ {
+ if (isFocused != value)
+ {
+ isFocused = value;
+ OnPropertyChanged("IsFocused");
+ }
+ }
+ }
+
+ [XmlIgnore]
private bool isDim;
[XmlIgnore]
using LibTVRefCommonPortable.Utils;
using LibTVRefCommonTizen.Ports;
using Tizen.Applications;
+using System.Threading;
namespace TVApps.TizenTV
{
{
private static Program instance;
private IPlatformNotification notification;
+ private Timer timerForKeyGrab;
public static string AppResourcePath
{
get;
private set;
}
+ private void CallbackForKeyGrab(Object state)
+ {
+ MainWindow.KeyGrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName, true);
+ timerForKeyGrab.Dispose();
+ timerForKeyGrab = null;
+ DebuggingUtils.Dbg("KeyGrab finished");
+ }
protected override void OnCreate()
{
LoadApplication(app);
PackageManagerPort.RegisterCallbacks(notification);
+
+ MainWindow.KeyUp += KeyUpListener;
+
+ TimerCallback timerDelegate = new TimerCallback(CallbackForKeyGrab);
+ timerForKeyGrab = new Timer(timerDelegate, MainWindow, 3000, 0);
+ }
+
+ private void KeyUpListener(object sender, ElmSharp.EvasKeyEventArgs e)
+ {
+ DebuggingUtils.Dbg("[TVApps.TizenTV.cs] Key Pressed :" + e.KeyName);
+ if (e.KeyName.CompareTo(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName) == 0)
+ {
+ if (notification != null)
+ {
+ notification.OnMenuKeyPressed();
+ }
+ }
}
protected override void OnTerminate()
notification = null;
PackageManagerPort.DeregisterCallbacks();
MainWindow.KeyUngrab(ElmSharp.EvasKeyEventArgs.PlatformBackButtonName);
+ MainWindow.KeyUngrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName);
+
}
protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
<Button Grid.Row="1" Text="DELETE" />
</Grid>
- <!-- This BoxView is temporary code for Long Press test -->
+ <!-- TODO: This BoxView is temporary code for Long Press test -->
<BoxView x:Name="ItemDim"
Color="Black"
Opacity="0.0"
set { SetValue(IsDimProperty, value); }
}
+ public static readonly BindableProperty IsFocusedProperty = BindableProperty.Create("IsFocused", typeof(bool), typeof(AppItemCell), default(bool), BindingMode.TwoWay);
+ public bool IsFocused
+ {
+ get { return (bool)GetValue(IsFocusedProperty); }
+ set { SetValue(IsFocusedProperty, value); }
+ }
+
public AppItemCell()
{
InitializeComponent();
}
else if (e.PropertyName.CompareTo("IsShowOptions") == 0)
{
-
- // Set the icon status to default
- ButtonImage.ScaleTo(1.0, 50);
- ButtonImage.TranslateTo(0.0, 0.0, 100);
- TextArea.TranslateTo(0.0, 0.0, 50);
+ changeDefaultIconSize();
if (IsShowOptions)
{
}
}
+ public void changeDefaultIconSize()
+ {
+ ButtonImage.ScaleTo(1.0, 50);
+ ButtonImage.TranslateTo(0.0, 0.0, 100);
+ TextArea.TranslateTo(0.0, 0.0, 50);
+ }
+
+ public void ShowOptionMenu()
+ {
+ changeDefaultIconSize();
+
+ ButtonImage.TranslateTo(0, -90, 100);
+ TextArea.TranslateTo(0, -90, 100);
+ TextArea.FadeTo(0.0, 100);
+ OptionMenuArea.TranslateTo(0, -144, 100);
+ }
+
+ public void HideOptionMenu()
+ {
+ changeDefaultIconSize();
+
+ ButtonImage.TranslateTo(0, 0, 100);
+ TextArea.TranslateTo(0, 0, 100);
+ TextArea.FadeTo(0.99, 100);
+ OptionMenuArea.TranslateTo(0, 0, 100);
+ }
+
private void ButtonTitle_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "Width")
private void OnFocused(object sender, EventArgs e)
{
+ IsFocused = true;
+ OnPropertyChanged("IsFocused");
+
OnFocusedCommand?.Execute("");
ButtonImage.ScaleTo(1.32, 300);
ButtonImage.TranslateTo(0.0, 2.0, 300);
private void OnUnFocused(object sender, EventArgs e)
{
+ IsFocused = false;
+ OnPropertyChanged("IsFocused");
+
ButtonImage.ScaleTo(1.0, 300);
ButtonImage.TranslateTo(0.0, 0.0, 300);
TextArea.TranslateTo(0.0, 0.0, 300);
}
private int AppCount;
+ private ViewCell FocusedItem;
+
+ public ViewCell GetFocusedItem()
+ {
+ return FocusedItem;
+ }
public bool IsFirstItemFocused
{
return true;
}
- return AppUpperList.Children[0].IsFocused;
+ return AppUpperList.Children[0].FindByName<Button>("ButtonFocusArea").IsFocused;
}
}
-
public AppListView()
{
InitializeComponent();
viewCell.SetBinding(AppItemCell.IsCheckedProperty, new Binding("BindingContext.IsChecked", source: viewCell.View));
viewCell.SetBinding(AppItemCell.IsShowOptionsProperty, new Binding("BindingContext.IsShowOptions", source: viewCell.View));
viewCell.SetBinding(AppItemCell.IsDimProperty, new Binding("BindingContext.IsDim", source: viewCell.View));
+ viewCell.SetBinding(AppItemCell.IsFocusedProperty, new Binding("BindingContext.IsFocused", mode: BindingMode.TwoWay, source: viewCell.View));
viewCell.OnClickedCommand = new Command(() =>
{
var index = AppCount / 2;
viewCell.OnFocusedCommand = new Command(() =>
{
+ FocusedItem = viewCell;
ScrollToIndex(index);
});
if (AppCount % 2 == 0)
public class App : Application, IPlatformNotification
{
+ private static EventHandler<TVAppsEventArgs> MenuKeyListener;
private static EventHandler<TVAppsEventArgs> AppInstalledListener;
private static EventHandler<TVAppsEventArgs> AppUninstalledListener;
private static EventHandler<TVAppsEventArgs> PinAppRequestListener;
}
+ public static void SetMenuKeyListener(EventHandler<TVAppsEventArgs> listener)
+ {
+ MenuKeyListener += listener;
+ }
+
public static void SetAppInstalledListener(EventHandler<TVAppsEventArgs> listener)
{
AppInstalledListener += listener;
public void OnMenuKeyPressed()
{
+ DebuggingUtils.Dbg("[APPS] Menu Key is pressed");
+ MenuKeyListener.Invoke(this, new TVAppsEventArgs()
+ {
+ arg = "",
+ });
}
+
}
}
item.IsChecked = item.IsPinned;
break;
case AppsStatus.LongPress:
- item.IsDim = true;
+ if (item.IsFocused)
+ {
+ item.IsShowOptions = true;
+ }
+ else
+ {
+ item.IsDim = true;
+ }
break;
case AppsStatus.Delete:
item.IsChecked = false;
SetLongPressCommand = new Command((appId) =>
{
- DebuggingUtils.Dbg(" === Set LongPress AppID : " + appId);
-
- // 1. Change Apps status to LongPress
- // LongPress of AppsStatus will change ItemCell to be dimmed
ChangeCurrentStatus(AppsStatus.LongPress);
-
- // 2. The selected icon on apps list will be moved
- appsHolder.ShowLongPressOption(appId.ToString());
-
- // 3. The option menu will be shown
-
});
UnSetLongPressCommand = new Command((appId) =>
{
- DebuggingUtils.Dbg(" === Unset LongPress AppID : " + appId);
-
- // 1. change Apps status to Default
- // Default of AppsStatus will change ItemCell to be normal
- // 2. The option menu will be hidden
ChangeCurrentStatus(AppsStatus.Default);
-
- // 3. The selected icon will be moved
- //appsHolder.HideLongPressOption(appId.ToString());
-
});
<ColumnDefinition Width="50*" />
</Grid.ColumnDefinitions>
- <!-- This StackLayout is temporary code for Long Press test -->
+ <!-- TODO: This StackLayout is temporary code for Long Press test -->
<Button Grid.Row="0" Grid.Column="1"
Style="{StaticResource button}"
Command="{Binding SetLongPressCommand}"
<Button Grid.Row="2" Grid.Column="1"
Style="{StaticResource button}"
Command="{Binding UnSetLongPressCommand}"
- CommandParameter="org.tizen.example.TVHome.TizenTV"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"/>
using LibTVRefCommonPortable.Utils;
using System.Threading;
using System.Threading.Tasks;
+using TVApps.Controls;
namespace TVApps.Views
{
InitializeComponent();
PropertyChanged += MainPage_PropertyChanged;
SetCurrntStatus(AppsStatus.Default);
+
+ // TODO: This code is temporary for menu option test
+ App.SetMenuKeyListener((e, arg) =>
+ {
+ DebuggingUtils.Dbg("[Apps] Menu key is pressed");
+
+ if (CurrentStatus != AppsStatus.LongPress)
+ {
+ MessagingCenter.Send<MainPage, string>(this, "ChangeCurrentStatus", AppsStatus.LongPress.ToString());
+ }
+ });
}
private void SetCurrntStatus(AppsStatus status)
FooterPin.IsVisible = false;
FooterDelete.IsVisible = false;
BackKeyInfo.Text = "Quit";
+ AppList.InitializeFocus();
break;
case AppsStatus.Pin:
FooterNormal.IsVisible = false;
BackKeyInfo.Text = "Back";
break;
}
-
- AppList.InitializeFocus();
}
private void MainPage_PropertyChanged(object sender, PropertyChangedEventArgs e)
}
}
- // TODO : remove this
- private static bool IsBackKeyPressed;
-
private async Task<bool> OnBackKeyPressedAtMain()
{
DebuggingUtils.Dbg("OnBackKeyPressedAtMain - first item focused? " + AppList.IsFirstItemFocused);
MessagingCenter.Send<MainPage, string>(this, "ChangeCurrentStatus", AppsStatus.Default.ToString());
}
- if (!AppList.IsFirstItemFocused &&
- IsBackKeyPressed == false)
+ if (!AppList.IsFirstItemFocused)
{
- IsBackKeyPressed = true;
DebuggingUtils.Dbg("OnBackKeyPressedAtMain - focus move");
AppList.InitializeFocus();
return true;