Added nosteps options attribute.
This commit is contained in:
parent
99640d31a8
commit
16ee56bf94
7 changed files with 61 additions and 44 deletions
|
@ -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"))
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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]*"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -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]*"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -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"><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_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_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_ops"><font color=\"red\">opts</font> missing.</string>
|
||||
<string name="validate_missing_opts"><font color=\"red\">opts</font> missing.</string>
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue