*/
using System;
-using System.Threading.Tasks;
using Tizen.NUI;
using Tizen.NUI.WindowSystem.Shell;
/// </summary>
public sealed class SoftKeyClientService
{
- private const int MaxInitializeAttempts = 10;
- private const int IntitializeAttemptInterval = 3000;
-
private static SoftKeyClientService instance;
private TizenShell shell;
private SoftkeyClient client;
- private TaskCompletionSource<bool> initialized;
private SoftKeyClientService()
{
- initialized = new TaskCompletionSource<bool>();
- ScheduleInitialize();
+ Initialize();
}
/// <summary>
/// <summary>
/// Shows soft keys system-wide
/// </summary>
- public async Task Show()
+ public void Show()
{
- Tizen.Log.Warn("oobe", $"Show");
- bool initDone = await initialized.Task;
- if (initDone)
- {
- Tizen.Log.Warn("oobe", $"client.Show()");
- client.Opacity = SoftkeyOpacityState.Opaque;
- client.Show();
- }
+ Tizen.Log.Warn("oobe", $"client.Show()");
+ client.Opacity = SoftkeyOpacityState.Opaque;
+ client.Show();
}
/// <summary>
/// Hides soft keys system-wide
/// </summary>
- public async Task Hide()
+ public void Hide()
{
- Tizen.Log.Warn("oobe", $"Hide");
- bool initDone = await initialized.Task;
- if (initDone)
- {
- Tizen.Log.Warn("oobe", $"client.Hide()");
- client.Opacity = SoftkeyOpacityState.Transparent;
- client.Hide();
- }
+ Tizen.Log.Warn("oobe", $"client.Hide()");
+ client.Opacity = SoftkeyOpacityState.Transparent;
+ client.Hide();
}
private void Initialize()
{
shell = new TizenShell();
client = new SoftkeyClient(shell, Window.Instance);
- initialized.SetResult(true);
- }
-
- private void ScheduleInitialize()
- {
- int attempt = 0;
- Tizen.Log.Warn("oobe", $"ScheduleInitialize");
-
- Timer timer = new Timer(IntitializeAttemptInterval);
- timer.Tick += (sender, args) =>
- {
- attempt++;
-
- if (attempt > MaxInitializeAttempts)
- {
- Tizen.Log.Error("oobe", $"Max initialize attempts reached");
- initialized.SetResult(false);
- return false;
- }
-
- try
- {
- Tizen.Log.Warn("oobe", $"Attempt to intialize: {attempt}");
- Initialize();
- }
- catch (Exception e)
- {
- Tizen.Log.Warn("oobe", $"SoftKeyClientService.Initialize failed {e.Message}");
- return true;
- }
-
- return false;
- };
- timer.Start();
}
}
}