Attach Panel
NoteAll Attach Panel APIs have been deprecated since Tizen 9.0 and will be removed after two releases without any alternatives.
The attach panel allows you to attach various content to an application that contains an attach panel. You can attach images, take pictures, record voice, and select files on the attach panel.
This API is supported on Tizen mobile devices that support attach panel features.
The main features of the Tizen.Applications.AttachPanel namespace includes the following:
-
Create an attach panel
You can create an attach panel and manage events related to user selections and panel visibility. You can add and remove content categories.
You can also create an attach panel in xamarin by using Custom Renderers.
-
Manage an attach panel
You can set extra data to a content category to manage its content.
Figure: Attach panel
The attach panel contains UI components that manage user interactions on its interface. The layout component includes the tabBar and scroller components, which are connected to show the content synchronously. The scroller component contains pages that display content. For example, images, camera, and voice recorder. The contents are shown as a page on the panel. However, some content can be launched from the More tab of the panel using application controls.
The attach panel contains half and full display modes. The mode can be changed by swiping up and down the page.
Figure: Attach panel modes
Content categories
You can manage the following types of content:
-
Images
In half mode, you can select and attach only one image at a time. In full mode, you can select and attach multiple images at a time.
-
Camera
You can take a picture and attach it to the content using a device camera.
-
Voice
You can attach voice recordings to the content.
-
Various content in the More tab
You can use the additional category icons in the More tab, for example, video, audio, calendar, contact, myfiles, and video recorder. Click the respective icon to launch the category.
The following figure explains the content types. From left to right: images, camera, voice, and More tab content.
Figure: Content categories
Prerequisites
This section explains, how you can enable your application to use the attach panel functionality:
-
To use the Tizen.Applications.AttachPanel namespace, the application must request permission by adding the following privileges to the
tizen-manifest.xml
file:XMLCopy<privileges> <!--To add the image viewer and camera UI gadget in the attach panel--> <privilege>http://tizen.org/privilege/mediastorage</privilege> <!--To add the camera UI gadget in the attach panel--> <privilege>http://tizen.org/privilege/camera</privilege> <!--To launch the camera, verify that the video call status is not active--> <privilege>http://tizen.org/privilege/telephony</privilege> <!--To add the voice recorder UI gadget in the attach panel--> <privilege>http://tizen.org/privilege/recorder</privilege> <!--To launch apps from the More tab--> <privilege>http://tizen.org/privilege/appmanager.launch</privilege> </privileges>
-
To use the attach panel features, include the following feature in your tizen-manifest.xml file:
XMLCopy<feature name="http://tizen.org/feature/attach_panel"/>
-
To use the methods and properties of the Tizen.Applications.AttachPanel namespace, include the following namespace in your application:
C#Copyusing Tizen.Applications.AttachPanel;
-
To create an attach panel instance, an ElmSharp.Conformant instance is required. To create the instance, follow any of the step mentioned:
-
For Tizen platform conformant, see Get the Tizen platform conformant.
-
Create a conformant, into which you can add the attach panel later:
C#Copyclass App : CoreUIApplication { Conformant conformant; protected override void OnCreate() { /// Application initialization conformant = new Conformant(window); conformant.Show(); conformant.SetContent(bg); } }
-
Create an attach panel
-
Create an attach panel using the Tizen.Applications.AttachPanel.AttachPanel class.
When the attach panel is created, the state is hidden by default. To show the created panel, use the
Show()
method of theTizen.Applications.AttachPanel.AttachPanel
class:C#CopyAttachPanel attachPanel; public void CreateAttachPanel(Conformant conformant) { if (attachPanel == null) { attachPanel = new AttachPanel(conformant); attachPanel.AddCategory(ContentCategory.Image, null); attachPanel.Show(); } }
-
Select the type of content for the attach panel. Add content categories using the AddCategory() method, based on the type of content. The available content categories are defined in the Tizen.Applications.AttachPanel.ContentCategory enumeration.
The content categories in the More tab are shown in the frequency of recently used and alphabetical sequence.
To deliver more information to the UI gadget or called application, add the data within a bundle:
C#CopyBundle bundle = new Bundle(); bundle.AddItem("http://tizen.org/appcontrol/data/total_count", "3"); attachPanel.AddCategory(ContentCategory.Image, bundle); attachPanel.AddCategory(ContentCategory.Camera, null); attachPanel.AddCategory(ContentCategory.Voice, null); attachPanel.AddCategory(ContentCategory.Video, null); attachPanel.AddCategory(ContentCategory.Audio, null); attachPanel.AddCategory(ContentCategory.Calendar, null); attachPanel.AddCategory(ContentCategory.Contact, null); attachPanel.AddCategory(ContentCategory.Myfiles, null); attachPanel.AddCategory(ContentCategory.VideoRecorder, null); attachPanel.AddCategory(ContentCategory.Document, null); attachPanel.AddCategory(ContentCategory.TakePicture, null); attachPanel.AddCategory(ContentCategory.Memo, null); attachPanel.Show();
Note
To use the camera content category
attachPanel.AddCategory(ContentCategory.Camera, null)
, you must verify the video call status. To launch the camera, the video call status must not be active. To verify the status of video call, Telephony APItelephony_call_get_type()
is called, ensure that the telephony privilege is added to the tizen-manifest.xml file. -
Register the required event handlers:
-
To access the data that you select in the called application, register the
ResultCallback
event of theTizen.Applications.AttachPanel.AttachPanel
class and define an event handler for it.Select and confirm the content category to trigger the event. In the event handler, you can retrieve the selected items from the
Result.ExtraData
property of the Tizen.Applications.AttachPanel.ResultEventArgs class. -
To monitor published events from the panel side, register the
EventChanged
event of theTizen.Applications.AttachPanel.AttachPanel
class and define an event handler for it.Publish the reserved events (defined in the Tizen.Applications.AttachPanel.EventType enumeration) from the panel side to trigger the event:
C#Copyprivate void AttachPanelResultCallback(object sender, ResultEventArgs e) { if (e.ResultCode != AppControlReplyResult.Succeeded) { /// Error handling return; } IEnumerable<string> selectedItems; if (e.Result.ExtraData.TryGet("http://tizen.org/appcontrol/data/selected", out selectedItems)) { foreach (var item in selectedItems) { Tizen.Log.Debug("AttachPanelTest", $"Selected content type is {e.Category}, selected item is {item}"); } } else { /// Error handling } } private void AttachPanelEventChanged(object sender, StateEventArgs e) { switch (e.EventType) { case EventType.ShowStart: /// Attach panel showing starts break; case EventType.ShowFinish: /// Attach panel showing ends break; case EventType.HideStart: /// Attach panel hiding starts break; case EventType.HideFinish: /// Attach panel hiding ends break; } } attachPanel.ResultCallback += AttachPanelResultCallback; attachPanel.EventChanged += AttachPanelEventChanged;
-
-
When the content category is not required, you can remove the content category using the RemoveCategory() method:
C#Copypublic void RemoveCategory() { attachPanel.RemoveCategory(ContentCategory.Image); attachPanel.RemoveCategory(ContentCategory.Camera); }
Create an attach panel in Xamarin
To create an attach panel in Xamarin, use the custom renderers as described below:
-
Get the Tizen platform conformant.
In Tizen,
BaseLayout.Parent
is the conformant of the main window:C#Copypublic static EvasObject WindowConformant { set; get; } protected override void OnCreate() { base.OnCreate(); WindowConformant = BaseLayout.Parent; LoadApplication(new App()); }
-
Create the custom control.
The following example creates an
AttachPanelLayout
custom control, which is a custom renderer showing the attach panel in theContentView
. The control also has theIsAttachPanelVisibleProperty
property, which determines whether the attach panel is shown or hidden:C#Copypublic partial class AttachPanelLayout : ContentView { public static readonly BindableProperty IsAttachPanelVisibleProperty = BindableProperty.Create("IsAttachPanelVisible", typeof(bool), typeof(AttachPanelLayout), true); public bool IsAttachPanelVisible { get { return (bool)GetValue(IsAttachPanelVisibleProperty); } set { SetValue(IsAttachPanelVisibleProperty, value); } } public AttachPanelLayout() { InitializeComponent(); } }
-
Use the custom control.
The following code example shows how the
attachPanelLayout
custom control can be used by a C# page:C#Copyprivate void OpenAttachPanelClicked(object sender, EventArgs e) { if (attachPanelLayout != null) { attachPanelLayout.IsAttachPanelVisible = true; } else { if (Content is StackLayout layout) { attachPanelLayout = new AttachPanelLayout(); layout.Children.Add(attachPanelLayout); } } }
-
Create the custom renderer on the Tizen platform:
C#Copy[assembly: ExportRenderer(typeof(AttachPanelLayout), typeof(AttachPanelLayoutRenderer))] namespace AttachPanelSample.Tizen.Mobile { public class AttachPanelLayoutRenderer : LayoutRenderer { private AttachPanel attachPanel; protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Layout> e) { base.OnElementChanged(e); if (attachPanel == null) { attachPanel = new AttachPanel(Program.WindowConformant); attachPanel.AddCategory(ContentCategory.Image, null); } attachPanel.Show(); if (e.OldElement != null) { attachPanel.ResultCallback -= AttachPanelResultCallback; attachPanel.EventChanged -= AttachPanelEventChanged; attachPanel = null; } if (e.NewElement != null) { attachPanel.ResultCallback += AttachPanelResultCallback; attachPanel.EventChanged += AttachPanelEventChanged; } } } }
Manage an attach panel
To manage an attach panel content, you can set extra data to a previously added content category using a bundle. Use the SetExtraData()
method of the Tizen.Applications.AttachPanel.AttachPanel class.
The following are the extra data supported by the attach panel:
http://tizen.org/appcontrol/data/total_count
: Total count of selected items in the Images categoryhttp://tizen.org/appcontrol/data/total_size
: Total size of selected items in the VideoRecorder category within the More tab
C#
Copy
public void SetTotalCountOfSelectedImages()
{
Bundle bundle = new Bundle();
bundle.AddItem("http://tizen.org/appcontrol/data/total_count", "3");
attachPanel.SetExtraData(ContentCategory.Image, bundle);
}
public void SetTotalSizeOfSelectedItems()
{
Bundle bundle = new Bundle();
bundle.AddItem("http://tizen.org/appcontrol/data/total_size", "200000");
attachPanel.SetExtraData(ContentCategory.VideoRecorder, bundle);
}
Related information
- Dependencies
- Tizen 4.0 and Higher