Minor code cleanups

This commit is contained in:
Juha Heinanen
2021-04-03 17:50:30 +03:00
parent d8a4853bb0
commit a2afd8fdcc
@@ -58,7 +58,7 @@ object Utils {
fun alertView(context: Context, title: String, message: String, action: () -> (Unit) = {}) { fun alertView(context: Context, title: String, message: String, action: () -> (Unit) = {}) {
val titleView = View.inflate(context, R.layout.alert_title, null) as TextView val titleView = View.inflate(context, R.layout.alert_title, null) as TextView
titleView.text = title titleView.text = title
with (AlertDialog.Builder(context, R.style.AlertDialog)) { with(AlertDialog.Builder(context, R.style.AlertDialog)) {
setCustomTitle(titleView) setCustomTitle(titleView)
setMessage(message) setMessage(message)
setPositiveButton(R.string.ok) { dialog, _ -> setPositiveButton(R.string.ok) { dialog, _ ->
@@ -132,7 +132,7 @@ object Utils {
val params = uriParams(aor) val params = uriParams(aor)
return params.isEmpty() || return params.isEmpty() ||
((params.size == 1) && ((params.size == 1) &&
params[0] in arrayOf("transport=udp", "transport=tcp","transport=tls")) params[0] in arrayOf("transport=udp", "transport=tcp", "transport=tls"))
} }
fun checkStunUri(uri: String): Boolean { fun checkStunUri(uri: String): Boolean {
@@ -353,7 +353,7 @@ object Utils {
override fun beforeTextChanged(sequence: CharSequence, start: Int, count: Int, after: Int) {} override fun beforeTextChanged(sequence: CharSequence, start: Int, count: Int, after: Int) {}
override fun onTextChanged(sequence: CharSequence, start: Int, before: Int, count: Int) { override fun onTextChanged(sequence: CharSequence, start: Int, before: Int, count: Int) {
val text = sequence.subSequence(start, start + count).toString() val text = sequence.subSequence(start, start + count).toString()
if (text.length > 0) { if (text.isNotEmpty()) {
val digit = text[0] val digit = text[0]
val call = Call.ofCallp(callp) val call = Call.ofCallp(callp)
if (call == null) { if (call == null) {
@@ -420,7 +420,7 @@ object Utils {
fun getFileContents(filePath: String): ByteArray? { fun getFileContents(filePath: String): ByteArray? {
try { try {
return File(filePath).readBytes() return File(filePath).readBytes()
} catch(e: FileNotFoundException) { } catch (e: FileNotFoundException) {
Log.e("Baresip", "File '$filePath' not found: ${e.printStackTrace()}") Log.e("Baresip", "File '$filePath' not found: ${e.printStackTrace()}")
return null return null
} catch (e: Exception) { } catch (e: Exception) {
@@ -444,7 +444,7 @@ object Utils {
if (file.exists()) file.delete() if (file.exists()) file.delete()
try { try {
val out = FileOutputStream(file) val out = FileOutputStream(file)
val scaledBitmap = createScaledBitmap (bitmap, 96, 96, true) val scaledBitmap = createScaledBitmap(bitmap, 96, 96, true)
scaledBitmap.compress(Bitmap.CompressFormat.PNG, 100, out) scaledBitmap.compress(Bitmap.CompressFormat.PNG, 100, out)
out.flush() out.flush()
out.close() out.close()