comparison android/DWindows.kt @ 2694:cee79add3669

Andrdoid: Implement dw_browse() to load a URL in a new Activity.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 02 Nov 2021 19:04:56 +0000
parents 231f9489a38a
children 9df2c11f020f
comparison
equal deleted inserted replaced
2693:0dac724f890f 2694:cee79add3669
60 import java.io.IOException 60 import java.io.IOException
61 import java.util.* 61 import java.util.*
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
66
67
68
65 69
66 object DWEvent { 70 object DWEvent {
67 const val TIMER = 0 71 const val TIMER = 0
68 const val CONFIGURE = 1 72 const val CONFIGURE = 1
69 const val KEY_PRESS = 2 73 const val KEY_PRESS = 2
1020 // forwarded from the C Dynamic Windows API 1024 // forwarded from the C Dynamic Windows API
1021 1025
1022 fun darkModeDetected(): Int 1026 fun darkModeDetected(): Int
1023 { 1027 {
1024 return darkMode 1028 return darkMode
1029 }
1030
1031 fun browseURL(url: String): Int {
1032 var retval: Int = -1 // DW_ERROR_UNKNOWN
1033
1034 waitOnUiThread {
1035 val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
1036 try {
1037 retval = 0 // DW_ERROR_NONE
1038 startActivity(browserIntent)
1039 } catch (e: ActivityNotFoundException) {
1040 retval = -1 // DW_ERROR_UNKNOWN
1041 }
1042 }
1043 return retval
1025 } 1044 }
1026 1045
1027 fun menuPopup(menu: DWMenu, parent: View, x: Int, y: Int) 1046 fun menuPopup(menu: DWMenu, parent: View, x: Int, y: Int)
1028 { 1047 {
1029 var anchor: View? = parent 1048 var anchor: View? = parent