[Notification] Add 4.0 new api guide 53/148653/6
authorMyungki Lee <mk5004.lee@samsung.com>
Fri, 8 Sep 2017 08:19:07 +0000 (17:19 +0900)
committerMyungKi Lee <mk5004.lee@samsung.com>
Mon, 11 Sep 2017 05:55:14 +0000 (05:55 +0000)
PS4: Reviewed again.
PS5: Added two typo fixes missed from PS4.

Change-Id: I90647a57570f198167e009b4f7bebaf17799a7a8
Signed-off-by: Myungki Lee <mk5004.lee@samsung.com>
org.tizen.guides/html/native/notification/noti_n.htm

index 23fdb14..aa33e47 100644 (file)
@@ -45,6 +45,7 @@
                        </li>
                        <li><a href="#bar">Displaying the Progress Bar</a></li>
                        <li><a href="#input_box">Creating an Active Notification with Text Input</a></li>
+                       <li><a href="#extended_noti">Creating an Extended Notification</a></li>
                        <li><a href="#template">Using a Notification Template</a></li>
                </ul>
                <p class="toc-title">Related Info</p>
 <li><code>NOTIFICATION_LY_NOTI_THUMBNAIL</code>
 <p>Layout for a notification displaying images.</p></li>
 <li><code>NOTIFICATION_LY_ONGOING_PROGRESS</code>
-<p>Layout for an ongoing notification displaying progress.</p></li></ul>
+<p>Layout for an ongoing notification displaying progress.</p></li>
+<li><code>NOTIFICATION_LY_EXTENSION</code>
+<p>Layout for an <a href="#extended_noti">extended notification</a>.</p></li></ul>
 
    <p align="center"><strong>Figure: Notification layouts</strong></p>
    <p align="center"><img alt="Notification layouts" src="../../images/notification_layout_desc.png" /></p>
@@ -575,11 +578,110 @@ if (ret != APP_CONTROL_ERROR_NONE)
    <p align="center"><strong>Figure: Text input box</strong></p>
    <p align="center"><img alt="Text input box" src="../../images/active_notification_2.png" /></p>
 
+<h2 id="extended_noti" name="extended_noti">Creating an Extended Notification</h2>
+
+<p>The extended notification layout is used to display long text or large images on the quick panel:</p>
+<ul>
+<li>When the notification is displayed in basic form, the text set with the <code>NOTIFICATION_TEXT_TYPE_CONTENT</code> text type is displayed.</li>
+<li>When the notification is displayed in extended form, the text set with the <code>NOTIFICATION_TEXT_TYPE_CONTENT_EXTENSION</code> text type is displayed.</li>
+</ul>
+
+<p>To show a large image, use the <code>NOTIFICATION_IMAGE_TYPE_EXTENSION</code> image type, and define the size of the image.</p>
+
+<p>To create an extended notification:</p>
+
+<ol>
+<li>Create a notification and set the extended layout:
+<pre class="prettyprint">
+notification_h noti_handle = NULL;
+app_control_h app_control = NULL;
+
+/* Create a new notification */
+noti_handle = notification_create(NOTIFICATION_TYPE_NOTI);
+if (noti == NULL)
+    /* Error handling */
+
+/* Set layout */
+int ret = notification_set_layout(noti_handle, NOTIFICATION_LY_EXTENSION);
+if (ret != NOTIFICATION_ERROR_NONE)
+    /* Error handling */
+</pre>
+</li>
+<li>Set the notification attributes. For example, you can set the title text, the body text for basic and extended form, and the large image and its size:
+<pre class="prettyprint">
+ret = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_TITLE, "Title",
+                            NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+if (ret != NOTIFICATION_ERROR_NONE)
+    /* Error handling */
+
+/* Body text for basic form */
+ret = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT, "Body",
+                            NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+if (ret != NOTIFICATION_ERROR_NONE)
+    /* Error handling */
+
+/* Body text for extended form */
+ret = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT_EXTENSION,
+                            "Long Body", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+if (ret != NOTIFICATION_ERROR_NONE)
+    /* Error handling */
+
+/* Large image */
+ret = notification_set_image(noti_handle, NOTIFICATION_IMAGE_TYPE_EXTENSION, image_path);
+if (ret != NOTIFICATION_ERROR_NONE)
+    /* Error handling */
+
+/* Image height */
+ret = notification_set_extension_image_size(noti_handle, 300);
+if (ret != NOTIFICATION_ERROR_NONE)
+    /* Error handling */
+
+ret = notification_set_display_applist(noti_handle,
+                                       NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY);
+if (ret != NOTIFICATION_ERROR_NONE)
+    /* Error handling */
+</pre>
+</li>
+<li>Set the application control to launch an application when the user clicks the notification:
+<pre class="prettyprint">
+ret = app_control_create(&amp;app_control);
+if (ret != APP_CONTROL_ERROR_NONE)
+    /* Error handling */
+
+ret = app_control_set_app_id(app_control, appid);
+/*
+   Or use:
+   ret = app_control_set_uri(app_control, uri);
+*/
+if (ret != APP_CONTROL_ERROR_NONE)
+    /* Error handling */
+
+ret = notification_set_launch_option(noti_handle, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL,
+                                     app_control);
+if (ret != NOTIFICATION_ERROR_NONE)
+    /* Error handling */
+</pre>
+</li>
+<li>Post the notification:
+<pre class="prettyprint">
+ret  = notification_post(noti_handle);
+if (ret != NOTIFICATION_ERROR_NONE)
+    /* Error handling */
+
+app_control_destroy(app_control);
+
+notification_free(noti_handle);
+</pre>
+</li></ol>
+
 <h2 id="template" name="template">Using a Notification Template</h2>
 
-<p>To create a template from an existing notification, and reuse that template in another notification:</p>
+<p>To create a template from an existing notification, and reuse that template later to quickly create other notifications with the same pattern:</p>
 
-<ol><li><p>Create a notification as usual.</p>
+  <ul>
+  <li>To create a template:
+  <ol>
+  <li><p>Create a notification as usual.</p>
 <p>The following example creates an active notification with 2 buttons (<strong>accept</strong> and <strong>cancel</strong>), a background image, sound, led, and vibration:</p>
 
 <pre class="prettyprint">
@@ -685,19 +787,19 @@ ret = app_control_destroy(app_control);
 if (ret != APP_CONTROL_ERROR_NONE)
     /* Error handling */
 </pre></li>
-<li><p>To save the notification handle as a template and define a name for the template, use the <code>notification_save_as_template()</code> function:</p>
+<li><p>Save the notification handle as a template and define a name for the template, using the <code>notification_save_as_template()</code> function:</p>
 <pre class="prettyprint">
 ret = notification_save_as_template(notification, "CALL_ACCEPT");
 if (ret != APP_CONTROL_ERROR_NONE)
     /* Error handling */
-</pre></li>
+</pre></li></ol></li>
 <li><p>To use the template when creating a new notification, call the <code>notification_create_from_template()</code> function:</p>
 <pre class="prettyprint">
 notification_h notification = NULL;
 notification = notification_create_from_template("CALL_ACCEPT")
 if (noti == NULL)
     /* Error handling */
-</pre></li></ol>
+</pre></li></ul>
 
 <script type="text/javascript" src="../../scripts/jquery.zclip.min.js"></script>
 <script type="text/javascript" src="../../scripts/showhide.js"></script>