comparison android/DWindows.kt @ 2578:a36448beb7f7

Android: Implement dw_window_set_style() for static text widgets. Clean up a number of warnings reported by Android Studio.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 22 May 2021 21:53:41 +0000
parents db097ec28c90
children 68ee9a89e0f0
comparison
equal deleted inserted replaced
2577:6fdab466d7a2 2578:a36448beb7f7
491 return -1 491 return -1
492 } 492 }
493 493
494 fun getRowAndColumn(row: Int, column: Int): Any? 494 fun getRowAndColumn(row: Int, column: Int): Any?
495 { 495 {
496 var index: Int = (row * columns.size) + column 496 val index: Int = (row * columns.size) + column
497 497
498 if(index > -1 && index < data.size) { 498 if(index > -1 && index < data.size) {
499 return data[index] 499 return data[index]
500 } 500 }
501 return null 501 return null
502 } 502 }
503 503
504 fun setRowAndColumn(row: Int, column: Int, obj: Any?) 504 fun setRowAndColumn(row: Int, column: Int, obj: Any?)
505 { 505 {
506 var index: Int = (row * columns.size) + column 506 val index: Int = (row * columns.size) + column
507 507
508 if(index > -1 && index < data.size && column < types.size) { 508 if(index > -1 && index < data.size && column < types.size) {
509 // Verify the data matches the column type 509 // Verify the data matches the column type
510 if((((types[column] and 1) != 0) && (obj is Drawable)) || 510 if((((types[column] and 1) != 0) && (obj is Drawable)) ||
511 (((types[column] and (1 shl 1)) != 0) && (obj is String)) || 511 (((types[column] and (1 shl 1)) != 0) && (obj is String)) ||
596 } 596 }
597 } 597 }
598 598
599 fun addRows(count: Int): Long 599 fun addRows(count: Int): Long
600 { 600 {
601 var startRow: Long = numberOfRows().toLong() 601 val startRow: Long = numberOfRows().toLong()
602 602
603 for(i in 0 until count) 603 for(i in 0 until count)
604 { 604 {
605 for(j in 0 until columns.size) 605 for(j in 0 until columns.size)
606 { 606 {
784 Configuration.UI_MODE_NIGHT_YES -> { darkMode = 1 } // Night mode is active, we're using dark theme 784 Configuration.UI_MODE_NIGHT_YES -> { darkMode = 1 } // Night mode is active, we're using dark theme
785 } 785 }
786 786
787 // Send a DW_SIGNAL_CONFIGURE on orientation change 787 // Send a DW_SIGNAL_CONFIGURE on orientation change
788 if(windowLayout != null) { 788 if(windowLayout != null) {
789 var width: Int = windowLayout!!.width 789 val width: Int = windowLayout!!.width
790 var height: Int = windowLayout!!.height 790 val height: Int = windowLayout!!.height
791 791
792 eventHandlerInt(windowLayout as View, 1, width, height, 0, 0) 792 eventHandlerInt(windowLayout as View, 1, width, height, 0, 0)
793 } 793 }
794 } 794 }
795 795
915 } 915 }
916 916
917 fun windowNew(title: String, style: Int): LinearLayout? { 917 fun windowNew(title: String, style: Int): LinearLayout? {
918 if (firstWindow) { 918 if (firstWindow) {
919 waitOnUiThread { 919 waitOnUiThread {
920 var dataArrayMap = SimpleArrayMap<String, Long>() 920 val dataArrayMap = SimpleArrayMap<String, Long>()
921 windowLayout = LinearLayout(this) 921 windowLayout = LinearLayout(this)
922 922
923 windowLayout!!.visibility = View.GONE 923 windowLayout!!.visibility = View.GONE
924 windowLayout!!.tag = dataArrayMap 924 windowLayout!!.tag = dataArrayMap
925 setContentView(windowLayout) 925 setContentView(windowLayout)
931 return windowLayout 931 return windowLayout
932 } 932 }
933 return null 933 return null
934 } 934 }
935 935
936 fun windowSetStyle(window: View, style: Int, mask: Int)
937 {
938 waitOnUiThread {
939 if (window is TextView && window !is EditText) {
940 val text = window as TextView
941 val ourmask = (Gravity.HORIZONTAL_GRAVITY_MASK or Gravity.VERTICAL_GRAVITY_MASK) and mask
942
943 if (ourmask != 0) {
944 // Gravity with the masked parts zeroed out
945 val newgravity = style and ourmask
946
947 text.gravity = newgravity
948 }
949 }
950 }
951 }
952
936 fun windowFromId(window: View, cid: Int): View { 953 fun windowFromId(window: View, cid: Int): View {
937 return window.findViewById(cid) 954 return window.findViewById(cid)
938 } 955 }
939 956
940 fun windowSetData(window: View, name: String, data: Long) { 957 fun windowSetData(window: View, name: String, data: Long) {
941 if (window.tag != null) { 958 if (window.tag != null) {
942 var dataArrayMap: SimpleArrayMap<String, Long> = window.tag as SimpleArrayMap<String, Long> 959 val dataArrayMap: SimpleArrayMap<String, Long> = window.tag as SimpleArrayMap<String, Long>
943 960
944 if (data != 0L) { 961 if (data != 0L) {
945 dataArrayMap.put(name, data) 962 dataArrayMap.put(name, data)
946 } else { 963 } else {
947 dataArrayMap.remove(name) 964 dataArrayMap.remove(name)
951 968
952 fun windowGetData(window: View, name: String): Long { 969 fun windowGetData(window: View, name: String): Long {
953 var retval: Long = 0L 970 var retval: Long = 0L
954 971
955 if (window.tag != null) { 972 if (window.tag != null) {
956 var dataArrayMap: SimpleArrayMap<String, Long> = window.tag as SimpleArrayMap<String, Long> 973 val dataArrayMap: SimpleArrayMap<String, Long> = window.tag as SimpleArrayMap<String, Long>
957 974
958 if(dataArrayMap.containsKey(name)) { 975 if(dataArrayMap.containsKey(name)) {
959 retval = dataArrayMap.get(name)!! 976 retval = dataArrayMap.get(name)!!
960 } 977 }
961 } 978 }
975 val italic: Boolean = fontname.contains(" Italic") 992 val italic: Boolean = fontname.contains(" Italic")
976 val font = fontname.substringAfter('.') 993 val font = fontname.substringAfter('.')
977 var fontFamily = font 994 var fontFamily = font
978 var typeface: Typeface? = null 995 var typeface: Typeface? = null
979 996
980 if (bold && font != null) { 997 if (bold) {
981 fontFamily = font.substringBefore(" Bold") 998 fontFamily = font.substringBefore(" Bold")
982 } else if (italic && font != null) { 999 } else if (italic) {
983 fontFamily = font.substringBefore(" Italic") 1000 fontFamily = font.substringBefore(" Italic")
984 } 1001 }
985 1002
986 if (fontFamily != null) { 1003 var style: Int = Typeface.NORMAL
987 var style: Int = Typeface.NORMAL 1004 if (bold && italic) {
988 if (bold && italic) { 1005 style = Typeface.BOLD_ITALIC
989 style = Typeface.BOLD_ITALIC 1006 } else if (bold) {
990 } else if (bold) { 1007 style = Typeface.BOLD
991 style = Typeface.BOLD 1008 } else if (italic) {
992 } else if (italic) { 1009 style = Typeface.ITALIC
993 style = Typeface.ITALIC 1010 }
994 } 1011 typeface = Typeface.create(fontFamily, style)
995 typeface = Typeface.create(fontFamily, style) 1012
996 }
997 return typeface 1013 return typeface
998 } 1014 }
999 return Typeface.DEFAULT 1015 return Typeface.DEFAULT
1000 } 1016 }
1001 1017
1008 } 1024 }
1009 1025
1010 if(typeface != null) { 1026 if(typeface != null) {
1011 waitOnUiThread { 1027 waitOnUiThread {
1012 if (window is TextView) { 1028 if (window is TextView) {
1013 var textview: TextView = window 1029 val textview: TextView = window
1014 textview.typeface = typeface 1030 textview.typeface = typeface
1015 if(size != null) { 1031 if(size != null) {
1016 textview.textSize = size 1032 textview.textSize = size
1017 } 1033 }
1018 } else if (window is Button) { 1034 } else if (window is Button) {
1019 var button: Button = window 1035 val button: Button = window
1020 button.typeface = typeface 1036 button.typeface = typeface
1021 if(size != null) { 1037 if(size != null) {
1022 button.textSize = size 1038 button.textSize = size
1023 } 1039 }
1024 } else if(window is DWRender) { 1040 } else if(window is DWRender) {
1025 var render: DWRender = window 1041 val render: DWRender = window
1026 render.typeface = typeface 1042 render.typeface = typeface
1027 if(size != null) { 1043 if(size != null) {
1028 render.fontsize = size 1044 render.fontsize = size
1029 } 1045 }
1030 } 1046 }
1043 colorback = Color.TRANSPARENT 1059 colorback = Color.TRANSPARENT
1044 } 1060 }
1045 1061
1046 waitOnUiThread { 1062 waitOnUiThread {
1047 if (window is TextView) { 1063 if (window is TextView) {
1048 var textview: TextView = window 1064 val textview: TextView = window
1049 1065
1050 // Handle DW_CLR_DEFAULT 1066 // Handle DW_CLR_DEFAULT
1051 if(fore == 16) { 1067 if(fore == 16) {
1052 val value = TypedValue() 1068 val value = TypedValue()
1053 this.theme.resolveAttribute(R.attr.editTextColor, value, true) 1069 this.theme.resolveAttribute(R.attr.editTextColor, value, true)
1054 colorfore = value.data 1070 colorfore = value.data
1055 } 1071 }
1056 textview.setTextColor(colorfore) 1072 textview.setTextColor(colorfore)
1057 textview.setBackgroundColor(colorback) 1073 textview.setBackgroundColor(colorback)
1058 } else if (window is Button) { 1074 } else if (window is Button) {
1059 var button: Button = window 1075 val button: Button = window
1060 1076
1061 // Handle DW_CLR_DEFAULT 1077 // Handle DW_CLR_DEFAULT
1062 if(fore == 16) { 1078 if(fore == 16) {
1063 val value = TypedValue() 1079 val value = TypedValue()
1064 // colorButtonNormal requires API 21... use the editTextColor... 1080 this.theme.resolveAttribute(R.attr.colorButtonNormal, value, true)
1065 // on older versions as a placeholder... this is probably wrong
1066 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
1067 this.theme.resolveAttribute(R.attr.colorButtonNormal, value, true)
1068 } else {
1069 this.theme.resolveAttribute(R.attr.editTextColor, value, true)
1070 }
1071 colorfore = value.data 1081 colorfore = value.data
1072 } 1082 }
1073 button.setTextColor(colorfore) 1083 button.setTextColor(colorfore)
1074 button.setBackgroundColor(colorback) 1084 button.setBackgroundColor(colorback)
1075 } else if(window is LinearLayout) { 1085 } else if(window is LinearLayout) {
1076 var box: LinearLayout = window 1086 val box: LinearLayout = window
1077 1087
1078 box.setBackgroundColor(colorback) 1088 box.setBackgroundColor(colorback)
1079 } 1089 }
1080 } 1090 }
1081 } 1091 }
1082 1092
1083 fun windowSetText(window: View, text: String) { 1093 fun windowSetText(window: View, text: String) {
1084 waitOnUiThread { 1094 waitOnUiThread {
1085 if (window is TextView) { 1095 if (window is TextView) {
1086 var textview: TextView = window 1096 val textview: TextView = window
1087 textview.text = text 1097 textview.text = text
1088 } else if (window is Button) { 1098 } else if (window is Button) {
1089 var button: Button = window 1099 val button: Button = window
1090 button.text = text 1100 button.text = text
1091 } else if (window is LinearLayout) { 1101 } else if (window is LinearLayout) {
1092 // TODO: Make sure this is actually the top-level layout, not just a box 1102 // TODO: Make sure this is actually the top-level layout, not just a box
1093 this.title = text 1103 this.title = text
1094 } 1104 }
1098 fun windowGetText(window: View): String? { 1108 fun windowGetText(window: View): String? {
1099 var text: String? = null 1109 var text: String? = null
1100 1110
1101 waitOnUiThread { 1111 waitOnUiThread {
1102 if (window is TextView) { 1112 if (window is TextView) {
1103 var textview: TextView = window 1113 val textview: TextView = window
1104 text = textview.text.toString() 1114 text = textview.text.toString()
1105 } else if (window is Button) { 1115 } else if (window is Button) {
1106 var button: Button = window 1116 val button: Button = window
1107 text = button.text.toString() 1117 text = button.text.toString()
1108 } else if (window is LinearLayout) { 1118 } else if (window is LinearLayout) {
1109 // TODO: Make sure this is actually the top-level layout, not just a box 1119 // TODO: Make sure this is actually the top-level layout, not just a box
1110 text = this.title.toString() 1120 text = this.title.toString()
1111 } 1121 }
1123 } 1133 }
1124 } 1134 }
1125 } 1135 }
1126 1136
1127 fun clipboardGetText(): String { 1137 fun clipboardGetText(): String {
1128 var cm: ClipboardManager = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager 1138 val cm: ClipboardManager = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
1129 var clipdata = cm.primaryClip 1139 val clipdata = cm.primaryClip
1130 1140
1131 if (clipdata != null && clipdata.itemCount > 0) { 1141 if (clipdata != null && clipdata.itemCount > 0) {
1132 return clipdata.getItemAt(0).coerceToText(this).toString() 1142 return clipdata.getItemAt(0).coerceToText(this).toString()
1133 } 1143 }
1134 return "" 1144 return ""
1135 } 1145 }
1136 1146
1137 fun clipboardSetText(text: String) { 1147 fun clipboardSetText(text: String) {
1138 var cm: ClipboardManager = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager 1148 val cm: ClipboardManager = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
1139 var clipdata = ClipData.newPlainText("text", text) 1149 val clipdata = ClipData.newPlainText("text", text)
1140 1150
1141 cm.setPrimaryClip(clipdata) 1151 cm.setPrimaryClip(clipdata)
1142 } 1152 }
1143 1153
1144 fun boxNew(type: Int, pad: Int): LinearLayout? { 1154 fun boxNew(type: Int, pad: Int): LinearLayout? {
1145 var box: LinearLayout? = null 1155 var box: LinearLayout? = null
1146 waitOnUiThread { 1156 waitOnUiThread {
1147 box = LinearLayout(this) 1157 box = LinearLayout(this)
1148 var dataArrayMap = SimpleArrayMap<String, Long>() 1158 val dataArrayMap = SimpleArrayMap<String, Long>()
1149 1159
1150 box!!.tag = dataArrayMap 1160 box!!.tag = dataArrayMap
1151 box!!.layoutParams = 1161 box!!.layoutParams =
1152 LinearLayout.LayoutParams( 1162 LinearLayout.LayoutParams(
1153 LinearLayout.LayoutParams.WRAP_CONTENT, 1163 LinearLayout.LayoutParams.WRAP_CONTENT,
1167 var scrollBox: ScrollView? = null 1177 var scrollBox: ScrollView? = null
1168 1178
1169 waitOnUiThread { 1179 waitOnUiThread {
1170 val box = LinearLayout(this) 1180 val box = LinearLayout(this)
1171 scrollBox = ScrollView(this) 1181 scrollBox = ScrollView(this)
1172 var dataArrayMap = SimpleArrayMap<String, Long>() 1182 val dataArrayMap = SimpleArrayMap<String, Long>()
1173 1183
1174 scrollBox!!.tag = dataArrayMap 1184 scrollBox!!.tag = dataArrayMap
1175 box.layoutParams = 1185 box.layoutParams =
1176 LinearLayout.LayoutParams( 1186 LinearLayout.LayoutParams(
1177 LinearLayout.LayoutParams.MATCH_PARENT, 1187 LinearLayout.LayoutParams.MATCH_PARENT,
1208 // Handle scrollboxes by pulling the LinearLayout 1218 // Handle scrollboxes by pulling the LinearLayout
1209 // out of the ScrollView to pack into 1219 // out of the ScrollView to pack into
1210 if (boxview is LinearLayout) { 1220 if (boxview is LinearLayout) {
1211 box = boxview 1221 box = boxview
1212 } else if (boxview is ScrollView) { 1222 } else if (boxview is ScrollView) {
1213 var sv: ScrollView = boxview 1223 val sv: ScrollView = boxview
1214 1224
1215 if (sv.getChildAt(0) is LinearLayout) { 1225 if (sv.getChildAt(0) is LinearLayout) {
1216 box = sv.getChildAt(0) as LinearLayout 1226 box = sv.getChildAt(0) as LinearLayout
1217 } 1227 }
1218 } 1228 }
1274 } 1284 }
1275 } 1285 }
1276 } 1286 }
1277 } 1287 }
1278 1288
1279 var params: LinearLayout.LayoutParams = LinearLayout.LayoutParams(w, h) 1289 val params: LinearLayout.LayoutParams = LinearLayout.LayoutParams(w, h)
1280 1290
1281 // Handle expandable items by giving them a weight... 1291 // Handle expandable items by giving them a weight...
1282 // in the direction of the box. 1292 // in the direction of the box.
1283 if (box.orientation == LinearLayout.VERTICAL) { 1293 if (box.orientation == LinearLayout.VERTICAL) {
1284 if (vsize != 0) { 1294 if (vsize != 0) {
1288 if (hsize != 0) { 1298 if (hsize != 0) {
1289 params.weight = weight 1299 params.weight = weight
1290 } 1300 }
1291 } 1301 }
1292 // Gravity needs to match the expandable settings 1302 // Gravity needs to match the expandable settings
1293 var grav: Int = Gravity.CLIP_HORIZONTAL or Gravity.CLIP_VERTICAL 1303 val grav: Int = Gravity.CLIP_HORIZONTAL or Gravity.CLIP_VERTICAL
1294 if (hsize != 0 && vsize != 0) { 1304 if (hsize != 0 && vsize != 0) {
1295 params.gravity = Gravity.FILL or grav 1305 params.gravity = Gravity.FILL or grav
1296 } else if (hsize != 0) { 1306 } else if (hsize != 0) {
1297 params.gravity = Gravity.FILL_HORIZONTAL or grav 1307 params.gravity = Gravity.FILL_HORIZONTAL or grav
1298 } else if (vsize != 0) { 1308 } else if (vsize != 0) {
1308 } 1318 }
1309 } 1319 }
1310 1320
1311 fun boxUnpack(item: View) { 1321 fun boxUnpack(item: View) {
1312 waitOnUiThread { 1322 waitOnUiThread {
1313 var box: LinearLayout = item.parent as LinearLayout 1323 val box: LinearLayout = item.parent as LinearLayout
1314 box.removeView(item) 1324 box.removeView(item)
1315 } 1325 }
1316 } 1326 }
1317 1327
1318 fun boxUnpackAtIndex(box: LinearLayout, index: Int): View? { 1328 fun boxUnpackAtIndex(box: LinearLayout, index: Int): View? {
1328 1338
1329 fun buttonNew(text: String, cid: Int): Button? { 1339 fun buttonNew(text: String, cid: Int): Button? {
1330 var button: Button? = null 1340 var button: Button? = null
1331 waitOnUiThread { 1341 waitOnUiThread {
1332 button = Button(this) 1342 button = Button(this)
1333 var dataArrayMap = SimpleArrayMap<String, Long>() 1343 val dataArrayMap = SimpleArrayMap<String, Long>()
1334 1344
1335 button!!.tag = dataArrayMap 1345 button!!.tag = dataArrayMap
1336 button!!.text = text 1346 button!!.text = text
1337 button!!.id = cid 1347 button!!.id = cid
1338 button!!.setOnClickListener { 1348 button!!.setOnClickListener {
1344 1354
1345 fun bitmapButtonNew(text: String, resid: Int): ImageButton? { 1355 fun bitmapButtonNew(text: String, resid: Int): ImageButton? {
1346 var button: ImageButton? = null 1356 var button: ImageButton? = null
1347 waitOnUiThread { 1357 waitOnUiThread {
1348 button = ImageButton(this) 1358 button = ImageButton(this)
1349 var dataArrayMap = SimpleArrayMap<String, Long>() 1359 val dataArrayMap = SimpleArrayMap<String, Long>()
1350 1360
1351 button!!.tag = dataArrayMap 1361 button!!.tag = dataArrayMap
1352 button!!.id = resid 1362 button!!.id = resid
1353 button!!.setImageResource(resid) 1363 button!!.setImageResource(resid)
1354 button!!.setOnClickListener { 1364 button!!.setOnClickListener {
1360 1370
1361 fun bitmapButtonNewFromFile(text: String, cid: Int, filename: String): ImageButton? { 1371 fun bitmapButtonNewFromFile(text: String, cid: Int, filename: String): ImageButton? {
1362 var button: ImageButton? = null 1372 var button: ImageButton? = null
1363 waitOnUiThread { 1373 waitOnUiThread {
1364 button = ImageButton(this) 1374 button = ImageButton(this)
1365 var dataArrayMap = SimpleArrayMap<String, Long>() 1375 val dataArrayMap = SimpleArrayMap<String, Long>()
1366 var exts = arrayOf("", ".png", ".webp", ".jpg", ".jpeg", ".gif") 1376 val exts = arrayOf("", ".png", ".webp", ".jpg", ".jpeg", ".gif")
1367 1377
1368 button!!.tag = dataArrayMap 1378 button!!.tag = dataArrayMap
1369 button!!.id = cid 1379 button!!.id = cid
1370 button!!.setOnClickListener { 1380 button!!.setOnClickListener {
1371 eventHandlerSimple(button!!, 8) 1381 eventHandlerSimple(button!!, 8)
1390 1400
1391 fun bitmapButtonNewFromData(text: String, cid: Int, data: ByteArray, length: Int): ImageButton? { 1401 fun bitmapButtonNewFromData(text: String, cid: Int, data: ByteArray, length: Int): ImageButton? {
1392 var button: ImageButton? = null 1402 var button: ImageButton? = null
1393 waitOnUiThread { 1403 waitOnUiThread {
1394 button = ImageButton(this) 1404 button = ImageButton(this)
1395 var dataArrayMap = SimpleArrayMap<String, Long>() 1405 val dataArrayMap = SimpleArrayMap<String, Long>()
1396 val b = BitmapFactory.decodeByteArray(data,0, length) 1406 val b = BitmapFactory.decodeByteArray(data,0, length)
1397 1407
1398 button!!.tag = dataArrayMap 1408 button!!.tag = dataArrayMap
1399 button!!.id = cid 1409 button!!.id = cid
1400 button!!.setOnClickListener { 1410 button!!.setOnClickListener {
1407 1417
1408 fun entryfieldNew(text: String, cid: Int, password: Int): EditText? { 1418 fun entryfieldNew(text: String, cid: Int, password: Int): EditText? {
1409 var entryfield: EditText? = null 1419 var entryfield: EditText? = null
1410 1420
1411 waitOnUiThread { 1421 waitOnUiThread {
1412 var dataArrayMap = SimpleArrayMap<String, Long>() 1422 val dataArrayMap = SimpleArrayMap<String, Long>()
1413 entryfield = EditText(this) 1423 entryfield = EditText(this)
1414 1424
1415 entryfield!!.tag = dataArrayMap 1425 entryfield!!.tag = dataArrayMap
1416 entryfield!!.id = cid 1426 entryfield!!.id = cid
1417 entryfield!!.isSingleLine = true 1427 entryfield!!.isSingleLine = true
1431 1441
1432 fun radioButtonNew(text: String, cid: Int): RadioButton? { 1442 fun radioButtonNew(text: String, cid: Int): RadioButton? {
1433 var radiobutton: RadioButton? = null 1443 var radiobutton: RadioButton? = null
1434 1444
1435 waitOnUiThread { 1445 waitOnUiThread {
1436 var dataArrayMap = SimpleArrayMap<String, Long>() 1446 val dataArrayMap = SimpleArrayMap<String, Long>()
1437 radiobutton = RadioButton(this) 1447 radiobutton = RadioButton(this)
1438 1448
1439 radiobutton!!.tag = dataArrayMap 1449 radiobutton!!.tag = dataArrayMap
1440 radiobutton!!.id = cid 1450 radiobutton!!.id = cid
1441 radiobutton!!.text = text 1451 radiobutton!!.text = text
1448 1458
1449 fun checkboxNew(text: String, cid: Int): CheckBox? { 1459 fun checkboxNew(text: String, cid: Int): CheckBox? {
1450 var checkbox: CheckBox? = null 1460 var checkbox: CheckBox? = null
1451 1461
1452 waitOnUiThread { 1462 waitOnUiThread {
1453 var dataArrayMap = SimpleArrayMap<String, Long>() 1463 val dataArrayMap = SimpleArrayMap<String, Long>()
1454 1464
1455 checkbox = CheckBox(this) 1465 checkbox = CheckBox(this)
1456 checkbox!!.tag = dataArrayMap 1466 checkbox!!.tag = dataArrayMap
1457 checkbox!!.id = cid 1467 checkbox!!.id = cid
1458 checkbox!!.text = text 1468 checkbox!!.text = text
1465 1475
1466 fun checkOrRadioSetChecked(control: View, state: Int) 1476 fun checkOrRadioSetChecked(control: View, state: Int)
1467 { 1477 {
1468 waitOnUiThread { 1478 waitOnUiThread {
1469 if (control is CheckBox) { 1479 if (control is CheckBox) {
1470 var checkbox: CheckBox = control 1480 val checkbox: CheckBox = control
1471 checkbox.isChecked = state != 0 1481 checkbox.isChecked = state != 0
1472 } else if (control is RadioButton) { 1482 } else if (control is RadioButton) {
1473 var radiobutton: RadioButton = control 1483 val radiobutton: RadioButton = control
1474 radiobutton.isChecked = state != 0 1484 radiobutton.isChecked = state != 0
1475 } 1485 }
1476 } 1486 }
1477 } 1487 }
1478 1488
1480 { 1490 {
1481 var retval: Boolean = false 1491 var retval: Boolean = false
1482 1492
1483 waitOnUiThread { 1493 waitOnUiThread {
1484 if (control is CheckBox) { 1494 if (control is CheckBox) {
1485 var checkbox: CheckBox = control 1495 val checkbox: CheckBox = control
1486 retval = checkbox.isChecked 1496 retval = checkbox.isChecked
1487 } else if (control is RadioButton) { 1497 } else if (control is RadioButton) {
1488 var radiobutton: RadioButton = control 1498 val radiobutton: RadioButton = control
1489 retval = radiobutton.isChecked 1499 retval = radiobutton.isChecked
1490 } 1500 }
1491 } 1501 }
1492 return retval 1502 return retval
1493 } 1503 }
1494 1504
1495 fun textNew(text: String, cid: Int, status: Int): TextView? { 1505 fun textNew(text: String, cid: Int, status: Int): TextView? {
1496 var textview: TextView? = null 1506 var textview: TextView? = null
1497 1507
1498 waitOnUiThread { 1508 waitOnUiThread {
1499 var dataArrayMap = SimpleArrayMap<String, Long>() 1509 val dataArrayMap = SimpleArrayMap<String, Long>()
1500 1510
1501 textview = TextView(this) 1511 textview = TextView(this)
1502 textview!!.tag = dataArrayMap 1512 textview!!.tag = dataArrayMap
1503 textview!!.id = cid 1513 textview!!.id = cid
1504 textview!!.text = text 1514 textview!!.text = text
1519 fun mleNew(cid: Int): EditText? 1529 fun mleNew(cid: Int): EditText?
1520 { 1530 {
1521 var mle: EditText? = null 1531 var mle: EditText? = null
1522 1532
1523 waitOnUiThread { 1533 waitOnUiThread {
1524 var dataArrayMap = SimpleArrayMap<String, Long>() 1534 val dataArrayMap = SimpleArrayMap<String, Long>()
1525 1535
1526 mle = EditText(this) 1536 mle = EditText(this)
1527 mle!!.tag = dataArrayMap 1537 mle!!.tag = dataArrayMap
1528 mle!!.id = cid 1538 mle!!.id = cid
1529 mle!!.isSingleLine = false 1539 mle!!.isSingleLine = false
1616 var notebook: RelativeLayout? = null 1626 var notebook: RelativeLayout? = null
1617 1627
1618 waitOnUiThread { 1628 waitOnUiThread {
1619 val pager = ViewPager2(this) 1629 val pager = ViewPager2(this)
1620 val tabs = TabLayout(this) 1630 val tabs = TabLayout(this)
1621 var w: Int = RelativeLayout.LayoutParams.MATCH_PARENT 1631 val w: Int = RelativeLayout.LayoutParams.MATCH_PARENT
1622 var h: Int = RelativeLayout.LayoutParams.WRAP_CONTENT 1632 val h: Int = RelativeLayout.LayoutParams.WRAP_CONTENT
1623 var dataArrayMap = SimpleArrayMap<String, Long>() 1633 val dataArrayMap = SimpleArrayMap<String, Long>()
1624 1634
1625 notebook = RelativeLayout(this) 1635 notebook = RelativeLayout(this)
1626 notebook!!.tag = dataArrayMap 1636 notebook!!.tag = dataArrayMap
1627 notebook!!.id = cid 1637 notebook!!.id = cid
1628 tabs.id = View.generateViewId() 1638 tabs.id = View.generateViewId()
1681 pager = notebook.getChildAt(1) as ViewPager2 1691 pager = notebook.getChildAt(1) as ViewPager2
1682 tabs = notebook.getChildAt(0) as TabLayout 1692 tabs = notebook.getChildAt(0) as TabLayout
1683 } 1693 }
1684 1694
1685 if (pager != null && tabs != null) { 1695 if (pager != null && tabs != null) {
1686 var adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter 1696 val adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter
1687 var tab = tabs.newTab() 1697 val tab = tabs.newTab()
1688 1698
1689 // Increment our page ID... making sure no duplicates exist 1699 // Increment our page ID... making sure no duplicates exist
1690 do { 1700 do {
1691 adapter.currentPageID += 1 1701 adapter.currentPageID += 1
1692 } while (adapter.currentPageID == 0L || adapter.pageList.contains(adapter.currentPageID)) 1702 } while (adapter.currentPageID == 0L || adapter.pageList.contains(adapter.currentPageID))
1719 pager = notebook.getChildAt(1) as ViewPager2 1729 pager = notebook.getChildAt(1) as ViewPager2
1720 tabs = notebook.getChildAt(0) as TabLayout 1730 tabs = notebook.getChildAt(0) as TabLayout
1721 } 1731 }
1722 1732
1723 if (pager != null && tabs != null) { 1733 if (pager != null && tabs != null) {
1724 var adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter 1734 val adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter
1725 val index = adapter.pageList.indexOf(pageID) 1735 val index = adapter.pageList.indexOf(pageID)
1726 val tab = tabs.getTabAt(index) 1736 val tab = tabs.getTabAt(index)
1727 1737
1728 if (tab != null) { 1738 if (tab != null) {
1729 adapter.viewList.removeAt(index) 1739 adapter.viewList.removeAt(index)
1773 pager = notebook.getChildAt(1) as ViewPager2 1783 pager = notebook.getChildAt(1) as ViewPager2
1774 tabs = notebook.getChildAt(0) as TabLayout 1784 tabs = notebook.getChildAt(0) as TabLayout
1775 } 1785 }
1776 1786
1777 if (pager != null && tabs != null) { 1787 if (pager != null && tabs != null) {
1778 var adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter 1788 val adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter
1779 val index = adapter.pageList.indexOf(pageID) 1789 val index = adapter.pageList.indexOf(pageID)
1780 1790
1781 // Make sure the box is MATCH_PARENT 1791 // Make sure the box is MATCH_PARENT
1782 box.layoutParams = LinearLayout.LayoutParams( 1792 box.layoutParams = LinearLayout.LayoutParams(
1783 LinearLayout.LayoutParams.MATCH_PARENT, 1793 LinearLayout.LayoutParams.MATCH_PARENT,
1804 pager = notebook.getChildAt(1) as ViewPager2 1814 pager = notebook.getChildAt(1) as ViewPager2
1805 tabs = notebook.getChildAt(0) as TabLayout 1815 tabs = notebook.getChildAt(0) as TabLayout
1806 } 1816 }
1807 1817
1808 if (pager != null && tabs != null) { 1818 if (pager != null && tabs != null) {
1809 var adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter 1819 val adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter
1810 retval = adapter.pageList.get(tabs.selectedTabPosition) 1820 retval = adapter.pageList.get(tabs.selectedTabPosition)
1811 } 1821 }
1812 } 1822 }
1813 return retval 1823 return retval
1814 } 1824 }
1840 fun sliderNew(vertical: Int, increments: Int, cid: Int): SeekBar? 1850 fun sliderNew(vertical: Int, increments: Int, cid: Int): SeekBar?
1841 { 1851 {
1842 var slider: SeekBar? = null 1852 var slider: SeekBar? = null
1843 1853
1844 waitOnUiThread { 1854 waitOnUiThread {
1845 var dataArrayMap = SimpleArrayMap<String, Long>() 1855 val dataArrayMap = SimpleArrayMap<String, Long>()
1846 1856
1847 slider = SeekBar(this) 1857 slider = SeekBar(this)
1848 slider!!.tag = dataArrayMap 1858 slider!!.tag = dataArrayMap
1849 slider!!.id = cid 1859 slider!!.id = cid
1850 slider!!.max = increments 1860 slider!!.max = increments
1869 fun percentNew(cid: Int): ProgressBar? 1879 fun percentNew(cid: Int): ProgressBar?
1870 { 1880 {
1871 var percent: ProgressBar? = null 1881 var percent: ProgressBar? = null
1872 1882
1873 waitOnUiThread { 1883 waitOnUiThread {
1874 var dataArrayMap = SimpleArrayMap<String, Long>() 1884 val dataArrayMap = SimpleArrayMap<String, Long>()
1875 1885
1876 percent = ProgressBar(this,null, R.attr.progressBarStyleHorizontal) 1886 percent = ProgressBar(this,null, R.attr.progressBarStyleHorizontal)
1877 percent!!.tag = dataArrayMap 1887 percent!!.tag = dataArrayMap
1878 percent!!.id = cid 1888 percent!!.id = cid
1879 percent!!.max = 100 1889 percent!!.max = 100
1908 fun htmlNew(cid: Int): WebView? 1918 fun htmlNew(cid: Int): WebView?
1909 { 1919 {
1910 var html: WebView? = null 1920 var html: WebView? = null
1911 1921
1912 waitOnUiThread { 1922 waitOnUiThread {
1913 var dataArrayMap = SimpleArrayMap<String, Long>() 1923 val dataArrayMap = SimpleArrayMap<String, Long>()
1914 1924
1915 html = WebView(this) 1925 html = WebView(this)
1916 html!!.tag = dataArrayMap 1926 html!!.tag = dataArrayMap
1917 html!!.id = cid 1927 html!!.id = cid
1918 // Configure a few settings to make it behave as we expect 1928 // Configure a few settings to make it behave as we expect
2036 fun containerNew(cid: Int, multi: Int): ListView? 2046 fun containerNew(cid: Int, multi: Int): ListView?
2037 { 2047 {
2038 var cont: ListView? = null 2048 var cont: ListView? = null
2039 2049
2040 waitOnUiThread { 2050 waitOnUiThread {
2041 var dataArrayMap = SimpleArrayMap<String, Long>() 2051 val dataArrayMap = SimpleArrayMap<String, Long>()
2042 var adapter = DWContainerAdapter(this) 2052 val adapter = DWContainerAdapter(this)
2043 2053
2044 cont = ListView(this) 2054 cont = ListView(this)
2045 cont!!.tag = dataArrayMap 2055 cont!!.tag = dataArrayMap
2046 cont!!.id = cid 2056 cont!!.id = cid
2047 cont!!.adapter = adapter 2057 cont!!.adapter = adapter
2086 // Handle DW_CRA_SELECTED 2096 // Handle DW_CRA_SELECTED
2087 if((flags and 1) != 0) { 2097 if((flags and 1) != 0) {
2088 val checked: SparseBooleanArray = cont.getCheckedItemPositions() 2098 val checked: SparseBooleanArray = cont.getCheckedItemPositions()
2089 val position = checked.keyAt(0) 2099 val position = checked.keyAt(0)
2090 2100
2091 if(position != null) { 2101 adapter.model.querypos = position
2092 adapter.model.querypos = position 2102 retval = adapter.model.getRowTitle(position)
2093 retval = adapter.model.getRowTitle(position)
2094 } else {
2095 adapter.model.querypos = -1
2096 }
2097 } else { 2103 } else {
2098 if(adapter.model.rowdata.size == 0) { 2104 if(adapter.model.rowdata.size == 0) {
2099 adapter.model.querypos = -1 2105 adapter.model.querypos = -1
2100 } else { 2106 } else {
2101 retval = adapter.model.getRowTitle(0) 2107 retval = adapter.model.getRowTitle(0)
2121 // Otherwise loop until we find our current place 2127 // Otherwise loop until we find our current place
2122 for (i in 0 until checked.size()) { 2128 for (i in 0 until checked.size()) {
2123 // Item position in adapter 2129 // Item position in adapter
2124 val position: Int = checked.keyAt(i) 2130 val position: Int = checked.keyAt(i)
2125 2131
2126 if (position != null) { 2132 if (adapter.model.querypos == position && (i + 1) < checked.size()) {
2127 // If we are at our current point... check to see 2133 val newpos = checked.keyAt(i + 1)
2128 // if there is another one, and return it... 2134
2129 // otherwise we will return -1 to indicated we are done. 2135 adapter.model.querypos = newpos
2130 if (adapter.model.querypos == position && (i + 1) < checked.size()) { 2136 retval = adapter.model.getRowTitle(newpos)
2131 val newpos = checked.keyAt(i + 1)
2132
2133 if (newpos != null) {
2134 adapter.model.querypos = newpos
2135 retval = adapter.model.getRowTitle(newpos)
2136 } else {
2137 adapter.model.querypos = -1
2138 }
2139 }
2140 } else {
2141 adapter.model.querypos = -1
2142 } 2137 }
2143 } 2138 }
2144 } else { 2139 } else {
2145 if (adapter.model.rowtitle.size > adapter.model.querypos) { 2140 if (adapter.model.rowtitle.size > adapter.model.querypos) {
2146 adapter.model.querypos += 1 2141 adapter.model.querypos += 1
2164 // Handle DW_CRA_SELECTED 2159 // Handle DW_CRA_SELECTED
2165 if((flags and 1) != 0) { 2160 if((flags and 1) != 0) {
2166 val checked: SparseBooleanArray = cont.getCheckedItemPositions() 2161 val checked: SparseBooleanArray = cont.getCheckedItemPositions()
2167 val position = checked.keyAt(0) 2162 val position = checked.keyAt(0)
2168 2163
2169 if(position != null) { 2164 adapter.model.querypos = position
2170 adapter.model.querypos = position 2165 retval = adapter.model.getRowData(position)
2171 retval = adapter.model.getRowData(position)
2172 } else {
2173 adapter.model.querypos = -1
2174 }
2175 } else { 2166 } else {
2176 if(adapter.model.rowdata.size == 0) { 2167 if(adapter.model.rowdata.size == 0) {
2177 adapter.model.querypos = -1 2168 adapter.model.querypos = -1
2178 } else { 2169 } else {
2179 retval = adapter.model.getRowData(0) 2170 retval = adapter.model.getRowData(0)
2199 // Otherwise loop until we find our current place 2190 // Otherwise loop until we find our current place
2200 for (i in 0 until checked.size()) { 2191 for (i in 0 until checked.size()) {
2201 // Item position in adapter 2192 // Item position in adapter
2202 val position: Int = checked.keyAt(i) 2193 val position: Int = checked.keyAt(i)
2203 2194
2204 if (position != null) { 2195 if (adapter.model.querypos == position && (i + 1) < checked.size()) {
2205 // If we are at our current point... check to see 2196 val newpos = checked.keyAt(i + 1)
2206 // if there is another one, and return it... 2197
2207 // otherwise we will return -1 to indicated we are done. 2198 adapter.model.querypos = newpos
2208 if (adapter.model.querypos == position && (i + 1) < checked.size()) { 2199 retval = adapter.model.getRowData(newpos)
2209 val newpos = checked.keyAt(i + 1)
2210
2211 if (newpos != null) {
2212 adapter.model.querypos = newpos
2213 retval = adapter.model.getRowData(newpos)
2214 } else {
2215 adapter.model.querypos = -1
2216 }
2217 }
2218 } else {
2219 adapter.model.querypos = -1
2220 } 2200 }
2221 } 2201 }
2222 } else { 2202 } else {
2223 if (adapter.model.rowdata.size > adapter.model.querypos) { 2203 if (adapter.model.rowdata.size > adapter.model.querypos) {
2224 adapter.model.querypos += 1 2204 adapter.model.querypos += 1
2357 fun listBoxNew(cid: Int, multi: Int): DWListBox? 2337 fun listBoxNew(cid: Int, multi: Int): DWListBox?
2358 { 2338 {
2359 var listbox: DWListBox? = null 2339 var listbox: DWListBox? = null
2360 2340
2361 waitOnUiThread { 2341 waitOnUiThread {
2362 var dataArrayMap = SimpleArrayMap<String, Long>() 2342 val dataArrayMap = SimpleArrayMap<String, Long>()
2363 2343
2364 listbox = DWListBox(this) 2344 listbox = DWListBox(this)
2365 listbox!!.tag = dataArrayMap 2345 listbox!!.tag = dataArrayMap
2366 listbox!!.id = cid 2346 listbox!!.id = cid
2367 if(multi != 0) { 2347 if(multi != 0) {
2579 fun calendarNew(cid: Int): CalendarView? 2559 fun calendarNew(cid: Int): CalendarView?
2580 { 2560 {
2581 var calendar: CalendarView? = null 2561 var calendar: CalendarView? = null
2582 2562
2583 waitOnUiThread { 2563 waitOnUiThread {
2584 var dataArrayMap = SimpleArrayMap<String, Long>() 2564 val dataArrayMap = SimpleArrayMap<String, Long>()
2585 2565
2586 calendar = CalendarView(this) 2566 calendar = CalendarView(this)
2587 calendar!!.tag = dataArrayMap 2567 calendar!!.tag = dataArrayMap
2588 calendar!!.id = cid 2568 calendar!!.id = cid
2589 calendar!!.setOnDateChangeListener { calendar, year, month, day -> 2569 calendar!!.setOnDateChangeListener { calendar, year, month, day ->
2618 fun bitmapNew(cid: Int): ImageView? 2598 fun bitmapNew(cid: Int): ImageView?
2619 { 2599 {
2620 var imageview: ImageView? = null 2600 var imageview: ImageView? = null
2621 2601
2622 waitOnUiThread { 2602 waitOnUiThread {
2623 var dataArrayMap = SimpleArrayMap<String, Long>() 2603 val dataArrayMap = SimpleArrayMap<String, Long>()
2624 2604
2625 imageview = ImageView(this) 2605 imageview = ImageView(this)
2626 imageview!!.tag = dataArrayMap 2606 imageview!!.tag = dataArrayMap
2627 imageview!!.id = cid 2607 imageview!!.id = cid
2628 } 2608 }
2642 val imageview = window 2622 val imageview = window
2643 2623
2644 imageview.setImageResource(resID) 2624 imageview.setImageResource(resID)
2645 } 2625 }
2646 } else if(filename != null) { 2626 } else if(filename != null) {
2647 var exts = arrayOf("", ".png", ".webp", ".jpg", ".jpeg", ".gif") 2627 val exts = arrayOf("", ".png", ".webp", ".jpg", ".jpeg", ".gif")
2648 2628
2649 for (ext in exts) { 2629 for (ext in exts) {
2650 // Try to load the image, and protect against exceptions 2630 // Try to load the image, and protect against exceptions
2651 try { 2631 try {
2652 val f = this.assets.open(filename + ext) 2632 val f = this.assets.open(filename + ext)
2706 2686
2707 waitOnUiThread { 2687 waitOnUiThread {
2708 if(resID != 0) { 2688 if(resID != 0) {
2709 icon = ResourcesCompat.getDrawable(resources, resID, null); 2689 icon = ResourcesCompat.getDrawable(resources, resID, null);
2710 } else if(filename != null) { 2690 } else if(filename != null) {
2711 var exts = arrayOf("", ".png", ".webp", ".jpg", ".jpeg", ".gif") 2691 val exts = arrayOf("", ".png", ".webp", ".jpg", ".jpeg", ".gif")
2712 2692
2713 for (ext in exts) { 2693 for (ext in exts) {
2714 // Try to load the image, and protect against exceptions 2694 // Try to load the image, and protect against exceptions
2715 try { 2695 try {
2716 val f = this.assets.open(filename + ext) 2696 val f = this.assets.open(filename + ext)
2737 if(width > 0 && height > 0) { 2717 if(width > 0 && height > 0) {
2738 pixmap = Bitmap.createBitmap(null, width, height, Bitmap.Config.ARGB_8888) 2718 pixmap = Bitmap.createBitmap(null, width, height, Bitmap.Config.ARGB_8888)
2739 } else if(resID != 0) { 2719 } else if(resID != 0) {
2740 pixmap = BitmapFactory.decodeResource(resources, resID); 2720 pixmap = BitmapFactory.decodeResource(resources, resID);
2741 } else if(filename != null) { 2721 } else if(filename != null) {
2742 var exts = arrayOf("", ".png", ".webp", ".jpg", ".jpeg", ".gif") 2722 val exts = arrayOf("", ".png", ".webp", ".jpg", ".jpeg", ".gif")
2743 2723
2744 for (ext in exts) { 2724 for (ext in exts) {
2745 // Try to load the image, and protect against exceptions 2725 // Try to load the image, and protect against exceptions
2746 try { 2726 try {
2747 val f = this.assets.open(filename + ext) 2727 val f = this.assets.open(filename + ext)
2778 fun renderNew(cid: Int): DWRender? 2758 fun renderNew(cid: Int): DWRender?
2779 { 2759 {
2780 var render: DWRender? = null 2760 var render: DWRender? = null
2781 2761
2782 waitOnUiThread { 2762 waitOnUiThread {
2783 var dataArrayMap = SimpleArrayMap<String, Long>() 2763 val dataArrayMap = SimpleArrayMap<String, Long>()
2784 2764
2785 render = DWRender(this) 2765 render = DWRender(this)
2786 render!!.tag = dataArrayMap 2766 render!!.tag = dataArrayMap
2787 render!!.id = cid 2767 render!!.id = cid
2788 } 2768 }
2798 2778
2799 fun pixmapBitBlt(dstr: DWRender?, dstp: Bitmap?, dstx: Int, dsty: Int, dstw: Int, dsth: Int, 2779 fun pixmapBitBlt(dstr: DWRender?, dstp: Bitmap?, dstx: Int, dsty: Int, dstw: Int, dsth: Int,
2800 srcr: DWRender?, srcp: Bitmap?, srcy: Int, srcx: Int, srcw: Int, srch: Int): Int 2780 srcr: DWRender?, srcp: Bitmap?, srcy: Int, srcx: Int, srcw: Int, srch: Int): Int
2801 { 2781 {
2802 val dst = Rect(dstx, dsty, dstx + dstw, dsty + dsth) 2782 val dst = Rect(dstx, dsty, dstx + dstw, dsty + dsth)
2803 var src = Rect(srcx, srcy, srcx + srcw, srcy + srch) 2783 val src = Rect(srcx, srcy, srcx + srcw, srcy + srch)
2804 var retval: Int = 1 2784 var retval: Int = 1
2805 2785
2806 if(srcw == -1) { 2786 if(srcw == -1) {
2807 src.right = srcx + dstw 2787 src.right = srcx + dstw
2808 } 2788 }
2879 fun fontTextExtentsGet(render: DWRender?, bitmap: Bitmap?, text:String, typeface: Typeface?, fontsize: Int, window: View?): Long 2859 fun fontTextExtentsGet(render: DWRender?, bitmap: Bitmap?, text:String, typeface: Typeface?, fontsize: Int, window: View?): Long
2880 { 2860 {
2881 var dimensions: Long = 0 2861 var dimensions: Long = 0
2882 2862
2883 waitOnUiThread { 2863 waitOnUiThread {
2884 var rect = Rect() 2864 val rect = Rect()
2885 2865
2886 if (render != null) { 2866 if (render != null) {
2887 if (render.typeface != null) { 2867 if (render.typeface != null) {
2888 paint.typeface = render.typeface 2868 paint.typeface = render.typeface
2889 if (render.fontsize != null && render.fontsize!! > 0F) { 2869 if (render.fontsize != null && render.fontsize!! > 0F) {
2949 } 2929 }
2950 2930
2951 if(canvas != null) { 2931 if(canvas != null) {
2952 colorsSet(fgColor, bgColor) 2932 colorsSet(fgColor, bgColor)
2953 // Save the old color for later... 2933 // Save the old color for later...
2954 var rect = Rect() 2934 val rect = Rect()
2955 val oldcolor = paint.color 2935 val oldcolor = paint.color
2956 // Prepare to draw the background rect 2936 // Prepare to draw the background rect
2957 paint.color = bgcolor 2937 paint.color = bgcolor
2958 paint.flags = 0 2938 paint.flags = 0
2959 paint.style = Paint.Style.FILL_AND_STROKE 2939 paint.style = Paint.Style.FILL_AND_STROKE
3073 if(y2 < y1) { 3053 if(y2 < y1) {
3074 top = y2.toFloat() 3054 top = y2.toFloat()
3075 bottom = y1.toFloat() 3055 bottom = y1.toFloat()
3076 } 3056 }
3077 3057
3078 val width: Float = Math.abs((x1-x2)).toFloat()
3079 val height: Float = Math.abs((y1-y2)).toFloat()
3080 canvas.drawOval(left, top, right, bottom, paint) 3058 canvas.drawOval(left, top, right, bottom, paint)
3081 } else { 3059 } else {
3082 var a1: Double = Math.atan2((y1 - yorigin).toDouble(), (x1 - xorigin).toDouble()) 3060 var a1: Double = Math.atan2((y1 - yorigin).toDouble(), (x1 - xorigin).toDouble())
3083 var a2: Double = Math.atan2((y2 - yorigin).toDouble(), (x2 - xorigin).toDouble()) 3061 var a2: Double = Math.atan2((y2 - yorigin).toDouble(), (x2 - xorigin).toDouble())
3084 val dx = (xorigin - x1).toDouble() 3062 val dx = (xorigin - x1).toDouble()
3199 { 3177 {
3200 var retval: Int = 0 3178 var retval: Int = 0
3201 3179
3202 waitOnUiThread { 3180 waitOnUiThread {
3203 // make a text input dialog and show it 3181 // make a text input dialog and show it
3204 var alert = AlertDialog.Builder(this) 3182 val alert = AlertDialog.Builder(this)
3205 3183
3206 alert.setTitle(title) 3184 alert.setTitle(title)
3207 alert.setMessage(body) 3185 alert.setMessage(body)
3208 if ((flags and (1 shl 3)) != 0) { 3186 if ((flags and (1 shl 3)) != 0) {
3209 alert.setPositiveButton("Yes", 3187 alert.setPositiveButton("Yes",