Added nosteps options attribute.
This commit is contained in:
parent
99640d31a8
commit
16ee56bf94
7 changed files with 61 additions and 44 deletions
31
README.md
31
README.md
|
@ -24,7 +24,7 @@ In the programming activity screen fill out the fields and click the 
|

|
||||||
|
|
||||||
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.
|
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 |
|
| 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 |
|
|`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 |
|
|`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 |
|
|`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
|
||||||
|
|
||||||
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.
|
1. Press *01 and enter Master Code.
|
||||||
2. Enter a Directory Code then press *.
|
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.
|
4. Press 0# TOGETHER when finished.
|
||||||
|
|
||||||
which would translate into:
|
which would translate into:
|
||||||
|
@ -89,14 +89,17 @@ which would translate into:
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
| Elements | Description |
|
Step 4 is configured in the `end` [Parameter](#parameters) since it only applies to manual/keypad programming.
|
||||||
|:---------|:-----------------------------------------------------------------------------------------|
|
|
||||||
|`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. |
|
|
||||||
|
|
||||||
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
|
#### 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 |
|
|`min` | Set the minimum value of a numeric field. | No |
|
||||||
|`max` | Set the maximum 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 |
|
|`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
|
#### DTMF
|
||||||
|
@ -132,7 +135,7 @@ Fields represent the data entry text fields on option screens.
|
||||||
"dtmf": "*01[MASTER],[FIELD:1]*,[FIELD:2]*"
|
"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.
|
The following markers will be substituted by their actual values upon dialing.
|
||||||
|
|
||||||
|
|
|
@ -323,7 +323,7 @@ class MainActivity : AppCompatActivity(), AnkoLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts.size == 0) {
|
if (opts.size == 0) {
|
||||||
errors.append(getString(R.string.validate_missing_ops))
|
errors.append(getString(R.string.validate_missing_opts))
|
||||||
}
|
}
|
||||||
|
|
||||||
opts.forEachIndexed { i, option ->
|
opts.forEachIndexed { i, option ->
|
||||||
|
@ -331,6 +331,10 @@ class MainActivity : AppCompatActivity(), AnkoLogger {
|
||||||
errors.append(getString(R.string.validate_missing_fields, i + 1))
|
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 ->
|
option.fields.forEachIndexed { j, field ->
|
||||||
if (field.size <= 0) {
|
if (field.size <= 0) {
|
||||||
errors.append(getString(R.string.validate_invalid_attr, i + 1, j + 1, "size"))
|
errors.append(getString(R.string.validate_invalid_attr, i + 1, j + 1, "size"))
|
||||||
|
|
|
@ -132,40 +132,42 @@ class ProgrammingActivity : AppCompatActivity(), AnkoLogger {
|
||||||
}
|
}
|
||||||
}.lparams(width = matchParent, height = matchParent)
|
}.lparams(width = matchParent, height = matchParent)
|
||||||
|
|
||||||
floatingActionButton {
|
if (!option.nosteps) {
|
||||||
imageResource = R.drawable.ic_menu_dialpad_lt
|
floatingActionButton {
|
||||||
|
imageResource = R.drawable.ic_menu_dialpad_lt
|
||||||
|
|
||||||
if (!option.nodial) {
|
if (!option.nodial) {
|
||||||
backgroundTintList = ColorStateList.valueOf(Color.GRAY)
|
backgroundTintList = ColorStateList.valueOf(Color.GRAY)
|
||||||
}
|
}
|
||||||
|
|
||||||
onClick {
|
onClick {
|
||||||
if (validateFields(fields, option)) {
|
if (validateFields(fields, option)) {
|
||||||
val dtmf = Dtmf.build(params.master, params.star, option, fields)
|
val dtmf = Dtmf.build(params.master, params.star, option, fields)
|
||||||
if (Dtmf.validate(dtmf, "${MainActivity.PAUSE}${params.star}${params.hash}")) {
|
if (Dtmf.validate(dtmf, "${MainActivity.PAUSE}${params.star}${params.hash}")) {
|
||||||
startActivity<StepsActivity>(
|
startActivity<StepsActivity>(
|
||||||
StepsActivity.EXTRA_STEPS to "$dtmf${MainActivity.PAUSE}${params.end}".split(','))
|
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 {
|
} 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()
|
Snackbar.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Snackbar.make(this@coordinatorLayout, R.string.error_invalid_field,
|
|
||||||
Snackbar.LENGTH_LONG).show()
|
|
||||||
}
|
}
|
||||||
}
|
}.lparams(width = wrapContent, height = wrapContent) {
|
||||||
}.lparams(width = wrapContent, height = wrapContent) {
|
if (option.nodial) {
|
||||||
if (option.nodial) {
|
gravity = BOTTOM or END
|
||||||
gravity = BOTTOM or END
|
rightMargin = dip(16)
|
||||||
rightMargin = dip(16)
|
} else {
|
||||||
} else {
|
gravity = BOTTOM or START
|
||||||
gravity = BOTTOM or START
|
leftMargin = dip(16)
|
||||||
leftMargin = dip(16)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bottomMargin = dip(16)
|
bottomMargin = dip(16)
|
||||||
elevation = dip(6).toFloat()
|
elevation = dip(6).toFloat()
|
||||||
behavior = ScrollAwareFABBehavior()
|
behavior = ScrollAwareFABBehavior()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!option.nodial) {
|
if (!option.nodial) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.io.Serializable
|
||||||
data class Option(var title: String,
|
data class Option(var title: String,
|
||||||
var fields: List<Field>,
|
var fields: List<Field>,
|
||||||
var nodial: Boolean,
|
var nodial: Boolean,
|
||||||
|
var nosteps: Boolean,
|
||||||
var dtmf: String) : Parcelable, Serializable, Comparable<Option> {
|
var dtmf: String) : Parcelable, Serializable, Comparable<Option> {
|
||||||
|
|
||||||
companion object {
|
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(
|
constructor(source: Parcel) : this(
|
||||||
source.readString(),
|
source.readString(),
|
||||||
source.createTypedArrayList(Field.CREATOR),
|
source.createTypedArrayList(Field.CREATOR),
|
||||||
1.equals(source.readInt()),
|
1.equals(source.readInt()),
|
||||||
|
1.equals(source.readInt()),
|
||||||
source.readString())
|
source.readString())
|
||||||
|
|
||||||
override fun compareTo(other: Option): Int {
|
override fun compareTo(other: Option): Int {
|
||||||
|
@ -52,6 +54,7 @@ data class Option(var title: String,
|
||||||
dest?.writeString(title)
|
dest?.writeString(title)
|
||||||
dest?.writeTypedList(fields)
|
dest?.writeTypedList(fields)
|
||||||
dest?.writeInt((if (nodial) 1 else 0))
|
dest?.writeInt((if (nodial) 1 else 0))
|
||||||
|
dest?.writeInt((if (nosteps) 1 else 0))
|
||||||
dest?.writeString(dtmf)
|
dest?.writeString(dtmf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,7 @@
|
||||||
"max": 9
|
"max": 9
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"nosteps": true,
|
||||||
"dtmf": "*16[MASTER],[FIELD:1]*"
|
"dtmf": "*16[MASTER],[FIELD:1]*"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -136,6 +137,7 @@
|
||||||
"max": 5
|
"max": 5
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"nosteps": true,
|
||||||
"dtmf": "*16[MASTER],[FIELD:1]*"
|
"dtmf": "*16[MASTER],[FIELD:1]*"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -124,6 +124,7 @@
|
||||||
"max": 9
|
"max": 9
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"nosteps": true,
|
||||||
"dtmf": "*16[MASTER],[FIELD:1]*"
|
"dtmf": "*16[MASTER],[FIELD:1]*"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -136,6 +137,7 @@
|
||||||
"max": 5
|
"max": 5
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"nosteps": true,
|
||||||
"dtmf": "*16[MASTER],[FIELD:1]*"
|
"dtmf": "*16[MASTER],[FIELD:1]*"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -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="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"><p><b>opts[<xliff:g id="opts">%1$d</xliff:g>]</b>, <b>fields[<xliff:g id="field">%2$d</xliff:g>]</b>: <font color=\"red\"><xliff:g id="attr">%3$s</xliff:g></font> invalid</string>
|
<string name="validate_invalid_attr"><p><b>opts[<xliff:g id="opts">%1$d</xliff:g>]</b>, <b>fields[<xliff:g id="field">%2$d</xliff:g>]</b>: <font color=\"red\"><xliff:g id="attr">%3$s</xliff:g></font> invalid</string>
|
||||||
<string name="validate_invalid_dtmf"><p><b>opts[<xliff:g id="opts">%1$d</xliff:g>]</b>, <font color=\"red\">dtmf</font> invalid:<br>    <font color=\"red\"><small><xliff:g id="dtmf">%2$s</xliff:g></small></font></p></string>
|
<string name="validate_invalid_dtmf"><p><b>opts[<xliff:g id="opts">%1$d</xliff:g>]</b>, <font color=\"red\">dtmf</font> invalid:<br>    <font color=\"red\"><small><xliff:g id="dtmf">%2$s</xliff:g></small></font></p></string>
|
||||||
|
<string name="validate_invalid_option"><p><b>opts[<xliff:g id="opts">%1$d</xliff:g>]</b>: <font color=\"red\"><xliff:g id="attr">%2$s</xliff:g></font></font> invalid</string>
|
||||||
<string name="validate_invalid_param"><p><b>params</b>: <font color=\"red\"><xliff:g id="param">%1$s</xliff:g></font> invalid</p></string>
|
<string name="validate_invalid_param"><p><b>params</b>: <font color=\"red\"><xliff:g id="param">%1$s</xliff:g></font> invalid</p></string>
|
||||||
<string name="validate_missing_fields"><p><b>opts[<xliff:g id="opts">%1$d</xliff:g>]</b>: <font color=\"red\">fields</font> missing</string>
|
<string name="validate_missing_fields"><p><b>opts[<xliff:g id="opts">%1$d</xliff:g>]</b>: <font color=\"red\">fields</font> missing</string>
|
||||||
<string name="validate_missing_param"><p><p><b>params</b>: <font color=\"red\"><xliff:g id="param">%1$s</xliff:g></font> missing</p></string>
|
<string name="validate_missing_param"><p><p><b>params</b>: <font color=\"red\"><xliff:g id="param">%1$s</xliff:g></font> missing</p></string>
|
||||||
<string name="validate_missing_ops"><font color=\"red\">opts</font> missing.</string>
|
<string name="validate_missing_opts"><font color=\"red\">opts</font> missing.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue