2 * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Collections.Generic;
21 namespace Tizen.Applications.WatchfaceComplication
24 /// Represents the ComplicationProviderSetup class for the complication provider setup application.
26 /// <since_tizen> 6 </since_tizen>
27 public static class ComplicationProviderSetup
30 /// Gets the received appctrl containing inforamtion about edit.
32 /// <param name="recvAppCtrl">The appcontrol received event args.</param>
33 /// <exception cref="ArgumentException">Thrown when e is invalid.</exception>
34 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
35 /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
38 /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
40 /// if (ComplicationProviderSetup.IsEditing(e.ReceivedAppControl))
44 /// base.OnAppControlReceived(e);
48 /// <returns>The boolean value.</returns>
49 /// <since_tizen> 6 </since_tizen>
50 public static bool IsEditing(ReceivedAppControl recvAppCtrl)
52 bool isEditing = false;
53 ComplicationError err = Interop.WatchfaceComplication.IsSetupEditing(recvAppCtrl.SafeAppControlHandle, out isEditing);
54 if (err != ComplicationError.None)
55 ErrorFactory.ThrowException(err, "fail to check editing");
60 /// Replies the setup context to the editor
62 /// <param name="recvAppCtrl">The appcontrol received event args.</param>
63 /// <param name="context">The context created by complication setup app.</param>
64 /// <privilege>http://tizen.org/privilege/datasharing</privilege>
65 /// <exception cref="ArgumentException">Thrown when e is invalid.</exception>
66 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
67 /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
68 /// <exception cref="UnauthorizedAccessException">Thrown when the application does not have privilege to access this method.</exception>
71 /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
73 /// if (ComplicationProviderSetup.IsEditing(e.ReceivedAppControl))
75 /// Bundle context = ComplicationProviderSetup.GetContext(e.ReceivedAppControl);
76 /// context.AddItem("TEST_KEY", "NEW CONTEXT");
77 /// ComplicationProviderSetup.ReplyToEditor(e.ReceivedAppControl, context);
79 /// base.OnAppControlReceived(e);
83 /// <returns>Event target complication type</returns>
84 /// <since_tizen> 6 </since_tizen>
85 public static void ReplyToEditor(ReceivedAppControl recvAppCtrl, Bundle context)
87 ComplicationError err = Interop.WatchfaceComplication.SetupReplyToEditor(recvAppCtrl.SafeAppControlHandle, context.SafeBundleHandle);
88 if (err != ComplicationError.None)
89 ErrorFactory.ThrowException(err, "fail to check editing");
93 /// Gets complication's setup context.
95 /// <param name="recvAppCtrl">The appcontrol received event args.</param>
96 /// <exception cref="ArgumentException">Thrown when e is invalid.</exception>
97 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
98 /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
101 /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
103 /// if (ComplicationProviderSetup.IsEditing(e.ReceivedAppControl))
105 /// Bundle context = ComplicationProviderSetup.GetContext(e.ReceivedAppControl);
106 /// context.AddItem("TEST_KEY", "NEW CONTEXT");
107 /// ComplicationProviderSetup.ReplyToEditor(e.ReceivedAppControl, context);
109 /// base.OnAppControlReceived(e);
113 /// <returns>The setup context.</returns>
114 /// <since_tizen> 6 </since_tizen>
115 public static Bundle GetContext(ReceivedAppControl recvAppCtrl)
117 SafeBundleHandle context;
118 ComplicationError err = Interop.WatchfaceComplication.GetSetupContext(recvAppCtrl.SafeAppControlHandle, out context);
119 if (err != ComplicationError.None)
120 ErrorFactory.ThrowException(err, "fail to check editing");
124 return new Bundle(context);