Mercurial > dwindows
annotate android/DWindows.kt @ 2530:b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
Return nullptr instead of 0 on any functions using jobject.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 10 May 2021 22:34:52 +0000 |
parents | 060fdb2d807d |
children | f45ebd96ebe5 |
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 |
2505
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
14 import android.graphics.Bitmap |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
15 import android.graphics.BitmapFactory |
2530
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.Canvas |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
17 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
|
18 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
|
19 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
|
20 import android.media.AudioManager |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
21 import android.media.ToneGenerator |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
22 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
|
23 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
|
24 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
|
25 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
|
26 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
|
27 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
|
28 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
|
29 import android.util.SparseBooleanArray |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
30 import android.view.Gravity |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
31 import android.view.MotionEvent |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
32 import android.view.View |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
33 import android.view.View.OnTouchListener |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
34 import android.view.ViewGroup |
2510
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
35 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
|
36 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
|
37 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
|
38 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
|
39 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
|
40 import android.widget.SeekBar.OnSeekBarChangeListener |
2486
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
41 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
|
42 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
|
43 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
|
44 import androidx.collection.SimpleArrayMap |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
45 import androidx.core.app.NotificationCompat |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
46 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
|
47 import androidx.core.content.res.ResourcesCompat |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
48 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
|
49 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
|
50 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
|
51 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
|
52 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
|
53 import java.io.File |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
54 import java.io.FileInputStream |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
55 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
|
56 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
|
57 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
|
58 |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
59 |
2495
5664c91d03fb
Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2494
diff
changeset
|
60 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
|
61 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
|
62 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
|
63 var currentPageID = 0L |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
64 |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
65 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
|
66 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
|
67 |
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
|
68 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
|
69 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
|
70 return position |
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
71 } |
2495
5664c91d03fb
Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2494
diff
changeset
|
72 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
|
73 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
|
74 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
75 |
2498
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
76 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
|
77 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
78 |
2505
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
79 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
|
80 //Implement shouldOverrideUrlLoading// |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
81 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
|
82 // 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
|
83 // 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
|
84 return false |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
85 } |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
86 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
|
87 // 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
|
88 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
|
89 } |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
90 |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
91 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
|
92 // 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
|
93 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
|
94 } |
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 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
|
97 } |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
98 |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
99 class DWSpinButton(context: Context) : AppCompatEditText(context), OnTouchListener { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
100 var value: Long = 0 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
101 var minimum: Long = 0 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
102 var maximum: Long = 65535 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
103 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
104 init { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
105 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
|
106 setOnTouchListener(this) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
107 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
108 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
109 override fun onTouch(v: View, event: MotionEvent): Boolean { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
110 val DRAWABLE_RIGHT = 2 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
111 val DRAWABLE_LEFT = 0 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
112 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
113 if (event.action == MotionEvent.ACTION_UP) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
114 if (event.x >= v.width - (v as EditText) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
115 .compoundDrawables[DRAWABLE_RIGHT].bounds.width() |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
116 ) { |
2527
eec926265888
Android: Use toLongOrNull() whenever converting from string to long...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2526
diff
changeset
|
117 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
|
118 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
119 if(newvalue != null) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
120 value = newvalue + 1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
121 } else { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
122 value += 1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
123 } |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
124 if(value > maximum) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
125 value = maximum |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
126 } |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
127 if(value < minimum) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
128 value = minimum |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
129 } |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
130 setText(value.toString()) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
131 eventHandlerInt(14, value.toInt(), 0, 0, 0) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
132 return true |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
133 } else if (event.x <= (v as EditText) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
134 .compoundDrawables[DRAWABLE_LEFT].bounds.width() |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
135 ) { |
2527
eec926265888
Android: Use toLongOrNull() whenever converting from string to long...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2526
diff
changeset
|
136 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
|
137 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
138 if(newvalue != null) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
139 value = newvalue - 1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
140 } else { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
141 value -= 1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
142 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
143 if(value > maximum) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
144 value = maximum |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
145 } |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
146 if(value < minimum) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
147 value = minimum |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
148 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
149 setText(value.toString()) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
150 eventHandlerInt(14, value.toInt(), 0, 0, 0) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
151 return true |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
152 } |
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 return false |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
155 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
156 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
157 external fun eventHandlerInt( |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
158 message: Int, |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
159 inta: Int, |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
160 intb: Int, |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
161 intc: Int, |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
162 intd: Int |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
163 ) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
164 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
165 |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
166 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
|
167 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
|
168 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
|
169 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
|
170 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
171 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
|
172 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
|
173 setOnTouchListener(this) |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
174 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
|
175 lpw!!.setAdapter( |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
176 ArrayAdapter( |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
177 context, |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
178 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
|
179 ) |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
180 ) |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
181 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
|
182 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
|
183 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
|
184 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
185 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
186 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
|
187 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
|
188 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
|
189 setText(item) |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
190 lpw!!.dismiss() |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
191 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
|
192 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
193 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
194 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
|
195 val DRAWABLE_RIGHT = 2 |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
196 |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
197 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
|
198 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
|
199 .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
|
200 ) { |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
201 lpw!!.show() |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
202 return true |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
203 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
204 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
205 return false |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
206 } |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
207 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
208 external fun eventHandlerInt( |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
209 message: Int, |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
210 inta: Int, |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
211 intb: Int, |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
212 intc: Int, |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
213 intd: Int |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
214 ) |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
215 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
216 |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
217 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
|
218 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
|
219 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
|
220 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
221 init { |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
222 setAdapter( |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
223 ArrayAdapter( |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
224 context, |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
225 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
|
226 ) |
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 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
|
229 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
230 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
231 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
|
232 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
|
233 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
|
234 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
235 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
236 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
|
237 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
|
238 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
|
239 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
|
240 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
|
241 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
|
242 ) |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
243 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
244 |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
245 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
|
246 var cachedCanvas: Canvas? = null |
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 |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
402 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
|
403 var firstWindow: Boolean = true |
2499
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
404 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
|
405 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
|
406 var threadCond = threadLock.newCondition() |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
407 var notificationID: Int = 0 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
408 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
409 // 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
|
410 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
|
411 { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
412 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
|
413 runnable.run() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
414 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
415 threadLock.lock() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
416 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
|
417 threadLock.lock() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
418 runnable.run() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
419 threadCond.signal() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
420 threadLock.unlock() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
421 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
422 runOnUiThread(ourRunnable) |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
423 threadCond.await() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
424 threadLock.unlock() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
425 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
426 } |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
427 |
2498
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
428 // 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
|
429 // 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
|
430 // 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
|
431 // 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
|
432 // 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
|
433 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
|
434 super.onCreate(savedInstanceState) |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
435 |
2480
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
436 // Turn on rotation |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
437 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
|
438 |
2498
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
439 // 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
|
440 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
|
441 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
|
442 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
|
443 s = p.applicationInfo.dataDir |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
444 |
2498
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
445 // 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
|
446 // 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
|
447 dwindowsInit(s, this.getPackageName()) |
2496
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
448 } |
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
449 |
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
450 override fun onConfigurationChanged(newConfig: Configuration) { |
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
451 super.onConfigurationChanged(newConfig) |
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
452 |
2499
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
453 // 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
|
454 if(windowLayout != null) { |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
455 var width: Int = windowLayout!!.width |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
456 var height: Int = windowLayout!!.height |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
457 |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
458 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
|
459 } |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
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 |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
462 /* |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
463 * 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
|
464 * 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
|
465 */ |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
466 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
|
467 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
|
468 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
469 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
|
470 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
|
471 |
2503
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
472 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
|
473 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
|
474 setContentView(windowLayout) |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
475 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
|
476 // 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
|
477 // 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
|
478 firstWindow = false |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
479 } |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
480 return windowLayout |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
481 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
482 return null |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
483 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
484 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
485 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
|
486 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
|
487 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
488 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
489 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
|
490 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
|
491 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
|
492 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
493 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
|
494 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
|
495 } else { |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
496 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
|
497 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
498 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
499 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
500 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
501 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
|
502 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
|
503 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
504 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
|
505 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
|
506 |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
507 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
|
508 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
509 return retval |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
510 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
511 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
512 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
|
513 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
514 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
|
515 } |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
516 } |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
517 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
518 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
|
519 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
520 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
|
521 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
|
522 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
|
523 } 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
|
524 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
|
525 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
|
526 } 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
|
527 // 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
|
528 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
|
529 } |
2489
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
530 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
531 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
532 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
533 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
|
534 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
|
535 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
536 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
537 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
|
538 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
|
539 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
|
540 } 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
|
541 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
|
542 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
|
543 } 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
|
544 // 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
|
545 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
|
546 } |
2489
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
547 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
548 return text |
2489
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
549 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
550 |
2503
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
551 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
|
552 { |
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
553 waitOnUiThread { |
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
554 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
|
555 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
|
556 } else { |
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
557 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
|
558 } |
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
559 } |
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
560 } |
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
561 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
562 fun clipboardGetText(): String { |
2489
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
563 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
|
564 var clipdata = cm.primaryClip |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
565 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
566 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
|
567 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
|
568 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
569 return "" |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
570 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
571 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
572 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
|
573 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
|
574 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
|
575 |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
576 cm.setPrimaryClip(clipdata) |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
577 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
578 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
579 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
|
580 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
|
581 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
582 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
|
583 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
|
584 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
585 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
|
586 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
|
587 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
|
588 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
|
589 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
|
590 ) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
591 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
|
592 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
|
593 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
594 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
|
595 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
596 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
|
597 } |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
598 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
|
599 } |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
600 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
601 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
|
602 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
|
603 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
604 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
605 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
|
606 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
|
607 var dataArrayMap = SimpleArrayMap<String, Long>() |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
608 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
609 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
|
610 box.layoutParams = |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
611 LinearLayout.LayoutParams( |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
612 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
|
613 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
|
614 ) |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
615 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
|
616 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
|
617 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
618 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
|
619 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
620 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
|
621 // 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
|
622 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
|
623 scrollBox!!.addView(box) |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
624 } |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
625 return scrollBox |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
626 } |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
627 |
2495
5664c91d03fb
Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2494
diff
changeset
|
628 fun boxPack( |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
629 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
|
630 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
|
631 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
|
632 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
|
633 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
|
634 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
|
635 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
|
636 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
|
637 ) { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
638 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
639 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
|
640 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
|
641 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
|
642 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
643 // 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
|
644 // 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
|
645 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
|
646 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
|
647 } 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
|
648 var sv: ScrollView = boxview |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
649 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
650 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
|
651 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
|
652 } |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
653 } |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
654 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
655 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
|
656 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
|
657 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
|
658 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
|
659 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
|
660 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
661 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
662 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
|
663 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
|
664 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
665 } |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
666 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
667 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
|
668 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
669 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
|
670 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
|
671 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
|
672 w = width |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
673 } 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
|
674 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
|
675 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
676 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
|
677 h = height |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
678 } 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
|
679 h = item.getMeasuredHeight() |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
680 } |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
681 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
682 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
|
683 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
|
684 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
|
685 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
|
686 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
687 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
|
688 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
689 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
690 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
691 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
|
692 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
|
693 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
|
694 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
695 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
|
696 } |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
697 } |
2480
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
698 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
699 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
|
700 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
|
701 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
702 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
|
703 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
|
704 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
|
705 } 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
|
706 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
|
707 } 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
|
708 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
|
709 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
710 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
|
711 box.addView(item, index) |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
712 } |
2478
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
713 } |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
714 } |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
715 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
716 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
|
717 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
718 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
|
719 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
|
720 } |
2477
3fbf8783122d
Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2476
diff
changeset
|
721 } |
3fbf8783122d
Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2476
diff
changeset
|
722 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
723 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
|
724 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
|
725 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
726 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
727 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
|
728 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
729 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
|
730 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
731 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
|
732 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
733 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
734 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
|
735 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
|
736 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
737 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
|
738 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
|
739 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
740 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
|
741 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
|
742 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
|
743 button!!.setOnClickListener { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
744 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
|
745 } |
2482
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
746 } |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
747 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
|
748 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
749 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
750 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
|
751 var button: ImageButton? = null |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
752 waitOnUiThread { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
753 button = ImageButton(this) |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
754 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
|
755 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
756 button!!.tag = dataArrayMap |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
757 button!!.id = resid |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
758 button!!.setImageResource(resid) |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
759 button!!.setOnClickListener { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
760 eventHandlerSimple(button!!, 8) |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
761 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
762 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
763 return button |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
764 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
765 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
766 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
|
767 var button: ImageButton? = null |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
768 waitOnUiThread { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
769 button = ImageButton(this) |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
770 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
|
771 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
772 button!!.tag = dataArrayMap |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
773 button!!.id = cid |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
774 button!!.setOnClickListener { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
775 eventHandlerSimple(button!!, 8) |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
776 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
777 // 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
|
778 try { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
779 val f = File(filename) |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
780 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
|
781 button!!.setImageBitmap(b) |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
782 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
783 catch (e: FileNotFoundException) |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
784 { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
785 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
786 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
787 return button |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
788 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
789 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
790 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
|
791 var button: ImageButton? = null |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
792 waitOnUiThread { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
793 button = ImageButton(this) |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
794 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
|
795 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
|
796 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
797 button!!.tag = dataArrayMap |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
798 button!!.id = cid |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
799 button!!.setOnClickListener { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
800 eventHandlerSimple(button!!, 8) |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
801 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
802 button!!.setImageBitmap(b) |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
803 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
804 return button |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
805 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
806 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
807 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
|
808 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
|
809 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
810 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
811 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
|
812 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
|
813 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
814 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
|
815 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
|
816 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
|
817 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
|
818 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
819 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
|
820 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
821 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
|
822 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
823 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
824 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
|
825 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
826 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
|
827 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
828 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
829 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
830 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
|
831 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
|
832 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
833 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
834 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
|
835 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
|
836 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
837 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
|
838 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
|
839 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
|
840 radiobutton!!.setOnClickListener { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
841 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
|
842 } |
2482
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
843 } |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
844 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
|
845 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
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 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
|
848 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
|
849 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
850 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
851 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
|
852 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
853 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
|
854 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
|
855 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
|
856 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
|
857 checkbox!!.setOnClickListener { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
858 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
|
859 } |
2482
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
860 } |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
861 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
|
862 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
863 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
864 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
|
865 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
866 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
867 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
|
868 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
|
869 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
|
870 } 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
|
871 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
|
872 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
|
873 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
874 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
875 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
876 |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
877 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
|
878 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
879 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
|
880 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
881 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
882 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
|
883 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
|
884 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
|
885 } 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
|
886 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
|
887 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
|
888 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
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 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
|
891 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
892 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
893 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
|
894 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
|
895 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
896 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
897 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
|
898 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
899 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
|
900 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
|
901 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
|
902 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
|
903 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
|
904 val border = GradientDrawable() |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
905 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
906 // 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
|
907 // 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
|
908 // 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
|
909 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
|
910 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
|
911 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
|
912 } |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
913 } |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
914 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
|
915 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
916 |
2510
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
917 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
|
918 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
919 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
|
920 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
921 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
922 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
|
923 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
924 mle = EditText(this) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
925 mle!!.tag = dataArrayMap |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
926 mle!!.id = cid |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
927 mle!!.isSingleLine = false |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
928 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
|
929 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
|
930 mle!!.isVerticalScrollBarEnabled = true |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
931 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
|
932 mle!!.setHorizontallyScrolling(true) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
933 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
934 return mle |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
935 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
936 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
937 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
|
938 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
939 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
940 if (state != 0) { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
941 mle.setHorizontallyScrolling(false) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
942 } else { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
943 mle.setHorizontallyScrolling(true) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
944 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
945 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
946 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
947 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
948 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
|
949 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
950 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
951 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
|
952 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
|
953 } else { |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
954 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
|
955 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
956 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
957 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
958 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
959 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
|
960 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
961 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
962 mle.setSelection(point) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
963 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
964 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
965 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
966 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
|
967 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
968 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
969 mle.setText("") |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
970 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
971 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
972 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
973 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
|
974 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
975 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
|
976 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
977 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
978 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
|
979 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
|
980 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
981 if(startpoint < 1) { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
982 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
|
983 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
984 mle.setText(newtext) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
985 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
|
986 } 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
|
987 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
|
988 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
989 mle.setText(newtext) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
990 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
|
991 } else { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
992 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
|
993 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
994 mle.setText(newtext) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
995 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
|
996 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
997 mle.setSelection(retval) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
998 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
999 return retval |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
1000 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
1001 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
1002 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
|
1003 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
1004 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
1005 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
|
1006 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
|
1007 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
1008 mle.setText(newtext) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
1009 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
1010 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
1011 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1012 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
|
1013 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1014 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
|
1015 |
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 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
|
1018 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
|
1019 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
|
1020 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
|
1021 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
|
1022 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1023 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
|
1024 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
|
1025 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
|
1026 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
|
1027 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
|
1028 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
|
1029 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
|
1030 // 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
|
1031 }.attach() |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
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 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
|
1034 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
|
1035 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
|
1036 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1037 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
|
1038 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1039 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
|
1040 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
|
1041 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
|
1042 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
|
1043 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
|
1044 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
|
1045 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1046 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
|
1047 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1048 notebook!!.addView(pager, params) |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1049 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
|
1050 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
|
1051 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
|
1052 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1053 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
|
1054 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
|
1055 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1056 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1057 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
|
1058 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
|
1059 }) |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1060 } |
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
|
1061 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
|
1062 } |
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
|
1063 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
1064 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
|
1065 { |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
1066 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
|
1067 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1068 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1069 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
|
1070 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
|
1071 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1072 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
|
1073 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
|
1074 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
|
1075 } 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
|
1076 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
|
1077 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
|
1078 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1079 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1080 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
|
1081 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
|
1082 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
|
1083 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1084 // 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
|
1085 do { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1086 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
|
1087 } 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
|
1088 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
|
1089 // 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
|
1090 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
|
1091 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
|
1092 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
|
1093 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
|
1094 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1095 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
|
1096 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
|
1097 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
|
1098 } |
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
|
1099 } |
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
|
1100 } |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
1101 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
|
1102 } |
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
|
1103 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
1104 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
|
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 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1107 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
|
1108 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
|
1109 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1110 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
|
1111 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
|
1112 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
|
1113 } 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
|
1114 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
|
1115 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
|
1116 } |
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
|
1117 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1118 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
|
1119 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
|
1120 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
|
1121 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
|
1122 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1123 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
|
1124 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
|
1125 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
|
1126 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
|
1127 } |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
1128 } |
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
|
1129 } |
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
|
1130 } |
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
|
1131 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
1132 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
|
1133 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1134 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1135 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
|
1136 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
|
1137 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1138 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
|
1139 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
|
1140 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
|
1141 } 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
|
1142 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
|
1143 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
|
1144 } |
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
|
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 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
|
1147 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
|
1148 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
|
1149 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
|
1150 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1151 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
|
1152 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
|
1153 } |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
1154 } |
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
|
1155 } |
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
|
1156 } |
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
|
1157 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
1158 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
|
1159 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1160 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1161 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
|
1162 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
|
1163 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1164 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
|
1165 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
|
1166 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
|
1167 } 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
|
1168 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
|
1169 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
|
1170 } |
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
|
1171 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1172 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
|
1173 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
|
1174 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
|
1175 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1176 // 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
|
1177 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
|
1178 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
|
1179 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
|
1180 ); |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
1181 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1182 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
|
1183 } |
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
|
1184 } |
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
|
1185 } |
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
|
1186 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
1187 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
|
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 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
|
1190 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1191 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1192 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
|
1193 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
|
1194 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1195 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
|
1196 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
|
1197 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
|
1198 } 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
|
1199 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
|
1200 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
|
1201 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1202 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1203 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
|
1204 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
|
1205 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
|
1206 } |
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
|
1207 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1208 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
|
1209 } |
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
|
1210 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
1211 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
|
1212 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1213 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1214 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
|
1215 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
|
1216 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1217 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
|
1218 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
|
1219 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
|
1220 } 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
|
1221 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
|
1222 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
|
1223 } |
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
|
1224 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1225 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
|
1226 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
|
1227 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
|
1228 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
|
1229 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1230 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
|
1231 } |
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
|
1232 } |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1233 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1234 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1235 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
|
1236 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1237 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
|
1238 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1239 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1240 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
|
1241 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1242 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
|
1243 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
|
1244 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
|
1245 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
|
1246 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
|
1247 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
|
1248 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1249 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
|
1250 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
|
1251 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1252 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1253 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
|
1254 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1255 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1256 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
|
1257 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
|
1258 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1259 }) |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1260 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1261 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
|
1262 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1263 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1264 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
|
1265 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1266 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
|
1267 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1268 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1269 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
|
1270 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1271 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
|
1272 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
|
1273 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
|
1274 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
|
1275 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1276 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
|
1277 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1278 |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1279 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
|
1280 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1281 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
|
1282 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1283 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1284 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
|
1285 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1286 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
|
1287 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1288 |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1289 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
|
1290 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1291 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1292 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
|
1293 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1294 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1295 |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1296 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
|
1297 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1298 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1299 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
|
1300 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1301 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1302 |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1303 fun htmlNew(cid: Int): WebView? |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1304 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1305 var html: WebView? = null |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1306 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1307 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1308 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
|
1309 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1310 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
|
1311 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
|
1312 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
|
1313 // 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
|
1314 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
|
1315 html!!.settings.javaScriptEnabled = true |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1316 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1317 return html |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1318 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1319 |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1320 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
|
1321 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1322 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1323 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
|
1324 } |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1325 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1326 |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1327 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
|
1328 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1329 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1330 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
|
1331 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
|
1332 } |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1333 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1334 |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1335 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
|
1336 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1337 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1338 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
|
1339 // 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
|
1340 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
|
1341 } |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1342 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1343 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1344 |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1345 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
|
1346 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1347 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1348 when (action) { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1349 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
|
1350 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
|
1351 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
|
1352 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
|
1353 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
|
1354 } |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1355 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1356 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
1357 |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1358 fun spinButtonNew(text: String, cid: Int): DWSpinButton? |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1359 { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1360 var spinbutton: DWSpinButton? = null |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1361 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1362 waitOnUiThread { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1363 var dataArrayMap = SimpleArrayMap<String, Long>() |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1364 val newval = text.toLongOrNull() |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1365 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1366 spinbutton = DWSpinButton(this) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1367 spinbutton!!.tag = dataArrayMap |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1368 spinbutton!!.id = cid |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1369 spinbutton!!.setText(text) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1370 if(newval != null) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1371 spinbutton!!.value = newval |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1372 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1373 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1374 return spinbutton |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1375 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1376 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1377 fun spinButtonSetPos(spinbutton: DWSpinButton, position: Long) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1378 { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1379 waitOnUiThread { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1380 spinbutton.value = position |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1381 spinbutton.setText(position.toString()) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1382 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1383 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1384 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1385 fun spinButtonSetLimits(spinbutton: DWSpinButton, upper: Long, lower: Long) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1386 { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1387 waitOnUiThread { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1388 spinbutton.maximum = upper |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1389 spinbutton.minimum = lower |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1390 if(spinbutton.value > upper) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1391 spinbutton.value = upper |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1392 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1393 if(spinbutton.value < lower) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1394 spinbutton.value = lower |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1395 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1396 spinbutton.setText(spinbutton.value.toString()) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1397 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1398 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1399 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1400 fun spinButtonGetPos(spinbutton: DWSpinButton): Long |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1401 { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1402 var retval: Long = 0 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1403 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1404 waitOnUiThread { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1405 val newvalue = spinbutton.text.toString().toLongOrNull() |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1406 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1407 if(newvalue == null) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1408 retval = spinbutton.value |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1409 } else { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1410 retval = newvalue |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1411 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1412 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1413 return retval |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1414 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1415 |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1416 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
|
1417 { |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1418 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
|
1419 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1420 waitOnUiThread { |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1421 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
|
1422 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1423 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
|
1424 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
|
1425 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
|
1426 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
|
1427 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1428 return combobox |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1429 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1430 |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1431 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
|
1432 { |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1433 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
|
1434 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1435 waitOnUiThread { |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1436 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
|
1437 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1438 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
|
1439 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
|
1440 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
|
1441 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
|
1442 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
|
1443 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1444 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1445 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
|
1446 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1447 |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1448 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
|
1449 { |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1450 waitOnUiThread { |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1451 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
|
1452 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
|
1453 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1454 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
|
1455 } 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
|
1456 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
|
1457 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1458 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
|
1459 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1460 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1461 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1462 |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1463 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
|
1464 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1465 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1466 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
|
1467 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1468 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1469 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
|
1470 } 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
|
1471 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
|
1472 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1473 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
|
1474 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1475 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1476 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1477 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1478 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
|
1479 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1480 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1481 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
|
1482 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1483 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1484 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
|
1485 } 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
|
1486 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
|
1487 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1488 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
|
1489 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1490 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1491 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1492 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1493 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
|
1494 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1495 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
|
1496 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1497 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1498 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
|
1499 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1500 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1501 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
|
1502 } 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
|
1503 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
|
1504 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1505 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
|
1506 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1507 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1508 return retval |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1509 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1510 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1511 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
|
1512 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1513 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1514 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
|
1515 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1516 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1517 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
|
1518 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
|
1519 } 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
|
1520 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
|
1521 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1522 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
|
1523 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
|
1524 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1525 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1526 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1527 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1528 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
|
1529 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1530 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
|
1531 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1532 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1533 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
|
1534 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1535 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1536 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
|
1537 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
|
1538 } 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
|
1539 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
|
1540 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1541 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
|
1542 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
|
1543 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1544 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1545 return retval |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1546 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1547 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1548 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
|
1549 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1550 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
|
1551 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1552 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1553 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
|
1554 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1555 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1556 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
|
1557 } 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
|
1558 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
|
1559 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1560 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
|
1561 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1562 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1563 return retval |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1564 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1565 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1566 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
|
1567 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1568 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1569 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
|
1570 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1571 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1572 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
|
1573 combobox.selected = index |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1574 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
|
1575 } |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1576 } 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
|
1577 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
|
1578 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1579 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
|
1580 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
|
1581 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
|
1582 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
|
1583 } else { |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1584 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
|
1585 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1586 } |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1587 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1588 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1589 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1590 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1591 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
|
1592 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1593 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1594 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
|
1595 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1596 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1597 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
|
1598 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
|
1599 } |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1600 } 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
|
1601 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
|
1602 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1603 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
|
1604 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
|
1605 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1606 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1607 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1608 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1609 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1610 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
|
1611 { |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1612 waitOnUiThread { |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1613 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
|
1614 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
|
1615 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1616 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
|
1617 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
|
1618 } |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1619 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1620 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1621 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1622 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1623 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
|
1624 { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1625 var retval: Int = -1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1626 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1627 waitOnUiThread { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1628 if(window is DWListBox) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1629 val listbox = window |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1630 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
|
1631 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1632 // 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
|
1633 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
|
1634 retval = checked.keyAt(0) |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1635 } else { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1636 // 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
|
1637 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
|
1638 // Item position in adapter |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1639 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
|
1640 // 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
|
1641 // 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
|
1642 // 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
|
1643 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
|
1644 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
|
1645 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1646 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1647 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1648 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1649 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1650 return retval |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1651 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1652 |
2523
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1653 fun calendarNew(cid: Int): CalendarView? |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1654 { |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1655 var calendar: CalendarView? = null |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1656 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1657 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
|
1658 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
|
1659 |
2523
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1660 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
|
1661 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
|
1662 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
|
1663 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
|
1664 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
|
1665 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
|
1666 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
|
1667 } |
2523
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1668 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1669 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1670 return calendar |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1671 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1672 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1673 fun calendarSetDate(calendar: CalendarView, date: Long) |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1674 { |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1675 waitOnUiThread { |
2524
d5c3c573c74e
Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2523
diff
changeset
|
1676 // 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
|
1677 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
|
1678 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1679 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1680 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1681 fun calendarGetDate(calendar: CalendarView): Long |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1682 { |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1683 var date: Long = 0 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1684 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1685 waitOnUiThread { |
2524
d5c3c573c74e
Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2523
diff
changeset
|
1686 // 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
|
1687 date = calendar.date / 1000 |
2523
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1688 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1689 return date |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1690 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
1691 |
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
|
1692 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
|
1693 { |
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
|
1694 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
|
1695 |
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
|
1696 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
|
1697 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
|
1698 |
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
|
1699 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
|
1700 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
|
1701 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
|
1702 } |
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
|
1703 |
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
|
1704 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
|
1705 } |
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
|
1706 |
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
|
1707 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
|
1708 { |
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
|
1709 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
|
1710 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
|
1711 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
|
1712 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
|
1713 |
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
|
1714 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
|
1715 } 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
|
1716 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
|
1717 |
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
|
1718 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
|
1719 } |
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
|
1720 } 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
|
1721 // 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
|
1722 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
|
1723 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
|
1724 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
|
1725 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
|
1726 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
|
1727 |
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
|
1728 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
|
1729 } 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
|
1730 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
|
1731 |
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
|
1732 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
|
1733 } |
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
|
1734 } 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
|
1735 } |
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
|
1736 } |
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
|
1737 } |
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
|
1738 } |
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
|
1739 |
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
|
1740 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
|
1741 { |
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
|
1742 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
|
1743 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
|
1744 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
|
1745 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
|
1746 |
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
|
1747 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
|
1748 } 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
|
1749 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
|
1750 |
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
|
1751 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
|
1752 } |
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
|
1753 } 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
|
1754 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
|
1755 |
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
|
1756 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
|
1757 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
|
1758 |
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
|
1759 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
|
1760 } 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
|
1761 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
|
1762 |
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
|
1763 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
|
1764 } |
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
|
1765 } |
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
|
1766 } |
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
|
1767 } |
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
|
1768 |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1769 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
|
1770 { |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1771 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
|
1772 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1773 waitOnUiThread { |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1774 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
|
1775 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
|
1776 } 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
|
1777 // 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
|
1778 try { |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1779 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
|
1780 } 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
|
1781 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1782 } 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
|
1783 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
|
1784 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1785 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1786 return icon |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1787 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1788 |
2529
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1789 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
|
1790 { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1791 var pixmap: Bitmap? = null |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1792 |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1793 waitOnUiThread { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1794 if(width > 0 && height > 0) { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1795 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
|
1796 } else if(resID != 0) { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1797 pixmap = BitmapFactory.decodeResource(resources, resID); |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1798 } else if(filename != null) { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1799 // 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
|
1800 try { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1801 val f = File(filename) |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1802 pixmap = BitmapFactory.decodeStream(FileInputStream(f)) |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1803 } catch (e: FileNotFoundException) { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1804 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1805 } else if(data != null) { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1806 pixmap = BitmapFactory.decodeByteArray(data, 0, length) |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1807 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1808 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1809 return pixmap |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1810 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1811 |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1812 fun pixmapGetDimensions(pixmap: Bitmap): Long |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1813 { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1814 var dimensions: Long = 0 |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1815 |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1816 waitOnUiThread { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1817 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
|
1818 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1819 return dimensions |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1820 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
1821 |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1822 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
|
1823 { |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1824 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
|
1825 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1826 waitOnUiThread { |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1827 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
|
1828 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1829 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
|
1830 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
|
1831 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
|
1832 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1833 return render |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1834 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1835 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1836 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
|
1837 { |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1838 render.invalidate() |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1839 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1840 |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1841 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
|
1842 { |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1843 // creating timer task, timer |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1844 val t = Timer() |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1845 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
|
1846 override fun run() { |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1847 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
|
1848 t.cancel() |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1849 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1850 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1851 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1852 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
|
1853 return t |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1854 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1855 |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1856 fun timerDisconnect(timer: Timer) |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1857 { |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1858 timer.cancel() |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1859 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1860 |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1861 fun doBeep(duration: Int) |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
1862 { |
2491
bf4fe6bb512b
Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2490
diff
changeset
|
1863 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
|
1864 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
|
1865 val handler = Handler(Looper.getMainLooper()) |
bf4fe6bb512b
Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2490
diff
changeset
|
1866 handler.postDelayed({ |
bf4fe6bb512b
Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2490
diff
changeset
|
1867 toneGen.release() |
bf4fe6bb512b
Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2490
diff
changeset
|
1868 }, (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
|
1869 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1870 |
2482
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
1871 fun debugMessage(text: String) |
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
1872 { |
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
1873 Log.d(null, text) |
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
1874 } |
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
1875 |
2526
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1876 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
|
1877 { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1878 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
|
1879 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1880 waitOnUiThread { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1881 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
|
1882 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
|
1883 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
|
1884 // 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
|
1885 retval = file!!.absolutePath |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1886 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
|
1887 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1888 }) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1889 if(ext != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1890 fc.setExtension(ext) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1891 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1892 fc.showDialog() |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1893 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1894 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1895 // 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
|
1896 try { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1897 Looper.loop() |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1898 } catch (e2: RuntimeException) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1899 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1900 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1901 return retval |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1902 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1903 |
2486
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
1904 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
|
1905 { |
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
1906 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
|
1907 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1908 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1909 // 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
|
1910 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
|
1911 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1912 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
|
1913 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
|
1914 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
|
1915 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
|
1916 //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
|
1917 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
|
1918 retval = 1 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1919 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
|
1920 }); |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1921 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1922 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
|
1923 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
|
1924 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
|
1925 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
|
1926 retval = 0 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1927 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
|
1928 }); |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1929 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1930 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
|
1931 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
|
1932 //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
|
1933 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
|
1934 retval = 0 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1935 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
|
1936 }); |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1937 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1938 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
|
1939 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
|
1940 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
|
1941 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
|
1942 retval = 2 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1943 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
|
1944 }); |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1945 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1946 alert.show(); |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1947 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1948 // 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
|
1949 try { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1950 Looper.loop() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1951 } 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
|
1952 } |
2486
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
1953 } |
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
1954 return retval |
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
1955 } |
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
1956 |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1957 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
|
1958 { |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1959 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
|
1960 return true |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1961 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1962 return false |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1963 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1964 |
2514
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1965 fun mainSleep(milliseconds: Int) |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1966 { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1967 // 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
|
1968 // 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
|
1969 // 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
|
1970 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
|
1971 val starttime = System.currentTimeMillis() |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1972 |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1973 // 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
|
1974 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
|
1975 var thrown: Boolean = false |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1976 |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1977 override fun queueIdle(): Boolean { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1978 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
|
1979 if (thrown == false) { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1980 thrown = true |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1981 throw java.lang.RuntimeException() |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1982 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1983 return false |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1984 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1985 return true |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1986 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1987 }) |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1988 |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1989 // 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
|
1990 try { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1991 Looper.loop() |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1992 } catch (e2: RuntimeException) { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1993 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1994 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1995 else |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1996 { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1997 // 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
|
1998 Thread.sleep(milliseconds.toLong()) |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
1999 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
2000 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
2001 |
2487
83f8f4f58a98
Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2486
diff
changeset
|
2002 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
|
2003 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2004 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2005 this.finishAffinity() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2006 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
|
2007 } |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2008 } |
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2009 |
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2010 fun dwindowsShutdown() |
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2011 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2012 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2013 this.finishAffinity() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2014 } |
2487
83f8f4f58a98
Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2486
diff
changeset
|
2015 } |
83f8f4f58a98
Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2486
diff
changeset
|
2016 |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2017 fun dwInit(appid: String, appname: String) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2018 { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2019 waitOnUiThread { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2020 // 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
|
2021 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
|
2022 // Create the NotificationChannel |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2023 val importance = NotificationManager.IMPORTANCE_DEFAULT |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2024 val mChannel = NotificationChannel(appid, appname, importance) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2025 // 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
|
2026 // or other notification behaviors after this |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2027 val notificationManager = |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2028 getSystemService(NOTIFICATION_SERVICE) as NotificationManager |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2029 notificationManager.createNotificationChannel(mChannel) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2030 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2031 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2032 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2033 |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2034 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
|
2035 { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2036 var builder: NotificationCompat.Builder? = null |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2037 |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2038 waitOnUiThread { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2039 builder = NotificationCompat.Builder(this, appid) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2040 .setContentTitle(title) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2041 .setContentText(text) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2042 .setPriority(NotificationCompat.PRIORITY_DEFAULT) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2043 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2044 return builder |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2045 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2046 |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2047 fun notificationSend(builder: NotificationCompat.Builder) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2048 { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2049 waitOnUiThread { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2050 notificationID += 1 |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2051 with(NotificationManagerCompat.from(this)) { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2052 // 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
|
2053 notify(notificationID, builder.build()) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2054 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2055 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2056 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2057 |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
2058 /* |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
2059 * 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
|
2060 * 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
|
2061 */ |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2062 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
|
2063 external fun eventHandler( |
2499
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
2064 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
|
2065 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
|
2066 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
|
2067 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
|
2068 str2: String?, |
2499
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
2069 inta: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
2070 intb: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
2071 intc: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
2072 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
|
2073 ): Int |
2499
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
2074 external fun eventHandlerInt( |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
2075 obj1: View, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
2076 message: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
2077 inta: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
2078 intb: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
2079 intc: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
2080 intd: Int |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
2081 ) |
2483
9f7af6d8c6a4
Android: Fix signal handlers so they actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2482
diff
changeset
|
2082 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
|
2083 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
|
2084 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
|
2085 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
|
2086 |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
2087 companion object |
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
2088 { |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2089 // 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
|
2090 init |
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
2091 { |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2092 System.loadLibrary("dwindows") |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2093 } |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2094 } |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2095 } |