+++ /dev/null
-using System;
-using Tizen.NUI;
-
-namespace Fitness.Services
-{
- /// <summary>
- /// Manages screen activity.
- /// </summary>
- public class ScreenActivityService : IDisposable
- {
- private const uint ActivityInterval = 3000;
- private readonly Window win = NUIApplication.GetDefaultWindow();
- private readonly Timer activityTimer;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ScreenActivityService"/> class.
- /// </summary>
- public ScreenActivityService()
- {
- activityTimer = new Timer(ActivityInterval);
- activityTimer.Tick += ActivatyTimer_Tick;
- win.TouchEvent += Win_TouchEvent;
- }
-
- /// <summary>
- /// Raised when the screen is touched.
- /// </summary>
- public event EventHandler ScreenActivated;
-
- /// <summary>
- /// Raised when the screen is deactivated.
- /// </summary>
- public event EventHandler ScreenDeactivated;
-
- /// <summary>
- /// Starts the screen activity timer.
- /// </summary>
- public void StartTimer()
- {
- activityTimer.Start();
- }
-
- /// <summary>
- /// Stops the screen activity timer.
- /// </summary>
- public void StopTimer()
- {
- activityTimer.Stop();
- }
-
- /// <summary>
- /// Disposes activity timer.
- /// </summary>
- public void Dispose()
- {
- activityTimer?.Dispose();
- }
-
- private void Win_TouchEvent(object sender, Window.TouchEventArgs e)
- {
- if (e.Touch.GetState(0) == PointStateType.Down)
- {
- ScreenActivated?.Invoke(this, EventArgs.Empty);
- }
- }
-
- private bool ActivatyTimer_Tick(object source, Timer.TickEventArgs e)
- {
- ScreenDeactivated?.Invoke(this, EventArgs.Empty);
- return false;
- }
- }
-}
--- /dev/null
+using System;
+using Tizen.NUI;
+
+namespace Fitness.Services
+{
+ /// <summary>
+ /// Manages user interaction with the screen.
+ /// </summary>
+ public class ScreenInteractionService : IDisposable
+ {
+ private const uint ActivityInterval = 3000;
+ private readonly Window win = NUIApplication.GetDefaultWindow();
+ private readonly Timer activityTimer;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ScreenInteractionService"/> class.
+ /// </summary>
+ public ScreenInteractionService()
+ {
+ activityTimer = new Timer(ActivityInterval);
+ activityTimer.Tick += ActivatyTimer_Tick;
+ win.TouchEvent += Win_TouchEvent;
+ }
+
+ /// <summary>
+ /// Raised when the screen state has changed.
+ /// </summary>
+ public event EventHandler<ScreenInteractionState> ScreenInteractionStateChanged;
+
+ /// <summary>
+ /// Starts the screen activity timer.
+ /// </summary>
+ public void StartTimer()
+ {
+ activityTimer.Start();
+ }
+
+ /// <summary>
+ /// Stops the screen activity timer.
+ /// </summary>
+ public void StopTimer()
+ {
+ activityTimer.Stop();
+ }
+
+ /// <summary>
+ /// Disposes activity timer.
+ /// </summary>
+ public void Dispose()
+ {
+ activityTimer?.Dispose();
+ }
+
+ private void Win_TouchEvent(object sender, Window.TouchEventArgs e)
+ {
+ if (e.Touch.GetState(0) == PointStateType.Down)
+ {
+ ScreenInteractionStateChanged.Invoke(this, ScreenInteractionState.Activated);
+ }
+ }
+
+ private bool ActivatyTimer_Tick(object source, Timer.TickEventArgs e)
+ {
+ ScreenInteractionStateChanged.Invoke(this, ScreenInteractionState.Deactivated);
+ return false;
+ }
+ }
+}
--- /dev/null
+namespace Fitness.Services
+{
+ /// <summary>
+ /// State of screen interaction.
+ /// </summary>
+ public enum ScreenInteractionState
+ {
+ /// <summary>
+ /// Screen interaction activated.
+ /// </summary>
+ Activated,
+
+ /// <summary>
+ /// Screen interaction deactivated.
+ /// </summary>
+ Deactivated,
+ }
+}
private int repetitions;
private Landmark[,] poseLandmarks;
private bool isSummaryVisible;
+ private bool isUserInterfaceVisible = true;
private ICommand summaryBackCommand;
private ICommand summaryOkCommand;
private string summaryTitle;
}
}
+ /// <summary>
+ /// Gets a value indicating whether the summary pop-up is visible.
+ /// </summary>
+ public bool IsUserInterfaceVisible
+ {
+ get => isUserInterfaceVisible;
+ set
+ {
+ if (value != isUserInterfaceVisible)
+ {
+ isUserInterfaceVisible = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
/// <summary>
/// Gets PauseWorkout Command.
/// </summary>
private const int TransitionTime = 500;
private const string UnhandledWorkoutStateMessage = "Unhandled workout state.";
- private ScreenActivityService screenActivityService;
+ private const string UnhandledScreenInteractionStateMessage = "Unhandled screen interaction state.";
+ private ScreenInteractionService screenActivityService;
private CancellationTokenSource source;
private bool isInitialized = false;
private (Coordinates Preview, Coordinates Camera) playing;
cameraView.StopPreview();
}
- screenActivityService.ScreenActivated -= OnScreenActivated;
- screenActivityService.ScreenDeactivated -= OnScreenDeactivated;
+ screenActivityService.ScreenInteractionStateChanged -= OnScreenInteractionStateChanged;
}
/// <summary>
cameraView.Preview += DetectPreview;
}
- screenActivityService.ScreenActivated += OnScreenActivated;
- screenActivityService.ScreenDeactivated += OnScreenDeactivated;
+ screenActivityService.ScreenInteractionStateChanged += OnScreenInteractionStateChanged;
}
private static void OnWorkoutStateChanged(BindableObject bindable, object oldValue, object newValue)
PlayingView.PreviewStub.Relayout += OnPlayingViewRelayout;
cameraView.Preview += DetectPreview;
- screenActivityService = new ScreenActivityService();
+ screenActivityService = new ScreenInteractionService();
}
private void ExecuteNewState(WorkoutState newState, WorkoutState oldState)
case WorkoutState.Playing:
_ = ExecutePlayingState(oldState);
- OnScreenActivated();
+ ShowUserInterface();
break;
case WorkoutState.OnHold:
}
}
- private void OnScreenActivated(object sender, System.EventArgs e)
+ private void OnScreenInteractionStateChanged(object sender, ScreenInteractionState screenInteractionState)
{
- OnScreenActivated();
+ switch (screenInteractionState)
+ {
+ case ScreenInteractionState.Activated:
+ ShowUserInterface();
+ break;
+
+ case ScreenInteractionState.Deactivated:
+ HideUserInterface();
+ break;
+
+ default:
+ Services.Logger.Warn(UnhandledScreenInteractionStateMessage);
+ break;
+ }
}
- private void OnScreenActivated()
+ private void HideUserInterface()
{
- UpperBar.Show();
- PlayingView.BottomBar.Show();
- screenActivityService.StartTimer();
+ if (BindingContext is ExercisingViewModel viewModel)
+ {
+ viewModel.IsUserInterfaceVisible = false;
+ }
}
- private void OnScreenDeactivated(object sender, System.EventArgs e)
+ private void ShowUserInterface()
{
- UpperBar.Hide();
- PlayingView.BottomBar.Hide();
+ if (BindingContext is ExercisingViewModel viewModel)
+ {
+ viewModel.IsUserInterfaceVisible = true;
+ }
+ screenActivityService.StartTimer();
}
private void OnPlayingViewRelayout(object sender, System.EventArgs e)
<!--Layer-->
- <views:BarView x:Name="UpperBar"
- BindingContext="{Binding Source={x:Reference Root}, Path=BindingContext}"
+ <views:BarView BindingContext="{Binding Source={x:Reference Root}, Path=BindingContext}"
PrevCommand="{Binding PreviousWorkout}"
NextCommand="{Binding NextWorkout}"
- Title="{Binding CurrentWorkout.Title}"/>
+ Title="{Binding CurrentWorkout.Title}"
+ behaviors:VisibilitySetter.IsVisible="{Binding IsUserInterfaceVisible}"/>
<views:LoadingView x:Name="LoadingView"/>
Weight="1"/>
<!--Bar-->
- <View x:Name="BottomBar"
- Size="{views:SizeInUnits Height=30}"
- WidthSpecification="{Static LayoutParamPolicies.MatchParent}">
+ <View Size="{views:SizeInUnits Height=30}"
+ WidthSpecification="{Static LayoutParamPolicies.MatchParent}"
+ behaviors:VisibilitySetter.IsVisible="{Binding IsUserInterfaceVisible}">
<ctrl:NinePatchButton BindingContext="{Binding Source={x:Reference Root}, Path=BindingContext}"
PositionUsesPivotPoint="True"
ParentOrigin="Center"