This commit includes these changes.
* Add new method for screen reader status checking
* Remove white space to match the indentation
* Remove invalid symbol from interop
* Add feature tag on doxygen for 'IsScreenReaderOn' property
* Fix log to make easy for specifying error
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported, /* STT NOT supported */
InvalidState = ErrorTts | 0x01, /* Invalid state */
InvalidVoice = ErrorTts | 0x02, /* Invalid language */
- EngineNotFound = ErrorTts | 0x03, /* No available engine */
- OperationFailed = ErrorTts | 0x04, /* Operation failed */
+ EngineNotFound = ErrorTts | 0x03, /* No available engine */
+ OperationFailed = ErrorTts | 0x04, /* Operation failed */
AudioPolicyBlocked = ErrorTts | 0x05, /* Audio policy blocked */
- NotSupportedFeature = ErrorTts | 0x06, /* Not supported feature of current engine*/
- ServiceReset = ErrorTts | 0x07 /* Service reset*/
+ NotSupportedFeature = ErrorTts | 0x06, /* Not supported feature of current engine */
+ ServiceReset = ErrorTts | 0x07, /* Service reset*/
+ ScreenReaderOff = ErrorTts | 0x08 /* Screen reader off */
};
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void TtsEngineChangedCB(IntPtr handle, IntPtr engine_id, IntPtr language, int voice_type, bool need_credential, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void TtsScreenReaderChangedCB(IntPtr handle, bool is_on, IntPtr userData);
+
[DllImport(Libraries.Tts, EntryPoint = "tts_create", CallingConvention = CallingConvention.Cdecl)]
internal static extern TtsError TtsCreate(out IntPtr handle);
[DllImport(Libraries.Tts, EntryPoint = "tts_get_error_message", CallingConvention = CallingConvention.Cdecl)]
internal static extern TtsError TtsGetErrorMessage(IntPtr handle, out string err_msg);
- [DllImport(Libraries.Tts, EntryPoint = "tts_is_recognition_type_supported", CallingConvention = CallingConvention.Cdecl)]
- internal static extern TtsError TtsIsRecognitionTypeSupported(IntPtr handle, string type, out bool support);
+ [DllImport(Libraries.Tts, EntryPoint = "tts_check_screen_reader_on", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern TtsError TtsCheckScreenReaderOn(IntPtr handle, out bool isOn);
[DllImport(Libraries.Tts, EntryPoint = "tts_add_text", CallingConvention = CallingConvention.Cdecl)]
internal static extern TtsError TtsAddText(IntPtr handle, string text, string language, int voice_type, int speed, out int uttId);
[DllImport(Libraries.Tts, EntryPoint = "tts_unset_engine_changed_cb", CallingConvention = CallingConvention.Cdecl)]
internal static extern TtsError TtsUnsetEngineChangedCB(IntPtr handle);
+
+ [DllImport(Libraries.Tts, EntryPoint = "tts_set_screen_reader_changed_cb", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern TtsError TtsSetScreenReaderChangedCB(IntPtr handle, TtsScreenReaderChangedCB callback, IntPtr userData);
+
+ [DllImport(Libraries.Tts, EntryPoint = "tts_unset_screen_reader_changed_cb", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern TtsError TtsUnsetScreenReaderChangedCB(IntPtr handle);
}
}
--- /dev/null
+/*
+* Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+namespace Tizen.Uix.Tts
+{
+ /// <summary>
+ /// This class holds information related to the ScreenReaderChanged event.
+ /// </summary>
+ /// <since_tizen> 9 </since_tizen>
+ public class ScreenReaderChangedEventArgs
+ {
+ internal ScreenReaderChangedEventArgs(bool isOn)
+ {
+ IsOn = isOn;
+ }
+
+ /// <summary>
+ /// The status of screen reader
+ /// </summary>
+ /// <since_tizen> 9 </since_tizen>
+ public bool IsOn
+ {
+ get;
+ internal set;
+ }
+ }
+}
private event EventHandler<ErrorOccurredEventArgs> _errorOccurred;
private event EventHandler<DefaultVoiceChangedEventArgs> _defaultVoiceChanged;
private event EventHandler<EngineChangedEventArgs> _engineChanged;
+ private event EventHandler<ScreenReaderChangedEventArgs> _screenReaderChanged;
private bool disposedValue = false;
private readonly Object _stateChangedLock = new Object();
private readonly Object _utteranceStartedLock = new Object();
private readonly Object _errorOccurredLock = new Object();
private readonly Object _defaultVoiceChangedLock = new Object();
private readonly Object _engineChangedLock = new Object();
+ private readonly Object _screenReaderChangedLock = new Object();
private TtsStateChangedCB _stateDelegate;
private TtsUtteranceStartedCB _utteranceStartedResultDelegate;
private TtsUtteranceCompletedCB _utteranceCompletedResultDelegate;
private TtsErrorCB _errorDelegate;
private TtsDefaultVoiceChangedCB _voiceChangedDelegate;
private TtsEngineChangedCB _engineDelegate;
+ private TtsScreenReaderChangedCB _screenReaderDelegate;
private TtsSupportedVoiceCB _supportedvoiceDelegate;
/// <summary>
}
/// <summary>
+ /// Event to be invoked to detect screen reader status change.
+ /// </summary>
+ /// <since_tizen> 9 </since_tizen>
+ public event EventHandler<ScreenReaderChangedEventArgs> ScreenReaderChanged
+ {
+ add
+ {
+ lock (_screenReaderChangedLock)
+ {
+ if (_screenReaderChanged == null)
+ {
+ _screenReaderDelegate = (IntPtr handle, bool isOn, IntPtr userData) =>
+ {
+ ScreenReaderChangedEventArgs args = new ScreenReaderChangedEventArgs(isOn);
+ _screenReaderChanged?.Invoke(this, args);
+ };
+ TtsError error = TtsSetScreenReaderChangedCB(_handle, _screenReaderDelegate, IntPtr.Zero);
+ if (error != TtsError.None)
+ {
+ Log.Error(LogTag, "Add ScreenReaderChanged Failed with error " + error);
+ }
+ }
+ _screenReaderChanged += value;
+ }
+ }
+
+ remove
+ {
+ lock (_screenReaderChangedLock)
+ {
+ _screenReaderChanged -= value;
+ if (_screenReaderChanged == null)
+ {
+ TtsError error = TtsUnsetScreenReaderChangedCB(_handle);
+ if (error != TtsError.None)
+ {
+ Log.Error(LogTag, "Remove ScreenReaderChanged Failed with error " + error);
+ }
+ }
+ }
+ }
+ }
+
+ /// <summary>
/// Gets the default voice set by the user.
/// </summary>
/// <since_tizen> 3 </since_tizen>
}
/// <summary>
+ /// Gets the current status of screen reader.
+ /// </summary>
+ /// <since_tizen> 9 </since_tizen>
+ /// <value>
+ /// The current status of screen reader.
+ /// </value>
+ /// <returns>
+ /// Boolean value whether screen reader is on or off.
+ /// </returns>
+ /// <feature>
+ /// http://tizen.org/feature/speech.synthesis
+ /// </feature>
+ /// <exception cref="InvalidOperationException">This exception can be due to operation failed.</exception>
+ /// <exception cref="NotSupportedException">This exception can be due to TTS not supported.</exception>
+ public bool IsScreenReaderOn
+ {
+ get
+ {
+ bool isOn = true;
+ TtsError error = TtsCheckScreenReaderOn(_handle, out isOn);
+ if (error != TtsError.None)
+ {
+ Log.Error(LogTag, "Fail to check screen reader on with error " + error);
+ return false;
+ }
+
+ return isOn;
+ }
+ }
+
+ /// <summary>
/// Sets the application credential.
/// </summary>
/// <since_tizen> 3 </since_tizen>