disappearedPage.UnregisterDefaultLabel();
//We can call disappearedPage.NotifyAccessibilityStatesChange
//To reduce accessibility events, we are using currently highlighted view instead
- View curHighlightedView = Accessibility.Accessibility.Instance.GetCurrentlyHighlightedView();
+ View curHighlightedView = Accessibility.Accessibility.GetCurrentlyHighlightedView();
if (curHighlightedView != null)
{
curHighlightedView.NotifyAccessibilityStatesChange(new AccessibilityStates(AccessibilityState.Visible, AccessibilityState.Showing), AccessibilityStatesNotifyMode.Single);
{
internal static partial class Accessibility
{
- [DllImport(NDalicPINVOKE.Lib, EntryPoint = "csharp_dali_accessibility_get_status")]
- [return: MarshalAs(UnmanagedType.U1)]
- public static extern bool GetStatus(HandleRef jarg1);
-
[DllImport(NDalicPINVOKE.Lib, EntryPoint = "csharp_dali_accessibility_say")]
[return: MarshalAs(UnmanagedType.U1)]
- public static extern bool Say(HandleRef jarg1, string jarg2, bool jarg3, IntPtr jarg4);
+ public static extern bool Say(string jarg1, bool jarg2, IntPtr jarg3);
[DllImport(NDalicPINVOKE.Lib, EntryPoint = "csharp_dali_accessibility_pause_resume")]
- public static extern void PauseResume(HandleRef jarg1, bool jarg2);
+ public static extern void PauseResume(bool jarg1);
[DllImport(NDalicPINVOKE.Lib, EntryPoint = "csharp_dali_accessibility_stop_reading")]
- public static extern void StopReading(HandleRef jarg1, bool jarg2);
+ public static extern void StopReading(bool jarg1);
[DllImport(NDalicPINVOKE.Lib, EntryPoint = "csharp_dali_accessibility_suppress_screen_reader")]
[return: MarshalAs(UnmanagedType.U1)]
- public static extern bool SuppressScreenReader(HandleRef jarg1, bool jarg2);
+ public static extern bool SuppressScreenReader(bool jarg1);
[DllImport(NDalicPINVOKE.Lib, EntryPoint = "csharp_dali_accessibility_BridgeEnableAutoInit")]
public static extern void BridgeEnableAutoInit();
[SuppressMessage("Microsoft.Design", "CA1724: Type names should not match namespaces")]
[SuppressMessage("Microsoft.Design", "CA1001:Types that own disposable fields should be disposable", Justification = "This is a singleton class and is not disposed")]
[EditorBrowsable(EditorBrowsableState.Never)]
- public class Accessibility
+ public static class Accessibility
{
- #region Constructor, Destructor, Dispose
- private Accessibility()
- {
- dummy = new View();
- dummy.Name = "dali-atspi-singleton";
- }
-
+ #region Constructor
+ [SuppressMessage("Microsoft.Performance", "CA1810: Initialize reference type static fields inline", Justification = "Need to call native code")]
static Accessibility()
{
enabledSignalHandler = () =>
Interop.Accessibility.RegisterEnabledDisabledSignalHandler(enabledSignalHandler, disabledSignalHandler);
}
-
- /// <summary>
- /// destructor. This is HiddenAPI. recommended not to use in public.
- /// </summary>
- ~Accessibility()
- {
- Interop.Accessibility.RegisterEnabledDisabledSignalHandler(null, null);
-
- Tizen.Log.Debug("NUI", $"Accessibility is destroyed\n");
- }
- #endregion Constructor, Destructor, Dispose
-
+ #endregion Constructor
#region Property
/// <summary>
- /// Instance for singleton
- /// </summary>
- // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static Accessibility Instance
- {
- get => accessibility;
- }
-
- /// <summary>
/// Flag to check whether the state of Accessibility is enabled or not.
/// </summary>
/// <remarks>
#endregion Property
-
#region Method
/// <summary>
- /// Get the current status
- /// </summary>
- /// <returns>Current enabled status</returns>
- // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
- [EditorBrowsable(EditorBrowsableState.Never)]
- static public bool GetStatus()
- {
- return true;
- }
-
- /// <summary>
/// Start to speak
/// </summary>
/// <param name="sentence">Content to be spoken</param>
/// <returns></returns>
// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
[EditorBrowsable(EditorBrowsableState.Never)]
- public bool Say(string sentence, bool discardable)
+ public static bool Say(string sentence, bool discardable)
{
- IntPtr callbackIntPtr = IntPtr.Zero;
- if (sayFinishedEventHandler != null)
- {
- callback = SayFinishedEventCallback;
- callbackIntPtr = Marshal.GetFunctionPointerForDelegate<Delegate>(callback);
- }
- bool ret = Interop.Accessibility.Say(View.getCPtr(dummy), sentence, discardable, callbackIntPtr);
+ bool ret = Interop.Accessibility.Say(sentence, discardable, Marshal.GetFunctionPointerForDelegate<Delegate>(callback));
+
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
/// <param name="pause">true to be paused, false to be resumed</param>
// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
[EditorBrowsable(EditorBrowsableState.Never)]
- public void PauseResume(bool pause)
+ public static void PauseResume(bool pause)
{
- Interop.Accessibility.PauseResume(View.getCPtr(dummy), pause);
+ Interop.Accessibility.PauseResume(pause);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
/// <param name="alsoNonDiscardable">whether to cancel non-discardable readings as well</param>
// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
[EditorBrowsable(EditorBrowsableState.Never)]
- public void StopReading(bool alsoNonDiscardable)
+ public static void StopReading(bool alsoNonDiscardable)
{
- Interop.Accessibility.StopReading(View.getCPtr(dummy), alsoNonDiscardable);
+ Interop.Accessibility.StopReading(alsoNonDiscardable);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
/// <param name="suppress">whether to suppress reading of screen-reader</param>
// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
[EditorBrowsable(EditorBrowsableState.Never)]
- public bool SuppressScreenReader(bool suppress)
+ public static bool SuppressScreenReader(bool suppress)
{
- bool ret = Interop.Accessibility.SuppressScreenReader(View.getCPtr(dummy), suppress);
+ bool ret = Interop.Accessibility.SuppressScreenReader(suppress);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
/// </summary>
// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
[EditorBrowsable(EditorBrowsableState.Never)]
- public View GetHighlightFrameView()
+ public static View GetHighlightFrameView()
{
var ptr = Interop.ControlDevel.DaliAccessibilityAccessibleGetHighlightActor();
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
/// </summary>
// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
[EditorBrowsable(EditorBrowsableState.Never)]
- public void SetHighlightFrameView(View view)
+ public static void SetHighlightFrameView(View view)
{
Interop.ControlDevel.DaliAccessibilityAccessibleSetHighlightActor(View.getCPtr(view));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
/// </summary>
// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
[EditorBrowsable(EditorBrowsableState.Never)]
- public View GetCurrentlyHighlightedView()
+ public static View GetCurrentlyHighlightedView()
{
var ptr = Interop.ControlDevel.DaliAccessibilityAccessibleGetCurrentlyHighlightedActor();
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return this.GetInstanceSafely<View>(ptr);
+ return dummyHandle.GetInstanceSafely<View>(ptr);
}
/// <summary>
/// </summary>
// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
[EditorBrowsable(EditorBrowsableState.Never)]
- public bool ClearCurrentlyHighlightedView()
+ public static bool ClearCurrentlyHighlightedView()
{
var view = GetCurrentlyHighlightedView();
/// </summary>
// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
[EditorBrowsable(EditorBrowsableState.Never)]
- public event EventHandler<SayFinishedEventArgs> SayFinished
- {
- add => sayFinishedEventHandler += value;
- remove => sayFinishedEventHandler -= value;
- }
+ public static event EventHandler<SayFinishedEventArgs> SayFinished;
/// <summary>
/// Triggered whenever the value of IsEnabled would change from false to true
#endregion Event, Enum, Struct, ETC
-
- #region Internal
- internal void PauseResume(View target, bool pause)
- {
- Interop.Accessibility.PauseResume(View.getCPtr(target), pause);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal bool Say(View target, string sentence, bool discardable)
- {
- IntPtr callbackIntPtr = IntPtr.Zero;
- if (sayFinishedEventHandler != null)
- {
- callback = SayFinishedEventCallback;
- callbackIntPtr = Marshal.GetFunctionPointerForDelegate<Delegate>(callback);
- }
- bool ret = Interop.Accessibility.Say(View.getCPtr(target), sentence, discardable, callbackIntPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
- #endregion Internal
-
-
#region Private
- private static readonly Accessibility accessibility = new Accessibility();
-
- private event EventHandler<SayFinishedEventArgs> sayFinishedEventHandler;
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate void SayFinishedEventCallbackType(int result);
- private SayFinishedEventCallbackType callback = null;
+ private static SayFinishedEventCallbackType callback = SayFinishedEventCallback;
private static Interop.Accessibility.EnabledDisabledSignalHandler enabledSignalHandler = null;
private static Interop.Accessibility.EnabledDisabledSignalHandler disabledSignalHandler = null;
- private void SayFinishedEventCallback(int result)
+ private static void SayFinishedEventCallback(int result)
{
NUILog.Debug($"sayFinishedEventCallback(res={result}) called!");
- sayFinishedEventHandler?.Invoke(this, new SayFinishedEventArgs(result));
+ SayFinished?.Invoke(typeof(Accessibility), new SayFinishedEventArgs(result));
}
- private View dummy;
+ private static BaseHandle dummyHandle = new BaseHandle();
#endregion Private
}
{
get
{
- return (this == Accessibility.Accessibility.Instance.GetCurrentlyHighlightedView());
+ return (this == Accessibility.Accessibility.GetCurrentlyHighlightedView());
}
}
//var accessbilityStatus = NDalicPINVOKE.accessibility_get_status(View.getCPtr(view));
if (e.Key.KeyPressedName == "Return")
{
- Accessibility.Instance.SayFinished -= Instance_SayFinished;
- Accessibility.Instance.Say("", true);
+ Accessibility.SayFinished -= Instance_SayFinished;
+ Accessibility.Say("", true);
repeatFlag = false;
}
else if (e.Key.KeyPressedName == "Right")
{
- Accessibility.Instance.Say(testScript1, true);
+ Accessibility.Say(testScript1, true);
}
else if (e.Key.KeyPressedName == "Left")
{
- Accessibility.Instance.Say(testScript2, true);
+ Accessibility.Say(testScript2, true);
}
else if (e.Key.KeyPressedName == "Up")
{
- Accessibility.Instance.Say(testScript3, true);
+ Accessibility.Say(testScript3, true);
}
else if (e.Key.KeyPressedName == "Down")
{
repeatFlag = true;
- Accessibility.Instance.SayFinished += Instance_SayFinished;
- Accessibility.Instance.Say("my name is say api !!!", true);
+ Accessibility.SayFinished += Instance_SayFinished;
+ Accessibility.Say("my name is say api !!!", true);
}
else if (e.Key.KeyPressedName == "1")
{
- Accessibility.Instance.PauseResume(true);
+ Accessibility.PauseResume(true);
}
else if (e.Key.KeyPressedName == "2")
{
- Accessibility.Instance.PauseResume(false);
+ Accessibility.PauseResume(false);
}
}
return false;
tlog.Fatal(tag, $"Instance_SayFinished()! State={e.State}");
if (e.State == Accessibility.SayFinishedState.Stopped)
{
- Accessibility.Instance.Say("ÀÌ°Ç Äݹé Å×½ºÆ® ÀÔ´Ï´Ù. this is callback test! ÄݹéÀ» »©·Á¸é È®ÀÎÅ°¸¦ ´©¸£¼¼¿ä. to remove callback please push Return key", true);
+ Accessibility.Say("ÀÌ°Ç Äݹé Å×½ºÆ® ÀÔ´Ï´Ù. this is callback test! ÄݹéÀ» »©·Á¸é È®ÀÎÅ°¸¦ ´©¸£¼¼¿ä. to remove callback please push Return key", true);
}
}
[Test]
[Category("P1")]
- [Description("Accessibility constructor.")]
- [Property("SPEC", "Tizen.NUI.Accessibility.Accessibility C")]
- [Property("SPEC_URL", "-")]
- [Property("CRITERIA", "CONSTR")]
- [Property("AUTHOR", "guowei.wang@samsung.com")]
- public void AccessibilityConstructor()
- {
- tlog.Debug(tag, $"AccessibilityConstructor START");
-
- var testingTarget = Accessibility.Accessibility.Instance; ;
- Assert.IsNotNull(testingTarget, "Can't create success object Accessibility");
- Assert.IsInstanceOf<Accessibility.Accessibility>(testingTarget, "Should be an instance of Accessibility type.");
-
- tlog.Debug(tag, $"AccessibilityConstructor END (OK)");
- }
-
- [Test]
- [Category("P1")]
[Description("Accessibility GetStatus.")]
[Property("SPEC", "Tizen.NUI.Accessibility.GetStatus M")]
[Property("SPEC_URL", "-")]
{
tlog.Debug(tag, $"AccessibilitySay START");
- var testingTarget = Accessibility.Accessibility.Instance; ;
- Assert.IsNotNull(testingTarget, "Can't create success object Accessibility");
- Assert.IsInstanceOf<Accessibility.Accessibility>(testingTarget, "Should be an instance of Accessibility type.");
-
- var result = testingTarget.Say("Hi,Bixby! Please help to order a sandwich.", true);
+ var result = Accessibility.Accessibility.Say("Hi,Bixby! Please help to order a sandwich.", true);
tlog.Debug(tag, "Status : " + result);
tlog.Debug(tag, $"AccessibilitySay END (OK)");
{
tlog.Debug(tag, $"AccessibilityPauseResume START");
- var testingTarget = Accessibility.Accessibility.Instance; ;
- Assert.IsNotNull(testingTarget, "Can't create success object Accessibility");
- Assert.IsInstanceOf<Accessibility.Accessibility>(testingTarget, "Should be an instance of Accessibility type.");
-
try
{
- testingTarget.PauseResume(true);
+ Accessibility.Accessibility.PauseResume(true);
}
catch (Exception e)
{
{
tlog.Debug(tag, $"AccessibilityStopReading START");
- var testingTarget = Accessibility.Accessibility.Instance; ;
- Assert.IsNotNull(testingTarget, "Can't create success object Accessibility");
- Assert.IsInstanceOf<Accessibility.Accessibility>(testingTarget, "Should be an instance of Accessibility type.");
-
try
{
- testingTarget.StopReading(true);
+ Accessibility.Accessibility.StopReading(true);
}
catch (Exception e)
{
{
tlog.Debug(tag, $"AccessibilitySuppressScreenReader START");
- var testingTarget = Accessibility.Accessibility.Instance; ;
- Assert.IsNotNull(testingTarget, "Can't create success object Accessibility");
- Assert.IsInstanceOf<Accessibility.Accessibility>(testingTarget, "Should be an instance of Accessibility type.");
-
try
{
- testingTarget.SuppressScreenReader(false);
+ Accessibility.Accessibility.SuppressScreenReader(false);
}
catch (Exception e)
{
{
tlog.Debug(tag, $"AccessibilitySetHighlightFrameView START");
- var testingTarget = Accessibility.Accessibility.Instance; ;
- Assert.IsNotNull(testingTarget, "Can't create success object Accessibility");
- Assert.IsInstanceOf<Accessibility.Accessibility>(testingTarget, "Should be an instance of Accessibility type.");
-
using (View view = new View())
{
view.Size = new Size(100, 50);
try
{
- testingTarget.SetHighlightFrameView(view);
+ Accessibility.Accessibility.SetHighlightFrameView(view);
- var result = testingTarget.GetHighlightFrameView();
+ var result = Accessibility.Accessibility.GetHighlightFrameView();
tlog.Debug(tag, "HighlightFrameView : " + result);
- tlog.Debug(tag, "ClearCurrentlyHighlightedView : " + testingTarget.ClearCurrentlyHighlightedView());
+ tlog.Debug(tag, "ClearCurrentlyHighlightedView : " + Accessibility.Accessibility.ClearCurrentlyHighlightedView());
}
catch (Exception e)
{
{
tlog.Debug(tag, $"AccessibilitySayFinished START");
- var testingTarget = Accessibility.Accessibility.Instance;
- Assert.IsNotNull(testingTarget, "Can't create success object Accessibility");
- Assert.IsInstanceOf<Accessibility.Accessibility>(testingTarget, "Should be an instance of Accessibility type.");
-
- testingTarget.SayFinished += OnSayFinished;
- testingTarget.SayFinished -= OnSayFinished;
+ Accessibility.Accessibility.SayFinished += OnSayFinished;
+ Accessibility.Accessibility.SayFinished -= OnSayFinished;
tlog.Debug(tag, $"AccessibilitySayFinished END (OK)");
}