Mercurial > dwindows
annotate android/DWindows.kt @ 2690:755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
Avoid warnings creating bitmaps from resources by not calling setImageResource()
unless the resource ID is greater than 65535. Use App ID when logging messages.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 31 Oct 2021 12:59:45 +0000 |
parents | 7127de139acf |
children | e13607b87517 |
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 |
2608
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
4 import android.annotation.SuppressLint |
2526
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.Activity |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
6 import android.app.Dialog |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
7 import android.app.NotificationChannel |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
8 import android.app.NotificationManager |
2594
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
9 import android.content.* |
2480
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
10 import android.content.pm.ActivityInfo |
2496
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
11 import android.content.res.Configuration |
2643
28ca1e59e76f
Android: Catch NotFoundException when loading resource...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2642
diff
changeset
|
12 import android.content.res.Resources |
2594
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
13 import android.database.Cursor |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
14 import android.graphics.* |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
15 import android.graphics.drawable.BitmapDrawable |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
16 import android.graphics.drawable.Drawable |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
17 import android.graphics.drawable.GradientDrawable |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
18 import android.media.AudioManager |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
19 import android.media.ToneGenerator |
2594
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
20 import android.net.Uri |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
21 import android.os.* |
2594
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
22 import android.provider.DocumentsContract |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
23 import android.provider.MediaStore |
2492
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 |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
25 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
|
26 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
|
27 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
|
28 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
|
29 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
|
30 import android.util.SparseBooleanArray |
2551
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
31 import android.util.TypedValue |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
32 import android.view.* |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
33 import android.view.View.OnTouchListener |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
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 |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
45 import androidx.constraintlayout.widget.ConstraintLayout |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
46 import androidx.constraintlayout.widget.ConstraintSet |
2675
a7868380098f
Android: LinearLayout does not allow null views, if null, create a Placeholder view.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2670
diff
changeset
|
47 import androidx.constraintlayout.widget.Placeholder |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
48 import androidx.core.app.NotificationCompat |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
49 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
|
50 import androidx.core.content.res.ResourcesCompat |
2544
dbfcc0e357d6
Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2543
diff
changeset
|
51 import androidx.core.view.MenuCompat |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
52 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
|
53 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
|
54 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
|
55 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
|
56 import com.google.android.material.tabs.TabLayoutMediator |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
57 import java.io.BufferedInputStream |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
58 import java.io.File |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
59 import java.io.FileOutputStream |
2564
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
60 import java.io.IOException |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
61 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
|
62 import java.util.concurrent.locks.ReentrantLock |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
63 import java.util.zip.ZipEntry |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
64 import java.util.zip.ZipFile |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
65 |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
66 object DWEvent { |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
67 const val TIMER = 0 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
68 const val CONFIGURE = 1 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
69 const val KEY_PRESS = 2 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
70 const val BUTTON_PRESS = 3 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
71 const val BUTTON_RELEASE = 4 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
72 const val MOTION_NOTIFY = 5 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
73 const val DELETE = 6 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
74 const val EXPOSE = 7 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
75 const val CLICKED = 8 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
76 const val ITEM_ENTER = 9 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
77 const val ITEM_CONTEXT = 10 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
78 const val LIST_SELECT = 11 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
79 const val ITEM_SELECT = 12 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
80 const val SET_FOCUS = 13 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
81 const val VALUE_CHANGED = 14 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
82 const val SWITCH_PAGE = 15 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
83 const val TREE_EXPAND = 16 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
84 const val COLUMN_CLICK = 17 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
85 const val HTML_RESULT = 18 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
86 const val HTML_CHANGED = 19 |
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
87 } |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
88 |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
89 val DWImageExts = arrayOf("", ".png", ".webp", ".jpg", ".jpeg", ".gif") |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
90 |
2495
5664c91d03fb
Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2494
diff
changeset
|
91 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
|
92 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
|
93 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
|
94 var currentPageID = 0L |
2667
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
95 var recyclerView: RecyclerView? = null |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
96 |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
97 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
|
98 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
|
99 |
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
|
100 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
|
101 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
|
102 return position |
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
103 } |
2667
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
104 override fun onAttachedToRecyclerView(rv: RecyclerView) { |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
105 recyclerView = rv |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
106 } |
2495
5664c91d03fb
Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2494
diff
changeset
|
107 override fun onBindViewHolder(holder: DWEventViewHolder, position: Int) { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
108 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
|
109 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
110 |
2498
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
111 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
|
112 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
113 |
2505
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
114 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
|
115 //Implement shouldOverrideUrlLoading// |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
116 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
|
117 // 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
|
118 // 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
|
119 return false |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
120 } |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
121 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
|
122 // Handle the DW_HTML_CHANGE_STARTED event |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
123 eventHandlerHTMLChanged(view, DWEvent.HTML_CHANGED, url, 1) |
2505
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
124 } |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
125 |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
126 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
|
127 // Handle the DW_HTML_CHANGE_COMPLETE event |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
128 eventHandlerHTMLChanged(view, DWEvent.HTML_CHANGED, url, 4) |
2505
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
129 } |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
130 |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
131 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
|
132 } |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
133 |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
134 class DWSpinButton(context: Context) : AppCompatEditText(context), OnTouchListener { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
135 var value: Long = 0 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
136 var minimum: Long = 0 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
137 var maximum: Long = 65535 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
138 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
139 init { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
140 setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_media_previous, 0, R.drawable.ic_media_next, 0) |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
141 setOnTouchListener(this) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
142 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
143 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
144 override fun onTouch(v: View, event: MotionEvent): Boolean { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
145 val DRAWABLE_RIGHT = 2 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
146 val DRAWABLE_LEFT = 0 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
147 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
148 if (event.action == MotionEvent.ACTION_UP) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
149 if (event.x >= v.width - (v as EditText) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
150 .compoundDrawables[DRAWABLE_RIGHT].bounds.width() |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
151 ) { |
2527
eec926265888
Android: Use toLongOrNull() whenever converting from string to long...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2526
diff
changeset
|
152 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
|
153 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
154 if(newvalue != null) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
155 value = newvalue + 1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
156 } else { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
157 value += 1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
158 } |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
159 if(value > maximum) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
160 value = maximum |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
161 } |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
162 if(value < minimum) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
163 value = minimum |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
164 } |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
165 setText(value.toString()) |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
166 eventHandlerInt(DWEvent.VALUE_CHANGED, value.toInt(), 0, 0, 0) |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
167 return true |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
168 } else if (event.x <= v.compoundDrawables[DRAWABLE_LEFT].bounds.width()) { |
2527
eec926265888
Android: Use toLongOrNull() whenever converting from string to long...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2526
diff
changeset
|
169 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
|
170 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
171 if(newvalue != null) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
172 value = newvalue - 1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
173 } else { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
174 value -= 1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
175 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
176 if(value > maximum) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
177 value = maximum |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
178 } |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
179 if(value < minimum) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
180 value = minimum |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
181 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
182 setText(value.toString()) |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
183 eventHandlerInt(DWEvent.VALUE_CHANGED, value.toInt(), 0, 0, 0) |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
184 return true |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
185 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
186 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
187 return false |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
188 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
189 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
190 external fun eventHandlerInt( |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
191 message: Int, |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
192 inta: Int, |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
193 intb: Int, |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
194 intc: Int, |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
195 intd: Int |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
196 ) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
197 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
198 |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
199 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
|
200 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
|
201 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
|
202 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
|
203 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
204 init { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
205 setCompoundDrawablesWithIntrinsicBounds(0, 0, 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
|
206 setOnTouchListener(this) |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
207 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
|
208 lpw!!.setAdapter( |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
209 ArrayAdapter( |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
210 context, |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
211 R.layout.simple_list_item_1, list |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
212 ) |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
213 ) |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
214 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
|
215 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
|
216 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
|
217 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
218 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
219 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
|
220 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
|
221 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
|
222 setText(item) |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
223 lpw!!.dismiss() |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
224 eventHandlerInt(DWEvent.LIST_SELECT, 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
|
225 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
226 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
227 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
|
228 val DRAWABLE_RIGHT = 2 |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
229 |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
230 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
|
231 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
|
232 .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
|
233 ) { |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
234 lpw!!.show() |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
235 return true |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
236 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
237 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
238 return false |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
239 } |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
240 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
241 external fun eventHandlerInt( |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
242 message: Int, |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
243 inta: Int, |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
244 intb: Int, |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
245 intc: Int, |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
246 intd: Int |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
247 ) |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
248 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
249 |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
250 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
|
251 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
|
252 var selected: Int = -1 |
2677
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
253 var colorFore: Int? = null |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
254 var colorBack: Int? = null |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
255 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
256 init { |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
257 setAdapter( |
2677
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
258 object : ArrayAdapter<String>( |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
259 context, |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
260 R.layout.simple_list_item_1, list |
2677
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
261 ) { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
262 override fun getView(pos: Int, view: View?, parent: ViewGroup): View { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
263 val thisview = super.getView(pos, view, parent) |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
264 val textview = thisview as TextView |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
265 if (colorFore != null) { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
266 textview.setTextColor(colorFore!!) |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
267 } |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
268 if (colorBack != null) { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
269 textview.setBackgroundColor(colorBack!!) |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
270 } |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
271 return thisview |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
272 } |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
273 } |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
274 ) |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
275 onItemClickListener = this |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
276 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
277 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
278 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
|
279 selected = position |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
280 eventHandlerInt(DWEvent.LIST_SELECT, position, 0, 0, 0) |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
281 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
282 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
283 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
|
284 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
|
285 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
|
286 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
|
287 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
|
288 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
|
289 ) |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
290 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
291 |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
292 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
|
293 var cachedCanvas: Canvas? = null |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
294 var typeface: Typeface? = null |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
295 var fontsize: Float? = null |
2608
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
296 var evx: Float = 0f |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
297 var evy: Float = 0f |
2611
ed2c4a503666
Android: Implement button release and motion notify events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2608
diff
changeset
|
298 var button: Int = 1 |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
299 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
300 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
|
301 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
|
302 // Send DW_SIGNAL_CONFIGURE |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
303 eventHandlerInt(DWEvent.CONFIGURE, width, height, 0, 0) |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
304 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
305 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
306 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
|
307 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
|
308 cachedCanvas = canvas |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
309 // Send DW_SIGNAL_EXPOSE |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
310 eventHandlerInt(DWEvent.EXPOSE, 0, 0, this.width, this.height) |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
311 cachedCanvas = null |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
312 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
313 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
314 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
|
315 message: Int, |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
316 inta: Int, |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
317 intb: Int, |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
318 intc: Int, |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
319 intd: Int |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
320 ) |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
321 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
322 |
2526
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
323 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
|
324 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
|
325 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
|
326 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
|
327 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
328 // 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
|
329 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
|
330 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
|
331 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
|
332 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
333 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
334 // 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
|
335 interface FileSelectedListener { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
336 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
|
337 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
338 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
339 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
|
340 this.fileListener = fileListener |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
341 return this |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
342 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
343 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
344 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
|
345 fun showDialog() { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
346 dialog.show() |
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 |
2527
eec926265888
Android: Use toLongOrNull() whenever converting from string to long...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2526
diff
changeset
|
349 /* |
2526
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
350 * 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
|
351 */ |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
352 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
|
353 currentPath = path |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
354 if (path != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
355 if (path.exists()) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
356 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
|
357 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
|
358 if (!file.isDirectory) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
359 if (!file.canRead()) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
360 false |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
361 } 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
|
362 true |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
363 } else { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
364 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
|
365 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
366 } else { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
367 false |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
368 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
369 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
370 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
371 // 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
|
372 var i = 0 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
373 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
|
374 var filecount = 0 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
375 var dircount = 0 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
376 if(files != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
377 filecount = files.size |
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 if(dirs != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
380 dircount = dirs.size |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
381 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
382 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
|
383 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
|
384 } else { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
385 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
|
386 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
|
387 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
388 if(dirs != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
389 Arrays.sort(dirs) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
390 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
|
391 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
|
392 } |
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 if(files != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
395 Arrays.sort(files) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
396 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
|
397 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
|
398 } |
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 // 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
|
402 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
|
403 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
|
404 activity, |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
405 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
|
406 ) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
407 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
|
408 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
|
409 (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
|
410 return thisview |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
411 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
412 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
413 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
414 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
415 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
416 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
417 /** |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
418 * 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
|
419 */ |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
420 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
|
421 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
|
422 currentPath!!.parentFile |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
423 } else { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
424 File(currentPath, fileChosen) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
425 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
426 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
427 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
428 companion object { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
429 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
|
430 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
431 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
432 init { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
433 list.onItemClickListener = |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
434 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
|
435 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
|
436 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
|
437 if (chosenFile != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
438 if (chosenFile.isDirectory) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
439 refresh(chosenFile) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
440 } else { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
441 if (fileListener != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
442 fileListener!!.fileSelected(chosenFile) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
443 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
444 dialog.dismiss() |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
445 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
446 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
447 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
448 dialog.setContentView(list) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
449 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
|
450 refresh(Environment.getExternalStorageDirectory()) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
451 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
452 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
453 |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
454 // On Android we can't pre-create submenus... |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
455 // So create our own placeholder classes, and create the actual menus |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
456 // on demand when required by Android |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
457 class DWMenuItem |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
458 { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
459 var title: String? = null |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
460 var menu: DWMenu? = null |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
461 var submenu: DWMenu? = null |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
462 var checked: Boolean = false |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
463 var check: Boolean = false |
2546
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
464 var enabled: Boolean = true |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
465 var menuitem: MenuItem? = null |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
466 var submenuitem: SubMenu? = null |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
467 var id: Int = 0 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
468 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
469 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
470 class DWMenu { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
471 var menu: Menu? = null |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
472 var children = mutableListOf<DWMenuItem>() |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
473 var id: Int = 0 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
474 |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
475 fun createMenu(newmenu: Menu?, recreate: Boolean) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
476 var refresh = recreate |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
477 |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
478 if(newmenu != null) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
479 if(newmenu != menu) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
480 menu = newmenu |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
481 refresh = true |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
482 } |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
483 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
484 if(menu != null) { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
485 var group = 0 |
2544
dbfcc0e357d6
Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2543
diff
changeset
|
486 |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
487 if(refresh) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
488 menu!!.clear() |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
489 } |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
490 |
2544
dbfcc0e357d6
Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2543
diff
changeset
|
491 // Enable group dividers for separators |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
492 MenuCompat.setGroupDividerEnabled(menu, true) |
2544
dbfcc0e357d6
Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2543
diff
changeset
|
493 |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
494 for (menuitem in children) { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
495 // Submenus on Android can't have submenus, so stop at depth 1 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
496 if (menuitem.submenu != null && menu !is SubMenu) { |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
497 if(menuitem.submenuitem == null || refresh) { |
2544
dbfcc0e357d6
Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2543
diff
changeset
|
498 menuitem.submenuitem = menu?.addSubMenu(group, menuitem.id, 0, menuitem.title) |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
499 } |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
500 menuitem.submenu!!.createMenu(menuitem.submenuitem, refresh) |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
501 } else if(menuitem.submenu == null) { |
2544
dbfcc0e357d6
Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2543
diff
changeset
|
502 if(menuitem.title!!.isEmpty()) { |
dbfcc0e357d6
Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2543
diff
changeset
|
503 group += 1 |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
504 } else if(menuitem.menuitem == null || refresh) { |
2544
dbfcc0e357d6
Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2543
diff
changeset
|
505 menuitem.menuitem = menu?.add(group, menuitem.id, 0, menuitem.title) |
2545
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
506 menuitem.menuitem!!.isCheckable = menuitem.check |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
507 menuitem.menuitem!!.isChecked = menuitem.checked |
2546
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
508 menuitem.menuitem!!.isEnabled = menuitem.enabled |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
509 menuitem.menuitem!!.setOnMenuItemClickListener { item: MenuItem? -> |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
510 eventHandlerSimple(menuitem, DWEvent.CLICKED) |
2544
dbfcc0e357d6
Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2543
diff
changeset
|
511 true |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
512 } |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
513 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
514 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
515 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
516 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
517 } |
2544
dbfcc0e357d6
Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2543
diff
changeset
|
518 |
dbfcc0e357d6
Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2543
diff
changeset
|
519 external fun eventHandlerSimple(item: DWMenuItem, message: Int) |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
520 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
521 |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
522 // Class for storing container data |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
523 class DWContainerModel { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
524 var columns = mutableListOf<String?>() |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
525 var types = mutableListOf<Int>() |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
526 var data = mutableListOf<Any?>() |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
527 var rowdata = mutableListOf<Long>() |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
528 var rowtitle = mutableListOf<String?>() |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
529 var querypos: Int = -1 |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
530 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
531 fun numberOfColumns(): Int |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
532 { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
533 return columns.size |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
534 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
535 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
536 fun numberOfRows(): Int |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
537 { |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
538 if(columns.size > 0) { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
539 return data.size / columns.size |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
540 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
541 return 0 |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
542 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
543 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
544 fun getColumnType(column: Int): Int |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
545 { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
546 if(column < types.size) { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
547 return types[column] |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
548 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
549 return -1 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
550 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
551 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
552 fun getRowAndColumn(row: Int, column: Int): Any? |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
553 { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
554 val index: Int = (row * columns.size) + column |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
555 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
556 if(index > -1 && index < data.size) { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
557 return data[index] |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
558 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
559 return null |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
560 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
561 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
562 fun setRowAndColumn(row: Int, column: Int, obj: Any?) |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
563 { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
564 val index: Int = (row * columns.size) + column |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
565 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
566 if(index > -1 && index < data.size && column < types.size) { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
567 // Verify the data matches the column type |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
568 if((((types[column] and 1) != 0) && (obj is Drawable)) || |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
569 (((types[column] and (1 shl 1)) != 0) && (obj is String)) || |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
570 (((types[column] and (1 shl 2)) != 0) && (obj is Int))) { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
571 data[index] = obj |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
572 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
573 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
574 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
575 |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
576 fun changeRowData(row: Int, rdata: Long) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
577 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
578 if(row > -1 && row < rowdata.size) { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
579 rowdata[row] = rdata |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
580 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
581 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
582 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
583 fun getRowData(row: Int): Long |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
584 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
585 if(row > -1 && row < rowdata.size) { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
586 return rowdata[row] |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
587 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
588 return 0 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
589 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
590 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
591 fun changeRowTitle(row: Int, title: String?) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
592 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
593 if(row > -1 && row < rowtitle.size) { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
594 rowtitle[row] = title |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
595 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
596 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
597 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
598 fun getRowTitle(row: Int): String? |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
599 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
600 if(row > -1 && row < rowtitle.size) { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
601 return rowtitle[row] |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
602 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
603 return null |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
604 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
605 |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
606 fun addColumn(title: String?, type: Int) |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
607 { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
608 columns.add(title) |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
609 types.add(type) |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
610 // If we change the columns we have to invalidate the data |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
611 data.clear() |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
612 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
613 |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
614 fun deleteRows(count: Int) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
615 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
616 if(count < rowdata.size) { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
617 for(i in 0 until count) { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
618 for(j in 0 until columns.size) { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
619 data.removeAt(0) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
620 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
621 rowdata.removeAt(0) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
622 rowtitle.removeAt(0) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
623 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
624 } else { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
625 data.clear() |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
626 rowdata.clear() |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
627 rowtitle.clear() |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
628 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
629 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
630 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
631 fun deleteRowByTitle(title: String?) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
632 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
633 for(i in 0 until rowtitle.size) { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
634 if(rowtitle[i] != null && rowtitle[i] == title) { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
635 for(j in 0 until columns.size) { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
636 data.removeAt(i * columns.size) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
637 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
638 rowdata.removeAt(i) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
639 rowtitle.removeAt(i) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
640 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
641 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
642 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
643 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
644 fun deleteRowByData(rdata: Long) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
645 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
646 for(i in 0 until rowdata.size) { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
647 if(rowdata[i] == rdata) { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
648 for(j in 0 until columns.size) { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
649 data.removeAt(i * columns.size) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
650 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
651 rowdata.removeAt(i) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
652 rowtitle.removeAt(i) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
653 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
654 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
655 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
656 |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
657 fun addRows(count: Int): Long |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
658 { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
659 val startRow: Long = numberOfRows().toLong() |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
660 |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
661 for(i in 0 until count) |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
662 { |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
663 for(j in 0 until columns.size) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
664 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
665 // Fill in with nulls to be set later |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
666 data.add(null) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
667 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
668 rowdata.add(0) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
669 rowtitle.add(null) |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
670 } |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
671 return startRow |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
672 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
673 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
674 fun clear() |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
675 { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
676 data.clear() |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
677 rowdata.clear() |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
678 rowtitle.clear() |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
679 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
680 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
681 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
682 class DWContainerAdapter(c: Context) : BaseAdapter() |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
683 { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
684 private var context = c |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
685 var model = DWContainerModel() |
2563
56183bef6793
Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2562
diff
changeset
|
686 var selectedItem: Int = -1 |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
687 var simpleMode: Boolean = true |
2580
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
688 var oddColor: Int? = null |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
689 var evenColor: Int? = null |
2677
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
690 var foreColor: Int? = null |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
691 var backColor: Int? = null |
2613
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
692 var lastClick: Long = 0 |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
693 var lastClickRow: Int = -1 |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
694 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
695 override fun getCount(): Int { |
2567
19d82c1f135f
Android: Fix incorrect display of first container entry with the new layout code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2565
diff
changeset
|
696 return model.numberOfRows() |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
697 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
698 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
699 override fun getItem(position: Int): Any? { |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
700 return model.getRowAndColumn(position, 0) |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
701 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
702 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
703 override fun getItemId(position: Int): Long { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
704 return position.toLong() |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
705 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
706 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
707 override fun getView(position: Int, view: View?, parent: ViewGroup): View { |
2568
b536b7b21682
Android: Switch to using LinearLayout for Container row layout...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2567
diff
changeset
|
708 var rowView: LinearLayout? = view as LinearLayout? |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
709 var displayColumns = model.numberOfColumns() |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
710 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
711 // In simple mode, limit the columns to 1 or 2 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
712 if(simpleMode == true) { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
713 // If column 1 is bitmap and column 2 is text... |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
714 if(displayColumns > 1 && (model.getColumnType(0) and 1) != 0 && |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
715 (model.getColumnType(1) and (1 shl 1)) != 0) { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
716 displayColumns = 2 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
717 } else { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
718 displayColumns = 1 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
719 } |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
720 } |
2561
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
721 |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
722 // If the view passed in is null we need to create the layout |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
723 if(rowView == null) { |
2568
b536b7b21682
Android: Switch to using LinearLayout for Container row layout...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2567
diff
changeset
|
724 rowView = LinearLayout(context) |
b536b7b21682
Android: Switch to using LinearLayout for Container row layout...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2567
diff
changeset
|
725 rowView.orientation = LinearLayout.HORIZONTAL |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
726 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
727 for(i in 0 until displayColumns) { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
728 val content = model.getRowAndColumn(position, i) |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
729 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
730 // Image |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
731 if((model.getColumnType(i) and 1) != 0) { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
732 val imageview = ImageView(context) |
2580
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
733 val params = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
734 LinearLayout.LayoutParams.WRAP_CONTENT) |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
735 params.gravity = Gravity.CENTER |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
736 imageview.layoutParams = params |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
737 imageview.id = View.generateViewId() |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
738 if (content is Drawable) { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
739 imageview.setImageDrawable(content) |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
740 } |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
741 rowView.addView(imageview) |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
742 } else { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
743 // Everything else id displayed as text |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
744 val textview = TextView(context) |
2580
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
745 val params = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
746 LinearLayout.LayoutParams.WRAP_CONTENT) |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
747 params.gravity = Gravity.CENTER |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
748 textview.layoutParams = params |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
749 textview.id = View.generateViewId() |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
750 if (content is String) { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
751 textview.text = content |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
752 } else if(content is Int) { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
753 textview.text = content.toString() |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
754 } |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
755 rowView.addView(textview) |
2561
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
756 } |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
757 } |
2561
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
758 // TODO: Add code to optionally add other columns |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
759 } else { |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
760 // Otherwise we just need to update the existing layout |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
761 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
762 for(i in 0 until displayColumns) { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
763 val content = model.getRowAndColumn(position, i) |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
764 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
765 // Image |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
766 if((model.getColumnType(i) and 1) != 0) { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
767 val imageview = rowView.getChildAt(i) |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
768 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
769 if (imageview is ImageView && content is Drawable) { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
770 imageview.setImageDrawable(content) |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
771 } |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
772 } else { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
773 // Text |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
774 val textview = rowView.getChildAt(i) |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
775 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
776 if (textview is TextView) { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
777 if (content is String) { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
778 textview.text = content |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
779 } else if (content is Int) { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
780 textview.text = content.toString() |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
781 } |
2677
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
782 if(foreColor != null) { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
783 textview.setTextColor(foreColor!!) |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
784 } |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
785 } |
2561
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
786 } |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
787 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
788 } |
2580
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
789 // Handle row stripe |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
790 if (position % 2 == 0) { |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
791 if(evenColor != null) { |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
792 rowView.setBackgroundColor(evenColor!!) |
2677
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
793 } else if(backColor != null) { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
794 rowView.setBackgroundColor(backColor!!) |
2580
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
795 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
796 } else { |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
797 if(oddColor != null) { |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
798 rowView.setBackgroundColor(oddColor!!) |
2677
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
799 } else if(backColor != null) { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
800 rowView.setBackgroundColor(backColor!!) |
2580
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
801 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
802 } |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
803 return rowView |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
804 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
805 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
806 |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
807 class DWindows : AppCompatActivity() { |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
808 var windowLayout: ViewPager2? = null |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
809 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
|
810 var threadCond = threadLock.newCondition() |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
811 var notificationID: Int = 0 |
2551
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
812 var darkMode: Int = -1 |
2614
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
813 var lastClickView: View? = null |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
814 private var appID: String? = null |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
815 private var paint = Paint() |
2637
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
816 private var bgcolor: Int? = null |
2594
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
817 private var fileURI: Uri? = null |
2595
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
818 private var fileLock = ReentrantLock() |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
819 private var fileCond = threadLock.newCondition() |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
820 // Lists of data for our Windows |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
821 private var windowTitles = mutableListOf<String?>() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
822 private var windowMenuBars = mutableListOf<DWMenu?>() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
823 private var windowStyles = mutableListOf<Int>() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
824 private var windowDefault = mutableListOf<View?>() |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
825 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
826 // 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
|
827 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
|
828 { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
829 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
|
830 runnable.run() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
831 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
832 threadLock.lock() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
833 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
|
834 threadLock.lock() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
835 runnable.run() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
836 threadCond.signal() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
837 threadLock.unlock() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
838 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
839 runOnUiThread(ourRunnable) |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
840 threadCond.await() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
841 threadLock.unlock() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
842 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
843 } |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
844 |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
845 // Returns true if the filename is a resource ID (non-zero number) |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
846 // with a image file extension in our DWImageExts list |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
847 private fun isDWResource(filename: String): Boolean { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
848 val length = filename.length |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
849 |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
850 for (ext in DWImageExts) { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
851 if (ext.isNotEmpty() && filename.endsWith(ext)) { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
852 val filebody: String = filename.substring(7, length - ext.length) |
2659
3a14d7fd4b99
Android: Catch NumberFormatException in isDWResource().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2658
diff
changeset
|
853 try { |
3a14d7fd4b99
Android: Catch NumberFormatException in isDWResource().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2658
diff
changeset
|
854 if (filebody.toInt() > 0) { |
3a14d7fd4b99
Android: Catch NumberFormatException in isDWResource().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2658
diff
changeset
|
855 return true |
3a14d7fd4b99
Android: Catch NumberFormatException in isDWResource().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2658
diff
changeset
|
856 } |
3a14d7fd4b99
Android: Catch NumberFormatException in isDWResource().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2658
diff
changeset
|
857 } catch(e: NumberFormatException) { |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
858 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
859 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
860 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
861 return false |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
862 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
863 |
2659
3a14d7fd4b99
Android: Catch NumberFormatException in isDWResource().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2658
diff
changeset
|
864 // Extracts assets/ in the APK to the application cache directory |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
865 private fun extractAssets() { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
866 var zipFile: ZipFile? = null |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
867 val targetDir = cacheDir |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
868 |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
869 try { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
870 zipFile = ZipFile(this.applicationInfo.sourceDir) |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
871 val e: Enumeration<out ZipEntry?> = zipFile.entries() |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
872 while (e.hasMoreElements()) { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
873 val entry: ZipEntry? = e.nextElement() |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
874 if (entry == null || entry.isDirectory || !entry.name.startsWith("assets/") || |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
875 isDWResource(entry.name)) { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
876 continue |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
877 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
878 val targetFile = File(targetDir, entry.name.substring("assets/".length)) |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
879 targetFile.parentFile!!.mkdirs() |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
880 val tempBuffer = ByteArray(entry.size.toInt()) |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
881 var ais: BufferedInputStream? = null |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
882 var aos: FileOutputStream? = null |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
883 try { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
884 ais = BufferedInputStream(zipFile.getInputStream(entry)) |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
885 aos = FileOutputStream(targetFile) |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
886 ais.read(tempBuffer) |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
887 aos.write(tempBuffer) |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
888 } catch (e: IOException) { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
889 } finally { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
890 ais?.close() |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
891 aos?.close() |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
892 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
893 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
894 } catch (e: IOException) { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
895 } finally { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
896 zipFile?.close() |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
897 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
898 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
899 |
2498
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
900 // 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
|
901 // 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
|
902 // 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
|
903 // 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
|
904 // 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
|
905 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
|
906 super.onCreate(savedInstanceState) |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
907 |
2480
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
908 // Turn on rotation |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
909 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
|
910 |
2498
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
911 // 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
|
912 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
|
913 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
|
914 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
|
915 s = p.applicationInfo.dataDir |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
916 val c = cacheDir.path |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
917 |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
918 // Extract any non-resource assets to the cache directory |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
919 // So that our C code can access them as files, like on |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
920 // other Dynamic Windows platforms |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
921 extractAssets() |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
922 |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
923 // Setup our ViewPager2 as our activty window container |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
924 windowLayout = ViewPager2(this) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
925 windowLayout!!.id = View.generateViewId() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
926 windowLayout!!.adapter = DWTabViewPagerAdapter() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
927 windowLayout!!.isUserInputEnabled = false |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
928 windowLayout!!.layoutParams = |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
929 ViewGroup.LayoutParams( |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
930 ViewGroup.LayoutParams.MATCH_PARENT, |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
931 ViewGroup.LayoutParams.MATCH_PARENT |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
932 ) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
933 |
2498
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
934 // 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
|
935 // This will start a new thread that calls the app's dwmain() |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
936 dwindowsInit(s, c, this.getPackageName()) |
2496
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
937 } |
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
938 |
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
939 override fun onConfigurationChanged(newConfig: Configuration) { |
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
940 super.onConfigurationChanged(newConfig) |
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
941 |
2551
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
942 val currentNightMode = newConfig.uiMode and Configuration.UI_MODE_NIGHT_MASK |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
943 when (currentNightMode) { |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
944 Configuration.UI_MODE_NIGHT_NO -> { darkMode = 0 } // Night mode is not active, we're using the light theme |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
945 Configuration.UI_MODE_NIGHT_YES -> { darkMode = 1 } // Night mode is active, we're using dark theme |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
946 } |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
947 |
2499
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
948 // 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
|
949 if(windowLayout != null) { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
950 val width: Int = windowLayout!!.width |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
951 val height: Int = windowLayout!!.height |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
952 val adapter: DWTabViewPagerAdapter = windowLayout!!.adapter as DWTabViewPagerAdapter |
2685
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
953 val index = windowLayout!!.currentItem |
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
954 val count = adapter.viewList.count() |
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
955 |
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
956 if(count > 0 && index < count) { |
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
957 val window = adapter.viewList[index] |
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
958 |
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
959 eventHandlerInt(window, DWEvent.CONFIGURE, width, height, 0, 0) |
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
960 } |
2496
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
961 } |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
962 } |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
963 |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
964 override fun onCreateOptionsMenu(menu: Menu?): Boolean { |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
965 if(windowLayout != null) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
966 val index = windowLayout!!.currentItem |
2685
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
967 val count = windowMenuBars.count() |
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
968 |
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
969 if (count > 0 && index < count) { |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
970 var menuBar = windowMenuBars[index] |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
971 |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
972 if(menuBar == null) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
973 menuBar = DWMenu() |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
974 windowMenuBars[index] = menuBar |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
975 } |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
976 menuBar!!.menu = menu |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
977 return super.onCreateOptionsMenu(menu) |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
978 } |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
979 } |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
980 return false |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
981 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
982 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
983 override fun onPrepareOptionsMenu(menu: Menu?): Boolean { |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
984 if(windowLayout != null) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
985 val index = windowLayout!!.currentItem |
2685
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
986 val count = windowMenuBars.count() |
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
987 |
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
988 if (count > 0 && index < count) { |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
989 var menuBar = windowMenuBars[index] |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
990 |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
991 if(menuBar != null) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
992 menuBar!!.createMenu(menu, true) |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
993 } else { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
994 menuBar = DWMenu() |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
995 menuBar!!.createMenu(menu, true) |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
996 windowMenuBars[index] = menuBar |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
997 } |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
998 return super.onPrepareOptionsMenu(menu) |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
999 } |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1000 } |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1001 return false |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1002 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1003 |
2668
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1004 override fun onBackPressed() { |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1005 if(windowLayout != null) { |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1006 val adapter: DWTabViewPagerAdapter = windowLayout!!.adapter as DWTabViewPagerAdapter |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1007 val index = windowLayout!!.currentItem |
2685
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
1008 val count = windowStyles.count() |
2668
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1009 |
2670
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
1010 // If the current window has a close button... |
2685
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
1011 if (count > 1 && index > 0 && index < count && (windowStyles[index] and 1) == 1) { |
2670
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
1012 // Send the DW_SIGNAL_DELETE to the event handler |
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
1013 eventHandlerSimple(adapter.viewList[index], DWEvent.DELETE) |
2668
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1014 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1015 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1016 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1017 |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1018 // These are the Android calls to actually create the UI... |
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1019 // forwarded from the C Dynamic Windows API |
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1020 |
2551
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1021 fun darkModeDetected(): Int |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1022 { |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1023 return darkMode |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1024 } |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1025 |
2607
3b9bbd69bb9c
Android: Implement dw_menu_popup() ... still need to implement the context events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2596
diff
changeset
|
1026 fun menuPopup(menu: DWMenu, parent: View, x: Int, y: Int) |
3b9bbd69bb9c
Android: Implement dw_menu_popup() ... still need to implement the context events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2596
diff
changeset
|
1027 { |
2614
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
1028 var anchor: View? = parent |
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
1029 |
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
1030 // If lastClickView is valid, use that instead of parent |
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
1031 if(lastClickView != null) { |
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
1032 anchor = lastClickView |
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
1033 } |
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
1034 |
2607
3b9bbd69bb9c
Android: Implement dw_menu_popup() ... still need to implement the context events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2596
diff
changeset
|
1035 runOnUiThread { |
2614
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
1036 val popup = PopupMenu(this, anchor) |
2607
3b9bbd69bb9c
Android: Implement dw_menu_popup() ... still need to implement the context events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2596
diff
changeset
|
1037 |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1038 menu.createMenu(popup.menu, false) |
2607
3b9bbd69bb9c
Android: Implement dw_menu_popup() ... still need to implement the context events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2596
diff
changeset
|
1039 popup.show() |
3b9bbd69bb9c
Android: Implement dw_menu_popup() ... still need to implement the context events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2596
diff
changeset
|
1040 } |
3b9bbd69bb9c
Android: Implement dw_menu_popup() ... still need to implement the context events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2596
diff
changeset
|
1041 } |
3b9bbd69bb9c
Android: Implement dw_menu_popup() ... still need to implement the context events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2596
diff
changeset
|
1042 |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1043 fun menuBarNew(location: View): DWMenu? |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1044 { |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1045 var menuBar: DWMenu? = null |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1046 |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1047 if(windowLayout != null) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1048 waitOnUiThread { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1049 val adapter: DWTabViewPagerAdapter = windowLayout!!.adapter as DWTabViewPagerAdapter |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1050 val index = adapter.viewList.indexOf(location) |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1051 |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1052 if (index != -1) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1053 menuBar = DWMenu() |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1054 windowMenuBars[index] = menuBar |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1055 } |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1056 } |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1057 } |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1058 return menuBar |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1059 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1060 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1061 fun menuNew(cid: Int): DWMenu |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1062 { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1063 val menu = DWMenu() |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1064 menu.id = cid |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1065 return menu |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1066 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1067 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1068 fun menuAppendItem(menu: DWMenu, title: String, cid: Int, flags: Int, end: Int, check: Int, submenu: DWMenu?): DWMenuItem |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1069 { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1070 val menuitem = DWMenuItem() |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1071 menuitem.id = cid |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1072 menuitem.title = title |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1073 menuitem.check = check != 0 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1074 if(submenu != null) { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1075 menuitem.submenu = submenu |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1076 } |
2546
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1077 if((flags and (1 shl 1)) != 0) { |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1078 menuitem.enabled = false |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1079 } |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1080 if((flags and (1 shl 2)) != 0) { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1081 menuitem.checked = true |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1082 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1083 if(end == 0) { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1084 menu.children.add(0, menuitem) |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1085 } else { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1086 menu.children.add(menuitem) |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1087 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1088 return menuitem |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1089 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1090 |
2545
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1091 fun menuDestroy(menu: DWMenu) |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1092 { |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1093 menu.children.clear() |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1094 runOnUiThread { |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1095 menu.menu!!.clear() |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1096 invalidateOptionsMenu() |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1097 } |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1098 } |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1099 |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1100 fun menuDeleteItem(menu: DWMenu, cid: Int) |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1101 { |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1102 for(menuitem in menu.children) { |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1103 if(menuitem.id == cid) { |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1104 menu.children.remove(menuitem) |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1105 runOnUiThread { |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1106 menu.menu!!.removeItem(menuitem.id) |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1107 invalidateOptionsMenu() |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1108 } |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1109 } |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1110 } |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1111 } |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1112 |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1113 fun menuSetState(menu: DWMenu, cid: Int, state: Int) |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1114 { |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1115 for(menuitem in menu.children) { |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1116 if(menuitem.id == cid) { |
2546
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1117 // Handle DW_MIS_ENABLED/DISABLED |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1118 if((state and (1 or (1 shl 1))) != 0) { |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
1119 var enabled = false |
2546
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1120 |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1121 // Handle DW_MIS_ENABLED |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1122 if ((state and 1) != 0) { |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1123 enabled = true |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1124 } |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1125 menuitem.enabled = enabled |
2642
3edc64443b71
Android: Fix a null pointer exception in the menu code running HandyFTP on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2637
diff
changeset
|
1126 if(menuitem.menuitem != null) { |
3edc64443b71
Android: Fix a null pointer exception in the menu code running HandyFTP on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2637
diff
changeset
|
1127 runOnUiThread { |
3edc64443b71
Android: Fix a null pointer exception in the menu code running HandyFTP on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2637
diff
changeset
|
1128 menuitem.menuitem!!.isEnabled = enabled |
3edc64443b71
Android: Fix a null pointer exception in the menu code running HandyFTP on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2637
diff
changeset
|
1129 invalidateOptionsMenu() |
3edc64443b71
Android: Fix a null pointer exception in the menu code running HandyFTP on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2637
diff
changeset
|
1130 } |
2546
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1131 } |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1132 } |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1133 |
2545
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1134 // Handle DW_MIS_CHECKED/UNCHECKED |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1135 if((state and ((1 shl 2) or (1 shl 3))) != 0) { |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
1136 var checked = false |
2545
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1137 |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1138 // Handle DW_MIS_CHECKED |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1139 if ((state and (1 shl 2)) != 0) { |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1140 checked = true |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1141 } |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1142 menuitem.checked = checked |
2642
3edc64443b71
Android: Fix a null pointer exception in the menu code running HandyFTP on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2637
diff
changeset
|
1143 if(menuitem.menuitem != null) { |
3edc64443b71
Android: Fix a null pointer exception in the menu code running HandyFTP on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2637
diff
changeset
|
1144 runOnUiThread { |
3edc64443b71
Android: Fix a null pointer exception in the menu code running HandyFTP on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2637
diff
changeset
|
1145 menuitem.menuitem!!.isChecked = checked |
3edc64443b71
Android: Fix a null pointer exception in the menu code running HandyFTP on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2637
diff
changeset
|
1146 invalidateOptionsMenu() |
3edc64443b71
Android: Fix a null pointer exception in the menu code running HandyFTP on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2637
diff
changeset
|
1147 } |
2545
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1148 } |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1149 } |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1150 } |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1151 } |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1152 } |
f803f3b164cf
Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2544
diff
changeset
|
1153 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1154 fun windowNew(title: String, style: Int): LinearLayout? { |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1155 var window: LinearLayout? = null |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1156 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1157 if(windowLayout != null) { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1158 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1159 val dataArrayMap = SimpleArrayMap<String, Long>() |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1160 val adapter: DWTabViewPagerAdapter = windowLayout!!.adapter as DWTabViewPagerAdapter |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1161 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1162 setContentView(windowLayout) |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1163 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1164 window = LinearLayout(this) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1165 window!!.visibility = View.GONE |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1166 window!!.tag = dataArrayMap |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1167 window!!.layoutParams = |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1168 LinearLayout.LayoutParams( |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1169 LinearLayout.LayoutParams.MATCH_PARENT, |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1170 LinearLayout.LayoutParams.MATCH_PARENT |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1171 ) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1172 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1173 // Update our window list |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1174 adapter.viewList.add(window!!) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1175 windowTitles.add(title) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1176 windowMenuBars.add(null) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1177 windowStyles.add(style) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1178 windowDefault.add(null) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1179 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1180 // If this is our first/only window... |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1181 // We can set stuff immediately |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1182 if (adapter.viewList.count() == 1) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1183 this.title = title |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1184 windowLayout!!.setCurrentItem(0, false) |
2670
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
1185 if((windowStyles[0] and 2) != 2) { |
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
1186 supportActionBar?.hide() |
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
1187 } |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
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 } |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1190 } |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1191 return window |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1192 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1193 |
2582
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1194 fun windowSetFocus(window: View) |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1195 { |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1196 waitOnUiThread { |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1197 window.requestFocus() |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1198 } |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1199 } |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1200 |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1201 fun windowDefault(window: View, default: View) |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1202 { |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1203 if(windowLayout != null) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1204 val adapter: DWTabViewPagerAdapter = windowLayout!!.adapter as DWTabViewPagerAdapter |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1205 val index = adapter.viewList.indexOf(window) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1206 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1207 if (index != -1) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1208 windowDefault[index] = default |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1209 } |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1210 } |
2582
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1211 } |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1212 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1213 fun windowSetStyle(window: View, style: Int, mask: Int) |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1214 { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1215 waitOnUiThread { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1216 if (window is TextView && window !is EditText) { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1217 val ourmask = (Gravity.HORIZONTAL_GRAVITY_MASK or Gravity.VERTICAL_GRAVITY_MASK) and mask |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1218 |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1219 if (ourmask != 0) { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1220 // Gravity with the masked parts zeroed out |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1221 val newgravity = style and ourmask |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1222 |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1223 window.gravity = newgravity |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1224 } |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1225 } |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1226 } |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1227 } |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1228 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1229 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
|
1230 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
|
1231 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1232 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1233 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
|
1234 if (window.tag != null) { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1235 val dataArrayMap: SimpleArrayMap<String, Long> = window.tag as 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
|
1236 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1237 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
|
1238 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
|
1239 } else { |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1240 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
|
1241 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1242 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1243 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1244 |
2686
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1245 fun windowGetPreferredSize(window: View): Long |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1246 { |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1247 var retval: Long = 0 |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1248 |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1249 waitOnUiThread { |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1250 window.measure(0, 0) |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1251 val width = window.measuredWidth |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1252 val height = window.measuredHeight |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1253 retval = width.toLong() or (height.toLong() shl 32) |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1254 if(window is SeekBar) { |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1255 val slider = window as SeekBar |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1256 |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1257 // If the widget is rotated, swap width and height |
2687
42ff9d95e87b
Android: Fix the logic error, had height and width reversed in bitfields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2686
diff
changeset
|
1258 if(slider.rotation == 270F || slider.rotation == 90F) { |
2686
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1259 retval = height.toLong() or (width.toLong() shl 32) |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1260 } |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1261 } |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1262 } |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1263 return retval |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1264 } |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1265 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1266 fun windowGetData(window: View, name: String): Long { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
1267 var retval = 0L |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1268 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1269 if (window.tag != null) { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1270 val dataArrayMap: SimpleArrayMap<String, Long> = window.tag as 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
|
1271 |
2557
756331246f94
Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2556
diff
changeset
|
1272 if(dataArrayMap.containsKey(name)) { |
756331246f94
Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2556
diff
changeset
|
1273 retval = dataArrayMap.get(name)!! |
756331246f94
Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2556
diff
changeset
|
1274 } |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1275 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1276 return retval |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1277 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1278 |
2492
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 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
|
1280 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1281 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
|
1282 } |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
1283 } |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1284 |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1285 fun typefaceFromFontName(fontname: String?): Typeface? |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1286 { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1287 if(fontname != null) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1288 val bold: Boolean = fontname.contains(" Bold") |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1289 val italic: Boolean = fontname.contains(" Italic") |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1290 val font = fontname.substringAfter('.') |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1291 var fontFamily = font |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
1292 val typeface: Typeface? |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1293 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1294 if (bold) { |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1295 fontFamily = font.substringBefore(" Bold") |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1296 } else if (italic) { |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1297 fontFamily = font.substringBefore(" Italic") |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1298 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1299 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1300 var style: Int = Typeface.NORMAL |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1301 if (bold && italic) { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1302 style = Typeface.BOLD_ITALIC |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1303 } else if (bold) { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1304 style = Typeface.BOLD |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1305 } else if (italic) { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1306 style = Typeface.ITALIC |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1307 } |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1308 typeface = Typeface.create(fontFamily, style) |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1309 |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1310 return typeface |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1311 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1312 return Typeface.DEFAULT |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1313 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1314 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1315 fun windowSetFont(window: View, fontname: String?) { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
1316 val typeface: Typeface? = typefaceFromFontName(fontname) |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1317 var size: Float? = null |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1318 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1319 if(fontname != null) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1320 size = fontname.substringBefore('.').toFloatOrNull() |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1321 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1322 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1323 if(typeface != null) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1324 waitOnUiThread { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1325 if (window is TextView) { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1326 val textview: TextView = window |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1327 textview.typeface = typeface |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1328 if(size != null) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1329 textview.textSize = size |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1330 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1331 } else if (window is Button) { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1332 val button: Button = window |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1333 button.typeface = typeface |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1334 if(size != null) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1335 button.textSize = size |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1336 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1337 } else if(window is DWRender) { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1338 val render: DWRender = window |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1339 render.typeface = typeface |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1340 if(size != null) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1341 render.fontsize = size |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1342 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1343 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1344 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1345 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1346 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1347 |
2582
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1348 fun windowGetFont(window: View): String? |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1349 { |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1350 var fontname: String? = null |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1351 |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1352 waitOnUiThread { |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1353 var typeface: Typeface? = null |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1354 var fontsize: Float? = null |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1355 |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1356 if(window is DWRender) { |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1357 typeface = window.typeface |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1358 fontsize = window.fontsize |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1359 } else if(window is TextView) { |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1360 typeface = window.typeface |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1361 fontsize = window.textSize |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1362 } else if(window is Button) { |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1363 typeface = window.typeface |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1364 fontsize = window.textSize |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1365 } |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1366 |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1367 if(typeface != null && fontsize != null) { |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1368 val isize = fontsize.toInt() |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1369 val name = typeface.toString() |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1370 |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1371 fontname = "$isize.$name" |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1372 } |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1373 } |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1374 return null |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1375 } |
01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2581
diff
changeset
|
1376 |
2551
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1377 fun windowSetColor(window: View, fore: Int, falpha: Int, fred: Int, fgreen: Int, fblue: Int, |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1378 back: Int, balpha: Int, bred: Int, bgreen: Int, bblue: Int) { |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1379 var colorfore: Int = Color.rgb(fred, fgreen, fblue) |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1380 var colorback: Int = Color.rgb(bred, bgreen, bblue) |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1381 |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1382 // DW_CLR_DEFAULT on background sets it transparent... |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1383 // so the background drawable shows through |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1384 if(back == 16) { |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1385 colorback = Color.TRANSPARENT |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1386 } |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1387 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1388 waitOnUiThread { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1389 if (window is TextView) { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1390 val textview: TextView = window |
2551
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1391 |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1392 // Handle DW_CLR_DEFAULT |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1393 if(fore == 16) { |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1394 val value = TypedValue() |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1395 this.theme.resolveAttribute(R.attr.editTextColor, value, true) |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1396 colorfore = value.data |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1397 } |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1398 textview.setTextColor(colorfore) |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1399 textview.setBackgroundColor(colorback) |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1400 } else if (window is Button) { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1401 val button: Button = window |
2551
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1402 |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1403 // Handle DW_CLR_DEFAULT |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1404 if(fore == 16) { |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1405 val value = TypedValue() |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1406 this.theme.resolveAttribute(R.attr.colorButtonNormal, value, true) |
2551
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1407 colorfore = value.data |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1408 } |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1409 button.setTextColor(colorfore) |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1410 button.setBackgroundColor(colorback) |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1411 } else if(window is LinearLayout) { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1412 val box: LinearLayout = window |
2551
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1413 |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1414 box.setBackgroundColor(colorback) |
2677
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1415 } else if(window is DWListBox) { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1416 val listbox = window as DWListBox |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1417 |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1418 // Handle DW_CLR_DEFAULT |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1419 if(fore == 16) { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1420 val value = TypedValue() |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1421 this.theme.resolveAttribute(R.attr.editTextColor, value, true) |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1422 colorfore = value.data |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1423 } |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1424 |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1425 listbox.colorFore = colorfore |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1426 listbox.colorBack = colorback |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1427 |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1428 listbox.setBackgroundColor(colorback) |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1429 } else if(window is ListView) { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1430 val cont = window as ListView |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1431 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1432 |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1433 // Handle DW_CLR_DEFAULT |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1434 if(fore == 16) { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1435 val value = TypedValue() |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1436 this.theme.resolveAttribute(R.attr.editTextColor, value, true) |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1437 colorfore = value.data |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1438 } |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1439 |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1440 adapter.foreColor = colorfore |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1441 adapter.backColor = colorback |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1442 |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1443 cont.setBackgroundColor(colorback) |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1444 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1445 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1446 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1447 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1448 fun windowSetText(window: View, text: String) { |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1449 if(windowLayout != null) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1450 waitOnUiThread { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1451 if (window is TextView) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1452 val textview: TextView = window |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1453 textview.text = text |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1454 } else if (window is Button) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1455 val button: Button = window |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1456 button.text = text |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1457 } else if (window is LinearLayout) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1458 val adapter: DWTabViewPagerAdapter = windowLayout!!.adapter as DWTabViewPagerAdapter |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1459 val index = adapter.viewList.indexOf(window) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1460 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1461 if(index != -1) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1462 windowTitles[index] = text |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1463 if(index == windowLayout!!.currentItem) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1464 this.title = text |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1465 } |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1466 } |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1467 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1468 } |
2489
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1469 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1470 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1471 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1472 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
|
1473 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
|
1474 |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1475 if(windowLayout != null) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1476 waitOnUiThread { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1477 if (window is TextView) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1478 val textview: TextView = window |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1479 text = textview.text.toString() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1480 } else if (window is Button) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1481 val button: Button = window |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1482 text = button.text.toString() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1483 } else if (window is LinearLayout) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1484 val adapter: DWTabViewPagerAdapter = windowLayout!!.adapter as DWTabViewPagerAdapter |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1485 val index = adapter.viewList.indexOf(window) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1486 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1487 if(index != -1) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1488 text = windowTitles[index] |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1489 } |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1490 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1491 } |
2489
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1492 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1493 return text |
2489
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1494 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1495 |
2667
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1496 private fun windowSwitchWindow(index: Int) |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1497 { |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1498 val adapter: DWTabViewPagerAdapter = windowLayout!!.adapter as DWTabViewPagerAdapter |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1499 |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1500 if (index != -1) { |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1501 val window = adapter.viewList[index] as View |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1502 |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1503 // Only allow a window to become active if it is shown |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1504 if(window.visibility == View.VISIBLE) { |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1505 // Update the action bar title |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1506 this.title = windowTitles[index] |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1507 // Switch the visible view in the pager |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1508 if(adapter.recyclerView != null) { |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1509 adapter.recyclerView!!.scrollToPosition(index) |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1510 } |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1511 // This is how I prefered to do it, but it doesn't work... |
2669
2ad924c6493d
Android: Still need to call setCurrentItem() on ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2668
diff
changeset
|
1512 // So using RecyclerView.scrollToPosition() also |
2ad924c6493d
Android: Still need to call setCurrentItem() on ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2668
diff
changeset
|
1513 windowLayout!!.setCurrentItem(index, true) |
2667
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1514 |
2670
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
1515 // Hide or show the actionbar based on the titlebar flag |
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
1516 if((windowStyles[index] and 2) == 2) { |
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
1517 supportActionBar?.show() |
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
1518 } else { |
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
1519 supportActionBar?.hide() |
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
1520 } |
2667
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1521 // If the new view has a default item, focus it |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1522 if(windowDefault[index] != null) { |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1523 windowDefault[index]?.requestFocus() |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1524 } |
2668
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1525 // Add or remove a back button depending on the visible window |
2670
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
1526 if(index > 0 && (windowStyles[index] and 1) == 1) { |
2668
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1527 this.actionBar?.setDisplayHomeAsUpEnabled(true) |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1528 } else { |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1529 this.actionBar?.setDisplayHomeAsUpEnabled(false) |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1530 } |
2667
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1531 // Invalidate the menu, so it gets updated for the new window |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1532 invalidateOptionsMenu() |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1533 } |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1534 } |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1535 } |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1536 |
2503
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
1537 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
|
1538 { |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1539 if(windowLayout != null) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1540 waitOnUiThread { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1541 val adapter: DWTabViewPagerAdapter = windowLayout!!.adapter as DWTabViewPagerAdapter |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1542 val index = adapter.viewList.indexOf(window) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1543 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1544 if(state == 0) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1545 window.visibility = View.GONE |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1546 } else { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1547 window.visibility = View.VISIBLE |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1548 } |
2667
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1549 windowSwitchWindow(index) |
2503
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
1550 } |
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
1551 } |
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
1552 } |
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
1553 |
2668
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1554 fun windowDestroy(window: View): Int { |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1555 var retval: Int = 1 // DW_ERROR_GENERAL |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1556 |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1557 if(windowLayout != null) { |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1558 waitOnUiThread { |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1559 val adapter: DWTabViewPagerAdapter = windowLayout!!.adapter as DWTabViewPagerAdapter |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1560 val index = adapter.viewList.indexOf(window) |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1561 |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1562 // We need to have at least 1 window... |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1563 // so only destroy secondary windows |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1564 if(index > 0) { |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1565 val newindex = index - 1 |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1566 val newwindow = adapter.viewList[newindex] |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1567 |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1568 // Make sure the previous window is visible... |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1569 // not sure if we should search the list for a visible |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1570 // window or force it visible. Forcing visible for now. |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1571 if(newwindow.visibility != View.VISIBLE) { |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1572 newwindow.visibility = View.VISIBLE |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1573 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1574 // Switch to the previous window |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1575 windowSwitchWindow(newindex) |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1576 |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1577 // Update our window list |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1578 adapter.viewList.removeAt(index) |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1579 windowTitles.removeAt(index) |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1580 windowMenuBars.removeAt(index) |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1581 windowStyles.removeAt(index) |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1582 windowDefault.removeAt(index) |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1583 |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1584 retval = 0 // DW_ERROR_NONE |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1585 } else { |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1586 // If we are removing an individual widget, |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1587 // find the parent layout and remove it. |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1588 if(window.parent is ViewGroup) { |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1589 val group = window.parent as ViewGroup |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1590 |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1591 group.removeView(window) |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1592 retval = 0 // DW_ERROR_NONE |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1593 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1594 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1595 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1596 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1597 return retval |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1598 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1599 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1600 fun clipboardGetText(): String { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1601 val cm: ClipboardManager = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1602 val clipdata = cm.primaryClip |
2489
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1603 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1604 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
|
1605 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
|
1606 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1607 return "" |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1608 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1609 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1610 fun clipboardSetText(text: String) { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1611 val cm: ClipboardManager = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1612 val clipdata = ClipData.newPlainText("text", text) |
2489
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1613 |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1614 cm.setPrimaryClip(clipdata) |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1615 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1616 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1617 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
|
1618 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
|
1619 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1620 box = LinearLayout(this) |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1621 val 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
|
1622 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1623 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
|
1624 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
|
1625 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
|
1626 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
|
1627 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
|
1628 ) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1629 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
|
1630 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
|
1631 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1632 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
|
1633 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1634 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
|
1635 } |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
1636 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
|
1637 } |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
1638 |
2689
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1639 fun groupBoxNew(type: Int, pad: Int, title: String?): LinearLayout? { |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1640 var box: LinearLayout? = null |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1641 waitOnUiThread { |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1642 box = RadioGroup(this) |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1643 val dataArrayMap = SimpleArrayMap<String, Long>() |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1644 |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1645 box!!.tag = dataArrayMap |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1646 box!!.layoutParams = |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1647 LinearLayout.LayoutParams( |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1648 LinearLayout.LayoutParams.WRAP_CONTENT, |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1649 LinearLayout.LayoutParams.WRAP_CONTENT |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1650 ) |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1651 if (type > 0) { |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1652 box!!.orientation = LinearLayout.VERTICAL |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1653 } else { |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1654 box!!.orientation = LinearLayout.HORIZONTAL |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1655 } |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1656 box!!.setPadding(pad, pad, pad, pad) |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1657 } |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1658 return box |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1659 } |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1660 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1661 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
|
1662 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
|
1663 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1664 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1665 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
|
1666 scrollBox = ScrollView(this) |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1667 val dataArrayMap = SimpleArrayMap<String, Long>() |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1668 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1669 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
|
1670 box.layoutParams = |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1671 LinearLayout.LayoutParams( |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1672 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
|
1673 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
|
1674 ) |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1675 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
|
1676 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
|
1677 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1678 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
|
1679 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1680 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
|
1681 // 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
|
1682 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
|
1683 scrollBox!!.addView(box) |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1684 } |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1685 return scrollBox |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1686 } |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1687 |
2683
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1688 // Update the layoutParams of a box after a change |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1689 private fun boxUpdate(box: LinearLayout) |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1690 { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1691 val parent = box.parent |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1692 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1693 if(parent is LinearLayout) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1694 val params = box.layoutParams as LinearLayout.LayoutParams |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1695 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1696 if(parent.orientation == LinearLayout.VERTICAL) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1697 if(params.height == 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1698 box.measure(0, 0) |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1699 val calch = box.measuredHeight |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1700 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1701 if(calch > 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1702 params.weight = calch.toFloat() |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1703 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1704 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1705 } else { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1706 if(params.width == 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1707 box.measure(0, 0) |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1708 val calcw = box.measuredWidth |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1709 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1710 if(calcw > 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1711 params.weight = calcw.toFloat() |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1712 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1713 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1714 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1715 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1716 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1717 |
2495
5664c91d03fb
Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2494
diff
changeset
|
1718 fun boxPack( |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1719 boxview: View, |
2675
a7868380098f
Android: LinearLayout does not allow null views, if null, create a Placeholder view.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2670
diff
changeset
|
1720 packitem: 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
|
1721 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
|
1722 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
|
1723 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
|
1724 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
|
1725 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
|
1726 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
|
1727 ) { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1728 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1729 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
|
1730 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
|
1731 var box: LinearLayout? = null |
2675
a7868380098f
Android: LinearLayout does not allow null views, if null, create a Placeholder view.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2670
diff
changeset
|
1732 var item: View? = packitem |
a7868380098f
Android: LinearLayout does not allow null views, if null, create a Placeholder view.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2670
diff
changeset
|
1733 |
a7868380098f
Android: LinearLayout does not allow null views, if null, create a Placeholder view.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2670
diff
changeset
|
1734 // We can't pack nothing, so create an empty placeholder to pack |
a7868380098f
Android: LinearLayout does not allow null views, if null, create a Placeholder view.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2670
diff
changeset
|
1735 if(item == null) { |
2688
c359cbd0b20f
Android: Revert the change from Placeholder to View since it didn't solve the problem.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2687
diff
changeset
|
1736 item = Placeholder(this) |
c359cbd0b20f
Android: Revert the change from Placeholder to View since it didn't solve the problem.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2687
diff
changeset
|
1737 item.emptyVisibility = View.VISIBLE |
2675
a7868380098f
Android: LinearLayout does not allow null views, if null, create a Placeholder view.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2670
diff
changeset
|
1738 } |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
1739 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1740 // 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
|
1741 // 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
|
1742 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
|
1743 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
|
1744 } else if (boxview is ScrollView) { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1745 val sv: ScrollView = boxview |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1746 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1747 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
|
1748 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
|
1749 } |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1750 } |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1751 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1752 if (box != null) { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
1753 var weight = 1F |
2553
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1754 |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1755 // If it is a box, match parent based on direction |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1756 if ((item is LinearLayout) || (item is ScrollView)) { |
2683
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1757 item.measure(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
|
1758 if (box.orientation == LinearLayout.VERTICAL) { |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1759 if (hsize != 0) { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1760 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
|
1761 } |
2683
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1762 if (vsize != 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1763 val calch = item.measuredHeight |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1764 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1765 if(calch > 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1766 weight = calch.toFloat() |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1767 } else { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1768 weight = 1F |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1769 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1770 h = 0 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1771 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1772 } else { |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1773 if (vsize != 0) { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1774 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
|
1775 } |
2683
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1776 if (hsize != 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1777 val calcw = item.measuredWidth |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1778 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1779 if(calcw > 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1780 weight = calcw.toFloat() |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1781 } else { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1782 weight = 1F |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1783 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1784 w = 0 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1785 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1786 } |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1787 // If it isn't a box... set or calculate the size as needed |
2553
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1788 } else { |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1789 if(width != -1 || height != -1) { |
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1790 item.measure(0, 0) |
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1791 } |
2553
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1792 if(hsize == 0) { |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1793 if (width > 0) { |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1794 w = width |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1795 } |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1796 } else { |
2575
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1797 if (box.orientation == LinearLayout.VERTICAL) { |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1798 w = LinearLayout.LayoutParams.MATCH_PARENT |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1799 } else { |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1800 if (width > 0) { |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1801 weight = width.toFloat() |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1802 } else if (width == -1) { |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1803 val newwidth = item.getMeasuredWidth() |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1804 |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1805 if (newwidth > 0) { |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1806 weight = newwidth.toFloat() |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1807 } |
2553
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1808 } |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1809 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1810 } |
2553
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1811 if(vsize == 0) { |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1812 if (height > 0) { |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1813 h = height |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1814 } |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1815 } else { |
2575
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1816 if (box.orientation == LinearLayout.HORIZONTAL) { |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1817 h = LinearLayout.LayoutParams.MATCH_PARENT |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1818 } else { |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1819 if (height > 0) { |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1820 weight = height.toFloat() |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1821 } else if (height == -1) { |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1822 val newheight = item.getMeasuredHeight() |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1823 |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1824 if (newheight > 0) { |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1825 weight = newheight.toFloat() |
5beaaa4e9b03
Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2574
diff
changeset
|
1826 } |
2553
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1827 } |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1828 } |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1829 } |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1830 } |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1831 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1832 val params: LinearLayout.LayoutParams = LinearLayout.LayoutParams(w, h) |
2553
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1833 |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1834 // Handle expandable items by giving them a weight... |
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1835 // in the direction of the box. |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1836 if (box.orientation == LinearLayout.VERTICAL) { |
2681
c1482518b643
Android: Fix weight based layout problems.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2677
diff
changeset
|
1837 if (vsize != 0 && weight > 0F) { |
2553
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1838 params.weight = weight |
2681
c1482518b643
Android: Fix weight based layout problems.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2677
diff
changeset
|
1839 params.height = 0 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1840 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1841 } else { |
2681
c1482518b643
Android: Fix weight based layout problems.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2677
diff
changeset
|
1842 if (hsize != 0 && weight > 0F) { |
2553
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1843 params.weight = weight |
2681
c1482518b643
Android: Fix weight based layout problems.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2677
diff
changeset
|
1844 params.width = 0 |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1845 } |
2480
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
1846 } |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1847 // Gravity needs to match the expandable settings |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1848 val grav: Int = Gravity.CLIP_HORIZONTAL or Gravity.CLIP_VERTICAL |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1849 if (hsize != 0 && vsize != 0) { |
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1850 params.gravity = Gravity.FILL or grav |
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1851 } else if (hsize != 0) { |
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1852 params.gravity = Gravity.FILL_HORIZONTAL or grav |
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1853 } else if (vsize != 0) { |
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1854 params.gravity = Gravity.FILL_VERTICAL or grav |
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1855 } |
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1856 // Finally add the padding |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1857 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
|
1858 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
|
1859 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1860 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
|
1861 box.addView(item, index) |
2683
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1862 boxUpdate(box) |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1863 } |
2478
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
1864 } |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
1865 } |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
1866 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1867 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
|
1868 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1869 val box: LinearLayout = item.parent as LinearLayout |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1870 box.removeView(item) |
2683
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1871 boxUpdate(box) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1872 } |
2477
3fbf8783122d
Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2476
diff
changeset
|
1873 } |
3fbf8783122d
Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2476
diff
changeset
|
1874 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1875 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
|
1876 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
|
1877 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1878 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1879 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
|
1880 box.removeView(item) |
2683
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1881 boxUpdate(box) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1882 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1883 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
|
1884 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1885 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1886 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
|
1887 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
|
1888 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1889 button = Button(this) |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1890 val 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
|
1891 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1892 button!!.tag = dataArrayMap |
2590
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
1893 button!!.isAllCaps = false |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1894 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
|
1895 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
|
1896 button!!.setOnClickListener { |
2614
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
1897 lastClickView = button!! |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
1898 eventHandlerSimple(button!!, DWEvent.CLICKED) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1899 } |
2482
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
1900 } |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
1901 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
|
1902 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
1903 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1904 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
|
1905 var button: ImageButton? = null |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1906 waitOnUiThread { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1907 button = ImageButton(this) |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1908 val dataArrayMap = SimpleArrayMap<String, Long>() |
2653
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1909 var filename: String? = null |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1910 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1911 button!!.tag = dataArrayMap |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1912 button!!.id = resid |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1913 button!!.setOnClickListener { |
2614
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
1914 lastClickView = button!! |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
1915 eventHandlerSimple(button!!, DWEvent.CLICKED) |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1916 } |
2653
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1917 |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1918 if(resid > 0 && resid < 65536) { |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1919 filename = resid.toString() |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
1920 } else { |
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
1921 button!!.setImageResource(resid) |
2653
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1922 } |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1923 |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1924 if(filename != null) { |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
1925 for (ext in DWImageExts) { |
2653
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1926 // Try to load the image, and protect against exceptions |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1927 try { |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1928 val f = this.assets.open(filename + ext) |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1929 val b = BitmapFactory.decodeStream(f) |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1930 |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1931 if (b != null) { |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1932 button!!.setImageBitmap(b) |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1933 break |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1934 } |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1935 } catch (e: IOException) { |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1936 } |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1937 } |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1938 } |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1939 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1940 return button |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1941 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1942 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1943 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
|
1944 var button: ImageButton? = null |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1945 waitOnUiThread { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1946 button = ImageButton(this) |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1947 val dataArrayMap = SimpleArrayMap<String, Long>() |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1948 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1949 button!!.tag = dataArrayMap |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1950 button!!.id = cid |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1951 button!!.setOnClickListener { |
2614
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
1952 lastClickView = button!! |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
1953 eventHandlerSimple(button!!, DWEvent.CLICKED) |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1954 } |
2564
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
1955 |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
1956 for (ext in DWImageExts) { |
2564
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
1957 // Try to load the image, and protect against exceptions |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
1958 try { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
1959 val f = this.assets.open(filename + ext) |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
1960 val b = BitmapFactory.decodeStream(f) |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
1961 |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
1962 if(b != null) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
1963 button!!.setImageBitmap(b) |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
1964 break |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
1965 } |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
1966 } catch (e: IOException) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
1967 } |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1968 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1969 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1970 return button |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1971 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1972 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1973 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
|
1974 var button: ImageButton? = null |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1975 waitOnUiThread { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1976 button = ImageButton(this) |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1977 val dataArrayMap = SimpleArrayMap<String, Long>() |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1978 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
|
1979 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1980 button!!.tag = dataArrayMap |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1981 button!!.id = cid |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1982 button!!.setOnClickListener { |
2614
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
1983 lastClickView = button!! |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
1984 eventHandlerSimple(button!!, DWEvent.CLICKED) |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1985 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1986 button!!.setImageBitmap(b) |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1987 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1988 return button |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1989 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1990 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1991 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
|
1992 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
|
1993 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1994 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1995 val dataArrayMap = SimpleArrayMap<String, Long>() |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1996 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
|
1997 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1998 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
|
1999 entryfield!!.id = cid |
2554
4c75fb6089a9
Android: Need to set isSingleLine for entryfields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2553
diff
changeset
|
2000 entryfield!!.isSingleLine = true |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2001 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
|
2002 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
|
2003 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2004 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
|
2005 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
2006 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
|
2007 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
2008 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2009 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
|
2010 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2011 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
|
2012 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2013 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2014 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2015 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
|
2016 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
|
2017 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2018 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2019 val dataArrayMap = SimpleArrayMap<String, Long>() |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2020 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
|
2021 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2022 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
|
2023 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
|
2024 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
|
2025 radiobutton!!.setOnClickListener { |
2614
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
2026 lastClickView = radiobutton!! |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
2027 eventHandlerSimple(radiobutton!!, DWEvent.CLICKED) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2028 } |
2482
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
2029 } |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
2030 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
|
2031 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
2032 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2033 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
|
2034 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
|
2035 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2036 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2037 val 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
|
2038 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2039 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
|
2040 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
|
2041 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
|
2042 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
|
2043 checkbox!!.setOnClickListener { |
2614
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
2044 lastClickView = checkbox!! |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
2045 eventHandlerSimple(checkbox!!, DWEvent.CLICKED) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2046 } |
2482
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
2047 } |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
2048 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
|
2049 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
2050 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2051 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
|
2052 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2053 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2054 if (control is CheckBox) { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2055 val checkbox: CheckBox = control |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2056 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
|
2057 } else if (control is RadioButton) { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2058 val radiobutton: RadioButton = control |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2059 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
|
2060 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2061 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2062 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2063 |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2064 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
|
2065 { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
2066 var retval = false |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2067 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2068 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2069 if (control is CheckBox) { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2070 val checkbox: CheckBox = control |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2071 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
|
2072 } else if (control is RadioButton) { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2073 val radiobutton: RadioButton = control |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2074 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
|
2075 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2076 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2077 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
|
2078 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2079 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2080 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
|
2081 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
|
2082 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2083 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2084 val 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
|
2085 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2086 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
|
2087 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
|
2088 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
|
2089 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
|
2090 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
|
2091 val border = GradientDrawable() |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
2092 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2093 // 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
|
2094 // 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
|
2095 // 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
|
2096 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
|
2097 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
|
2098 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
|
2099 } |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
2100 } |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
2101 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
|
2102 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
2103 |
2510
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2104 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
|
2105 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2106 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
|
2107 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2108 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2109 val dataArrayMap = SimpleArrayMap<String, Long>() |
2510
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2110 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2111 mle = EditText(this) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2112 mle!!.tag = dataArrayMap |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2113 mle!!.id = cid |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2114 mle!!.isSingleLine = false |
2676
a43cf048ff17
Android: Fix what I thought was a MLE layout issue... but it turns out the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2675
diff
changeset
|
2115 mle!!.maxLines = Integer.MAX_VALUE |
2510
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2116 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
|
2117 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
|
2118 mle!!.isVerticalScrollBarEnabled = true |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2119 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
|
2120 mle!!.setHorizontallyScrolling(true) |
2676
a43cf048ff17
Android: Fix what I thought was a MLE layout issue... but it turns out the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2675
diff
changeset
|
2121 mle!!.isHorizontalScrollBarEnabled = true |
2581
9dea42f27b0a
Android: MLE should have TOP/LEFT gravity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2580
diff
changeset
|
2122 mle!!.gravity = Gravity.TOP or Gravity.LEFT |
2510
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2123 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2124 return mle |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2125 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2126 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2127 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
|
2128 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2129 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2130 if (state != 0) { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2131 mle.setHorizontallyScrolling(false) |
2676
a43cf048ff17
Android: Fix what I thought was a MLE layout issue... but it turns out the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2675
diff
changeset
|
2132 mle.isHorizontalScrollBarEnabled = false |
2510
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2133 } else { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2134 mle.setHorizontallyScrolling(true) |
2676
a43cf048ff17
Android: Fix what I thought was a MLE layout issue... but it turns out the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2675
diff
changeset
|
2135 mle.isHorizontalScrollBarEnabled = true |
2510
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2136 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2137 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2138 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2139 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2140 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
|
2141 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2142 waitOnUiThread { |
2676
a43cf048ff17
Android: Fix what I thought was a MLE layout issue... but it turns out the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2675
diff
changeset
|
2143 mle.isFocusable = state != 0 |
2510
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2144 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2145 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2146 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2147 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
|
2148 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2149 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2150 mle.setSelection(point) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2151 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2152 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2153 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2154 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
|
2155 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2156 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2157 mle.setText("") |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2158 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2159 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2160 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2161 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
|
2162 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2163 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
|
2164 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2165 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2166 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
|
2167 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
|
2168 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2169 if(startpoint < 1) { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2170 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
|
2171 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2172 mle.setText(newtext) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2173 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
|
2174 } 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
|
2175 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
|
2176 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2177 mle.setText(newtext) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2178 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
|
2179 } else { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2180 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
|
2181 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2182 mle.setText(newtext) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2183 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
|
2184 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2185 mle.setSelection(retval) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2186 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2187 return retval |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2188 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2189 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2190 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
|
2191 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2192 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2193 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
|
2194 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
|
2195 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2196 mle.setText(newtext) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2197 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2198 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2199 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2200 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
|
2201 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2202 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
|
2203 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2204 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2205 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
|
2206 val tabs = TabLayout(this) |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2207 val w: Int = RelativeLayout.LayoutParams.MATCH_PARENT |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2208 val h: Int = RelativeLayout.LayoutParams.WRAP_CONTENT |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2209 val dataArrayMap = SimpleArrayMap<String, Long>() |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2210 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2211 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
|
2212 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
|
2213 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
|
2214 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
|
2215 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
|
2216 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
|
2217 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
|
2218 // 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
|
2219 }.attach() |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
2220 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2221 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
|
2222 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
|
2223 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
|
2224 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2225 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
|
2226 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2227 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
|
2228 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
|
2229 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
|
2230 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
|
2231 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
|
2232 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
|
2233 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2234 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
|
2235 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2236 notebook!!.addView(pager, params) |
2550
a8d90e2896bc
Android: For the moment disable swiping to change notebook pages.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2547
diff
changeset
|
2237 // TODO: Not sure if we want this all the time... |
a8d90e2896bc
Android: For the moment disable swiping to change notebook pages.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2547
diff
changeset
|
2238 // Might want to make a flag for this |
a8d90e2896bc
Android: For the moment disable swiping to change notebook pages.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2547
diff
changeset
|
2239 pager.isUserInputEnabled = false |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2240 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
|
2241 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
|
2242 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
|
2243 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2244 pager.currentItem = tab.position |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
2245 eventHandlerNotebook(notebook!!, DWEvent.SWITCH_PAGE, adapter.pageList[tab.position]) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2246 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2247 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2248 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
|
2249 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
|
2250 }) |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
2251 } |
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
|
2252 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
|
2253 } |
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
|
2254 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2255 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
|
2256 { |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2257 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
|
2258 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2259 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2260 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
|
2261 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
|
2262 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2263 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
|
2264 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
|
2265 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
|
2266 } 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
|
2267 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
|
2268 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
|
2269 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2270 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2271 if (pager != null && tabs != null) { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2272 val adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2273 val 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
|
2274 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2275 // 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
|
2276 do { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2277 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
|
2278 } 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
|
2279 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
|
2280 // Temporarily add a black tab with an empty layout/box |
2682
856d3c8b559f
Android: Fix an exception when displaying a notebook with a placeholder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2681
diff
changeset
|
2281 val placeholder = LinearLayout(this) |
856d3c8b559f
Android: Fix an exception when displaying a notebook with a placeholder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2681
diff
changeset
|
2282 placeholder.layoutParams = LinearLayout.LayoutParams( |
856d3c8b559f
Android: Fix an exception when displaying a notebook with a placeholder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2681
diff
changeset
|
2283 LinearLayout.LayoutParams.MATCH_PARENT, |
856d3c8b559f
Android: Fix an exception when displaying a notebook with a placeholder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2681
diff
changeset
|
2284 LinearLayout.LayoutParams.MATCH_PARENT |
856d3c8b559f
Android: Fix an exception when displaying a notebook with a placeholder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2681
diff
changeset
|
2285 ) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2286 if (front != 0) { |
2682
856d3c8b559f
Android: Fix an exception when displaying a notebook with a placeholder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2681
diff
changeset
|
2287 adapter.viewList.add(0, placeholder) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2288 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
|
2289 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
|
2290 } else { |
2682
856d3c8b559f
Android: Fix an exception when displaying a notebook with a placeholder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2681
diff
changeset
|
2291 adapter.viewList.add(placeholder) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2292 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
|
2293 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
|
2294 } |
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
|
2295 } |
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
|
2296 } |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2297 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
|
2298 } |
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
|
2299 |
2590
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2300 fun notebookCapsOff(view: View?) { |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2301 if (view !is ViewGroup) { |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2302 return |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2303 } |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2304 for (i in 0 until view.childCount) { |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2305 val child = view.getChildAt(i) |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2306 if (child is TextView) { |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2307 child.isAllCaps = false |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2308 } else { |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2309 notebookCapsOff(child) |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2310 } |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2311 } |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2312 } |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2313 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2314 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
|
2315 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2316 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2317 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
|
2318 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
|
2319 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2320 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
|
2321 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
|
2322 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
|
2323 } 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
|
2324 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
|
2325 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
|
2326 } |
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
|
2327 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2328 if (pager != null && tabs != null) { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2329 val adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2330 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
|
2331 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
|
2332 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2333 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
|
2334 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
|
2335 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
|
2336 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
|
2337 } |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2338 } |
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
|
2339 } |
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
|
2340 } |
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
|
2341 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2342 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
|
2343 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2344 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2345 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
|
2346 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
|
2347 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2348 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
|
2349 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
|
2350 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
|
2351 } 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
|
2352 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
|
2353 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
|
2354 } |
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
|
2355 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2356 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
|
2357 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
|
2358 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
|
2359 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
|
2360 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2361 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
|
2362 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
|
2363 } |
2590
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2364 |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2365 notebookCapsOff(tabs) |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2366 } |
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
|
2367 } |
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
|
2368 } |
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
|
2369 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2370 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
|
2371 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2372 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2373 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
|
2374 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
|
2375 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2376 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
|
2377 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
|
2378 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
|
2379 } 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
|
2380 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
|
2381 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
|
2382 } |
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
|
2383 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2384 if (pager != null && tabs != null) { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2385 val adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2386 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
|
2387 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2388 // 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
|
2389 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
|
2390 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
|
2391 LinearLayout.LayoutParams.MATCH_PARENT |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
2392 ) |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2393 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2394 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
|
2395 } |
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
|
2396 } |
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
|
2397 } |
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
|
2398 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2399 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
|
2400 { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
2401 var retval = 0L |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2402 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2403 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2404 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
|
2405 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
|
2406 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2407 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
|
2408 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
|
2409 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
|
2410 } 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
|
2411 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
|
2412 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
|
2413 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2414 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2415 if (pager != null && tabs != null) { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2416 val adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2417 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
|
2418 } |
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
|
2419 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2420 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
|
2421 } |
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
|
2422 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2423 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
|
2424 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2425 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2426 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
|
2427 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
|
2428 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2429 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
|
2430 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
|
2431 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
|
2432 } 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
|
2433 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
|
2434 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
|
2435 } |
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
|
2436 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2437 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
|
2438 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
|
2439 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
|
2440 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
|
2441 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2442 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
|
2443 } |
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
|
2444 } |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
2445 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
2446 |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2447 fun splitBarNew(type: Int, topleft: View?, bottomright: View?, cid: Int): ConstraintLayout? |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2448 { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2449 var splitbar: ConstraintLayout? = null |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2450 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2451 waitOnUiThread { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2452 splitbar = ConstraintLayout(this) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2453 if(splitbar != null) { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2454 val constraintSet = ConstraintSet() |
2656
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2455 val dataArrayMap = SimpleArrayMap<String, Long>() |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2456 |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2457 constraintSet.clone(splitbar) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2458 |
2656
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2459 splitbar!!.tag = dataArrayMap |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2460 splitbar!!.id = cid |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2461 |
2656
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2462 // Add the special data to the array map |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2463 dataArrayMap.put("_dw_type", type.toLong()) |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2464 dataArrayMap.put("_dw_percent", 50000000L) |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2465 |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2466 // Place the top/left item |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2467 if(topleft != null) { |
2651
7700c8022af3
Android: Unset ID is -1 on Android not 0, so generate a View ID if < 1 not just 0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2650
diff
changeset
|
2468 if(topleft.id < 1) { |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2469 topleft.id = View.generateViewId() |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2470 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2471 splitbar!!.addView(topleft) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2472 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2473 topleft.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2474 ConstraintLayout.LayoutParams.TOP, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2475 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2476 ConstraintLayout.LayoutParams.TOP |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2477 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2478 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2479 topleft.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2480 ConstraintLayout.LayoutParams.LEFT, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2481 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2482 ConstraintLayout.LayoutParams.LEFT |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2483 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2484 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2485 if (type == 0) { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2486 // Horizontal |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2487 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2488 topleft.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2489 ConstraintLayout.LayoutParams.BOTTOM, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2490 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2491 ConstraintLayout.LayoutParams.BOTTOM |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2492 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2493 constraintSet.constrainPercentWidth(topleft.id, 0.5F) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2494 } else { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2495 // Vertical |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2496 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2497 topleft.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2498 ConstraintLayout.LayoutParams.RIGHT, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2499 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2500 ConstraintLayout.LayoutParams.RIGHT |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2501 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2502 constraintSet.constrainPercentHeight(topleft.id, 0.5F) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2503 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2504 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2505 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2506 // Place the bottom/right item |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2507 if(bottomright != null) { |
2651
7700c8022af3
Android: Unset ID is -1 on Android not 0, so generate a View ID if < 1 not just 0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2650
diff
changeset
|
2508 if (bottomright.id < 1) { |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2509 bottomright.id = View.generateViewId() |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2510 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2511 splitbar!!.addView(bottomright) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2512 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2513 bottomright.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2514 ConstraintLayout.LayoutParams.BOTTOM, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2515 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2516 ConstraintLayout.LayoutParams.BOTTOM |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2517 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2518 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2519 bottomright.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2520 ConstraintLayout.LayoutParams.RIGHT, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2521 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2522 ConstraintLayout.LayoutParams.RIGHT |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2523 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2524 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2525 if (type == 0) { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2526 // Horizontal |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2527 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2528 bottomright.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2529 ConstraintLayout.LayoutParams.TOP, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2530 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2531 ConstraintLayout.LayoutParams.TOP |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2532 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2533 constraintSet.constrainPercentWidth(bottomright.id, 0.5F) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2534 } else { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2535 // Vertical |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2536 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2537 bottomright.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2538 ConstraintLayout.LayoutParams.LEFT, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2539 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2540 ConstraintLayout.LayoutParams.LEFT |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2541 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2542 constraintSet.constrainPercentHeight(bottomright.id, 0.5F) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2543 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2544 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2545 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2546 // finally, apply the constraint set to layout |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2547 constraintSet.applyTo(splitbar) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2548 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2549 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2550 return splitbar |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2551 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2552 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2553 fun splitBarGet(splitbar: ConstraintLayout): Float { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2554 var position: Float = 50.0F |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2555 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2556 waitOnUiThread { |
2656
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2557 val dataArrayMap: SimpleArrayMap<String, Long> = splitbar.tag as SimpleArrayMap<String, Long> |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2558 var percent: Long = 50000000L |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2559 |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2560 if(dataArrayMap.containsKey("_dw_percent")) { |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2561 percent = dataArrayMap.get("_dw_percent")!! |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2562 } |
2656
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2563 |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2564 position = percent.toFloat() / 1000000.0F |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2565 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2566 return position |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2567 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2568 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2569 fun splitBarSet(splitbar: ConstraintLayout, position: Float) { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2570 waitOnUiThread { |
2656
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2571 val dataArrayMap: SimpleArrayMap<String, Long> = splitbar.tag as SimpleArrayMap<String, Long> |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2572 var percent: Float = position * 1000000.0F |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2573 |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2574 if(percent > 0F) { |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2575 val topleft: View? = splitbar.getChildAt(0) |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2576 val bottomright: View? = splitbar.getChildAt(1) |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2577 val constraintSet = ConstraintSet() |
2656
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2578 var type: Long = 0L |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2579 |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2580 if (dataArrayMap.containsKey("_dw_type")) { |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2581 type = dataArrayMap.get("_dw_type")!! |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2582 } |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2583 dataArrayMap.put("_dw_percent", percent.toLong()) |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2584 |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2585 constraintSet.clone(splitbar) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2586 if (topleft != null) { |
2656
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2587 if (type == 1L) { |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2588 constraintSet.constrainPercentHeight(topleft.id, position / 100.0F) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2589 } else { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2590 constraintSet.constrainPercentWidth(topleft.id, position / 100.0F) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2591 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2592 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2593 if (bottomright != null) { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2594 val altper: Float = (100.0F - position) / 100.0F |
2656
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2595 if (type == 1L) { |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2596 constraintSet.constrainPercentHeight(bottomright.id, altper) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2597 } else { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2598 constraintSet.constrainPercentWidth(bottomright.id, altper) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2599 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2600 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2601 constraintSet.applyTo(splitbar) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2602 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2603 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2604 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2605 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2606 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
|
2607 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2608 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
|
2609 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2610 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2611 val 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
|
2612 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2613 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
|
2614 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
|
2615 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
|
2616 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
|
2617 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
|
2618 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
|
2619 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2620 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
|
2621 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
|
2622 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2623 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2624 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
|
2625 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2626 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2627 override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
2628 eventHandlerInt(slider as View, DWEvent.VALUE_CHANGED, 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
|
2629 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2630 }) |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2631 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2632 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
|
2633 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2634 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2635 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
|
2636 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2637 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
|
2638 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2639 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2640 val 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
|
2641 |
2574
5b13bb267364
Android: Percent widget should be using horizontal ProgressBar.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2573
diff
changeset
|
2642 percent = ProgressBar(this,null, R.attr.progressBarStyleHorizontal) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2643 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
|
2644 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
|
2645 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
|
2646 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2647 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
|
2648 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2649 |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2650 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
|
2651 { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
2652 var retval = 0 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2653 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2654 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2655 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
|
2656 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2657 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
|
2658 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2659 |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2660 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
|
2661 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2662 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2663 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
|
2664 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2665 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2666 |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2667 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
|
2668 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2669 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2670 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
|
2671 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2672 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2673 |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2674 fun htmlNew(cid: Int): WebView? |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2675 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2676 var html: WebView? = null |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2677 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2678 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2679 val dataArrayMap = SimpleArrayMap<String, Long>() |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2680 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2681 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
|
2682 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
|
2683 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
|
2684 // 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
|
2685 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
|
2686 html!!.settings.javaScriptEnabled = true |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2687 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2688 return html |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2689 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2690 |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2691 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
|
2692 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2693 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2694 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
|
2695 } |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2696 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2697 |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2698 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
|
2699 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2700 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2701 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
|
2702 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
|
2703 } |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2704 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2705 |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2706 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
|
2707 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2708 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2709 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
|
2710 // Execute onReceiveValue's code |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
2711 eventHandlerHTMLResult(html, DWEvent.HTML_RESULT, value, data) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2712 } |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2713 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2714 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2715 |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2716 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
|
2717 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2718 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2719 when (action) { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2720 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
|
2721 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
|
2722 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
|
2723 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
|
2724 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
|
2725 } |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2726 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2727 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2728 |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2729 fun spinButtonNew(text: String, cid: Int): DWSpinButton? |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2730 { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2731 var spinbutton: DWSpinButton? = null |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2732 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2733 waitOnUiThread { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
2734 val dataArrayMap = SimpleArrayMap<String, Long>() |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2735 val newval = text.toLongOrNull() |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2736 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2737 spinbutton = DWSpinButton(this) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2738 spinbutton!!.tag = dataArrayMap |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2739 spinbutton!!.id = cid |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2740 spinbutton!!.setText(text) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2741 if(newval != null) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2742 spinbutton!!.value = newval |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2743 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2744 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2745 return spinbutton |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2746 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2747 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2748 fun spinButtonSetPos(spinbutton: DWSpinButton, position: Long) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2749 { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2750 waitOnUiThread { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2751 spinbutton.value = position |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2752 spinbutton.setText(position.toString()) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2753 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2754 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2755 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2756 fun spinButtonSetLimits(spinbutton: DWSpinButton, upper: Long, lower: Long) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2757 { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2758 waitOnUiThread { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2759 spinbutton.maximum = upper |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2760 spinbutton.minimum = lower |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2761 if(spinbutton.value > upper) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2762 spinbutton.value = upper |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2763 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2764 if(spinbutton.value < lower) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2765 spinbutton.value = lower |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2766 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2767 spinbutton.setText(spinbutton.value.toString()) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2768 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2769 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2770 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2771 fun spinButtonGetPos(spinbutton: DWSpinButton): Long |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2772 { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2773 var retval: Long = 0 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2774 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2775 waitOnUiThread { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2776 val newvalue = spinbutton.text.toString().toLongOrNull() |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2777 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2778 if(newvalue == null) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2779 retval = spinbutton.value |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2780 } else { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2781 retval = newvalue |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2782 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2783 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2784 return retval |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2785 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2786 |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
2787 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
|
2788 { |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
2789 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
|
2790 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
2791 waitOnUiThread { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
2792 val dataArrayMap = SimpleArrayMap<String, Long>() |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
2793 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
2794 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
|
2795 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
|
2796 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
|
2797 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
|
2798 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
2799 return combobox |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
2800 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
2801 |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2802 fun containerNew(cid: Int, multi: Int): ListView? |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2803 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2804 var cont: ListView? = null |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2805 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2806 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2807 val dataArrayMap = SimpleArrayMap<String, Long>() |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2808 val adapter = DWContainerAdapter(this) |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2809 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2810 cont = ListView(this) |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2811 cont!!.tag = dataArrayMap |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2812 cont!!.id = cid |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2813 cont!!.adapter = adapter |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2814 if(multi != 0) { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
2815 cont!!.choiceMode = ListView.CHOICE_MODE_MULTIPLE |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2816 } |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2817 cont!!.setOnItemClickListener { parent, view, position, id -> |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2818 val title = adapter.model.getRowTitle(position) |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2819 val data = adapter.model.getRowData(position) |
2613
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2820 val now = System.currentTimeMillis() |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2821 |
2563
56183bef6793
Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2562
diff
changeset
|
2822 view.isSelected = !view.isSelected |
56183bef6793
Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2562
diff
changeset
|
2823 adapter.selectedItem = position |
2614
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
2824 lastClickView = cont!! |
2613
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2825 // If we are single select or we got a double tap... |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2826 // Generate an ENTER event |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2827 if(cont!!.choiceMode != ListView.CHOICE_MODE_MULTIPLE || |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2828 (position == adapter.lastClickRow && |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2829 (now - adapter.lastClick) < ViewConfiguration.getDoubleTapTimeout())) { |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
2830 eventHandlerContainer(cont!!, DWEvent.ITEM_ENTER, title, 0, 0, data) |
2613
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2831 } else { |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2832 // If we are mutiple select, generate a SELECT event |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
2833 eventHandlerContainer(cont!!, DWEvent.ITEM_SELECT, title, 0, 0, data) |
2613
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2834 } |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2835 adapter.lastClick = now |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2836 adapter.lastClickRow = position |
2563
56183bef6793
Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2562
diff
changeset
|
2837 } |
56183bef6793
Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2562
diff
changeset
|
2838 cont!!.setOnContextClickListener { |
56183bef6793
Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2562
diff
changeset
|
2839 if(adapter.selectedItem > -1 && adapter.selectedItem < adapter.model.numberOfRows()) { |
56183bef6793
Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2562
diff
changeset
|
2840 val title = adapter.model.getRowTitle(adapter.selectedItem) |
56183bef6793
Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2562
diff
changeset
|
2841 val data = adapter.model.getRowData(adapter.selectedItem) |
56183bef6793
Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2562
diff
changeset
|
2842 |
2614
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
2843 lastClickView = cont!! |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
2844 eventHandlerContainer(cont!!, DWEvent.ITEM_CONTEXT, title, 0, 0, data) |
2563
56183bef6793
Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2562
diff
changeset
|
2845 } |
56183bef6793
Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2562
diff
changeset
|
2846 true |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2847 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2848 cont!!.setOnItemLongClickListener { parent, view, position, id -> |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2849 val title = adapter.model.getRowTitle(position) |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2850 val data = adapter.model.getRowData(position) |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2851 |
2614
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
2852 lastClickView = cont!! |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
2853 eventHandlerContainer(cont!!, DWEvent.ITEM_CONTEXT, title, 0, 0, data) |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2854 true |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2855 } |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2856 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2857 return cont |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2858 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2859 |
2580
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2860 fun containerSetStripe(cont: ListView, oddcolor: Long, evencolor: Long) |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2861 { |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2862 waitOnUiThread { |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2863 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2864 |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2865 if(oddcolor == -1L) { |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2866 adapter.oddColor = null |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2867 } else if(evencolor == -2L) { |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2868 if(darkMode == 1) { |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2869 adapter.oddColor = Color.rgb(100, 100, 100) |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2870 } else { |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2871 adapter.oddColor = Color.rgb(230, 230, 230) |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2872 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2873 } else { |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2874 adapter.oddColor = colorFromDW(oddcolor) |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2875 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2876 if(evencolor == -1L || evencolor == -2L) { |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2877 adapter.evenColor = null |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2878 } else { |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2879 adapter.evenColor = colorFromDW(evencolor) |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2880 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2881 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2882 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2883 |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2884 fun containerGetTitleStart(cont: ListView, flags: Int): String? |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2885 { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2886 var retval: String? = null |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2887 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2888 waitOnUiThread { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2889 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2890 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2891 // Handle DW_CRA_SELECTED |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2892 if((flags and 1) != 0) { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2893 val checked: SparseBooleanArray = cont.getCheckedItemPositions() |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2894 val position = checked.keyAt(0) |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2895 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2896 adapter.model.querypos = position |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2897 retval = adapter.model.getRowTitle(position) |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2898 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2899 if(adapter.model.rowdata.size == 0) { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2900 adapter.model.querypos = -1 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2901 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2902 retval = adapter.model.getRowTitle(0) |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2903 adapter.model.querypos = 0 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2904 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2905 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2906 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2907 return retval |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2908 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2909 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2910 fun containerGetTitleNext(cont: ListView, flags: Int): String? |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2911 { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2912 var retval: String? = null |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2913 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2914 waitOnUiThread { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2915 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2916 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2917 if(adapter.model.querypos != -1) { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2918 // Handle DW_CRA_SELECTED |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2919 if ((flags and 1) != 0) { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2920 val checked: SparseBooleanArray = cont.getCheckedItemPositions() |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2921 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2922 // Otherwise loop until we find our current place |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2923 for (i in 0 until checked.size()) { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2924 // Item position in adapter |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2925 val position: Int = checked.keyAt(i) |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2926 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2927 if (adapter.model.querypos == position && (i + 1) < checked.size()) { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2928 val newpos = checked.keyAt(i + 1) |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2929 |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2930 adapter.model.querypos = newpos |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2931 retval = adapter.model.getRowTitle(newpos) |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2932 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2933 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2934 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2935 if (adapter.model.rowtitle.size > adapter.model.querypos) { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2936 adapter.model.querypos += 1 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2937 retval = adapter.model.getRowTitle(adapter.model.querypos) |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2938 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2939 adapter.model.querypos = -1 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2940 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2941 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2942 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2943 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2944 return retval |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2945 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2946 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2947 fun containerGetDataStart(cont: ListView, flags: Int): Long |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2948 { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2949 var retval: Long = 0 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2950 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2951 waitOnUiThread { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2952 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2953 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2954 // Handle DW_CRA_SELECTED |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2955 if((flags and 1) != 0) { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2956 val checked: SparseBooleanArray = cont.getCheckedItemPositions() |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2957 val position = checked.keyAt(0) |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2958 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2959 adapter.model.querypos = position |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2960 retval = adapter.model.getRowData(position) |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2961 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2962 if(adapter.model.rowdata.size == 0) { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2963 adapter.model.querypos = -1 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2964 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2965 retval = adapter.model.getRowData(0) |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2966 adapter.model.querypos = 0 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2967 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2968 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2969 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2970 return retval |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2971 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2972 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2973 fun containerGetDataNext(cont: ListView, flags: Int): Long |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2974 { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2975 var retval: Long = 0 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2976 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2977 waitOnUiThread { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2978 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2979 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2980 if(adapter.model.querypos != -1) { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2981 // Handle DW_CRA_SELECTED |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2982 if ((flags and 1) != 0) { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2983 val checked: SparseBooleanArray = cont.getCheckedItemPositions() |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2984 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2985 // Otherwise loop until we find our current place |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2986 for (i in 0 until checked.size()) { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2987 // Item position in adapter |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2988 val position: Int = checked.keyAt(i) |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2989 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2990 if (adapter.model.querypos == position && (i + 1) < checked.size()) { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2991 val newpos = checked.keyAt(i + 1) |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2992 |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2993 adapter.model.querypos = newpos |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2994 retval = adapter.model.getRowData(newpos) |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2995 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2996 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2997 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2998 if (adapter.model.rowdata.size > adapter.model.querypos) { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2999 adapter.model.querypos += 1 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3000 retval = adapter.model.getRowData(adapter.model.querypos) |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3001 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3002 adapter.model.querypos = -1 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3003 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3004 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3005 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3006 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3007 return retval |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3008 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3009 |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3010 fun containerAddColumn(cont: ListView, title: String, flags: Int) |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3011 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3012 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3013 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3014 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3015 adapter.model.addColumn(title, flags) |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3016 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3017 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3018 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3019 fun containerAlloc(cont: ListView, rowcount: Int): ListView |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3020 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3021 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3022 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3023 val rowStart = adapter.model.addRows(rowcount) |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3024 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3025 windowSetData(cont, "_dw_rowstart", rowStart) |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3026 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3027 return cont |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3028 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3029 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3030 fun containerChangeItemString(cont: ListView, column: Int, row: Int, text: String) |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3031 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3032 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3033 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3034 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3035 adapter.model.setRowAndColumn(row, column, text) |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3036 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3037 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3038 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3039 fun containerChangeItemIcon(cont: ListView, column: Int, row: Int, icon: Drawable) |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3040 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3041 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3042 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3043 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3044 adapter.model.setRowAndColumn(row, column, icon) |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3045 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3046 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3047 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3048 fun containerChangeItemInt(cont: ListView, column: Int, row: Int, num: Int) |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3049 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3050 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3051 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3052 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3053 adapter.model.setRowAndColumn(row, column, num) |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3054 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3055 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3056 |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3057 fun containerChangeRowData(cont: ListView, row: Int, data: Long) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3058 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3059 waitOnUiThread { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3060 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3061 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3062 adapter.model.changeRowData(row, data) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3063 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3064 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3065 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3066 fun containerChangeRowTitle(cont: ListView, row: Int, title: String?) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3067 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3068 waitOnUiThread { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3069 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3070 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3071 adapter.model.changeRowTitle(row, title) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3072 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3073 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3074 |
2561
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
3075 fun containerRefresh(cont: ListView) |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
3076 { |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
3077 waitOnUiThread { |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
3078 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
3079 |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
3080 adapter.notifyDataSetChanged() |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
3081 } |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
3082 } |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
3083 |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3084 fun containerGetColumnType(cont: ListView, column: Int): Int |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3085 { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
3086 var type = 0 |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3087 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3088 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3089 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3090 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3091 type = adapter.model.getColumnType(column) |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3092 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3093 return type |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3094 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3095 |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3096 fun containerDelete(cont: ListView, rowcount: Int) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3097 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3098 waitOnUiThread { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3099 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3100 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3101 adapter.model.deleteRows(rowcount) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3102 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3103 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3104 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3105 fun containerRowDeleteByTitle(cont: ListView, title: String?) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3106 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3107 waitOnUiThread { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3108 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3109 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3110 adapter.model.deleteRowByTitle(title) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3111 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3112 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3113 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3114 fun containerRowDeleteByData(cont: ListView, data: Long) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3115 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3116 waitOnUiThread { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3117 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3118 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3119 adapter.model.deleteRowByData(data) |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3120 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3121 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3122 |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3123 fun containerClear(cont: ListView) |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3124 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3125 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3126 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3127 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3128 adapter.model.clear() |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3129 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3130 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3131 |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3132 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
|
3133 { |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3134 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
|
3135 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3136 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3137 val dataArrayMap = SimpleArrayMap<String, Long>() |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3138 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3139 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
|
3140 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
|
3141 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
|
3142 if(multi != 0) { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
3143 listbox!!.choiceMode = ListView.CHOICE_MODE_MULTIPLE |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3144 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3145 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3146 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
|
3147 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3148 |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
3149 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
|
3150 { |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
3151 waitOnUiThread { |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
3152 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
|
3153 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
|
3154 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
3155 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
|
3156 } 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
|
3157 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
|
3158 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3159 listbox.list.add(text) |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
3160 val adapter = listbox.adapter as ArrayAdapter<String> |
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
3161 adapter.notifyDataSetChanged() |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
3162 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
3163 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
3164 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
3165 |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3166 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
|
3167 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3168 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3169 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
|
3170 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3171 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3172 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
|
3173 } 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
|
3174 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
|
3175 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3176 listbox.list.add(pos, text) |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
3177 val adapter = listbox.adapter as ArrayAdapter<String> |
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
3178 adapter.notifyDataSetChanged() |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3179 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3180 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3181 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3182 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3183 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
|
3184 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3185 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3186 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
|
3187 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3188 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3189 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
|
3190 } 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
|
3191 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
|
3192 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3193 listbox.list.clear() |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
3194 val adapter = listbox.adapter as ArrayAdapter<String> |
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
3195 adapter.notifyDataSetChanged() |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3196 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3197 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3198 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3199 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3200 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
|
3201 { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
3202 var retval = 0 |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3203 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3204 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3205 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
|
3206 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3207 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3208 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
|
3209 } 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
|
3210 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
|
3211 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3212 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
|
3213 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3214 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3215 return retval |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3216 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3217 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3218 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
|
3219 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3220 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3221 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
|
3222 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3223 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3224 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
|
3225 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
|
3226 } 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
|
3227 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
|
3228 |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
3229 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
|
3230 listbox.list[index] = text |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
3231 val adapter = listbox.adapter as ArrayAdapter<String> |
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
3232 adapter.notifyDataSetChanged() |
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
3233 } |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3234 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3235 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3236 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3237 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3238 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
|
3239 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3240 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
|
3241 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3242 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3243 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
|
3244 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3245 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3246 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
|
3247 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
|
3248 } 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
|
3249 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
|
3250 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3251 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
|
3252 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
|
3253 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3254 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3255 return retval |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3256 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3257 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3258 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
|
3259 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3260 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
|
3261 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3262 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3263 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
|
3264 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3265 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3266 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
|
3267 } 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
|
3268 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
|
3269 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3270 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
|
3271 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3272 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3273 return retval |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3274 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3275 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3276 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
|
3277 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3278 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3279 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
|
3280 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3281 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3282 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
|
3283 combobox.selected = index |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3284 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
|
3285 } |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3286 } 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
|
3287 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
|
3288 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3289 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
|
3290 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
|
3291 listbox.selected = index |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
3292 listbox.setItemChecked(index, true) |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3293 } else { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
3294 listbox.setItemChecked(index, false) |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3295 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3296 } |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3297 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3298 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3299 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3300 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3301 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
|
3302 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3303 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3304 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
|
3305 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3306 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3307 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
|
3308 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
|
3309 } |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3310 } 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
|
3311 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
|
3312 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3313 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
|
3314 listbox.list.removeAt(index) |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
3315 val adapter = listbox.adapter as ArrayAdapter<String> |
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
3316 adapter.notifyDataSetChanged() |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3317 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3318 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3319 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3320 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3321 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3322 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
|
3323 { |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3324 waitOnUiThread { |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3325 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
|
3326 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
|
3327 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3328 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
|
3329 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
|
3330 } |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3331 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3332 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3333 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3334 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3335 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
|
3336 { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3337 var retval: Int = -1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3338 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3339 waitOnUiThread { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3340 if(window is DWListBox) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3341 val listbox = window |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3342 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
|
3343 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3344 // 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
|
3345 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
|
3346 retval = checked.keyAt(0) |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3347 } else { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3348 // 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
|
3349 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
|
3350 // Item position in adapter |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3351 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
|
3352 // 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
|
3353 // 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
|
3354 // 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
|
3355 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
|
3356 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
|
3357 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3358 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3359 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3360 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3361 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3362 return retval |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3363 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3364 |
2523
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3365 fun calendarNew(cid: Int): CalendarView? |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3366 { |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3367 var calendar: CalendarView? = null |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3368 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3369 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3370 val dataArrayMap = SimpleArrayMap<String, Long>() |
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
|
3371 |
2523
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3372 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
|
3373 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
|
3374 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
|
3375 calendar!!.setOnDateChangeListener { calendar, year, month, day -> |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
3376 val c: Calendar = Calendar.getInstance() |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
3377 c.set(year, month, day) |
2524
d5c3c573c74e
Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2523
diff
changeset
|
3378 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
|
3379 } |
2523
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3380 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3381 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3382 return calendar |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3383 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3384 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3385 fun calendarSetDate(calendar: CalendarView, date: Long) |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3386 { |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3387 waitOnUiThread { |
2524
d5c3c573c74e
Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2523
diff
changeset
|
3388 // 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
|
3389 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
|
3390 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3391 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3392 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3393 fun calendarGetDate(calendar: CalendarView): Long |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3394 { |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3395 var date: Long = 0 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3396 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3397 waitOnUiThread { |
2524
d5c3c573c74e
Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2523
diff
changeset
|
3398 // 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
|
3399 date = calendar.date / 1000 |
2523
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3400 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3401 return date |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3402 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3403 |
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
|
3404 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
|
3405 { |
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
|
3406 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
|
3407 |
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
|
3408 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3409 val dataArrayMap = SimpleArrayMap<String, Long>() |
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
|
3410 |
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
|
3411 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
|
3412 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
|
3413 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
|
3414 } |
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
|
3415 |
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
|
3416 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
|
3417 } |
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
|
3418 |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3419 fun windowSetBitmap(window: View, resID: Int, file: String?) |
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
|
3420 { |
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
|
3421 waitOnUiThread { |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3422 var filename: String? = file |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3423 |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3424 if(resID > 0 && resID < 65536) { |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3425 filename = resID.toString() |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3426 } else if(resID != 0) { |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3427 if (window is ImageButton) { |
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
|
3428 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
|
3429 |
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
|
3430 button.setImageResource(resID) |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3431 } else if (window is ImageView) { |
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
|
3432 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
|
3433 |
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
|
3434 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
|
3435 } |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3436 } |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3437 if(filename != null) { |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
3438 for (ext in DWImageExts) { |
2564
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3439 // Try to load the image, and protect against exceptions |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3440 try { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3441 val f = this.assets.open(filename + ext) |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3442 val b = BitmapFactory.decodeStream(f) |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3443 |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3444 if(b != null) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3445 if (window is ImageButton) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3446 val button = window |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3447 |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3448 button.setImageBitmap(b) |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3449 } else if (window is ImageView) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3450 val imageview = window |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3451 |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3452 imageview.setImageBitmap(b) |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3453 } |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3454 break |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3455 } |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3456 } catch (e: IOException) { |
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
|
3457 } |
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
|
3458 } |
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
|
3459 } |
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
|
3460 } |
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
|
3461 } |
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
|
3462 |
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
|
3463 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
|
3464 { |
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
|
3465 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
|
3466 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
|
3467 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
|
3468 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
|
3469 |
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
|
3470 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
|
3471 } 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
|
3472 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
|
3473 |
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
|
3474 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
|
3475 } |
2655
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3476 } |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3477 if(data != null) { |
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
|
3478 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
|
3479 |
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
|
3480 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
|
3481 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
|
3482 |
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
|
3483 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
|
3484 } 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
|
3485 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
|
3486 |
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
|
3487 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
|
3488 } |
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
|
3489 } |
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
|
3490 } |
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
|
3491 } |
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
|
3492 |
2652
42151fd096d4
Android: Switch to loading resource images like we do on iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2651
diff
changeset
|
3493 fun iconNew(file: String?, data: ByteArray?, length: Int, resID: Int): Drawable? |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3494 { |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3495 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
|
3496 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3497 waitOnUiThread { |
2655
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3498 var filename: String? = null |
2652
42151fd096d4
Android: Switch to loading resource images like we do on iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2651
diff
changeset
|
3499 |
42151fd096d4
Android: Switch to loading resource images like we do on iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2651
diff
changeset
|
3500 // Handle Dynamic Windows resource IDs |
42151fd096d4
Android: Switch to loading resource images like we do on iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2651
diff
changeset
|
3501 if(resID > 0 && resID < 65536) { |
42151fd096d4
Android: Switch to loading resource images like we do on iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2651
diff
changeset
|
3502 filename = resID.toString() |
2655
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3503 // Handle Android resource IDs |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3504 } else if(resID != 0) { |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3505 try { |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3506 icon = ResourcesCompat.getDrawable(resources, resID, null) |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3507 } catch (e: Resources.NotFoundException) { |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3508 } |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3509 // Handle bitmap data |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3510 } else if(data != null) { |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3511 icon = BitmapDrawable(resources, BitmapFactory.decodeByteArray(data, 0, length)) |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3512 } else { |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3513 filename = file |
2652
42151fd096d4
Android: Switch to loading resource images like we do on iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2651
diff
changeset
|
3514 } |
42151fd096d4
Android: Switch to loading resource images like we do on iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2651
diff
changeset
|
3515 // Handle filename or DW resource IDs |
42151fd096d4
Android: Switch to loading resource images like we do on iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2651
diff
changeset
|
3516 // these will be located in the assets folder |
42151fd096d4
Android: Switch to loading resource images like we do on iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2651
diff
changeset
|
3517 if(filename != null) { |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
3518 for (ext in DWImageExts) { |
2564
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3519 // Try to load the image, and protect against exceptions |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3520 try { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3521 val f = this.assets.open(filename + ext) |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3522 icon = Drawable.createFromStream(f, null) |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3523 } catch (e: IOException) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3524 } |
2652
42151fd096d4
Android: Switch to loading resource images like we do on iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2651
diff
changeset
|
3525 if (icon != null) { |
2564
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3526 break |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3527 } |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3528 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3529 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3530 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3531 return icon |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3532 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3533 |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3534 fun pixmapNew(width: Int, height: Int, file: String?, data: ByteArray?, length: Int, resID: Int): Bitmap? |
2529
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3535 { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3536 var pixmap: Bitmap? = null |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3537 |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3538 waitOnUiThread { |
2655
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3539 var filename: String? = null |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3540 |
2529
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3541 if(width > 0 && height > 0) { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3542 pixmap = Bitmap.createBitmap(null, width, height, Bitmap.Config.ARGB_8888) |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3543 } else if(resID > 0 && resID < 65536) { |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3544 filename = resID.toString() |
2529
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3545 } else if(resID != 0) { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
3546 pixmap = BitmapFactory.decodeResource(resources, resID) |
2655
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3547 } else if(data != null) { |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3548 pixmap = BitmapFactory.decodeByteArray(data, 0, length) |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3549 } else { |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3550 filename = file |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3551 } |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3552 if(filename != null) { |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
3553 for (ext in DWImageExts) { |
2564
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3554 // Try to load the image, and protect against exceptions |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3555 try { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3556 val f = this.assets.open(filename + ext) |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3557 pixmap = BitmapFactory.decodeStream(f) |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3558 } catch (e: IOException) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3559 } |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3560 if(pixmap != null) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3561 break |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3562 } |
2529
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3563 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3564 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3565 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3566 return pixmap |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3567 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3568 |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3569 fun pixmapGetDimensions(pixmap: Bitmap): Long |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3570 { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3571 var dimensions: Long = 0 |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3572 |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3573 waitOnUiThread { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3574 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
|
3575 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3576 return dimensions |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3577 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3578 |
2542
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
3579 fun screenGetDimensions(): Long |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
3580 { |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
3581 val dm = resources.displayMetrics |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
3582 return dm.widthPixels.toLong() or (dm.heightPixels.toLong() shl 32) |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
3583 } |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
3584 |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3585 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
|
3586 { |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3587 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
|
3588 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3589 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3590 val dataArrayMap = SimpleArrayMap<String, Long>() |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3591 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3592 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
|
3593 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
|
3594 render!!.id = cid |
2608
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3595 render!!.setOnTouchListener(object : View.OnTouchListener { |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3596 @SuppressLint("ClickableViewAccessibility") |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3597 override fun onTouch(v: View, event: MotionEvent): Boolean { |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3598 when (event.action) { |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3599 MotionEvent.ACTION_DOWN -> { |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3600 render!!.evx = event.x |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3601 render!!.evy = event.y |
2611
ed2c4a503666
Android: Implement button release and motion notify events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2608
diff
changeset
|
3602 // Event will be generated in the onClickListener or |
ed2c4a503666
Android: Implement button release and motion notify events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2608
diff
changeset
|
3603 // onLongClickListener below, just save the location |
2608
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3604 } |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3605 MotionEvent.ACTION_UP -> { |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3606 render!!.evx = event.x |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3607 render!!.evy = event.y |
2614
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
3608 lastClickView = render!! |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
3609 eventHandlerInt(render!!, DWEvent.BUTTON_RELEASE, event.x.toInt(), event.y.toInt(), render!!.button, 0) |
2611
ed2c4a503666
Android: Implement button release and motion notify events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2608
diff
changeset
|
3610 } |
ed2c4a503666
Android: Implement button release and motion notify events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2608
diff
changeset
|
3611 MotionEvent.ACTION_MOVE -> { |
ed2c4a503666
Android: Implement button release and motion notify events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2608
diff
changeset
|
3612 render!!.evx = event.x |
ed2c4a503666
Android: Implement button release and motion notify events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2608
diff
changeset
|
3613 render!!.evy = event.y |
2614
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
3614 lastClickView = render!! |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
3615 eventHandlerInt(render!!, DWEvent.MOTION_NOTIFY, event.x.toInt(), event.y.toInt(), 1, 0) |
2608
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3616 } |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3617 } |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3618 return false |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3619 } |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3620 }) |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3621 render!!.setOnLongClickListener{ |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3622 // Long click functions as button 2 |
2611
ed2c4a503666
Android: Implement button release and motion notify events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2608
diff
changeset
|
3623 render!!.button = 2 |
2614
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
3624 lastClickView = render!! |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
3625 eventHandlerInt(render!!, DWEvent.BUTTON_PRESS, render!!.evx.toInt(), render!!.evy.toInt(), 2, 0) |
2608
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3626 true |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3627 } |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3628 render!!.setOnClickListener{ |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3629 // Normal click functions as button 1 |
2611
ed2c4a503666
Android: Implement button release and motion notify events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2608
diff
changeset
|
3630 render!!.button = 1 |
2614
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
3631 lastClickView = render!! |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
3632 eventHandlerInt(render!!, DWEvent.BUTTON_PRESS, render!!.evx.toInt(), render!!.evy.toInt(), 1, 0) |
2608
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3633 } |
2596
60ec91d23746
Android: Add initial keyboard support for Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2595
diff
changeset
|
3634 render!!.setOnKeyListener(View.OnKeyListener { v, keyCode, event -> |
60ec91d23746
Android: Add initial keyboard support for Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2595
diff
changeset
|
3635 if (event.action == KeyEvent.ACTION_DOWN) { |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
3636 eventHandlerKey(render!!, DWEvent.KEY_PRESS, keyCode, event.unicodeChar, event.modifiers, event.characters) |
2596
60ec91d23746
Android: Add initial keyboard support for Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2595
diff
changeset
|
3637 } |
60ec91d23746
Android: Add initial keyboard support for Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2595
diff
changeset
|
3638 false |
60ec91d23746
Android: Add initial keyboard support for Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2595
diff
changeset
|
3639 }) |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3640 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3641 return render |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3642 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3643 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3644 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
|
3645 { |
2539
822f814a54f4
Android: Fix memory corruption issue due to incorrectly allocating HPIXMAP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2538
diff
changeset
|
3646 runOnUiThread { |
822f814a54f4
Android: Fix memory corruption issue due to incorrectly allocating HPIXMAP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2538
diff
changeset
|
3647 render.invalidate() |
822f814a54f4
Android: Fix memory corruption issue due to incorrectly allocating HPIXMAP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2538
diff
changeset
|
3648 } |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3649 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3650 |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3651 fun pixmapBitBlt(dstr: DWRender?, dstp: Bitmap?, dstx: Int, dsty: Int, dstw: Int, dsth: Int, |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3652 srcr: DWRender?, srcp: Bitmap?, srcy: Int, srcx: Int, srcw: Int, srch: Int): Int |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3653 { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3654 val dst = Rect(dstx, dsty, dstx + dstw, dsty + dsth) |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3655 val src = Rect(srcx, srcy, srcx + srcw, srcy + srch) |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
3656 var retval = 1 |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3657 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3658 if(srcw == -1) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3659 src.right = srcx + dstw |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3660 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3661 if(srch == -1) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3662 src.bottom = srcy + dsth |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3663 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3664 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3665 waitOnUiThread { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3666 var canvas: Canvas? = null |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3667 var bitmap: Bitmap? = null |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3668 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3669 if(dstr != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3670 canvas = dstr.cachedCanvas |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3671 } else if(dstp != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3672 canvas = Canvas(dstp) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3673 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3674 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3675 if(srcp != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3676 bitmap = srcp |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3677 } else if(srcr != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3678 bitmap = Bitmap.createBitmap(srcr.layoutParams.width, |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3679 srcr.layoutParams.height, Bitmap.Config.ARGB_8888) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3680 val c = Canvas(bitmap) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3681 srcr.layout(srcr.left, srcr.top, srcr.right, srcr.bottom) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3682 srcr.draw(c) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3683 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3684 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3685 if(canvas != null && bitmap != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3686 canvas.drawBitmap(bitmap, src, dst, null) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3687 retval = 0 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3688 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3689 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3690 return retval |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3691 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3692 |
2580
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
3693 fun drawPoint(render: DWRender?, bitmap: Bitmap?, x: Int, y: Int, fgColor: Long, bgColor: Long) |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3694 { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3695 waitOnUiThread { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3696 var canvas: Canvas? = null |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3697 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3698 if(render != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3699 canvas = render.cachedCanvas |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3700 } else if(bitmap != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3701 canvas = Canvas(bitmap) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3702 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3703 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3704 if(canvas != null) { |
2572
bbe693293be5
Android: New color handling system, save the color in the C API and pass
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2568
diff
changeset
|
3705 colorsSet(fgColor, bgColor) |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3706 canvas.drawPoint(x.toFloat(), y.toFloat(), Paint()) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3707 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3708 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3709 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3710 |
2580
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
3711 fun drawLine(render: DWRender?, bitmap: Bitmap?, x1: Int, y1: Int, x2: Int, y2: Int, fgColor: Long, bgColor: Long) |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3712 { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3713 waitOnUiThread { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3714 var canvas: Canvas? = null |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3715 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3716 if(render != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3717 canvas = render.cachedCanvas |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3718 } else if(bitmap != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3719 canvas = Canvas(bitmap) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3720 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3721 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3722 if(canvas != null) { |
2572
bbe693293be5
Android: New color handling system, save the color in the C API and pass
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2568
diff
changeset
|
3723 colorsSet(fgColor, bgColor) |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3724 paint.flags = 0 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3725 paint.style = Paint.Style.STROKE |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3726 canvas.drawLine(x1.toFloat(), y1.toFloat(), x2.toFloat(), y2.toFloat(), paint) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3727 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3728 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3729 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3730 |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3731 fun fontTextExtentsGet(render: DWRender?, bitmap: Bitmap?, text:String, typeface: Typeface?, fontsize: Int, window: View?): Long |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3732 { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3733 var dimensions: Long = 0 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3734 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3735 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3736 val rect = Rect() |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3737 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3738 if (render != null) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3739 if (render.typeface != null) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3740 paint.typeface = render.typeface |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3741 if (render.fontsize != null && render.fontsize!! > 0F) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3742 paint.textSize = render.fontsize!! |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3743 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3744 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3745 } else if (bitmap != null) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3746 if (typeface != null) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3747 paint.typeface = typeface |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3748 if (fontsize > 0) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3749 paint.textSize = fontsize.toFloat() |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3750 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3751 } else if (window != null && window is DWRender) { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
3752 val secondary: DWRender = window |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3753 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3754 if (secondary.typeface != null) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3755 paint.typeface = secondary.typeface |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3756 if (secondary.fontsize != null && secondary.fontsize!! > 0F) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3757 paint.textSize = secondary.fontsize!! |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3758 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3759 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3760 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3761 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3762 paint.getTextBounds(text, 0, text.length, rect) |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3763 val textheight = rect.bottom - rect.top |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3764 val textwidth = rect.right - rect.left |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3765 dimensions = textwidth.toLong() or (textheight.toLong() shl 32) |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3766 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3767 return dimensions |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3768 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3769 |
2572
bbe693293be5
Android: New color handling system, save the color in the C API and pass
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2568
diff
changeset
|
3770 fun drawText(render: DWRender?, bitmap: Bitmap?, x: Int, y: Int, text:String, typeface: Typeface?, |
2580
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
3771 fontsize: Int, window: View?, fgColor: Long, bgColor: Long) |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3772 { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3773 waitOnUiThread { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3774 var canvas: Canvas? = null |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3775 |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3776 if(render != null && render.cachedCanvas != null) { |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3777 canvas = render.cachedCanvas |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3778 if(render.typeface != null) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3779 paint.typeface = render.typeface |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3780 if(render.fontsize != null && render.fontsize!! > 0F) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3781 paint.textSize = render.fontsize!! |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3782 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3783 } |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3784 } else if(bitmap != null) { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3785 canvas = Canvas(bitmap) |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3786 if(typeface != null) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3787 paint.typeface = typeface |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3788 if(fontsize > 0) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3789 paint.textSize = fontsize.toFloat() |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3790 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3791 } else if(window != null && window is DWRender) { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
3792 val secondary: DWRender = window |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3793 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3794 if(secondary.typeface != null) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3795 paint.typeface = secondary.typeface |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3796 if(secondary.fontsize != null && secondary.fontsize!! > 0F) { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3797 paint.textSize = secondary.fontsize!! |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3798 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3799 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3800 } |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3801 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3802 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3803 if(canvas != null) { |
2572
bbe693293be5
Android: New color handling system, save the color in the C API and pass
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2568
diff
changeset
|
3804 colorsSet(fgColor, bgColor) |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3805 // Save the old color for later... |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3806 val rect = Rect() |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3807 paint.flags = 0 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3808 paint.style = Paint.Style.FILL_AND_STROKE |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3809 paint.textAlign = Paint.Align.LEFT |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3810 paint.getTextBounds(text, 0, text.length, rect) |
2538
1b3b40c89cd0
Android: Move the text to below the point, not above it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2537
diff
changeset
|
3811 val textheight = rect.bottom - rect.top |
2637
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3812 if(bgcolor != null) { |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3813 val oldcolor = paint.color |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3814 // Prepare to draw the background rect |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3815 paint.color = bgcolor as Int |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3816 rect.top += y + textheight |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3817 rect.bottom += y + textheight |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3818 rect.left += x |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3819 rect.right += x |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3820 canvas.drawRect(rect, paint) |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3821 // Restore the color and prepare to draw text |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3822 paint.color = oldcolor |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3823 } |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3824 paint.style = Paint.Style.STROKE |
2538
1b3b40c89cd0
Android: Move the text to below the point, not above it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2537
diff
changeset
|
3825 canvas.drawText(text, x.toFloat(), y.toFloat() + textheight.toFloat(), paint) |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3826 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3827 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3828 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3829 |
2580
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
3830 fun drawRect(render: DWRender?, bitmap: Bitmap?, x: Int, y: Int, width: Int, height: Int, fgColor: Long, bgColor: Long) |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3831 { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3832 waitOnUiThread { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3833 var canvas: Canvas? = null |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3834 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3835 if(render != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3836 canvas = render.cachedCanvas |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3837 } else if(bitmap != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3838 canvas = Canvas(bitmap) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3839 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3840 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3841 if(canvas != null) { |
2572
bbe693293be5
Android: New color handling system, save the color in the C API and pass
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2568
diff
changeset
|
3842 colorsSet(fgColor, bgColor) |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3843 paint.flags = 0 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3844 paint.style = Paint.Style.FILL_AND_STROKE |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3845 canvas.drawRect(x.toFloat(), y.toFloat(), x.toFloat() + width.toFloat(), y.toFloat() + height.toFloat(), paint) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3846 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3847 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3848 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3849 |
2572
bbe693293be5
Android: New color handling system, save the color in the C API and pass
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2568
diff
changeset
|
3850 fun drawPolygon(render: DWRender?, bitmap: Bitmap?, flags: Int, npoints: Int, |
2580
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
3851 x: IntArray, y: IntArray, fgColor: Long, bgColor: Long) |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3852 { |
2537
cd9d2ba251d5
Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2536
diff
changeset
|
3853 // Create a path with all our points |
cd9d2ba251d5
Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2536
diff
changeset
|
3854 val path = Path() |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3855 |
2537
cd9d2ba251d5
Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2536
diff
changeset
|
3856 path.moveTo(x[0].toFloat(), y[0].toFloat()) |
cd9d2ba251d5
Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2536
diff
changeset
|
3857 for (i in 1 until npoints) { |
cd9d2ba251d5
Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2536
diff
changeset
|
3858 path.lineTo(x[i].toFloat(), y[i].toFloat()) |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3859 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3860 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3861 waitOnUiThread { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3862 var canvas: Canvas? = null |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3863 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3864 if(render != null) { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3865 canvas = render.cachedCanvas |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3866 } else if(bitmap != null) { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3867 canvas = Canvas(bitmap) |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3868 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3869 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3870 if(canvas != null) { |
2572
bbe693293be5
Android: New color handling system, save the color in the C API and pass
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2568
diff
changeset
|
3871 colorsSet(fgColor, bgColor) |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3872 // Handle the DW_DRAW_NOAA flag |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3873 if((flags and (1 shl 2)) == 0) { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3874 paint.flags = Paint.ANTI_ALIAS_FLAG |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3875 } else { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3876 paint.flags = 0 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3877 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3878 // Handle the DW_DRAW_FILL flag |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3879 if((flags and 1) == 1) { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3880 paint.style = Paint.Style.FILL_AND_STROKE |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3881 } else { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3882 paint.style = Paint.Style.STROKE |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3883 } |
2537
cd9d2ba251d5
Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2536
diff
changeset
|
3884 canvas.drawPath(path, paint) |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3885 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3886 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3887 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3888 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3889 fun drawArc(render: DWRender?, bitmap: Bitmap?, flags: Int, xorigin: Int, yorigin: Int, |
2580
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
3890 x1: Int, y1: Int, x2: Int, y2: Int, fgColor: Long, bgColor: Long) |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3891 { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3892 waitOnUiThread { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3893 var canvas: Canvas? = null |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3894 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3895 if(render != null) { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3896 canvas = render.cachedCanvas |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3897 } else if(bitmap != null) { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3898 canvas = Canvas(bitmap) |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3899 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3900 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3901 if(canvas != null) { |
2572
bbe693293be5
Android: New color handling system, save the color in the C API and pass
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2568
diff
changeset
|
3902 colorsSet(fgColor, bgColor) |
bbe693293be5
Android: New color handling system, save the color in the C API and pass
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2568
diff
changeset
|
3903 |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3904 // Handle the DW_DRAW_NOAA flag |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3905 if((flags and (1 shl 2)) == 0) { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3906 paint.flags = Paint.ANTI_ALIAS_FLAG |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3907 } else { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3908 paint.flags = 0 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3909 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3910 // Handle the DW_DRAW_FILL flag |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3911 if((flags and 1) == 1) { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3912 paint.style = Paint.Style.FILL_AND_STROKE |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3913 } else { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3914 paint.style = Paint.Style.STROKE |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3915 } |
2536
d172ab2eddb6
Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2535
diff
changeset
|
3916 // Handle the DW_DRAW_FULL flag |
d172ab2eddb6
Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2535
diff
changeset
|
3917 if((flags and (1 shl 1)) != 0) { |
2576
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3918 var left: Float = x1.toFloat() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3919 var top: Float = y1.toFloat() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3920 var right: Float = x2.toFloat() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3921 var bottom: Float = y2.toFloat() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3922 |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3923 if(x2 < x1) { |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3924 left = x2.toFloat() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3925 right = x1.toFloat() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3926 } |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3927 if(y2 < y1) { |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3928 top = y2.toFloat() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3929 bottom = y1.toFloat() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3930 } |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3931 |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3932 canvas.drawOval(left, top, right, bottom, paint) |
2536
d172ab2eddb6
Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2535
diff
changeset
|
3933 } else { |
2576
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3934 var a1: Double = Math.atan2((y1 - yorigin).toDouble(), (x1 - xorigin).toDouble()) |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3935 var a2: Double = Math.atan2((y2 - yorigin).toDouble(), (x2 - xorigin).toDouble()) |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3936 val dx = (xorigin - x1).toDouble() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3937 val dy = (yorigin - y1).toDouble() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3938 val r: Double = Math.sqrt(dx * dx + dy * dy) |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3939 val left = (xorigin-r).toFloat() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3940 val top = (yorigin-r).toFloat() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3941 val rect = RectF(left, top, (left + (r*2)).toFloat(), (top + (r*2)).toFloat()) |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3942 |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3943 // Convert to degrees |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3944 a1 *= 180.0 / Math.PI |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3945 a2 *= 180.0 / Math.PI |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3946 val sweep = Math.abs(a1 - a2) |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3947 |
2536
d172ab2eddb6
Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2535
diff
changeset
|
3948 canvas.drawArc(rect, a1.toFloat(), sweep.toFloat(), false, paint) |
d172ab2eddb6
Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2535
diff
changeset
|
3949 } |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3950 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3951 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3952 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3953 |
2580
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
3954 fun colorFromDW(color: Long): Int |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
3955 { |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
3956 val red: Int = (color and 0x000000FF).toInt() |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
3957 val green: Int = ((color and 0x0000FF00) shr 8).toInt() |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
3958 val blue: Int = ((color and 0x00FF0000) shr 16).toInt() |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
3959 |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
3960 return Color.rgb(red, green, blue) |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
3961 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
3962 |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
3963 fun colorsSet(fgColor: Long, bgColor: Long) |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3964 { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3965 waitOnUiThread { |
2580
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
3966 paint.color = colorFromDW(fgColor) |
2637
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3967 if(bgColor != -1L) { |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3968 this.bgcolor = colorFromDW(bgColor) |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3969 } else { |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3970 this.bgcolor = null |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3971 } |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3972 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3973 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3974 |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3975 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
|
3976 { |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3977 // creating timer task, timer |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3978 val t = Timer() |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3979 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
|
3980 override fun run() { |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3981 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
|
3982 t.cancel() |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3983 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3984 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3985 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3986 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
|
3987 return t |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3988 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3989 |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3990 fun timerDisconnect(timer: Timer) |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3991 { |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3992 timer.cancel() |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3993 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3994 |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3995 fun doBeep(duration: Int) |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3996 { |
2491
bf4fe6bb512b
Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2490
diff
changeset
|
3997 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
|
3998 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
|
3999 val handler = Handler(Looper.getMainLooper()) |
bf4fe6bb512b
Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2490
diff
changeset
|
4000 handler.postDelayed({ |
bf4fe6bb512b
Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2490
diff
changeset
|
4001 toneGen.release() |
bf4fe6bb512b
Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2490
diff
changeset
|
4002 }, (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
|
4003 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
4004 |
2482
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
4005 fun debugMessage(text: String) |
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
4006 { |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
4007 Log.d(appID, text) |
2482
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
4008 } |
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
4009 |
2594
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4010 override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4011 super.onActivityResult(requestCode, resultCode, data) |
2595
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4012 if(requestCode == 100) { |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4013 fileLock.lock() |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4014 if(resultCode == Activity.RESULT_OK) { |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4015 fileURI = data!!.data |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4016 } else { |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4017 fileURI = null |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4018 } |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4019 fileCond.signal() |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4020 fileLock.unlock() |
2594
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4021 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4022 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4023 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4024 fun fileBrowseNew(title: String, defpath: String?, ext: String?, flags: Int): String? |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4025 { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4026 var retval: String? = null |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4027 |
2595
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4028 // This can't be called from the main thread |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4029 if(Looper.getMainLooper() != Looper.myLooper()) { |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4030 fileLock.lock() |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4031 waitOnUiThread { |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4032 val fileintent = Intent(Intent.ACTION_GET_CONTENT) |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4033 fileintent.type = "text/plain" |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4034 fileintent.addCategory(Intent.CATEGORY_OPENABLE) |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4035 startActivityForResult(fileintent, 100) |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4036 } |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4037 |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4038 // Wait until the intent finishes. |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4039 fileCond.await() |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4040 fileLock.unlock() |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4041 |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4042 if(fileURI != null) { |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4043 retval = getUriRealPath(this, fileURI) |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4044 } |
2594
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4045 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4046 return retval |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4047 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4048 |
2526
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4049 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
|
4050 { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4051 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
|
4052 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4053 waitOnUiThread { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4054 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
|
4055 fc.setFileListener(object: DWFileChooser.FileSelectedListener { |
2594
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4056 override fun fileSelected(file: File?) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4057 // do something with the file |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4058 retval = file!!.absolutePath |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4059 throw java.lang.RuntimeException() |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4060 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4061 }) |
2526
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4062 if(ext != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4063 fc.setExtension(ext) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4064 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4065 fc.showDialog() |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4066 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4067 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4068 // 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
|
4069 try { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4070 Looper.loop() |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4071 } catch (e2: RuntimeException) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4072 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4073 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4074 return retval |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4075 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4076 |
2486
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
4077 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
|
4078 { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4079 var retval = 0 |
2486
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
4080 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4081 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4082 // make a text input dialog and show it |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
4083 val 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
|
4084 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4085 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
|
4086 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
|
4087 if ((flags and (1 shl 3)) != 0) { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4088 alert.setPositiveButton("Yes" |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4089 ) |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4090 //R.string.yes, |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4091 { _: DialogInterface, _: Int -> |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4092 retval = 1 |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4093 throw java.lang.RuntimeException() |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4094 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4095 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4096 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
|
4097 alert.setNegativeButton( |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4098 R.string.ok |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4099 ) { _: DialogInterface, _: Int -> |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4100 retval = 0 |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4101 throw java.lang.RuntimeException() |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4102 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4103 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4104 if ((flags and ((1 shl 3) or (1 shl 4))) != 0) { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4105 alert.setNegativeButton("No" |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4106 ) |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4107 //R.string.no, |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4108 { _: DialogInterface, _: Int -> |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4109 retval = 0 |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4110 throw java.lang.RuntimeException() |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4111 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4112 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4113 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
|
4114 alert.setNeutralButton( |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4115 R.string.cancel |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4116 ) { _: DialogInterface, _: Int -> |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4117 retval = 2 |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4118 throw java.lang.RuntimeException() |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4119 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4120 } |
2573
ea75e295025b
Android: Make message boxes modal (not cancelable).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2572
diff
changeset
|
4121 alert.setCancelable(false) |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4122 alert.show() |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4123 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4124 // 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
|
4125 try { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4126 Looper.loop() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4127 } 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
|
4128 } |
2486
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
4129 } |
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
4130 return retval |
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
4131 } |
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
4132 |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
4133 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
|
4134 { |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
4135 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
|
4136 return true |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
4137 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
4138 return false |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
4139 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
4140 |
2514
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4141 fun mainSleep(milliseconds: Int) |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4142 { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4143 // 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
|
4144 // 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
|
4145 // 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
|
4146 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
|
4147 val starttime = System.currentTimeMillis() |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4148 |
2637
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
4149 // Waiting for Idle to check for sleep expiration |
2514
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4150 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
|
4151 var thrown: Boolean = false |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4152 |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4153 override fun queueIdle(): Boolean { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4154 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
|
4155 if (thrown == false) { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4156 thrown = true |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4157 throw java.lang.RuntimeException() |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4158 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4159 return false |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4160 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4161 return true |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4162 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4163 }) |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4164 |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4165 // 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
|
4166 try { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4167 Looper.loop() |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4168 } catch (e2: RuntimeException) { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4169 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4170 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4171 else |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4172 { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4173 // 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
|
4174 Thread.sleep(milliseconds.toLong()) |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4175 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4176 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4177 |
2487
83f8f4f58a98
Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2486
diff
changeset
|
4178 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
|
4179 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4180 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4181 this.finishAffinity() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4182 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
|
4183 } |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
4184 } |
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
4185 |
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
4186 fun dwindowsShutdown() |
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
4187 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4188 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4189 this.finishAffinity() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4190 } |
2487
83f8f4f58a98
Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2486
diff
changeset
|
4191 } |
83f8f4f58a98
Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2486
diff
changeset
|
4192 |
2542
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
4193 fun dwInit(appid: String, appname: String): Int |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4194 { |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
4195 appID = appid |
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
4196 |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4197 waitOnUiThread { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4198 // 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
|
4199 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
|
4200 // Create the NotificationChannel |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4201 val importance = NotificationManager.IMPORTANCE_DEFAULT |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4202 val mChannel = NotificationChannel(appid, appname, importance) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4203 // 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
|
4204 // or other notification behaviors after this |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4205 val notificationManager = |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4206 getSystemService(NOTIFICATION_SERVICE) as NotificationManager |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4207 notificationManager.createNotificationChannel(mChannel) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4208 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4209 } |
2542
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
4210 return Build.VERSION.SDK_INT |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
4211 } |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
4212 |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
4213 fun dwMain() |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
4214 { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
4215 runOnUiThread { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
4216 // Trigger the options menu to update when dw_main() is called |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
4217 invalidateOptionsMenu() |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
4218 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
4219 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
4220 |
2542
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
4221 fun androidGetRelease(): String |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
4222 { |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
4223 return Build.VERSION.RELEASE |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4224 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4225 |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4226 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
|
4227 { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4228 var builder: NotificationCompat.Builder? = null |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4229 |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4230 waitOnUiThread { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4231 builder = NotificationCompat.Builder(this, appid) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4232 .setContentTitle(title) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4233 .setContentText(text) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4234 .setPriority(NotificationCompat.PRIORITY_DEFAULT) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4235 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4236 return builder |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4237 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4238 |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4239 fun notificationSend(builder: NotificationCompat.Builder) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4240 { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4241 waitOnUiThread { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4242 notificationID += 1 |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4243 with(NotificationManagerCompat.from(this)) { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4244 // 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
|
4245 notify(notificationID, builder.build()) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4246 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4247 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4248 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4249 |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
4250 /* |
2594
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4251 * This method will parse out the real local file path from the file content URI. |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4252 */ |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4253 private fun getUriRealPath(ctx: Context?, uri: Uri?): String? { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4254 var ret: String? = "" |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4255 if (ctx != null && uri != null) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4256 if (isContentUri(uri)) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4257 if (isGooglePhotoDoc(uri.authority)) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4258 ret = uri.lastPathSegment |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4259 } else { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4260 ret = getImageRealPath(contentResolver, uri, null) |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4261 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4262 } else if (isFileUri(uri)) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4263 ret = uri.path |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4264 } else if (isDocumentUri(ctx, uri)) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4265 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4266 // Get uri related document id. |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4267 val documentId = DocumentsContract.getDocumentId(uri) |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4268 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4269 // Get uri authority. |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4270 val uriAuthority: String? = uri.authority |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4271 if (isMediaDoc(uriAuthority)) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4272 val idArr = documentId.split(":").toTypedArray() |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4273 if (idArr.size == 2) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4274 // First item is document type. |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4275 val docType = idArr[0] |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4276 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4277 // Second item is document real id. |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4278 val realDocId = idArr[1] |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4279 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4280 // Get content uri by document type. |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4281 var mediaContentUri: Uri? = MediaStore.Images.Media.EXTERNAL_CONTENT_URI |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4282 if ("image" == docType) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4283 mediaContentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4284 } else if ("video" == docType) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4285 mediaContentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4286 } else if ("audio" == docType) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4287 mediaContentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4288 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4289 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4290 // Get where clause with real document id. |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4291 val whereClause = MediaStore.Images.Media._ID + " = " + realDocId |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4292 ret = getImageRealPath(contentResolver, mediaContentUri, whereClause) |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4293 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4294 } else if (isDownloadDoc(uriAuthority)) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4295 // Build download uri. |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4296 val downloadUri: Uri = Uri.parse("content://downloads/public_downloads") |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4297 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4298 // Append download document id at uri end. |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4299 val downloadUriAppendId: Uri = |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4300 ContentUris.withAppendedId(downloadUri, java.lang.Long.valueOf(documentId)) |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4301 ret = getImageRealPath(contentResolver, downloadUriAppendId, null) |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4302 } else if (isExternalStoreDoc(uriAuthority)) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4303 val idArr = documentId.split(":").toTypedArray() |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4304 if (idArr.size == 2) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4305 val type = idArr[0] |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4306 val realDocId = idArr[1] |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4307 if ("primary".equals(type, ignoreCase = true)) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4308 ret = Environment.getExternalStorageDirectory() |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4309 .toString() + "/" + realDocId |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4310 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4311 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4312 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4313 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4314 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4315 return ret |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4316 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4317 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4318 /* Check whether this uri represent a document or not. */ |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4319 private fun isDocumentUri(ctx: Context?, uri: Uri?): Boolean { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4320 var ret = false |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4321 if (ctx != null && uri != null) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4322 ret = DocumentsContract.isDocumentUri(ctx, uri) |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4323 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4324 return ret |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4325 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4326 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4327 /* Check whether this uri is a content uri or not. |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4328 * content uri like content://media/external/images/media/1302716 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4329 */ |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4330 private fun isContentUri(uri: Uri?): Boolean { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4331 var ret = false |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4332 if (uri != null) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4333 val uriSchema: String? = uri.scheme |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4334 if ("content".equals(uriSchema, ignoreCase = true)) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4335 ret = true |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4336 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4337 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4338 return ret |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4339 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4340 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4341 /* Check whether this uri is a file uri or not. |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4342 * file uri like file:///storage/41B7-12F1/DCIM/Camera/IMG_20180211_095139.jpg |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4343 */ |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4344 private fun isFileUri(uri: Uri?): Boolean { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4345 var ret = false |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4346 if (uri != null) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4347 val uriSchema: String? = uri.scheme |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4348 if ("file".equals(uriSchema, ignoreCase = true)) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4349 ret = true |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4350 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4351 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4352 return ret |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4353 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4354 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4355 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4356 /* Check whether this document is provided by ExternalStorageProvider. Return true means the file is saved in external storage. */ |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4357 private fun isExternalStoreDoc(uriAuthority: String?): Boolean { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4358 var ret = false |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4359 if (uriAuthority != null && "com.android.externalstorage.documents" == uriAuthority) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4360 ret = true |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4361 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4362 return ret |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4363 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4364 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4365 /* Check whether this document is provided by DownloadsProvider. return true means this file is a downloaed file. */ |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4366 private fun isDownloadDoc(uriAuthority: String?): Boolean { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4367 var ret = false |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4368 if (uriAuthority != null && "com.android.providers.downloads.documents" == uriAuthority) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4369 ret = true |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4370 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4371 return ret |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4372 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4373 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4374 /* |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4375 * Check if MediaProvider provide this document, if true means this image is created in android media app. |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4376 */ |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4377 private fun isMediaDoc(uriAuthority: String?): Boolean { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4378 var ret = false |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4379 if (uriAuthority != null && "com.android.providers.media.documents" == uriAuthority) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4380 ret = true |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4381 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4382 return ret |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4383 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4384 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4385 /* |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4386 * Check whether google photos provide this document, if true means this image is created in google photos app. |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4387 */ |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4388 private fun isGooglePhotoDoc(uriAuthority: String?): Boolean { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4389 var ret = false |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4390 if (uriAuthority != null && "com.google.android.apps.photos.content" == uriAuthority) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4391 ret = true |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4392 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4393 return ret |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4394 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4395 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4396 /* Return uri represented document file real local path.*/ |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4397 private fun getImageRealPath( |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4398 contentResolver: ContentResolver, |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4399 uri: Uri?, |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4400 whereClause: String? |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4401 ): String { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4402 var ret = "" |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4403 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4404 if(uri != null) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4405 // Query the uri with condition. |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4406 val cursor: Cursor? = contentResolver.query(uri, null, whereClause, null, null) |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4407 if (cursor != null) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4408 val moveToFirst: Boolean = cursor.moveToFirst() |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4409 if (moveToFirst) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4410 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4411 // Get columns name by uri type. |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4412 var columnName = MediaStore.Images.Media.DATA |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4413 if (uri === MediaStore.Images.Media.EXTERNAL_CONTENT_URI) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4414 columnName = MediaStore.Images.Media.DATA |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4415 } else if (uri === MediaStore.Audio.Media.EXTERNAL_CONTENT_URI) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4416 columnName = MediaStore.Audio.Media.DATA |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4417 } else if (uri === MediaStore.Video.Media.EXTERNAL_CONTENT_URI) { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4418 columnName = MediaStore.Video.Media.DATA |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4419 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4420 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4421 // Get column index. |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4422 val imageColumnIndex: Int = cursor.getColumnIndex(columnName) |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4423 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4424 // Get column value which is the uri related file local path. |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4425 ret = cursor.getString(imageColumnIndex) |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4426 // Clean up |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4427 cursor.close() |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4428 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4429 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4430 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4431 return ret |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4432 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4433 |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
4434 /* |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
4435 * 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
|
4436 * 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
|
4437 */ |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
4438 external fun dwindowsInit(dataDir: String, cacheDir: 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
|
4439 external fun eventHandler( |
2499
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4440 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
|
4441 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
|
4442 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
|
4443 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
|
4444 str2: String?, |
2499
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4445 inta: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4446 intb: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4447 intc: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4448 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
|
4449 ): Int |
2499
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4450 external fun eventHandlerInt( |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4451 obj1: View, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4452 message: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4453 inta: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4454 intb: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4455 intc: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4456 intd: Int |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4457 ) |
2483
9f7af6d8c6a4
Android: Fix signal handlers so they actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2482
diff
changeset
|
4458 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
|
4459 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
|
4460 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
|
4461 external fun eventHandlerHTMLResult(obj1: View, message: Int, result: String, data: Long) |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
4462 external fun eventHandlerContainer(obj1: View, message: Int, title: String?, x: Int, y: Int, data: Long) |
2596
60ec91d23746
Android: Add initial keyboard support for Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2595
diff
changeset
|
4463 external fun eventHandlerKey(obj1: View, message: Int, character: Int, vk: Int, modifiers: Int, str: String) |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4464 |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
4465 companion object |
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
4466 { |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4467 // 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
|
4468 init |
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
4469 { |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4470 System.loadLibrary("dwindows") |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4471 } |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4472 } |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4473 } |