From wiki.ginstr.com
Jump to: navigation, search

GnMediaAction

Widget XML tag
<com.ginstr.widgets.GnMediaAction>
Description
GnMediaAction provides media functionality. Recording of audio, video or photo material. It is a composite control made of TextView and Button.
It 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.

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...)

Additional information here

gn:maxFileSize Sets maximum file size in kilobytes for photos.

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

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

Can be

  • hardcoded, i.e. 75, expressed in kilobytes.
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:singleValueMode If enabled, widget will store only a single media item. Each new media item will overwrite the old one

Can be

  • true
  • false
gn:hidePhotoText Hides text on button that is displayed as standard

Can be

  • true
  • false
gn:hideCounter Hides counter text that is displayed as standard

Can be

  • true
  • false
gn:setAfterMediaTaken Event which will be executed after user has taken media with this widget.

More information here

gn:buttonText Defines text for internal main media button @+id/enMediaActionButton

Can be

  • @string
gn:layoutSignature target id of root layout which will be open after button for take signature is pressed.

This attribute only works when attribute gn:s_actionType="signature" is set.

gn:act_onMediaActionClick Action set which will be executed when user clicks on media action, before taking media.
gn:photoGPSandTimestampShow Enables embedding GPS and timestamp to taken image. When this option is enabled it's required to obtain GPS position before taking a photo.

Works in combination with gn:forceGpsReception and gn:gpsMaximumWaitingTime.

Can be

  • true
  • false
gn:photoGPSandTimestampFontSize Determines size of font of embedded text. Needs to be used with gn:photoGPSandTimestampShow set to true.

Can be (default value 15):

  • number
gn:act_setAfterGalleryPhotoDeleted Action set which will be executed when on related GnMediaGallery widget user deletes a photo
gn:minRequiredItems Defines minimum media content to be added by user.
gn:forceGpsReception Works in combination with gn:photoGPSandTimestampShow to block taking a photo until the GPS coordinate is received.

Ensures that the GPS coordinate will always be embedded in the photo.

Can be

  • true
  • false
gn:gpsMaximumWaitingTime Works in combination with gn:photoGPSandTimestampShow to block taking a photo for defined number of miliseconds or if the GPS coordinate is retrieved.

Does not guarantee that the GPS coordinate will be embedded in the photo.

Not working if gn:forceGpsReception is "true".

Can be

  • hardcoded, i.e. 2000

Events

gn:act_setClick
gn:act_setLongClick
gn:setAfterMediaTaken

Data types

Input
text
video
audio
documents
pictures
signature
Output
video
audio
documents
pictures
signature

Example

<com.ginstr.widgets.GnMediaAction
  android:id="@+id/report_photosElectricalWorkNextOrder"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_marginRight="5dp"
  android:layout_alignParentRight="true"
  gn:act_setAfterMediaTaken="[gn:act_copyData]|[@+id/report_photosElectricalWorkNextOrder,@+id/report_photosElectricalWorkNextOrderView]"
  gn:maxMediaTaken="5"
  gn:maxFileSize="75"
  gn:hidePhotoText="true"
  gn:s_actionType="photo" />

Action types

Sets media type

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
signature Initiates the signature activity. After signature is created, its path is added to array of signature paths in widget

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.
Widget Name Description
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)