Added nosteps options attribute.

This commit is contained in:
Erik C. Thauvin 2016-08-26 12:03:01 -07:00
parent 99640d31a8
commit 16ee56bf94
7 changed files with 61 additions and 44 deletions

View file

@ -24,7 +24,7 @@ In the programming activity screen fill out the fields and click the ![Dial](ima
![Configurations](images/screenshots/configurations_framed_small.png)
To switch configuration, choose `Configurations` under the toolbar menu and select the desired configured.
To switch configuration, choose `Configurations` under the toolbar menu and select the desired configuration.
To import a new configuration, select `Import` in the _Configurations_ dialog.
@ -50,7 +50,7 @@ Parameters define the configuration's global settings.
| Parameter | Description | Required |
|:-----------|:-------------------------------------------------------------------------------------------------|:---------|
|`name` | The configuration name. | Yes |
|`name` | The name of the configuration. | Yes |
|`star` | The key used to start, acknowledge or terminate programming steps. Most systems use the `*` key. | Yes |
|`hash` | They key used to in place of numbers when applicable. Most system use the `#` key | No |
|`end` | The end programming manual sequence. For example DoorKing uses `0` and `#` pressed together. | No |
@ -58,13 +58,13 @@ Parameters define the configuration's global settings.
### Options
Options define the data used to create programming activity screens in the app.
Opts define the data used to create programming activity screens in the app.
For example, the system's manual would list the steps to _Programming 7-digit Phone Numbers_ as something like:
For example, the system's manual lists the steps to _Programming 7-digit Phone Numbers_ as:
1. Press *01 and enter Master Code.
2. Enter a Directory Code then press *.
3. Enter a 7-digit Phone Number then press *.
3. Enter a 7-digit Phone Number then press *. If the number is less than 7-digits, enter # in the empty spaces.
4. Press 0# TOGETHER when finished.
which would translate into:
@ -89,14 +89,17 @@ which would translate into:
]
```
| Elements | Description |
|:---------|:-----------------------------------------------------------------------------------------|
|`title` | The title of the option. |
|`fields` | See [Fields](#fields) |
|`dtmf` | See [DTMF](#dtmf) |
|`nodial` | Indicate thar remote programming is not available. Steps must be executed at the keypad. |
Step 4 is configured in the `end` [Parameter](#parameters) since it only applies to manual/keypad programming.
All are required, except `nodial`
| Elements | Description |
|:---------|:--------------------------------------------------------------------------------------------------|
|`title` | The title of the option. |
|`fields` | See [Fields](#fields) |
|`dtmf` | See [DTMF](#dtmf) |
|`nodial` | Indicate thar remote programming is not available. Steps must be executed manually at the keypad. |
|`nosteps` | Indicate that manual/keypad steps are not available. Programming must be executed remotely. |
All are required, except `nodial` and `nosteps` which are mutually exclusive.
#### Fields
@ -123,7 +126,7 @@ Fields represent the data entry text fields on option screens.
|`min` | Set the minimum value of a numeric field. | No |
|`max` | Set the maximum value of a numeric field. | No |
|`alpha` | Set to `true` if the field is alphanumeric. | No |
|`hash` | Set to `true` if the field accept the [Parameters](#parameters) `hash` value in place of a digit. | No |
|`hash` | Set to `true` if the field accept the `hash` [Parameter](#parameters) value in place of a digit. | No |
#### DTMF
@ -132,7 +135,7 @@ Fields represent the data entry text fields on option screens.
"dtmf": "*01[MASTER],[FIELD:1]*,[FIELD:2]*"
```
DTMF represent the dialing sequence for the programming steps. A comma (`,`) can be used to specify a pause in the dialing sequence.
DTMF represent the dialing sequence for the programming steps. A comma (`,`) should be used to specify a pause in the dialing sequence.
The following markers will be substituted by their actual values upon dialing.

View file

@ -323,7 +323,7 @@ class MainActivity : AppCompatActivity(), AnkoLogger {
}
if (opts.size == 0) {
errors.append(getString(R.string.validate_missing_ops))
errors.append(getString(R.string.validate_missing_opts))
}
opts.forEachIndexed { i, option ->
@ -331,6 +331,10 @@ class MainActivity : AppCompatActivity(), AnkoLogger {
errors.append(getString(R.string.validate_missing_fields, i + 1))
}
if (option.nosteps && option.nodial) {
errors.append(getString(R.string.validate_invalid_option, i + 1, "nodial/nosteps"))
}
option.fields.forEachIndexed { j, field ->
if (field.size <= 0) {
errors.append(getString(R.string.validate_invalid_attr, i + 1, j + 1, "size"))

View file

@ -132,40 +132,42 @@ class ProgrammingActivity : AppCompatActivity(), AnkoLogger {
}
}.lparams(width = matchParent, height = matchParent)
floatingActionButton {
imageResource = R.drawable.ic_menu_dialpad_lt
if (!option.nosteps) {
floatingActionButton {
imageResource = R.drawable.ic_menu_dialpad_lt
if (!option.nodial) {
backgroundTintList = ColorStateList.valueOf(Color.GRAY)
}
if (!option.nodial) {
backgroundTintList = ColorStateList.valueOf(Color.GRAY)
}
onClick {
if (validateFields(fields, option)) {
val dtmf = Dtmf.build(params.master, params.star, option, fields)
if (Dtmf.validate(dtmf, "${MainActivity.PAUSE}${params.star}${params.hash}")) {
startActivity<StepsActivity>(
StepsActivity.EXTRA_STEPS to "$dtmf${MainActivity.PAUSE}${params.end}".split(','))
onClick {
if (validateFields(fields, option)) {
val dtmf = Dtmf.build(params.master, params.star, option, fields)
if (Dtmf.validate(dtmf, "${MainActivity.PAUSE}${params.star}${params.hash}")) {
startActivity<StepsActivity>(
StepsActivity.EXTRA_STEPS to "$dtmf${MainActivity.PAUSE}${params.end}".split(','))
} else {
Snackbar.make(this@coordinatorLayout, getString(R.string.error_invalid_dtmf, dtmf),
Snackbar.LENGTH_LONG).show()
}
} else {
Snackbar.make(this@coordinatorLayout, getString(R.string.error_invalid_dtmf, dtmf),
Snackbar.make(this@coordinatorLayout, R.string.error_invalid_field,
Snackbar.LENGTH_LONG).show()
}
} else {
Snackbar.make(this@coordinatorLayout, R.string.error_invalid_field,
Snackbar.LENGTH_LONG).show()
}
}
}.lparams(width = wrapContent, height = wrapContent) {
if (option.nodial) {
gravity = BOTTOM or END
rightMargin = dip(16)
} else {
gravity = BOTTOM or START
leftMargin = dip(16)
}
}.lparams(width = wrapContent, height = wrapContent) {
if (option.nodial) {
gravity = BOTTOM or END
rightMargin = dip(16)
} else {
gravity = BOTTOM or START
leftMargin = dip(16)
}
bottomMargin = dip(16)
elevation = dip(6).toFloat()
behavior = ScrollAwareFABBehavior()
bottomMargin = dip(16)
elevation = dip(6).toFloat()
behavior = ScrollAwareFABBehavior()
}
}
if (!option.nodial) {

View file

@ -24,6 +24,7 @@ import java.io.Serializable
data class Option(var title: String,
var fields: List<Field>,
var nodial: Boolean,
var nosteps: Boolean,
var dtmf: String) : Parcelable, Serializable, Comparable<Option> {
companion object {
@ -35,12 +36,13 @@ data class Option(var title: String,
}
}
constructor() : this("", emptyList(), false, "")
constructor() : this("", emptyList(), false, false, "")
constructor(source: Parcel) : this(
source.readString(),
source.createTypedArrayList(Field.CREATOR),
1.equals(source.readInt()),
1.equals(source.readInt()),
source.readString())
override fun compareTo(other: Option): Int {
@ -52,6 +54,7 @@ data class Option(var title: String,
dest?.writeString(title)
dest?.writeTypedList(fields)
dest?.writeInt((if (nodial) 1 else 0))
dest?.writeInt((if (nosteps) 1 else 0))
dest?.writeString(dtmf)
}

View file

@ -124,6 +124,7 @@
"max": 9
}
],
"nosteps": true,
"dtmf": "*16[MASTER],[FIELD:1]*"
},
{
@ -136,6 +137,7 @@
"max": 5
}
],
"nosteps": true,
"dtmf": "*16[MASTER],[FIELD:1]*"
},
{

View file

@ -124,6 +124,7 @@
"max": 9
}
],
"nosteps": true,
"dtmf": "*16[MASTER],[FIELD:1]*"
},
{
@ -136,6 +137,7 @@
"max": 5
}
],
"nosteps": true,
"dtmf": "*16[MASTER],[FIELD:1]*"
},
{

View file

@ -16,8 +16,9 @@
<string name="title_template_step">Step <xliff:g id="step_number">%1$d</xliff:g> of <xliff:g id="steps_count">%2$d</xliff:g></string>
<string name="validate_invalid_attr">&lt;p>&lt;b>opts[<xliff:g id="opts">%1$d</xliff:g>]&lt;/b>, &lt;b>fields[<xliff:g id="field">%2$d</xliff:g>]&lt;/b>: &lt;font color=\"red\"><xliff:g id="attr">%3$s</xliff:g>&lt;/font> invalid</string>
<string name="validate_invalid_dtmf">&lt;p>&lt;b>opts[<xliff:g id="opts">%1$d</xliff:g>]&lt;/b>, &lt;font color=\"red\">dtmf&lt;/font> invalid:&lt;br>&#160;&#160;&#160;&#160;&lt;font color=\"red\">&lt;small><xliff:g id="dtmf">%2$s</xliff:g>&lt;/small>&lt;/font>&lt;/p></string>
<string name="validate_invalid_option">&lt;p>&lt;b>opts[<xliff:g id="opts">%1$d</xliff:g>]&lt;/b>: &lt;font color=\"red\"><xliff:g id="attr">%2$s</xliff:g>&lt;/font>&lt;/font> invalid</string>
<string name="validate_invalid_param">&lt;p>&lt;b>params&lt;/b>: &lt;font color=\"red\"><xliff:g id="param">%1$s</xliff:g>&lt;/font> invalid&lt;/p></string>
<string name="validate_missing_fields">&lt;p>&lt;b>opts[<xliff:g id="opts">%1$d</xliff:g>]&lt;/b>: &lt;font color=\"red\">fields&lt;/font> missing</string>
<string name="validate_missing_param">&lt;p>&lt;p>&lt;b>params&lt;/b>: &lt;font color=\"red\"><xliff:g id="param">%1$s</xliff:g>&lt;/font> missing&lt;/p></string>
<string name="validate_missing_ops">&lt;font color=\"red\">opts&lt;/font> missing.</string>
<string name="validate_missing_opts">&lt;font color=\"red\">opts&lt;/font> missing.</string>
</resources>