2 * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Collections.Generic;
22 namespace Tizen.Applications.WatchfaceComplication
25 /// Represents the Complication class for the watch application which using watchface complication.
27 /// <since_tizen> 6 </since_tizen>
28 public abstract class Complication : IEditable, IDisposable
30 private int _complicationId;
31 private ComplicationTypes _supportTypes;
32 private string _defaultProviderId;
33 private ComplicationTypes _defaultType;
34 private EventTypes _supportEvents;
35 private Highlight _highlight;
36 internal IntPtr _handle;
37 private Interop.WatchfaceComplication.ComplicationUpdatedCallback _updatedCallback;
38 private Interop.WatchfaceComplication.ComplicationErrorCallback _errorCallback;
39 private IEnumerable<(string allowedProviderId, ComplicationTypes supportTypes)> _allowedList;
40 private int _editableId;
41 private bool _disposed = false;
44 /// Initializes the Complication class.
46 /// <param name="complicationId">The id of the complication.</param>
47 /// <param name="supportTypes">The complication support types.</param>
48 /// <param name="supportEvents">The complication's support events.</param>
49 /// <param name="defaultProviderId">The complication's default provider ID.</param>
50 /// <param name="defaultType">The complication's default type.</param>
51 /// <privilege>http://tizen.org/privilege/datasharing</privilege>
52 /// <privilege>http://tizen.org/privilege/packagemanager.info</privilege>
53 /// <exception cref="ArgumentException">Thrown when the invalid parameter is passed.</exception>
54 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
55 /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
56 /// <exception cref="UnauthorizedAccessException">Thrown when the application does not have privilege to access this method.</exception>
60 /// public class MyComplication : Complication
62 /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
63 /// ComplicationTypes defaultType)
64 /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
67 /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
71 /// _complication = new MyComplication(_complicationId, (int)(ComplicationTypes.ShortText | ComplicationTypes.Image),
72 /// (int) EventTypes.EventNone, _complicationProviderId, ComplicationTypes.ShortText, _complicationBtn);
76 /// <since_tizen> 6 </since_tizen>
77 protected Complication(int complicationId, ComplicationTypes supportTypes, EventTypes supportEvents, string defaultProviderId, ComplicationTypes defaultType)
79 _complicationId = complicationId;
80 _supportTypes = supportTypes;
81 _supportEvents = supportEvents;
82 _defaultProviderId = defaultProviderId;
83 _defaultType = defaultType;
85 ComplicationError ret = Interop.WatchfaceComplication.CreateComplication(complicationId, defaultProviderId, defaultType, (int)supportTypes, (int)supportEvents, out _handle);
86 if (ret != ComplicationError.None)
88 ErrorFactory.ThrowException(ret, "Fail to create complication");
90 _updatedCallback = new Interop.WatchfaceComplication.ComplicationUpdatedCallback(ComplicationUpdatedCallback);
91 _errorCallback = new Interop.WatchfaceComplication.ComplicationErrorCallback(ComplicationErrorCallback);
92 ret = Interop.WatchfaceComplication.AddUpdatedCallback(_handle, _updatedCallback, _errorCallback, IntPtr.Zero);
93 if (ret != ComplicationError.None)
96 ErrorFactory.ThrowException(ret, "Fail to add update callback");
101 /// Destructor of the complication class.
109 /// Gets the support types.
111 /// <since_tizen> 6 </since_tizen>
112 public ComplicationTypes SupportTypes
116 return _supportTypes;
121 /// Gets the support event types.
123 /// <since_tizen> 6 </since_tizen>
124 public EventTypes SupportEvents
128 return _supportEvents;
133 /// The information of the editable's highlight.
135 /// <since_tizen> 6 </since_tizen>
136 Highlight IEditable.Highlight
150 /// The information of specific allowed provider id, support types list for complication
152 /// <since_tizen> 6 </since_tizen>
153 public IEnumerable<(string allowedProviderId, ComplicationTypes supportTypes)> AllowedList
161 _allowedList = value;
162 if (_allowedList == null || _allowedList.Count() == 0)
164 Interop.WatchfaceComplication.ClearAllowedList(_handle);
169 Interop.WatchfaceComplication.CreateAllowedList(out listRaw);
170 List<(string allowedProviderId, ComplicationTypes supportTypes)> list = _allowedList.ToList();
171 foreach (var item in list)
173 Interop.WatchfaceComplication.AddAllowedList(listRaw, item.allowedProviderId, (int)item.supportTypes);
175 Interop.WatchfaceComplication.ApplyAllowedList(_handle, listRaw);
176 Interop.WatchfaceComplication.DestroyAllowedList(listRaw);
183 /// The information of the complication's highlight.
185 /// <since_tizen> 6 </since_tizen>
186 public Highlight Highlight
199 /// The information of complication ID.
201 /// <since_tizen> 6 </since_tizen>
202 public int ComplicationId
206 return _complicationId;
211 /// The information of editable ID.
213 /// <since_tizen> 6 </since_tizen>
214 int IEditable.EditableId
227 /// The information of editable name.
229 /// <since_tizen> 6 </since_tizen>
230 string IEditable.Name
234 string editableName = "";
235 Interop.WatchfaceComplication.GetEditableName(_handle, out editableName);
240 Interop.WatchfaceComplication.SetEditableName(_handle, value);
245 /// Gets the editable's current data index.
247 /// <returns>The index of current data</returns>
248 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
251 /// MyComplication comp = new MyComplication();
252 /// Bundle curData = comp.GetCurrentDataIndex();
255 /// <since_tizen> 6 </since_tizen>
256 int IEditable.GetCurrentDataIndex()
259 ComplicationError ret = Interop.WatchfaceComplication.GetCurrentIdx(_handle, out curIdx);
260 if (ret != ComplicationError.None)
262 ErrorFactory.ThrowException(ret, "Fail to get current idx");
268 /// Gets the editable's current data.
270 /// <returns>The current data</returns>
271 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
274 /// MyComplication comp = new MyComplication();
275 /// Bundle curData = comp.GetCurrentData();
278 /// <since_tizen> 6 </since_tizen>
279 Bundle IEditable.GetCurrentData()
281 SafeBundleHandle bundleHandle;
282 ComplicationError err = Interop.WatchfaceComplication.GetCurrentData(_handle, out bundleHandle);
283 if (err != ComplicationError.None)
284 ErrorFactory.ThrowException(err, "Can not get current data");
285 Bundle data = new Bundle(bundleHandle);
290 /// Gets the current provider ID.
292 /// <returns>The current provider ID</returns>
293 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
296 /// MyComplication comp = new MyComplication();
297 /// string providerId = comp.GetCurrentProviderId();
300 /// <since_tizen> 6 </since_tizen>
301 public string GetCurrentProviderId()
303 string providerId = "";
304 ComplicationError err = Interop.WatchfaceComplication.GetCurrentProviderId(_handle, out providerId);
305 if (err != ComplicationError.None)
306 ErrorFactory.ThrowException(err, "Can not get current provider id");
311 /// Gets the current complication type.
313 /// <returns>The current complication type</returns>
314 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
317 /// MyComplication comp = new MyComplication();
318 /// ComplicationTypes type = comp.GetCurrentType();
321 /// <since_tizen> 6 </since_tizen>
322 public ComplicationTypes GetCurrentType()
324 ComplicationTypes type;
325 ComplicationError err = Interop.WatchfaceComplication.GetCurrentType(_handle, out type);
326 if (err != ComplicationError.None)
327 ErrorFactory.ThrowException(err, "Can not get current provider type");
331 private void ComplicationUpdatedCallback(int complicationId,
332 string providerId, ComplicationTypes type, IntPtr data, IntPtr userData)
334 if (_complicationId == complicationId)
335 OnComplicationUpdated(providerId, type, new Bundle(new SafeBundleHandle(data, false)));
338 private void ComplicationErrorCallback(int complicationId,
339 string providerId, ComplicationTypes type, ComplicationError error, IntPtr userData)
341 if (_complicationId == complicationId)
342 OnComplicationError(providerId, type, error);
346 /// Sends the complication update requests.
348 /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
349 /// <privilege>http://tizen.org/privilege/datasharing</privilege>
350 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
351 /// <exception cref="UnauthorizedAccessException">Thrown when the application does not have privilege to access this method.</exception>
354 /// MyComplication comp = new MyComplication();
355 /// ComplicationError err = comp.SendUpdateRequest();
358 /// <since_tizen> 6 </since_tizen>
359 public void SendUpdateRequest()
361 ComplicationError ret = Interop.WatchfaceComplication.SendUpdateRequest(_handle);
362 if (ret != ComplicationError.None)
363 ErrorFactory.ThrowException(ret, "Fail to get send request");
367 /// Transfers event to the provider.
369 /// <param name="eventType">The complication event type.</param>
370 /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
371 /// <privilege>http://tizen.org/privilege/datasharing</privilege>
372 /// <exception cref="UnauthorizedAccessException">Thrown when the application does not have privilege to access this method.</exception>
373 /// <exception cref="ArgumentException">Thrown when the invalid argument is passed.</exception>
374 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
377 /// void OnButtonClicked()
379 /// comp.TransferEvent(EventTypes.EventTap);
383 /// <since_tizen> 6 </since_tizen>
384 public void TransferEvent(EventTypes eventType)
386 ComplicationError ret = Interop.WatchfaceComplication.TransferEvent(_handle, eventType);
387 if (ret != ComplicationError.None)
388 ErrorFactory.ThrowException(ret, "Fail to transfer event");
392 /// Gets the complication data type.
394 /// <param name="data">The data from OnComplicationUpdate callback.</param>
395 /// <returns>The complication type of data</returns>
396 /// <exception cref="ArgumentException">Thrown when the invalid argument is passed.</exception>
397 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
398 /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
401 /// ComplicationTypes type = Complication.GetType(dupData);
404 /// <since_tizen> 6 </since_tizen>
405 public static ComplicationTypes GetType(Bundle data)
407 ComplicationTypes type;
409 ComplicationError err = Interop.WatchfaceComplication.GetDataType(data.SafeBundleHandle, out type);
410 if (err != ComplicationError.None)
411 ErrorFactory.ThrowException(err, "fail to get data type");
416 /// Gets the short text.
418 /// <param name="data">The data from OnComplicationUpdate callback.</param>
419 /// <returns>The short text data</returns>
420 /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
421 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
422 /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
426 /// public class MyComplication : Complication
428 /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
429 /// ComplicationTypes defaultType)
430 /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
433 /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
435 /// if (type == ComplicationTypes.ShortText)
437 /// string shortText = Complication.GetShortText(data);
438 /// layout.Text = shortText;
445 /// <since_tizen> 6 </since_tizen>
446 public static string GetShortText(Bundle data)
450 ComplicationError err = Interop.WatchfaceComplication.GetShortText(data.SafeBundleHandle, out shortText);
451 if (err != ComplicationError.None)
452 ErrorFactory.ThrowException(err, "fail to get short text");
457 /// Gets the long text.
459 /// <param name="data">The data from OnComplicationUpdate callback.</param>
460 /// <returns>The long text data</returns>
461 /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
462 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
463 /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
467 /// public class MyComplication : Complication
469 /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
470 /// ComplicationTypes defaultType)
471 /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
474 /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
476 /// if (type == ComplicationTypes.LongText)
478 /// string longText = Complication.GetLongText(data);
479 /// layout.Text = longText;
486 /// <since_tizen> 6 </since_tizen>
487 public static string GetLongText(Bundle data)
491 ComplicationError err = Interop.WatchfaceComplication.GetLongText(data.SafeBundleHandle, out longText);
492 if (err != ComplicationError.None)
493 ErrorFactory.ThrowException(err, "fail to get long text");
500 /// <param name="data">The data from OnComplicationUpdate callback.</param>
501 /// <returns>The title data</returns>
502 /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
503 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
504 /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
508 /// public class MyComplication : Complication
510 /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
511 /// ComplicationTypes defaultType)
512 /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
515 /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
517 /// if (type == ComplicationTypes.ShortText)
519 /// string title = Complication.GetTitle(data);
520 /// layout.Text = title;
527 /// <since_tizen> 6 </since_tizen>
528 public static string GetTitle(Bundle data)
532 ComplicationError err = Interop.WatchfaceComplication.GetTitle(data.SafeBundleHandle, out title);
533 if (err != ComplicationError.None)
534 ErrorFactory.ThrowException(err, "fail to get title");
539 /// Gets the timestamp.
541 /// <returns>The timestamp data in long value</returns>
542 /// <param name="data">The data from OnComplicationUpdate callback.</param>
543 /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
544 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
545 /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
549 /// public class MyComplication : Complication
551 /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
552 /// ComplicationTypes defaultType)
553 /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
556 /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
558 /// if (type == ComplicationTypes.Time)
560 /// long time = Complication.GetTimestamp(data);
561 /// layout.Text = time;
568 /// <since_tizen> 6 </since_tizen>
569 public static long GetTimestamp(Bundle data)
573 ComplicationError err = Interop.WatchfaceComplication.GetTimestamp(data.SafeBundleHandle, out timestamp);
574 if (err != ComplicationError.None)
575 ErrorFactory.ThrowException(err, "fail to get timestamp");
580 /// Gets the image path.
582 /// <param name="data">The data from OnComplicationUpdate callback.</param>
583 /// <returns>The image path data</returns>
584 /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
585 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
586 /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
590 /// public class MyComplication : Complication
592 /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
593 /// ComplicationTypes defaultType)
594 /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
597 /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
599 /// if (type == ComplicationTypes.Image)
601 /// string imagePath = Complication.GetImagePath(data);
602 /// layout.Text = imagePath;
609 /// <since_tizen> 6 </since_tizen>
610 public static string GetImagePath(Bundle data)
614 ComplicationError err = Interop.WatchfaceComplication.GetImagePath(data.SafeBundleHandle, out imagePath);
615 if (err != ComplicationError.None)
616 ErrorFactory.ThrowException(err, "fail to get image path");
621 /// Gets the current value of ranged type data.
623 /// <returns>The current value of range type data</returns>
624 /// <param name="data">The data from OnComplicationUpdate callback.</param>
625 /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
626 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
627 /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
631 /// public class MyComplication : Complication
633 /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
634 /// ComplicationTypes defaultType)
635 /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
638 /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
640 /// if (type == ComplicationTypes.RangedValue)
642 /// double currentValue = Complication.GetCurrentValueOfRange(data);
643 /// layout.Text = currentValue;
650 /// <since_tizen> 6 </since_tizen>
651 public static double GetCurrentValueOfRange(Bundle data)
653 double curVal, minVal, maxVal;
655 ComplicationError err = Interop.WatchfaceComplication.GetRangedValue(data.SafeBundleHandle, out curVal, out minVal, out maxVal);
656 if (err != ComplicationError.None)
657 ErrorFactory.ThrowException(err, "fail to get value");
662 /// Gets the minimum value of ranged type data.
664 /// <param name="data">The data from OnComplicationUpdate callback.</param>
665 /// <returns>The minimum value of range type data</returns>
666 /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
667 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
668 /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
672 /// public class MyComplication : Complication
674 /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
675 /// ComplicationTypes defaultType)
676 /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
679 /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
681 /// if (type == ComplicationTypes.RangedValue)
683 /// double currentValue = Complication.GetMinValueOfRange(data);
684 /// layout.Text = currentValue;
691 /// <since_tizen> 6 </since_tizen>
692 public static double GetMinValueOfRange(Bundle data)
694 double curVal, minVal, maxVal;
696 ComplicationError err = Interop.WatchfaceComplication.GetRangedValue(data.SafeBundleHandle, out curVal, out minVal, out maxVal);
697 if (err != ComplicationError.None)
698 ErrorFactory.ThrowException(err, "fail to get value");
703 /// Gets the max value of ranged type data.
705 /// <param name="data">The data from OnComplicationUpdate callback.</param>
706 /// <returns>The maximum value of range type data</returns>
707 /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
708 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
709 /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
713 /// public class MyComplication : Complication
715 /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
716 /// ComplicationTypes defaultType)
717 /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
720 /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
722 /// if (type == ComplicationTypes.RangedValue)
724 /// double maxValue = Complication.GetMaxValueOfRange(data);
725 /// layout.Text = maxValue;
732 /// <since_tizen> 6 </since_tizen>
733 public static double GetMaxValueOfRange(Bundle data)
735 double curVal, minVal, maxVal;
737 ComplicationError err = Interop.WatchfaceComplication.GetRangedValue(data.SafeBundleHandle, out curVal, out minVal, out maxVal);
738 if (err != ComplicationError.None)
739 ErrorFactory.ThrowException(err, "fail to get value");
744 /// Gets the icon path.
746 /// <param name="data">The data from OnComplicationUpdate callback.</param>
747 /// <returns>The icon path data</returns>
748 /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
749 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
750 /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
754 /// public class MyComplication : Complication
756 /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
757 /// ComplicationTypes defaultType)
758 /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
761 /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
763 /// if (type == ComplicationTypes.Icon)
765 /// string iconPath = Complication.GetIconPath(data);
766 /// layout.Text = iconPath;
773 /// <since_tizen> 6 </since_tizen>
774 public static string GetIconPath(Bundle data)
778 ComplicationError err = Interop.WatchfaceComplication.GetIconPath(data.SafeBundleHandle, out iconPath);
779 if (err != ComplicationError.None)
780 ErrorFactory.ThrowException(err, "fail to get icon path");
785 /// Gets the extra data.
787 /// <param name="data">The data from OnComplicationUpdate callback.</param>
788 /// <returns>The extra string data</returns>
789 /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
790 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
791 /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
795 /// public class MyComplication : Complication
797 /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
798 /// ComplicationTypes defaultType)
799 /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
802 /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
804 /// if (type == ComplicationTypes.Icon)
806 /// string extraData = Complication.GetExtraData(data);
807 /// layout.Text = extraData;
814 /// <since_tizen> 6 </since_tizen>
815 public static string GetExtraData(Bundle data)
819 ComplicationError err = Interop.WatchfaceComplication.GetExtraData(data.SafeBundleHandle, out extraData);
820 if (err != ComplicationError.None)
821 ErrorFactory.ThrowException(err, "fail to get extra data");
826 /// Gets the screen reader text.
828 /// <param name="data">The data from OnComplicationUpdate callback.</param>
829 /// <returns>The screen reader text data</returns>
830 /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
831 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
832 /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
836 /// public class MyComplication : Complication
838 /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
839 /// ComplicationTypes defaultType)
840 /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
843 /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
845 /// if (type == ComplicationTypes.LongText)
847 /// string screenReaderText = Complication.GetScreenReaderText(data);
848 /// layout.Text = screenReaderText;
855 /// <since_tizen> 6 </since_tizen>
856 public static string GetScreenReaderText(Bundle data)
858 string screenReaderText;
860 ComplicationError err = Interop.WatchfaceComplication.GetScreenReaderText(data.SafeBundleHandle, out screenReaderText);
861 if (err != ComplicationError.None)
862 ErrorFactory.ThrowException(err, "fail to get text");
863 return screenReaderText;
867 /// Overrides this method to handle the behavior when the complication update event comes.
869 /// <param name="providerId">The updated provider's ID.</param>
870 /// <param name="type">The updated type.</param>
871 /// <param name="data">The updated data.</param>
872 /// <since_tizen> 6 </since_tizen>
873 protected abstract void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data);
876 /// Overrides this method to handle the behavior when the complication error occurs.
878 /// <param name="providerId">The updated provider's ID.</param>
879 /// <param name="type">The updated type.</param>
880 /// <param name="errorReason">The occured error.</param>
881 /// <since_tizen> 6 </since_tizen>
882 protected virtual void OnComplicationError(string providerId, ComplicationTypes type, ComplicationError errorReason)
887 /// Releases the unmanaged resources used by the Complication class specifying whether to perform a normal dispose operation.
889 /// <param name="disposing">true for a normal dispose operation; false to finalize the handle.</param>
890 /// <since_tizen> 3 </since_tizen>
891 protected virtual void Dispose(bool disposing)
895 Interop.WatchfaceComplication.RemoveUpdatedCallback(_handle, _updatedCallback);
896 Interop.WatchfaceComplication.Destroy(_handle);
902 /// Releases all resources used by the Complication class.
904 /// <since_tizen> 3 </since_tizen>
905 public void Dispose()
908 GC.SuppressFinalize(this);