--- /dev/null
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <TargetFramework>netstandard2.0</TargetFramework>
+ </PropertyGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Tizen\Tizen.csproj" />
+ <ProjectReference Include="..\Tizen.Applications.Common\Tizen.Applications.Common.csproj" />
+ <ProjectReference Include="..\Tizen.Log\Tizen.Log.csproj" />
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Tizen.Applications\Interop\" />
+ </ItemGroup>
+</Project>
--- /dev/null
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26730.16
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.WatchfaceComplication", "Tizen.Applications.WatchfaceComplication.csproj", "{F1EF8A92-02E2-483D-9D68-234640648CE3}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.Common", "..\Tizen.Applications.Common\Tizen.Applications.Common.csproj", "{888128ED-3F96-4D72-B3BE-DD545910E313}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen", "..\Tizen\Tizen.csproj", "{6DA1B64B-E113-4BE1-915A-E2E6CE96007E}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Log", "..\Tizen.Log\Tizen.Log.csproj", "{A1FA50DC-8A5B-4857-BF13-D0F8254D09D9}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {F1EF8A92-02E2-483D-9D68-234640648CE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F1EF8A92-02E2-483D-9D68-234640648CE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F1EF8A92-02E2-483D-9D68-234640648CE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F1EF8A92-02E2-483D-9D68-234640648CE3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {888128ED-3F96-4D72-B3BE-DD545910E313}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {888128ED-3F96-4D72-B3BE-DD545910E313}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {888128ED-3F96-4D72-B3BE-DD545910E313}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {888128ED-3F96-4D72-B3BE-DD545910E313}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6DA1B64B-E113-4BE1-915A-E2E6CE96007E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6DA1B64B-E113-4BE1-915A-E2E6CE96007E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6DA1B64B-E113-4BE1-915A-E2E6CE96007E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6DA1B64B-E113-4BE1-915A-E2E6CE96007E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A1FA50DC-8A5B-4857-BF13-D0F8254D09D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A1FA50DC-8A5B-4857-BF13-D0F8254D09D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A1FA50DC-8A5B-4857-BF13-D0F8254D09D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A1FA50DC-8A5B-4857-BF13-D0F8254D09D9}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {801AB838-E62B-4E17-9AA4-CB24E9774492}
+ EndGlobalSection
+EndGlobal
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Tizen.Applications;
+
+
+namespace Tizen.Applications.WatchfaceComplication
+{
+ /// <summary>
+ /// Represents the Complication class for the watch application which using watchface complication.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public abstract class Complication : IEditable, IDisposable
+ {
+ private int _complicationId;
+ private ComplicationTypes _supportTypes;
+ private string _defaultProviderId;
+ private ComplicationTypes _defaultType;
+ private EventTypes _supportEvents;
+ private Highlight _highlight;
+ internal IntPtr _handle;
+ private Interop.WatchfaceComplication.ComplicationUpdatedCallback _updatedCallback;
+ private Interop.WatchfaceComplication.ComplicationErrorCallback _errorCallback;
+ private IEnumerable<(string allowedProviderId, ComplicationTypes supportTypes)> _allowedList;
+ private int _editableId;
+ private bool _disposed = false;
+
+ /// <summary>
+ /// Initializes the Complication class.
+ /// </summary>
+ /// <param name="complicationId">The id of the complication.</param>
+ /// <param name="supportTypes">The complication support types.</param>
+ /// <param name="supportEvents">The complication's support events.</param>
+ /// <param name="defaultProviderId">The complication's default provider ID.</param>
+ /// <param name="defaultType">The complication's default type.</param>
+ /// <privilege>http://tizen.org/privilege/datasharing</privilege>
+ /// <privilege>http://tizen.org/privilege/packagemanager.info</privilege>
+ /// <exception cref="ArgumentException">Thrown when the invalid parameter is passed.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when the application does not have privilege to access this method.</exception>
+ /// <example>
+ /// <code>
+ ///
+ /// public class MyComplication : Complication
+ /// {
+ /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
+ /// ComplicationTypes defaultType)
+ /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
+ /// {
+ /// }
+ /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
+ /// {
+ /// }
+ /// }
+ /// _complication = new MyComplication(_complicationId, (int)(ComplicationTypes.ShortText | ComplicationTypes.Image),
+ /// (int) EventTypes.EventNone, _complicationProviderId, ComplicationTypes.ShortText, _complicationBtn);
+ ///
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ protected Complication(int complicationId, ComplicationTypes supportTypes, EventTypes supportEvents, string defaultProviderId, ComplicationTypes defaultType)
+ {
+ _complicationId = complicationId;
+ _supportTypes = supportTypes;
+ _supportEvents = supportEvents;
+ _defaultProviderId = defaultProviderId;
+ _defaultType = defaultType;
+
+ ComplicationError ret = Interop.WatchfaceComplication.CreateComplication(complicationId, defaultProviderId, defaultType, (int)supportTypes, (int)supportEvents, out _handle);
+ if (ret != ComplicationError.None)
+ {
+ ErrorFactory.ThrowException(ret, "Fail to create complication");
+ }
+ _updatedCallback = new Interop.WatchfaceComplication.ComplicationUpdatedCallback(ComplicationUpdatedCallback);
+ _errorCallback = new Interop.WatchfaceComplication.ComplicationErrorCallback(ComplicationErrorCallback);
+ ret = Interop.WatchfaceComplication.AddUpdatedCallback(_handle, _updatedCallback, _errorCallback, IntPtr.Zero);
+ if (ret != ComplicationError.None)
+ {
+
+ ErrorFactory.ThrowException(ret, "Fail to add update callback");
+ }
+ }
+
+ /// <summary>
+ /// Destructor of the complication class.
+ /// </summary>
+ ~Complication()
+ {
+ Dispose(true);
+ }
+
+ /// <summary>
+ /// Gets the support types.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public ComplicationTypes SupportTypes
+ {
+ get
+ {
+ return _supportTypes;
+ }
+ }
+
+ /// <summary>
+ /// Gets the support event types.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public EventTypes SupportEvents
+ {
+ get
+ {
+ return _supportEvents;
+ }
+ }
+
+ /// <summary>
+ /// The information of the editable's highlight.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ Highlight IEditable.Highlight
+ {
+ get
+ {
+ return _highlight;
+ }
+ set
+ {
+ _highlight = value;
+ }
+ }
+
+
+ /// <summary>
+ /// The information of specific allowed provider id, support types list for complication
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public IEnumerable<(string allowedProviderId, ComplicationTypes supportTypes)> AllowedList
+ {
+ get
+ {
+ return _allowedList;
+ }
+ set
+ {
+ _allowedList = value;
+ if (_allowedList == null || _allowedList.Count() == 0)
+ {
+ Interop.WatchfaceComplication.ClearAllowedList(_handle);
+ }
+ else
+ {
+ IntPtr listRaw;
+ Interop.WatchfaceComplication.CreateAllowedList(out listRaw);
+ List<(string allowedProviderId, ComplicationTypes supportTypes)> list = _allowedList.ToList();
+ foreach (var item in list)
+ {
+ Interop.WatchfaceComplication.AddAllowedList(listRaw, item.allowedProviderId, (int)item.supportTypes);
+ }
+ Interop.WatchfaceComplication.ApplyAllowedList(_handle, listRaw);
+ Interop.WatchfaceComplication.DestroyAllowedList(listRaw);
+ }
+
+ }
+ }
+
+ /// <summary>
+ /// The information of the complication's highlight.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public Highlight Highlight
+ {
+ get
+ {
+ return _highlight;
+ }
+ set
+ {
+ _highlight = value;
+ }
+ }
+
+ /// <summary>
+ /// The information of complication ID.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public int ComplicationId
+ {
+ get
+ {
+ return _complicationId;
+ }
+ }
+
+ /// <summary>
+ /// The information of editable ID.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ int IEditable.EditableId
+ {
+ get
+ {
+ return _editableId;
+ }
+ set
+ {
+ _editableId = value;
+ }
+ }
+
+ /// <summary>
+ /// The information of editable name.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ string IEditable.Name
+ {
+ get
+ {
+ string editableName = "";
+ Interop.WatchfaceComplication.GetEditableName(_handle, out editableName);
+ return editableName;
+ }
+ set
+ {
+ Interop.WatchfaceComplication.SetEditableName(_handle, value);
+ }
+ }
+
+ /// <summary>
+ /// Gets the editable's current data index.
+ /// </summary>
+ /// <returns>The index of current data</returns>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <example>
+ /// <code>
+ /// MyComplication comp = new MyComplication();
+ /// Bundle curData = comp.GetCurrentDataIndex();
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ int IEditable.GetCurrentDataIndex()
+ {
+ int curIdx;
+ ComplicationError ret = Interop.WatchfaceComplication.GetCurrentIdx(_handle, out curIdx);
+ if (ret != ComplicationError.None)
+ {
+ ErrorFactory.ThrowException(ret, "Fail to get current idx");
+ }
+ return curIdx;
+ }
+
+ /// <summary>
+ /// Gets the editable's current data.
+ /// </summary>
+ /// <returns>The current data</returns>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <example>
+ /// <code>
+ /// MyComplication comp = new MyComplication();
+ /// Bundle curData = comp.GetCurrentData();
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ Bundle IEditable.GetCurrentData()
+ {
+ SafeBundleHandle bundleHandle;
+ ComplicationError err = Interop.WatchfaceComplication.GetCurrentData(_handle, out bundleHandle);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "Can not get current data");
+ Bundle data = new Bundle(bundleHandle);
+ return data;
+ }
+
+ /// <summary>
+ /// Gets the current provider ID.
+ /// </summary>
+ /// <returns>The current provider ID</returns>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <example>
+ /// <code>
+ /// MyComplication comp = new MyComplication();
+ /// string providerId = comp.GetCurrentProviderId();
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public string GetCurrentProviderId()
+ {
+ string providerId = "";
+ ComplicationError err = Interop.WatchfaceComplication.GetCurrentProviderId(_handle, out providerId);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "Can not get current provider id");
+ return providerId;
+ }
+
+ /// <summary>
+ /// Gets the current complication type.
+ /// </summary>
+ /// <returns>The current complication type</returns>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <example>
+ /// <code>
+ /// MyComplication comp = new MyComplication();
+ /// ComplicationTypes type = comp.GetCurrentType();
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public ComplicationTypes GetCurrentType()
+ {
+ ComplicationTypes type;
+ ComplicationError err = Interop.WatchfaceComplication.GetCurrentType(_handle, out type);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "Can not get current provider type");
+ return type;
+ }
+
+ private void ComplicationUpdatedCallback(int complicationId,
+ string providerId, ComplicationTypes type, IntPtr data, IntPtr userData)
+ {
+ if (_complicationId == complicationId)
+ OnComplicationUpdated(providerId, type, new Bundle(new SafeBundleHandle(data, false)));
+ }
+
+ private void ComplicationErrorCallback(int complicationId,
+ string providerId, ComplicationTypes type, ComplicationError error, IntPtr userData)
+ {
+ if (_complicationId == complicationId)
+ OnComplicationError(providerId, type, error);
+ }
+
+ /// <summary>
+ /// Sends the complication update requests.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+ /// <privilege>http://tizen.org/privilege/datasharing</privilege>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when the application does not have privilege to access this method.</exception>
+ /// <example>
+ /// <code>
+ /// MyComplication comp = new MyComplication();
+ /// ComplicationError err = comp.SendUpdateRequest();
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public void SendUpdateRequest()
+ {
+ ComplicationError ret = Interop.WatchfaceComplication.SendUpdateRequest(_handle);
+ if (ret != ComplicationError.None)
+ ErrorFactory.ThrowException(ret, "Fail to get send request");
+ }
+
+ /// <summary>
+ /// Transfers event to the provider.
+ /// </summary>
+ /// <param name="eventType">The complication event type.</param>
+ /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+ /// <privilege>http://tizen.org/privilege/datasharing</privilege>
+ /// <exception cref="UnauthorizedAccessException">Thrown when the application does not have privilege to access this method.</exception>
+ /// <exception cref="ArgumentException">Thrown when the invalid argument is passed.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <example>
+ /// <code>
+ /// void OnButtonClicked()
+ /// {
+ /// comp.TransferEvent(EventTypes.EventTap);
+ /// }
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public void TransferEvent(EventTypes eventType)
+ {
+ ComplicationError ret = Interop.WatchfaceComplication.TransferEvent(_handle, eventType);
+ if (ret != ComplicationError.None)
+ ErrorFactory.ThrowException(ret, "Fail to transfer event");
+ }
+
+ /// <summary>
+ /// Gets the complication data type.
+ /// </summary>
+ /// <param name="data">The data from OnComplicationUpdate callback.</param>
+ /// <returns>The complication type of data</returns>
+ /// <exception cref="ArgumentException">Thrown when the invalid argument is passed.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <example>
+ /// <code>
+ /// ComplicationTypes type = Complication.GetType(dupData);
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public static ComplicationTypes GetType(Bundle data)
+ {
+ ComplicationTypes type;
+
+ ComplicationError err = Interop.WatchfaceComplication.GetDataType(data.SafeBundleHandle, out type);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to get data type");
+ return type;
+ }
+
+ /// <summary>
+ /// Gets the short text.
+ /// </summary>
+ /// <param name="data">The data from OnComplicationUpdate callback.</param>
+ /// <returns>The short text data</returns>
+ /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <example>
+ /// <code>
+ ///
+ /// public class MyComplication : Complication
+ /// {
+ /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
+ /// ComplicationTypes defaultType)
+ /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
+ /// {
+ /// }
+ /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
+ /// {
+ /// if (type == ComplicationTypes.ShortText)
+ /// {
+ /// string shortText = Complication.GetShortText(data);
+ /// layout.Text = shortText;
+ /// }
+ /// }
+ /// }
+ ///
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public static string GetShortText(Bundle data)
+ {
+ string shortText;
+
+ ComplicationError err = Interop.WatchfaceComplication.GetShortText(data.SafeBundleHandle, out shortText);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to get short text");
+ return shortText;
+ }
+
+ /// <summary>
+ /// Gets the long text.
+ /// </summary>
+ /// <param name="data">The data from OnComplicationUpdate callback.</param>
+ /// <returns>The long text data</returns>
+ /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <example>
+ /// <code>
+ ///
+ /// public class MyComplication : Complication
+ /// {
+ /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
+ /// ComplicationTypes defaultType)
+ /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
+ /// {
+ /// }
+ /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
+ /// {
+ /// if (type == ComplicationTypes.LongText)
+ /// {
+ /// string longText = Complication.GetLongText(data);
+ /// layout.Text = longText;
+ /// }
+ /// }
+ /// }
+ ///
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public static string GetLongText(Bundle data)
+ {
+ string longText;
+
+ ComplicationError err = Interop.WatchfaceComplication.GetLongText(data.SafeBundleHandle, out longText);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to get long text");
+ return longText;
+ }
+
+ /// <summary>
+ /// Gets the title.
+ /// </summary>
+ /// <param name="data">The data from OnComplicationUpdate callback.</param>
+ /// <returns>The title data</returns>
+ /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <example>
+ /// <code>
+ ///
+ /// public class MyComplication : Complication
+ /// {
+ /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
+ /// ComplicationTypes defaultType)
+ /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
+ /// {
+ /// }
+ /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
+ /// {
+ /// if (type == ComplicationTypes.ShortText)
+ /// {
+ /// string title = Complication.GetTitle(data);
+ /// layout.Text = title;
+ /// }
+ /// }
+ /// }
+ ///
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public static string GetTitle(Bundle data)
+ {
+ string title;
+
+ ComplicationError err = Interop.WatchfaceComplication.GetTitle(data.SafeBundleHandle, out title);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to get title");
+ return title;
+ }
+
+ /// <summary>
+ /// Gets the timestamp.
+ /// </summary>
+ /// <returns>The timestamp data in long value</returns>
+ /// <param name="data">The data from OnComplicationUpdate callback.</param>
+ /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <example>
+ /// <code>
+ ///
+ /// public class MyComplication : Complication
+ /// {
+ /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
+ /// ComplicationTypes defaultType)
+ /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
+ /// {
+ /// }
+ /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
+ /// {
+ /// if (type == ComplicationTypes.Time)
+ /// {
+ /// long time = Complication.GetTimestamp(data);
+ /// layout.Text = time;
+ /// }
+ /// }
+ /// }
+ ///
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public static long GetTimestamp(Bundle data)
+ {
+ long timestamp;
+
+ ComplicationError err = Interop.WatchfaceComplication.GetTimestamp(data.SafeBundleHandle, out timestamp);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to get timestamp");
+ return timestamp;
+ }
+
+ /// <summary>
+ /// Gets the image path.
+ /// </summary>
+ /// <param name="data">The data from OnComplicationUpdate callback.</param>
+ /// <returns>The image path data</returns>
+ /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <example>
+ /// <code>
+ ///
+ /// public class MyComplication : Complication
+ /// {
+ /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
+ /// ComplicationTypes defaultType)
+ /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
+ /// {
+ /// }
+ /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
+ /// {
+ /// if (type == ComplicationTypes.Image)
+ /// {
+ /// string imagePath = Complication.GetImagePath(data);
+ /// layout.Text = imagePath;
+ /// }
+ /// }
+ /// }
+ ///
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public static string GetImagePath(Bundle data)
+ {
+ string imagePath;
+
+ ComplicationError err = Interop.WatchfaceComplication.GetImagePath(data.SafeBundleHandle, out imagePath);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to get image path");
+ return imagePath;
+ }
+
+ /// <summary>
+ /// Gets the current value of ranged type data.
+ /// </summary>
+ /// <returns>The current value of range type data</returns>
+ /// <param name="data">The data from OnComplicationUpdate callback.</param>
+ /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <example>
+ /// <code>
+ ///
+ /// public class MyComplication : Complication
+ /// {
+ /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
+ /// ComplicationTypes defaultType)
+ /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
+ /// {
+ /// }
+ /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
+ /// {
+ /// if (type == ComplicationTypes.RangedValue)
+ /// {
+ /// double currentValue = Complication.GetCurrentValueOfRange(data);
+ /// layout.Text = currentValue;
+ /// }
+ /// }
+ /// }
+ ///
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public static double GetCurrentValueOfRange(Bundle data)
+ {
+ double curVal, minVal, maxVal;
+
+ ComplicationError err = Interop.WatchfaceComplication.GetRangedValue(data.SafeBundleHandle, out curVal, out minVal, out maxVal);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to get value");
+ return curVal;
+ }
+
+ /// <summary>
+ /// Gets the minimum value of ranged type data.
+ /// </summary>
+ /// <param name="data">The data from OnComplicationUpdate callback.</param>
+ /// <returns>The minimum value of range type data</returns>
+ /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <example>
+ /// <code>
+ ///
+ /// public class MyComplication : Complication
+ /// {
+ /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
+ /// ComplicationTypes defaultType)
+ /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
+ /// {
+ /// }
+ /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
+ /// {
+ /// if (type == ComplicationTypes.RangedValue)
+ /// {
+ /// double currentValue = Complication.GetMinValueOfRange(data);
+ /// layout.Text = currentValue;
+ /// }
+ /// }
+ /// }
+ ///
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public static double GetMinValueOfRange(Bundle data)
+ {
+ double curVal, minVal, maxVal;
+
+ ComplicationError err = Interop.WatchfaceComplication.GetRangedValue(data.SafeBundleHandle, out curVal, out minVal, out maxVal);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to get value");
+ return minVal;
+ }
+
+ /// <summary>
+ /// Gets the max value of ranged type data.
+ /// </summary>
+ /// <param name="data">The data from OnComplicationUpdate callback.</param>
+ /// <returns>The maximum value of range type data</returns>
+ /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <example>
+ /// <code>
+ ///
+ /// public class MyComplication : Complication
+ /// {
+ /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
+ /// ComplicationTypes defaultType)
+ /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
+ /// {
+ /// }
+ /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
+ /// {
+ /// if (type == ComplicationTypes.RangedValue)
+ /// {
+ /// double maxValue = Complication.GetMaxValueOfRange(data);
+ /// layout.Text = maxValue;
+ /// }
+ /// }
+ /// }
+ ///
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public static double GetMaxValueOfRange(Bundle data)
+ {
+ double curVal, minVal, maxVal;
+
+ ComplicationError err = Interop.WatchfaceComplication.GetRangedValue(data.SafeBundleHandle, out curVal, out minVal, out maxVal);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to get value");
+ return maxVal;
+ }
+
+ /// <summary>
+ /// Gets the icon path.
+ /// </summary>
+ /// <param name="data">The data from OnComplicationUpdate callback.</param>
+ /// <returns>The icon path data</returns>
+ /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <example>
+ /// <code>
+ ///
+ /// public class MyComplication : Complication
+ /// {
+ /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
+ /// ComplicationTypes defaultType)
+ /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
+ /// {
+ /// }
+ /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
+ /// {
+ /// if (type == ComplicationTypes.Icon)
+ /// {
+ /// string iconPath = Complication.GetIconPath(data);
+ /// layout.Text = iconPath;
+ /// }
+ /// }
+ /// }
+ ///
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public static string GetIconPath(Bundle data)
+ {
+ string iconPath;
+
+ ComplicationError err = Interop.WatchfaceComplication.GetIconPath(data.SafeBundleHandle, out iconPath);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to get icon path");
+ return iconPath;
+ }
+
+ /// <summary>
+ /// Gets the extra data.
+ /// </summary>
+ /// <param name="data">The data from OnComplicationUpdate callback.</param>
+ /// <returns>The extra string data</returns>
+ /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <example>
+ /// <code>
+ ///
+ /// public class MyComplication : Complication
+ /// {
+ /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
+ /// ComplicationTypes defaultType)
+ /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
+ /// {
+ /// }
+ /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
+ /// {
+ /// if (type == ComplicationTypes.Icon)
+ /// {
+ /// string extraData = Complication.GetExtraData(data);
+ /// layout.Text = extraData;
+ /// }
+ /// }
+ /// }
+ ///
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public static string GetExtraData(Bundle data)
+ {
+ string extraData;
+
+ ComplicationError err = Interop.WatchfaceComplication.GetExtraData(data.SafeBundleHandle, out extraData);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to get extra data");
+ return extraData;
+ }
+
+ /// <summary>
+ /// Gets the screen reader text.
+ /// </summary>
+ /// <param name="data">The data from OnComplicationUpdate callback.</param>
+ /// <returns>The screen reader text data</returns>
+ /// <exception cref="ArgumentException">Thrown when data is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <example>
+ /// <code>
+ ///
+ /// public class MyComplication : Complication
+ /// {
+ /// public MyComplication(int complicationId, int supportTypes, int supportEvents, string defaultProviderId,
+ /// ComplicationTypes defaultType)
+ /// : base(complicationId, supportTypes, supportEvents, defaultProviderId, defaultType)
+ /// {
+ /// }
+ /// protected override void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data)
+ /// {
+ /// if (type == ComplicationTypes.LongText)
+ /// {
+ /// string screenReaderText = Complication.GetScreenReaderText(data);
+ /// layout.Text = screenReaderText;
+ /// }
+ /// }
+ /// }
+ ///
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public static string GetScreenReaderText(Bundle data)
+ {
+ string screenReaderText;
+
+ ComplicationError err = Interop.WatchfaceComplication.GetScreenReaderText(data.SafeBundleHandle, out screenReaderText);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to get text");
+ return screenReaderText;
+ }
+
+ /// <summary>
+ /// Overrides this method to handle the behavior when the complication update event comes.
+ /// </summary>
+ /// <param name="providerId">The updated provider's ID.</param>
+ /// <param name="type">The updated type.</param>
+ /// <param name="data">The updated data.</param>
+ /// <since_tizen> 6 </since_tizen>
+ protected abstract void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data);
+
+ /// <summary>
+ /// Overrides this method to handle the behavior when the complication error occurs.
+ /// </summary>
+ /// <param name="providerId">The updated provider's ID.</param>
+ /// <param name="type">The updated type.</param>
+ /// <param name="errorReason">The occured error.</param>
+ /// <since_tizen> 6 </since_tizen>
+ protected virtual void OnComplicationError(string providerId, ComplicationTypes type, ComplicationError errorReason)
+ {
+ }
+
+ /// <summary>
+ /// Releases the unmanaged resources used by the Complication class specifying whether to perform a normal dispose operation.
+ /// </summary>
+ /// <param name="disposing">true for a normal dispose operation; false to finalize the handle.</param>
+ /// <since_tizen> 3 </since_tizen>
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ Interop.WatchfaceComplication.Destroy(_handle);
+ Interop.WatchfaceComplication.RemoveUpdatedCallback(_handle, _updatedCallback);
+ _disposed = true;
+ }
+ }
+
+ /// <summary>
+ /// Releases all resources used by the Complication class.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Applications.WatchfaceComplication
+{
+ /// <summary>
+ /// Represents the Complication data class.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public abstract class ComplicationData
+ {
+ private long _timestamp;
+ private string _imagePath;
+ private double _currentValue;
+ private double _minValue;
+ private double _maxValue;
+ private string _iconPath;
+ private string _longText;
+ private string _shortText;
+ private string _extraData;
+ private string _screenReaderText;
+ private string _title;
+ private ComplicationTypes _type;
+ private const string LogTag = "WatchfaceComplication";
+
+ internal string ShortText
+ {
+ get
+ {
+ return _shortText;
+ }
+ set
+ {
+ _shortText = value;
+ }
+ }
+
+ internal string LongText
+ {
+ get
+ {
+ return _longText;
+ }
+ set
+ {
+ _longText = value;
+ }
+ }
+
+ internal string IconPath
+ {
+ get
+ {
+ return _iconPath;
+ }
+ set
+ {
+ _iconPath = value;
+ }
+ }
+
+ internal string ImagePath
+ {
+ get
+ {
+ return _imagePath;
+ }
+ set
+ {
+ _imagePath = value;
+ }
+ }
+
+ internal string Title
+ {
+ get
+ {
+ return _title;
+ }
+ set
+ {
+ _title = value;
+ }
+ }
+
+ internal string ExtraData
+ {
+ get
+ {
+ return _extraData;
+ }
+ set
+ {
+ _extraData = value;
+ }
+ }
+
+ internal string ScreenReaderText
+ {
+ get
+ {
+ return _screenReaderText;
+ }
+ set
+ {
+ _screenReaderText = value;
+ }
+ }
+
+ internal long Timestamp
+ {
+ get
+ {
+ return _timestamp;
+ }
+ set
+ {
+ _timestamp = value;
+ }
+ }
+
+ internal double RangeCurrent
+ {
+ get
+ {
+ return _currentValue;
+ }
+ set
+ {
+ _currentValue = value;
+ }
+ }
+
+ internal double RangeMin
+ {
+ get
+ {
+ return _minValue;
+ }
+ set
+ {
+ _minValue = value;
+ }
+ }
+
+ internal double RangeMax
+ {
+ get
+ {
+ return _maxValue;
+ }
+ set
+ {
+ _maxValue = value;
+ }
+ }
+
+ internal ComplicationTypes Type
+ {
+ get
+ {
+ return _type;
+ }
+ set
+ {
+ _type = value;
+ }
+ }
+
+ private bool IsDataValid(IntPtr sharedData)
+ {
+ bool isValid = false;
+ ComplicationError err = Interop.WatchfaceComplication.ProviderSharedDataIsValid(sharedData, out isValid);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to check shared data validation");
+ return isValid;
+ }
+
+ internal ComplicationError UpdateSharedData(IntPtr sharedData)
+ {
+ ComplicationError err = ComplicationError.None;
+ switch (_type)
+ {
+ case ComplicationTypes.ShortText:
+ err = Interop.WatchfaceComplication.ProviderSetShortText(sharedData, _shortText);
+ Interop.WatchfaceComplication.ProviderSetIconPath(sharedData, _iconPath);
+ Interop.WatchfaceComplication.ProviderSetTitle(sharedData, _title);
+ Interop.WatchfaceComplication.ProviderSetExtraData(sharedData, _extraData);
+ break;
+ case ComplicationTypes.LongText:
+ err = Interop.WatchfaceComplication.ProviderSetLongText(sharedData, _longText);
+ Interop.WatchfaceComplication.ProviderSetIconPath(sharedData, _iconPath);
+ Interop.WatchfaceComplication.ProviderSetTitle(sharedData, _title);
+ Interop.WatchfaceComplication.ProviderSetExtraData(sharedData, _extraData);
+ break;
+ case ComplicationTypes.RangedValue:
+ Interop.WatchfaceComplication.ProviderSetLongText(sharedData, _shortText);
+ Interop.WatchfaceComplication.ProviderSetIconPath(sharedData, _iconPath);
+ Interop.WatchfaceComplication.ProviderSetTitle(sharedData, _title);
+ err = Interop.WatchfaceComplication.ProviderSetRangedValue(sharedData, _currentValue, _minValue, _maxValue);
+ Interop.WatchfaceComplication.ProviderSetExtraData(sharedData, _extraData);
+ break;
+ case ComplicationTypes.Time:
+ err = Interop.WatchfaceComplication.ProviderSetTimestamp(sharedData, _timestamp);
+ Interop.WatchfaceComplication.ProviderSetIconPath(sharedData, _iconPath);
+ Interop.WatchfaceComplication.ProviderSetExtraData(sharedData, _extraData);
+ break;
+ case ComplicationTypes.Icon:
+ err = Interop.WatchfaceComplication.ProviderSetIconPath(sharedData, _iconPath);
+ Interop.WatchfaceComplication.ProviderSetExtraData(sharedData, _extraData);
+ break;
+ case ComplicationTypes.Image:
+ err = Interop.WatchfaceComplication.ProviderSetImagePath(sharedData, _imagePath);
+ Interop.WatchfaceComplication.ProviderSetExtraData(sharedData, _extraData);
+ break;
+ }
+ Interop.WatchfaceComplication.ProviderSetScreenReaderText(sharedData, _screenReaderText);
+ try
+ {
+ if (!IsDataValid(sharedData))
+ return ComplicationError.IO;
+ }
+ catch (Exception ex)
+ {
+ Log.Error(LogTag, "valid check fail : " + ex);
+ return ComplicationError.IO;
+ }
+
+ return err;
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2018 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.Applications.WatchfaceComplication
+{
+ /// <summary>
+ /// Enumeration for the complication error.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public enum ComplicationError
+ {
+ /// <summary>
+ /// Error none.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ None = Interop.WatchfaceComplication.ErrorType.None,
+ /// <summary>
+ /// Out of memory error.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ OutOfMemory = Interop.WatchfaceComplication.ErrorType.OutOfMemory,
+ /// <summary>
+ /// Invalid parameter error.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ InvalidParam = Interop.WatchfaceComplication.ErrorType.InvalidParam,
+ /// <summary>
+ /// IO error.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ IO = Interop.WatchfaceComplication.ErrorType.IO,
+ /// <summary>
+ /// No data error.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ NoData = Interop.WatchfaceComplication.ErrorType.NoData,
+ /// <summary>
+ /// Permission deny error.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ PermissionDeny = Interop.WatchfaceComplication.ErrorType.PermissionDeny,
+ /// <summary>
+ /// The complication API is not supported error.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ NotSupported = Interop.WatchfaceComplication.ErrorType.NotSupported,
+ /// <summary>
+ /// DB operation error.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ DB = Interop.WatchfaceComplication.ErrorType.DB,
+ /// <summary>
+ /// DBus operation error.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ DBus = Interop.WatchfaceComplication.ErrorType.DBus,
+ /// <summary>
+ /// The editor is not ready for editing error.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ EditNotReady = Interop.WatchfaceComplication.ErrorType.EditNotReady,
+ /// <summary>
+ /// Already exist ID error.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ ExistID = Interop.WatchfaceComplication.ErrorType.ExistID,
+ /// <summary>
+ /// Not exist error.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ NotExist = Interop.WatchfaceComplication.ErrorType.NotExist,
+ /// <summary>
+ /// Not available error.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ NotAvailable = Interop.WatchfaceComplication.ErrorType.NotAvailable
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Applications.WatchfaceComplication
+{
+ /// <summary>
+ /// Represents the ComplicationProvider class for the complication provider service application.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public abstract class ComplicationProvider : IDisposable
+ {
+ private string _providerId;
+ private bool _disposed = false;
+ private const string LogTag = "WatchfaceComplication";
+
+ /// <summary>
+ /// Initializes the ComplicationProvider class.
+ /// </summary>
+ /// <param name="providerId">The id of the complication provider.</param>
+ /// <privilege>http://tizen.org/privilege/datasharing</privilege>
+ /// <exception cref="ArgumentException">Thrown when providerId is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when the application does not have privilege to access this method.</exception>
+ /// <example>
+ /// <code>
+ /// public class MyComplicationProvider : ComplicationProvider
+ /// {
+ /// public MyComplicationProvider(string providerId)
+ /// : base(providerId)
+ /// {
+ /// }
+ /// protected override void OnDataUpdateRequested(string reqestAppId, ComplicationTypes type, Bundle contextData)
+ /// {
+ /// }
+ /// }
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ protected ComplicationProvider(string providerId)
+ {
+ ComplicationError err = Interop.WatchfaceComplication.AddUpdateRequestedCallback(providerId, DataUpdateRequested, IntPtr.Zero);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to create provider");
+ _providerId = providerId;
+ }
+
+ /// <summary>
+ /// Destructor of the provider class.
+ /// </summary>
+ ~ComplicationProvider()
+ {
+ Dispose(false);
+ }
+
+ /// <summary>
+ /// Gets the provider ID.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public string Id
+ {
+ get
+ {
+ return _providerId;
+ }
+ }
+
+ private void DataUpdateRequested(string providerId, string reqAppId, ComplicationTypes type,
+ IntPtr context, IntPtr sharedData, IntPtr userData)
+ {
+ Bundle bContext = new Bundle(new SafeBundleHandle(context, false));
+ ComplicationData data = OnDataUpdateRequested(reqAppId, type, bContext);
+ if (data == null)
+ {
+ Log.Error(LogTag, "null complication data");
+ return;
+ }
+ ComplicationError err = data.UpdateSharedData(sharedData);
+ if (err != ComplicationError.None)
+ Log.Error(LogTag, "Set complication data error : " + err);
+ }
+
+ /// <summary>
+ /// Overrides this method to handle the behavior when the complication data update request event comes from watchface complication.
+ /// </summary>
+ /// <param name="reqestAppId">The application ID of application which sent update request.</param>
+ /// <param name="type">The requested type.</param>
+ /// <param name="contextData">The complication's context which is set by complication setup application.</param>
+ /// <returns>The requested ComplicationData</returns>
+ /// <since_tizen> 6 </since_tizen>
+ protected abstract ComplicationData OnDataUpdateRequested(string reqestAppId, ComplicationTypes type, Bundle contextData);
+
+ /// <summary>
+ /// Emits the update event for complications.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/datasharing</privilege>
+ /// <exception cref="UnauthorizedAccessException">Thrown when the application does not have privilege to access this method.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public void NotifyUpdate()
+ {
+ ComplicationError err = Interop.WatchfaceComplication.NotifyUpdate(_providerId);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to notify");
+ }
+
+ /// <summary>
+ /// Gets the received event type.
+ /// </summary>
+ /// <param name="recvAppCtrl">The appcontrol received event args.</param>
+ /// <exception cref="ArgumentException">Thrown when the invalid parameter is passed.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <example>
+ /// <code>
+ /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
+ /// {
+ /// EventTypes type = ComplicationProvider.GetEventType(e.ReceivedAppControl);
+ /// if (type == EventTypes.EventDoubleTap)
+ /// {
+ /// // do something
+ /// }
+ /// base.OnAppControlReceived(e);
+ /// }
+ /// </code>
+ /// </example>
+ /// <returns>The type of received event</returns>
+ /// <since_tizen> 6 </since_tizen>
+ public static EventTypes GetEventType(ReceivedAppControl recvAppCtrl)
+ {
+ EventTypes type;
+ ComplicationError err = Interop.WatchfaceComplication.GetEventType(recvAppCtrl.SafeAppControlHandle, out type);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to get event");
+ return type;
+ }
+
+ /// <summary>
+ /// Gets the received event target provider ID.
+ /// </summary>
+ /// <param name="recvAppCtrl">The appcontrol received event args.</param>
+ /// <exception cref="ArgumentException">Thrown when e is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <example>
+ /// <code>
+ /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
+ /// {
+ /// string providerId = ComplicationProvider.GetEventProviderId(e.ReceivedAppControl);
+ /// base.OnAppControlReceived(e);
+ /// }
+ /// </code>
+ /// </example>
+ /// <returns>The target provider ID of received event</returns>
+ /// <since_tizen> 6 </since_tizen>
+ public static string GetEventProviderId(ReceivedAppControl recvAppCtrl)
+ {
+ string providerId = string.Empty;
+ ComplicationError err = Interop.WatchfaceComplication.GetEventProviderId(recvAppCtrl.SafeAppControlHandle, out providerId);
+ if (err != ComplicationError.None && err != ComplicationError.NoData)
+ ErrorFactory.ThrowException(err, "fail to get event");
+ return providerId;
+ }
+
+ /// <summary>
+ /// Gets the received event target complication type.
+ /// </summary>
+ /// <param name="recvAppCtrl">The appcontrol received event args.</param>
+ /// <exception cref="ArgumentException">Thrown when e is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <example>
+ /// <code>
+ /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
+ /// {
+ /// ComplicationTypes type = ComplicationProvider.GetEventComplicationType(e.ReceivedAppControl);
+ /// base.OnAppControlReceived(e);
+ /// }
+ /// </code>
+ /// </example>
+ /// <returns>The target complication type of received event</returns>
+ /// <since_tizen> 6 </since_tizen>
+ public static ComplicationTypes GetEventComplicationType(ReceivedAppControl recvAppCtrl)
+ {
+ ComplicationTypes type;
+ ComplicationError err = Interop.WatchfaceComplication.GetEventComplicationType(recvAppCtrl.SafeAppControlHandle, out type);
+ if (err != ComplicationError.None && err != ComplicationError.NoData)
+ ErrorFactory.ThrowException(err, "fail to get complication type");
+ return type;
+ }
+
+ /// <summary>
+ /// Gets the received event target complication context.
+ /// </summary>
+ /// <param name="recvAppCtrl">The appcontrol received event args.</param>
+ /// <exception cref="ArgumentException">Thrown when e is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <example>
+ /// <code>
+ /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
+ /// {
+ /// Bundle context = ComplicationProvider.GetEventContext(e.ReceivedAppControl);
+ /// base.OnAppControlReceived(e);
+ /// }
+ /// </code>
+ /// </example>
+ /// <returns>The context of received event</returns>
+ /// <since_tizen> 6 </since_tizen>
+ public static Bundle GetEventContext(ReceivedAppControl recvAppCtrl)
+ {
+ SafeBundleHandle bHandle;
+ ComplicationError err = Interop.WatchfaceComplication.GetEventContext(recvAppCtrl.SafeAppControlHandle, out bHandle);
+ if (err != ComplicationError.None)
+ {
+ if (err == ComplicationError.NoData)
+ return null;
+ ErrorFactory.ThrowException(err, "fail to get complication context");
+ }
+
+ return new Bundle(bHandle);
+ }
+
+ /// <summary>
+ /// Releases the unmanaged resources used by the ComplicationProvider class specifying whether to perform a normal dispose operation.
+ /// </summary>
+ /// <param name="disposing">true for a normal dispose operation; false to finalize the handle.</param>
+ /// <since_tizen> 3 </since_tizen>
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ Interop.WatchfaceComplication.RemoveUpdateRequestedCallback(_providerId, DataUpdateRequested);
+ _disposed = true;
+ }
+ }
+
+ /// <summary>
+ /// Releases all resources used by the ComplicationProvider class.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Applications.WatchfaceComplication
+{
+ /// <summary>
+ /// Represents the ComplicationProviderSetup class for the complication provider setup application.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public static class ComplicationProviderSetup
+ {
+ /// <summary>
+ /// Gets the received appctrl containing inforamtion about edit.
+ /// </summary>
+ /// <param name="recvAppCtrl">The appcontrol received event args.</param>
+ /// <exception cref="ArgumentException">Thrown when e is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <example>
+ /// <code>
+ /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
+ /// {
+ /// if (ComplicationProviderSetup.IsEditing(e.ReceivedAppControl))
+ /// {
+ /// // do something
+ /// }
+ /// base.OnAppControlReceived(e);
+ /// }
+ /// </code>
+ /// </example>
+ /// <returns>The boolean value.</returns>
+ /// <since_tizen> 6 </since_tizen>
+ public static bool IsEditing(ReceivedAppControl recvAppCtrl)
+ {
+ bool isEditing = false;
+ ComplicationError err = Interop.WatchfaceComplication.IsSetupEditing(recvAppCtrl.SafeAppControlHandle, out isEditing);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to check editing");
+ return isEditing;
+ }
+
+ /// <summary>
+ /// Replies the setup context to the editor
+ /// </summary>
+ /// <param name="recvAppCtrl">The appcontrol received event args.</param>
+ /// <param name="context">The context created by complication setup app.</param>
+ /// <privilege>http://tizen.org/privilege/datasharing</privilege>
+ /// <exception cref="ArgumentException">Thrown when e is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when the application does not have privilege to access this method.</exception>
+ /// <example>
+ /// <code>
+ /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
+ /// {
+ /// if (ComplicationProviderSetup.IsEditing(e.ReceivedAppControl))
+ /// {
+ /// Bundle context = ComplicationProviderSetup.GetContext(e.ReceivedAppControl);
+ /// context.AddItem("TEST_KEY", "NEW CONTEXT");
+ /// ComplicationProviderSetup.ReplyToEditor(e.ReceivedAppControl, context);
+ /// }
+ /// base.OnAppControlReceived(e);
+ /// }
+ /// </code>
+ /// </example>
+ /// <returns>Event target complication type</returns>
+ /// <since_tizen> 6 </since_tizen>
+ public static void ReplyToEditor(ReceivedAppControl recvAppCtrl, Bundle context)
+ {
+ ComplicationError err = Interop.WatchfaceComplication.SetupReplyToEditor(recvAppCtrl.SafeAppControlHandle, context.SafeBundleHandle);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to check editing");
+ }
+
+ /// <summary>
+ /// Gets complication's setup context.
+ /// </summary>
+ /// <param name="recvAppCtrl">The appcontrol received event args.</param>
+ /// <exception cref="ArgumentException">Thrown when e is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <example>
+ /// <code>
+ /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
+ /// {
+ /// if (ComplicationProviderSetup.IsEditing(e.ReceivedAppControl))
+ /// {
+ /// Bundle context = ComplicationProviderSetup.GetContext(e.ReceivedAppControl);
+ /// context.AddItem("TEST_KEY", "NEW CONTEXT");
+ /// ComplicationProviderSetup.ReplyToEditor(e.ReceivedAppControl, context);
+ /// }
+ /// base.OnAppControlReceived(e);
+ /// }
+ /// </code>
+ /// </example>
+ /// <returns>The setup context.</returns>
+ /// <since_tizen> 6 </since_tizen>
+ public static Bundle GetContext(ReceivedAppControl recvAppCtrl)
+ {
+ SafeBundleHandle context;
+ ComplicationError err = Interop.WatchfaceComplication.GetSetupContext(recvAppCtrl.SafeAppControlHandle, out context);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to check editing");
+ if (context == null)
+ return null;
+
+ return new Bundle(context);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Applications.WatchfaceComplication
+{
+ /// <summary>
+ /// Enumeration for the complication type.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ [Flags]
+ public enum ComplicationTypes
+ {
+ /// <summary>
+ /// The complication type NoData do not displays anything.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ NoData = 0x01,
+ /// <summary>
+ /// The complication type ShortText displays short text.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ ShortText = 0x02,
+ /// <summary>
+ /// The complication type LongText displays long text.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ LongText = 0x04,
+ /// <summary>
+ /// The complication type RangedValue displays minimum, maximum, current value.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ RangedValue = 0x08,
+ /// <summary>
+ /// The complication type Time displays time.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ Time = 0x10,
+ /// <summary>
+ /// The complication type Icon displays icon.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ Icon = 0x20,
+ /// <summary>
+ /// The complication type Image displays image.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ Image = 0x40
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Tizen.Applications.WatchfaceComplication
+{
+ /// <summary>
+ /// Represents the DesignElement class for the watch application.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public abstract class DesignElement : IEditable
+ {
+
+ private IEnumerable<Bundle> _candidates;
+ private int _currentDataIndex;
+ private Highlight _highlight;
+ private string _editableName;
+ private int _editableId;
+
+ /// <summary>
+ /// Initializes the DesignElement class.
+ /// </summary>
+ /// <param name="candidates">The candidates list.</param>
+ /// <param name="currentDataIndex">The currently selected data index of candidate list.</param>
+ /// <param name="editableName">The design element name.</param>
+ /// <exception cref="ArgumentException">Thrown when e is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <example>
+ /// <code>
+ /// public class ColorDesign : DesignElement
+ /// {
+ /// private Button _layout;
+ /// private static string _colorKey = "TEST_COLOR";
+ /// public ColorDesign(IEnumerable candidates, int curDataIdx, string editableName, Button layout)
+ /// : base(candidates, curDataIdx, editableName)
+ /// {
+ /// _layout = layout;
+ /// }
+ /// protected override void OnDesignUpdated(int selectedIdx, State state)
+ /// {
+ /// int idx = 0;
+ /// string color = "";
+ /// foreach (Bundle candidate in this.Candidates)
+ /// {
+ /// if (idx++ != selectedIdx)
+ /// continue;
+ /// color = candidate.GetItem(_colorKey);
+ /// break;
+ /// }
+ /// Log.Warn(_logTag, "Color : " + color);
+ /// if (color.Equals("YELLOW"))
+ /// {
+ /// _layout.BackgroundColor = Color.Yellow;
+ /// }
+ /// }
+ /// }
+ ///
+ /// List<Bundle> candidatesList = new List<Bundle>();
+ /// data = new Bundle();
+ /// data.AddItem(_colorKey, "RED");
+ /// candidatesList.Add(data);
+ /// data.AddItem(_colorKey, "BLUE");
+ /// candidatesList.Add(data);
+ /// ColorDesign colorEdit = new ColorDesign(candidatesList, curIdx, "COLOR", _complicationBtn);
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ protected DesignElement(IEnumerable<Bundle> candidates, int currentDataIndex, string editableName)
+ {
+ if (candidates == null || currentDataIndex < 0)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam);
+ List<Bundle> candidatesList = candidates.ToList();
+ if (candidatesList.Count < currentDataIndex)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam);
+
+ _candidates = candidates;
+ _currentDataIndex = currentDataIndex;
+ _editableName = editableName;
+ }
+
+ /// <summary>
+ /// The information of Editable ID.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ int IEditable.EditableId
+ {
+ get
+ {
+ return _editableId;
+ }
+ set
+ {
+ _editableId = value;
+ }
+ }
+
+ /// <summary>
+ /// The information of Editable candidates.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public IEnumerable<Bundle> Candidates
+ {
+ get
+ {
+ return _candidates;
+ }
+ }
+
+ /// <summary>
+ /// The information of Editable name.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ string IEditable.Name
+ {
+ get
+ {
+ return _editableName;
+ }
+ set
+ {
+ _editableName = value;
+ }
+ }
+
+ /// <summary>
+ /// The information of editable's highlight.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ Highlight IEditable.Highlight
+ {
+ get
+ {
+ return _highlight;
+ }
+ set
+ {
+ _highlight = value;
+ }
+ }
+
+ /// <summary>
+ /// The information of design element's highlight.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public Highlight Highlight
+ {
+ get
+ {
+ return _highlight;
+ }
+ set
+ {
+ _highlight = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets the editable's currently selected data index of candidate list.
+ /// </summary>
+ /// <returns>The currently selected data index of candidate list.</returns>
+ /// <since_tizen> 6 </since_tizen>
+ int IEditable.GetCurrentDataIndex()
+ {
+ return _currentDataIndex;
+ }
+
+ internal void SetCurrentDataIndex(int idx)
+ {
+ _currentDataIndex = idx;
+ }
+
+ /// <summary>
+ /// Gets the editable's currently selected data.
+ /// </summary>
+ /// <returns>The currently selected data.</returns>
+ /// <since_tizen> 6 </since_tizen>
+ Bundle IEditable.GetCurrentData()
+ {
+ int idx = 0;
+ foreach (Bundle data in _candidates)
+ {
+ if (idx == _currentDataIndex)
+ return data;
+ idx++;
+ }
+ return null;
+ }
+
+ internal void NotifyUpdate(int candidateIdx, State state)
+ {
+ OnDesignUpdated(candidateIdx, state);
+ }
+
+ /// <summary>
+ /// Overrides this method to handle the behavior when the design element is updated.
+ /// </summary>
+ /// <param name="selectedIdx">The selected candidate index.</param>
+ /// <param name="state">The update state.</param>
+ /// <since_tizen> 6 </since_tizen>
+ protected abstract void OnDesignUpdated(int selectedIdx, State state);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Applications.WatchfaceComplication
+{
+ /// <summary>
+ /// Represents the EditablesContainer class for the watch application.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public abstract class EditablesContainer : IDisposable
+ {
+ internal IList<DesignElement> _deList = new List<DesignElement>();
+ internal IList<Complication> _compList = new List<Complication>();
+ internal IntPtr _container = IntPtr.Zero;
+ private Interop.WatchfaceComplication.EditableUpdateRequestedCallback _editableUpdatedCallback;
+ private bool _disposed = false;
+ private static string _logTag = "WatchfaceComplication";
+
+ /// <summary>
+ /// Initializes the EditablesContainer class.
+ /// </summary>
+ /// <exception cref="ArgumentException">Thrown when some parameter are invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ protected EditablesContainer()
+ {
+ ComplicationError err = Interop.WatchfaceComplication.AddEditReadyCallback(EditReady, IntPtr.Zero);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "Fail to add edit ready callback");
+ Log.Debug(_logTag, "Edit container ready");
+ }
+
+ /// <summary>
+ /// Destructor of the EditablesContainer class.
+ /// </summary>
+ ~EditablesContainer()
+ {
+ Dispose(false);
+ }
+
+ /// <summary>
+ /// Adds the DesignElement to edit list.
+ /// </summary>
+ /// <param name="de">The DesignElement object.</param>
+ /// <param name="editableId">The editable id.</param>
+ /// <exception cref="ArgumentException">Thrown when the invalid parameter is passed.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public void Add(DesignElement de, int editableId)
+ {
+ if (de == null)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam);
+ if (IsExist(editableId))
+ ErrorFactory.ThrowException(ComplicationError.ExistID);
+
+ IEditable e = de;
+ e.EditableId = editableId;
+ _deList.Add(de);
+ }
+
+ /// <summary>
+ /// Adds the Complication to edit list.
+ /// </summary>
+ /// <param name="comp">The Complication object.</param>
+ /// <param name="editableId">The editable id.</param>
+ /// <exception cref="ArgumentException">Thrown when the invalid parameter is passed.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public void Add(Complication comp, int editableId)
+ {
+ if (comp == null)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam);
+ if (IsExist(editableId))
+ ErrorFactory.ThrowException(ComplicationError.ExistID);
+
+ IEditable e = comp;
+ e.EditableId = editableId;
+ _compList.Add(comp);
+ }
+
+ /// <summary>
+ /// Removes the editable from edit list.
+ /// </summary>
+ /// <param name="editableId">The editable id.</param>
+ /// <exception cref="ArgumentException">Thrown when the invalid parameter is passed.</exception>
+ /// <example>
+ /// <code>
+ /// if (myContainer.IsExist(_colorEditId)
+ /// myContainer.Remove(_colorEditId);
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public void Remove(int editableId)
+ {
+ foreach (DesignElement de in _deList)
+ {
+ if (((IEditable)de).EditableId == editableId)
+ {
+ _deList.Remove(de);
+ return;
+ }
+ }
+
+ foreach (Complication comp in _compList)
+ {
+ if (((IEditable)comp).EditableId == editableId)
+ {
+ _compList.Remove(comp);
+ return;
+ }
+ }
+
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam, "invalid editable ID");
+ }
+
+ internal IEditable GetEditable(int editableId)
+ {
+ foreach (IEditable ed in _deList)
+ {
+ if (ed.EditableId == editableId)
+ return ed;
+ }
+
+ foreach (IEditable ed in _compList)
+ {
+ if (ed.EditableId == editableId)
+ return ed;
+ }
+
+ return null;
+ }
+
+ internal DesignElement GetDesignElement(int editableId)
+ {
+ foreach (DesignElement de in _deList)
+ {
+ IEditable ed = de;
+ if (ed.EditableId == editableId)
+ return de;
+ }
+
+ return null;
+ }
+
+ /// <summary>
+ /// Checks the editable with editableId is already exists in edit list.
+ /// </summary>
+ /// <param name="editableId">The target editable Id.</param>
+ /// <returns>true if the editable is already exists in edit list, otherwise false</returns>
+ /// <since_tizen> 6 </since_tizen>
+ public bool IsExist(int editableId)
+ {
+ return (GetEditable(editableId) != null);
+ }
+
+ private void EditReady(IntPtr container, string editorAppid, IntPtr userData)
+ {
+ OnEditReady(editorAppid);
+ }
+
+
+ private void EditableUpdatedCallback(IntPtr handle, int selectedIdx,
+ int state, IntPtr userData)
+ {
+ int editableId;
+ ComplicationError err = Interop.WatchfaceComplication.GetEditableId(handle, out editableId);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to get current index");
+
+ int currentIdx;
+ err = Interop.WatchfaceComplication.GetCurrentIdx(handle, out currentIdx);
+ if (err != ComplicationError.None)
+ ErrorFactory.ThrowException(err, "fail to get current index");
+
+ DesignElement de = GetDesignElement(editableId);
+ if (de != null)
+ {
+ de.SetCurrentDataIndex(currentIdx);
+ de.NotifyUpdate(currentIdx, (State)state);
+ }
+ }
+
+ /// <summary>
+ /// Requests edit to editor application.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/datasharing</privilege>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when the application does not have privilege to access this method.</exception>
+ /// <example>
+ /// <code>
+ /// public class MyContainer : EditablesContainer {
+ /// public MyContainer() : base()
+ /// {
+ /// }
+ /// protected override void OnEditReady(string editorId)
+ /// {
+ /// this.RequestEdit();
+ /// }
+ /// }
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public void RequestEdit()
+ {
+ Log.Debug(_logTag, "request edit");
+ ComplicationError ret;
+
+ Interop.WatchfaceComplication.GetEditableContainer(out _container);
+ if (_container == IntPtr.Zero)
+ {
+ ErrorFactory.ThrowException(ComplicationError.EditNotReady, "Editor not ready");
+ }
+
+ if (_editableUpdatedCallback == null)
+ _editableUpdatedCallback = new Interop.WatchfaceComplication.EditableUpdateRequestedCallback(EditableUpdatedCallback);
+
+ foreach (Complication comp in _compList)
+ {
+ IEditable e = comp;
+ IntPtr hi = IntPtr.Zero;
+ if (e.Highlight != null && e.Highlight.Raw != IntPtr.Zero)
+ hi = e.Highlight.Raw;
+ Interop.WatchfaceComplication.AddComplication(_container, e.EditableId, comp._handle, hi);
+ }
+
+ foreach (DesignElement de in _deList)
+ {
+ IEditable e = de;
+ IntPtr candidates;
+ Interop.WatchfaceComplication.CreateCandidatesList(out candidates);
+ foreach (Bundle b in de.Candidates)
+ {
+ Interop.WatchfaceComplication.AddCandidatesListItem(candidates, b.SafeBundleHandle);
+ }
+
+ IntPtr hi = IntPtr.Zero;
+ if (e.Highlight != null && e.Highlight.Raw != IntPtr.Zero)
+ hi = e.Highlight.Raw;
+ Interop.WatchfaceComplication.AddDesignElement(_container, e.EditableId, e.GetCurrentDataIndex(), candidates, hi, e.Name);
+ Log.Debug(_logTag, "Add design element done :" + e.Name);
+ }
+
+ ret = Interop.WatchfaceComplication.RequestEdit(_container, _editableUpdatedCallback, IntPtr.Zero);
+ if (ret != ComplicationError.None)
+ {
+ ErrorFactory.ThrowException(ret, "Request edit fail");
+ }
+ }
+
+ /// <summary>
+ /// Overrides this method if you want to handle the behavior when the editor is ready to edit.
+ /// </summary>
+ /// <param name="editorId">The appid of ready to edit editor.</param>
+ /// <since_tizen> 6 </since_tizen>
+ protected abstract void OnEditReady(string editorId);
+
+ /// <summary>
+ /// Loads the editable's current data.
+ /// </summary>
+ /// <returns>The editable's latest data that selected by editor.</returns>
+ /// <exception cref="ArgumentException">Thrown when some parameter are invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
+ /// <remarks>
+ /// This API loads editable's last current data which is updated by editor application.
+ /// </remarks>
+ /// <param name="editableId">The id of the editable.</param>
+ /// <example>
+ /// <code>
+ /// internal void InitEditables()
+ /// {
+ /// _container = new MyContainer();
+ /// Bundle curData = EditablesContainer.LoadCurrentData(_colorEditId);
+ /// List<Bundle> candidatesList = new List<Bundle>();
+ /// int curIdx = 0;
+ /// int i = 0;
+ /// foreach (string str in _colorArr)
+ /// {
+ /// Bundle data = new Bundle();
+ /// data.AddItem(_colorKey, str);
+ /// candidatesList.Add(data);
+ /// if (curData != null && curData.GetItem(_colorKey) != null
+ /// && curData.GetItem(_colorKey).Equals(str))
+ /// {
+ /// curIdx = i;
+ /// }
+ /// i++;
+ /// }
+ /// ColorDesign colorEdit = new ColorDesign(candidatesList, curIdx, "COLOR", _complicationBtn);
+ /// colorEdit.Highlight = new Highlight(ShapeType.Circle, 0, 40, 10, 10);
+ /// _container.Add(colorEdit, _colorEditId);
+ /// }
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public static Bundle LoadCurrentData(int editableId)
+ {
+ SafeBundleHandle handle;
+ ComplicationError err = Interop.WatchfaceComplication.LoadCurrentData(editableId, out handle);
+ if (err == ComplicationError.None)
+ return new Bundle(handle);
+
+ return null;
+ }
+
+ /// <summary>
+ /// Releases the unmanaged resources used by the EditablesContainer class specifying whether to perform a normal dispose operation.
+ /// </summary>
+ /// <param name="disposing">true for a normal dispose operation; false to finalize the handle.</param>
+ /// <since_tizen> 3 </since_tizen>
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ Interop.WatchfaceComplication.RemoveEditReadyCallback(EditReady);
+ _disposed = true;
+ }
+ }
+
+ /// <summary>
+ /// Releases all resources used by the EditablesContainer class.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ };
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ */
+
+using System;
+using System.Runtime.CompilerServices;
+
+namespace Tizen.Applications.WatchfaceComplication
+{
+ internal static class ErrorFactory
+ {
+ private const string LogTag = "WatchfaceComplication";
+
+ internal static void ThrowException(ComplicationError errorCode, string errorMessage = null,
+ [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0)
+ {
+ Log.Error(LogTag, $"{memberName}({lineNumber.ToString()}) : {filePath}");
+ switch (errorCode)
+ {
+ case ComplicationError.None:
+ return;
+ case ComplicationError.OutOfMemory:
+ case ComplicationError.IO:
+ case ComplicationError.NoData:
+ case ComplicationError.DB:
+ case ComplicationError.DBus:
+ case ComplicationError.EditNotReady:
+ case ComplicationError.ExistID:
+ case ComplicationError.NotExist:
+ throw new InvalidOperationException(string.IsNullOrEmpty(errorMessage) ? "error code : " + errorCode.ToString() :
+ $"{errorMessage} - {errorCode}");
+ case ComplicationError.InvalidParam:
+ Log.Error(LogTag, "Invalid parameter : " + errorMessage);
+ throw new ArgumentException(string.IsNullOrEmpty(errorMessage) ? "Invalid parameter" : "Invalid parameter : " + errorMessage);
+ case ComplicationError.PermissionDeny:
+ Log.Error(LogTag, "Permission denied : " + errorMessage);
+ throw new UnauthorizedAccessException(string.IsNullOrEmpty(errorMessage) ? "Permission denied" : "Permission denied : " + errorMessage);
+ case ComplicationError.NotSupported:
+ Log.Error(LogTag, "Not supported : " + errorMessage);
+ throw new NotSupportedException(string.IsNullOrEmpty(errorMessage) ? "Not supported" : "Not supported : " + errorMessage);
+ default:
+ Log.Error(LogTag, $"Unknown error : {errorMessage} - {errorCode}");
+ throw new InvalidOperationException(string.IsNullOrEmpty(errorMessage) ? "Unknown error : " + errorCode.ToString() :
+ $"Unknown error : {errorMessage} - {errorCode}");
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Applications.WatchfaceComplication
+{
+ /// <summary>
+ /// Enumeration for the complication event type.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ [Flags]
+ public enum EventTypes
+ {
+ /// <summary>
+ /// The complication event none.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ EventNone = 0x01,
+ /// <summary>
+ /// The complication event tap.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ EventTap = 0x02,
+ /// <summary>
+ /// The complication event double tap.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ EventDoubleTap = 0x04
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Applications.WatchfaceComplication
+{
+ /// <summary>
+ /// Represents the Highlight class for the editable.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public class Highlight
+ {
+ private IntPtr _raw = IntPtr.Zero;
+ private int _x;
+ private int _y;
+ private int _w;
+ private int _h;
+ private ShapeType _type;
+
+ /// <summary>
+ /// Initializes the Highlight class.
+ /// </summary>
+ /// <param name="type">The highlight shape type.</param>
+ /// <param name="x">The highlight geometry x.</param>
+ /// <param name="y">The highlight geometry y.</param>
+ /// <param name="w">The highlight geometry w.</param>
+ /// <param name="h">The highlight geometry h.</param>
+ /// <exception cref="ArgumentException">Thrown when some parameter are invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public Highlight(ShapeType type, int x, int y, int w, int h)
+ {
+ _type = type;
+ _x = x;
+ _y = y;
+ _w = w;
+ _h = h;
+ }
+
+ /// <summary>
+ /// Destructor of the Highlight class.
+ /// </summary>
+ ~Highlight()
+ {
+ Interop.WatchfaceComplication.DestroyHighlight(_raw);
+ }
+
+ internal IntPtr Raw
+ {
+ get
+ {
+ ComplicationError ret;
+ if (_raw == IntPtr.Zero)
+ {
+ ret = Interop.WatchfaceComplication.CreateHighlight(out _raw);
+ if (ret != ComplicationError.None)
+ {
+ ErrorFactory.ThrowException(ret, "Fail to create Highlight");
+ }
+ }
+
+ ret = Interop.WatchfaceComplication.SetHighlightGeometry(_raw, _x, _y, _w, _h);
+ if (ret != ComplicationError.None)
+ {
+ ErrorFactory.ThrowException(ret, "Fail to set Highlight geometry");
+ }
+ ret = Interop.WatchfaceComplication.SetHighlightShapeType(_raw, _type);
+ if (ret != ComplicationError.None)
+ {
+ ErrorFactory.ThrowException(ret, "Fail to set Highlight type");
+ }
+ return _raw;
+ }
+ }
+
+ /// <summary>
+ /// The x coordinate.
+ /// </summary>
+ /// <exception cref="ArgumentException">Thrown when some parameter are invalid.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public int X
+ {
+ get
+ {
+ return _x;
+ }
+ set
+ {
+ if (value < 0)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam, "invalid x value (" + value + ")");
+ _x = value;
+ }
+ }
+
+ /// <summary>
+ /// The y coordinate.
+ /// </summary>
+ /// <exception cref="ArgumentException">Thrown when some parameter are invalid.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public int Y
+ {
+ get
+ {
+ return _y;
+ }
+ set
+ {
+ if (value < 0)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam, "invalid y value (" + value + ")");
+ _y = value;
+ }
+ }
+
+ /// <summary>
+ /// The width of editable.
+ /// </summary>
+ /// <exception cref="ArgumentException">Thrown when some parameter are invalid.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public int W
+ {
+ get
+ {
+ return _w;
+ }
+ set
+ {
+ if (value < 0)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam, "invalid w value (" + value + ")");
+ _w = value;
+ }
+ }
+
+ /// <summary>
+ /// The height of editable.
+ /// </summary>
+ /// <exception cref="ArgumentException">Thrown when some parameter are invalid.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public int H
+ {
+ get
+ {
+ return _h;
+ }
+ set
+ {
+ if (value < 0)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam, "invalid h value (" + value + ")");
+ _h = value;
+ }
+ }
+
+ /// <summary>
+ /// The shape of editable.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public ShapeType ShapeType
+ {
+ get
+ {
+ return _type;
+ }
+ set
+ {
+ _type = value;
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+
+namespace Tizen.Applications.WatchfaceComplication
+{
+ /// <summary>
+ /// Represents the Editable interface.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public interface IEditable
+ {
+ /// <summary>
+ /// The information about editable's ID.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ int EditableId { get; set; }
+
+ /// <summary>
+ /// The information about editable's name.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ string Name { get; set; }
+
+ /// <summary>
+ /// The information about editable's geometry.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ Highlight Highlight { get; set; }
+
+ /// <summary>
+ /// The information about editable's current data index.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ int GetCurrentDataIndex();
+
+ /// <summary>
+ /// The information about editable's current data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ Bundle GetCurrentData();
+ }
+}
\ No newline at end of file
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Applications.WatchfaceComplication
+{
+ /// <summary>
+ /// Represents the IconData class for the Icon type complication.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public class IconData : ComplicationData
+ {
+ /// <summary>
+ /// Initializes the IconData class.
+ /// </summary>
+ /// <param name="iconPath">The icon path.</param>
+ /// <param name="extraData">The extra data.</param>
+ /// <exception cref="ArgumentException">Thrown when parameter is invalid.</exception>
+ /// <example>
+ /// <code>
+ /// protected override ComplicationData OnDataUpdateRequested(string reqestAppId, ComplicationTypes type, Bundle contextData)
+ /// {
+ /// if (type == ComplicationTypes.Icon)
+ /// {
+ /// return new IconData("Icon", "extra");
+ /// }
+ /// else if (type == ComplicationTypes.LongText)
+ /// {
+ /// return new LongTextData("longlong", "icon path", "title", null);
+ /// }
+ /// }
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public IconData(string iconPath, string extraData)
+ {
+ if (iconPath == null)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam, "icon path can not be null");
+ Type = ComplicationTypes.Icon;
+ IconPath = iconPath;
+ ExtraData = extraData;
+ }
+
+ /// <summary>
+ /// The icon path data.
+ /// </summary>
+ /// <exception cref="ArgumentException">Thrown when try to set invalid value.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public new string IconPath
+ {
+ get
+ {
+ return base.IconPath;
+ }
+ set
+ {
+ if (value == null)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam, "icon path can not be null");
+ base.IconPath = value;
+ }
+ }
+
+ /// <summary>
+ /// The extra data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public new string ExtraData
+ {
+ get
+ {
+ return base.ExtraData;
+ }
+ set
+ {
+ base.ExtraData = value;
+ }
+ }
+
+ /// <summary>
+ /// The information about the screen reader text of complication data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public new string ScreenReaderText
+ {
+ get
+ {
+ return base.ScreenReaderText;
+ }
+ set
+ {
+ base.ScreenReaderText = value;
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Applications.WatchfaceComplication
+{
+ /// <summary>
+ /// Represents the ImageData class for the Image type complication.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public class ImageData : ComplicationData
+ {
+ /// <summary>
+ /// Initializes the ImageData class.
+ /// </summary>
+ /// <param name="imagePath">The image path.</param>
+ /// <param name="extraData">The extra data.</param>
+ /// <exception cref="ArgumentException">Thrown when parameter is invalid.</exception>
+ /// <example>
+ /// <code>
+ /// protected override ComplicationData OnDataUpdateRequested(string reqestAppId, ComplicationTypes type, Bundle contextData)
+ /// {
+ /// if (type == ComplicationTypes.Image)
+ /// {
+ /// return new ImageData("Image path", "extra");
+ /// }
+ /// else if (type == ComplicationTypes.LongText)
+ /// {
+ /// return new LongTextData("longlong", "icon path", "title", null);
+ /// }
+ /// }
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public ImageData(string imagePath, string extraData)
+ {
+ if (imagePath == null)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam, "image path can not be null");
+ Type = ComplicationTypes.Image;
+ ImagePath = imagePath;
+ ExtraData = extraData;
+ }
+
+ /// <summary>
+ /// The image path data.
+ /// </summary>
+ /// <exception cref="ArgumentException">Thrown when try to set invalid value.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public new string ImagePath
+ {
+ get
+ {
+ return base.ImagePath;
+ }
+ set
+ {
+ if (value == null)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam, "image path can not be null");
+ base.ImagePath = value;
+ }
+ }
+
+ /// <summary>
+ /// The extra data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public new string ExtraData
+ {
+ get
+ {
+ return base.ExtraData;
+ }
+ set
+ {
+ base.ExtraData = value;
+ }
+ }
+
+ /// <summary>
+ /// The information about the screen reader text of complication data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public new string ScreenReaderText
+ {
+ get
+ {
+ return base.ScreenReaderText;
+ }
+ set
+ {
+ base.ScreenReaderText = value;
+ }
+ }
+ }
+}
--- /dev/null
+internal static partial class Interop
+{
+ internal static partial class Libraries
+ {
+ public const string Complication = "libwatchface-complication.so.1";
+ public const string ComplicationProvider = "libwatchface-complication-provider.so.1";
+ }
+}
\ No newline at end of file
--- /dev/null
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+using Tizen.Applications;
+using Tizen;
+using Tizen.Applications.WatchfaceComplication;
+
+internal static partial class Interop
+{
+ internal static partial class WatchfaceComplication
+ {
+ internal enum ErrorType : int
+ {
+ None = Tizen.Internals.Errors.ErrorCode.None,
+ OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+ InvalidParam = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+ IO = Tizen.Internals.Errors.ErrorCode.IoError,
+ NoData = Tizen.Internals.Errors.ErrorCode.NoData,
+ PermissionDeny = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
+ NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,
+ DB = -0x02FC0000 | 0x1,
+ DBus = -0x02FC0000 | 0x2,
+ EditNotReady = -0x02FC0000 | 0x3,
+ ExistID = -0x02FC0000 | 0x4,
+ NotExist = -0x02FC0000 | 0x5,
+ NotAvailable = -0x02FC0000 | 0x6
+ }
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_highlight_create")]
+ internal static extern ComplicationError CreateHighlight(out IntPtr highlightHandle);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_highlight_destroy")]
+ internal static extern ComplicationError DestroyHighlight(IntPtr highlightHandle);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_highlight_set_geometry")]
+ internal static extern ComplicationError SetHighlightGeometry(IntPtr highlightHandle, int x, int y, int w, int h);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_highlight_get_geometry")]
+ internal static extern ComplicationError GetHighlightGeometry(IntPtr highlightHandle, out int x, out int y, out int w, out int h);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_highlight_set_shape_type")]
+ internal static extern ComplicationError SetHighlightShapeType(IntPtr highlightHandle, ShapeType shapeType);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_highlight_get_shape_type")]
+ internal static extern ComplicationError GetHighlightShapeType(IntPtr highlightHandle, out ShapeType shapeType);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_get_highlight")]
+ internal static extern ComplicationError GetHighlight(IntPtr handle, out IntPtr highlightHandle);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_create")]
+ internal static extern ComplicationError CreateComplication(int complicationId,
+ string defaultProviderId, ComplicationTypes defaultType, int supportTypes, int supportEventTypes, out IntPtr handle);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_destroy")]
+ internal static extern ComplicationError Destroy(IntPtr handle);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_get_current_provider_id")]
+ internal static extern ComplicationError GetCurrentProviderId(IntPtr handle, out string curProviderId);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_get_current_type")]
+ internal static extern ComplicationError GetCurrentType(IntPtr handle, out ComplicationTypes type);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_add_updated_cb")]
+ internal static extern ComplicationError AddUpdatedCallback(IntPtr handle, ComplicationUpdatedCallback callback, ComplicationErrorCallback errCallback, IntPtr userData);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_remove_updated_cb")]
+ internal static extern ComplicationError RemoveUpdatedCallback(IntPtr handle, ComplicationUpdatedCallback callback);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_send_update_request")]
+ internal static extern ComplicationError SendUpdateRequest(IntPtr handle);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_data_get_type")]
+ internal static extern ComplicationError GetDataType(SafeBundleHandle handle, out ComplicationTypes type);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_data_get_short_text")]
+ internal static extern ComplicationError GetShortText(SafeBundleHandle handle, out string shortText);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_data_get_long_text")]
+ internal static extern ComplicationError GetLongText(SafeBundleHandle handle, out string longText);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_data_get_title")]
+ internal static extern ComplicationError GetTitle(SafeBundleHandle handle, out string title);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_data_get_timestamp")]
+ internal static extern ComplicationError GetTimestamp(SafeBundleHandle handle, out long timestamp);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_data_get_image_path")]
+ internal static extern ComplicationError GetImagePath(SafeBundleHandle handle, out string imagePath);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_data_get_ranged_value")]
+ internal static extern ComplicationError GetRangedValue(SafeBundleHandle handle, out double currentValue, out double minValue, out double maxValue);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_data_get_icon_path")]
+ internal static extern ComplicationError GetIconPath(SafeBundleHandle handle, out string iconPath);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_data_get_extra_data")]
+ internal static extern ComplicationError GetExtraData(SafeBundleHandle handle, out string extraData);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_data_get_screen_reader_text")]
+ internal static extern ComplicationError GetScreenReaderText(SafeBundleHandle handle, out string screenReaderText);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_transfer_event")]
+ internal static extern ComplicationError TransferEvent(IntPtr handle, EventTypes e);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_allowed_list_create")]
+ internal static extern ComplicationError CreateAllowedList(out IntPtr allowedList);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_allowed_list_destroy")]
+ internal static extern ComplicationError DestroyAllowedList(IntPtr allowedList);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_allowed_list_add")]
+ internal static extern ComplicationError AddAllowedList(IntPtr allowedList, string providerId, int types);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_allowed_list_delete")]
+ internal static extern ComplicationError DeleteAllowedList(IntPtr allowedList, string providerId);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_allowed_list_get_nth")]
+ internal static extern ComplicationError GetNthAllowedListItem(IntPtr allowedList, int idx, out string providerId, out int types);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_allowed_list_apply")]
+ internal static extern ComplicationError ApplyAllowedList(IntPtr handle, IntPtr allowedList);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_complication_allowed_list_clear")]
+ internal static extern ComplicationError ClearAllowedList(IntPtr handle);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_add_edit_ready_cb")]
+ internal static extern ComplicationError AddEditReadyCallback(EditReadyCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_remove_edit_ready_cb")]
+ internal static extern ComplicationError RemoveEditReadyCallback(EditReadyCallback callback);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_get_current_data_idx")]
+ internal static extern ComplicationError GetCurrentIdx(IntPtr handle, out int curIdx);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_get_current_data")]
+ internal static extern ComplicationError GetCurrentData(IntPtr handle, out SafeBundleHandle data);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_get_nth_data")]
+ internal static extern ComplicationError GetNthData(IntPtr handle, out SafeBundleHandle data);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_get_editable_id")]
+ internal static extern ComplicationError GetEditableId(IntPtr handle, out int editableId);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_get_editable_name")]
+ internal static extern ComplicationError GetEditableName(IntPtr handle, out string editableName);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_set_editable_name")]
+ internal static extern ComplicationError SetEditableName(IntPtr handle, string editableName);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_add_complication")]
+ internal static extern ComplicationError AddComplication(IntPtr container, int editId, IntPtr comp, IntPtr highlight);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_add_design_element")]
+ internal static extern ComplicationError AddDesignElement(IntPtr container, int editId, int curDataIdx, IntPtr listHandle, IntPtr highlight, string editableName);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_candidates_list_create")]
+ internal static extern ComplicationError CreateCandidatesList(out IntPtr listHandle);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_candidates_list_add")]
+ internal static extern ComplicationError AddCandidatesListItem(IntPtr listHandle, SafeBundleHandle candidate);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_candidates_list_destroy")]
+ internal static extern ComplicationError DestroyCandidatesList(IntPtr listHandle);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_request_edit")]
+ internal static extern ComplicationError RequestEdit(IntPtr container, EditableUpdateRequestedCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_container_get")]
+ internal static extern ComplicationError GetEditableContainer(out IntPtr container);
+
+ [DllImport(Libraries.Complication, EntryPoint = "watchface_editable_load_current_data")]
+ internal static extern ComplicationError LoadCurrentData(int editableId, out SafeBundleHandle data);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_add_update_requested_cb")]
+ internal static extern ComplicationError AddUpdateRequestedCallback(string providerId, UpdateRequestedCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_remove_update_requested_cb")]
+ internal static extern ComplicationError RemoveUpdateRequestedCallback(string providerId, UpdateRequestedCallback callback);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_data_set_type")]
+ internal static extern ComplicationError ProviderSetDataType(IntPtr sharedData, ComplicationTypes type);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_data_set_title")]
+ internal static extern ComplicationError ProviderSetTitle(IntPtr sharedData, string title);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_data_set_short_text")]
+ internal static extern ComplicationError ProviderSetShortText(IntPtr sharedData, string shortText);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_data_set_long_text")]
+ internal static extern ComplicationError ProviderSetLongText(IntPtr sharedData, string longText);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_data_set_timestamp")]
+ internal static extern ComplicationError ProviderSetTimestamp(IntPtr sharedData, long timestamp);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_data_set_image_path")]
+ internal static extern ComplicationError ProviderSetImagePath(IntPtr sharedData, string imagePath);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_data_set_ranged_value")]
+ internal static extern ComplicationError ProviderSetRangedValue(IntPtr sharedData, double currentValue, double minValue, double maxValue);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_data_set_icon_path")]
+ internal static extern ComplicationError ProviderSetIconPath(IntPtr sharedData, string iconPath);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_data_set_extra_data")]
+ internal static extern ComplicationError ProviderSetExtraData(IntPtr sharedData, string extraData);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_data_set_screen_reader_text")]
+ internal static extern ComplicationError ProviderSetScreenReaderText(IntPtr sharedData, string screenReaderText);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_data_is_valid")]
+ internal static extern ComplicationError ProviderSharedDataIsValid(IntPtr sharedData, out bool isVaild);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_notify_update")]
+ internal static extern ComplicationError NotifyUpdate(string updatedProviderId);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_event_get_type")]
+ internal static extern ComplicationError GetEventType(SafeAppControlHandle handle, out EventTypes type);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_event_get_provider_id")]
+ internal static extern ComplicationError GetEventProviderId(SafeAppControlHandle handle, out string providerId);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_event_get_complication_type")]
+ internal static extern ComplicationError GetEventComplicationType(SafeAppControlHandle handle, out ComplicationTypes type);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_event_get_context")]
+ internal static extern ComplicationError GetEventContext(SafeAppControlHandle handle, out SafeBundleHandle context);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_setup_reply_to_editor")]
+ internal static extern ComplicationError SetupReplyToEditor(SafeAppControlHandle handle, SafeBundleHandle context);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_setup_is_editing")]
+ internal static extern ComplicationError IsSetupEditing(SafeAppControlHandle handle, out bool isEditing);
+
+ [DllImport(Libraries.ComplicationProvider, EntryPoint = "watchface_complication_provider_setup_get_context")]
+ internal static extern ComplicationError GetSetupContext(SafeAppControlHandle handle, out SafeBundleHandle context);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void EditReadyCallback(IntPtr handle, string editorAppId, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void UpdateRequestedCallback(string providerId, string reqAppId, ComplicationTypes type,
+ IntPtr context, IntPtr sharedData, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void ComplicationUpdatedCallback(int complicationId,
+ string providerId, ComplicationTypes type, IntPtr data, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void ComplicationErrorCallback(int complicationId,
+ string providerId, ComplicationTypes type, ComplicationError error, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void EditableUpdateRequestedCallback(IntPtr handle, int selectedIdx,
+ int state, IntPtr userData);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Applications.WatchfaceComplication
+{
+ /// <summary>
+ /// Represents the LongTextData class for the LongText type complication.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public class LongTextData : ComplicationData
+ {
+ /// <summary>
+ /// Initializes the LongTextData class.
+ /// </summary>
+ /// <param name="longText">The long text.</param>
+ /// <param name="iconPath">The icon path.</param>
+ /// <param name="title">The title.</param>
+ /// <param name="extraData">The extra data.</param>
+ /// <exception cref="ArgumentException">Thrown when parameter is invalid.</exception>
+ /// <example>
+ /// <code>
+ /// protected override ComplicationData OnDataUpdateRequested(string reqestAppId, ComplicationTypes type, Bundle contextData)
+ /// {
+ /// if (type == ComplicationTypes.ShortText)
+ /// {
+ /// return new ShortTextData("short", "icon path", "title", "extra");
+ /// }
+ /// else if (type == ComplicationTypes.LongText)
+ /// {
+ /// return new LongTextData("longlong", "icon path", "title", null);
+ /// }
+ /// }
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public LongTextData(string longText, string iconPath, string title, string extraData)
+ {
+ if (longText == null)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam, "fail to create short text");
+ Type = ComplicationTypes.LongText;
+ LongText = longText;
+ IconPath = iconPath;
+ Title = title;
+ ExtraData = extraData;
+ }
+
+ /// <summary>
+ /// The long text data.
+ /// </summary>
+ /// <exception cref="ArgumentException">Thrown when try to set invalid value.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public new string LongText
+ {
+ get
+ {
+ return base.LongText;
+ }
+ set
+ {
+ if (value == null)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam, "fail to create short text");
+ base.LongText = value;
+ }
+ }
+
+ /// <summary>
+ /// The icon path data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public new string IconPath
+ {
+ get
+ {
+ return base.IconPath;
+ }
+ set
+ {
+ base.IconPath = value;
+ }
+ }
+
+ /// <summary>
+ /// The title data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public new string Title
+ {
+ get
+ {
+ return base.Title;
+ }
+ set
+ {
+ base.Title = value;
+ }
+ }
+
+ /// <summary>
+ /// The extra data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public new string ExtraData
+ {
+ get
+ {
+ return base.ExtraData;
+ }
+ set
+ {
+ base.ExtraData = value;
+ }
+ }
+
+ /// <summary>
+ /// The information about the screen reader text of complication data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public new string ScreenReaderText
+ {
+ get
+ {
+ return base.ScreenReaderText;
+ }
+ set
+ {
+ base.ScreenReaderText = value;
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Applications.WatchfaceComplication
+{
+ /// <summary>
+ /// Represents the RangedValueData class for the RangedValue type complication.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public class RangedValueData : ComplicationData
+ {
+ /// <summary>
+ /// Initializes the RangedValueData class.
+ /// </summary>
+ /// <param name="currentValue">The current value.</param>
+ /// <param name="minValue">The minimum value.</param>
+ /// <param name="maxValue">The max value.</param>
+ /// <param name="shortText">The short text.</param>
+ /// <param name="iconPath">The icon path.</param>
+ /// <param name="title">The title.</param>
+ /// <param name="extraData">The extra data.</param>
+ /// <exception cref="ArgumentException">Thrown when parameter is invalid.</exception>
+ /// <example>
+ /// <code>
+ /// protected override ComplicationData OnDataUpdateRequested(string reqestAppId, ComplicationTypes type, Bundle contextData)
+ /// {
+ /// if (type == ComplicationTypes.RangedValue)
+ /// {
+ /// return new RangedValueData(50, 0, 100, "short", "icon path", "title", "extra");
+ /// }
+ /// else if (type == ComplicationTypes.LongText)
+ /// {
+ /// return new LongTextData("longlong", "icon path", "title", null);
+ /// }
+ /// }
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public RangedValueData(double currentValue, double minValue, double maxValue, string shortText, string iconPath, string title, string extraData)
+ {
+ if (minValue > maxValue || currentValue < minValue || currentValue > maxValue)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam, "Invalid value range min(" + minValue + "), cur(" + currentValue + "), max(" + maxValue + ")");
+ Type = ComplicationTypes.RangedValue;
+ RangeCurrent = currentValue;
+ RangeMin = minValue;
+ RangeMax = maxValue;
+ ShortText = shortText;
+ IconPath = iconPath;
+ Title = title;
+ ExtraData = extraData;
+ }
+
+ /// <summary>
+ /// The information about the current range value of complication data.
+ /// </summary>
+ /// <exception cref="ArgumentException">Thrown when try to set invalid value.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public new double RangeCurrent
+ {
+ get
+ {
+ return base.RangeCurrent;
+ }
+ set
+ {
+ if (value > base.RangeMax)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam,
+ "invalid min(" + value + "), current value can not bigger than max(" + base.RangeMax + ")");
+ if (value < base.RangeMin)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam,
+ "invalid min(" + value + "), min value can not smaller than min(" + base.RangeMin + ")");
+ base.RangeCurrent = value;
+ }
+ }
+
+ /// <summary>
+ /// The information about the min range value of complication data.
+ /// </summary>
+ /// <exception cref="ArgumentException">Thrown when try to set invalid value.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public new double RangeMin
+ {
+ get
+ {
+ return base.RangeMin;
+ }
+ set
+ {
+ if (value > base.RangeCurrent)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam,
+ "invalid min(" + value + "), min value can not bigger than current(" + base.RangeCurrent + ")");
+ base.RangeMin = value;
+ }
+ }
+
+ /// <summary>
+ /// The information about the max range value of complication data.
+ /// </summary>
+ /// <exception cref="ArgumentException">Thrown when try to set invalid value.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public new double RangeMax
+ {
+ get
+ {
+ return base.RangeMax;
+ }
+ set
+ {
+ if (value < base.RangeCurrent)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam,
+ "invalid min(" + value + "), min value can not smaller than current(" + base.RangeCurrent + ")");
+ base.RangeMax = value;
+ }
+ }
+
+ /// <summary>
+ /// The short text data.
+ /// </summary>
+ /// <exception cref="ArgumentException">Thrown when try to set invalid value.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public new string ShortText
+ {
+ get
+ {
+ return base.ShortText;
+ }
+ set
+ {
+ if (value == null)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam, "fail to create short text");
+ base.ShortText = value;
+ }
+ }
+
+ /// <summary>
+ /// The icon path data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public new string IconPath
+ {
+ get
+ {
+ return base.IconPath;
+ }
+ set
+ {
+ base.IconPath = value;
+ }
+ }
+
+ /// <summary>
+ /// The title data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public new string Title
+ {
+ get
+ {
+ return base.Title;
+ }
+ set
+ {
+ base.Title = value;
+ }
+ }
+
+ /// <summary>
+ /// The extra data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public new string ExtraData
+ {
+ get
+ {
+ return base.ExtraData;
+ }
+ set
+ {
+ base.ExtraData = value;
+ }
+ }
+
+ /// <summary>
+ /// The information about the screen reader text of complication data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public new string ScreenReaderText
+ {
+ get
+ {
+ return base.ScreenReaderText;
+ }
+ set
+ {
+ base.ScreenReaderText = value;
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ */
+
+using System;
+
+namespace Tizen.Applications.WatchfaceComplication
+{
+ /// <summary>
+ /// Represents the Editable shape type.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public enum ShapeType {
+ /// <summary>
+ /// Shape circle.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ Circle,
+ /// <summary>
+ /// Shape rectangle.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ Rectangle
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Applications.WatchfaceComplication
+{
+ /// <summary>
+ /// Represents the ShortTextData class for the ShortText type complication.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public class ShortTextData : ComplicationData
+ {
+ /// <summary>
+ /// Initializes the ShortTextData class.
+ /// </summary>
+ /// <param name="shortText">The short text.</param>
+ /// <param name="iconPath">The icon path.</param>
+ /// <param name="title">The title.</param>
+ /// <param name="extraData">The extra data.</param>
+ /// <exception cref="ArgumentException">Thrown when parameter is invalid.</exception>
+ /// <example>
+ /// <code>
+ /// protected override ComplicationData OnDataUpdateRequested(string reqestAppId, ComplicationTypes type, Bundle contextData)
+ /// {
+ /// if (type == ComplicationTypes.ShortText)
+ /// {
+ /// return new ShortTextData("short", "icon path", "title", "extra");
+ /// }
+ /// else if (type == ComplicationTypes.LongText)
+ /// {
+ /// return new LongTextData("longlong", "icon path", "title", null);
+ /// }
+ /// }
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public ShortTextData(string shortText, string iconPath, string title, string extraData)
+ {
+ if (shortText == null)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam, "fail to create short text");
+ Type = ComplicationTypes.ShortText;
+ ShortText = shortText;
+ IconPath = iconPath;
+ Title = title;
+ ExtraData = extraData;
+ }
+
+ /// <summary>
+ /// The short text data.
+ /// </summary>
+ /// <exception cref="ArgumentException">Thrown when try to set invalid value.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public new string ShortText
+ {
+ get
+ {
+ return base.ShortText;
+ }
+ set
+ {
+ if (value == null)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam, "fail to create short text");
+ base.ShortText = value;
+ }
+ }
+
+ /// <summary>
+ /// The icon path data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public new string IconPath
+ {
+ get
+ {
+ return base.IconPath;
+ }
+ set
+ {
+ base.IconPath = value;
+ }
+ }
+
+ /// <summary>
+ /// The title data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public new string Title
+ {
+ get
+ {
+ return base.Title;
+ }
+ set
+ {
+ base.Title = value;
+ }
+ }
+
+ /// <summary>
+ /// The extra data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public new string ExtraData
+ {
+ get
+ {
+ return base.ExtraData;
+ }
+ set
+ {
+ base.ExtraData = value;
+ }
+ }
+
+ /// <summary>
+ /// The information about the screen reader text of complication data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public new string ScreenReaderText
+ {
+ get
+ {
+ return base.ScreenReaderText;
+ }
+ set
+ {
+ base.ScreenReaderText = value;
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Applications.WatchfaceComplication
+{
+ /// <summary>
+ /// Represents the Editable state.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public enum State
+ {
+ /// <summary>
+ /// The editable editing is complete.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ Complete,
+ /// <summary>
+ /// The editable editing is on going now.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ OnGoing,
+
+ /// <summary>
+ /// The editable editing is canceled.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ Cancel
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Applications.WatchfaceComplication
+{
+ /// <summary>
+ /// Represents the TimeData class for the Time type complication.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public class TimeData : ComplicationData
+ {
+ /// <summary>
+ /// Initializes the TimeData class.
+ /// </summary>
+ /// <param name="timestamp">The timestamp value.</param>
+ /// <param name="iconPath">The icon path.</param>
+ /// <param name="extraData">The extra data.</param>
+ /// <exception cref="ArgumentException">Thrown when parameter is invalid.</exception>
+ /// <example>
+ /// <code>
+ /// protected override ComplicationData OnDataUpdateRequested(string reqestAppId, ComplicationTypes type, Bundle contextData)
+ /// {
+ /// if (type == ComplicationTypes.Time)
+ /// {
+ /// return new TimeData((Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds, "icon path", "extra");
+ /// }
+ /// else if (type == ComplicationTypes.LongText)
+ /// {
+ /// return new LongTextData("longlong", "icon path", "title", null);
+ /// }
+ /// }
+ /// </code>
+ /// </example>
+ /// <since_tizen> 6 </since_tizen>
+ public TimeData(long timestamp, string iconPath, string extraData)
+ {
+ if (timestamp < 0)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam, "Invalid value time(" + timestamp + ")");
+ Type = ComplicationTypes.Time;
+ Timestamp = timestamp;
+ IconPath = iconPath;
+ ExtraData = extraData;
+ }
+
+ /// <summary>
+ /// The information about the timestamp of complication data.
+ /// </summary>
+ /// <exception cref="ArgumentException">Thrown when try to set invalid value.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public new long Timestamp
+ {
+ get
+ {
+ return base.Timestamp;
+ }
+ set
+ {
+ if (value < 0)
+ ErrorFactory.ThrowException(ComplicationError.InvalidParam, "invalid time(" + value + ")");
+ base.Timestamp = value;
+ }
+ }
+
+ /// <summary>
+ /// The icon path data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public new string IconPath
+ {
+ get
+ {
+ return base.IconPath;
+ }
+ set
+ {
+ base.IconPath = value;
+ }
+ }
+
+ /// <summary>
+ /// The extra data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public new string ExtraData
+ {
+ get
+ {
+ return base.ExtraData;
+ }
+ set
+ {
+ base.ExtraData = value;
+ }
+ }
+
+ /// <summary>
+ /// The information about the screen reader text of complication data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public new string ScreenReaderText
+ {
+ get
+ {
+ return base.ScreenReaderText;
+ }
+ set
+ {
+ base.ScreenReaderText = value;
+ }
+ }
+
+ }
+}
\ No newline at end of file