annotate android/DWindows.kt @ 2551:127779860ac1

Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 15 May 2021 00:44:24 +0000
parents a8d90e2896bc
children 303f544d14fa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2484
cb5b67154399 Android: The DWindows class should be org.dbsoft.dwindows, remove dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2483
diff changeset
1 package org.dbsoft.dwindows
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2
2526
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3 import android.R
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
4 import android.app.Activity
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
5 import android.app.Dialog
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6 import android.app.NotificationChannel
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
7 import android.app.NotificationManager
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
8 import android.content.ClipData
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
9 import android.content.ClipboardManager
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
10 import android.content.Context
2486
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
11 import android.content.DialogInterface
2480
878d36588aaa Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2479
diff changeset
12 import android.content.pm.ActivityInfo
2496
3bf2f08fdc45 Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2495
diff changeset
13 import android.content.res.Configuration
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
14 import android.graphics.*
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
15 import android.graphics.drawable.BitmapDrawable
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
16 import android.graphics.drawable.Drawable
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
17 import android.graphics.drawable.GradientDrawable
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
18 import android.media.AudioManager
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
19 import android.media.ToneGenerator
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
20 import android.os.*
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
21 import android.text.InputFilter
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
22 import android.text.InputFilter.LengthFilter
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
23 import android.text.InputType
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
24 import android.text.method.PasswordTransformationMethod
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
25 import android.util.Base64
2482
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
26 import android.util.Log
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
27 import android.util.SparseBooleanArray
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
28 import android.util.TypedValue
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
29 import android.view.*
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
30 import android.view.View.OnTouchListener
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
31 import android.view.inputmethod.EditorInfo
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
32 import android.webkit.WebView
2505
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
33 import android.webkit.WebViewClient
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
34 import android.widget.*
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
35 import android.widget.AdapterView.OnItemClickListener
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
36 import android.widget.SeekBar.OnSeekBarChangeListener
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
37 import androidx.annotation.RequiresApi
2486
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
38 import androidx.appcompat.app.AlertDialog
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
39 import androidx.appcompat.app.AppCompatActivity
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
40 import androidx.appcompat.widget.AppCompatEditText
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
41 import androidx.collection.SimpleArrayMap
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
42 import androidx.core.app.NotificationCompat
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
43 import androidx.core.app.NotificationManagerCompat
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
44 import androidx.core.content.res.ResourcesCompat
2544
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
45 import androidx.core.view.MenuCompat
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
46 import androidx.recyclerview.widget.RecyclerView
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
47 import androidx.viewpager2.widget.ViewPager2
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
48 import com.google.android.material.tabs.TabLayout
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
49 import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
50 import com.google.android.material.tabs.TabLayoutMediator
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
51 import java.io.File
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
52 import java.io.FileInputStream
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
53 import java.io.FileNotFoundException
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
54 import java.util.*
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
55 import java.util.concurrent.locks.ReentrantLock
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
56
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
57
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
58 class DWTabViewPagerAdapter : RecyclerView.Adapter<DWTabViewPagerAdapter.DWEventViewHolder>() {
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
59 val viewList = mutableListOf<LinearLayout>()
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
60 val pageList = mutableListOf<Long>()
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
61 var currentPageID = 0L
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
62
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
63 override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
2498
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
64 DWEventViewHolder(viewList.get(viewType))
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
65
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
66 override fun getItemCount() = viewList.count()
2498
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
67 override fun getItemViewType(position: Int): Int {
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
68 return position
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
69 }
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
70 override fun onBindViewHolder(holder: DWEventViewHolder, position: Int) {
2498
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
71 holder.setIsRecyclable(false);
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
72 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
73
2498
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
74 class DWEventViewHolder(var view: View) : RecyclerView.ViewHolder(view)
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
75 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
76
2505
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
77 private class DWWebViewClient : WebViewClient() {
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
78 //Implement shouldOverrideUrlLoading//
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
79 override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
80 // We always want to load in our own WebView,
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
81 // to match the behavior on the other platforms
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
82 return false
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
83 }
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
84 override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) {
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
85 // Handle the DW_HTML_CHANGE_STARTED event
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
86 eventHandlerHTMLChanged(view, 19, url, 1)
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
87 }
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
88
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
89 override fun onPageFinished(view: WebView, url: String) {
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
90 // Handle the DW_HTML_CHANGE_COMPLETE event
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
91 eventHandlerHTMLChanged(view, 19, url, 4)
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
92 }
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
93
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
94 external fun eventHandlerHTMLChanged(obj1: View, message: Int, URI: String, status: Int)
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
95 }
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
96
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
97 class DWSpinButton(context: Context) : AppCompatEditText(context), OnTouchListener {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
98 var value: Long = 0
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
99 var minimum: Long = 0
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
100 var maximum: Long = 65535
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
101
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
102 init {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
103 setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.ic_media_previous, 0, android.R.drawable.ic_media_next, 0);
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
104 setOnTouchListener(this)
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
105 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
106
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
107 override fun onTouch(v: View, event: MotionEvent): Boolean {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
108 val DRAWABLE_RIGHT = 2
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
109 val DRAWABLE_LEFT = 0
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
110
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
111 if (event.action == MotionEvent.ACTION_UP) {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
112 if (event.x >= v.width - (v as EditText)
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
113 .compoundDrawables[DRAWABLE_RIGHT].bounds.width()
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
114 ) {
2527
eec926265888 Android: Use toLongOrNull() whenever converting from string to long...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
115 val newvalue = this.text.toString().toLongOrNull()
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
116
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
117 if(newvalue != null) {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
118 value = newvalue + 1
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
119 } else {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
120 value += 1
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
121 }
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
122 if(value > maximum) {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
123 value = maximum
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
124 }
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
125 if(value < minimum) {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
126 value = minimum
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
127 }
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
128 setText(value.toString())
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
129 eventHandlerInt(14, value.toInt(), 0, 0, 0)
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
130 return true
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
131 } else if (event.x <= (v as EditText)
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
132 .compoundDrawables[DRAWABLE_LEFT].bounds.width()
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
133 ) {
2527
eec926265888 Android: Use toLongOrNull() whenever converting from string to long...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
134 val newvalue = this.text.toString().toLongOrNull()
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
135
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
136 if(newvalue != null) {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
137 value = newvalue - 1
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
138 } else {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
139 value -= 1
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
140 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
141 if(value > maximum) {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
142 value = maximum
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
143 }
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
144 if(value < minimum) {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
145 value = minimum
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
146 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
147 setText(value.toString())
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
148 eventHandlerInt(14, value.toInt(), 0, 0, 0)
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
149 return true
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
150 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
151 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
152 return false
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
153 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
154
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
155 external fun eventHandlerInt(
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
156 message: Int,
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
157 inta: Int,
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
158 intb: Int,
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
159 intc: Int,
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
160 intd: Int
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
161 )
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
162 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
163
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
164 class DWComboBox(context: Context) : AppCompatEditText(context), OnTouchListener, OnItemClickListener {
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
165 var lpw: ListPopupWindow? = null
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
166 var list = mutableListOf<String>()
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
167 var selected: Int = -1
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
168
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
169 init {
2516
8f5d064b7054 Android: Fix the down arrow on the comboboxes, found a system resource that works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
170 setCompoundDrawablesWithIntrinsicBounds(0, 0, android.R.drawable.arrow_down_float, 0);
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
171 setOnTouchListener(this)
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
172 lpw = ListPopupWindow(context)
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
173 lpw!!.setAdapter(
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
174 ArrayAdapter(
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
175 context,
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
176 android.R.layout.simple_list_item_1, list
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
177 )
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
178 )
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
179 lpw!!.anchorView = this
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
180 lpw!!.isModal = true
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
181 lpw!!.setOnItemClickListener(this)
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
182 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
183
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
184 override fun onItemClick(parent: AdapterView<*>?, view: View, position: Int, id: Long) {
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
185 val item = list[position]
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
186 selected = position
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
187 setText(item)
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
188 lpw!!.dismiss()
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
189 eventHandlerInt(11, position, 0, 0, 0)
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
190 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
191
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
192 override fun onTouch(v: View, event: MotionEvent): Boolean {
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
193 val DRAWABLE_RIGHT = 2
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
194
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
195 if (event.action == MotionEvent.ACTION_UP) {
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
196 if (event.x >= v.width - (v as EditText)
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
197 .compoundDrawables[DRAWABLE_RIGHT].bounds.width()
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
198 ) {
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
199 lpw!!.show()
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
200 return true
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
201 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
202 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
203 return false
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
204 }
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
205
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
206 external fun eventHandlerInt(
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
207 message: Int,
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
208 inta: Int,
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
209 intb: Int,
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
210 intc: Int,
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
211 intd: Int
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
212 )
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
213 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
214
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
215 class DWListBox(context: Context) : ListView(context), OnItemClickListener {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
216 var list = mutableListOf<String>()
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
217 var selected: Int = -1
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
218
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
219 init {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
220 setAdapter(
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
221 ArrayAdapter(
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
222 context,
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
223 android.R.layout.simple_list_item_1, list
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
224 )
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
225 )
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
226 setOnItemClickListener(this)
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
227 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
228
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
229 override fun onItemClick(parent: AdapterView<*>?, view: View, position: Int, id: Long) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
230 selected = position
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
231 eventHandlerInt(11, position, 0, 0, 0)
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
232 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
233
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
234 external fun eventHandlerInt(
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
235 message: Int,
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
236 inta: Int,
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
237 intb: Int,
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
238 intc: Int,
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
239 intd: Int
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
240 )
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
241 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
242
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
243 class DWRender(context: Context) : View(context) {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
244 var cachedCanvas: Canvas? = null
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
245 var typeface: Typeface? = null
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
246 var fontsize: Float? = null
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
247
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
248 override fun onSizeChanged(width: Int, height: Int, oldWidth: Int, oldHeight: Int) {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
249 super.onSizeChanged(width, height, oldWidth, oldHeight)
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
250 // Send DW_SIGNAL_CONFIGURE
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
251 eventHandlerInt(1, width, height, 0, 0)
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
252 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
253
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
254 override fun onDraw(canvas: Canvas) {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
255 super.onDraw(canvas)
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
256 cachedCanvas = canvas
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
257 // Send DW_SIGNAL_EXPOSE
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
258 eventHandlerInt(7, 0, 0, this.width, this.height)
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
259 cachedCanvas = null
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
260 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
261
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
262 external fun eventHandlerInt(
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
263 message: Int,
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
264 inta: Int,
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
265 intb: Int,
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
266 intc: Int,
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
267 intd: Int
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
268 )
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
269 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
270
2526
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
271 class DWFileChooser(private val activity: Activity) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
272 private val list: ListView = ListView(activity)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
273 private val dialog: Dialog = Dialog(activity)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
274 private var currentPath: File? = null
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
275
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
276 // filter on file extension
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
277 private var extension: String? = null
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
278 fun setExtension(extension: String?) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
279 this.extension = extension?.toLowerCase(Locale.ROOT)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
280 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
281
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
282 // file selection event handling
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
283 interface FileSelectedListener {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
284 fun fileSelected(file: File?)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
285 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
286
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
287 fun setFileListener(fileListener: FileSelectedListener?): DWFileChooser {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
288 this.fileListener = fileListener
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
289 return this
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
290 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
291
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
292 private var fileListener: FileSelectedListener? = null
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
293 fun showDialog() {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
294 dialog.show()
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
295 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
296
2527
eec926265888 Android: Use toLongOrNull() whenever converting from string to long...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
297 /*
2526
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
298 * Sort, filter and display the files for the given path.
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
299 */
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
300 private fun refresh(path: File?) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
301 currentPath = path
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
302 if (path != null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
303 if (path.exists()) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
304 val dirs = path.listFiles { file -> file.isDirectory && file.canRead() }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
305 val files = path.listFiles { file ->
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
306 if (!file.isDirectory) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
307 if (!file.canRead()) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
308 false
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
309 } else if (extension == null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
310 true
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
311 } else {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
312 file.name.toLowerCase(Locale.ROOT).endsWith(extension!!)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
313 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
314 } else {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
315 false
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
316 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
317 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
318
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
319 // convert to an array
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
320 var i = 0
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
321 val fileList: Array<String?>
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
322 var filecount = 0
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
323 var dircount = 0
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
324 if(files != null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
325 filecount = files.size
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
326 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
327 if(dirs != null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
328 dircount = dirs.size
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
329 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
330 if (path.parentFile == null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
331 fileList = arrayOfNulls(dircount + filecount)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
332 } else {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
333 fileList = arrayOfNulls(dircount + filecount + 1)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
334 fileList[i++] = PARENT_DIR
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
335 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
336 if(dirs != null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
337 Arrays.sort(dirs)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
338 for (dir in dirs) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
339 fileList[i++] = dir.name
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
340 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
341 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
342 if(files != null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
343 Arrays.sort(files)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
344 for (file in files) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
345 fileList[i++] = file.name
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
346 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
347 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
348
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
349 // refresh the user interface
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
350 dialog.setTitle(currentPath!!.path)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
351 list.adapter = object : ArrayAdapter<Any?>(
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
352 activity,
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
353 R.layout.simple_list_item_1, fileList
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
354 ) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
355 override fun getView(pos: Int, view: View?, parent: ViewGroup): View {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
356 val thisview = super.getView(pos, view, parent)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
357 (thisview as TextView).isSingleLine = true
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
358 return thisview
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
359 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
360 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
361 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
362 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
363 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
364
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
365 /**
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
366 * Convert a relative filename into an actual File object.
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
367 */
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
368 private fun getChosenFile(fileChosen: String): File? {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
369 return if (fileChosen == PARENT_DIR) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
370 currentPath!!.parentFile
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
371 } else {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
372 File(currentPath, fileChosen)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
373 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
374 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
375
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
376 companion object {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
377 private const val PARENT_DIR = ".."
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
378 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
379
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
380 init {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
381 list.onItemClickListener =
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
382 OnItemClickListener { parent, view, which, id ->
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
383 val fileChosen = list.getItemAtPosition(which) as String
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
384 val chosenFile: File? = getChosenFile(fileChosen)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
385 if (chosenFile != null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
386 if (chosenFile.isDirectory) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
387 refresh(chosenFile)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
388 } else {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
389 if (fileListener != null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
390 fileListener!!.fileSelected(chosenFile)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
391 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
392 dialog.dismiss()
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
393 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
394 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
395 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
396 dialog.setContentView(list)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
397 dialog.window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
398 refresh(Environment.getExternalStorageDirectory())
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
399 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
400 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
401
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
402 // On Android we can't pre-create submenus...
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
403 // So create our own placeholder classes, and create the actual menus
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
404 // on demand when required by Android
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
405 class DWMenuItem
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
406 {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
407 var title: String? = null
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
408 var menu: DWMenu? = null
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
409 var submenu: DWMenu? = null
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
410 var checked: Boolean = false
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
411 var check: Boolean = false
2546
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
412 var enabled: Boolean = true
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
413 var menuitem: MenuItem? = null
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
414 var submenuitem: SubMenu? = null
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
415 var id: Int = 0
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
416 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
417
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
418 class DWMenu {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
419 var menu: Menu? = null
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
420 var children = mutableListOf<DWMenuItem>()
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
421 var id: Int = 0
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
422
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
423 fun createMenu(newmenu: Menu?) {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
424 if(menu == null) {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
425 menu = newmenu
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
426 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
427 if(menu != null) {
2544
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
428 var group: Int = 0
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
429
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
430 // Enable group dividers for separators
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
431 MenuCompat.setGroupDividerEnabled(menu, true);
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
432
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
433 for (menuitem in children) {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
434 // Submenus on Android can't have submenus, so stop at depth 1
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
435 if (menuitem.submenu != null && menu !is SubMenu) {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
436 if(menuitem.submenuitem == null) {
2544
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
437 menuitem.submenuitem = menu?.addSubMenu(group, menuitem.id, 0, menuitem.title)
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
438 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
439 menuitem.submenu!!.createMenu(menuitem.submenuitem)
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
440 } else if(menuitem.submenu == null) {
2544
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
441 if(menuitem.title!!.isEmpty()) {
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
442 group += 1
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
443 } else if(menuitem.menuitem == null) {
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
444 menuitem.menuitem = menu?.add(group, menuitem.id, 0, menuitem.title)
2545
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
445 menuitem.menuitem!!.isCheckable = menuitem.check
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
446 menuitem.menuitem!!.isChecked = menuitem.checked
2546
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
447 menuitem.menuitem!!.isEnabled = menuitem.enabled
2544
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
448 menuitem.menuitem!!.setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener { item: MenuItem? ->
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
449 eventHandlerSimple(menuitem, 8)
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
450 true
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
451 })
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
452 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
453 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
454 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
455 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
456 }
2544
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
457
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
458 external fun eventHandlerSimple(item: DWMenuItem, message: Int)
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
459 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
460
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
461 class DWindows : AppCompatActivity() {
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
462 var firstWindow: Boolean = true
2499
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
463 var windowLayout: LinearLayout? = null
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
464 var threadLock = ReentrantLock()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
465 var threadCond = threadLock.newCondition()
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
466 var notificationID: Int = 0
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
467 var darkMode: Int = -1
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
468 private var paint = Paint()
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
469 private var bgcolor: Int = 0
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
470 private var menuBar: DWMenu? = null
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
471
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
472 // Our version of runOnUiThread that waits for execution
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
473 fun waitOnUiThread(runnable: Runnable)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
474 {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
475 if(Looper.myLooper() == Looper.getMainLooper()) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
476 runnable.run()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
477 } else {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
478 threadLock.lock()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
479 val ourRunnable = Runnable {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
480 threadLock.lock()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
481 runnable.run()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
482 threadCond.signal()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
483 threadLock.unlock()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
484 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
485 runOnUiThread(ourRunnable)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
486 threadCond.await()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
487 threadLock.unlock()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
488 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
489 }
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
490
2498
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
491 // We only want to call this once when the app starts up
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
492 // By default Android will call onCreate for rotation and other
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
493 // changes. This is incompatible with Dynamic Windows...
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
494 // Make sure the following is in your AndroidManifest.xml
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
495 // android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
496 override fun onCreate(savedInstanceState: Bundle?) {
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
497 super.onCreate(savedInstanceState)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
498
2480
878d36588aaa Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2479
diff changeset
499 // Turn on rotation
878d36588aaa Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2479
diff changeset
500 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR)
878d36588aaa Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2479
diff changeset
501
2498
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
502 // Get the Android app path
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
503 val m = packageManager
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
504 var s = packageName
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
505 val p = m.getPackageInfo(s!!, 0)
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
506 s = p.applicationInfo.dataDir
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
507
2498
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
508 // Initialize the Dynamic Windows code...
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
509 // This will start a new thread that calls the app's dwmain()
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
510 dwindowsInit(s, this.getPackageName())
2496
3bf2f08fdc45 Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2495
diff changeset
511 }
3bf2f08fdc45 Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2495
diff changeset
512
3bf2f08fdc45 Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2495
diff changeset
513 override fun onConfigurationChanged(newConfig: Configuration) {
3bf2f08fdc45 Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2495
diff changeset
514 super.onConfigurationChanged(newConfig)
3bf2f08fdc45 Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2495
diff changeset
515
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
516 val currentNightMode = newConfig.uiMode and Configuration.UI_MODE_NIGHT_MASK
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
517 when (currentNightMode) {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
518 Configuration.UI_MODE_NIGHT_NO -> { darkMode = 0 } // Night mode is not active, we're using the light theme
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
519 Configuration.UI_MODE_NIGHT_YES -> { darkMode = 1 } // Night mode is active, we're using dark theme
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
520 }
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
521
2499
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
522 // Send a DW_SIGNAL_CONFIGURE on orientation change
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
523 if(windowLayout != null) {
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
524 var width: Int = windowLayout!!.width
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
525 var height: Int = windowLayout!!.height
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
526
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
527 eventHandlerInt(windowLayout as View, 1, width, height, 0, 0)
2496
3bf2f08fdc45 Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2495
diff changeset
528 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
529 }
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
530
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
531 override fun onCreateOptionsMenu(menu: Menu?): Boolean {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
532 if(menuBar == null) {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
533 menuBar = DWMenu()
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
534 menuBar!!.menu = menu
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
535 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
536 return super.onCreateOptionsMenu(menu)
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
537 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
538
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
539 override fun onPrepareOptionsMenu(menu: Menu?): Boolean {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
540 if(menuBar != null) {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
541 menuBar!!.createMenu(menu)
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
542 } else {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
543 menuBar = DWMenu()
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
544 menuBar!!.createMenu(menu)
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
545 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
546 return super.onPrepareOptionsMenu(menu)
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
547 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
548
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
549 fun darkModeDetected(): Int
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
550 {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
551 return darkMode
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
552 }
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
553
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
554 fun menuBarNew(location: View): DWMenu?
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
555 {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
556 // TODO: Make sure location is this activity
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
557 return menuBar
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
558 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
559
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
560 fun menuNew(cid: Int): DWMenu
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
561 {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
562 val menu = DWMenu()
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
563 menu.id = cid
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
564 return menu
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
565 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
566
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
567 fun menuAppendItem(menu: DWMenu, title: String, cid: Int, flags: Int, end: Int, check: Int, submenu: DWMenu?): DWMenuItem
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
568 {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
569 val menuitem = DWMenuItem()
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
570 menuitem.id = cid
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
571 menuitem.title = title
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
572 menuitem.check = check != 0
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
573 if(submenu != null) {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
574 menuitem.submenu = submenu
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
575 }
2546
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
576 if((flags and (1 shl 1)) != 0) {
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
577 menuitem.enabled = false
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
578 }
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
579 if((flags and (1 shl 2)) != 0) {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
580 menuitem.checked = true
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
581 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
582 if(end == 0) {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
583 menu.children.add(0, menuitem)
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
584 } else {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
585 menu.children.add(menuitem)
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
586 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
587 return menuitem
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
588 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
589
2545
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
590 fun menuDestroy(menu: DWMenu)
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
591 {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
592 menu.children.clear()
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
593 runOnUiThread {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
594 menu.menu!!.clear()
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
595 invalidateOptionsMenu()
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
596 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
597 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
598
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
599 fun menuDeleteItem(menu: DWMenu, cid: Int)
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
600 {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
601 for(menuitem in menu.children) {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
602 if(menuitem.id == cid) {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
603 menu.children.remove(menuitem)
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
604 runOnUiThread {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
605 menu.menu!!.removeItem(menuitem.id)
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
606 invalidateOptionsMenu()
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
607 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
608 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
609 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
610 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
611
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
612 fun menuSetState(menu: DWMenu, cid: Int, state: Int)
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
613 {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
614 for(menuitem in menu.children) {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
615 if(menuitem.id == cid) {
2546
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
616 // Handle DW_MIS_ENABLED/DISABLED
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
617 if((state and (1 or (1 shl 1))) != 0) {
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
618 var enabled: Boolean = false
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
619
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
620 // Handle DW_MIS_ENABLED
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
621 if ((state and 1) != 0) {
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
622 enabled = true
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
623 }
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
624 menuitem.enabled = enabled
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
625 runOnUiThread {
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
626 menuitem.menuitem!!.isEnabled = enabled
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
627 invalidateOptionsMenu()
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
628 }
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
629 }
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
630
2545
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
631 // Handle DW_MIS_CHECKED/UNCHECKED
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
632 if((state and ((1 shl 2) or (1 shl 3))) != 0) {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
633 var checked: Boolean = false
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
634
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
635 // Handle DW_MIS_CHECKED
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
636 if ((state and (1 shl 2)) != 0) {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
637 checked = true
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
638 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
639 menuitem.checked = checked
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
640 runOnUiThread {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
641 menuitem.menuitem!!.isChecked = checked
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
642 invalidateOptionsMenu()
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
643 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
644 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
645 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
646 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
647 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
648
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
649 /*
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
650 * These are the Android calls to actually create the UI...
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
651 * forwarded from the C Dynamic Windows API
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
652 */
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
653 fun windowNew(title: String, style: Int): LinearLayout? {
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
654 if (firstWindow) {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
655 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
656 var dataArrayMap = SimpleArrayMap<String, Long>()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
657 windowLayout = LinearLayout(this)
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
658
2503
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
659 windowLayout!!.visibility = View.GONE
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
660 windowLayout!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
661 setContentView(windowLayout)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
662 this.title = title
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
663 // For now we just return our DWindows' main activity layout...
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
664 // in the future, later calls should create new activities
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
665 firstWindow = false
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
666 }
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
667 return windowLayout
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
668 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
669 return null
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
670 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
671
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
672 fun windowFromId(window: View, cid: Int): View {
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
673 return window.findViewById(cid)
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
674 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
675
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
676 fun windowSetData(window: View, name: String, data: Long) {
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
677 if (window.tag != null) {
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
678 var dataArrayMap: SimpleArrayMap<String, Long> = window.tag as SimpleArrayMap<String, Long>
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
679
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
680 if (data != 0L) {
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
681 dataArrayMap.put(name, data)
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
682 } else {
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
683 dataArrayMap.remove(name)
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
684 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
685 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
686 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
687
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
688 fun windowGetData(window: View, name: String): Long {
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
689 var retval: Long = 0L
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
690
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
691 if (window.tag != null) {
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
692 var dataArrayMap: SimpleArrayMap<String, Long> = window.tag as SimpleArrayMap<String, Long>
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
693
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
694 retval = dataArrayMap.get(name)!!
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
695 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
696 return retval
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
697 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
698
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
699 fun windowSetEnabled(window: View, state: Boolean) {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
700 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
701 window.setEnabled(state)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
702 }
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
703 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
704
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
705 fun typefaceFromFontName(fontname: String?): Typeface?
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
706 {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
707 if(fontname != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
708 val bold: Boolean = fontname.contains(" Bold")
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
709 val italic: Boolean = fontname.contains(" Italic")
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
710 val font = fontname.substringAfter('.')
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
711 var fontFamily = font
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
712 var typeface: Typeface? = null
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
713
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
714 if (bold && font != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
715 fontFamily = font.substringBefore(" Bold")
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
716 } else if (italic && font != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
717 fontFamily = font.substringBefore(" Italic")
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
718 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
719
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
720 if (fontFamily != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
721 var style: Int = Typeface.NORMAL
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
722 if (bold && italic) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
723 style = Typeface.BOLD_ITALIC
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
724 } else if (bold) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
725 style = Typeface.BOLD
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
726 } else if (italic) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
727 style = Typeface.ITALIC
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
728 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
729 typeface = Typeface.create(fontFamily, style)
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
730 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
731 return typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
732 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
733 return Typeface.DEFAULT
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
734 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
735
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
736 fun windowSetFont(window: View, fontname: String?) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
737 var typeface: Typeface? = typefaceFromFontName(fontname)
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
738 var size: Float? = null
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
739
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
740 if(fontname != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
741 size = fontname.substringBefore('.').toFloatOrNull()
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
742 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
743
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
744 if(typeface != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
745 waitOnUiThread {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
746 if (window is TextView) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
747 var textview: TextView = window
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
748 textview.typeface = typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
749 if(size != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
750 textview.textSize = size
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
751 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
752 } else if (window is Button) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
753 var button: Button = window
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
754 button.typeface = typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
755 if(size != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
756 button.textSize = size
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
757 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
758 } else if(window is DWRender) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
759 var render: DWRender = window
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
760 render.typeface = typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
761 if(size != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
762 render.fontsize = size
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
763 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
764 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
765 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
766 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
767 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
768
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
769 fun windowSetColor(window: View, fore: Int, falpha: Int, fred: Int, fgreen: Int, fblue: Int,
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
770 back: Int, balpha: Int, bred: Int, bgreen: Int, bblue: Int) {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
771 var colorfore: Int = Color.rgb(fred, fgreen, fblue)
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
772 var colorback: Int = Color.rgb(bred, bgreen, bblue)
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
773
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
774 // DW_CLR_DEFAULT on background sets it transparent...
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
775 // so the background drawable shows through
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
776 if(back == 16) {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
777 colorback = Color.TRANSPARENT
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
778 }
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
779
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
780 waitOnUiThread {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
781 if (window is TextView) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
782 var textview: TextView = window
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
783
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
784 // Handle DW_CLR_DEFAULT
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
785 if(fore == 16) {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
786 val value = TypedValue()
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
787 this.theme.resolveAttribute(R.attr.editTextColor, value, true)
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
788 colorfore = value.data
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
789 }
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
790 textview.setTextColor(colorfore)
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
791 textview.setBackgroundColor(colorback)
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
792 } else if (window is Button) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
793 var button: Button = window
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
794
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
795 // Handle DW_CLR_DEFAULT
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
796 if(fore == 16) {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
797 val value = TypedValue()
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
798 // colorButtonNormal requires API 21... use the editTextColor...
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
799 // on older versions as a placeholder... this is probably wrong
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
800 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
801 this.theme.resolveAttribute(R.attr.colorButtonNormal, value, true)
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
802 } else {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
803 this.theme.resolveAttribute(R.attr.editTextColor, value, true)
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
804 }
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
805 colorfore = value.data
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
806 }
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
807 button.setTextColor(colorfore)
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
808 button.setBackgroundColor(colorback)
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
809 } else if(window is LinearLayout) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
810 var box: LinearLayout = window
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
811
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
812 box.setBackgroundColor(colorback)
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
813 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
814 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
815 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
816
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
817 fun windowSetText(window: View, text: String) {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
818 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
819 if (window is TextView) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
820 var textview: TextView = window
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
821 textview.text = text
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
822 } else if (window is Button) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
823 var button: Button = window
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
824 button.text = text
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
825 } else if (window is LinearLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
826 // TODO: Make sure this is actually the top-level layout, not just a box
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
827 this.title = text
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
828 }
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
829 }
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
830 }
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
831
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
832 fun windowGetText(window: View): String? {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
833 var text: String? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
834
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
835 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
836 if (window is TextView) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
837 var textview: TextView = window
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
838 text = textview.text.toString()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
839 } else if (window is Button) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
840 var button: Button = window
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
841 text = button.text.toString()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
842 } else if (window is LinearLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
843 // TODO: Make sure this is actually the top-level layout, not just a box
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
844 text = this.title.toString()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
845 }
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
846 }
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
847 return text
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
848 }
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
849
2503
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
850 fun windowHideShow(window: View, state: Int)
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
851 {
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
852 waitOnUiThread {
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
853 if(state == 0) {
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
854 window.visibility = View.GONE
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
855 } else {
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
856 window.visibility = View.VISIBLE
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
857 }
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
858 }
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
859 }
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
860
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
861 fun clipboardGetText(): String {
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
862 var cm: ClipboardManager = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
863 var clipdata = cm.primaryClip
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
864
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
865 if (clipdata != null && clipdata.itemCount > 0) {
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
866 return clipdata.getItemAt(0).coerceToText(this).toString()
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
867 }
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
868 return ""
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
869 }
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
870
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
871 fun clipboardSetText(text: String) {
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
872 var cm: ClipboardManager = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
873 var clipdata = ClipData.newPlainText("text", text)
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
874
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
875 cm.setPrimaryClip(clipdata)
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
876 }
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
877
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
878 fun boxNew(type: Int, pad: Int): LinearLayout? {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
879 var box: LinearLayout? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
880 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
881 box = LinearLayout(this)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
882 var dataArrayMap = SimpleArrayMap<String, Long>()
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
883
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
884 box!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
885 box!!.layoutParams =
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
886 LinearLayout.LayoutParams(
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
887 LinearLayout.LayoutParams.WRAP_CONTENT,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
888 LinearLayout.LayoutParams.WRAP_CONTENT
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
889 )
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
890 if (type > 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
891 box!!.orientation = LinearLayout.VERTICAL
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
892 } else {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
893 box!!.orientation = LinearLayout.HORIZONTAL
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
894 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
895 box!!.setPadding(pad, pad, pad, pad)
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
896 }
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
897 return box
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
898 }
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
899
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
900 fun scrollBoxNew(type: Int, pad: Int) : ScrollView? {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
901 var scrollBox: ScrollView? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
902
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
903 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
904 val box = LinearLayout(this)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
905 scrollBox = ScrollView(this)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
906 var dataArrayMap = SimpleArrayMap<String, Long>()
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
907
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
908 scrollBox!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
909 box.layoutParams =
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
910 LinearLayout.LayoutParams(
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
911 LinearLayout.LayoutParams.MATCH_PARENT,
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
912 LinearLayout.LayoutParams.MATCH_PARENT
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
913 )
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
914 if (type > 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
915 box.orientation = LinearLayout.VERTICAL
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
916 } else {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
917 box.orientation = LinearLayout.HORIZONTAL
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
918 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
919 box.setPadding(pad, pad, pad, pad)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
920 // Add a pointer back to the ScrollView
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
921 box.tag = scrollBox
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
922 scrollBox!!.addView(box)
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
923 }
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
924 return scrollBox
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
925 }
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
926
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
927 fun boxPack(
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
928 boxview: View,
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
929 item: View,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
930 index: Int,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
931 width: Int,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
932 height: Int,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
933 hsize: Int,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
934 vsize: Int,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
935 pad: Int
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
936 ) {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
937 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
938 var w: Int = LinearLayout.LayoutParams.WRAP_CONTENT
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
939 var h: Int = LinearLayout.LayoutParams.WRAP_CONTENT
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
940 var box: LinearLayout? = null
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
941
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
942 // Handle scrollboxes by pulling the LinearLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
943 // out of the ScrollView to pack into
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
944 if (boxview is LinearLayout) {
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
945 box = boxview
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
946 } else if (boxview is ScrollView) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
947 var sv: ScrollView = boxview
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
948
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
949 if (sv.getChildAt(0) is LinearLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
950 box = sv.getChildAt(0) as LinearLayout
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
951 }
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
952 }
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
953
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
954 if (box != null) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
955 if ((item is LinearLayout) or (item is ScrollView)) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
956 if (box.orientation == LinearLayout.VERTICAL) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
957 if (hsize > 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
958 w = LinearLayout.LayoutParams.MATCH_PARENT
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
959 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
960 } else {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
961 if (vsize > 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
962 h = LinearLayout.LayoutParams.MATCH_PARENT
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
963 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
964 }
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
965 }
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
966 var params: LinearLayout.LayoutParams = LinearLayout.LayoutParams(w, h)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
967
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
968 if (item !is LinearLayout && (width != -1 || height != -1)) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
969 item.measure(0, 0)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
970 if (width > 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
971 w = width
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
972 } else if (width == -1) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
973 w = item.getMeasuredWidth()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
974 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
975 if (height > 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
976 h = height
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
977 } else if (height == -1) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
978 h = item.getMeasuredHeight()
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
979 }
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
980 }
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
981 if (box.orientation == LinearLayout.VERTICAL) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
982 if (vsize > 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
983 if (w > 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
984 params.weight = w.toFloat()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
985 } else {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
986 params.weight = 1F
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
987 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
988 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
989 } else {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
990 if (hsize > 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
991 if (h > 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
992 params.weight = h.toFloat()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
993 } else {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
994 params.weight = 1F
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
995 }
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
996 }
2480
878d36588aaa Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2479
diff changeset
997 }
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
998 if (pad > 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
999 params.setMargins(pad, pad, pad, pad)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1000 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1001 var grav: Int = Gravity.CLIP_HORIZONTAL or Gravity.CLIP_VERTICAL
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1002 if (hsize > 0 && vsize > 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1003 params.gravity = Gravity.FILL or grav
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1004 } else if (hsize > 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1005 params.gravity = Gravity.FILL_HORIZONTAL or grav
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1006 } else if (vsize > 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1007 params.gravity = Gravity.FILL_VERTICAL or grav
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1008 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1009 item.layoutParams = params
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1010 box.addView(item, index)
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1011 }
2478
b0230e378667 Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
1012 }
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1013 }
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1014
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1015 fun boxUnpack(item: View) {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1016 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1017 var box: LinearLayout = item.parent as LinearLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1018 box.removeView(item)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1019 }
2477
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1020 }
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1021
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1022 fun boxUnpackAtIndex(box: LinearLayout, index: Int): View? {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1023 var item: View? = null
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1024
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1025 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1026 item = box.getChildAt(index)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1027
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1028 box.removeView(item)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1029 }
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1030 return item
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1031 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1032
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1033 fun buttonNew(text: String, cid: Int): Button? {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1034 var button: Button? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1035 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1036 button = Button(this)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1037 var dataArrayMap = SimpleArrayMap<String, Long>()
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
1038
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1039 button!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1040 button!!.text = text
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1041 button!!.id = cid
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1042 button!!.setOnClickListener {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1043 eventHandlerSimple(button!!, 8)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1044 }
2482
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
1045 }
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1046 return button
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1047 }
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1048
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1049 fun bitmapButtonNew(text: String, resid: Int): ImageButton? {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1050 var button: ImageButton? = null
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1051 waitOnUiThread {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1052 button = ImageButton(this)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1053 var dataArrayMap = SimpleArrayMap<String, Long>()
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1054
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1055 button!!.tag = dataArrayMap
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1056 button!!.id = resid
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1057 button!!.setImageResource(resid)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1058 button!!.setOnClickListener {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1059 eventHandlerSimple(button!!, 8)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1060 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1061 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1062 return button
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1063 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1064
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1065 fun bitmapButtonNewFromFile(text: String, cid: Int, filename: String): ImageButton? {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1066 var button: ImageButton? = null
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1067 waitOnUiThread {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1068 button = ImageButton(this)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1069 var dataArrayMap = SimpleArrayMap<String, Long>()
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1070
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1071 button!!.tag = dataArrayMap
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1072 button!!.id = cid
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1073 button!!.setOnClickListener {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1074 eventHandlerSimple(button!!, 8)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1075 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1076 // Try to load the image, and protect against exceptions
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1077 try {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1078 val f = File(filename)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1079 val b = BitmapFactory.decodeStream(FileInputStream(f))
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1080 button!!.setImageBitmap(b)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1081 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1082 catch (e: FileNotFoundException)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1083 {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1084 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1085 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1086 return button
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1087 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1088
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1089 fun bitmapButtonNewFromData(text: String, cid: Int, data: ByteArray, length: Int): ImageButton? {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1090 var button: ImageButton? = null
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1091 waitOnUiThread {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1092 button = ImageButton(this)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1093 var dataArrayMap = SimpleArrayMap<String, Long>()
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1094 val b = BitmapFactory.decodeByteArray(data,0, length)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1095
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1096 button!!.tag = dataArrayMap
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1097 button!!.id = cid
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1098 button!!.setOnClickListener {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1099 eventHandlerSimple(button!!, 8)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1100 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1101 button!!.setImageBitmap(b)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1102 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1103 return button
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1104 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1105
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1106 fun entryfieldNew(text: String, cid: Int, password: Int): EditText? {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1107 var entryfield: EditText? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1108
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1109 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1110 var dataArrayMap = SimpleArrayMap<String, Long>()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1111 entryfield = EditText(this)
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
1112
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1113 entryfield!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1114 entryfield!!.id = cid
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1115 if (password > 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1116 entryfield!!.transformationMethod = PasswordTransformationMethod.getInstance()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1117 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1118 entryfield!!.setText(text)
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1119 }
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1120 return entryfield
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1121 }
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1122
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1123 fun entryfieldSetLimit(entryfield: EditText, limit: Long) {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1124 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1125 entryfield.filters = arrayOf<InputFilter>(LengthFilter(limit.toInt()))
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1126 }
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1127 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1128
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1129 fun radioButtonNew(text: String, cid: Int): RadioButton? {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1130 var radiobutton: RadioButton? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1131
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1132 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1133 var dataArrayMap = SimpleArrayMap<String, Long>()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1134 radiobutton = RadioButton(this)
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
1135
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1136 radiobutton!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1137 radiobutton!!.id = cid
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1138 radiobutton!!.text = text
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1139 radiobutton!!.setOnClickListener {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1140 eventHandlerSimple(radiobutton!!, 8)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1141 }
2482
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
1142 }
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1143 return radiobutton
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1144 }
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1145
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1146 fun checkboxNew(text: String, cid: Int): CheckBox? {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1147 var checkbox: CheckBox? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1148
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1149 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1150 var dataArrayMap = SimpleArrayMap<String, Long>()
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
1151
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1152 checkbox = CheckBox(this)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1153 checkbox!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1154 checkbox!!.id = cid
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1155 checkbox!!.text = text
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1156 checkbox!!.setOnClickListener {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1157 eventHandlerSimple(checkbox!!, 8)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1158 }
2482
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
1159 }
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1160 return checkbox
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1161 }
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1162
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1163 fun checkOrRadioSetChecked(control: View, state: Int)
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1164 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1165 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1166 if (control is CheckBox) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1167 var checkbox: CheckBox = control
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1168 checkbox.isChecked = state != 0
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1169 } else if (control is RadioButton) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1170 var radiobutton: RadioButton = control
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1171 radiobutton.isChecked = state != 0
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1172 }
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1173 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1174 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1175
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1176 fun checkOrRadioGetChecked(control: View): Boolean
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1177 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1178 var retval: Boolean = false
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1179
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1180 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1181 if (control is CheckBox) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1182 var checkbox: CheckBox = control
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1183 retval = checkbox.isChecked
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1184 } else if (control is RadioButton) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1185 var radiobutton: RadioButton = control
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1186 retval = radiobutton.isChecked
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1187 }
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1188 }
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1189 return retval
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1190 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1191
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1192 fun textNew(text: String, cid: Int, status: Int): TextView? {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1193 var textview: TextView? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1194
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1195 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1196 var dataArrayMap = SimpleArrayMap<String, Long>()
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
1197
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1198 textview = TextView(this)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1199 textview!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1200 textview!!.id = cid
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1201 textview!!.text = text
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1202 if (status != 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1203 val border = GradientDrawable()
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
1204
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1205 // Set a black border on white background...
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1206 // might need to change this to invisible...
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1207 // or the color from windowSetColor
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1208 border.setColor(-0x1)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1209 border.setStroke(1, -0x1000000)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1210 textview!!.background = border
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1211 }
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
1212 }
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1213 return textview
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1214 }
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1215
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1216 fun mleNew(cid: Int): EditText?
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1217 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1218 var mle: EditText? = null
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1219
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1220 waitOnUiThread {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1221 var dataArrayMap = SimpleArrayMap<String, Long>()
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1222
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1223 mle = EditText(this)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1224 mle!!.tag = dataArrayMap
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1225 mle!!.id = cid
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1226 mle!!.isSingleLine = false
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1227 mle!!.imeOptions = EditorInfo.IME_FLAG_NO_ENTER_ACTION
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1228 mle!!.inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1229 mle!!.isVerticalScrollBarEnabled = true
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1230 mle!!.scrollBarStyle = View.SCROLLBARS_INSIDE_INSET
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1231 mle!!.setHorizontallyScrolling(true)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1232 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1233 return mle
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1234 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1235
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1236 fun mleSetWordWrap(mle: EditText, state: Int)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1237 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1238 waitOnUiThread {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1239 if (state != 0) {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1240 mle.setHorizontallyScrolling(false)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1241 } else {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1242 mle.setHorizontallyScrolling(true)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1243 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1244 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1245 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1246
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1247 fun mleSetEditable(mle: EditText, state: Int)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1248 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1249 waitOnUiThread {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1250 if (state != 0) {
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1251 mle.inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE)
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1252 } else {
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1253 mle.inputType = InputType.TYPE_NULL
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1254 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1255 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1256 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1257
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1258 fun mleSetCursor(mle: EditText, point: Int)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1259 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1260 waitOnUiThread {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1261 mle.setSelection(point)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1262 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1263 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1264
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1265 fun mleClear(mle: EditText)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1266 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1267 waitOnUiThread {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1268 mle.setText("")
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1269 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1270 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1271
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1272 fun mleImport(mle: EditText, text: String, startpoint: Int): Int
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1273 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1274 var retval: Int = startpoint
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1275
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1276 waitOnUiThread {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1277 val origtext = mle.text
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1278 val origlen = origtext.toString().length
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1279
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1280 if(startpoint < 1) {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1281 val newtext = text + origtext.toString()
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1282
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1283 mle.setText(newtext)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1284 retval = origlen + text.length
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1285 } else if(startpoint >= origlen) {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1286 val newtext = origtext.toString() + text
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1287
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1288 mle.setText(newtext)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1289 retval = origlen + text.length
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1290 } else {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1291 val newtext = origtext.substring(0, startpoint) + text + origtext.substring(startpoint)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1292
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1293 mle.setText(newtext)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1294 retval = startpoint + text.length
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1295 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1296 mle.setSelection(retval)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1297 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1298 return retval
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1299 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1300
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1301 fun mleDelete(mle: EditText, startpoint: Int, length: Int)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1302 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1303 waitOnUiThread {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1304 val origtext = mle.text
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1305 val newtext = origtext.substring(0, startpoint) + origtext.substring(startpoint + length)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1306
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1307 mle.setText(newtext)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1308 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1309 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1310
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1311 fun notebookNew(cid: Int, top: Int): RelativeLayout?
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
1312 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1313 var notebook: RelativeLayout? = null
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
1314
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1315 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1316 val pager = ViewPager2(this)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1317 val tabs = TabLayout(this)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1318 var w: Int = RelativeLayout.LayoutParams.MATCH_PARENT
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1319 var h: Int = RelativeLayout.LayoutParams.WRAP_CONTENT
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1320 var dataArrayMap = SimpleArrayMap<String, Long>()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1321
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1322 notebook = RelativeLayout(this)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1323 notebook!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1324 notebook!!.id = cid
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1325 tabs.id = View.generateViewId()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1326 pager.id = View.generateViewId()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1327 pager.adapter = DWTabViewPagerAdapter()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1328 TabLayoutMediator(tabs, pager) { tab, position ->
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1329 // This code never gets called?
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1330 }.attach()
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
1331
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1332 var params: RelativeLayout.LayoutParams = RelativeLayout.LayoutParams(w, h)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1333 if (top != 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1334 params.addRule(RelativeLayout.ALIGN_PARENT_TOP)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1335 } else {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1336 params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1337 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1338 tabs.tabGravity = TabLayout.GRAVITY_FILL
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1339 tabs.tabMode = TabLayout.MODE_FIXED
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1340 notebook!!.addView(tabs, params)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1341 params = RelativeLayout.LayoutParams(w, w)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1342 if (top != 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1343 params.addRule(RelativeLayout.BELOW, tabs.id)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1344 } else {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1345 params.addRule(RelativeLayout.ABOVE, tabs.id)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1346 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1347 notebook!!.addView(pager, params)
2550
a8d90e2896bc Android: For the moment disable swiping to change notebook pages.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2547
diff changeset
1348 // TODO: Not sure if we want this all the time...
a8d90e2896bc Android: For the moment disable swiping to change notebook pages.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2547
diff changeset
1349 // Might want to make a flag for this
a8d90e2896bc Android: For the moment disable swiping to change notebook pages.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2547
diff changeset
1350 pager.isUserInputEnabled = false
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1351 tabs.addOnTabSelectedListener(object : OnTabSelectedListener {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1352 override fun onTabSelected(tab: TabLayout.Tab) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1353 val adapter = pager.adapter as DWTabViewPagerAdapter
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1354
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1355 pager.currentItem = tab.position
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1356 eventHandlerNotebook(notebook!!, 15, adapter.pageList[tab.position])
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1357 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1358
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1359 override fun onTabUnselected(tab: TabLayout.Tab) {}
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1360 override fun onTabReselected(tab: TabLayout.Tab) {}
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1361 })
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
1362 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1363 return notebook
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1364 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1365
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1366 fun notebookPageNew(notebook: RelativeLayout, flags: Long, front: Int): Long
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1367 {
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1368 var pageID = 0L
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1369
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1370 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1371 var pager: ViewPager2? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1372 var tabs: TabLayout? = null
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1373
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1374 if (notebook.getChildAt(0) is ViewPager2 && notebook.getChildAt(1) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1375 pager = notebook.getChildAt(0) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1376 tabs = notebook.getChildAt(1) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1377 } else if (notebook.getChildAt(1) is ViewPager2 && notebook.getChildAt(0) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1378 pager = notebook.getChildAt(1) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1379 tabs = notebook.getChildAt(0) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1380 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1381
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1382 if (pager != null && tabs != null) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1383 var adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1384 var tab = tabs.newTab()
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1385
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1386 // Increment our page ID... making sure no duplicates exist
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1387 do {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1388 adapter.currentPageID += 1
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1389 } while (adapter.currentPageID == 0L || adapter.pageList.contains(adapter.currentPageID))
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1390 pageID = adapter.currentPageID
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1391 // Temporarily add a black tab with an empty layout/box
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1392 if (front != 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1393 adapter.viewList.add(0, LinearLayout(this))
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1394 adapter.pageList.add(0, pageID)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1395 tabs.addTab(tab, 0)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1396 } else {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1397 adapter.viewList.add(LinearLayout(this))
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1398 adapter.pageList.add(pageID)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1399 tabs.addTab(tab)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1400 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1401 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1402 }
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1403 return pageID
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1404 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1405
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1406 fun notebookPageDestroy(notebook: RelativeLayout, pageID: Long)
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1407 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1408 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1409 var pager: ViewPager2? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1410 var tabs: TabLayout? = null
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1411
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1412 if (notebook.getChildAt(0) is ViewPager2 && notebook.getChildAt(1) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1413 pager = notebook.getChildAt(0) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1414 tabs = notebook.getChildAt(1) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1415 } else if (notebook.getChildAt(1) is ViewPager2 && notebook.getChildAt(0) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1416 pager = notebook.getChildAt(1) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1417 tabs = notebook.getChildAt(0) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1418 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1419
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1420 if (pager != null && tabs != null) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1421 var adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1422 val index = adapter.pageList.indexOf(pageID)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1423 val tab = tabs.getTabAt(index)
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1424
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1425 if (tab != null) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1426 adapter.viewList.removeAt(index)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1427 adapter.pageList.removeAt(index)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1428 tabs.removeTab(tab)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1429 }
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1430 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1431 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1432 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1433
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1434 fun notebookPageSetText(notebook: RelativeLayout, pageID: Long, text: String)
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1435 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1436 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1437 var pager: ViewPager2? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1438 var tabs: TabLayout? = null
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1439
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1440 if (notebook.getChildAt(0) is ViewPager2 && notebook.getChildAt(1) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1441 pager = notebook.getChildAt(0) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1442 tabs = notebook.getChildAt(1) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1443 } else if (notebook.getChildAt(1) is ViewPager2 && notebook.getChildAt(0) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1444 pager = notebook.getChildAt(1) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1445 tabs = notebook.getChildAt(0) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1446 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1447
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1448 if (pager != null && tabs != null) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1449 val adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1450 val index = adapter.pageList.indexOf(pageID)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1451 val tab = tabs.getTabAt(index)
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1452
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1453 if (tab != null) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1454 tab.text = text
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1455 }
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1456 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1457 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1458 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1459
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1460 fun notebookPagePack(notebook: RelativeLayout, pageID: Long, box: LinearLayout)
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1461 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1462 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1463 var pager: ViewPager2? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1464 var tabs: TabLayout? = null
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1465
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1466 if (notebook.getChildAt(0) is ViewPager2 && notebook.getChildAt(1) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1467 pager = notebook.getChildAt(0) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1468 tabs = notebook.getChildAt(1) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1469 } else if (notebook.getChildAt(1) is ViewPager2 && notebook.getChildAt(0) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1470 pager = notebook.getChildAt(1) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1471 tabs = notebook.getChildAt(0) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1472 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1473
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1474 if (pager != null && tabs != null) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1475 var adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1476 val index = adapter.pageList.indexOf(pageID)
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1477
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1478 // Make sure the box is MATCH_PARENT
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1479 box.layoutParams = LinearLayout.LayoutParams(
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1480 LinearLayout.LayoutParams.MATCH_PARENT,
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1481 LinearLayout.LayoutParams.MATCH_PARENT
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1482 );
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1483
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1484 adapter.viewList[index] = box
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1485 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1486 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1487 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1488
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1489 fun notebookPageGet(notebook: RelativeLayout): Long
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1490 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1491 var retval: Long = 0L
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1492
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1493 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1494 var pager: ViewPager2? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1495 var tabs: TabLayout? = null
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1496
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1497 if (notebook.getChildAt(0) is ViewPager2 && notebook.getChildAt(1) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1498 pager = notebook.getChildAt(0) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1499 tabs = notebook.getChildAt(1) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1500 } else if (notebook.getChildAt(1) is ViewPager2 && notebook.getChildAt(0) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1501 pager = notebook.getChildAt(1) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1502 tabs = notebook.getChildAt(0) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1503 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1504
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1505 if (pager != null && tabs != null) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1506 var adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1507 retval = adapter.pageList.get(tabs.selectedTabPosition)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1508 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1509 }
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1510 return retval
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1511 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1512
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1513 fun notebookPageSet(notebook: RelativeLayout, pageID: Long)
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1514 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1515 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1516 var pager: ViewPager2? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1517 var tabs: TabLayout? = null
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1518
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1519 if (notebook.getChildAt(0) is ViewPager2 && notebook.getChildAt(1) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1520 pager = notebook.getChildAt(0) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1521 tabs = notebook.getChildAt(1) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1522 } else if (notebook.getChildAt(1) is ViewPager2 && notebook.getChildAt(0) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1523 pager = notebook.getChildAt(1) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1524 tabs = notebook.getChildAt(0) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1525 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1526
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1527 if (pager != null && tabs != null) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1528 val adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1529 val index = adapter.pageList.indexOf(pageID)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1530 val tab = tabs.getTabAt(index)
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1531
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1532 tabs.selectTab(tab)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1533 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1534 }
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
1535 }
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
1536
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1537 fun sliderNew(vertical: Int, increments: Int, cid: Int): SeekBar?
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1538 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1539 var slider: SeekBar? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1540
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1541 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1542 var dataArrayMap = SimpleArrayMap<String, Long>()
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1543
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1544 slider = SeekBar(this)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1545 slider!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1546 slider!!.id = cid
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1547 slider!!.max = increments
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1548 if (vertical != 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1549 slider!!.rotation = 270F
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1550 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1551 slider!!.setOnSeekBarChangeListener(object : OnSeekBarChangeListener {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1552 override fun onStopTrackingTouch(seekBar: SeekBar) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1553 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1554
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1555 override fun onStartTrackingTouch(seekBar: SeekBar) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1556 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1557
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1558 override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1559 eventHandlerInt(slider as View, 14, slider!!.progress, 0, 0, 0)
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1560 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1561 })
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1562 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1563 return slider
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1564 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1565
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1566 fun percentNew(cid: Int): ProgressBar?
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1567 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1568 var percent: ProgressBar? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1569
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1570 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1571 var dataArrayMap = SimpleArrayMap<String, Long>()
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1572
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1573 percent = ProgressBar(this)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1574 percent!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1575 percent!!.id = cid
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1576 percent!!.max = 100
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1577 }
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1578 return percent
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1579 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1580
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1581 fun percentGetPos(percent: ProgressBar): Int
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1582 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1583 var retval: Int = 0
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1584
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1585 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1586 retval = percent.progress
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1587 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1588 return retval
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1589 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1590
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1591 fun percentSetPos(percent: ProgressBar, position: Int)
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1592 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1593 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1594 percent.progress = position
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1595 }
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1596 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1597
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1598 fun percentSetRange(percent: ProgressBar, range: Int)
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1599 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1600 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1601 percent.max = range
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1602 }
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1603 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1604
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1605 fun htmlNew(cid: Int): WebView?
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1606 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1607 var html: WebView? = null
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1608
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1609 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1610 var dataArrayMap = SimpleArrayMap<String, Long>()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1611
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1612 html = WebView(this)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1613 html!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1614 html!!.id = cid
2505
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
1615 // Configure a few settings to make it behave as we expect
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
1616 html!!.webViewClient = DWWebViewClient()
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
1617 html!!.settings.javaScriptEnabled = true
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1618 }
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1619 return html
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1620 }
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1621
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1622 fun htmlLoadURL(html: WebView, url: String)
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1623 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1624 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1625 html.loadUrl(url)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1626 }
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1627 }
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1628
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1629 fun htmlRaw(html: WebView, data: String)
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1630 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1631 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1632 val encodedHtml: String = Base64.encodeToString(data.toByteArray(), Base64.NO_PADDING)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1633 html.loadData(encodedHtml, "text/html", "base64")
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1634 }
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1635 }
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1636
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1637 fun htmlJavascriptRun(html: WebView, javascript: String, data: Long)
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1638 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1639 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1640 html.evaluateJavascript(javascript) { value ->
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1641 // Execute onReceiveValue's code
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1642 eventHandlerHTMLResult(html, 18, value, data)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1643 }
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1644 }
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1645 }
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1646
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1647 fun htmlAction(html: WebView, action: Int)
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1648 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1649 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1650 when (action) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1651 0 -> html.goBack()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1652 1 -> html.goForward()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1653 2 -> html.loadUrl("http://dwindows.netlabs.org")
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1654 4 -> html.reload()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1655 5 -> html.stopLoading()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1656 }
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1657 }
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1658 }
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1659
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1660 fun spinButtonNew(text: String, cid: Int): DWSpinButton?
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1661 {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1662 var spinbutton: DWSpinButton? = null
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1663
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1664 waitOnUiThread {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1665 var dataArrayMap = SimpleArrayMap<String, Long>()
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1666 val newval = text.toLongOrNull()
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1667
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1668 spinbutton = DWSpinButton(this)
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1669 spinbutton!!.tag = dataArrayMap
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1670 spinbutton!!.id = cid
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1671 spinbutton!!.setText(text)
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1672 if(newval != null) {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1673 spinbutton!!.value = newval
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1674 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1675 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1676 return spinbutton
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1677 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1678
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1679 fun spinButtonSetPos(spinbutton: DWSpinButton, position: Long)
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1680 {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1681 waitOnUiThread {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1682 spinbutton.value = position
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1683 spinbutton.setText(position.toString())
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1684 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1685 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1686
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1687 fun spinButtonSetLimits(spinbutton: DWSpinButton, upper: Long, lower: Long)
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1688 {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1689 waitOnUiThread {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1690 spinbutton.maximum = upper
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1691 spinbutton.minimum = lower
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1692 if(spinbutton.value > upper) {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1693 spinbutton.value = upper
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1694 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1695 if(spinbutton.value < lower) {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1696 spinbutton.value = lower
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1697 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1698 spinbutton.setText(spinbutton.value.toString())
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1699 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1700 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1701
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1702 fun spinButtonGetPos(spinbutton: DWSpinButton): Long
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1703 {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1704 var retval: Long = 0
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1705
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1706 waitOnUiThread {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1707 val newvalue = spinbutton.text.toString().toLongOrNull()
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1708
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1709 if(newvalue == null) {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1710 retval = spinbutton.value
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1711 } else {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1712 retval = newvalue
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1713 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1714 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1715 return retval
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1716 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1717
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1718 fun comboBoxNew(text: String, cid: Int): DWComboBox?
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1719 {
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1720 var combobox: DWComboBox? = null
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1721
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1722 waitOnUiThread {
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1723 var dataArrayMap = SimpleArrayMap<String, Long>()
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1724
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1725 combobox = DWComboBox(this)
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1726 combobox!!.tag = dataArrayMap
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1727 combobox!!.id = cid
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1728 combobox!!.setText(text)
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1729 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1730 return combobox
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1731 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1732
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1733 fun listBoxNew(cid: Int, multi: Int): DWListBox?
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1734 {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1735 var listbox: DWListBox? = null
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1736
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1737 waitOnUiThread {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1738 var dataArrayMap = SimpleArrayMap<String, Long>()
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1739
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1740 listbox = DWListBox(this)
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1741 listbox!!.tag = dataArrayMap
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1742 listbox!!.id = cid
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1743 if(multi != 0) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1744 listbox!!.choiceMode = ListView.CHOICE_MODE_MULTIPLE;
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1745 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1746 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1747 return listbox
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1748 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1749
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1750 fun listOrComboBoxAppend(window: View, text: String)
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1751 {
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1752 waitOnUiThread {
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1753 if(window is DWComboBox) {
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1754 val combobox = window
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1755
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1756 combobox.list.add(text)
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1757 } else if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1758 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1759
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1760 listbox.list.add(text)
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1761 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1762 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1763 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1764
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1765 fun listOrComboBoxInsert(window: View, text: String, pos: Int)
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1766 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1767 waitOnUiThread {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1768 if(window is DWComboBox) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1769 val combobox = window
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1770
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1771 combobox.list.add(pos, text)
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1772 } else if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1773 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1774
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1775 listbox.list.add(pos, text)
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1776 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1777 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1778 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1779
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1780 fun listOrComboBoxClear(window: View)
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1781 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1782 waitOnUiThread {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1783 if(window is DWComboBox) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1784 val combobox = window
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1785
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1786 combobox.list.clear()
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1787 } else if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1788 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1789
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1790 listbox.list.clear()
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1791 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1792 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1793 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1794
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1795 fun listOrComboBoxCount(window: View): Int
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1796 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1797 var retval: Int = 0
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1798
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1799 waitOnUiThread {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1800 if(window is DWComboBox) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1801 val combobox = window
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1802
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1803 retval = combobox.list.count()
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1804 } else if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1805 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1806
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1807 retval = listbox.list.count()
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1808 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1809 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1810 return retval
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1811 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1812
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1813 fun listOrComboBoxSetText(window: View, index: Int, text: String)
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1814 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1815 waitOnUiThread {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1816 if(window is DWComboBox) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1817 val combobox = window
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1818
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1819 if(index > -1 && index < combobox.list.count())
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1820 combobox.list[index] = text
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1821 } else if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1822 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1823
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1824 if(index > -1 && index < listbox.list.count())
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1825 listbox.list[index] = text
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1826 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1827 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1828 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1829
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1830 fun listOrComboBoxGetText(window: View, index: Int): String?
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1831 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1832 var retval: String? = null
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1833
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1834 waitOnUiThread {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1835 if(window is DWComboBox) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1836 val combobox = window
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1837
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1838 if(index > -1 && index < combobox.list.count())
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1839 retval = combobox.list[index]
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1840 } else if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1841 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1842
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1843 if(index > -1 && index < listbox.list.count())
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1844 retval = listbox.list[index]
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1845 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1846 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1847 return retval
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1848 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1849
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1850 fun listOrComboBoxGetSelected(window: View): Int
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1851 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1852 var retval: Int = -1
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1853
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1854 waitOnUiThread {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1855 if(window is DWComboBox) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1856 val combobox = window
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1857
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1858 retval = combobox.selected
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1859 } else if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1860 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1861
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1862 retval = listbox.selected
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1863 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1864 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1865 return retval
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1866 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1867
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1868 fun listOrComboBoxSelect(window: View, index: Int, state: Int)
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1869 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1870 waitOnUiThread {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1871 if(window is DWComboBox) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1872 val combobox = window
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1873
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1874 if(index < combobox.list.count() && state != 0) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1875 combobox.selected = index
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1876 combobox.setText(combobox.list[index])
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1877 }
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1878 } else if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1879 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1880
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1881 if(index < listbox.list.count()) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1882 if(state != 0) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1883 listbox.selected = index
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1884 listbox.setItemChecked(index, true);
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1885 } else {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1886 listbox.setItemChecked(index, false);
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1887 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1888 }
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1889 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1890 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1891 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1892
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1893 fun listOrComboBoxDelete(window: View, index: Int)
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1894 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1895 waitOnUiThread {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1896 if(window is DWComboBox) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1897 val combobox = window
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1898
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1899 if(index < combobox.list.count()) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1900 combobox.list.removeAt(index)
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1901 }
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1902 } else if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1903 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1904
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1905 if(index < listbox.list.count()) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1906 listbox.list.removeAt(index)
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1907 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1908 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1909 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1910 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1911
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1912 fun listBoxSetTop(window: View, top: Int)
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1913 {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1914 waitOnUiThread {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1915 if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1916 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1917
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1918 if(top < listbox.list.count()) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1919 listbox.smoothScrollToPosition(top)
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
1920 }
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1921 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1922 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1923 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1924
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1925 fun listBoxSelectedMulti(window: View, where: Int): Int
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1926 {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1927 var retval: Int = -1
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1928
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1929 waitOnUiThread {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1930 if(window is DWListBox) {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1931 val listbox = window
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1932 val checked: SparseBooleanArray = listbox.getCheckedItemPositions()
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1933
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1934 // If we are starting over....
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1935 if(where == -1 && checked.size() > 0) {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1936 retval = checked.keyAt(0)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1937 } else {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1938 // Otherwise loop until we find our current place
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1939 for (i in 0 until checked.size()) {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1940 // Item position in adapter
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1941 val position: Int = checked.keyAt(i)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1942 // If we are at our current point... check to see
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1943 // if there is another one, and return it...
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1944 // otherwise we will return -1 to indicated we are done.
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1945 if (where == position && (i+1) < checked.size()) {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1946 retval = checked.keyAt(i+1)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1947 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1948 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1949 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1950 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1951 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1952 return retval
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1953 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1954
2523
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1955 fun calendarNew(cid: Int): CalendarView?
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1956 {
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1957 var calendar: CalendarView? = null
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1958
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1959 waitOnUiThread {
2528
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
1960 var dataArrayMap = SimpleArrayMap<String, Long>()
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
1961
2523
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1962 calendar = CalendarView(this)
2528
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
1963 calendar!!.tag = dataArrayMap
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
1964 calendar!!.id = cid
2524
d5c3c573c74e Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
1965 calendar!!.setOnDateChangeListener { calendar, year, month, day ->
d5c3c573c74e Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
1966 val c: Calendar = Calendar.getInstance();
d5c3c573c74e Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
1967 c.set(year, month, day);
d5c3c573c74e Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
1968 calendar.date = c.timeInMillis
d5c3c573c74e Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
1969 }
2523
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1970 }
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1971
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1972 return calendar
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1973 }
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1974
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1975 fun calendarSetDate(calendar: CalendarView, date: Long)
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1976 {
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1977 waitOnUiThread {
2524
d5c3c573c74e Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
1978 // Convert from seconds to milliseconds
d5c3c573c74e Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
1979 calendar.setDate(date * 1000, true, true)
2523
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1980 }
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1981 }
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1982
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1983 fun calendarGetDate(calendar: CalendarView): Long
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1984 {
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1985 var date: Long = 0
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1986
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1987 waitOnUiThread {
2524
d5c3c573c74e Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
1988 // Convert from milliseconds to seconds
d5c3c573c74e Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
1989 date = calendar.date / 1000
2523
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1990 }
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1991 return date
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1992 }
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
1993
2528
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
1994 fun bitmapNew(cid: Int): ImageView?
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
1995 {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
1996 var imageview: ImageView? = null
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
1997
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
1998 waitOnUiThread {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
1999 var dataArrayMap = SimpleArrayMap<String, Long>()
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2000
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2001 imageview = ImageView(this)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2002 imageview!!.tag = dataArrayMap
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2003 imageview!!.id = cid
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2004 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2005
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2006 return imageview
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2007 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2008
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2009 fun windowSetBitmap(window: View, resID: Int, filename: String?)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2010 {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2011 waitOnUiThread {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2012 if(resID != 0) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2013 if(window is ImageButton) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2014 val button = window
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2015
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2016 button.setImageResource(resID)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2017 } else if(window is ImageView) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2018 val imageview = window
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2019
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2020 imageview.setImageResource(resID)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2021 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2022 } else if(filename != null) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2023 // Try to load the image, and protect against exceptions
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2024 try {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2025 val f = File(filename)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2026 val b = BitmapFactory.decodeStream(FileInputStream(f))
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2027 if(window is ImageButton) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2028 val button = window
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2029
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2030 button.setImageBitmap(b)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2031 } else if(window is ImageView) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2032 val imageview = window
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2033
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2034 imageview.setImageBitmap(b)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2035 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2036 } catch (e: FileNotFoundException) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2037 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2038 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2039 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2040 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2041
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2042 fun windowSetBitmapFromData(window: View, resID: Int, data: ByteArray?, length: Int)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2043 {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2044 waitOnUiThread {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2045 if(resID != 0) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2046 if (window is ImageButton) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2047 val button = window
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2048
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2049 button.setImageResource(resID)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2050 } else if (window is ImageView) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2051 val imageview = window
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2052
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2053 imageview.setImageResource(resID)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2054 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2055 } else if(data != null) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2056 val b = BitmapFactory.decodeByteArray(data, 0, length)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2057
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2058 if (window is ImageButton) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2059 val button = window
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2060
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2061 button.setImageBitmap(b)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2062 } else if (window is ImageView) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2063 val imageview = window
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2064
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2065 imageview.setImageBitmap(b)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2066 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2067 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2068 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2069 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2070
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2071 fun iconNew(filename: String?, data: ByteArray?, length: Int, resID: Int): Drawable?
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2072 {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2073 var icon: Drawable? = null
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2074
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2075 waitOnUiThread {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2076 if(resID != 0) {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2077 icon = ResourcesCompat.getDrawable(resources, resID, null);
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2078 } else if(filename != null) {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2079 // Try to load the image, and protect against exceptions
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2080 try {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2081 icon = Drawable.createFromPath(filename)
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2082 } catch (e: FileNotFoundException) {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2083 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2084 } else if(data != null) {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2085 icon = BitmapDrawable(resources, BitmapFactory.decodeByteArray(data, 0, length))
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2086 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2087 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2088 return icon
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2089 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2090
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2091 fun pixmapNew(width: Int, height: Int, filename: String?, data: ByteArray?, length: Int, resID: Int): Bitmap?
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2092 {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2093 var pixmap: Bitmap? = null
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2094
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2095 waitOnUiThread {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2096 if(width > 0 && height > 0) {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2097 pixmap = Bitmap.createBitmap(null, width, height, Bitmap.Config.ARGB_8888)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2098 } else if(resID != 0) {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2099 pixmap = BitmapFactory.decodeResource(resources, resID);
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2100 } else if(filename != null) {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2101 // Try to load the image, and protect against exceptions
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2102 try {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2103 val f = File(filename)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2104 pixmap = BitmapFactory.decodeStream(FileInputStream(f))
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2105 } catch (e: FileNotFoundException) {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2106 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2107 } else if(data != null) {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2108 pixmap = BitmapFactory.decodeByteArray(data, 0, length)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2109 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2110 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2111 return pixmap
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2112 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2113
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2114 fun pixmapGetDimensions(pixmap: Bitmap): Long
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2115 {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2116 var dimensions: Long = 0
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2117
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2118 waitOnUiThread {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2119 dimensions = pixmap.width.toLong() or (pixmap.height.toLong() shl 32)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2120 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2121 return dimensions
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2122 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2123
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
2124 fun screenGetDimensions(): Long
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
2125 {
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
2126 val dm = resources.displayMetrics
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
2127 return dm.widthPixels.toLong() or (dm.heightPixels.toLong() shl 32)
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
2128 }
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
2129
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2130 fun renderNew(cid: Int): DWRender?
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2131 {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2132 var render: DWRender? = null
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2133
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2134 waitOnUiThread {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2135 var dataArrayMap = SimpleArrayMap<String, Long>()
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2136
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2137 render = DWRender(this)
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2138 render!!.tag = dataArrayMap
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2139 render!!.id = cid
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2140 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2141 return render
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2142 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2143
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2144 fun renderRedraw(render: DWRender)
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2145 {
2539
822f814a54f4 Android: Fix memory corruption issue due to incorrectly allocating HPIXMAP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2538
diff changeset
2146 runOnUiThread {
822f814a54f4 Android: Fix memory corruption issue due to incorrectly allocating HPIXMAP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2538
diff changeset
2147 render.invalidate()
822f814a54f4 Android: Fix memory corruption issue due to incorrectly allocating HPIXMAP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2538
diff changeset
2148 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2149 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2150
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2151 fun pixmapBitBlt(dstr: DWRender?, dstp: Bitmap?, dstx: Int, dsty: Int, dstw: Int, dsth: Int,
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2152 srcr: DWRender?, srcp: Bitmap?, srcy: Int, srcx: Int, srcw: Int, srch: Int): Int
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2153 {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2154 val dst = Rect(dstx, dsty, dstx + dstw, dsty + dsth)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2155 var src = Rect(srcx, srcy, srcx + srcw, srcy + srch)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2156 var retval: Int = 1
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2157
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2158 if(srcw == -1) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2159 src.right = srcx + dstw
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2160 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2161 if(srch == -1) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2162 src.bottom = srcy + dsth
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2163 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2164
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2165 waitOnUiThread {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2166 var canvas: Canvas? = null
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2167 var bitmap: Bitmap? = null
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2168
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2169 if(dstr != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2170 canvas = dstr.cachedCanvas
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2171 } else if(dstp != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2172 canvas = Canvas(dstp)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2173 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2174
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2175 if(srcp != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2176 bitmap = srcp
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2177 } else if(srcr != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2178 bitmap = Bitmap.createBitmap(srcr.layoutParams.width,
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2179 srcr.layoutParams.height, Bitmap.Config.ARGB_8888)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2180 val c = Canvas(bitmap)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2181 srcr.layout(srcr.left, srcr.top, srcr.right, srcr.bottom)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2182 srcr.draw(c)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2183 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2184
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2185 if(canvas != null && bitmap != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2186 canvas.drawBitmap(bitmap, src, dst, null)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2187 retval = 0
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2188 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2189 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2190 return retval
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2191 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2192
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2193 fun drawPoint(render: DWRender?, bitmap: Bitmap?, x: Int, y: Int)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2194 {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2195 waitOnUiThread {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2196 var canvas: Canvas? = null
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2197
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2198 if(render != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2199 canvas = render.cachedCanvas
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2200 } else if(bitmap != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2201 canvas = Canvas(bitmap)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2202 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2203
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2204 if(canvas != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2205 canvas.drawPoint(x.toFloat(), y.toFloat(), Paint())
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2206 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2207 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2208 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2209
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2210 fun drawLine(render: DWRender?, bitmap: Bitmap?, x1: Int, y1: Int, x2: Int, y2: Int)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2211 {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2212 waitOnUiThread {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2213 var canvas: Canvas? = null
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2214
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2215 if(render != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2216 canvas = render.cachedCanvas
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2217 } else if(bitmap != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2218 canvas = Canvas(bitmap)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2219 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2220
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2221 if(canvas != null) {
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2222 paint.flags = 0
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2223 paint.style = Paint.Style.STROKE
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2224 canvas.drawLine(x1.toFloat(), y1.toFloat(), x2.toFloat(), y2.toFloat(), paint)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2225 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2226 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2227 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2228
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2229 fun fontTextExtentsGet(render: DWRender?, bitmap: Bitmap?, text:String, typeface: Typeface?, fontsize: Int, window: View?): Long
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2230 {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2231 var dimensions: Long = 0
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2232
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2233 waitOnUiThread {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2234 var rect = Rect()
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2235
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2236 if (render != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2237 if (render.typeface != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2238 paint.typeface = render.typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2239 if (render.fontsize != null && render.fontsize!! > 0F) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2240 paint.textSize = render.fontsize!!
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2241 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2242 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2243 } else if (bitmap != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2244 if (typeface != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2245 paint.typeface = typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2246 if (fontsize > 0) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2247 paint.textSize = fontsize.toFloat()
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2248 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2249 } else if (window != null && window is DWRender) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2250 val secondary: DWRender = window as DWRender
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2251
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2252 if (secondary.typeface != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2253 paint.typeface = secondary.typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2254 if (secondary.fontsize != null && secondary.fontsize!! > 0F) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2255 paint.textSize = secondary.fontsize!!
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2256 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2257 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2258 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2259 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2260 paint.getTextBounds(text, 0, text.length, rect)
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2261 val textheight = rect.bottom - rect.top
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2262 val textwidth = rect.right - rect.left
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2263 dimensions = textwidth.toLong() or (textheight.toLong() shl 32)
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2264 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2265 return dimensions
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2266 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2267
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2268 fun drawText(render: DWRender?, bitmap: Bitmap?, x: Int, y: Int, text:String, typeface: Typeface?, fontsize: Int, window: View?)
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2269 {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2270 waitOnUiThread {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2271 var canvas: Canvas? = null
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2272
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2273 if(render != null && render.cachedCanvas != null) {
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2274 canvas = render.cachedCanvas
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2275 if(render.typeface != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2276 paint.typeface = render.typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2277 if(render.fontsize != null && render.fontsize!! > 0F) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2278 paint.textSize = render.fontsize!!
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2279 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2280 }
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2281 } else if(bitmap != null) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2282 canvas = Canvas(bitmap)
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2283 if(typeface != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2284 paint.typeface = typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2285 if(fontsize > 0) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2286 paint.textSize = fontsize.toFloat()
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2287 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2288 } else if(window != null && window is DWRender) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2289 val secondary: DWRender = window as DWRender
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2290
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2291 if(secondary.typeface != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2292 paint.typeface = secondary.typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2293 if(secondary.fontsize != null && secondary.fontsize!! > 0F) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2294 paint.textSize = secondary.fontsize!!
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2295 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2296 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2297 }
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2298 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2299
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2300 if(canvas != null) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2301 // Save the old color for later...
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2302 var rect = Rect()
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2303 val oldcolor = paint.color
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2304 // Prepare to draw the background rect
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2305 paint.color = bgcolor
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2306 paint.flags = 0
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2307 paint.style = Paint.Style.FILL_AND_STROKE
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2308 paint.textAlign = Paint.Align.LEFT
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2309 paint.getTextBounds(text, 0, text.length, rect)
2538
1b3b40c89cd0 Android: Move the text to below the point, not above it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2537
diff changeset
2310 val textheight = rect.bottom - rect.top
1b3b40c89cd0 Android: Move the text to below the point, not above it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2537
diff changeset
2311 rect.top += y + textheight
1b3b40c89cd0 Android: Move the text to below the point, not above it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2537
diff changeset
2312 rect.bottom += y + textheight
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2313 rect.left += x
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2314 rect.right += x
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2315 canvas.drawRect(rect, paint)
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2316 // Restore the color and prepare to draw text
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2317 paint.color = oldcolor
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2318 paint.style = Paint.Style.STROKE
2538
1b3b40c89cd0 Android: Move the text to below the point, not above it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2537
diff changeset
2319 canvas.drawText(text, x.toFloat(), y.toFloat() + textheight.toFloat(), paint)
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2320 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2321 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2322 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2323
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2324 fun drawRect(render: DWRender?, bitmap: Bitmap?, x: Int, y: Int, width: Int, height: Int)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2325 {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2326 waitOnUiThread {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2327 var canvas: Canvas? = null
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2328
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2329 if(render != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2330 canvas = render.cachedCanvas
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2331 } else if(bitmap != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2332 canvas = Canvas(bitmap)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2333 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2334
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2335 if(canvas != null) {
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2336 paint.flags = 0
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2337 paint.style = Paint.Style.FILL_AND_STROKE
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2338 canvas.drawRect(x.toFloat(), y.toFloat(), x.toFloat() + width.toFloat(), y.toFloat() + height.toFloat(), paint)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2339 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2340 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2341 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2342
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2343 fun drawPolygon(render: DWRender?, bitmap: Bitmap?, flags: Int, npoints: Int, x: IntArray, y: IntArray)
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2344 {
2537
cd9d2ba251d5 Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2536
diff changeset
2345 // Create a path with all our points
cd9d2ba251d5 Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2536
diff changeset
2346 val path = Path()
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2347
2537
cd9d2ba251d5 Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2536
diff changeset
2348 path.moveTo(x[0].toFloat(), y[0].toFloat())
cd9d2ba251d5 Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2536
diff changeset
2349 for (i in 1 until npoints) {
cd9d2ba251d5 Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2536
diff changeset
2350 path.lineTo(x[i].toFloat(), y[i].toFloat())
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2351 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2352
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2353 waitOnUiThread {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2354 var canvas: Canvas? = null
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2355
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2356 if(render != null) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2357 canvas = render.cachedCanvas
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2358 } else if(bitmap != null) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2359 canvas = Canvas(bitmap)
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2360 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2361
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2362 if(canvas != null) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2363 // Handle the DW_DRAW_NOAA flag
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2364 if((flags and (1 shl 2)) == 0) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2365 paint.flags = Paint.ANTI_ALIAS_FLAG
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2366 } else {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2367 paint.flags = 0
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2368 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2369 // Handle the DW_DRAW_FILL flag
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2370 if((flags and 1) == 1) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2371 paint.style = Paint.Style.FILL_AND_STROKE
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2372 } else {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2373 paint.style = Paint.Style.STROKE
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2374 }
2537
cd9d2ba251d5 Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2536
diff changeset
2375 canvas.drawPath(path, paint)
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2376 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2377 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2378 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2379
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2380 fun drawArc(render: DWRender?, bitmap: Bitmap?, flags: Int, xorigin: Int, yorigin: Int,
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2381 x1: Int, y1: Int, x2: Int, y2: Int)
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2382 {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2383 waitOnUiThread {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2384 var canvas: Canvas? = null
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2385
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2386 if(render != null) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2387 canvas = render.cachedCanvas
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2388 } else if(bitmap != null) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2389 canvas = Canvas(bitmap)
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2390 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2391
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2392 if(canvas != null) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2393 var a1: Double = Math.atan2((y1 - yorigin).toDouble(), (x1 - xorigin).toDouble())
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2394 var a2: Double = Math.atan2((y2 - yorigin).toDouble(), (x2 - xorigin).toDouble())
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2395 val dx = (xorigin - x1).toDouble()
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2396 val dy = (yorigin - y1).toDouble()
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2397 val r: Double = Math.sqrt(dx * dx + dy * dy)
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2398 val left = (xorigin-r).toFloat()
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2399 val top = (yorigin-r).toFloat()
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2400 val rect = RectF(left, top, (left + (r*2)).toFloat(), (top + (r*2)).toFloat())
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2401
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2402 /* Convert to degrees */
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2403 a1 *= 180.0 / Math.PI
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2404 a2 *= 180.0 / Math.PI
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2405 val sweep = Math.abs(a1 - a2)
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2406
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2407 // Handle the DW_DRAW_NOAA flag
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2408 if((flags and (1 shl 2)) == 0) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2409 paint.flags = Paint.ANTI_ALIAS_FLAG
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2410 } else {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2411 paint.flags = 0
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2412 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2413 // Handle the DW_DRAW_FILL flag
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2414 if((flags and 1) == 1) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2415 paint.style = Paint.Style.FILL_AND_STROKE
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2416 } else {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2417 paint.style = Paint.Style.STROKE
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2418 }
2536
d172ab2eddb6 Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2535
diff changeset
2419 // Handle the DW_DRAW_FULL flag
d172ab2eddb6 Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2535
diff changeset
2420 if((flags and (1 shl 1)) != 0) {
d172ab2eddb6 Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2535
diff changeset
2421 canvas.drawOval(rect, paint)
d172ab2eddb6 Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2535
diff changeset
2422 } else {
d172ab2eddb6 Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2535
diff changeset
2423 canvas.drawArc(rect, a1.toFloat(), sweep.toFloat(), false, paint)
d172ab2eddb6 Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2535
diff changeset
2424 }
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2425 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2426 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2427 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2428
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2429 fun colorSet(alpha: Int, red: Int, green: Int, blue: Int)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2430 {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2431 waitOnUiThread {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2432 if(alpha != 0) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2433 paint.color = Color.argb(alpha, red, green, blue)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2434 } else {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2435 paint.color = Color.rgb(red, green, blue)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2436 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2437 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2438 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2439
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2440 fun bgColorSet(alpha: Int, red: Int, green: Int, blue: Int)
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2441 {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2442 if(alpha != 0) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2443 this.bgcolor = Color.argb(alpha, red, green, blue)
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2444 } else {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2445 this.bgcolor = Color.rgb(red, green, blue)
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2446 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2447 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2448
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2449 fun timerConnect(interval: Long, sigfunc: Long, data: Long): Timer
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2450 {
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2451 // creating timer task, timer
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2452 val t = Timer()
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2453 val tt: TimerTask = object : TimerTask() {
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2454 override fun run() {
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2455 if(eventHandlerTimer(sigfunc, data) == 0) {
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2456 t.cancel()
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2457 }
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2458 }
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2459 }
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2460 t.scheduleAtFixedRate(tt, interval, interval)
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2461 return t
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2462 }
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2463
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2464 fun timerDisconnect(timer: Timer)
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2465 {
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2466 timer.cancel()
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2467 }
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2468
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2469 fun doBeep(duration: Int)
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2470 {
2491
bf4fe6bb512b Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
2471 val toneGen = ToneGenerator(AudioManager.STREAM_ALARM, 100)
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2472 toneGen.startTone(ToneGenerator.TONE_CDMA_PIP, duration)
2491
bf4fe6bb512b Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
2473 val handler = Handler(Looper.getMainLooper())
bf4fe6bb512b Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
2474 handler.postDelayed({
bf4fe6bb512b Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
2475 toneGen.release()
bf4fe6bb512b Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
2476 }, (duration + 50).toLong())
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
2477 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
2478
2482
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
2479 fun debugMessage(text: String)
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
2480 {
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
2481 Log.d(null, text)
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
2482 }
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
2483
2526
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2484 fun fileBrowse(title: String, defpath: String?, ext: String?, flags: Int): String?
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2485 {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2486 var retval: String? = null
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2487
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2488 waitOnUiThread {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2489 val fc = DWFileChooser(this)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2490 fc.setFileListener(object: DWFileChooser.FileSelectedListener {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2491 override fun fileSelected(file: File?) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2492 // do something with the file
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2493 retval = file!!.absolutePath
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2494 throw java.lang.RuntimeException()
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2495 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2496 })
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2497 if(ext != null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2498 fc.setExtension(ext)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2499 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2500 fc.showDialog()
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2501 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2502
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2503 // loop till a runtime exception is triggered.
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2504 try {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2505 Looper.loop()
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2506 } catch (e2: RuntimeException) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2507 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2508
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2509 return retval
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2510 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
2511
2486
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
2512 fun messageBox(title: String, body: String, flags: Int): Int
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
2513 {
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
2514 var retval: Int = 0
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
2515
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2516 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2517 // make a text input dialog and show it
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2518 var alert = AlertDialog.Builder(this)
2486
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
2519
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2520 alert.setTitle(title)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2521 alert.setMessage(body)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2522 if ((flags and (1 shl 3)) != 0) {
2516
8f5d064b7054 Android: Fix the down arrow on the comboboxes, found a system resource that works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2523 alert.setPositiveButton("Yes",
8f5d064b7054 Android: Fix the down arrow on the comboboxes, found a system resource that works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2524 //android.R.string.yes,
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2525 DialogInterface.OnClickListener { _: DialogInterface, _: Int ->
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2526 retval = 1
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2527 throw java.lang.RuntimeException()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2528 });
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2529 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2530 if ((flags and ((1 shl 1) or (1 shl 2))) != 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2531 alert.setNegativeButton(
2516
8f5d064b7054 Android: Fix the down arrow on the comboboxes, found a system resource that works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2532 android.R.string.ok,
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2533 DialogInterface.OnClickListener { _: DialogInterface, _: Int ->
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2534 retval = 0
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2535 throw java.lang.RuntimeException()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2536 });
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2537 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2538 if ((flags and ((1 shl 3) or (1 shl 4))) != 0) {
2516
8f5d064b7054 Android: Fix the down arrow on the comboboxes, found a system resource that works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2539 alert.setNegativeButton("No",
8f5d064b7054 Android: Fix the down arrow on the comboboxes, found a system resource that works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2540 //android.R.string.no,
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2541 DialogInterface.OnClickListener { _: DialogInterface, _: Int ->
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2542 retval = 0
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2543 throw java.lang.RuntimeException()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2544 });
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2545 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2546 if ((flags and ((1 shl 2) or (1 shl 4))) != 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2547 alert.setNeutralButton(
2516
8f5d064b7054 Android: Fix the down arrow on the comboboxes, found a system resource that works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2548 android.R.string.cancel,
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2549 DialogInterface.OnClickListener { _: DialogInterface, _: Int ->
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2550 retval = 2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2551 throw java.lang.RuntimeException()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2552 });
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2553 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2554 alert.show();
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2555
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2556 // loop till a runtime exception is triggered.
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2557 try {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2558 Looper.loop()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2559 } catch (e2: RuntimeException) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2560 }
2486
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
2561 }
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
2562 return retval
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
2563 }
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
2564
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2565 fun isUIThread(): Boolean
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2566 {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2567 if(Looper.getMainLooper() == Looper.myLooper()) {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2568 return true
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2569 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2570 return false
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2571 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2572
2514
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2573 fun mainSleep(milliseconds: Int)
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2574 {
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2575 // If we are on the main UI thread... add an idle handler
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2576 // Then loop until we throw an exception when the time expires
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2577 // in the idle handler, if we are already thrown... remove the handler
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2578 if(Looper.getMainLooper() == Looper.myLooper()) {
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2579 val starttime = System.currentTimeMillis()
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2580
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2581 // Waiting for Idle to make sure Toast gets rendered.
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2582 Looper.myQueue().addIdleHandler(object : MessageQueue.IdleHandler {
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2583 var thrown: Boolean = false
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2584
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2585 override fun queueIdle(): Boolean {
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2586 if(System.currentTimeMillis() - starttime >= milliseconds) {
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2587 if (thrown == false) {
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2588 thrown = true
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2589 throw java.lang.RuntimeException()
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2590 }
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2591 return false
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2592 }
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2593 return true
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2594 }
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2595 })
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2596
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2597 // loop till a runtime exception is triggered.
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2598 try {
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2599 Looper.loop()
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2600 } catch (e2: RuntimeException) {
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2601 }
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2602 }
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2603 else
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2604 {
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2605 // If we are in a different thread just sleep
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2606 Thread.sleep(milliseconds.toLong())
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2607 }
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2608 }
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
2609
2487
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
2610 fun dwindowsExit(exitcode: Int)
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
2611 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2612 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2613 this.finishAffinity()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2614 System.exit(exitcode)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2615 }
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
2616 }
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
2617
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
2618 fun dwindowsShutdown()
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
2619 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2620 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2621 this.finishAffinity()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
2622 }
2487
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
2623 }
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
2624
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
2625 fun dwInit(appid: String, appname: String): Int
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2626 {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2627 waitOnUiThread {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2628 // Create the notification channel in dw_init()
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2629 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2630 // Create the NotificationChannel
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2631 val importance = NotificationManager.IMPORTANCE_DEFAULT
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2632 val mChannel = NotificationChannel(appid, appname, importance)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2633 // Register the channel with the system; you can't change the importance
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2634 // or other notification behaviors after this
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2635 val notificationManager =
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2636 getSystemService(NOTIFICATION_SERVICE) as NotificationManager
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2637 notificationManager.createNotificationChannel(mChannel)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2638 }
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2639 }
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
2640 return Build.VERSION.SDK_INT
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
2641 }
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
2642
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
2643 fun dwMain()
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
2644 {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
2645 runOnUiThread {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
2646 // Trigger the options menu to update when dw_main() is called
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
2647 invalidateOptionsMenu()
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
2648 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
2649 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
2650
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
2651 fun androidGetRelease(): String
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
2652 {
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
2653 return Build.VERSION.RELEASE
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2654 }
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2655
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2656 fun notificationNew(title: String, imagepath: String, text: String, appid: String): NotificationCompat.Builder?
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2657 {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2658 var builder: NotificationCompat.Builder? = null
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2659
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2660 waitOnUiThread {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2661 builder = NotificationCompat.Builder(this, appid)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2662 .setContentTitle(title)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2663 .setContentText(text)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2664 .setPriority(NotificationCompat.PRIORITY_DEFAULT)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2665 }
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2666 return builder
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2667 }
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2668
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2669 fun notificationSend(builder: NotificationCompat.Builder)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2670 {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2671 waitOnUiThread {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2672 notificationID += 1
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2673 with(NotificationManagerCompat.from(this)) {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2674 // notificationId is a unique int for each notification that you must define
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2675 notify(notificationID, builder.build())
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2676 }
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2677 }
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2678 }
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2679
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
2680 /*
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
2681 * Native methods that are implemented by the 'dwindows' native library,
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2682 * which is packaged with this application.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2683 */
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
2684 external fun dwindowsInit(dataDir: String, appid: String)
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
2685 external fun eventHandler(
2499
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
2686 obj1: View?,
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
2687 obj2: View?,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
2688 message: Int,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
2689 str1: String?,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
2690 str2: String?,
2499
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
2691 inta: Int,
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
2692 intb: Int,
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
2693 intc: Int,
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
2694 intd: Int
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
2695 ): Int
2499
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
2696 external fun eventHandlerInt(
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
2697 obj1: View,
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
2698 message: Int,
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
2699 inta: Int,
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
2700 intb: Int,
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
2701 intc: Int,
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
2702 intd: Int
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
2703 )
2483
9f7af6d8c6a4 Android: Fix signal handlers so they actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2482
diff changeset
2704 external fun eventHandlerSimple(obj1: View, message: Int)
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
2705 external fun eventHandlerNotebook(obj1: View, message: Int, pageID: Long)
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
2706 external fun eventHandlerTimer(sigfunc: Long, data: Long): Int
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
2707 external fun eventHandlerHTMLResult(obj1: View, message: Int, result: String, data: Long)
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2708
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
2709 companion object
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
2710 {
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2711 // Used to load the 'dwindows' library on application startup.
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
2712 init
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
2713 {
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2714 System.loadLibrary("dwindows")
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2715 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2716 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2717 }