comparison android/DWindows.kt @ 2707:a3f6ca621453

Android: Implement dw_mle_set_visible(). Also fix various warnings.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 19 Nov 2021 02:49:53 +0000
parents 4e9eba7f7226
children 3a7dcc0ae08b
comparison
equal deleted inserted replaced
2706:4e9eba7f7226 2707:a3f6ca621453
62 import java.util.concurrent.locks.ReentrantLock 62 import java.util.concurrent.locks.ReentrantLock
63 import java.util.zip.ZipEntry 63 import java.util.zip.ZipEntry
64 import java.util.zip.ZipFile 64 import java.util.zip.ZipFile
65 import android.content.Intent 65 import android.content.Intent
66 66
67
68
69
70 object DWEvent { 67 object DWEvent {
71 const val TIMER = 0 68 const val TIMER = 0
72 const val CONFIGURE = 1 69 const val CONFIGURE = 1
73 const val KEY_PRESS = 2 70 const val KEY_PRESS = 2
74 const val BUTTON_PRESS = 3 71 const val BUTTON_PRESS = 3
331 private var currentPath: File? = null 328 private var currentPath: File? = null
332 329
333 // filter on file extension 330 // filter on file extension
334 private var extension: String? = null 331 private var extension: String? = null
335 fun setExtension(extension: String?) { 332 fun setExtension(extension: String?) {
336 this.extension = extension?.toLowerCase(Locale.ROOT) 333 this.extension = extension?.lowercase(Locale.ROOT)
337 } 334 }
338 335
339 // file selection event handling 336 // file selection event handling
340 interface FileSelectedListener { 337 interface FileSelectedListener {
341 fun fileSelected(file: File?) 338 fun fileSelected(file: File?)
364 if (!file.canRead()) { 361 if (!file.canRead()) {
365 false 362 false
366 } else if (extension == null) { 363 } else if (extension == null) {
367 true 364 true
368 } else { 365 } else {
369 file.name.toLowerCase(Locale.ROOT).endsWith(extension!!) 366 file.name.lowercase(Locale.ROOT).endsWith(extension!!)
370 } 367 }
371 } else { 368 } else {
372 false 369 false
373 } 370 }
374 } 371 }
987 984
988 if(menuBar == null) { 985 if(menuBar == null) {
989 menuBar = DWMenu() 986 menuBar = DWMenu()
990 windowMenuBars[index] = menuBar 987 windowMenuBars[index] = menuBar
991 } 988 }
992 menuBar!!.menu = menu 989 menuBar.menu = menu
993 return super.onCreateOptionsMenu(menu) 990 return super.onCreateOptionsMenu(menu)
994 } 991 }
995 } 992 }
996 return false 993 return false
997 } 994 }
1003 1000
1004 if (count > 0 && index < count) { 1001 if (count > 0 && index < count) {
1005 var menuBar = windowMenuBars[index] 1002 var menuBar = windowMenuBars[index]
1006 1003
1007 if(menuBar != null) { 1004 if(menuBar != null) {
1008 menuBar!!.createMenu(menu, true) 1005 menuBar.createMenu(menu, true)
1009 } else { 1006 } else {
1010 menuBar = DWMenu() 1007 menuBar = DWMenu()
1011 menuBar!!.createMenu(menu, true) 1008 menuBar.createMenu(menu, true)
1012 windowMenuBars[index] = menuBar 1009 windowMenuBars[index] = menuBar
1013 } 1010 }
1014 return super.onPrepareOptionsMenu(menu) 1011 return super.onPrepareOptionsMenu(menu)
1015 } 1012 }
1016 } 1013 }
2185 mle!!.setHorizontallyScrolling(false) 2182 mle!!.setHorizontallyScrolling(false)
2186 mle!!.isHorizontalScrollBarEnabled = false 2183 mle!!.isHorizontalScrollBarEnabled = false
2187 mle!!.gravity = Gravity.TOP or Gravity.LEFT 2184 mle!!.gravity = Gravity.TOP or Gravity.LEFT
2188 } 2185 }
2189 return mle 2186 return mle
2187 }
2188
2189 fun mleSetVisible(mle: EditText, line: Int)
2190 {
2191 waitOnUiThread {
2192 val y: Int = mle.layout.getLineTop(line)
2193
2194 mle.scrollTo(0, y)
2195 }
2190 } 2196 }
2191 2197
2192 fun mleSetWordWrap(mle: EditText, state: Int) 2198 fun mleSetWordWrap(mle: EditText, state: Int)
2193 { 2199 {
2194 waitOnUiThread { 2200 waitOnUiThread {
2656 } 2662 }
2657 2663
2658 fun splitBarSet(splitbar: ConstraintLayout, position: Float) { 2664 fun splitBarSet(splitbar: ConstraintLayout, position: Float) {
2659 waitOnUiThread { 2665 waitOnUiThread {
2660 val dataArrayMap: SimpleArrayMap<String, Long> = splitbar.tag as SimpleArrayMap<String, Long> 2666 val dataArrayMap: SimpleArrayMap<String, Long> = splitbar.tag as SimpleArrayMap<String, Long>
2661 var percent: Float = position * 1000000.0F 2667 val percent: Float = position * 1000000.0F
2662 2668
2663 if(percent > 0F) { 2669 if(percent > 0F) {
2664 val topleft: View? = splitbar.getChildAt(0) 2670 val topleft: View? = splitbar.getChildAt(0)
2665 val bottomright: View? = splitbar.getChildAt(1) 2671 val bottomright: View? = splitbar.getChildAt(1)
2666 val constraintSet = ConstraintSet() 2672 val constraintSet = ConstraintSet()