From wiki.ginstr.com
Jump to: navigation, search
m
m
Line 1: Line 1:
 
<div style="float:right; clear:both; margin-left:0.5em;">__TOC__</div>
 
<div style="float:right; clear:both; margin-left:0.5em;">__TOC__</div>
 
[[Category:Widget_Library]]
 
[[Category:Widget_Library]]
;Inherited classes: [http://developer.android.com/reference/android/view/View.html View]
+
;Inherited classes: <code>[http://developer.android.com/reference/android/view/View.html View]</code>
;Android class type: [http://developer.android.com/reference/android/widget/LinearLayout.html LinearLayout]
+
;Android class type: <code>[http://developer.android.com/reference/android/widget/LinearLayout.html LinearLayout]</code>
 
;Child elements: <code>[http://developer.android.com/reference/android/widget/EditText.html EditText]</code>, <code>[http://developer.android.com/reference/android/widget/Button.html Button]</code>
 
;Child elements: <code>[http://developer.android.com/reference/android/widget/EditText.html EditText]</code>, <code>[http://developer.android.com/reference/android/widget/Button.html Button]</code>
 
;Widget XML tag: <code><com.ginstr.widgets.GnEditText></code>
 
;Widget XML tag: <code><com.ginstr.widgets.GnEditText></code>

Revision as of 16:12, 28 June 2016

Inherited classes
View
Android class type
LinearLayout
Child elements
EditText, Button
Widget XML tag
<com.ginstr.widgets.GnEditText>


GnEditText is a multi-source EditText. It’s used to enter text data or acquire it from other sources.

Other sources are:

  • NFC
  • QR

XML Attributes Description

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

Attribute Description
#gn:s_sourceType* Defines source type (keyboard input, NFC, QR, GPS, serial, time etc...)
#gn:qrCameraRequired Checks if camera is required
#gn:showAddress Sets GPS data type displayed in EditText
#gn:typeface Sets font for child EditText
#gn:s_text Sets text into EditText
#gn:s_hint Sets text hint into EditText
#gn:textStyle Sets style for child EditText
#gn:background Sets background color for child EditText
#gn:textColor Sets font color for child EditText
#gn:textSize Sets font size for child EditText
#gn:s_nfcAlertType Sets alert type when NFC is scanned
#gn:s_gravity Sets the gravity of EditText content, this means text alignment within widget
#gn:minLines Sets minimum lines for EditText
#gn:maxLines Sets maximum lines for EditText
#gn:noServiceOnUpdate Prevents content update if EditText contains some data
#gn:focusable If present prevents user from focusing widget and entering data
#gn:nfcRequired Checks if NFC is required
#gn:Visible Shows or hides widget
#gn:nfcReadingsInterval Sets reading interval for NFC,
#gn:nfcReadingIntervalForSameContent Reading will be ignored and will only work if NFC with same id is read twice in a row within time defined by #gn:nfcReadingsInterval
#gn:nfcReadingGetAdditionalInfo Returns additional information about tag
#gn:s_nfcContentType When NFC is read instead of the ID the embedded content of NFC tag is read
#android:background Sets the background image for the element
#gn:inputType Defines the input mode for the keyboard which appears on the screen
#android:textColorHint Used to change the hint color when #gn:s_hint is set
#gn:useEntry Displays a button and entry field where a user can type “IMEI” and retrieve serial
#gn:nfcIntSequence Defines internal sequence of processing NFC scans when more then one NFC widget on screen is receiving NFC scan event
#gn:isMasked Masks the content of EditText gets with password artefacts
#gn:decimalFormat If GnEditText is target of calculation, set this attribute to change format of result
#gn:paddingLeft Defines internal space between text and left outer edge of the control
#gn:paddingRight Defines internal space between text and right outer edge of the control
#gn:paddingBottom Defines internal space between text and bottom outer edge of the control
#gn:paddingTop Defines internal space between text and top outer edge of the control
#gn:nfcActionLostFocus Triggers gn:act_setOnNfc when focus on GnEditText is lost
#gn:s_customLayoutXml Points to an XML file in “control” folder of ginstr app
#gn:trimDecimalPlaces Decimal value will be trimmed from widget when data is gathered from it
#gn:actionSetOnFocusLost Activates on focus lost attribute triggering
#gn:setOnFocusLost Action set which executes once focus is lost on GnEditText
#gn:autoLoadTimestamp Prevents autoloading timestamp
#gn:data_type Defines datatype of widget
#gn:typingTimeInterval Represents number of seconds after gn:act_setOnTypingEnd will be executed
#gn:autoLoadLocation Disables auto loading of GPS location when screen is loaded
#gn:autoAdjustHeight Changes behavior of input field
#gn:gpsPrecision Used in combination with #gn:s_sourceType="gps" and if #gn:gpsPrecision = “true” to ensure that only real gps data will be used

Alternative layout

Alternative layout can be set into control folder. It can have any name ending with ".xml" and it must have valid XML structure.

It must contain two widgets with following ids:

EditText @+id/enEditText 
this represents input field for data
Button@+id/enEditTextButton 
this button is visible in certain configurations like when widget has gn:s_sourceType="qr"

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

NFC scan modes

This option is only available on GnEditText when the widget has the mode set to “NFC”. NFC scan modes that are only relevant when there is more than one widget on screen that has gn:s_sourceType=“nfc“.

There are two modes of scanning available:

  1. Chain mode NFC scanning
  2. Focus mode NFC scanning

Chain mode NFC scanning

Chain mode scanning means that the widget can be set in a chain and scanned one after another without the need of a user to click into each widget every time a scan is performed.

Two attributes were added:

gn:nfcStartSequence 
once screen is loaded it defines the first widget into which data will be set after an NFC scan is performed and its value sets the target for the next scan
gn:nfcSequence 
every widget that is in the scanning chain but it’s not the starting widget should have this attribute to define the next target where data will be saved in next NFC scan
gn:typingTimeInterval 
represents a time from last GnEditText value change (in ms) after gn:act_setOnTypingEnd event will be raised
gn:act_setOnTypingEnd 
event raised after gn:typingTimeInterval is passed

i.e.<source lang="xml"><GnEditText

     android:id=“@+id/firstWidget“
     gn:nfcStartSequence=“@+id/secondWidget“ 
    .../>

<GnEditText

     android:id=“@+id/secondWidget“
     gn:nfcSequence=“@+id/firstWidget“ 
    .../>

</source>

Also notice in example that in gn:nfcSequence=“@+id/firstWidget“ is set. This is called circular chain of NFC scans, it means that when the last widget in the chain is scanned it will jump back to first widget on the screen. When a circular chain is made you do not need to reload screen to restart NFC scans.

If there is no circular chain once the last NFC tag in a chain is scanned and there is no next target every new scan will set data in the last widget in chain.

Focus mode NFC scanning

Once the screen is loaded if there is an NFC chain it is active. As soon as a widget is clicked on the chain is broken and only the focus mode scanning will work. This means that the widget in which the pointer is blinking (last tapped widget) will receive the results of the next NFC scan.

The only way to enable the chain scanning mode is to reload the screen where the chain exists.

imeOptions

imeOptions define keyboard functionality that will be valid when options are enabled upon that GnEditText.

To activate imeOptions on a GnEditText attribute “gn:imeOptions” has to be set.

There are four action types of imeOptions:

  1. actionGo
  2. actionSend
  3. actionNext
  4. actionDone

actionGo

When action go is set on GnEditText it is necessary to add another attribute “gn:imeActionGo”.

The imeActionGo defines target layout that will be opened by pressing the “enter/go” key on a virtual keyboard. i.e.<source lang="xml">gn:imeOptions="actionGo" gn:imeActionGo="@+id/targetRootLayout"</source>


actionSend

When action sent is set on GnEditText it is necessary to add another attribute to GnEditText “gn:imeActionSend”

actionSend defines action or action set that will get executed when the keyboard button enter/go is pressed. i.e.<source lang="xml">gn:imeOptions="actionSend" gn:imeActionSend="[action]|[action values],..."</source>

actionNext

When action next is set on GnEditText it is necessary to add another attribute to GnEditText “gn:imeActionNext”.

actionNext will take user to the next field that accepts text on pressing enter/go on keyboard. Options to navigate to the next fields are: FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_BACKWARD, FOCUS_FORWARD. i.e.<source lang="xml">gn:imeOptions="actionNext" gn:imeActionNext="FOCUS_DOWN"</source>

actionDone

actionDone will hide the keyboard when enter/go on virtual keyboard is pressed. i.e.<source lang="xml">gn:imeOptions=“actionDone”</source>

gn:s_sourceType

Defines source type

(String) values = input, NFC, QR, GPS, wifi, bt, serial

Value Description
input (default) Standard input via an on screen keyboard
NFC Input via a keyboard or by scanning a NFC tag. If there are multiple fields in same screen click on one to set active before scanning
QR Displays QR scan child button. Input via a keyboard or by selecting the button which will launch scanning application
GPS displays GPS location, there can be multiple GPS widgets on the same screen (related to attribute #gn:showAddress)
serial Displays serial number generated from IMEI. If attribute gn:useEntry is present then it will look for serial based on IMEI number provided in widget otherwise it will get IMEI from the device
time Displays current date time in milliseconds in widget
agversion Sets current ag version in the GnEditText on load of screen
aguser Sets current logged ag user into GnEditText widget on load of screen
wifi Displays WiFi fingerprint, there can be multiple WiFi fingerprint widgets on the same screen
gsm Displays GSM fingerprint, there can be multiple GSM fingerprint widgets on the same screen
bt Displays Bluetooth fingerprint, there can be multiple Bluetooth fingerprint widgets on the same screen

gn:qrCameraRequired

Checks if camera is required

(Boolean) values = true, false

Value Description
true (Relevant for QR sourceType) if device doesn’t have a camera it shows error dialog
false (Relevant for QR sourceType) it will check for camera and if none is present it will only disable child button for scan and leave option for manual entry

gn:showAddress

Sets GPS data type displayed in EditText

(Boolean) values = true, false

Value Description
true (Relevant for GPS sourceType) shows address of GPS location in EditText field
false (Relevant for GPS sourceType) shows coordinates of GPS location in EditText field

gn:typeface

Sets font for child EditText

(String) values = sans, serif, monospace

gn:s_text

Sets text into EditText

(String) values = text or @string/resourceId

gn:s_hint

Sets text hint into EditText

(String) values = text or @string/resourceId

gn:textStyle

Sets style for child EditText

(String) values = normal, bold, italic

gn:background

Sets background color for child EditText

(Hex) values i.e. = #000000 (hex color value)

gn:textColor

Sets font color for child EditText

(Hex) values i.e. = #000000 (hex color value)

gn:textSize

Sets font size for child EditText

(Dimension) value i.e. = 10dp or 10sp

gn:s_nfcAlertType

Sets alert type when NFC is scanned

Value Description
vibrate= Phone will vibrate with a NFC scan
sound Phone will play a sound with a NFC scan

gn:s_gravity

Sets the gravity of EditText content, this means text alignment within widget

(String) value i.e. = CENTER, CENTER_HORIZONTAL

gn:minLines

Sets minimum lines for EditText

(Integer) values i.e. = 1, 2, 4, ...

gn:maxLines

Sets maximum lines for EditText

(Integer) values i.e. = 1, 2, 4, ...

gn:noServiceOnUpdate

Prevents content update if EditText contains some data

values = none

gn:focusable

If present prevents user from focusing widget and entering data

Values = none

gn:nfcRequired

Checks if NFC is required

(Boolean) values = true, false

Value Description
true (Relevant for NFC sourceType) if not present it shows error dialog, if present but turned off shows dialog to open Android settings NFC screen
false (Relevant for NFC sourceType) does not check for NFC hardware

gn:Visible

Shows or hides widget

(Boolean) values = true, false

Value Description
true Displays widget. (NFC) click in control is necessary for NFC to work on this field
false Hides widget. (NFC) control gets autofocus for NFC,

IMPORTANT : there can be only one GnEditText on layout with this attribute false and sourceType nfc

gn:nfcReadingsInterval

Sets reading interval for NFC, if less time than defined has passed a message will be shown and reading ignored

(Integer) value = 1, 2, 5, …

If multiple widgets use NFC each one has its own individual timer

gn:nfcReadingIntervalForSameContent

Reading will be ignored and will only work if NFC with same id is read twice in a row within time defined by #gn:nfcReadingsInterval. If set to false then different id tags will produce same behaviour

(Boolean) values = true, false

gn:nfcReadingGetAdditionalInfo

Returns additional information about tag

gn:s_nfcContentType

When NFC is read instead of the ID the embedded content of NFC tag is read

(String) value = embedded

android:background

Sets the background image for the element

(String) value = @drawable/nameOfResource,

i.e. @drawable/imageOne the image resource has to be set inside of drawable folder (read more here)

gn:inputType

Defines the input mode for the keyboard which appears on the screen. For example setting the input type to number will display a numeric keyboard when user taps on this GnEditText.

Input types and combinations supported:

Input Type Description
TYPE_CLASS_NUMBER allows “0123456789” characters to be entered
TYPE_CLASS_NUMBER|TYPE_NUMBER_FLAG_SIGNED|TYPE_NUMBER_FLAG_DECIMAL allows "0123456789.,-" to be entered
TYPE_CLASS_NUMBER|TYPE_NUMBER_FLAG_SIGNED allows "0123456789-" to be entered
TYPE_NUMBER_FLAG_DECIMAL allows "0123456789.," to be entered
TYPE_CLASS_PHONE allows “0123456789+” and opens numerical keyboard

android:textColorHint

Used to change the hint color when #gn:s_hint is set

gn:useEntry

This attribute is only used when #gn:s_sourceType is set to serial. If this attribute is set the widget will display a button and entry field where a user can type “IMEI” and retrieve serial. If the field is omitted then only the entry field is displayed and the value is retrieve automatically for the current device

gn:nfcIntSequence

Defines internal sequence of processing NFC scans when more then one NFC widget on screen is receiving NFC scan event. This is an alternative to chain mode NFC scanning

gn:isMasked

When set the content of EditText gets masked with password artefacts

(Boolean) values = true, false

gn:decimalFormat

If GnEditText is target of calculation, set this attribute to change format of result. By default format is set to 0.00 which will show calculation result as i.e. 2.13, 121.67,… Please check format available on this link (under heading “Special Pattern Characters”).

gn:paddingLeft

If set, padding provides ability to define internal space between text and left outer edge of the control.

Use of measuring unit with value is obligatory

(String) value = 12dp, 1dp, etc...

gn:paddingRight

If set, padding provides ability to define internal space between text and right outer edge of the control.

Use of measuring unit with value is obligatory

(String) value = 12dp, 1dp, etc...

gn:paddingBottom

If set, padding provides ability to define internal space between text and bottom outer edge of the control.

Use of measuring unit with value is obligatory

(String) value = 12dp, 1dp, etc...

gn:paddingTop

If set, padding provides ability to define internal space between text and top outer edge of the control.

Use of measuring unit with value is obligatory

(String) value = 12dp, 1dp, etc...

gn:nfcActionLostFocus

If attribute is set to true it will trigger gn:act_setOnNfc when focus on GnEditText is lost

(Boolean) values = true, false

gn:s_customLayoutXml

If set it should point to an XML file in “control” folder of ginstr app

(String) : someXmlLayoutName.xml

More details in #Alternative layout

gn:trimDecimalPlaces

If attribute is true, decimal value will be trimmed from widget when data is gathered from it

(Boolean) value : true

gn:actionSetOnFocusLost

In order to activate on focus lost attribute triggering this attribute has to be set to true

(Boolean) value : true

gn:setOnFocusLost

Action set which executes once focus is lost on GnEditText

gn:autoLoadTimestamp

Prevents autoloading timestamp when widget with gn:s_sourceType=”time” is loaded on screen

(Boolean) value : false

gn:data_type

Defines datatype of widget

gn:typingTimeInterval

Represents number of seconds after gn:act_setOnTypingEnd will be executed

gn:autoLoadLocation

When set to falseand widget is set to type "GPS" it disables auto loading of GPS location when screen is loaded. In this case GPS information will have to be loaded from database or gn:act_reloadAutofilledWidgets will have to be called to resolve current location

gn:autoAdjustHeight

When set changes behaviour of input field. When input field has no content it is stretched to show entire hint text. As soon as text is entered into field height of field shrinks to size of inputted text,

(Boolean) value : true

gn:gpsPrecision

Used in combination with #gn:s_sourceType="gps" and if #gn:gpsPrecision = “true” to ensure that only real gps data will be used.