Mercurial > dwindows
annotate android/DWindows.kt @ 2701:9df2c11f020f
Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor().
Calling the wrong method in dw_mle_set_cursor().
Set maxWidth on MLE resize based on Word Wrap setting.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 16 Nov 2021 20:15:18 +0000 |
parents | cee79add3669 |
children | 4f12dc8e8f18 |
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 |
2694
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
65 import android.content.Intent |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
66 |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
67 |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
68 |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
69 |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 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
|
79 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 } |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
92 |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
93 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
|
94 |
2495
5664c91d03fb
Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2494
diff
changeset
|
95 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
|
96 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
|
97 val pageList = mutableListOf<Long>() |
2692
231f9489a38a
Android: Keep a list of tab titles in the ViewPager2 adapter and set titles in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2691
diff
changeset
|
98 val titleList = mutableListOf<String?>() |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
99 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
|
100 var recyclerView: RecyclerView? = null |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
101 |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
102 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
|
103 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
|
104 |
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
|
105 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
|
106 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
|
107 return position |
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
108 } |
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
|
109 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
|
110 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
|
111 } |
2495
5664c91d03fb
Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2494
diff
changeset
|
112 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
|
113 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
|
114 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
115 |
2498
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
116 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
|
117 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
118 |
2505
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
119 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
|
120 //Implement shouldOverrideUrlLoading// |
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 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
|
122 // 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
|
123 // 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
|
124 return false |
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 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
|
127 // 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
|
128 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
|
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 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
|
132 // 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
|
133 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
|
134 } |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
135 |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
136 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
|
137 } |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
138 |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
139 class DWSpinButton(context: Context) : AppCompatEditText(context), OnTouchListener { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
140 var value: Long = 0 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
141 var minimum: Long = 0 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
142 var maximum: Long = 65535 |
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 init { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
145 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
|
146 setOnTouchListener(this) |
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 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
149 override fun onTouch(v: View, event: MotionEvent): Boolean { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
150 val DRAWABLE_RIGHT = 2 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
151 val DRAWABLE_LEFT = 0 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
152 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
153 if (event.action == MotionEvent.ACTION_UP) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
154 if (event.x >= v.width - (v as EditText) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
155 .compoundDrawables[DRAWABLE_RIGHT].bounds.width() |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
156 ) { |
2527
eec926265888
Android: Use toLongOrNull() whenever converting from string to long...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2526
diff
changeset
|
157 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
|
158 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
159 if(newvalue != null) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
160 value = newvalue + 1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
161 } else { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
162 value += 1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
163 } |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
164 if(value > maximum) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
165 value = maximum |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
166 } |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
167 if(value < minimum) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
168 value = minimum |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
169 } |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
170 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
|
171 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
|
172 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
|
173 } 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
|
174 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
|
175 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
176 if(newvalue != null) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
177 value = newvalue - 1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
178 } else { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
179 value -= 1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
180 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
181 if(value > maximum) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
182 value = maximum |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
183 } |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
184 if(value < minimum) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
185 value = minimum |
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 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
|
188 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
|
189 return true |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
190 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
191 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
192 return false |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
193 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
194 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
195 external fun eventHandlerInt( |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
196 message: Int, |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
197 inta: Int, |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
198 intb: Int, |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
199 intc: Int, |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
200 intd: Int |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
201 ) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
202 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
203 |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
204 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
|
205 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
|
206 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
|
207 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
|
208 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
209 init { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
210 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
|
211 setOnTouchListener(this) |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
212 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
|
213 lpw!!.setAdapter( |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
214 ArrayAdapter( |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
215 context, |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
216 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
|
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 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
|
220 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
|
221 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
|
222 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
223 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
224 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
|
225 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
|
226 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
|
227 setText(item) |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
228 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
|
229 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
|
230 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
231 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
232 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
|
233 val DRAWABLE_RIGHT = 2 |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
234 |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
235 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
|
236 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
|
237 .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
|
238 ) { |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
239 lpw!!.show() |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
240 return true |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
241 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
242 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
243 return false |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
244 } |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
245 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
246 external fun eventHandlerInt( |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
247 message: Int, |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
248 inta: Int, |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
249 intb: Int, |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
250 intc: Int, |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
251 intd: Int |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
252 ) |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
253 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
254 |
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 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
|
256 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
|
257 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
|
258 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
|
259 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
|
260 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
261 init { |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
262 setAdapter( |
2677
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
263 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
|
264 context, |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
265 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
|
266 ) { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
267 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
|
268 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
|
269 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
|
270 if (colorFore != null) { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
271 textview.setTextColor(colorFore!!) |
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 if (colorBack != null) { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
274 textview.setBackgroundColor(colorBack!!) |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
275 } |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
276 return thisview |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
277 } |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
278 } |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
279 ) |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
280 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
|
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 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
|
284 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
|
285 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
|
286 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
287 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
288 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
|
289 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
|
290 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
|
291 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
|
292 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
|
293 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
|
294 ) |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
295 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
296 |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
297 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
|
298 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
|
299 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
|
300 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
|
301 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
|
302 var evy: Float = 0f |
2611
ed2c4a503666
Android: Implement button release and motion notify events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2608
diff
changeset
|
303 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
|
304 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
305 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
|
306 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
|
307 // 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
|
308 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
|
309 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
310 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
311 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
|
312 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
|
313 cachedCanvas = canvas |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
314 // 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
|
315 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
|
316 cachedCanvas = null |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
317 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
318 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
319 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
|
320 message: Int, |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
321 inta: Int, |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
322 intb: Int, |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
323 intc: Int, |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
324 intd: Int |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
325 ) |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
326 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
327 |
2526
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
328 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
|
329 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
|
330 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
|
331 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
|
332 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
333 // 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
|
334 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
|
335 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
|
336 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
|
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 // 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
|
340 interface FileSelectedListener { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
341 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
|
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 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
|
345 this.fileListener = fileListener |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
346 return this |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
347 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
348 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
349 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
|
350 fun showDialog() { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
351 dialog.show() |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
352 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
353 |
2527
eec926265888
Android: Use toLongOrNull() whenever converting from string to long...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2526
diff
changeset
|
354 /* |
2526
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
355 * 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
|
356 */ |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
357 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
|
358 currentPath = path |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
359 if (path != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
360 if (path.exists()) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
361 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
|
362 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
|
363 if (!file.isDirectory) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
364 if (!file.canRead()) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
365 false |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
366 } 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
|
367 true |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
368 } else { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
369 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
|
370 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
371 } else { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
372 false |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
373 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
374 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
375 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
376 // 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
|
377 var i = 0 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
378 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
|
379 var filecount = 0 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
380 var dircount = 0 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
381 if(files != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
382 filecount = files.size |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
383 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
384 if(dirs != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
385 dircount = dirs.size |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
386 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
387 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
|
388 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
|
389 } else { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
390 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
|
391 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
|
392 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
393 if(dirs != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
394 Arrays.sort(dirs) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
395 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
|
396 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
|
397 } |
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 if(files != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
400 Arrays.sort(files) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
401 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
|
402 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
|
403 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
404 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
405 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
406 // 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
|
407 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
|
408 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
|
409 activity, |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
410 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
|
411 ) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
412 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
|
413 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
|
414 (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
|
415 return thisview |
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 } |
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 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
421 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
422 /** |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
423 * 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
|
424 */ |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
425 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
|
426 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
|
427 currentPath!!.parentFile |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
428 } else { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
429 File(currentPath, fileChosen) |
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 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
433 companion object { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
434 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
|
435 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
436 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
437 init { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
438 list.onItemClickListener = |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
439 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
|
440 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
|
441 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
|
442 if (chosenFile != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
443 if (chosenFile.isDirectory) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
444 refresh(chosenFile) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
445 } else { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
446 if (fileListener != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
447 fileListener!!.fileSelected(chosenFile) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
448 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
449 dialog.dismiss() |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
450 } |
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 dialog.setContentView(list) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
454 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
|
455 refresh(Environment.getExternalStorageDirectory()) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
456 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
457 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
458 |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
459 // 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
|
460 // 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
|
461 // 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
|
462 class DWMenuItem |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
463 { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
464 var title: String? = null |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
465 var menu: DWMenu? = null |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
466 var submenu: DWMenu? = null |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
467 var checked: Boolean = false |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
468 var check: Boolean = false |
2546
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
469 var enabled: Boolean = true |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
470 var menuitem: MenuItem? = null |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
471 var submenuitem: SubMenu? = null |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
472 var id: Int = 0 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
473 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
474 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
475 class DWMenu { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
476 var menu: Menu? = null |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
477 var children = mutableListOf<DWMenuItem>() |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
478 var id: Int = 0 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
479 |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
480 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
|
481 var refresh = recreate |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
482 |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
483 if(newmenu != null) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
484 if(newmenu != menu) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
485 menu = newmenu |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
486 refresh = true |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
487 } |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
488 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
489 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
|
490 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
|
491 |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
492 if(refresh) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
493 menu!!.clear() |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
494 } |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
495 |
2544
dbfcc0e357d6
Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2543
diff
changeset
|
496 // 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
|
497 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
|
498 |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
499 for (menuitem in children) { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
500 // 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
|
501 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
|
502 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
|
503 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
|
504 } |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
505 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
|
506 } 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
|
507 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
|
508 group += 1 |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
509 } 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
|
510 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
|
511 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
|
512 menuitem.menuitem!!.isChecked = menuitem.checked |
2546
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
513 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
|
514 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
|
515 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
|
516 true |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
517 } |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
518 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
519 } |
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 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
522 } |
2544
dbfcc0e357d6
Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2543
diff
changeset
|
523 |
dbfcc0e357d6
Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2543
diff
changeset
|
524 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
|
525 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
526 |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
527 // Class for storing container data |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
528 class DWContainerModel { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
529 var columns = mutableListOf<String?>() |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
530 var types = mutableListOf<Int>() |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
531 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
|
532 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
|
533 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
|
534 var querypos: Int = -1 |
2555
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 numberOfColumns(): Int |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
537 { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
538 return columns.size |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
539 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
540 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
541 fun numberOfRows(): Int |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
542 { |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
543 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
|
544 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
|
545 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
546 return 0 |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
547 } |
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 fun getColumnType(column: Int): Int |
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 if(column < types.size) { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
552 return types[column] |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
553 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
554 return -1 |
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 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
557 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
|
558 { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
559 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
|
560 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
561 if(index > -1 && index < data.size) { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
562 return data[index] |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
563 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
564 return null |
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 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
567 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
|
568 { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
569 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
|
570 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
571 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
|
572 // 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
|
573 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
|
574 (((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
|
575 (((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
|
576 data[index] = obj |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
577 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
578 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
579 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
580 |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
581 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
|
582 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
583 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
|
584 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
|
585 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
586 } |
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 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
|
589 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
590 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
|
591 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
|
592 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
593 return 0 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
594 } |
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 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
|
597 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
598 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
|
599 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
|
600 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
601 } |
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 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
|
604 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
605 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
|
606 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
|
607 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
608 return null |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
609 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
610 |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
611 fun addColumn(title: String?, type: Int) |
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 columns.add(title) |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
614 types.add(type) |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
615 // 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
|
616 data.clear() |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
617 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
618 |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
619 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
|
620 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
621 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
|
622 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
|
623 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
|
624 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
|
625 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
626 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
|
627 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
|
628 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
629 } else { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
630 data.clear() |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
631 rowdata.clear() |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
632 rowtitle.clear() |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
633 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
634 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
635 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
636 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
|
637 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
638 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
|
639 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
|
640 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
|
641 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
|
642 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
643 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
|
644 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
|
645 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
646 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
647 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
648 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
649 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
|
650 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
651 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
|
652 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
|
653 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
|
654 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
|
655 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
656 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
|
657 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
|
658 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
659 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
660 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
661 |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
662 fun addRows(count: Int): Long |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
663 { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
664 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
|
665 |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
666 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
|
667 { |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
668 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
|
669 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
670 // 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
|
671 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
|
672 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
673 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
|
674 rowtitle.add(null) |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
675 } |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
676 return startRow |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
677 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
678 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
679 fun clear() |
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 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
|
682 rowdata.clear() |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
683 rowtitle.clear() |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
684 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
685 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
686 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
687 class DWContainerAdapter(c: Context) : BaseAdapter() |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
688 { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
689 private var context = c |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
690 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
|
691 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
|
692 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
|
693 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
|
694 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
|
695 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
|
696 var backColor: Int? = null |
2613
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
697 var lastClick: Long = 0 |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
698 var lastClickRow: Int = -1 |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
699 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
700 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
|
701 return model.numberOfRows() |
2555
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 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
704 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
|
705 return model.getRowAndColumn(position, 0) |
2555
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 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
708 override fun getItemId(position: Int): Long { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
709 return position.toLong() |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
710 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
711 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
712 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
|
713 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
|
714 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
|
715 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
716 // 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
|
717 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
|
718 // 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
|
719 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
|
720 (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
|
721 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
|
722 } else { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
723 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
|
724 } |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
725 } |
2561
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
726 |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
727 // 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
|
728 if(rowView == null) { |
2568
b536b7b21682
Android: Switch to using LinearLayout for Container row layout...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2567
diff
changeset
|
729 rowView = LinearLayout(context) |
b536b7b21682
Android: Switch to using LinearLayout for Container row layout...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2567
diff
changeset
|
730 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
|
731 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
732 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
|
733 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
|
734 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
735 // Image |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
736 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
|
737 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
|
738 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
|
739 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
|
740 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
|
741 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
|
742 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
|
743 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
|
744 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
|
745 } |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
746 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
|
747 } else { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
748 // 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
|
749 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
|
750 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
|
751 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
|
752 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
|
753 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
|
754 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
|
755 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
|
756 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
|
757 } 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
|
758 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
|
759 } |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
760 rowView.addView(textview) |
2561
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
761 } |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
762 } |
2561
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
763 // 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
|
764 } else { |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
765 // 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
|
766 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
767 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
|
768 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
|
769 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
770 // Image |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
771 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
|
772 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
|
773 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
774 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
|
775 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
|
776 } |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
777 } else { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
778 // Text |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
779 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
|
780 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
781 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
|
782 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
|
783 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
|
784 } 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
|
785 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
|
786 } |
2677
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
787 if(foreColor != null) { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
788 textview.setTextColor(foreColor!!) |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
789 } |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
790 } |
2561
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
791 } |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
792 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
793 } |
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
|
794 // 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
|
795 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
|
796 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
|
797 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
|
798 } 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
|
799 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
|
800 } |
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 } 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
|
802 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
|
803 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
|
804 } 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
|
805 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
|
806 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
807 } |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
808 return rowView |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
809 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
810 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
811 |
2701
9df2c11f020f
Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2694
diff
changeset
|
812 private class DWMLE(c: Context): androidx.appcompat.widget.AppCompatEditText(c) { |
9df2c11f020f
Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2694
diff
changeset
|
813 protected override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { |
9df2c11f020f
Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2694
diff
changeset
|
814 if(!isHorizontalScrollBarEnabled) { |
9df2c11f020f
Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2694
diff
changeset
|
815 this.maxWidth = w |
9df2c11f020f
Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2694
diff
changeset
|
816 } else { |
9df2c11f020f
Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2694
diff
changeset
|
817 this.maxWidth = -1 |
9df2c11f020f
Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2694
diff
changeset
|
818 } |
9df2c11f020f
Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2694
diff
changeset
|
819 super.onSizeChanged(w, h, oldw, oldh) |
9df2c11f020f
Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2694
diff
changeset
|
820 } |
9df2c11f020f
Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2694
diff
changeset
|
821 } |
9df2c11f020f
Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2694
diff
changeset
|
822 |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
823 class DWindows : AppCompatActivity() { |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
824 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
|
825 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
|
826 var threadCond = threadLock.newCondition() |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
827 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
|
828 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
|
829 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
|
830 private var appID: String? = null |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
831 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
|
832 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
|
833 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
|
834 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
|
835 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
|
836 // 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
|
837 private var windowTitles = mutableListOf<String?>() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
838 private var windowMenuBars = mutableListOf<DWMenu?>() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
839 private var windowStyles = mutableListOf<Int>() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
840 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
|
841 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
842 // 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
|
843 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
|
844 { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
845 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
|
846 runnable.run() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
847 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
848 threadLock.lock() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
849 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
|
850 threadLock.lock() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
851 runnable.run() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
852 threadCond.signal() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
853 threadLock.unlock() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
854 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
855 runOnUiThread(ourRunnable) |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
856 threadCond.await() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
857 threadLock.unlock() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
858 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
859 } |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
860 |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
861 // 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
|
862 // 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
|
863 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
|
864 val length = filename.length |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
865 |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
866 for (ext in DWImageExts) { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
867 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
|
868 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
|
869 try { |
3a14d7fd4b99
Android: Catch NumberFormatException in isDWResource().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2658
diff
changeset
|
870 if (filebody.toInt() > 0) { |
3a14d7fd4b99
Android: Catch NumberFormatException in isDWResource().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2658
diff
changeset
|
871 return true |
3a14d7fd4b99
Android: Catch NumberFormatException in isDWResource().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2658
diff
changeset
|
872 } |
3a14d7fd4b99
Android: Catch NumberFormatException in isDWResource().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2658
diff
changeset
|
873 } catch(e: NumberFormatException) { |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
874 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
875 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
876 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
877 return false |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
878 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
879 |
2659
3a14d7fd4b99
Android: Catch NumberFormatException in isDWResource().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2658
diff
changeset
|
880 // 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
|
881 private fun extractAssets() { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
882 var zipFile: ZipFile? = null |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
883 val targetDir = cacheDir |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
884 |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
885 try { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
886 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
|
887 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
|
888 while (e.hasMoreElements()) { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
889 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
|
890 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
|
891 isDWResource(entry.name)) { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
892 continue |
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 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
|
895 targetFile.parentFile!!.mkdirs() |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
896 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
|
897 var ais: BufferedInputStream? = null |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
898 var aos: FileOutputStream? = null |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
899 try { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
900 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
|
901 aos = FileOutputStream(targetFile) |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
902 ais.read(tempBuffer) |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
903 aos.write(tempBuffer) |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
904 } catch (e: IOException) { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
905 } finally { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
906 ais?.close() |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
907 aos?.close() |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
908 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
909 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
910 } catch (e: IOException) { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
911 } finally { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
912 zipFile?.close() |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
913 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
914 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
915 |
2498
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
916 // 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
|
917 // 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
|
918 // 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
|
919 // 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
|
920 // 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
|
921 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
|
922 super.onCreate(savedInstanceState) |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
923 |
2480
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
924 // Turn on rotation |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
925 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
|
926 |
2498
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
927 // 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
|
928 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
|
929 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
|
930 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
|
931 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
|
932 val c = cacheDir.path |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
933 |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
934 // 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
|
935 // 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
|
936 // other Dynamic Windows platforms |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
937 extractAssets() |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
938 |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
939 // 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
|
940 windowLayout = ViewPager2(this) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
941 windowLayout!!.id = View.generateViewId() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
942 windowLayout!!.adapter = DWTabViewPagerAdapter() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
943 windowLayout!!.isUserInputEnabled = false |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
944 windowLayout!!.layoutParams = |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
945 ViewGroup.LayoutParams( |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
946 ViewGroup.LayoutParams.MATCH_PARENT, |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
947 ViewGroup.LayoutParams.MATCH_PARENT |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
948 ) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
949 |
2498
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
950 // 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
|
951 // 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
|
952 dwindowsInit(s, c, this.getPackageName()) |
2496
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
953 } |
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
954 |
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
955 override fun onConfigurationChanged(newConfig: Configuration) { |
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
956 super.onConfigurationChanged(newConfig) |
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
957 |
2551
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
958 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
|
959 when (currentNightMode) { |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
960 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
|
961 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
|
962 } |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
963 |
2499
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
964 // 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
|
965 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
|
966 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
|
967 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
|
968 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
|
969 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
|
970 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
|
971 |
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
972 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
|
973 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
|
974 |
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
975 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
|
976 } |
2496
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
977 } |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
978 } |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
979 |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
980 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
|
981 if(windowLayout != null) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
982 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
|
983 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
|
984 |
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
985 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
|
986 var menuBar = windowMenuBars[index] |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
987 |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
988 if(menuBar == null) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
989 menuBar = DWMenu() |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
990 windowMenuBars[index] = menuBar |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
991 } |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
992 menuBar!!.menu = menu |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
993 return super.onCreateOptionsMenu(menu) |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
994 } |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
995 } |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
996 return false |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
997 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
998 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
999 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
|
1000 if(windowLayout != null) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1001 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
|
1002 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
|
1003 |
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
1004 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
|
1005 var menuBar = windowMenuBars[index] |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1006 |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1007 if(menuBar != null) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1008 menuBar!!.createMenu(menu, true) |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1009 } else { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1010 menuBar = DWMenu() |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1011 menuBar!!.createMenu(menu, true) |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1012 windowMenuBars[index] = menuBar |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1013 } |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1014 return super.onPrepareOptionsMenu(menu) |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1015 } |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1016 } |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1017 return false |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1018 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1019 |
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
|
1020 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
|
1021 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
|
1022 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
|
1023 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
|
1024 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
|
1025 |
2670
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
1026 // 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
|
1027 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
|
1028 // 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
|
1029 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
|
1030 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1031 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1032 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1033 |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1034 // 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
|
1035 // 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
|
1036 |
2551
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1037 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
|
1038 { |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1039 return darkMode |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1040 } |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1041 |
2694
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
1042 fun browseURL(url: String): Int { |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
1043 var retval: Int = -1 // DW_ERROR_UNKNOWN |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
1044 |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
1045 waitOnUiThread { |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
1046 val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
1047 try { |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
1048 retval = 0 // DW_ERROR_NONE |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
1049 startActivity(browserIntent) |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
1050 } catch (e: ActivityNotFoundException) { |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
1051 retval = -1 // DW_ERROR_UNKNOWN |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
1052 } |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
1053 } |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
1054 return retval |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
1055 } |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
1056 |
2607
3b9bbd69bb9c
Android: Implement dw_menu_popup() ... still need to implement the context events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2596
diff
changeset
|
1057 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
|
1058 { |
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
|
1059 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
|
1060 |
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
1061 // 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
|
1062 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
|
1063 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
|
1064 } |
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
1065 |
2607
3b9bbd69bb9c
Android: Implement dw_menu_popup() ... still need to implement the context events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2596
diff
changeset
|
1066 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
|
1067 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
|
1068 |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1069 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
|
1070 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
|
1071 } |
3b9bbd69bb9c
Android: Implement dw_menu_popup() ... still need to implement the context events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2596
diff
changeset
|
1072 } |
3b9bbd69bb9c
Android: Implement dw_menu_popup() ... still need to implement the context events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2596
diff
changeset
|
1073 |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1074 fun menuBarNew(location: View): DWMenu? |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1075 { |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1076 var menuBar: DWMenu? = null |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1077 |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1078 if(windowLayout != null) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1079 waitOnUiThread { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1080 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
|
1081 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
|
1082 |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1083 if (index != -1) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1084 menuBar = DWMenu() |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1085 windowMenuBars[index] = menuBar |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1086 } |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1087 } |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
1088 } |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1089 return menuBar |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1090 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1091 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1092 fun menuNew(cid: Int): DWMenu |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1093 { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1094 val menu = DWMenu() |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1095 menu.id = cid |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1096 return menu |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1097 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1098 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1099 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
|
1100 { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1101 val menuitem = DWMenuItem() |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1102 menuitem.id = cid |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1103 menuitem.title = title |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1104 menuitem.check = check != 0 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1105 if(submenu != null) { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1106 menuitem.submenu = submenu |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1107 } |
2546
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1108 if((flags and (1 shl 1)) != 0) { |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1109 menuitem.enabled = false |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1110 } |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1111 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
|
1112 menuitem.checked = true |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1113 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1114 if(end == 0) { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1115 menu.children.add(0, menuitem) |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1116 } else { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1117 menu.children.add(menuitem) |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1118 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1119 return menuitem |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1120 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
1121 |
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
|
1122 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
|
1123 { |
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
|
1124 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
|
1125 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
|
1126 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
|
1127 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
|
1128 } |
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
|
1129 } |
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
|
1130 |
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
|
1131 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
|
1132 { |
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
|
1133 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
|
1134 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
|
1135 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
|
1136 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
|
1137 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
|
1138 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
|
1139 } |
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 } |
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 } |
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
|
1143 |
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
|
1144 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
|
1145 { |
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
|
1146 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
|
1147 if(menuitem.id == cid) { |
2546
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1148 // Handle DW_MIS_ENABLED/DISABLED |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1149 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
|
1150 var enabled = false |
2546
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1151 |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1152 // Handle DW_MIS_ENABLED |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1153 if ((state and 1) != 0) { |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1154 enabled = true |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1155 } |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1156 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
|
1157 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
|
1158 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
|
1159 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
|
1160 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
|
1161 } |
2546
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1162 } |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1163 } |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
1164 |
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
|
1165 // 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
|
1166 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
|
1167 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
|
1168 |
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
|
1169 // 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
|
1170 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
|
1171 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
|
1172 } |
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
|
1173 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
|
1174 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
|
1175 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
|
1176 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
|
1177 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
|
1178 } |
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
|
1179 } |
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
|
1180 } |
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
|
1181 } |
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
|
1182 } |
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
|
1183 } |
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
|
1184 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1185 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
|
1186 var window: LinearLayout? = null |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1187 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1188 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
|
1189 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1190 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
|
1191 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
|
1192 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1193 setContentView(windowLayout) |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1194 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1195 window = LinearLayout(this) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1196 window!!.visibility = View.GONE |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1197 window!!.tag = dataArrayMap |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1198 window!!.layoutParams = |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1199 LinearLayout.LayoutParams( |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1200 LinearLayout.LayoutParams.MATCH_PARENT, |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1201 LinearLayout.LayoutParams.MATCH_PARENT |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1202 ) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1203 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1204 // Update our window list |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1205 adapter.viewList.add(window!!) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1206 windowTitles.add(title) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1207 windowMenuBars.add(null) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1208 windowStyles.add(style) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1209 windowDefault.add(null) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1210 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1211 // 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
|
1212 // We can set stuff immediately |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1213 if (adapter.viewList.count() == 1) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1214 this.title = title |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1215 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
|
1216 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
|
1217 supportActionBar?.hide() |
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
1218 } |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1219 } |
2691
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
1220 adapter.notifyDataSetChanged() |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1221 } |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1222 } |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1223 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
|
1224 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1225 |
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
|
1226 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
|
1227 { |
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
|
1228 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
|
1229 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
|
1230 } |
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
|
1231 } |
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
|
1232 |
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
|
1233 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
|
1234 { |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1235 if(windowLayout != null) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1236 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
|
1237 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
|
1238 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1239 if (index != -1) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1240 windowDefault[index] = default |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1241 } |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1242 } |
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
|
1243 } |
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
|
1244 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1245 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
|
1246 { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1247 waitOnUiThread { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1248 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
|
1249 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
|
1250 |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1251 if (ourmask != 0) { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1252 // 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
|
1253 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
|
1254 |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1255 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
|
1256 } |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1257 } |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1258 } |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1259 } |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1260 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1261 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
|
1262 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
|
1263 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1264 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1265 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
|
1266 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
|
1267 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
|
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 (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
|
1270 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
|
1271 } else { |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1272 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
|
1273 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1274 } |
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 |
2686
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1277 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
|
1278 { |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1279 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
|
1280 |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1281 waitOnUiThread { |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1282 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
|
1283 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
|
1284 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
|
1285 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
|
1286 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
|
1287 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
|
1288 |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1289 // 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
|
1290 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
|
1291 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
|
1292 } |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1293 } |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1294 } |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1295 return retval |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1296 } |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
1297 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1298 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
|
1299 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
|
1300 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1301 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
|
1302 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
|
1303 |
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
|
1304 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
|
1305 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
|
1306 } |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1307 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1308 return retval |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1309 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1310 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1311 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
|
1312 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1313 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
|
1314 } |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
1315 } |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1316 |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1317 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
|
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 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
|
1321 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
|
1322 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
|
1323 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
|
1324 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
|
1325 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1326 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
|
1327 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
|
1328 } 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
|
1329 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
|
1330 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1331 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1332 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
|
1333 if (bold && italic) { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1334 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
|
1335 } else if (bold) { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1336 style = Typeface.BOLD |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1337 } else if (italic) { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1338 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
|
1339 } |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1340 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
|
1341 |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1342 return typeface |
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 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
|
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 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
|
1348 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
|
1349 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
|
1350 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1351 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
|
1352 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
|
1353 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1354 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1355 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
|
1356 waitOnUiThread { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1357 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
|
1358 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
|
1359 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
|
1360 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
|
1361 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
|
1362 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1363 } 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
|
1364 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
|
1365 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
|
1366 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
|
1367 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
|
1368 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1369 } 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
|
1370 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
|
1371 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
|
1372 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
|
1373 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
|
1374 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1375 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1376 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1377 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1378 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1379 |
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
|
1380 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
|
1381 { |
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
|
1382 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
|
1383 |
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
|
1384 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
|
1385 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
|
1386 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
|
1387 |
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
|
1388 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
|
1389 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
|
1390 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
|
1391 } 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
|
1392 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
|
1393 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
|
1394 } 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
|
1395 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
|
1396 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
|
1397 } |
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
|
1398 |
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
|
1399 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
|
1400 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
|
1401 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
|
1402 |
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
|
1403 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
|
1404 } |
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
|
1405 } |
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
|
1406 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
|
1407 } |
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
|
1408 |
2551
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1409 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
|
1410 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
|
1411 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
|
1412 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
|
1413 |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1414 // 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
|
1415 // 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
|
1416 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
|
1417 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
|
1418 } |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1419 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1420 waitOnUiThread { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1421 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
|
1422 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
|
1423 |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1424 // 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
|
1425 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
|
1426 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
|
1427 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
|
1428 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
|
1429 } |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1430 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
|
1431 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
|
1432 } 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
|
1433 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
|
1434 |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1435 // 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
|
1436 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
|
1437 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
|
1438 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
|
1439 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
|
1440 } |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1441 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
|
1442 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
|
1443 } 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
|
1444 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
|
1445 |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
1446 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
|
1447 } 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
|
1448 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
|
1449 |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1450 // 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
|
1451 if(fore == 16) { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1452 val value = TypedValue() |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1453 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
|
1454 colorfore = value.data |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1455 } |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1456 |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1457 listbox.colorFore = colorfore |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1458 listbox.colorBack = colorback |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1459 |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1460 listbox.setBackgroundColor(colorback) |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1461 } 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
|
1462 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
|
1463 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
|
1464 |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1465 // 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
|
1466 if(fore == 16) { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1467 val value = TypedValue() |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1468 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
|
1469 colorfore = value.data |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1470 } |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1471 |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1472 adapter.foreColor = colorfore |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1473 adapter.backColor = colorback |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1474 |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1475 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
|
1476 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1477 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1478 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
1479 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1480 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
|
1481 if(windowLayout != null) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1482 waitOnUiThread { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1483 if (window is TextView) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1484 val textview: TextView = window |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1485 textview.text = text |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1486 } else if (window is Button) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1487 val button: Button = window |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1488 button.text = text |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1489 } else if (window is LinearLayout) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1490 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
|
1491 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
|
1492 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1493 if(index != -1) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1494 windowTitles[index] = text |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1495 if(index == windowLayout!!.currentItem) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1496 this.title = text |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1497 } |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1498 } |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1499 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1500 } |
2489
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1501 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1502 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1503 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1504 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
|
1505 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
|
1506 |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1507 if(windowLayout != null) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1508 waitOnUiThread { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1509 if (window is TextView) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1510 val textview: TextView = window |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1511 text = textview.text.toString() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1512 } else if (window is Button) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1513 val button: Button = window |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1514 text = button.text.toString() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1515 } else if (window is LinearLayout) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1516 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
|
1517 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
|
1518 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1519 if(index != -1) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1520 text = windowTitles[index] |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1521 } |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1522 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1523 } |
2489
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1524 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1525 return text |
2489
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1526 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1527 |
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
|
1528 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
|
1529 { |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1530 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
|
1531 |
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 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
|
1533 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
|
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 // 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
|
1536 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
|
1537 // 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
|
1538 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
|
1539 // 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
|
1540 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
|
1541 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
|
1542 } |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1543 // 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
|
1544 // So using RecyclerView.scrollToPosition() also |
2ad924c6493d
Android: Still need to call setCurrentItem() on ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2668
diff
changeset
|
1545 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
|
1546 |
2670
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
1547 // 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
|
1548 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
|
1549 supportActionBar?.show() |
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
1550 } else { |
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
1551 supportActionBar?.hide() |
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
1552 } |
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
|
1553 // 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
|
1554 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
|
1555 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
|
1556 } |
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
|
1557 // 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
|
1558 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
|
1559 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
|
1560 } 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
|
1561 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
|
1562 } |
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
|
1563 // 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
|
1564 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
|
1565 } |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1566 } |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1567 } |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
1568 |
2503
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
1569 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
|
1570 { |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1571 if(windowLayout != null) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1572 waitOnUiThread { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1573 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
|
1574 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
|
1575 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1576 if(state == 0) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1577 window.visibility = View.GONE |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1578 } else { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1579 window.visibility = View.VISIBLE |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
1580 } |
2691
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
1581 adapter.notifyDataSetChanged() |
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
|
1582 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
|
1583 } |
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
1584 } |
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
1585 } |
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
1586 |
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
|
1587 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
|
1588 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
|
1589 |
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 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
|
1591 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
|
1592 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
|
1593 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
|
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 // 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
|
1596 // 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
|
1597 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
|
1598 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
|
1599 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
|
1600 |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1601 // 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
|
1602 // 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
|
1603 // 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
|
1604 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
|
1605 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
|
1606 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1607 // 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
|
1608 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
|
1609 |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1610 // 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
|
1611 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
|
1612 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
|
1613 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
|
1614 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
|
1615 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
|
1616 |
2691
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
1617 adapter.notifyDataSetChanged() |
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
1618 |
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
|
1619 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
|
1620 } 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
|
1621 // 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
|
1622 // 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
|
1623 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
|
1624 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
|
1625 |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1626 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
|
1627 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
|
1628 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1629 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1630 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1631 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1632 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
|
1633 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
1634 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1635 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
|
1636 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
|
1637 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
|
1638 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1639 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
|
1640 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
|
1641 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1642 return "" |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1643 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1644 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1645 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
|
1646 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
|
1647 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
|
1648 |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1649 cm.setPrimaryClip(clipdata) |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1650 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
1651 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1652 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
|
1653 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
|
1654 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1655 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
|
1656 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
|
1657 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1658 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
|
1659 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
|
1660 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
|
1661 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
|
1662 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
|
1663 ) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1664 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
|
1665 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
|
1666 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1667 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
|
1668 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1669 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
|
1670 } |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
1671 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
|
1672 } |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
1673 |
2689
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1674 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
|
1675 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
|
1676 waitOnUiThread { |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1677 box = RadioGroup(this) |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1678 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
|
1679 |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1680 box!!.tag = dataArrayMap |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1681 box!!.layoutParams = |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1682 LinearLayout.LayoutParams( |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1683 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
|
1684 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
|
1685 ) |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1686 if (type > 0) { |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1687 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
|
1688 } else { |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1689 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
|
1690 } |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1691 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
|
1692 } |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1693 return box |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1694 } |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
1695 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1696 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
|
1697 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
|
1698 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1699 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1700 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
|
1701 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
|
1702 val dataArrayMap = SimpleArrayMap<String, Long>() |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1703 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1704 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
|
1705 box.layoutParams = |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1706 LinearLayout.LayoutParams( |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1707 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
|
1708 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
|
1709 ) |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1710 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
|
1711 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
|
1712 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1713 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
|
1714 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1715 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
|
1716 // 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
|
1717 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
|
1718 scrollBox!!.addView(box) |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1719 } |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1720 return scrollBox |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1721 } |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1722 |
2683
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1723 // 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
|
1724 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
|
1725 { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1726 val parent = box.parent |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1727 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1728 if(parent is LinearLayout) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1729 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
|
1730 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1731 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
|
1732 if(params.height == 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1733 box.measure(0, 0) |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1734 val calch = box.measuredHeight |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1735 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1736 if(calch > 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1737 params.weight = calch.toFloat() |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1738 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1739 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1740 } else { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1741 if(params.width == 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1742 box.measure(0, 0) |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1743 val calcw = box.measuredWidth |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1744 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1745 if(calcw > 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1746 params.weight = calcw.toFloat() |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1747 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1748 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1749 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1750 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1751 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1752 |
2495
5664c91d03fb
Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2494
diff
changeset
|
1753 fun boxPack( |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1754 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
|
1755 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
|
1756 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
|
1757 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
|
1758 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
|
1759 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
|
1760 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
|
1761 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
|
1762 ) { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1763 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1764 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
|
1765 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
|
1766 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
|
1767 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
|
1768 |
a7868380098f
Android: LinearLayout does not allow null views, if null, create a Placeholder view.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2670
diff
changeset
|
1769 // 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
|
1770 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
|
1771 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
|
1772 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
|
1773 } |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
1774 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1775 // 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
|
1776 // 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
|
1777 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
|
1778 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
|
1779 } 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
|
1780 val sv: ScrollView = boxview |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1781 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1782 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
|
1783 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
|
1784 } |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1785 } |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1786 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1787 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
|
1788 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
|
1789 |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1790 // 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
|
1791 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
|
1792 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
|
1793 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
|
1794 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
|
1795 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
|
1796 } |
2683
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1797 if (vsize != 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1798 val calch = item.measuredHeight |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1799 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1800 if(calch > 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1801 weight = calch.toFloat() |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1802 } else { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1803 weight = 1F |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1804 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1805 h = 0 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1806 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1807 } else { |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1808 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
|
1809 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
|
1810 } |
2683
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1811 if (hsize != 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1812 val calcw = item.measuredWidth |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1813 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1814 if(calcw > 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1815 weight = calcw.toFloat() |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1816 } else { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1817 weight = 1F |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1818 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1819 w = 0 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1820 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1821 } |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1822 // 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
|
1823 } else { |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1824 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
|
1825 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
|
1826 } |
2553
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1827 if(hsize == 0) { |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1828 if (width > 0) { |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1829 w = width |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1830 } |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1831 } 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
|
1832 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
|
1833 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
|
1834 } 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
|
1835 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
|
1836 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
|
1837 } 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
|
1838 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
|
1839 |
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
|
1840 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
|
1841 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
|
1842 } |
2553
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1843 } |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1844 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1845 } |
2553
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1846 if(vsize == 0) { |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1847 if (height > 0) { |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1848 h = height |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1849 } |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1850 } 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
|
1851 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
|
1852 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
|
1853 } 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
|
1854 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
|
1855 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
|
1856 } 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
|
1857 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
|
1858 |
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
|
1859 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
|
1860 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
|
1861 } |
2553
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1862 } |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
1863 } |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1864 } |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1865 } |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1866 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1867 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
|
1868 |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1869 // 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
|
1870 // 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
|
1871 if (box.orientation == LinearLayout.VERTICAL) { |
2681
c1482518b643
Android: Fix weight based layout problems.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2677
diff
changeset
|
1872 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
|
1873 params.weight = weight |
2681
c1482518b643
Android: Fix weight based layout problems.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2677
diff
changeset
|
1874 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
|
1875 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1876 } else { |
2681
c1482518b643
Android: Fix weight based layout problems.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2677
diff
changeset
|
1877 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
|
1878 params.weight = weight |
2681
c1482518b643
Android: Fix weight based layout problems.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2677
diff
changeset
|
1879 params.width = 0 |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1880 } |
2480
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
1881 } |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1882 // 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
|
1883 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
|
1884 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
|
1885 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
|
1886 } 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
|
1887 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
|
1888 } 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
|
1889 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
|
1890 } |
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
1891 // 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
|
1892 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
|
1893 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
|
1894 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1895 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
|
1896 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
|
1897 boxUpdate(box) |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
1898 } |
2478
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
1899 } |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
1900 } |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
1901 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1902 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
|
1903 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
1904 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
|
1905 box.removeView(item) |
2683
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1906 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
|
1907 } |
2477
3fbf8783122d
Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2476
diff
changeset
|
1908 } |
3fbf8783122d
Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2476
diff
changeset
|
1909 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1910 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
|
1911 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
|
1912 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1913 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1914 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
|
1915 box.removeView(item) |
2683
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
1916 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
|
1917 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1918 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
|
1919 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
1920 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1921 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
|
1922 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
|
1923 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1924 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
|
1925 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
|
1926 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
1927 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
|
1928 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
|
1929 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
|
1930 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
|
1931 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
|
1932 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
|
1933 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
|
1934 } |
2482
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
1935 } |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
1936 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
|
1937 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
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 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
|
1940 var button: ImageButton? = null |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1941 waitOnUiThread { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1942 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
|
1943 val dataArrayMap = SimpleArrayMap<String, Long>() |
2653
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1944 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
|
1945 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1946 button!!.tag = dataArrayMap |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1947 button!!.id = resid |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1948 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
|
1949 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
|
1950 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
|
1951 } |
2653
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1952 |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1953 if(resid > 0 && resid < 65536) { |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1954 filename = resid.toString() |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
1955 } else { |
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
1956 button!!.setImageResource(resid) |
2653
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1957 } |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1958 |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1959 if(filename != null) { |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
1960 for (ext in DWImageExts) { |
2653
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1961 // 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
|
1962 try { |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1963 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
|
1964 val b = BitmapFactory.decodeStream(f) |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1965 |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1966 if (b != null) { |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1967 button!!.setImageBitmap(b) |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1968 break |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1969 } |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1970 } catch (e: IOException) { |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1971 } |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1972 } |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
1973 } |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1974 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1975 return button |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1976 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1977 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1978 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
|
1979 var button: ImageButton? = null |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1980 waitOnUiThread { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1981 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
|
1982 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
|
1983 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1984 button!!.tag = dataArrayMap |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1985 button!!.id = cid |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1986 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
|
1987 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
|
1988 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
|
1989 } |
2564
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
1990 |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
1991 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
|
1992 // 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
|
1993 try { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
1994 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
|
1995 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
|
1996 |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
1997 if(b != null) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
1998 button!!.setImageBitmap(b) |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
1999 break |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
2000 } |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
2001 } catch (e: IOException) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
2002 } |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
2003 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
2004 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
2005 return button |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
2006 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
2007 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
2008 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
|
2009 var button: ImageButton? = null |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
2010 waitOnUiThread { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
2011 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
|
2012 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
|
2013 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
|
2014 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
2015 button!!.tag = dataArrayMap |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
2016 button!!.id = cid |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
2017 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
|
2018 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
|
2019 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
|
2020 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
2021 button!!.setImageBitmap(b) |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
2022 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
2023 return button |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
2024 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
2025 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2026 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
|
2027 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
|
2028 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2029 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2030 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
|
2031 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
|
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 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
|
2034 entryfield!!.id = cid |
2554
4c75fb6089a9
Android: Need to set isSingleLine for entryfields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2553
diff
changeset
|
2035 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
|
2036 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
|
2037 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
|
2038 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2039 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
|
2040 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
2041 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
|
2042 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
2043 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2044 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
|
2045 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2046 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
|
2047 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2048 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2049 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2050 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
|
2051 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
|
2052 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2053 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2054 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
|
2055 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
|
2056 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2057 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
|
2058 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
|
2059 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
|
2060 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
|
2061 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
|
2062 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
|
2063 } |
2482
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
2064 } |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
2065 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
|
2066 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
2067 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2068 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
|
2069 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
|
2070 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2071 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2072 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
|
2073 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2074 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
|
2075 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
|
2076 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
|
2077 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
|
2078 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
|
2079 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
|
2080 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
|
2081 } |
2482
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
2082 } |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
2083 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
|
2084 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
2085 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2086 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
|
2087 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2088 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2089 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
|
2090 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
|
2091 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
|
2092 } 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
|
2093 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
|
2094 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
|
2095 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2096 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2097 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2098 |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2099 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
|
2100 { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
2101 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
|
2102 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2103 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2104 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
|
2105 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
|
2106 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
|
2107 } 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
|
2108 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
|
2109 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
|
2110 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2111 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2112 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
|
2113 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2114 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2115 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
|
2116 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
|
2117 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2118 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2119 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
|
2120 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2121 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
|
2122 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
|
2123 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
|
2124 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
|
2125 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
|
2126 val border = GradientDrawable() |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
2127 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2128 // 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
|
2129 // 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
|
2130 // 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
|
2131 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
|
2132 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
|
2133 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
|
2134 } |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
2135 } |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
2136 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
|
2137 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
2138 |
2510
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2139 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
|
2140 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2141 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
|
2142 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2143 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2144 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
|
2145 |
2701
9df2c11f020f
Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2694
diff
changeset
|
2146 mle = DWMLE(this) |
2510
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2147 mle!!.tag = dataArrayMap |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2148 mle!!.id = cid |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2149 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
|
2150 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
|
2151 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
|
2152 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
|
2153 mle!!.isVerticalScrollBarEnabled = true |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2154 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
|
2155 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
|
2156 mle!!.isHorizontalScrollBarEnabled = true |
2581
9dea42f27b0a
Android: MLE should have TOP/LEFT gravity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2580
diff
changeset
|
2157 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
|
2158 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2159 return mle |
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 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2162 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
|
2163 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2164 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2165 if (state != 0) { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2166 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
|
2167 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
|
2168 } else { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2169 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
|
2170 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
|
2171 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2172 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2173 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2174 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2175 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
|
2176 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2177 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
|
2178 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
|
2179 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2180 } |
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 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
|
2183 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2184 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2185 mle.setSelection(point) |
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 } |
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 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
|
2190 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2191 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2192 mle.setText("") |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2193 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2194 } |
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 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
|
2197 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2198 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
|
2199 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2200 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2201 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
|
2202 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
|
2203 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2204 if(startpoint < 1) { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2205 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
|
2206 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2207 mle.setText(newtext) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2208 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
|
2209 } 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
|
2210 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
|
2211 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2212 mle.setText(newtext) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2213 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
|
2214 } else { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2215 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
|
2216 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2217 mle.setText(newtext) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2218 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
|
2219 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2220 mle.setSelection(retval) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2221 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2222 return retval |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2223 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2224 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2225 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
|
2226 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2227 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2228 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
|
2229 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
|
2230 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2231 mle.setText(newtext) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2232 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2233 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
2234 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2235 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
|
2236 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2237 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
|
2238 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2239 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2240 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
|
2241 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
|
2242 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
|
2243 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
|
2244 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
|
2245 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2246 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
|
2247 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
|
2248 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
|
2249 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
|
2250 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
|
2251 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
|
2252 TabLayoutMediator(tabs, pager) { tab, position -> |
2692
231f9489a38a
Android: Keep a list of tab titles in the ViewPager2 adapter and set titles in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2691
diff
changeset
|
2253 val adapter = pager.adapter as DWTabViewPagerAdapter |
231f9489a38a
Android: Keep a list of tab titles in the ViewPager2 adapter and set titles in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2691
diff
changeset
|
2254 tab.text = adapter.titleList[position] |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2255 }.attach() |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
2256 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2257 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
|
2258 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
|
2259 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
|
2260 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2261 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
|
2262 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2263 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
|
2264 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
|
2265 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
|
2266 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
|
2267 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
|
2268 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
|
2269 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2270 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
|
2271 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2272 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
|
2273 // 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
|
2274 // 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
|
2275 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
|
2276 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
|
2277 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
|
2278 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
|
2279 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2280 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
|
2281 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
|
2282 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2283 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2284 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
|
2285 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
|
2286 }) |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
2287 } |
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
|
2288 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
|
2289 } |
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
|
2290 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2291 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
|
2292 { |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2293 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
|
2294 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2295 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2296 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
|
2297 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
|
2298 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2299 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
|
2300 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
|
2301 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
|
2302 } 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
|
2303 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
|
2304 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
|
2305 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2306 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2307 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
|
2308 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
|
2309 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
|
2310 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2311 // 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
|
2312 do { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2313 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
|
2314 } 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
|
2315 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
|
2316 // 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
|
2317 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
|
2318 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
|
2319 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
|
2320 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
|
2321 ) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2322 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
|
2323 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
|
2324 adapter.pageList.add(0, pageID) |
2692
231f9489a38a
Android: Keep a list of tab titles in the ViewPager2 adapter and set titles in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2691
diff
changeset
|
2325 adapter.titleList.add(0, null) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2326 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
|
2327 } else { |
2682
856d3c8b559f
Android: Fix an exception when displaying a notebook with a placeholder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2681
diff
changeset
|
2328 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
|
2329 adapter.pageList.add(pageID) |
2692
231f9489a38a
Android: Keep a list of tab titles in the ViewPager2 adapter and set titles in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2691
diff
changeset
|
2330 adapter.titleList.add(null) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2331 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
|
2332 } |
2691
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
2333 adapter.notifyDataSetChanged() |
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
|
2334 } |
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
|
2335 } |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2336 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
|
2337 } |
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
|
2338 |
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
|
2339 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
|
2340 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
|
2341 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
|
2342 } |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2343 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
|
2344 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
|
2345 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
|
2346 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
|
2347 } 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
|
2348 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
|
2349 } |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2350 } |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2351 } |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2352 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2353 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
|
2354 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2355 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2356 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
|
2357 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
|
2358 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2359 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
|
2360 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
|
2361 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
|
2362 } 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
|
2363 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
|
2364 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
|
2365 } |
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
|
2366 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2367 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
|
2368 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
|
2369 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
|
2370 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
|
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 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
|
2373 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
|
2374 adapter.pageList.removeAt(index) |
2692
231f9489a38a
Android: Keep a list of tab titles in the ViewPager2 adapter and set titles in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2691
diff
changeset
|
2375 adapter.titleList.removeAt(index) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2376 tabs.removeTab(tab) |
2691
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
2377 adapter.notifyDataSetChanged() |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2378 } |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2379 } |
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
|
2380 } |
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
|
2381 } |
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
|
2382 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2383 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
|
2384 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2385 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2386 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
|
2387 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
|
2388 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2389 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
|
2390 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
|
2391 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
|
2392 } 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
|
2393 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
|
2394 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
|
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 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2397 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
|
2398 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
|
2399 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
|
2400 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
|
2401 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2402 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
|
2403 tab.text = text |
2692
231f9489a38a
Android: Keep a list of tab titles in the ViewPager2 adapter and set titles in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2691
diff
changeset
|
2404 adapter.titleList[index] = text |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2405 } |
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
|
2406 |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
2407 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
|
2408 } |
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
|
2409 } |
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
|
2410 } |
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
|
2411 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2412 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
|
2413 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2414 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2415 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
|
2416 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
|
2417 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2418 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
|
2419 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
|
2420 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
|
2421 } 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
|
2422 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
|
2423 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
|
2424 } |
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
|
2425 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2426 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
|
2427 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
|
2428 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
|
2429 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2430 // 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
|
2431 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
|
2432 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
|
2433 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
|
2434 ) |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2435 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2436 adapter.viewList[index] = box |
2691
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
2437 adapter.notifyDataSetChanged() |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2438 } |
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
|
2439 } |
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
|
2440 } |
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
|
2441 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2442 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
|
2443 { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
2444 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
|
2445 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2446 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2447 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
|
2448 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
|
2449 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2450 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
|
2451 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
|
2452 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
|
2453 } 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
|
2454 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
|
2455 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
|
2456 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2457 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2458 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
|
2459 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
|
2460 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
|
2461 } |
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
|
2462 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2463 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
|
2464 } |
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
|
2465 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
2466 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
|
2467 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2468 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2469 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
|
2470 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
|
2471 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2472 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
|
2473 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
|
2474 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
|
2475 } 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
|
2476 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
|
2477 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
|
2478 } |
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
|
2479 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2480 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
|
2481 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
|
2482 val index = adapter.pageList.indexOf(pageID) |
2691
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
2483 |
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
2484 if (index > -1 && index < adapter.pageList.count()) { |
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
2485 tabs.setScrollPosition(index, 0F, true) |
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
2486 pager.setCurrentItem(index, true) |
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
2487 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2488 } |
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
|
2489 } |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
2490 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
2491 |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2492 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
|
2493 { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2494 var splitbar: ConstraintLayout? = null |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2495 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2496 waitOnUiThread { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2497 splitbar = ConstraintLayout(this) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2498 if(splitbar != null) { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2499 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
|
2500 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
|
2501 |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2502 constraintSet.clone(splitbar) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2503 |
2656
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2504 splitbar!!.tag = dataArrayMap |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2505 splitbar!!.id = cid |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2506 |
2656
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2507 // 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
|
2508 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
|
2509 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
|
2510 |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2511 // Place the top/left item |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2512 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
|
2513 if(topleft.id < 1) { |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2514 topleft.id = View.generateViewId() |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2515 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2516 splitbar!!.addView(topleft) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2517 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2518 topleft.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2519 ConstraintLayout.LayoutParams.TOP, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2520 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2521 ConstraintLayout.LayoutParams.TOP |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2522 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2523 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2524 topleft.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2525 ConstraintLayout.LayoutParams.LEFT, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2526 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2527 ConstraintLayout.LayoutParams.LEFT |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2528 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2529 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2530 if (type == 0) { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2531 // Horizontal |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2532 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2533 topleft.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2534 ConstraintLayout.LayoutParams.BOTTOM, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2535 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2536 ConstraintLayout.LayoutParams.BOTTOM |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2537 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2538 constraintSet.constrainPercentWidth(topleft.id, 0.5F) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2539 } else { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2540 // Vertical |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2541 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2542 topleft.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2543 ConstraintLayout.LayoutParams.RIGHT, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2544 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2545 ConstraintLayout.LayoutParams.RIGHT |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2546 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2547 constraintSet.constrainPercentHeight(topleft.id, 0.5F) |
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 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2551 // Place the bottom/right item |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2552 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
|
2553 if (bottomright.id < 1) { |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2554 bottomright.id = View.generateViewId() |
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 splitbar!!.addView(bottomright) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2557 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2558 bottomright.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2559 ConstraintLayout.LayoutParams.BOTTOM, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2560 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2561 ConstraintLayout.LayoutParams.BOTTOM |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2562 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2563 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2564 bottomright.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2565 ConstraintLayout.LayoutParams.RIGHT, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2566 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2567 ConstraintLayout.LayoutParams.RIGHT |
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 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2570 if (type == 0) { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2571 // Horizontal |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2572 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2573 bottomright.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2574 ConstraintLayout.LayoutParams.TOP, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2575 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2576 ConstraintLayout.LayoutParams.TOP |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2577 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2578 constraintSet.constrainPercentWidth(bottomright.id, 0.5F) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2579 } else { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2580 // Vertical |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2581 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2582 bottomright.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2583 ConstraintLayout.LayoutParams.LEFT, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2584 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2585 ConstraintLayout.LayoutParams.LEFT |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2586 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2587 constraintSet.constrainPercentHeight(bottomright.id, 0.5F) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2588 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2589 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2590 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2591 // 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
|
2592 constraintSet.applyTo(splitbar) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2593 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2594 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2595 return splitbar |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2596 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2597 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2598 fun splitBarGet(splitbar: ConstraintLayout): Float { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2599 var position: Float = 50.0F |
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 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
|
2602 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
|
2603 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
|
2604 |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2605 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
|
2606 percent = dataArrayMap.get("_dw_percent")!! |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2607 } |
2656
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2608 |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2609 position = percent.toFloat() / 1000000.0F |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2610 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2611 return position |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2612 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2613 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2614 fun splitBarSet(splitbar: ConstraintLayout, position: Float) { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2615 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
|
2616 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
|
2617 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
|
2618 |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2619 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
|
2620 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
|
2621 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
|
2622 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
|
2623 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
|
2624 |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2625 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
|
2626 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
|
2627 } |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
2628 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
|
2629 |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2630 constraintSet.clone(splitbar) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2631 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
|
2632 if (type == 1L) { |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2633 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
|
2634 } else { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2635 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
|
2636 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2637 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2638 if (bottomright != null) { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2639 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
|
2640 if (type == 1L) { |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2641 constraintSet.constrainPercentHeight(bottomright.id, altper) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2642 } else { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2643 constraintSet.constrainPercentWidth(bottomright.id, altper) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2644 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2645 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2646 constraintSet.applyTo(splitbar) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2647 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2648 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2649 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
2650 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2651 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
|
2652 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2653 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
|
2654 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2655 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2656 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
|
2657 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2658 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
|
2659 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
|
2660 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
|
2661 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
|
2662 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
|
2663 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
|
2664 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2665 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
|
2666 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
|
2667 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2668 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2669 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
|
2670 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2671 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2672 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
|
2673 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
|
2674 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2675 }) |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2676 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2677 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
|
2678 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2679 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2680 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
|
2681 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2682 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
|
2683 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2684 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2685 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
|
2686 |
2574
5b13bb267364
Android: Percent widget should be using horizontal ProgressBar.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2573
diff
changeset
|
2687 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
|
2688 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
|
2689 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
|
2690 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
|
2691 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2692 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
|
2693 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2694 |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2695 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
|
2696 { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
2697 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
|
2698 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2699 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2700 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
|
2701 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2702 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
|
2703 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2704 |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2705 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
|
2706 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2707 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2708 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
|
2709 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2710 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2711 |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2712 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
|
2713 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2714 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2715 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
|
2716 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2717 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2718 |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2719 fun htmlNew(cid: Int): WebView? |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2720 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2721 var html: WebView? = null |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2722 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2723 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2724 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
|
2725 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2726 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
|
2727 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
|
2728 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
|
2729 // 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
|
2730 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
|
2731 html!!.settings.javaScriptEnabled = true |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2732 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2733 return html |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2734 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2735 |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2736 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
|
2737 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2738 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2739 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
|
2740 } |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2741 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2742 |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2743 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
|
2744 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2745 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2746 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
|
2747 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
|
2748 } |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2749 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2750 |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2751 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
|
2752 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2753 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2754 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
|
2755 // 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
|
2756 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
|
2757 } |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2758 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2759 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2760 |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2761 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
|
2762 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2763 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2764 when (action) { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2765 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
|
2766 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
|
2767 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
|
2768 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
|
2769 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
|
2770 } |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2771 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2772 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
2773 |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2774 fun spinButtonNew(text: String, cid: Int): DWSpinButton? |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2775 { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2776 var spinbutton: DWSpinButton? = null |
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 waitOnUiThread { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
2779 val dataArrayMap = SimpleArrayMap<String, Long>() |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2780 val newval = text.toLongOrNull() |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2781 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2782 spinbutton = DWSpinButton(this) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2783 spinbutton!!.tag = dataArrayMap |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2784 spinbutton!!.id = cid |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2785 spinbutton!!.setText(text) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2786 if(newval != null) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2787 spinbutton!!.value = newval |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2788 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2789 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2790 return spinbutton |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2791 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2792 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2793 fun spinButtonSetPos(spinbutton: DWSpinButton, position: Long) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2794 { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2795 waitOnUiThread { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2796 spinbutton.value = position |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2797 spinbutton.setText(position.toString()) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2798 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2799 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2800 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2801 fun spinButtonSetLimits(spinbutton: DWSpinButton, upper: Long, lower: Long) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2802 { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2803 waitOnUiThread { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2804 spinbutton.maximum = upper |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2805 spinbutton.minimum = lower |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2806 if(spinbutton.value > upper) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2807 spinbutton.value = upper |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2808 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2809 if(spinbutton.value < lower) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2810 spinbutton.value = lower |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2811 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2812 spinbutton.setText(spinbutton.value.toString()) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2813 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2814 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2815 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2816 fun spinButtonGetPos(spinbutton: DWSpinButton): Long |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2817 { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2818 var retval: Long = 0 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2819 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2820 waitOnUiThread { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2821 val newvalue = spinbutton.text.toString().toLongOrNull() |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2822 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2823 if(newvalue == null) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2824 retval = spinbutton.value |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2825 } else { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2826 retval = newvalue |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2827 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2828 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2829 return retval |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2830 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
2831 |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
2832 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
|
2833 { |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
2834 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
|
2835 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
2836 waitOnUiThread { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
2837 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
|
2838 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
2839 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
|
2840 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
|
2841 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
|
2842 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
|
2843 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
2844 return combobox |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
2845 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
2846 |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2847 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
|
2848 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2849 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
|
2850 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2851 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2852 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
|
2853 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
|
2854 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2855 cont = ListView(this) |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2856 cont!!.tag = dataArrayMap |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2857 cont!!.id = cid |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2858 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
|
2859 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
|
2860 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
|
2861 } |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2862 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
|
2863 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
|
2864 val data = adapter.model.getRowData(position) |
2613
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2865 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
|
2866 |
2563
56183bef6793
Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2562
diff
changeset
|
2867 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
|
2868 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
|
2869 lastClickView = cont!! |
2613
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2870 // 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
|
2871 // Generate an ENTER event |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2872 if(cont!!.choiceMode != ListView.CHOICE_MODE_MULTIPLE || |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2873 (position == adapter.lastClickRow && |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2874 (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
|
2875 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
|
2876 } else { |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2877 // 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
|
2878 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
|
2879 } |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2880 adapter.lastClick = now |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2881 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
|
2882 } |
56183bef6793
Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2562
diff
changeset
|
2883 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
|
2884 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
|
2885 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
|
2886 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
|
2887 |
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
|
2888 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
|
2889 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
|
2890 } |
56183bef6793
Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2562
diff
changeset
|
2891 true |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2892 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2893 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
|
2894 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
|
2895 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
|
2896 |
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
|
2897 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
|
2898 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
|
2899 true |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2900 } |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2901 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2902 return cont |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2903 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2904 |
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
|
2905 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
|
2906 { |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2907 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
|
2908 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
|
2909 |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2910 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
|
2911 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
|
2912 } 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
|
2913 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
|
2914 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
|
2915 } 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
|
2916 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
|
2917 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2918 } 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
|
2919 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
|
2920 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2921 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
|
2922 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
|
2923 } 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
|
2924 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
|
2925 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2926 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2927 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2928 |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2929 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
|
2930 { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2931 var retval: String? = null |
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 waitOnUiThread { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2934 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
|
2935 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2936 // Handle DW_CRA_SELECTED |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2937 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
|
2938 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
|
2939 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
|
2940 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2941 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
|
2942 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
|
2943 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2944 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
|
2945 adapter.model.querypos = -1 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2946 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2947 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
|
2948 adapter.model.querypos = 0 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2949 } |
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 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2952 return retval |
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 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2955 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
|
2956 { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2957 var retval: String? = null |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2958 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2959 waitOnUiThread { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2960 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
|
2961 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2962 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
|
2963 // Handle DW_CRA_SELECTED |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2964 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
|
2965 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
|
2966 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2967 // 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
|
2968 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
|
2969 // Item position in adapter |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2970 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
|
2971 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2972 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
|
2973 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
|
2974 |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2975 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
|
2976 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
|
2977 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2978 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2979 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2980 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
|
2981 adapter.model.querypos += 1 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2982 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
|
2983 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2984 adapter.model.querypos = -1 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2985 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2986 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2987 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2988 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2989 return retval |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2990 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2991 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2992 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
|
2993 { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2994 var retval: Long = 0 |
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 waitOnUiThread { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2997 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
|
2998 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
2999 // Handle DW_CRA_SELECTED |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3000 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
|
3001 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
|
3002 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
|
3003 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3004 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
|
3005 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
|
3006 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3007 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
|
3008 adapter.model.querypos = -1 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3009 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3010 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
|
3011 adapter.model.querypos = 0 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3012 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3013 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3014 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3015 return retval |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3016 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3017 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3018 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
|
3019 { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3020 var retval: Long = 0 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3021 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3022 waitOnUiThread { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3023 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
|
3024 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3025 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
|
3026 // Handle DW_CRA_SELECTED |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3027 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
|
3028 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
|
3029 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3030 // 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
|
3031 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
|
3032 // Item position in adapter |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3033 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
|
3034 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3035 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
|
3036 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
|
3037 |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3038 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
|
3039 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
|
3040 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3041 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3042 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3043 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
|
3044 adapter.model.querypos += 1 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3045 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
|
3046 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3047 adapter.model.querypos = -1 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3048 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3049 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3050 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3051 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3052 return retval |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3053 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
3054 |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3055 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
|
3056 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3057 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3058 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
|
3059 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3060 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
|
3061 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3062 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3063 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3064 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
|
3065 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3066 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3067 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
|
3068 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
|
3069 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3070 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
|
3071 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3072 return cont |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3073 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3074 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3075 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
|
3076 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3077 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3078 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
|
3079 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3080 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
|
3081 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3082 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3083 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3084 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
|
3085 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3086 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3087 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
|
3088 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3089 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
|
3090 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3091 } |
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 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
|
3094 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3095 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3096 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
|
3097 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3098 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
|
3099 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3100 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3101 |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3102 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
|
3103 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3104 waitOnUiThread { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3105 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
|
3106 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3107 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
|
3108 } |
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 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3111 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
|
3112 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3113 waitOnUiThread { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3114 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
|
3115 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3116 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
|
3117 } |
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 |
2561
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
3120 fun containerRefresh(cont: ListView) |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
3121 { |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
3122 waitOnUiThread { |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
3123 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
|
3124 |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
3125 adapter.notifyDataSetChanged() |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
3126 } |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
3127 } |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
3128 |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3129 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
|
3130 { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
3131 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
|
3132 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3133 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3134 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
|
3135 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3136 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
|
3137 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3138 return type |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3139 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3140 |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3141 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
|
3142 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3143 waitOnUiThread { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3144 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
|
3145 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3146 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
|
3147 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3148 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3149 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3150 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
|
3151 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3152 waitOnUiThread { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3153 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
|
3154 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3155 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
|
3156 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3157 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3158 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3159 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
|
3160 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3161 waitOnUiThread { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3162 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
|
3163 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3164 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
|
3165 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3166 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
3167 |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3168 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
|
3169 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3170 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3171 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
|
3172 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3173 adapter.model.clear() |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3174 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3175 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
3176 |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3177 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
|
3178 { |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3179 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
|
3180 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3181 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3182 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
|
3183 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3184 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
|
3185 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
|
3186 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
|
3187 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
|
3188 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
|
3189 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3190 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3191 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
|
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 |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
3194 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
|
3195 { |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
3196 waitOnUiThread { |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
3197 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
|
3198 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
|
3199 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
3200 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
|
3201 } 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
|
3202 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
|
3203 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3204 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
|
3205 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
|
3206 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
|
3207 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
3208 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
3209 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
3210 |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3211 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
|
3212 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3213 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3214 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
|
3215 val combobox = window |
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 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
|
3218 } 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
|
3219 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
|
3220 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3221 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
|
3222 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
|
3223 adapter.notifyDataSetChanged() |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3224 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3225 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3226 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3227 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3228 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
|
3229 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3230 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3231 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
|
3232 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3233 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3234 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
|
3235 } 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
|
3236 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
|
3237 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3238 listbox.list.clear() |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
3239 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
|
3240 adapter.notifyDataSetChanged() |
2517
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 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3243 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3244 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3245 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
|
3246 { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
3247 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
|
3248 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3249 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3250 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
|
3251 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3252 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3253 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
|
3254 } 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
|
3255 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
|
3256 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3257 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
|
3258 } |
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 return retval |
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 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3263 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
|
3264 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3265 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3266 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
|
3267 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3268 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3269 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
|
3270 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
|
3271 } 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
|
3272 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
|
3273 |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
3274 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
|
3275 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
|
3276 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
|
3277 adapter.notifyDataSetChanged() |
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
3278 } |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3279 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3280 } |
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 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3283 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
|
3284 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3285 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
|
3286 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3287 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3288 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
|
3289 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3290 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3291 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
|
3292 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
|
3293 } 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
|
3294 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
|
3295 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3296 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
|
3297 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
|
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 return retval |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3301 } |
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 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
|
3304 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3305 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
|
3306 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3307 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3308 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
|
3309 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3310 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3311 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
|
3312 } 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
|
3313 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
|
3314 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3315 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
|
3316 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3317 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3318 return retval |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3319 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3320 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3321 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
|
3322 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3323 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3324 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
|
3325 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3326 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3327 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
|
3328 combobox.selected = index |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3329 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
|
3330 } |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3331 } 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
|
3332 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
|
3333 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3334 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
|
3335 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
|
3336 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
|
3337 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
|
3338 } else { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
3339 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
|
3340 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3341 } |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3342 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3343 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3344 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3345 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3346 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
|
3347 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3348 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3349 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
|
3350 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3351 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3352 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
|
3353 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
|
3354 } |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3355 } 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
|
3356 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
|
3357 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3358 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
|
3359 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
|
3360 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
|
3361 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
|
3362 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3363 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3364 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3365 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3366 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3367 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
|
3368 { |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3369 waitOnUiThread { |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3370 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
|
3371 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
|
3372 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
3373 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
|
3374 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
|
3375 } |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3376 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3377 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3378 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
3379 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3380 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
|
3381 { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3382 var retval: Int = -1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3383 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3384 waitOnUiThread { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3385 if(window is DWListBox) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3386 val listbox = window |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3387 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
|
3388 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3389 // 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
|
3390 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
|
3391 retval = checked.keyAt(0) |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3392 } else { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3393 // 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
|
3394 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
|
3395 // Item position in adapter |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3396 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
|
3397 // 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
|
3398 // 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
|
3399 // 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
|
3400 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
|
3401 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
|
3402 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3403 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3404 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3405 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3406 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3407 return retval |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3408 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3409 |
2523
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3410 fun calendarNew(cid: Int): CalendarView? |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3411 { |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3412 var calendar: CalendarView? = null |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3413 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3414 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3415 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
|
3416 |
2523
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3417 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
|
3418 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
|
3419 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
|
3420 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
|
3421 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
|
3422 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
|
3423 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
|
3424 } |
2523
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3425 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3426 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3427 return calendar |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3428 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3429 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3430 fun calendarSetDate(calendar: CalendarView, date: Long) |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3431 { |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3432 waitOnUiThread { |
2524
d5c3c573c74e
Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2523
diff
changeset
|
3433 // 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
|
3434 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
|
3435 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3436 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3437 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3438 fun calendarGetDate(calendar: CalendarView): Long |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3439 { |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3440 var date: Long = 0 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3441 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3442 waitOnUiThread { |
2524
d5c3c573c74e
Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2523
diff
changeset
|
3443 // 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
|
3444 date = calendar.date / 1000 |
2523
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3445 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3446 return date |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3447 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
3448 |
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
|
3449 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
|
3450 { |
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
|
3451 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
|
3452 |
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
|
3453 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3454 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
|
3455 |
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
|
3456 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
|
3457 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
|
3458 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
|
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 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
|
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 |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3464 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
|
3465 { |
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 waitOnUiThread { |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3467 var filename: String? = file |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3468 |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3469 if(resID > 0 && resID < 65536) { |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3470 filename = resID.toString() |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3471 } else if(resID != 0) { |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3472 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
|
3473 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
|
3474 |
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 button.setImageResource(resID) |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3476 } 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
|
3477 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
|
3478 |
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 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
|
3480 } |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3481 } |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3482 if(filename != null) { |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
3483 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
|
3484 // 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
|
3485 try { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3486 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
|
3487 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
|
3488 |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3489 if(b != null) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3490 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
|
3491 val button = window |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3492 |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3493 button.setImageBitmap(b) |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3494 } 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
|
3495 val imageview = window |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3496 |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3497 imageview.setImageBitmap(b) |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3498 } |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3499 break |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3500 } |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3501 } 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
|
3502 } |
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
|
3503 } |
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
|
3504 } |
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
|
3505 } |
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
|
3506 } |
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
|
3507 |
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
|
3508 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
|
3509 { |
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
|
3510 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
|
3511 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
|
3512 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
|
3513 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
|
3514 |
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
|
3515 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
|
3516 } 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
|
3517 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
|
3518 |
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
|
3519 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
|
3520 } |
2655
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3521 } |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3522 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
|
3523 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
|
3524 |
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
|
3525 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
|
3526 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
|
3527 |
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
|
3528 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
|
3529 } 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
|
3530 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
|
3531 |
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
|
3532 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
|
3533 } |
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
|
3534 } |
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
|
3535 } |
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
|
3536 } |
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
|
3537 |
2652
42151fd096d4
Android: Switch to loading resource images like we do on iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2651
diff
changeset
|
3538 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
|
3539 { |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3540 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
|
3541 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3542 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
|
3543 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
|
3544 |
42151fd096d4
Android: Switch to loading resource images like we do on iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2651
diff
changeset
|
3545 // 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
|
3546 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
|
3547 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
|
3548 // 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
|
3549 } 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
|
3550 try { |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3551 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
|
3552 } 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
|
3553 } |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3554 // 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
|
3555 } 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
|
3556 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
|
3557 } else { |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3558 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
|
3559 } |
42151fd096d4
Android: Switch to loading resource images like we do on iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2651
diff
changeset
|
3560 // 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
|
3561 // 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
|
3562 if(filename != null) { |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
3563 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
|
3564 // 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
|
3565 try { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3566 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
|
3567 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
|
3568 } catch (e: IOException) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3569 } |
2652
42151fd096d4
Android: Switch to loading resource images like we do on iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2651
diff
changeset
|
3570 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
|
3571 break |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3572 } |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3573 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3574 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3575 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3576 return icon |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3577 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3578 |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3579 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
|
3580 { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3581 var pixmap: Bitmap? = null |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3582 |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3583 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
|
3584 var filename: String? = null |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3585 |
2529
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3586 if(width > 0 && height > 0) { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3587 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
|
3588 } 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
|
3589 filename = resID.toString() |
2529
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3590 } 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
|
3591 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
|
3592 } 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
|
3593 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
|
3594 } else { |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
3595 filename = file |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3596 } |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
3597 if(filename != null) { |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
3598 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
|
3599 // 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
|
3600 try { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3601 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
|
3602 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
|
3603 } catch (e: IOException) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3604 } |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3605 if(pixmap != null) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3606 break |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3607 } |
2529
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3608 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3609 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3610 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3611 return pixmap |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3612 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3613 |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3614 fun pixmapGetDimensions(pixmap: Bitmap): Long |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3615 { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3616 var dimensions: Long = 0 |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3617 |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3618 waitOnUiThread { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3619 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
|
3620 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3621 return dimensions |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3622 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
3623 |
2542
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
3624 fun screenGetDimensions(): Long |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
3625 { |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
3626 val dm = resources.displayMetrics |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
3627 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
|
3628 } |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
3629 |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3630 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
|
3631 { |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3632 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
|
3633 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3634 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3635 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
|
3636 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3637 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
|
3638 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
|
3639 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
|
3640 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
|
3641 @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
|
3642 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
|
3643 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
|
3644 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
|
3645 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
|
3646 render!!.evy = event.y |
2611
ed2c4a503666
Android: Implement button release and motion notify events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2608
diff
changeset
|
3647 // 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
|
3648 // 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
|
3649 } |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3650 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
|
3651 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
|
3652 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
|
3653 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
|
3654 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
|
3655 } |
ed2c4a503666
Android: Implement button release and motion notify events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2608
diff
changeset
|
3656 MotionEvent.ACTION_MOVE -> { |
ed2c4a503666
Android: Implement button release and motion notify events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2608
diff
changeset
|
3657 render!!.evx = event.x |
ed2c4a503666
Android: Implement button release and motion notify events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2608
diff
changeset
|
3658 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
|
3659 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
|
3660 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
|
3661 } |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3662 } |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3663 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
|
3664 } |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3665 }) |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3666 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
|
3667 // 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
|
3668 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
|
3669 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
|
3670 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
|
3671 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
|
3672 } |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
3673 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
|
3674 // 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
|
3675 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
|
3676 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
|
3677 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
|
3678 } |
2596
60ec91d23746
Android: Add initial keyboard support for Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2595
diff
changeset
|
3679 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
|
3680 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
|
3681 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
|
3682 } |
60ec91d23746
Android: Add initial keyboard support for Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2595
diff
changeset
|
3683 false |
60ec91d23746
Android: Add initial keyboard support for Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2595
diff
changeset
|
3684 }) |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3685 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3686 return render |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3687 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3688 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3689 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
|
3690 { |
2539
822f814a54f4
Android: Fix memory corruption issue due to incorrectly allocating HPIXMAP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2538
diff
changeset
|
3691 runOnUiThread { |
822f814a54f4
Android: Fix memory corruption issue due to incorrectly allocating HPIXMAP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2538
diff
changeset
|
3692 render.invalidate() |
822f814a54f4
Android: Fix memory corruption issue due to incorrectly allocating HPIXMAP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2538
diff
changeset
|
3693 } |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3694 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
3695 |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3696 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
|
3697 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
|
3698 { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3699 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
|
3700 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
|
3701 var retval = 1 |
2531
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 if(srcw == -1) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3704 src.right = srcx + dstw |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3705 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3706 if(srch == -1) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3707 src.bottom = srcy + dsth |
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 waitOnUiThread { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3711 var canvas: Canvas? = null |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3712 var bitmap: Bitmap? = null |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3713 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3714 if(dstr != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3715 canvas = dstr.cachedCanvas |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3716 } else if(dstp != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3717 canvas = Canvas(dstp) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3718 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3719 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3720 if(srcp != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3721 bitmap = srcp |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3722 } else if(srcr != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3723 bitmap = Bitmap.createBitmap(srcr.layoutParams.width, |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3724 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
|
3725 val c = Canvas(bitmap) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3726 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
|
3727 srcr.draw(c) |
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 if(canvas != null && bitmap != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3731 canvas.drawBitmap(bitmap, src, dst, null) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3732 retval = 0 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3733 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3734 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3735 return retval |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3736 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3737 |
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
|
3738 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
|
3739 { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3740 waitOnUiThread { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3741 var canvas: Canvas? = null |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3742 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3743 if(render != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3744 canvas = render.cachedCanvas |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3745 } else if(bitmap != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3746 canvas = Canvas(bitmap) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3747 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3748 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3749 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
|
3750 colorsSet(fgColor, bgColor) |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3751 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
|
3752 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3753 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3754 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3755 |
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
|
3756 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
|
3757 { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3758 waitOnUiThread { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3759 var canvas: Canvas? = null |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3760 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3761 if(render != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3762 canvas = render.cachedCanvas |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3763 } else if(bitmap != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3764 canvas = Canvas(bitmap) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3765 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3766 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3767 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
|
3768 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
|
3769 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
|
3770 paint.style = Paint.Style.STROKE |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3771 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
|
3772 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3773 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3774 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
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 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
|
3777 { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3778 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
|
3779 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3780 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3781 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
|
3782 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3783 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
|
3784 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
|
3785 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
|
3786 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
|
3787 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
|
3788 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3789 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3790 } 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
|
3791 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
|
3792 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
|
3793 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
|
3794 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
|
3795 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3796 } 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
|
3797 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
|
3798 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3799 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
|
3800 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
|
3801 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
|
3802 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
|
3803 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3804 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3805 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3806 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3807 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
|
3808 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
|
3809 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
|
3810 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
|
3811 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3812 return dimensions |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3813 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3814 |
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
|
3815 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
|
3816 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
|
3817 { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3818 waitOnUiThread { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3819 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
|
3820 |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3821 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
|
3822 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
|
3823 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
|
3824 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
|
3825 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
|
3826 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
|
3827 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3828 } |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3829 } 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
|
3830 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
|
3831 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
|
3832 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
|
3833 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
|
3834 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
|
3835 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3836 } 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
|
3837 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
|
3838 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3839 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
|
3840 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
|
3841 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
|
3842 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
|
3843 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3844 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3845 } |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3846 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3847 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3848 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
|
3849 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
|
3850 // 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
|
3851 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
|
3852 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
|
3853 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
|
3854 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
|
3855 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
|
3856 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
|
3857 if(bgcolor != null) { |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3858 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
|
3859 // 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
|
3860 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
|
3861 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
|
3862 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
|
3863 rect.left += x |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3864 rect.right += x |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3865 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
|
3866 // 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
|
3867 paint.color = oldcolor |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
3868 } |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3869 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
|
3870 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
|
3871 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3872 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3873 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3874 |
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
|
3875 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
|
3876 { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3877 waitOnUiThread { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3878 var canvas: Canvas? = null |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3879 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3880 if(render != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3881 canvas = render.cachedCanvas |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3882 } else if(bitmap != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3883 canvas = Canvas(bitmap) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3884 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3885 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3886 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
|
3887 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
|
3888 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
|
3889 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
|
3890 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
|
3891 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3892 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3893 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
3894 |
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
|
3895 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
|
3896 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
|
3897 { |
2537
cd9d2ba251d5
Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2536
diff
changeset
|
3898 // 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
|
3899 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
|
3900 |
2537
cd9d2ba251d5
Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2536
diff
changeset
|
3901 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
|
3902 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
|
3903 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
|
3904 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3905 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3906 waitOnUiThread { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3907 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
|
3908 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3909 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
|
3910 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
|
3911 } 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
|
3912 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
|
3913 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3914 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3915 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
|
3916 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
|
3917 // 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
|
3918 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
|
3919 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
|
3920 } else { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3921 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
|
3922 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3923 // 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
|
3924 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
|
3925 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
|
3926 } else { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3927 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
|
3928 } |
2537
cd9d2ba251d5
Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2536
diff
changeset
|
3929 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
|
3930 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3931 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3932 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3933 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3934 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
|
3935 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
|
3936 { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3937 waitOnUiThread { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3938 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
|
3939 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3940 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
|
3941 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
|
3942 } 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
|
3943 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
|
3944 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3945 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3946 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
|
3947 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
|
3948 |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3949 // 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
|
3950 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
|
3951 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
|
3952 } else { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3953 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
|
3954 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3955 // 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
|
3956 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
|
3957 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
|
3958 } else { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3959 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
|
3960 } |
2536
d172ab2eddb6
Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2535
diff
changeset
|
3961 // 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
|
3962 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
|
3963 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
|
3964 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
|
3965 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
|
3966 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
|
3967 |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3968 if(x2 < x1) { |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3969 left = x2.toFloat() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3970 right = x1.toFloat() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3971 } |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3972 if(y2 < y1) { |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3973 top = y2.toFloat() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3974 bottom = y1.toFloat() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3975 } |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3976 |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3977 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
|
3978 } else { |
2576
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3979 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
|
3980 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
|
3981 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
|
3982 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
|
3983 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
|
3984 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
|
3985 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
|
3986 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
|
3987 |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3988 // Convert to degrees |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
3989 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
|
3990 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
|
3991 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
|
3992 |
2536
d172ab2eddb6
Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2535
diff
changeset
|
3993 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
|
3994 } |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3995 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3996 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3997 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
3998 |
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
|
3999 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
|
4000 { |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
4001 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
|
4002 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
|
4003 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
|
4004 |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
4005 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
|
4006 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
4007 |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
4008 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
|
4009 { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
4010 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
|
4011 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
|
4012 if(bgColor != -1L) { |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
4013 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
|
4014 } else { |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
4015 this.bgcolor = null |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
4016 } |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
4017 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
4018 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
4019 |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4020 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
|
4021 { |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4022 // creating timer task, timer |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4023 val t = Timer() |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4024 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
|
4025 override fun run() { |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4026 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
|
4027 t.cancel() |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4028 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4029 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4030 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4031 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
|
4032 return t |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4033 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4034 |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4035 fun timerDisconnect(timer: Timer) |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4036 { |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4037 timer.cancel() |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4038 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4039 |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4040 fun doBeep(duration: Int) |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4041 { |
2491
bf4fe6bb512b
Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2490
diff
changeset
|
4042 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
|
4043 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
|
4044 val handler = Handler(Looper.getMainLooper()) |
bf4fe6bb512b
Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2490
diff
changeset
|
4045 handler.postDelayed({ |
bf4fe6bb512b
Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2490
diff
changeset
|
4046 toneGen.release() |
bf4fe6bb512b
Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2490
diff
changeset
|
4047 }, (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
|
4048 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
4049 |
2482
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
4050 fun debugMessage(text: String) |
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
4051 { |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
4052 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
|
4053 } |
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
4054 |
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
|
4055 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
|
4056 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
|
4057 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
|
4058 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
|
4059 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
|
4060 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
|
4061 } 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
|
4062 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
|
4063 } |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4064 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
|
4065 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
|
4066 } |
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
|
4067 } |
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
|
4068 |
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
|
4069 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
|
4070 { |
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
|
4071 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
|
4072 |
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
|
4073 // 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
|
4074 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
|
4075 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
|
4076 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
|
4077 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
|
4078 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
|
4079 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
|
4080 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
|
4081 } |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4082 |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4083 // 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
|
4084 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
|
4085 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
|
4086 |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
4087 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
|
4088 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
|
4089 } |
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
|
4090 } |
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
|
4091 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
|
4092 } |
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
|
4093 |
2526
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4094 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
|
4095 { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4096 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
|
4097 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4098 waitOnUiThread { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4099 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
|
4100 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
|
4101 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
|
4102 // 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
|
4103 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
|
4104 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
|
4105 } |
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
|
4106 }) |
2526
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4107 if(ext != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4108 fc.setExtension(ext) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4109 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4110 fc.showDialog() |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4111 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4112 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4113 // 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
|
4114 try { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4115 Looper.loop() |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4116 } catch (e2: RuntimeException) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4117 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4118 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4119 return retval |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4120 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
4121 |
2486
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
4122 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
|
4123 { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4124 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
|
4125 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4126 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4127 // 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
|
4128 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
|
4129 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4130 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
|
4131 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
|
4132 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
|
4133 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
|
4134 ) |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4135 //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
|
4136 { _: DialogInterface, _: Int -> |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4137 retval = 1 |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4138 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
|
4139 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4140 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4141 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
|
4142 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
|
4143 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
|
4144 ) { _: DialogInterface, _: Int -> |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4145 retval = 0 |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4146 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
|
4147 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4148 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4149 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
|
4150 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
|
4151 ) |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4152 //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
|
4153 { _: DialogInterface, _: Int -> |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4154 retval = 0 |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4155 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
|
4156 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4157 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4158 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
|
4159 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
|
4160 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
|
4161 ) { _: DialogInterface, _: Int -> |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4162 retval = 2 |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4163 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
|
4164 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4165 } |
2573
ea75e295025b
Android: Make message boxes modal (not cancelable).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2572
diff
changeset
|
4166 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
|
4167 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
|
4168 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4169 // 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
|
4170 try { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4171 Looper.loop() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4172 } 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
|
4173 } |
2486
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
4174 } |
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
4175 return retval |
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
4176 } |
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
4177 |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
4178 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
|
4179 { |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
4180 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
|
4181 return true |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
4182 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
4183 return false |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
4184 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
4185 |
2514
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4186 fun mainSleep(milliseconds: Int) |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4187 { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4188 // 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
|
4189 // 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
|
4190 // 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
|
4191 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
|
4192 val starttime = System.currentTimeMillis() |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4193 |
2637
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
4194 // 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
|
4195 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
|
4196 var thrown: Boolean = false |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4197 |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4198 override fun queueIdle(): Boolean { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4199 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
|
4200 if (thrown == false) { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4201 thrown = true |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4202 throw java.lang.RuntimeException() |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4203 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4204 return false |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4205 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4206 return true |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4207 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4208 }) |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4209 |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4210 // 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
|
4211 try { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4212 Looper.loop() |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4213 } catch (e2: RuntimeException) { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4214 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4215 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4216 else |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4217 { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4218 // 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
|
4219 Thread.sleep(milliseconds.toLong()) |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4220 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4221 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
4222 |
2487
83f8f4f58a98
Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2486
diff
changeset
|
4223 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
|
4224 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4225 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4226 this.finishAffinity() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4227 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
|
4228 } |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
4229 } |
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
4230 |
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
4231 fun dwindowsShutdown() |
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
4232 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4233 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4234 this.finishAffinity() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4235 } |
2487
83f8f4f58a98
Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2486
diff
changeset
|
4236 } |
83f8f4f58a98
Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2486
diff
changeset
|
4237 |
2542
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
4238 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
|
4239 { |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
4240 appID = appid |
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
4241 |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4242 waitOnUiThread { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4243 // 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
|
4244 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
|
4245 // Create the NotificationChannel |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4246 val importance = NotificationManager.IMPORTANCE_DEFAULT |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4247 val mChannel = NotificationChannel(appid, appname, importance) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4248 // 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
|
4249 // or other notification behaviors after this |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4250 val notificationManager = |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4251 getSystemService(NOTIFICATION_SERVICE) as NotificationManager |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4252 notificationManager.createNotificationChannel(mChannel) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4253 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4254 } |
2542
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
4255 return Build.VERSION.SDK_INT |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
4256 } |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
4257 |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
4258 fun dwMain() |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
4259 { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
4260 runOnUiThread { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
4261 // 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
|
4262 invalidateOptionsMenu() |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
4263 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
4264 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
4265 |
2542
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
4266 fun androidGetRelease(): String |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
4267 { |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
4268 return Build.VERSION.RELEASE |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4269 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4270 |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4271 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
|
4272 { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4273 var builder: NotificationCompat.Builder? = null |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4274 |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4275 waitOnUiThread { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4276 builder = NotificationCompat.Builder(this, appid) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4277 .setContentTitle(title) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4278 .setContentText(text) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4279 .setPriority(NotificationCompat.PRIORITY_DEFAULT) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4280 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4281 return builder |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4282 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4283 |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4284 fun notificationSend(builder: NotificationCompat.Builder) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4285 { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4286 waitOnUiThread { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4287 notificationID += 1 |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4288 with(NotificationManagerCompat.from(this)) { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4289 // 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
|
4290 notify(notificationID, builder.build()) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4291 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4292 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4293 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
4294 |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
4295 /* |
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
|
4296 * 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
|
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 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
|
4299 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
|
4300 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
|
4301 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
|
4302 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
|
4303 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
|
4304 } 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
|
4305 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
|
4306 } |
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 } 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
|
4308 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
|
4309 } 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
|
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 // 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
|
4312 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
|
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 // 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
|
4315 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
|
4316 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
|
4317 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
|
4318 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
|
4319 // 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
|
4320 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
|
4321 |
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 // 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
|
4323 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
|
4324 |
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 // 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
|
4326 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
|
4327 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
|
4328 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
|
4329 } 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
|
4330 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
|
4331 } 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
|
4332 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
|
4333 } |
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 |
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 // 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
|
4336 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
|
4337 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
|
4338 } |
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 } 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
|
4340 // 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
|
4341 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
|
4342 |
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 // 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
|
4344 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
|
4345 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
|
4346 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
|
4347 } 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
|
4348 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
|
4349 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
|
4350 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
|
4351 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
|
4352 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
|
4353 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
|
4354 .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
|
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 } |
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 } |
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 } |
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 } |
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 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
|
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 |
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 /* 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
|
4364 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
|
4365 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
|
4366 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
|
4367 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
|
4368 } |
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 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
|
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 |
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 /* 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
|
4373 * 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
|
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 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
|
4376 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
|
4377 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
|
4378 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
|
4379 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
|
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 } |
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 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
|
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 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
|
4387 * 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
|
4388 */ |
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 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
|
4390 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
|
4391 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
|
4392 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
|
4393 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
|
4394 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
|
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 } |
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 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
|
4398 } |
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 |
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 |
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 /* 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
|
4402 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
|
4403 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
|
4404 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
|
4405 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
|
4406 } |
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 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
|
4408 } |
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 |
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 /* 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
|
4411 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
|
4412 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
|
4413 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
|
4414 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
|
4415 } |
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 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
|
4417 } |
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 |
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 * 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
|
4421 */ |
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 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
|
4423 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
|
4424 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
|
4425 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
|
4426 } |
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 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
|
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 * 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
|
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 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
|
4434 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
|
4435 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
|
4436 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
|
4437 } |
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
|
4438 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
|
4439 } |
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
|
4440 |
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
|
4441 /* 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
|
4442 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
|
4443 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
|
4444 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
|
4445 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
|
4446 ): 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
|
4447 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
|
4448 |
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
|
4449 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
|
4450 // 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
|
4451 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
|
4452 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
|
4453 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
|
4454 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
|
4455 |
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
|
4456 // 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
|
4457 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
|
4458 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
|
4459 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
|
4460 } 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
|
4461 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
|
4462 } 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
|
4463 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
|
4464 } |
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
|
4465 |
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
|
4466 // 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
|
4467 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
|
4468 |
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
|
4469 // 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
|
4470 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
|
4471 // 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
|
4472 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
|
4473 } |
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
|
4474 } |
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
|
4475 } |
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
|
4476 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
|
4477 } |
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
|
4478 |
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
|
4479 /* |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
4480 * 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
|
4481 * 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
|
4482 */ |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
4483 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
|
4484 external fun eventHandler( |
2499
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4485 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
|
4486 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
|
4487 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
|
4488 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
|
4489 str2: String?, |
2499
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4490 inta: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4491 intb: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4492 intc: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4493 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
|
4494 ): Int |
2499
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4495 external fun eventHandlerInt( |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4496 obj1: View, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4497 message: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4498 inta: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4499 intb: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4500 intc: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4501 intd: Int |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
4502 ) |
2483
9f7af6d8c6a4
Android: Fix signal handlers so they actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2482
diff
changeset
|
4503 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
|
4504 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
|
4505 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
|
4506 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
|
4507 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
|
4508 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
|
4509 |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
4510 companion object |
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
4511 { |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4512 // 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
|
4513 init |
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
4514 { |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4515 System.loadLibrary("dwindows") |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4516 } |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4517 } |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4518 } |