From 16ee56bf943bc47c8774a9236d9cd81af3e5d230 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Fri, 26 Aug 2016 12:03:01 -0700 Subject: [PATCH] Added nosteps options attribute. --- README.md | 31 +++++----- .../tesremoteprogrammer/MainActivity.kt | 6 +- .../ProgrammingActivity.kt | 56 ++++++++++--------- .../tesremoteprogrammer/models/Option.kt | 5 +- app/src/main/res/raw/dks_1802.json | 2 + app/src/main/res/raw/dks_1802_epd.json | 2 + app/src/main/res/values/strings.xml | 3 +- 7 files changed, 61 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index d8d80e8..a6682f0 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/MainActivity.kt b/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/MainActivity.kt index fbe227e..6e4e49e 100644 --- a/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/MainActivity.kt +++ b/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/MainActivity.kt @@ -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")) diff --git a/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/ProgrammingActivity.kt b/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/ProgrammingActivity.kt index 434243a..30fae8d 100644 --- a/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/ProgrammingActivity.kt +++ b/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/ProgrammingActivity.kt @@ -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.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.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) { diff --git a/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/models/Option.kt b/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/models/Option.kt index 8e03bc5..0d0b62a 100644 --- a/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/models/Option.kt +++ b/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/models/Option.kt @@ -24,6 +24,7 @@ import java.io.Serializable data class Option(var title: String, var fields: List, var nodial: Boolean, + var nosteps: Boolean, var dtmf: String) : Parcelable, Serializable, Comparable