From wiki.ginstr.com
Revision as of 17:14, 28 June 2016 by Mark (talk | contribs) (XML Attributes Description)
Jump to: navigation, search
Inherited classes
View
Android class type
LinearLayout
Child elements
TextView, Button
Widget XML tag
<com.ginstr.widgets.GnMediaAction>

Widget provides media functionality. Recording of audio, video or photo material. It is a composite control made of TextView and Button. Widget saves files to a certain folder depending on the media type. Upon saving file, string path to file is added to the array list which contains all paths to the media taken in this form.

Only one actionType can be set on widget.

XML Attributes Description

Note: An attribute marked with asterisk (*) is a mandatory parameter when creating widget.

Attribute Description
gn:s_actionType* Sets media type (photo, video, audio, document etc...)
gn:maxFileSize Sets maximum file size in kilobytes for photos. Images are resized before being saved to database
gn:maxMediaTaken Defines maximum media content to be added by user. Once user reaches maximum a message will be shown and user will be not be able to store more media
gn:backgroundPhoto Defines background image of the widget
gn:backgroundPhotoPressed Defines background image (pressed) of the widget
gn:singleValueMode If enabled, widget will store only a single media item. Each new media item will overwrite the old one
gn:hidePhotoText Hides text on button that is displayed as standard
gn:hideCounter Hides counter text that is displayed as standard
gn:setAfterMediaTaken Defines action set which will be executed after user has taken media with this widget.
gn:qrAutoEnableTorch If set, flashlight will turn on automatically when QR scan screen opens
gn:rep_attachment Enables server side replication flag to replicate files from server to device for certain column at “generate table” moment

Alternative layout

Alternative layout can be set into control folder. It must be named "widget_en_mediaaction.xml" and it must have valid XML structure.

It must contain three widgets with following ids:

TextView @+id/enMediaActionTextView 
this text field represents counter of taken media that is visible over the buttons
Button@+id/enMediaActionButton 
this button is the main button and is always visible
Button@+id/enMediaActionButton2 
this button is visible in situations when two options are available (i.e. when user can take media by taking a picture or selecting it from gallery)

The rest of the widgets and attributes in this XML structure can be defined as required, there are no constraints.

gn:s_actionType

Sets media type

(String) values = photo, video, audio, gallery, photogallery, document

Value Description
photo Initiates the camera with a button press, after successful photo action it saves file to path and saves path to array of paths
video Initiates the video camera with a button press, after successful capture of a video it saves file to path and saves path to array of paths
audio Initiates the microphone with a button press, with the next button press stops recording and saves file to path and saves path to array of paths
gallery Initiates the menu to select a photo from a device with a button press, after a successful photo selection, the image path is saved to array of paths
photogallery Displays two buttons : “take photo” which works like photo, and “select photo” which works as gallery. Once photo is taken, the image path is saved to array of paths
document Initiates the menu to select a file from a device. After file is selected, its path is added to array of document paths in widget

gn:maxFileSize

Before image is saved to database, presence of this attribute reduces image multiple times until it reaches to first value under defined size.

(Integer) value = i.e. 75, expressed in kilobytes.

This attribute is only valid on GnMediaAction that is of actionType = photo

gn:maxMediaTaken

Defines maximum media content to be added by user. Once user reaches maximum a message will be shown and user will be not be able to store more media.

(Integer) value = 1, 2, ... 10

gn:backgroundPhoto

Defines background image of the widget

(String) value = resource pointer i.e. @drawable/button_red or patch 9 resource pointer @drawable/button_red.9

gn:backgroundPhotoPressed

Defines background image pressed for the widget

(String) value = resource pointer i.e. @drawable/button_red or patch 9 resource pointer @drawable/button_red.9

gn:singleValueMode

If enabled, widget will store only a single media item. Each new media item will overwrite the old one.

(Boolean) values = true, false

gn:hidePhotoText

Hides text on button that is displayed as standard

gn:hideCounter

Hides counter text that is displayed as standard

gn:setAfterMediaTaken

Defines action set which will be executed after user has taken media with this widget.

gn:qrAutoEnableTorch

If set, flashlight will turn on automatically when QR scan screen opens

gn:rep_attachment

Enables server side replication flag to replicate files from server to device for certain column at “generate table” moment

(Boolean) values = true, false