Added fromHtml function.
This commit is contained in:
parent
d23e767796
commit
0902c0ebff
1 changed files with 17 additions and 12 deletions
|
@ -23,12 +23,10 @@ import android.app.AlertDialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v7.app.AppCompatActivity
|
import android.support.v7.app.AppCompatActivity
|
||||||
import android.text.Html
|
import android.text.*
|
||||||
import android.text.InputFilter
|
|
||||||
import android.text.InputType
|
|
||||||
import android.text.TextUtils
|
|
||||||
import android.text.method.LinkMovementMethod
|
import android.text.method.LinkMovementMethod
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
|
@ -75,6 +73,14 @@ class MainActivity : AppCompatActivity(), AnkoLogger {
|
||||||
val PAUSE = ','
|
val PAUSE = ','
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun fromHtml(s: String) : Spanned {
|
||||||
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
|
return Html.fromHtml(s, Html.FROM_HTML_MODE_LEGACY)
|
||||||
|
} else {
|
||||||
|
return Html.fromHtml(s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun initConfigurations() {
|
fun initConfigurations() {
|
||||||
try {
|
try {
|
||||||
ObjectInputStream(openFileInput(currentConfigData)).use {
|
ObjectInputStream(openFileInput(currentConfigData)).use {
|
||||||
|
@ -92,7 +98,7 @@ class MainActivity : AppCompatActivity(), AnkoLogger {
|
||||||
if (validateConfig(config, errors)) {
|
if (validateConfig(config, errors)) {
|
||||||
info(">>> ${config.params.name}: successfully loaded")
|
info(">>> ${config.params.name}: successfully loaded")
|
||||||
} else {
|
} else {
|
||||||
info(">>> ${config.params.name}: " + Html.fromHtml(errors.toString()))
|
info(">>> ${config.params.name}: " + fromHtml(errors.toString()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +136,7 @@ class MainActivity : AppCompatActivity(), AnkoLogger {
|
||||||
if (errors.length > 0) {
|
if (errors.length > 0) {
|
||||||
alert {
|
alert {
|
||||||
title(R.string.alert_config_error)
|
title(R.string.alert_config_error)
|
||||||
message(Html.fromHtml("$errors"))
|
message(fromHtml("$errors"))
|
||||||
cancelButton { }
|
cancelButton { }
|
||||||
}.show()
|
}.show()
|
||||||
}
|
}
|
||||||
|
@ -170,7 +176,7 @@ class MainActivity : AppCompatActivity(), AnkoLogger {
|
||||||
// phone
|
// phone
|
||||||
textInputLayout {
|
textInputLayout {
|
||||||
horizontalPadding = dip(40)
|
horizontalPadding = dip(40)
|
||||||
val edtPhone = editText() {
|
val editText = editText() {
|
||||||
lparams(width = matchParent)
|
lparams(width = matchParent)
|
||||||
inputType = InputType.TYPE_CLASS_PHONE
|
inputType = InputType.TYPE_CLASS_PHONE
|
||||||
hint = getString(R.string.hint_phone_number)
|
hint = getString(R.string.hint_phone_number)
|
||||||
|
@ -187,13 +193,13 @@ class MainActivity : AppCompatActivity(), AnkoLogger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fields.add(Pair(edtPhone, 0))
|
fields.add(Pair(editText, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
// master code
|
// master code
|
||||||
textInputLayout {
|
textInputLayout {
|
||||||
horizontalPadding = dip(40)
|
horizontalPadding = dip(40)
|
||||||
val edtMasterCode = editText() {
|
val editText = editText() {
|
||||||
lparams(width = matchParent)
|
lparams(width = matchParent)
|
||||||
inputType = InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_PASSWORD
|
inputType = InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_PASSWORD
|
||||||
hint = getString(R.string.hint_master_code)
|
hint = getString(R.string.hint_master_code)
|
||||||
|
@ -223,7 +229,7 @@ class MainActivity : AppCompatActivity(), AnkoLogger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fields.add(Pair(edtMasterCode, size))
|
fields.add(Pair(editText, size))
|
||||||
}
|
}
|
||||||
|
|
||||||
// programming title
|
// programming title
|
||||||
|
@ -268,8 +274,7 @@ class MainActivity : AppCompatActivity(), AnkoLogger {
|
||||||
R.id.action_about -> {
|
R.id.action_about -> {
|
||||||
val alert = alert {
|
val alert = alert {
|
||||||
title(R.string.app_name)
|
title(R.string.app_name)
|
||||||
message(Html.fromHtml(
|
message(fromHtml(getString(R.string.about_message, BuildConfig.VERSION_NAME)))
|
||||||
getString(R.string.about_message, BuildConfig.VERSION_NAME)))
|
|
||||||
icon(R.mipmap.ic_launcher)
|
icon(R.mipmap.ic_launcher)
|
||||||
okButton {}
|
okButton {}
|
||||||
}.show()
|
}.show()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue