<!-- This BoxView is temporary code for Long Press test -->
<BoxView x:Name="ItemDim"
Color="Black"
- Opacity="0.5"
- IsVisible="{Binding IsDim}"
+ Opacity="0.0"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}" />
using LibTVRefCommonPortable.Utils;
using System;
using System.ComponentModel;
+using System.Threading.Tasks;
using System.Windows.Input;
using Xamarin.Forms;
set { SetValue(IsShowOptionsProperty, value); }
}
+ public static readonly BindableProperty IsDimProperty = BindableProperty.Create("IsDim", typeof(bool), typeof(AppItemCell), default(bool));
+ public bool IsDim
+ {
+ get { return (bool)GetValue(IsDimProperty); }
+ set { SetValue(IsDimProperty, 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, 50);
+ TextArea.TranslateTo(0.0, 0.0, 50);
+
if (IsShowOptions)
{
ButtonImage.TranslateTo(0, -50, 100);
TextArea.FadeTo(0.99, 100);
}
}
+ else if (e.PropertyName.CompareTo("IsDim") == 0)
+ {
+ if (IsDim)
+ {
+ ItemDim.FadeTo(0.5, 100);
+ }
+ else
+ {
+ ItemDim.FadeTo(0.0, 100);
+ }
+ }
}
private void ButtonTitle_PropertyChanged(object sender, PropertyChangedEventArgs e)
viewCell.SetBinding(AppItemCell.IsPinnedProperty, new Binding("BindingContext.IsPinned", source: viewCell.View));
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.OnClickedCommand = new Command(() =>
+
{
item.DoAction();
});
item.CurrentStateDescription = item.StateDescriptions[tag];
switch (status)
{
+ case AppsStatus.Default:
+ item.SetChecked(false);
+ item.SetDim(false);
+ break;
case AppsStatus.Pin:
item.SetChecked(item.IsPinned);
break;
-
- default:
+ case AppsStatus.LongPress:
+ item.SetDim(true);
+ break;
+ case AppsStatus.Delete:
item.SetChecked(false);
break;
}
}
}
- public void HideLongPressedApp(string appId)
- {
- InstalledApps = new List<AppShortcutInfo>(InstalledApps);
- AppShortcutInfo longPressedApp = InstalledApps.Find(app => app.AppID.Equals(appId));
- if (longPressedApp != null)
- {
- DebuggingUtils.Dbg("Hide the app icon : " + longPressedApp.AppID);
- longPressedApp.SetVisible(false);
- }
- }
-
- public void ShowLongPressedApp(string appId)
- {
- InstalledApps = new List<AppShortcutInfo>(InstalledApps);
- AppShortcutInfo longPressedApp = InstalledApps.Find(app => app.AppID.Equals(appId));
- if (longPressedApp != null)
- {
- DebuggingUtils.Dbg("Show the app icon : " + longPressedApp.AppID);
- longPressedApp.SetVisible(true);
- }
- }
-
- public void SetAppItemDim(string appId)
- {
- InstalledApps = new List<AppShortcutInfo>(InstalledApps);
- foreach (AppShortcutInfo app in InstalledApps)
- {
- if (!app.AppID.Equals(appId))
- {
- app.SetDim(true);
- }
- }
- }
-
- public void UnsetAppItemDim(string appId)
- {
- InstalledApps = new List<AppShortcutInfo>(InstalledApps);
- foreach (AppShortcutInfo app in InstalledApps)
- {
- if (!app.AppID.Equals(appId))
- {
- app.SetDim(false);
- }
- }
- }
-
public void ShowLongPressOption(string appId)
{
- InstalledApps = new List<AppShortcutInfo>(InstalledApps);
AppShortcutInfo longPressedApp = InstalledApps.Find(app => app.AppID.Equals(appId));
if (longPressedApp != null)
{
+ longPressedApp.SetDim(false);
longPressedApp.ShowOptions();
}
}
public void HideLongPressOption(string appId)
{
- InstalledApps = new List<AppShortcutInfo>(InstalledApps);
AppShortcutInfo longPressedApp = InstalledApps.Find(app => app.AppID.Equals(appId));
if (longPressedApp != null)
{
{
DebuggingUtils.Dbg(" === Set LongPress AppID : " + appId);
- // 1. ItemCell will be dimmed
- appsHolder.SetAppItemDim((string)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((string)appId);
+
// 3. The option menu will be shown
});
{
DebuggingUtils.Dbg(" === Unset LongPress AppID : " + appId);
- // 1. The option menu will be hidden
- // 2. The selected icon will be moved
+ // 1. change Apps status to Default
+ // Default of AppsStatus will change ItemCell to be normal
+ ChangeCurrentStatus(AppsStatus.Default);
+
+ // 2. The option menu will be hidden
+
+ // 3. The selected icon will be moved
appsHolder.HideLongPressOption((string)appId);
- // 3. ItemCell will be changed to normal
- appsHolder.UnsetAppItemDim((string)appId);
});