From b54293b94154997f5fbde246bd655808c85aae2a Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Tue, 27 Nov 2018 15:23:18 +0900 Subject: [PATCH] [WatchfaceComplication] WatchfaceComplication basic implementation (#520) * Initial commit Signed-off-by: hyunho * Add provider imeplementation Signed-off-by: hyunho * Add editable implementation Signed-off-by: hyunho * Fix api signature and doxygen Signed-off-by: hyunho * Add highlight feature Signed-off-by: hyunho * Modify some functions to static Members does not access instance data and can be marked as static Signed-off-by: hyunho * Replace number with interop from public class Signed-off-by: hyunho * Fix provider set type bug Signed-off-by: hyunho * Modify notify update function to non-static Only instance that listening update data request event can notify update. Signed-off-by: hyunho * Adds destructor for complication, provider Signed-off-by: hyunho * Modify some functions accessibility Signed-off-by: hyunho * Modify highlight implementation Remove unnecessary interop accessment. Signed-off-by: hyunho * Add flags to support types and event types Signed-off-by: hyunho * Remove unnecessary attribute Signed-off-by: hyunho * Remove highlight param from container add func highlight is optional and belong to editable instance so, we don't have to add it every time. Signed-off-by: hyunho * Fix document error Signed-off-by: hyunho * Rename flags enums Signed-off-by: hyunho * Add missing document about exception Signed-off-by: hyunho * Adds suppress finalize for dispose function Signed-off-by: hyunho * Modify proivder's set function to property Provider can access it's data field Signed-off-by: hyunho * Add dispose to provider, container We don't know exact time when GC run. Every class, register callback need dispose function. Signed-off-by: hyunho * Adds apply allowed list API Signed-off-by: hyunho * Add transfer event API Signed-off-by: hyunho * Add screen reader text APIs Signed-off-by: hyunho * Add get current info APIs for Complication Signed-off-by: hyunho * Modify allowed list to property Signed-off-by: hyunho * Add get for editable name property Signed-off-by: hyunho * Throw exception for highlight property Signed-off-by: hyunho * Add set for highlight shapetype property Signed-off-by: hyunho * Modify current data index property to get method We do not need set method and for consistency of code. Signed-off-by: hyunho * Fix doxygen error Signed-off-by: hyunho * Remove return error method Every error case is handled by exception. Signed-off-by: hyunho * Destroy raw complication when object destroyed If we do not destroy raw complication, natvie raw will be leaked Signed-off-by: hyunho * Fix document error Signed-off-by: hyunho * Add privilege document Signed-off-by: hyunho * Fix wrong param Signed-off-by: hyunho * Modify OnDataUpdateRequested Signed-off-by: hyunho * Add license boiler plate Signed-off-by: hyunho * Fix since tizen Signed-off-by: hyunho * Remove duplicate codes Signed-off-by: hyunho * Set type for complication data Signed-off-by: hyunho * Fix set data bug Signed-off-by: hyunho * Fix UpdateSharedData return err bug Signed-off-by: hyunho * Add desc for time data Signed-off-by: hyunho * Fix documentation error Signed-off-by: hyunho --- ...Tizen.Applications.WatchfaceComplication.csproj | 13 + .../Tizen.Applications.WatchfaceComplication.sln | 43 + .../Tizen.Applications/Complication.cs | 912 +++++++++++++++++++++ .../Tizen.Applications/ComplicationData.cs | 248 ++++++ .../Tizen.Applications/ComplicationError.cs | 91 ++ .../Tizen.Applications/ComplicationProvider.cs | 265 ++++++ .../ComplicationProviderSetup.cs | 127 +++ .../Tizen.Applications/ComplicationTypes.cs | 66 ++ .../Tizen.Applications/DesignElement.cs | 219 +++++ .../Tizen.Applications/EditablesContainer.cs | 348 ++++++++ .../Tizen.Applications/ErrorFactory.cs | 60 ++ .../Tizen.Applications/EventTypes.cs | 46 ++ .../Tizen.Applications/Highlight.cs | 184 +++++ .../Tizen.Applications/IEditable.cs | 60 ++ .../Tizen.Applications/IconData.cs | 95 +++ .../Tizen.Applications/ImageData.cs | 111 +++ .../Interop/Interop.Libraries.cs | 8 + .../Interop/Interop.WatchfaceComplication.cs | 256 ++++++ .../Tizen.Applications/LongTextData.cs | 147 ++++ .../Tizen.Applications/RangedValueData.cs | 216 +++++ .../Tizen.Applications/ShapeType.cs | 37 + .../Tizen.Applications/ShortTextData.cs | 147 ++++ .../Tizen.Applications/State.cs | 46 ++ .../Tizen.Applications/TimeData.cs | 130 +++ 24 files changed, 3875 insertions(+) create mode 100755 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications.WatchfaceComplication.csproj create mode 100755 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications.WatchfaceComplication.sln create mode 100644 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/Complication.cs create mode 100755 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationData.cs create mode 100755 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationError.cs create mode 100644 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationProvider.cs create mode 100644 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationProviderSetup.cs create mode 100755 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationTypes.cs create mode 100755 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/DesignElement.cs create mode 100644 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/EditablesContainer.cs create mode 100755 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ErrorFactory.cs create mode 100755 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/EventTypes.cs create mode 100755 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/Highlight.cs create mode 100644 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/IEditable.cs create mode 100755 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/IconData.cs create mode 100644 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ImageData.cs create mode 100755 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/Interop/Interop.Libraries.cs create mode 100755 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/Interop/Interop.WatchfaceComplication.cs create mode 100755 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/LongTextData.cs create mode 100755 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/RangedValueData.cs create mode 100755 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ShapeType.cs create mode 100755 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ShortTextData.cs create mode 100755 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/State.cs create mode 100755 src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/TimeData.cs diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications.WatchfaceComplication.csproj b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications.WatchfaceComplication.csproj new file mode 100755 index 0000000..92acbe9 --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications.WatchfaceComplication.csproj @@ -0,0 +1,13 @@ + + + netstandard2.0 + + + + + + + + + + diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications.WatchfaceComplication.sln b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications.WatchfaceComplication.sln new file mode 100755 index 0000000..980c746 --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications.WatchfaceComplication.sln @@ -0,0 +1,43 @@ + +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 diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/Complication.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/Complication.cs new file mode 100644 index 0000000..3ec7f6c --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/Complication.cs @@ -0,0 +1,912 @@ +/* + * 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 +{ + /// + /// Represents the Complication class for the watch application which using watchface complication. + /// + /// 6 + 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; + + /// + /// Initializes the Complication class. + /// + /// The id of the complication. + /// The complication support types. + /// The complication's support events. + /// The complication's default provider ID. + /// The complication's default type. + /// http://tizen.org/privilege/datasharing + /// http://tizen.org/privilege/packagemanager.info + /// Thrown when the invalid parameter is passed. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// Thrown when the application does not have privilege to access this method. + /// + /// + /// + /// 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); + /// + /// + /// + /// 6 + 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"); + } + } + + /// + /// Destructor of the complication class. + /// + ~Complication() + { + Dispose(true); + } + + /// + /// Gets the support types. + /// + /// 6 + public ComplicationTypes SupportTypes + { + get + { + return _supportTypes; + } + } + + /// + /// Gets the support event types. + /// + /// 6 + public EventTypes SupportEvents + { + get + { + return _supportEvents; + } + } + + /// + /// The information of the editable's highlight. + /// + /// 6 + Highlight IEditable.Highlight + { + get + { + return _highlight; + } + set + { + _highlight = value; + } + } + + + /// + /// The information of specific allowed provider id, support types list for complication + /// + /// 6 + 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); + } + + } + } + + /// + /// The information of the complication's highlight. + /// + /// 6 + public Highlight Highlight + { + get + { + return _highlight; + } + set + { + _highlight = value; + } + } + + /// + /// The information of complication ID. + /// + /// 6 + public int ComplicationId + { + get + { + return _complicationId; + } + } + + /// + /// The information of editable ID. + /// + /// 6 + int IEditable.EditableId + { + get + { + return _editableId; + } + set + { + _editableId = value; + } + } + + /// + /// The information of editable name. + /// + /// 6 + string IEditable.Name + { + get + { + string editableName = ""; + Interop.WatchfaceComplication.GetEditableName(_handle, out editableName); + return editableName; + } + set + { + Interop.WatchfaceComplication.SetEditableName(_handle, value); + } + } + + /// + /// Gets the editable's current data index. + /// + /// The index of current data + /// Thrown when the method failed due to invalid operation. + /// + /// + /// MyComplication comp = new MyComplication(); + /// Bundle curData = comp.GetCurrentDataIndex(); + /// + /// + /// 6 + 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; + } + + /// + /// Gets the editable's current data. + /// + /// The current data + /// Thrown when the method failed due to invalid operation. + /// + /// + /// MyComplication comp = new MyComplication(); + /// Bundle curData = comp.GetCurrentData(); + /// + /// + /// 6 + 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; + } + + /// + /// Gets the current provider ID. + /// + /// The current provider ID + /// Thrown when the method failed due to invalid operation. + /// + /// + /// MyComplication comp = new MyComplication(); + /// string providerId = comp.GetCurrentProviderId(); + /// + /// + /// 6 + 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; + } + + /// + /// Gets the current complication type. + /// + /// The current complication type + /// Thrown when the method failed due to invalid operation. + /// + /// + /// MyComplication comp = new MyComplication(); + /// ComplicationTypes type = comp.GetCurrentType(); + /// + /// + /// 6 + 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); + } + + /// + /// Sends the complication update requests. + /// + /// http://tizen.org/privilege/appmanager.launch + /// http://tizen.org/privilege/datasharing + /// Thrown when the method failed due to invalid operation. + /// Thrown when the application does not have privilege to access this method. + /// + /// + /// MyComplication comp = new MyComplication(); + /// ComplicationError err = comp.SendUpdateRequest(); + /// + /// + /// 6 + public void SendUpdateRequest() + { + ComplicationError ret = Interop.WatchfaceComplication.SendUpdateRequest(_handle); + if (ret != ComplicationError.None) + ErrorFactory.ThrowException(ret, "Fail to get send request"); + } + + /// + /// Transfers event to the provider. + /// + /// The complication event type. + /// http://tizen.org/privilege/appmanager.launch + /// http://tizen.org/privilege/datasharing + /// Thrown when the application does not have privilege to access this method. + /// Thrown when the invalid argument is passed. + /// Thrown when the method failed due to invalid operation. + /// + /// + /// void OnButtonClicked() + /// { + /// comp.TransferEvent(EventTypes.EventTap); + /// } + /// + /// + /// 6 + public void TransferEvent(EventTypes eventType) + { + ComplicationError ret = Interop.WatchfaceComplication.TransferEvent(_handle, eventType); + if (ret != ComplicationError.None) + ErrorFactory.ThrowException(ret, "Fail to transfer event"); + } + + /// + /// Gets the complication data type. + /// + /// The data from OnComplicationUpdate callback. + /// The complication type of data + /// Thrown when the invalid argument is passed. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// + /// ComplicationTypes type = Complication.GetType(dupData); + /// + /// + /// 6 + 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; + } + + /// + /// Gets the short text. + /// + /// The data from OnComplicationUpdate callback. + /// The short text data + /// Thrown when data is invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// + /// + /// 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; + /// } + /// } + /// } + /// + /// + /// + /// 6 + 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; + } + + /// + /// Gets the long text. + /// + /// The data from OnComplicationUpdate callback. + /// The long text data + /// Thrown when data is invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// + /// + /// 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; + /// } + /// } + /// } + /// + /// + /// + /// 6 + 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; + } + + /// + /// Gets the title. + /// + /// The data from OnComplicationUpdate callback. + /// The title data + /// Thrown when data is invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// + /// + /// 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; + /// } + /// } + /// } + /// + /// + /// + /// 6 + 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; + } + + /// + /// Gets the timestamp. + /// + /// The timestamp data in long value + /// The data from OnComplicationUpdate callback. + /// Thrown when data is invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// + /// + /// 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; + /// } + /// } + /// } + /// + /// + /// + /// 6 + 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; + } + + /// + /// Gets the image path. + /// + /// The data from OnComplicationUpdate callback. + /// The image path data + /// Thrown when data is invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// + /// + /// 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; + /// } + /// } + /// } + /// + /// + /// + /// 6 + 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; + } + + /// + /// Gets the current value of ranged type data. + /// + /// The current value of range type data + /// The data from OnComplicationUpdate callback. + /// Thrown when data is invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// + /// + /// 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; + /// } + /// } + /// } + /// + /// + /// + /// 6 + 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; + } + + /// + /// Gets the minimum value of ranged type data. + /// + /// The data from OnComplicationUpdate callback. + /// The minimum value of range type data + /// Thrown when data is invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// + /// + /// 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; + /// } + /// } + /// } + /// + /// + /// + /// 6 + 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; + } + + /// + /// Gets the max value of ranged type data. + /// + /// The data from OnComplicationUpdate callback. + /// The maximum value of range type data + /// Thrown when data is invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// + /// + /// 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; + /// } + /// } + /// } + /// + /// + /// + /// 6 + 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; + } + + /// + /// Gets the icon path. + /// + /// The data from OnComplicationUpdate callback. + /// The icon path data + /// Thrown when data is invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// + /// + /// 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; + /// } + /// } + /// } + /// + /// + /// + /// 6 + 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; + } + + /// + /// Gets the extra data. + /// + /// The data from OnComplicationUpdate callback. + /// The extra string data + /// Thrown when data is invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// + /// + /// 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; + /// } + /// } + /// } + /// + /// + /// + /// 6 + 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; + } + + /// + /// Gets the screen reader text. + /// + /// The data from OnComplicationUpdate callback. + /// The screen reader text data + /// Thrown when data is invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// + /// + /// 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; + /// } + /// } + /// } + /// + /// + /// + /// 6 + 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; + } + + /// + /// Overrides this method to handle the behavior when the complication update event comes. + /// + /// The updated provider's ID. + /// The updated type. + /// The updated data. + /// 6 + protected abstract void OnComplicationUpdated(string providerId, ComplicationTypes type, Bundle data); + + /// + /// Overrides this method to handle the behavior when the complication error occurs. + /// + /// The updated provider's ID. + /// The updated type. + /// The occured error. + /// 6 + protected virtual void OnComplicationError(string providerId, ComplicationTypes type, ComplicationError errorReason) + { + } + + /// + /// Releases the unmanaged resources used by the Complication class specifying whether to perform a normal dispose operation. + /// + /// true for a normal dispose operation; false to finalize the handle. + /// 3 + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + Interop.WatchfaceComplication.Destroy(_handle); + Interop.WatchfaceComplication.RemoveUpdatedCallback(_handle, _updatedCallback); + _disposed = true; + } + } + + /// + /// Releases all resources used by the Complication class. + /// + /// 3 + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + } +} \ No newline at end of file diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationData.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationData.cs new file mode 100755 index 0000000..d497adf --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationData.cs @@ -0,0 +1,248 @@ +/* + * 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 +{ + /// + /// Represents the Complication data class. + /// + /// 6 + 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 diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationError.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationError.cs new file mode 100755 index 0000000..463dabf --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationError.cs @@ -0,0 +1,91 @@ +/* + * 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 +{ + /// + /// Enumeration for the complication error. + /// + /// 6 + public enum ComplicationError + { + /// + /// Error none. + /// + /// 6 + None = Interop.WatchfaceComplication.ErrorType.None, + /// + /// Out of memory error. + /// + /// 6 + OutOfMemory = Interop.WatchfaceComplication.ErrorType.OutOfMemory, + /// + /// Invalid parameter error. + /// + /// 6 + InvalidParam = Interop.WatchfaceComplication.ErrorType.InvalidParam, + /// + /// IO error. + /// + /// 6 + IO = Interop.WatchfaceComplication.ErrorType.IO, + /// + /// No data error. + /// + /// 6 + NoData = Interop.WatchfaceComplication.ErrorType.NoData, + /// + /// Permission deny error. + /// + /// 6 + PermissionDeny = Interop.WatchfaceComplication.ErrorType.PermissionDeny, + /// + /// The complication API is not supported error. + /// + /// 6 + NotSupported = Interop.WatchfaceComplication.ErrorType.NotSupported, + /// + /// DB operation error. + /// + /// 6 + DB = Interop.WatchfaceComplication.ErrorType.DB, + /// + /// DBus operation error. + /// + /// 6 + DBus = Interop.WatchfaceComplication.ErrorType.DBus, + /// + /// The editor is not ready for editing error. + /// + /// 6 + EditNotReady = Interop.WatchfaceComplication.ErrorType.EditNotReady, + /// + /// Already exist ID error. + /// + /// 6 + ExistID = Interop.WatchfaceComplication.ErrorType.ExistID, + /// + /// Not exist error. + /// + /// 6 + NotExist = Interop.WatchfaceComplication.ErrorType.NotExist, + /// + /// Not available error. + /// + /// 6 + NotAvailable = Interop.WatchfaceComplication.ErrorType.NotAvailable + } +} diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationProvider.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationProvider.cs new file mode 100644 index 0000000..646a848 --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationProvider.cs @@ -0,0 +1,265 @@ +/* + * 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 +{ + /// + /// Represents the ComplicationProvider class for the complication provider service application. + /// + /// 6 + public abstract class ComplicationProvider : IDisposable + { + private string _providerId; + private bool _disposed = false; + private const string LogTag = "WatchfaceComplication"; + + /// + /// Initializes the ComplicationProvider class. + /// + /// The id of the complication provider. + /// http://tizen.org/privilege/datasharing + /// Thrown when providerId is invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// Thrown when the application does not have privilege to access this method. + /// + /// + /// public class MyComplicationProvider : ComplicationProvider + /// { + /// public MyComplicationProvider(string providerId) + /// : base(providerId) + /// { + /// } + /// protected override void OnDataUpdateRequested(string reqestAppId, ComplicationTypes type, Bundle contextData) + /// { + /// } + /// } + /// + /// + /// 6 + 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; + } + + /// + /// Destructor of the provider class. + /// + ~ComplicationProvider() + { + Dispose(false); + } + + /// + /// Gets the provider ID. + /// + /// 6 + 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); + } + + /// + /// Overrides this method to handle the behavior when the complication data update request event comes from watchface complication. + /// + /// The application ID of application which sent update request. + /// The requested type. + /// The complication's context which is set by complication setup application. + /// The requested ComplicationData + /// 6 + protected abstract ComplicationData OnDataUpdateRequested(string reqestAppId, ComplicationTypes type, Bundle contextData); + + /// + /// Emits the update event for complications. + /// + /// http://tizen.org/privilege/datasharing + /// Thrown when the application does not have privilege to access this method. + /// Thrown when the watchface complication is not supported. + /// 6 + public void NotifyUpdate() + { + ComplicationError err = Interop.WatchfaceComplication.NotifyUpdate(_providerId); + if (err != ComplicationError.None) + ErrorFactory.ThrowException(err, "fail to notify"); + } + + /// + /// Gets the received event type. + /// + /// The appcontrol received event args. + /// Thrown when the invalid parameter is passed. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// + /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e) + /// { + /// EventTypes type = ComplicationProvider.GetEventType(e.ReceivedAppControl); + /// if (type == EventTypes.EventDoubleTap) + /// { + /// // do something + /// } + /// base.OnAppControlReceived(e); + /// } + /// + /// + /// The type of received event + /// 6 + 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; + } + + /// + /// Gets the received event target provider ID. + /// + /// The appcontrol received event args. + /// Thrown when e is invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// + /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e) + /// { + /// string providerId = ComplicationProvider.GetEventProviderId(e.ReceivedAppControl); + /// base.OnAppControlReceived(e); + /// } + /// + /// + /// The target provider ID of received event + /// 6 + 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; + } + + /// + /// Gets the received event target complication type. + /// + /// The appcontrol received event args. + /// Thrown when e is invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// + /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e) + /// { + /// ComplicationTypes type = ComplicationProvider.GetEventComplicationType(e.ReceivedAppControl); + /// base.OnAppControlReceived(e); + /// } + /// + /// + /// The target complication type of received event + /// 6 + 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; + } + + /// + /// Gets the received event target complication context. + /// + /// The appcontrol received event args. + /// Thrown when e is invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// + /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e) + /// { + /// Bundle context = ComplicationProvider.GetEventContext(e.ReceivedAppControl); + /// base.OnAppControlReceived(e); + /// } + /// + /// + /// The context of received event + /// 6 + 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); + } + + /// + /// Releases the unmanaged resources used by the ComplicationProvider class specifying whether to perform a normal dispose operation. + /// + /// true for a normal dispose operation; false to finalize the handle. + /// 3 + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + Interop.WatchfaceComplication.RemoveUpdateRequestedCallback(_providerId, DataUpdateRequested); + _disposed = true; + } + } + + /// + /// Releases all resources used by the ComplicationProvider class. + /// + /// 3 + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + } +} \ No newline at end of file diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationProviderSetup.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationProviderSetup.cs new file mode 100644 index 0000000..95cb240 --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationProviderSetup.cs @@ -0,0 +1,127 @@ +/* + * 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 +{ + /// + /// Represents the ComplicationProviderSetup class for the complication provider setup application. + /// + /// 6 + public static class ComplicationProviderSetup + { + /// + /// Gets the received appctrl containing inforamtion about edit. + /// + /// The appcontrol received event args. + /// Thrown when e is invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// + /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e) + /// { + /// if (ComplicationProviderSetup.IsEditing(e.ReceivedAppControl)) + /// { + /// // do something + /// } + /// base.OnAppControlReceived(e); + /// } + /// + /// + /// The boolean value. + /// 6 + 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; + } + + /// + /// Replies the setup context to the editor + /// + /// The appcontrol received event args. + /// The context created by complication setup app. + /// http://tizen.org/privilege/datasharing + /// Thrown when e is invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// Thrown when the application does not have privilege to access this method. + /// + /// + /// 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); + /// } + /// + /// + /// Event target complication type + /// 6 + 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"); + } + + /// + /// Gets complication's setup context. + /// + /// The appcontrol received event args. + /// Thrown when e is invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// + /// 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); + /// } + /// + /// + /// The setup context. + /// 6 + 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); + } + } +} diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationTypes.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationTypes.cs new file mode 100755 index 0000000..0bdbbb9 --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ComplicationTypes.cs @@ -0,0 +1,66 @@ +/* + * 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 +{ + /// + /// Enumeration for the complication type. + /// + /// 6 + [Flags] + public enum ComplicationTypes + { + /// + /// The complication type NoData do not displays anything. + /// + /// 6 + NoData = 0x01, + /// + /// The complication type ShortText displays short text. + /// + /// 6 + ShortText = 0x02, + /// + /// The complication type LongText displays long text. + /// + /// 6 + LongText = 0x04, + /// + /// The complication type RangedValue displays minimum, maximum, current value. + /// + /// 6 + RangedValue = 0x08, + /// + /// The complication type Time displays time. + /// + /// 6 + Time = 0x10, + /// + /// The complication type Icon displays icon. + /// + /// 6 + Icon = 0x20, + /// + /// The complication type Image displays image. + /// + /// 6 + Image = 0x40 + } +} \ No newline at end of file diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/DesignElement.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/DesignElement.cs new file mode 100755 index 0000000..2cc26e0 --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/DesignElement.cs @@ -0,0 +1,219 @@ +/* + * 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 +{ + /// + /// Represents the DesignElement class for the watch application. + /// + /// 6 + public abstract class DesignElement : IEditable + { + + private IEnumerable _candidates; + private int _currentDataIndex; + private Highlight _highlight; + private string _editableName; + private int _editableId; + + /// + /// Initializes the DesignElement class. + /// + /// The candidates list. + /// The currently selected data index of candidate list. + /// The design element name. + /// Thrown when e is invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// + /// 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); + /// + /// + /// 6 + protected DesignElement(IEnumerable candidates, int currentDataIndex, string editableName) + { + if (candidates == null || currentDataIndex < 0) + ErrorFactory.ThrowException(ComplicationError.InvalidParam); + List candidatesList = candidates.ToList(); + if (candidatesList.Count < currentDataIndex) + ErrorFactory.ThrowException(ComplicationError.InvalidParam); + + _candidates = candidates; + _currentDataIndex = currentDataIndex; + _editableName = editableName; + } + + /// + /// The information of Editable ID. + /// + /// 6 + int IEditable.EditableId + { + get + { + return _editableId; + } + set + { + _editableId = value; + } + } + + /// + /// The information of Editable candidates. + /// + /// 6 + public IEnumerable Candidates + { + get + { + return _candidates; + } + } + + /// + /// The information of Editable name. + /// + /// 6 + string IEditable.Name + { + get + { + return _editableName; + } + set + { + _editableName = value; + } + } + + /// + /// The information of editable's highlight. + /// + /// 6 + Highlight IEditable.Highlight + { + get + { + return _highlight; + } + set + { + _highlight = value; + } + } + + /// + /// The information of design element's highlight. + /// + /// 6 + public Highlight Highlight + { + get + { + return _highlight; + } + set + { + _highlight = value; + } + } + + /// + /// Gets the editable's currently selected data index of candidate list. + /// + /// The currently selected data index of candidate list. + /// 6 + int IEditable.GetCurrentDataIndex() + { + return _currentDataIndex; + } + + internal void SetCurrentDataIndex(int idx) + { + _currentDataIndex = idx; + } + + /// + /// Gets the editable's currently selected data. + /// + /// The currently selected data. + /// 6 + 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); + } + + /// + /// Overrides this method to handle the behavior when the design element is updated. + /// + /// The selected candidate index. + /// The update state. + /// 6 + protected abstract void OnDesignUpdated(int selectedIdx, State state); + } +} diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/EditablesContainer.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/EditablesContainer.cs new file mode 100644 index 0000000..1a0dbde --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/EditablesContainer.cs @@ -0,0 +1,348 @@ +/* + * 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 +{ + /// + /// Represents the EditablesContainer class for the watch application. + /// + /// 6 + public abstract class EditablesContainer : IDisposable + { + internal IList _deList = new List(); + internal IList _compList = new List(); + internal IntPtr _container = IntPtr.Zero; + private Interop.WatchfaceComplication.EditableUpdateRequestedCallback _editableUpdatedCallback; + private bool _disposed = false; + private static string _logTag = "WatchfaceComplication"; + + /// + /// Initializes the EditablesContainer class. + /// + /// Thrown when some parameter are invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// 6 + 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"); + } + + /// + /// Destructor of the EditablesContainer class. + /// + ~EditablesContainer() + { + Dispose(false); + } + + /// + /// Adds the DesignElement to edit list. + /// + /// The DesignElement object. + /// The editable id. + /// Thrown when the invalid parameter is passed. + /// Thrown when the method failed due to invalid operation. + /// 6 + 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); + } + + /// + /// Adds the Complication to edit list. + /// + /// The Complication object. + /// The editable id. + /// Thrown when the invalid parameter is passed. + /// Thrown when the method failed due to invalid operation. + /// 6 + 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); + } + + /// + /// Removes the editable from edit list. + /// + /// The editable id. + /// Thrown when the invalid parameter is passed. + /// + /// + /// if (myContainer.IsExist(_colorEditId) + /// myContainer.Remove(_colorEditId); + /// + /// + /// 6 + 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; + } + + /// + /// Checks the editable with editableId is already exists in edit list. + /// + /// The target editable Id. + /// true if the editable is already exists in edit list, otherwise false + /// 6 + 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); + } + } + + /// + /// Requests edit to editor application. + /// + /// http://tizen.org/privilege/datasharing + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// Thrown when the application does not have privilege to access this method. + /// + /// + /// public class MyContainer : EditablesContainer { + /// public MyContainer() : base() + /// { + /// } + /// protected override void OnEditReady(string editorId) + /// { + /// this.RequestEdit(); + /// } + /// } + /// + /// + /// 6 + 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"); + } + } + + /// + /// Overrides this method if you want to handle the behavior when the editor is ready to edit. + /// + /// The appid of ready to edit editor. + /// 6 + protected abstract void OnEditReady(string editorId); + + /// + /// Loads the editable's current data. + /// + /// The editable's latest data that selected by editor. + /// Thrown when some parameter are invalid. + /// Thrown when the method failed due to invalid operation. + /// Thrown when the watchface complication is not supported. + /// + /// This API loads editable's last current data which is updated by editor application. + /// + /// The id of the editable. + /// + /// + /// 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); + /// } + /// + /// + /// 6 + 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; + } + + /// + /// Releases the unmanaged resources used by the EditablesContainer class specifying whether to perform a normal dispose operation. + /// + /// true for a normal dispose operation; false to finalize the handle. + /// 3 + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + Interop.WatchfaceComplication.RemoveEditReadyCallback(EditReady); + _disposed = true; + } + } + + /// + /// Releases all resources used by the EditablesContainer class. + /// + /// 3 + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + }; +} \ No newline at end of file diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ErrorFactory.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ErrorFactory.cs new file mode 100755 index 0000000..a695382 --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ErrorFactory.cs @@ -0,0 +1,60 @@ +/* + * 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}"); + } + } + } +} diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/EventTypes.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/EventTypes.cs new file mode 100755 index 0000000..96f4cf3 --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/EventTypes.cs @@ -0,0 +1,46 @@ +/* + * 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 +{ + /// + /// Enumeration for the complication event type. + /// + /// 6 + [Flags] + public enum EventTypes + { + /// + /// The complication event none. + /// + /// 6 + EventNone = 0x01, + /// + /// The complication event tap. + /// + /// 6 + EventTap = 0x02, + /// + /// The complication event double tap. + /// + /// 6 + EventDoubleTap = 0x04 + } +} diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/Highlight.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/Highlight.cs new file mode 100755 index 0000000..c82279e --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/Highlight.cs @@ -0,0 +1,184 @@ +/* + * 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 +{ + /// + /// Represents the Highlight class for the editable. + /// + /// 6 + public class Highlight + { + private IntPtr _raw = IntPtr.Zero; + private int _x; + private int _y; + private int _w; + private int _h; + private ShapeType _type; + + /// + /// Initializes the Highlight class. + /// + /// The highlight shape type. + /// The highlight geometry x. + /// The highlight geometry y. + /// The highlight geometry w. + /// The highlight geometry h. + /// Thrown when some parameter are invalid. + /// Thrown when the method failed due to invalid operation. + /// 6 + public Highlight(ShapeType type, int x, int y, int w, int h) + { + _type = type; + _x = x; + _y = y; + _w = w; + _h = h; + } + + /// + /// Destructor of the Highlight class. + /// + ~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; + } + } + + /// + /// The x coordinate. + /// + /// Thrown when some parameter are invalid. + /// 6 + public int X + { + get + { + return _x; + } + set + { + if (value < 0) + ErrorFactory.ThrowException(ComplicationError.InvalidParam, "invalid x value (" + value + ")"); + _x = value; + } + } + + /// + /// The y coordinate. + /// + /// Thrown when some parameter are invalid. + /// 6 + public int Y + { + get + { + return _y; + } + set + { + if (value < 0) + ErrorFactory.ThrowException(ComplicationError.InvalidParam, "invalid y value (" + value + ")"); + _y = value; + } + } + + /// + /// The width of editable. + /// + /// Thrown when some parameter are invalid. + /// 6 + public int W + { + get + { + return _w; + } + set + { + if (value < 0) + ErrorFactory.ThrowException(ComplicationError.InvalidParam, "invalid w value (" + value + ")"); + _w = value; + } + } + + /// + /// The height of editable. + /// + /// Thrown when some parameter are invalid. + /// 6 + public int H + { + get + { + return _h; + } + set + { + if (value < 0) + ErrorFactory.ThrowException(ComplicationError.InvalidParam, "invalid h value (" + value + ")"); + _h = value; + } + } + + /// + /// The shape of editable. + /// + /// 6 + public ShapeType ShapeType + { + get + { + return _type; + } + set + { + _type = value; + } + } + } +} diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/IEditable.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/IEditable.cs new file mode 100644 index 0000000..9caf3c3 --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/IEditable.cs @@ -0,0 +1,60 @@ +/* + * 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 +{ + /// + /// Represents the Editable interface. + /// + /// 6 + public interface IEditable + { + /// + /// The information about editable's ID. + /// + /// 6 + int EditableId { get; set; } + + /// + /// The information about editable's name. + /// + /// 6 + string Name { get; set; } + + /// + /// The information about editable's geometry. + /// + /// 6 + Highlight Highlight { get; set; } + + /// + /// The information about editable's current data index. + /// + /// 6 + int GetCurrentDataIndex(); + + /// + /// The information about editable's current data. + /// + /// 6 + Bundle GetCurrentData(); + } +} \ No newline at end of file diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/IconData.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/IconData.cs new file mode 100755 index 0000000..88fa872 --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/IconData.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tizen.Applications.WatchfaceComplication +{ + /// + /// Represents the IconData class for the Icon type complication. + /// + /// 6 + public class IconData : ComplicationData + { + /// + /// Initializes the IconData class. + /// + /// The icon path. + /// The extra data. + /// Thrown when parameter is invalid. + /// + /// + /// 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); + /// } + /// } + /// + /// + /// 6 + 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; + } + + /// + /// The icon path data. + /// + /// Thrown when try to set invalid value. + /// 6 + 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; + } + } + + /// + /// The extra data. + /// + /// 6 + public new string ExtraData + { + get + { + return base.ExtraData; + } + set + { + base.ExtraData = value; + } + } + + /// + /// The information about the screen reader text of complication data. + /// + /// 6 + public new string ScreenReaderText + { + get + { + return base.ScreenReaderText; + } + set + { + base.ScreenReaderText = value; + } + } + } +} diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ImageData.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ImageData.cs new file mode 100644 index 0000000..fe14f6c --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ImageData.cs @@ -0,0 +1,111 @@ +/* + * 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 +{ + /// + /// Represents the ImageData class for the Image type complication. + /// + /// 6 + public class ImageData : ComplicationData + { + /// + /// Initializes the ImageData class. + /// + /// The image path. + /// The extra data. + /// Thrown when parameter is invalid. + /// + /// + /// 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); + /// } + /// } + /// + /// + /// 6 + 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; + } + + /// + /// The image path data. + /// + /// Thrown when try to set invalid value. + /// 6 + 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; + } + } + + /// + /// The extra data. + /// + /// 6 + public new string ExtraData + { + get + { + return base.ExtraData; + } + set + { + base.ExtraData = value; + } + } + + /// + /// The information about the screen reader text of complication data. + /// + /// 6 + public new string ScreenReaderText + { + get + { + return base.ScreenReaderText; + } + set + { + base.ScreenReaderText = value; + } + } + } +} diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/Interop/Interop.Libraries.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/Interop/Interop.Libraries.cs new file mode 100755 index 0000000..381cd21 --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/Interop/Interop.Libraries.cs @@ -0,0 +1,8 @@ +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 diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/Interop/Interop.WatchfaceComplication.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/Interop/Interop.WatchfaceComplication.cs new file mode 100755 index 0000000..e38bf7d --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/Interop/Interop.WatchfaceComplication.cs @@ -0,0 +1,256 @@ +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); + } +} diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/LongTextData.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/LongTextData.cs new file mode 100755 index 0000000..cd46d52 --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/LongTextData.cs @@ -0,0 +1,147 @@ +/* + * 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 +{ + /// + /// Represents the LongTextData class for the LongText type complication. + /// + /// 6 + public class LongTextData : ComplicationData + { + /// + /// Initializes the LongTextData class. + /// + /// The long text. + /// The icon path. + /// The title. + /// The extra data. + /// Thrown when parameter is invalid. + /// + /// + /// 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); + /// } + /// } + /// + /// + /// 6 + 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; + } + + /// + /// The long text data. + /// + /// Thrown when try to set invalid value. + /// 6 + public new string LongText + { + get + { + return base.LongText; + } + set + { + if (value == null) + ErrorFactory.ThrowException(ComplicationError.InvalidParam, "fail to create short text"); + base.LongText = value; + } + } + + /// + /// The icon path data. + /// + /// 6 + public new string IconPath + { + get + { + return base.IconPath; + } + set + { + base.IconPath = value; + } + } + + /// + /// The title data. + /// + /// 6 + public new string Title + { + get + { + return base.Title; + } + set + { + base.Title = value; + } + } + + /// + /// The extra data. + /// + /// 6 + public new string ExtraData + { + get + { + return base.ExtraData; + } + set + { + base.ExtraData = value; + } + } + + /// + /// The information about the screen reader text of complication data. + /// + /// 6 + public new string ScreenReaderText + { + get + { + return base.ScreenReaderText; + } + set + { + base.ScreenReaderText = value; + } + } + } +} diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/RangedValueData.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/RangedValueData.cs new file mode 100755 index 0000000..5eee4de --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/RangedValueData.cs @@ -0,0 +1,216 @@ +/* + * 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 +{ + /// + /// Represents the RangedValueData class for the RangedValue type complication. + /// + /// 6 + public class RangedValueData : ComplicationData + { + /// + /// Initializes the RangedValueData class. + /// + /// The current value. + /// The minimum value. + /// The max value. + /// The short text. + /// The icon path. + /// The title. + /// The extra data. + /// Thrown when parameter is invalid. + /// + /// + /// 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); + /// } + /// } + /// + /// + /// 6 + 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; + } + + /// + /// The information about the current range value of complication data. + /// + /// Thrown when try to set invalid value. + /// 6 + 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; + } + } + + /// + /// The information about the min range value of complication data. + /// + /// Thrown when try to set invalid value. + /// 6 + 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; + } + } + + /// + /// The information about the max range value of complication data. + /// + /// Thrown when try to set invalid value. + /// 6 + 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; + } + } + + /// + /// The short text data. + /// + /// Thrown when try to set invalid value. + /// 6 + public new string ShortText + { + get + { + return base.ShortText; + } + set + { + if (value == null) + ErrorFactory.ThrowException(ComplicationError.InvalidParam, "fail to create short text"); + base.ShortText = value; + } + } + + /// + /// The icon path data. + /// + /// 6 + public new string IconPath + { + get + { + return base.IconPath; + } + set + { + base.IconPath = value; + } + } + + /// + /// The title data. + /// + /// 6 + public new string Title + { + get + { + return base.Title; + } + set + { + base.Title = value; + } + } + + /// + /// The extra data. + /// + /// 6 + public new string ExtraData + { + get + { + return base.ExtraData; + } + set + { + base.ExtraData = value; + } + } + + /// + /// The information about the screen reader text of complication data. + /// + /// 6 + public new string ScreenReaderText + { + get + { + return base.ScreenReaderText; + } + set + { + base.ScreenReaderText = value; + } + } + } +} diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ShapeType.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ShapeType.cs new file mode 100755 index 0000000..9c0ba27 --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ShapeType.cs @@ -0,0 +1,37 @@ +/* + * 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 +{ + /// + /// Represents the Editable shape type. + /// + /// 6 + public enum ShapeType { + /// + /// Shape circle. + /// + /// 6 + Circle, + /// + /// Shape rectangle. + /// + /// 6 + Rectangle + } +} diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ShortTextData.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ShortTextData.cs new file mode 100755 index 0000000..1d34946 --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/ShortTextData.cs @@ -0,0 +1,147 @@ +/* + * 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 +{ + /// + /// Represents the ShortTextData class for the ShortText type complication. + /// + /// 6 + public class ShortTextData : ComplicationData + { + /// + /// Initializes the ShortTextData class. + /// + /// The short text. + /// The icon path. + /// The title. + /// The extra data. + /// Thrown when parameter is invalid. + /// + /// + /// 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); + /// } + /// } + /// + /// + /// 6 + 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; + } + + /// + /// The short text data. + /// + /// Thrown when try to set invalid value. + /// 6 + public new string ShortText + { + get + { + return base.ShortText; + } + set + { + if (value == null) + ErrorFactory.ThrowException(ComplicationError.InvalidParam, "fail to create short text"); + base.ShortText = value; + } + } + + /// + /// The icon path data. + /// + /// 6 + public new string IconPath + { + get + { + return base.IconPath; + } + set + { + base.IconPath = value; + } + } + + /// + /// The title data. + /// + /// 6 + public new string Title + { + get + { + return base.Title; + } + set + { + base.Title = value; + } + } + + /// + /// The extra data. + /// + /// 6 + public new string ExtraData + { + get + { + return base.ExtraData; + } + set + { + base.ExtraData = value; + } + } + + /// + /// The information about the screen reader text of complication data. + /// + /// 6 + public new string ScreenReaderText + { + get + { + return base.ScreenReaderText; + } + set + { + base.ScreenReaderText = value; + } + } + } +} diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/State.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/State.cs new file mode 100755 index 0000000..4aeee90 --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/State.cs @@ -0,0 +1,46 @@ +/* + * 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 +{ + /// + /// Represents the Editable state. + /// + /// 6 + public enum State + { + /// + /// The editable editing is complete. + /// + /// 6 + Complete, + /// + /// The editable editing is on going now. + /// + /// 6 + OnGoing, + + /// + /// The editable editing is canceled. + /// + /// 6 + Cancel + } +} diff --git a/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/TimeData.cs b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/TimeData.cs new file mode 100755 index 0000000..0c1cbff --- /dev/null +++ b/src/Tizen.Applications.WatchfaceComplication/Tizen.Applications/TimeData.cs @@ -0,0 +1,130 @@ +/* + * 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 +{ + /// + /// Represents the TimeData class for the Time type complication. + /// + /// 6 + public class TimeData : ComplicationData + { + /// + /// Initializes the TimeData class. + /// + /// The timestamp value. + /// The icon path. + /// The extra data. + /// Thrown when parameter is invalid. + /// + /// + /// 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); + /// } + /// } + /// + /// + /// 6 + 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; + } + + /// + /// The information about the timestamp of complication data. + /// + /// Thrown when try to set invalid value. + /// 6 + public new long Timestamp + { + get + { + return base.Timestamp; + } + set + { + if (value < 0) + ErrorFactory.ThrowException(ComplicationError.InvalidParam, "invalid time(" + value + ")"); + base.Timestamp = value; + } + } + + /// + /// The icon path data. + /// + /// 6 + public new string IconPath + { + get + { + return base.IconPath; + } + set + { + base.IconPath = value; + } + } + + /// + /// The extra data. + /// + /// 6 + public new string ExtraData + { + get + { + return base.ExtraData; + } + set + { + base.ExtraData = value; + } + } + + /// + /// The information about the screen reader text of complication data. + /// + /// 6 + public new string ScreenReaderText + { + get + { + return base.ScreenReaderText; + } + set + { + base.ScreenReaderText = value; + } + } + + } +} \ No newline at end of file -- 2.7.4