[Tizen.Applications] Deprecate some application API (#4547)
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.RemoteView / Tizen.Applications / RemoteViewFactory.cs
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using ElmSharp;
18 using System;
19
20 namespace Tizen.Applications
21 {
22     /// <summary>
23     /// Represents a factory class for making the RemoteView objects.
24     /// </summary>
25     /// <since_tizen> 3 </since_tizen>
26     [Obsolete("Deprecated since API10. Will be removed in API12.")]
27     public static class RemoteViewFactory
28     {
29         private static bool _ready;
30
31         /// <summary>
32         /// Initializes RemoteViewFactory.
33         /// </summary>
34         /// <param name="win">Window object that will contain RemoteViews that are generated by RemoteViewFactory.
35         /// All the remote views will be located in the specified window object.
36         /// </param>
37         /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
38         /// <exception cref="InvalidOperationException">Thrown when this operation failed.</exception>
39         /// <exception cref="UnauthorizedAccessException">Thrown when this operation is denied.</exception>
40         /// <exception cref="NotSupportedException">Thrown when this operation is not supported for this device.</exception>
41         /// <since_tizen> 3 </since_tizen>
42         [Obsolete("Deprecated since API10. Will be removed in API12.")]
43         public static void Init(EvasObject win)
44         {
45             if (_ready)
46                 throw new InvalidOperationException("Already initialized");
47             RemoteView.CheckException(Interop.WidgetViewerEvas.Init(win));
48             _ready = true;
49         }
50
51         /// <summary>
52         /// Creates a RemoteView object.
53         /// </summary>
54         /// <param name="parent">Parent object.</param>
55         /// <param name="widgetId">Widget ID.</param>
56         /// <param name="content">Contents that will be given to the widget instance.</param>
57         /// <param name="period">Update period.</param>
58         /// <param name="previewImage">True if you want to show the preview image.</param>
59         /// <param name="overlayText">True if you want to show the overlay text.</param>
60         /// <param name="loadingMessage">True if you want to show the loading message.</param>
61         /// <returns>RemoteView object.</returns>
62         /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
63         /// <exception cref="InvalidOperationException">Thrown when this operation failed.</exception>
64         /// <exception cref="UnauthorizedAccessException">Thrown when this operation is denied.</exception>
65         /// <exception cref="NotSupportedException">Thrown when this operation is not supported for this device.</exception>
66         /// <since_tizen> 3 </since_tizen>
67         [Obsolete("Deprecated since API10. Will be removed in API12.")]
68         public static RemoteView Create(EvasObject parent, string widgetId, string content, double period,
69             bool previewImage = true, bool overlayText = true, bool loadingMessage = true)
70         {
71             if (!_ready)
72                 throw new InvalidOperationException("Not initialized");
73
74             var obj = new RemoteView()
75             {
76                 Layout = new RemoteWindow(parent, widgetId, content, period)
77             };
78
79             if (!previewImage)
80                 obj.HidePreviewImage();
81
82             if (!overlayText)
83                 obj.HideOverlayText();
84
85             if (!loadingMessage)
86                 obj.HideLoadingMessage();
87
88             return obj;
89         }
90
91         /// <summary>
92         /// Finalizes the RemoteViewFactory.
93         /// </summary>
94         /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
95         /// <exception cref="InvalidOperationException">Thrown when this operation failed.</exception>
96         /// <exception cref="UnauthorizedAccessException">Thrown when this operation is denied.</exception>
97         /// <exception cref="NotSupportedException">Thrown when this operation is not supported for this device.</exception>
98         /// <since_tizen> 3 </since_tizen>
99         [Obsolete("Deprecated since API10. Will be removed in API12.")]
100         public static void Shutdown()
101         {
102             if (!_ready)
103                 throw new InvalidOperationException("Not initialized");
104             RemoteView.CheckException(Interop.WidgetViewerEvas.Fini());
105             _ready = false;
106         }
107
108     }
109 }